Cyclic Code
Cyclic Code
Yunghsiang S. Han
Graduate Institute of Communication Engineering, National Taipei University Taiwan E-mail: [email protected]
Y. S. Han
Cyclic codes
Y. S. Han
Cyclic codes
Proof: Multiplying v (x) by xi , we obtain xi v (x) = v0 xi + v1 xi+1 + + vni1 xn1 + + vn1 xn+i1 . Then we manipulate the equation into the following form: xi v (x) = vni + vni+1 x + + vn1 xi1 + v0 xi + +vni1 xn1 + vni (xn + 1) + vni1 x(xn + 1) + + vn1 xi1 (xn + 1) = q (x)(xn + 1) + v (i) (x), where q (x) = vni + vni+1 x + + vn1 xi1 . The nonzero code polynomial of minimum degree in a cyclic code C is unique. Let g (x) = g0 + g1 x + + gr1 xr1 + xr be the nonzero code polynomial of minimum degree in an (n, k ) cyclic code C . Then
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
the constant term g0 must be equal to 1. Proof: Suppose that g0 = 0. Then g (x) = = g1 x + g2 x2 + + gr1 xr1 + xr x(g1 + g2 x + + gr1 xr2 + xr1 ).
If we shift g (x) cyclically n 1 places to the right (or one place to the left), we obtain a nonzero code polynomial, g1 + g2 x + + gr1 xr2 + xr1 , which has a degree less than r . Contradiction.
Y. S. Han
Cyclic codes
Y. S. Han
Cyclic codes
Consider the polynomial xg (x), x2 g (x), . . . , xnr1 g (x). Clearly, they are cyclic shifts of g (x) and hence code polynomials in C . Since C is linear, a linear combination of g (x), xg (x), . . . , xnr1 g (x), v (x) = u0 g (x) + u1 xg (x) + + unr1 xnr1 g (x) = (u0 + u1 x + + unr1 xnr1 )g (x),
is also a code polynomial where ui {0, 1}. Let g (x) = 1 + g1 x + + gr1 xr1 + xr . be the nonzero code polynomial of minimum degree in an (n, k ) cyclic code C . A binary polynomial of degree n 1 or less is a code polynomial if and only if it is a multiple of g (x). Proof: Let v (x) be a binary polynomial of degree n 1 or less.
Y. S. Han
Cyclic codes
Suppose that v (x) is a multiple of g (x). Then v (x) = (a0 + a1 x + + anr1 xnr1 )g (x) = a0 g (x) + a1 xg (x) + + anr1 xnr1 g (x).
Since v (x) ia a linear combination of the code polynomials, g (x), xg (x), . . . , xnr1 g (x), it is a code polynomial in C . Now let v (x) be a code polynomial in C . Dividing v (x) by g (x), we obtain v (x) = a(x)g (x) + b(x), where the degree of b(x) is less than the degree of g (x). Since v (x) and a(x)g (x) are code polynomials, b(x) is also a code polynomial. Suppose b(x) = 0. Then b(x) is a code polynomial with less degree than that of g (x). Contradiction. The number of binary polynomials of degree n 1 or less that are multiples of g (x) is 2nr .
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
There are total of 2k code polynomials in C , 2nr = 2k , i.e., r = n k. The polynomial g (x) is called the generator polynomial of the code. The degree of g (x) is equal toi the number of parity-check digits of the code. The generator polynomial g (x) of an (n, k ) cyclic code is a factor of xn + 1. Proof: We have xk g (x) = (xn + 1) + g (k) (x). Since g (k) (x) is the code polynomial obtained by shifting g (x) to
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
the right cyclically k times, g (k) (x) is a multiple of g (x). Hence, xn + 1 = {xk + a(x)}g (x). If g (x) is a polynomial of degree n k and is a factor of xn + 1, then g (x) generates an (n, k ) cyclic code. Proof: A linear combination of g (x), xg (x), . . . , xk1 g (x), v (x) = = a0 g (x) + a1 xg (x) + + ak1 xk1 g (x) (a0 + a1 x + + ak1 xk1 )g (x),
is a polynomial of degree n 1 or less and is a multiple of g (x). There are a total of 2k such polynomial and they form an (n, k ) linear code. Let v (x) = v0 + v1 x + + vn1 xn1 be a code polynomial in
Y. S. Han
Cyclic codes
this code. We have xv (x) = = = v0 x + v1 x2 + + vn1 xn vn1 (xn + 1) + (vn1 + v0 x + + vn2 xn1 ) vn1 (xn + 1) + v (1) (x).
Since both xv (x) and xn + 1 are divisible by g (x), v (1) must be divisible by g (x). Hence, v (1) (x) is a code polynomial and the code generated by g (x) is a cyclic code. Suppose that the message to be encoded is u = (u0 , u1 , . . . , uk1 ). Then xnk u(x) = u0 xnk + u1 xnk+1 + + uk1 xn1 . Dividing xnk u(x) by g (x), we have xnk u(x) = a(x)g (x) + b(x).
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
10
Since the degree of g (x) is n k , the degree of b(x) must be n k 1 or less. Then b(x) + xnk u(x) = a(x)g (x) is a multiple of g (x) and therefore it is a code polynomial. b(x) + xnk u(x) = b0 + b1 x + + bnk1 xnk1 +u0 xnk + u1 xnk+1 + + uk1 xn1 then corresponds to the code vector (b0 , b1 , . . . , bnk1 , u0 , u1 , . . . , uk1 ).
Y. S. Han
Cyclic codes
11
Y. S. Han
Cyclic codes
12
In general, G is not in systematic form. However, it can be put into systematic form with row operation. Let xn + 1 = g (x)h(x),
where the polynomial h(x) has the degree k and is of the following form: h(x) = h0 + h1 x + + hk xk
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
13
with h0 = hk = 1. A parity-check matrix of C may be obtained from h(x). Let v be a code vector in C and v (x) = a(x)g (x). Then v (x)h(x) = = = a(x)g (x)h(x) a(x)(xn + 1) a(x) + xn a(x).
Since the degree of a(x) is k 1 or less, the powers xk , xk+1 , . . . , xn1 do not appear in a(x) + xn a(x). Therefore,
k
hi vnij = 0 for 1 j n k.
i=0
Y. S. Han
Cyclic codes
14
and can see that xk h(x1 ) is also a factor of xn + 1. xk h(x1 ) then generates an (n, n k ) cyclic code with the following (n k ) n matrix as a generator matrix:
H = hk 0 0 0 0 0 hk hk1 hk2 hk1 hk 0 hk2 hk1 hk hk2 hk1 h0 0 h0 0 0 h0 0 0 0 h0
Then H is a parity-check matrix of the cyclic code C . We call h(x) the parity polynomial of C . Let C be an (n, k ) cyclic code with generator polynomial g (x). The dual code of C is also cyclic and is generated by the polynomial xk h(x1 ), where h(x) = (xn + 1)/g (x). Let xnk1 = ai (x)g (x) + bi (x) for 0 i k 1,
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
15
where bi (x) = bi0 + bi1 + + bi(nk1) . Since bi (x) + xnk+i are multiples of g (x), they are code polynomials. Then
G = b00 b10 b20 b01 b11 b21 . . . b(k1)0 b(k1)1 b(k1)2 b(k1)(nk1) b02 b12 b22 b0(nk1) b1(nk1) b2(nk1) 1 0 0 . . . 0 0 0 0 1 0 0 1 0 0 0 . . . 1 .
Y. S. Han
Cyclic codes
16
Message Xn-ku(X)
Y. S. Han
Cyclic codes
17
Example
Consider the (7, 4) cyclic code generated by g (x) = 1 + x + x3 . Suppose that the message u = (1 0 1 1) is to be encoded. The contentents in the register are as follows:
Input 1 1 0 1 Register contents 0 0 0 (initial state) 1 1 0 (first shift) 1 0 1 (second shift) 1 0 0 (third shift) 1 0 0 (fourth shift)
After four shifts, the contents of the register are (1 0 0). Thus the complete code vector is (1 0 0 1 0 1 1).
Gate
(1 0 1 1)
Message Xn-ku(X)
Parity digits
Code word
Y. S. Han
Cyclic codes
18
vnkj =
i=0
hi vnij for 1 j n k,
which is known as a dierence equation. vnk1 = h0 vn1 +h1 vn2 + +hk1 vnk = uk1 +h1 uk2 + +hk1 u0 vnk2 = uk2 + h1 uk3 + + hk1 vnk1 Encoding circuit:
Gate2 Gate1
+
hk-1
+
hk-2
+
h2
+
h1
u0
u1
Uk-2 k stage
Uk-1
Output to channel
Y. S. Han
Cyclic codes
19
Example
The parity polynomial of the (7, 4) cyclic code generated by g (x) = 1 + x + x3 is x7 + 1 2 4 = 1 + x + x + x . h(x) = 3 1+x+x The encoding circuit:
h0 = 1 Input Gate 1 Gate 2 p Output
Suppose that the message to be encoded is (1 0 1 1). Then v3 = 1, v4 = 0, v5 = 1, v6 = 1. The parity-check digits are v2 v1 = = v6 + v3 + v4 = 1 + 1 + 0 = 0 v5 + v4 + v3 = 1 + 0 + 1 = 0
Y. S. Han
Cyclic codes
20
v0
v4 + v3 + v2 = 0 + 1 + 0 = 1.
Y. S. Han
Cyclic codes
21
Syndrome Computation
Let r = (r0 , r1 , . . . , rn1 ) be the received vector. The syndrome is calculated as s = r H T , where H is the parity-check matrix. If syndrome is not identical to zero, r is not a code vector and the presence of errors has been detected. Dividing r (x) by the generator polynomial g (x), we obtain r(x) = a(x)g (x) + s(x). The n k coecients of s(x) form the syndrome s. We call s(x) Gate the syndrome.
r(x)/g(x) r(X)
Received vector
g1 s0 s1
g2
gn-k-1
sn-k-1
Y. S. Han
Cyclic codes
22
If C is a systematic code, then the syndrome is simply the vector sum of the received parity digits and the parity-check digits recomputed from the received information digits. Let s(x) be the syndrome of a received polynomial r (x). Then the remainder s(1) (x) resulting from dividing xs(x) by the generator polynomial g (x) is the syndrome of r (1) (x), which is a cyclic shift of r (x). Proof: We have xr (x) = rn1 (xn + 1) + r(1) (x). Then c(x)g (x) + (x) = rn1 g (x)h(x) + x[a(x)g (x) + s(x)], where (x) is the remainder resulting from dividing r(1) (x) by g (x). Then (x) is the syndrome of r (1) (x). Rearranging the
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
23
above equation, we have xs(x) = [c(x) + rn1 h(x) + xa(x)]g (x) + (x). It is clearly that (x) is also the remainder resulting from dividing xs(x) by g (x). Therefore, (x) = s(1) (x). The remainder s(i) (x) resulting from dividing xi s(x) be the generator polynomial g (x) is the syndrome of r (i) (x), which is the ith cyclic shift of r (x).
Y. S. Han
Cyclic codes
24
Example
Consider the (7, 4) cyclic code generated by g (x) = 1 + x + x3 . Suppose that the received vector is r = (0 0 1 0 1 1 0). The syndrome of r is s = (1 0 1). As the received vector is shifted into the circuit, the contents in the register are as follows:
Gate input Gate
1 0 1
If the register is shifted once more with the input gate disabled, the new contents will be s(1) = (1 0 0), which is the syndrome of r(1) = (0 0 0 1 0 1 1).
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
25
We may shift the received vector r(x) into the syndrome register from the right end. However, after the entire r (x) has been shifted into the register, the contents in the register do not form the sybdrome of r (x); rather, they form the syndrome s(nk) (x) of r(nk) (x).
Gate xn-kr(x)/g(x) s0 g1 s1 g2
Received vector
gn-k-1
sn-k-1 r(X)
Y. S. Han
Cyclic codes
26
It is known that xnk r (x) = b(x)(xn + 1) + r(nk) (x). Hence, r (nk) (x) = [b(x)h(x) + a(x)]g (x) + (x). When r (nk) (x) is divided by g (x), (x) is also the remainder. Therefore, (x) is indeed the syndrome of r (nk) (x).
Y. S. Han
Cyclic codes
27
Error Detection
Let v (x) be the transmitted code word and e(x) = e0 + e1 x + + en1 xn1 be the error pattern. Then r (x) = v (x) + e(x) = b(x)g (x) + e(x). Following the denition of syndrome, we have e(x) = [a(x) + b(x)]g (x) + s(x). This shows that the syndrome is actually equal to the remainder resulting from dividing the error pattern by the generator polynomial. The decoder has to estimate e(x) based on the syndrome s(x). If e(x) is identical to a code vector, e(x) is an undetectable error pattern.
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
28
The error-detection circuit is simply a syndrome circuit with an OR gate with the syndrome digits as inputs. For a cyclic code, an error pattern with errors conned to i high-order positions and i low-order positions is also regarded as a burst of length or less. such a burst is called end-around burst. An (n, k ) cyclic code is capable of detecting any error burst of length n k or less, including the end-around bursts. Proof: Suppose that the error pattern is a burst of length of n k or less. Then e(x) = xj B (x), where 0 j n 1 and B (x) is a polynomial of degree n k 1 or less. Since the degree of B (x) is less than that of g (x), B (x) is not divisible by g (x). Since g (x) is a factor of
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
29
xn + 1 and x is not a factor of g (x), g (x) and xj must be relatively prime. Therefore, e(x) is not divisible by g (x). The last part of the above statement is left as an exercise. The fraction of undetectable bursts of length n k + 1 is 2(nk1) . Proof: Consider the bursts of length n k + 1 starting from the ith digit position and ending at the (i + n k )th digit position. There are 2nk1 such burst. Among these bursts, the only one that cannot be detected is e(x) = xi g (x). Therefore, the fraction of undetectable bursts of length n k + 1 starting from the ith digit position is 2(nk1) . For > n k + 1, the fraction of undetectable error bursts of length is 2(nk) . The proof is left as an exercise.
Graduate Institute of Communication Engineering, National Taipei University
Y. S. Han
Cyclic codes
30
Y. S. Han
Cyclic codes
31
s(1) (x). The second digit rn2 of r (x) becomes the rst digit of r (1) (x). The same decoding processes. If the syndrome s(x) of r (x) does correspond to an error pattern with an error at the location xn1 , the rst received digit rn1 is an erroneous digit and it must be corrected by taking the sum rn1 en1 . This correction results in a modied received polynomial, denoted by r1 (x) = r0 + r1 x + + rn2 xn2 + (rn1 en1 )xn1 . The eect of the error digit en1 on the syndrome can be achieved by adding the syndrome of e (x) = xn1 to s(x). The syndrome s1 of r1 (x) is the remainder resulting from dividing x[s(x) + xn1 ] by the generator polynomial g (x).
Graduate Institute of Communication Engineering, National Taipei University
(1)
(1)
Y. S. Han
Cyclic codes
32
Since the remainders resulting from dividing xs(x) and xn by g (x) are s(1) (x) and 1, respectively, we have s1 (x) = s(1)(x) + 1.
(1)
Y. S. Han
Cyclic codes
33
Meggitt Decoder I
Gate (r0, r1, , rn-1)
r(X) Received vector Corrected vector
Gate
ri
Gate Syndrome register s(x) --- r(x) s(1)(x) --- r(1)(x) ei Gate
Y. S. Han
Cyclic codes
34
Example
Consider the decoding of the (7, 4) cyclic code generated by g (x) = 1 + x + x3 . This code has minimum distance 3 and is capable of correcting any single error. The seven single-error patterns and their corresponding syndromes are as follows:
Error pattern e(X) e6(X) = X6 e5(X) = X5 e4(X) = X4 e3(X) = X3 e2(X) = X2 e1(X) = X1 e0(X) = X0 Syndrome s(X) s(X) = 1 + X2 s(X) = 1 + X + X2 s(X) = X + X2 s(X) = 1 + X s(X) = X2 s(X) = X s(X) = 1 Syndrome vector (s0, s1, s2) (1 0 1) (1 1 1) (0 1 1) (1 1 0) (0 0 1) (0 1 0) (1 0 0)
Y. S. Han
Cyclic codes
35
r(X) Output
Gate
Y. S. Han
Cyclic codes
36
Syndrome register
Correction 0
Initial
0 0 1
Y. S. Han
Cyclic codes
37
1 4th shift 1 0 1 1 0 1 1 1 0 1 0
0 6th shift 0 0 0 0 0 1 0 1 1 1 0
Y. S. Han
Cyclic codes
38
Meggitt Decoder II
To decode a cyclic code, the received polynomial r (x) may be shifted into the syndrome register from the right end for computing the syndrome. When r (x) has been shifted into the syndrome register, the register contains s(nk) (x), which is the syndrome of r(nk) (x). If s(nk) (x) corresponds to an error pattern e(x) with en1 = 1, the highest-order digit rn1 of r (x) is erroneous and must be corrected. In r(nk) (x), the digit rn1 is at the location xnk1 . When rn1 is corrected, the error eect must be removed from s(nk) (x). The new syndrome s1 (x) is the sum of s(nk) (x) and the remainder (x) resulting from dividing xnk1 by g (x). Since
Graduate Institute of Communication Engineering, National Taipei University
(nk)
Y. S. Han
Cyclic codes
39
Gate
Feedback connection
Gate
Syndrome register
(Syndrome modification)
ei
Gate
Y. S. Han
Cyclic codes
40
Example
Again, we consider the decoding of the (7, 4) cyclic code generated by g (X ) = 1 + X + X 3 . Suppose that the received polynomial r (X ) is shifted into the syndrome register from the right end. The seven single-error patterns and their corresponding syndromes are as follows:
Error pattern e(X) e(X) = X6 e(X) = X5 e(X) = X4 e(X) = X3 e(X) = X2 e(X) = X1 e(X) = X0 Syndrome s(3)(X) s(3)(X) = X2 s(3)(X) = X s(3)(X) = 1 s(3)(X) = 1 + X2 s(3)(X) = 1 + X + X2 s(3)(X) = X + X2 s(3)(X) = 1 + X Syndrome vector (s0, s1, s2) (0 0 1) (0 1 0) (1 0 0) (1 0 1) (1 1 1) (0 1 1) (1 1 0)
Y. S. Han
Cyclic codes
41
after the entire received polynomial r (X ) has been shifted into the syndrome register. If the single error occurs at the location X i with i = 6, the syndrome in the register will not be (0 0 1) after the entire received polynomial r (X ) has been shifted into the syndrome register. However, another 6i shifts, the syndrome register will contain (0 0 1). Based on this fact, we obtain another decoding circuit for the (7, 4) cyclic code generated by g (X ) = 1 + X + X 3 .
Y. S. Han
Cyclic codes
42
r(X) Input
r(X) Output
Gate Gate
Gate