• Aucun résultat trouvé

Changing the Error Pattern Detection Circuit

Dans le document Error Correction Coding (Page 195-200)

4.1 1 Syndrome Decoding

Method 2: Changing the Error Pattern Detection Circuit

Another way to modify the decoder is to change the error pattern detection circuit so that it looks for patterns corresponding to the shifted input, but still retains the usual syndrome computation circuit. The error pattern detection circuit is designed to produce a 1 when the syndrome register corresponds to a correctable error pattern e ( x ) with an error at the right-position, that is, at position x n - l - l . When this happens, the received digit rn-l-l is corrected and the effect of the error digit en-l-l is removed from the syndrome register via syndrome modification.

Let e ( x ) = xn-'-'. Since this is input on the right end, this is equivalent to xn-l-lxn-k = x2n-r-k-1. The syndrome pattern to watch for is obtained by CJ (x) = Rg(x)[x2n-z-k-1

I.

Example 4.24 Consider again the (7,4) Hamming code shortened to a (5,2) code. The error pattern at position xn-'-' = x4 appearing on the right-hand side as x2n-z-k-1 = x7. The syndrome to watch for is

= R , ( , ) [ ~ ~ I = 1.

0

4.13 Binary CRC Codes

The term Cyclic Redundancy Check (CRC) code has come to be jargon applied to cyclic codes used as error detection codes: they indicate when error patterns have occurred over a sequence of bits, but not where the errors are nor how to correct them. They are commonly used in networking in conjunction with protocols which call for retransmission of erroneous data packets. Typically CRCs are binary codes, with operations taking place in GF(2). A CRC is a cyclic code, that is, the code polynomials are multiples of a generator polynomial g(x) E GF(2)[xl.

CRCs are simply cyclic codes, so the same encoding and decoding concepts as any other cyclic code applies. In this section, however, we will introduce an efficient byte-oriented

148 Cyclic Codes, Rings, and Polynomials

algorithm for computing syndromes.

We use the notation R,(,)[.] to denote the operation of computing the remainder of the argument when dividing by g(x). The entire cyclic encoding operation can thus be written, as described in Section 4.8, as

C ( X ) = x ' ~ ( x )

+

Rg(,)[x'm(~)l.

Example 4.25 Letg(x) = x16+x15+x2+1 andm(x) = x ~ ~ + + X ~ ~ + X ~ + X ~ + X ~ + X + ~ x ~ ~ + ~ ~ ~ corresponding to the message bits

m=[O,1,1,0,1,1,0,1,0,0,1,0,0,1,1,11

= [m15, m14, ' ' ' I m l , mo].

The vector m is written here with mo on the right. Since deg(g(x)) = n - k = 16, to encode we first multiply m ( x ) by x16:

x16m(x) = X3O

+

2 9

+

XZ7

+

2 6

+

2 4

+

2 1

+

x18

+

x*7

+

x16, (4.9)

then divide by g(x) to obtain the remainder

d ( x ) = X I 4 + X I 3 + X I 1 +.lo +x9 +x7 +x6 + x 4 +x2. (4.10) The code polynomial is

c ( x ) = x'6m(x)

+

d ( x )

= x30

+

2 9

+

2 7

+

x26

+

2 4

+

2 1

+

.18

+

2 7

+

,16

+

X I 4 + X I 3 + X I 1 + X I 0

+ 2

+x7 +x6 + x 4 + x 2

The operation can also be represented using bit vectors instead of polynomials. From (4.9), x16m(x) ff [O, 1, l , O , 1,1,0, 1,0,0, 1,0,0, 1, 1, 110,

o,o,o, o,o,o,

0,

o,o,

0,

o,o,

O,O,O]

(with the highest power of x corresponding to the bit on the left of this vector) and from (4.10), d ( x ) f, [O,O,O,O,

o,o,o,o,o,o,

0,0,0,0,0,010, 1,1,0,1,1,1,0,1,1,0,1,0, 1,0,01 Adding these two vectors we find

c = [ 0 , 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 , 1 ~ 0 , 1 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 0 ] The message vector m is clearly visible in the codeword c.

Suppose now that the effect of the channel is represented by r ( x ) = c ( x )

+

e(x).

To see if any errors occurred in transmission over the channel, r (x) is divided by g(x) to find s (x) = Rg(,) [r (x)]. The polynomial s (x) is the syndrome polynomial. Note that

s ( x ) = Rg(,)[r(x)l = Rg(,)[c(X)

+

&)I = R g ( x ) [ ~ ( ~ ) I

+

Rg(x)[e(x)l = Rg(,)[e(x>l, since Rg(,) [c(x)] = 0 for any code polynomial c ( x ) .

If s ( x )

#

0, then e ( x )

#

0, that is, one or more errors have occurred and they have been detected. If s ( x ) = 0, then it is concluded r ( x ) has not been corrupted by errors, so that the original message m (x) may be immediately extracted from I (x).

4.13 Binary CRC Codes 149

Note, however, that if an error pattern occurs which is exactly one of the code polyno- mials, say e ( x ) = CI (x) for some code polynomial cl (x), then

J(X) = R g ( x ) [ C ( X )

+

C l ( X > l = R g ( x ) [ C ( X ) l + R g ( x ) [ C l ( X ) I = 0.

In other words, there are error patterns that can occur which are not detected by the code:

an error pattern is undetectable if and only if e ( x ) is a code polynomial.

Let us consider how many such undetected error patterns there are.

Suppose there is a single bit in error, e ( x ) = x i for 0 <_ i 5 n - 1. If the polynomial g ( x ) has more than one nonzero term it cannot divide x i evenly, so there is a nonzero remainder. Thus all single-bit errors can be detected.

Suppose that g ( x ) has (1

+

x) as a factor. Then it can be shown that all codewords have even parity, so that any odd number of bit errors can be detected.

A burst error of length B is any error pattern for which the number of bits between the first and last errors (inclusive) is B . For example, the bit sequence

. .

.,O,O,l,l,O,l,

l,O,l,O,.

.

.has a burst error of length 7.

Let e ( x ) be an error burst of length r = II - k or less. Then n-k-1) e ( x ) = xi(l

+

elx

+ . . . +

en-k-1.x

for some i, 0 p i 5 k. Since g ( x ) is of degree n - k and has a non-zero constant term, that is

+

P - k ,

n-k-1

g(x) = 1

+

glx

+. . . +

g n - k - l x

then R g ( , ) [ e ( x ) ] cannot be zero, so the burst can be detected.

Consider now a burst of errors of length n - k

+

1, with error polynomial e ( x ) = x'(1 + e l x + . . . e , - k - l X n-k-l

+

x ~ - ~ ) . There are 2n-k-1 possible error patterns of this form for each value of i. Of these, all but error bursts of the form e ( x ) = x ' g ( x ) are detectable. The fraction of undetectable bursts of length n - k

+

1 is therefore

2 - ( n - k - l )

For bursts of length 1 > n - k

+

1 starting at position i, all 2'-2 of the bursts are detectable except those of the form

e ( x ) = x i a ( x ) g ( x )

for some a ( x ) = a0

+

a l x

+ . .

- a i - n + k - l x '-n+k-l with a0 = al-nfk-1 = 1. The number of undetectable bursts is 21-nfk-2, so the fraction of undetectable bursts is

2-n+k.

Example 4.26 Let g ( x ) = x16

+

x15 + x 2

+

1. This can be factored as g ( x ) = (1 +x)(l +x

+

x 15), so the CRC is capable of detecting any odd number of bit errors. It can be shown that the smallest integer rn such that g(x) divides 1

+

x m is rn = 32767, So by Exercise 4.37, the CRC is able to detect any pattern of two errors - a double error pattern -provided that the code block length n 5 32767.

All burst errors of length 16 or less are detectable. Bursts of length 17 are detectable with probability 0.99997. Bursts of length 2 18 are detectable with probability 0.99998.

Table 4.6 [373, p. 1 2 3 1 , [281] lists commonly used generator polynomials for CRC codes of various lengths.

150 Cyclic Codes, Rings, and Polynomials

Table 4.6: CRC Generators CRC Code Generator Polvnomial

CRC-4 CRC-7 CRC-8 CRC- 12 CRC-ANSI CRC-CCITT CRC-SDLC CRC-24 CRC-32a CRC-32b

4.1 3.1 Byte-Oriented Encoding and Decoding Algorithms

The syndrome computation algorithms described above are well-adapted to bit-oriented hardware implementations. However, CRCs are frequently used to check the integrity of files or data packets on computer systems which are intrinsically byte-oriented. An algorithm is presented here which produces the same result as a bit-oriented algorithm, but which operates on a byte at a time. The algorithm is faster because it deals with larger pieces of data and also because it makes use of parity information which is computed in advance and stored. It thus has higher storage requirements than the bitwise encoding algorithm but lower operational complexity; for a degree 16 polynomial, 256 two-byte integers must be stored.

Consider a block of N bytes of data, as in a file or a data packet. We think of the first byte of data as corresponding to higher powers of x in its polynomial representation, since polynomial division requires dealing first with highest powers of x. This convention allows the file to be processed in storage order. The data are stored in bytes, as in

do, 4 , .

.

., dN-1,

where di represents an 8-bit quantity. For a byte of data di, let di,7, di$,

. .

, di,o denote the bits, where di,o is the least-significant bit (LSB) and 4 7 is the most significant bit (MSB).

The byte di has a corresponding polynomial representation

bi+l(x) = d i , 7 ~ 7

+

di,6X6

+

* *

. +

di,lX

+

di,O.

The algorithm described below reads in a byte of data and computes the CRC parity check information for all of the data up to that byte. It is described in terms of a CRC polynomial g ( x ) of degree 16, but generalization to other degrees is straightforward. For explicitness of examples, the generator polynomial g(x) = x l6 +x l5 +x2

+

1 (CRC-ANSI) is used throughout. Let m"](x) denote the message polynomial formed from the 8i bits of the first i data bytes {do, dl ,

. . .

, dj-l},

m"](X) = d0,7X8i-1

+

d0,6X8i-2

+ . . . +

di-l,lx

+

dj-l,O,

4.13 Binary CRC Codes 151 and let p [ ' ] ( x ) denote the corresponding parity polynomial of degree 5 15,

p[il(x) = p & 15

+

p14x [il 14

+ . . . +

p y x

+

po [il

.

By the operation of cyclic encoding,

16 [i]

P[il(x) = R g ( x ) [ X m ( X I 1 9

x m (XI = q(x)g(x)

+

P [ ~ ] ( x ) that is,

16 [i] (4.1 1)

for some quotient polynomial q (x).

Let us now augment the message by one more byte. This is done by shifting the current message polynomial eight positions (bits) and inserting the new byte in the empty bit positions. We can write

m[i+ll(x) = Shift 8 x

- -

8 m positions [il (x)

+

add bi+l(x) new byte ,

where bi+1 (x) represents the new data. The new parity polynomial is computed by (4.12)

16 8 [i]

( ~ 1 1

= Rg(x)[x (X m

(XI +

h + l ( x ) ) I .

p['+'](x) = Rg(,)[X 16, [i+ll

Using (4.11), we can write (4.12) as

P [ ~ + ' ] ( x ) = Rg(x)[x8g(x>q(x)

+

X~P"](X)

+

x16bi+l(~)1

p[i+l?x) = Rg(,,[x8g(x)q(x)1

+

Rg(,)[x8p['](x)

+

X16bi+l (x)l,

P[i+ll(x) = Rg(x)[x8p[il(x)

+

x16bi+l(x)l This can be expanded as

or

since g(x) evenly divides x 8 g ( x ) q ( x ) . The argument can be expressed in expanded form as

X ~ ~ [ " ( X )

+

xl6bi+1 (x) = pl5x [il 23

+

pyjx22

+ . . .

+ pr1x9 + pi1x8

+

d i , 7 ~ ~ ~

+

dj,6X22

+ . . . +

di,1xl7

+

di,0xl6

[il 23 [il 15 [il 14

= ( 4 7

+

p 1 5 ) X

+

(di,6

+

p r i ) ~ ~ ~

+

* * *

+

(di,o

+ ~ F ] ) X ' ~ +

p7 x

+

pg x

+ . . . +

p p x g .

NOW let t j = di,j

+

pj+8 [il for j = 0, 1,

. . .

,7. Then

X8p['](x) +x'6bj+l(x) = t7x23

+

t6X22

+. . .

f

+

p.5"]X15

+

pt1X'4

+. . .

f pt1x8.

The updated parity is thus

p[i+ll(x) = Rg(x)[t7X 23

+

t6X22

+

' .

. + +

p y 1 X 1 5

+

p t 1 X 1 4

+ .

* *

+

ptlx81

= R g ( x ) [ t 7 X 23

+

t 6 X 2 2

+

'..

+

t 0 X l 6 ]

+

R g ( ~ ) [ p y ] X ~ ~

+

p F 1 X 1 4

+ ... +

p p 3 1

= R g ( ~ ) [ t 7 X ~ ~

+

t 6 X 2 2 f

. . . +

tOX 16 ]

+

p7 [il X 15

+

p i 11 X 14

+.

* . f p i 1 X 8 , where the last equality follows since the degree of the argument of the second Rg(x) is less than the degree of g (x)

.

152 Cvclic Codes. Rings. and Polvnomials

There are 28 = 256 possible remainders of the form

f 5

which has the representation in bits [1,0,0,0, O,O,O,O, O,O,O,O, 0,1,0,1], or in hex, 8005.

Table 4.7 shows the remainder values for all 256 possible values oft, where the hex number R ( t ) represents the bits of the syndrome. Let ?;(x) = t7x23

+

t6x22

+ . .. +

t0xl6 and let

R ( t ) = Rg(x)[t"(~)] (i.e., the polynomial representedby the data inTable 4.7). The encoding update rule is summarized as

The algorithm described above in terms of polynomials can be efficiently implemented in terms of byte-oriented arithmetic on a computer. The parity check information is represented in two bytes, c r c 1 and c r c0, with c r c 1 representing the high-orderparity byte. Together, [crcl, crcO] forms the two-byte (16 bit) parity. Also, let R ( t ) denote the 16-bit parity corresponding to the t, as in Table 4.7. The operation 69 indicates bitwise modulo-2 addition (i.e., exclusive or). The fast CRC algorithm is summarized in Algorithm 4.1.

Dans le document Error Correction Coding (Page 195-200)