Cyclic codes: overview EE 387, Notes 14, Handout #22 A linear block code is cyclic if the cyclic shift of a codeword is a codeword. Cyclic codes have many advantages. Elegant algebraic descriptions: c(x) = m(x)g(x), where g(x) is generator polynomial c(x)h(x) = 0 mod (x n 1), where h(x) is parity-check polynomial c(β1 ) = 0,...,c(β t ) = 0, where β 1,...,β t GF(q m ) Shift register encoders and syndrome units Simple burst error correction (error trapping) Random error correction by solving polynomial equations Cyclic codes are (by definition) a very special case of linear codes. But nearly all commonly used block codes are (shortened) cyclic codes. EE 387, October 23, 2015 Notes 14, Page 1
Cyclic shifts of n-tuples and polynomials The right cyclic shift of (v 0,v 1,...,v n 1 ) is (v n 1,v 0,...,v n 2 ). Circuit diagrams: D Q D Q D Q D Q D Q D Q D Q CLK The right cyclic shift of v is denoted by v (1). When n-tuples are polynomials of degree n 1, the right cyclic shift of v(x) = (v 0,v 1,...,v n 2,v n 1 ) = v 0 +v 1 x+ +v n 2 x n 2 +v n 1 x n 1 is also a polynomial of degree n 1: v (1) (x) = (v n 1,v 0,...,v n 2 ) = v n 1 +v 0 x+ +v n 2 x n 1 The right cyclic shift of v = v(x) by i positions is denoted v (i) = v (i) (x). EE 387, October 23, 2015 Notes 14, Page 2
Properties of cyclic shifts Some obvious facts about cyclic shifts of n-tuples: v (n) = v. Left cyclic shift i positions v ( i) is same as right cyclic shift v (n i). v (i) = v (i mod n). The first two statements are special cases of the third. The right cyclic shift operation is a linear transformation v (1) = vs 1, where S 1 is a permutation matrix: 0 1 0 0 0 0 1 0 S 1 =........ 0 0 0 1 1 0 0 0 Every linear feedback shift register corresponds to a matrix in rational canonical form. The cyclic register is the simplest feedback shift register. EE 387, October 23, 2015 Notes 14, Page 3
Numbers vs. polynomials When binary n-tuples represent integers, bit shifts perform multiplication and division by powers of 2. Logical left shift is multiplication by 2. Logical right shift is unsigned division by 2. Cyclic left/rights shifts are multiplication/division by 2 mod 2 n 1. When n-tuples represent polynomials over a field, cyclic shifts correspond to multiplication and division by powers of x mod (x n 1). We write polynomials with the most significant coefficients on the right. (v 0,v 1,...,v n 1 ) v 0 +v 1 x+ +v n 1 x n 1 Cyclic right shifts are multiplication by x, except coefficient of x n becomes coefficient of x 0 = 1. Thus right cyclic shift differs from product with x by a multiple of x n 1. EE 387, October 23, 2015 Notes 14, Page 4
Polynomial description of cyclic shifts Lemma: The right cyclic shift of v(x) is v (1) (x) = xv(x) v n 1 (x n 1) = xv(x) mod (x n 1). Proof: By the definition of right cyclic shift, v (1) (x) = v n 1 +v 0 x+ +v n 2 x n 1 = v n 1 +v 0 x+ +v n 2 x n 1 +v n 1 x n v n 1 x n = xv(x) v n 1 (x n 1) = xv(x) mod (x n 1) When v n 1 = 0, the right cyclic shift is same as the right logical shift: v n 1 = 0 v (1) (x) = xv(x) EE 387, October 23, 2015 Notes 14, Page 5
Cyclic codes: definition and basic properties Definition: A cyclic code is a linear block code such that the right cyclic shift of any codeword is a codeword. By iteration, all cyclic shifts of codewords are codewords. The right cyclic shift i positions of any codeword c(x) is a codeword: c (i) (x) = x i c(x) mod (x n 1) Since cyclic codes are linear, sums of cyclic shifts are codewords. For any polynomial a(x) = a 0 +a 1 x+ +a m x m, m a(x)c(x) mod (x n ( 1) = ai x i c(x) mod (x n 1) ) is a codeword. Important special case: dega(x) < n degc(x). Then i=0 dega(x)c(x) < n = a(x)c(x) mod (x n 1) = a(x)c(x). Therefore a(x)c(x) is a codeword when deg a(x)c(x) < n. EE 387, October 23, 2015 Notes 14, Page 6
Generator polynomial Theorem: Let C be an (n,k) cyclic code over GF(q). 1. There exists a monic polynomial g(x) such that n-tuple c(x) is a codeword if and only if g(x) is a divisor of c(x). The polynomial g(x) is called the generator polynomial of C. 2. The generator polynomial is unique. 3. The degree of the generator polynomial is n k. 4. The generator polynomial is a divisor of x n 1. Proof: When k = 0 we can take g(x) = x n 1. In this case all the statements are obviously true. So assume k > 0 and therefore n k < n. The zero polynomial is the only polynomial of degree < n that is divisible by x n 1. So x n 1 generates the code consisting of only the zero vector. x n 1 is called the cyclic polynomial of degree n. EE 387, October 23, 2015 Notes 14, Page 7
Generator polynomial proof (1) 1. Let g(x) be the monic greatest common divisor of {c i (x)}, the set of nonzero codewords. Then there exist polynomials {a i (x)} such that g(x) = a i (x)c i (x) i ( ) = a i (x)c i (x) mod (x n 1) since degg(x) < n = i i ( ) a i (x)c i (x) mod (x n 1) The final expression shows that g(x) is a linear combination of codewords. Therefore g(x) is a divisor of all other codewords. 2. If there were two generator polynomials, each would be a divisor of the other. Since both are monic, the ratio is 1, so they are equal. EE 387, October 23, 2015 Notes 14, Page 8
Generator polynomial proof (2) 3. Let r = degg(x). If degm(x) < n r then degm(x)g(x) < n, so m(x)g(x) is a codeword. Conversely, every codeword c(x) is a polynomial multiple of g(x), that is, c(x) = m(x)g(x) where degm(x) < n r. So there are q n r codewords. But every (n,k) code over GF(q) has q k codewords. Therefore q n r = q k = n r = k = r = n k. 4. (Cute trick.) The right cyclic shift of g(x) by k digits is a codeword: g (k) (x) = (1,0,...,0,g 0,g 1,...,g n k 1 ) Therefore = 1+g 0 x k +g 1 x k+1 + +g n k 1 x n 1 + x n x n = x k g(x) (x n 1) x n 1 = x k g(x) g (k) (x) is a sum of multiples of g(x) and so itself is a multiple of g(x). EE 387, October 23, 2015 Notes 14, Page 9
Examples of binary cyclic codes The (n,0) code consisting of the zero vector: g n (x) = x n 1. The (n,n) code of all n-tuples is another trivial cyclic code: g 0 (x) = 1. The (n,0) and (n,n) codes are duals. Note: g 0 (x)g n (x) = x n 1. Even-parity simple parity-check codes are cyclic: g 1 (x) = x 1 = x+1. Nonsystematic generator matrix: 1 1 0 0 0 0 0 1 1 0 0 0 G =......... 0 0 0 1 1 0 0 0 0 0 1 1 Repetition codes have generator polynomial g n 1 = 1+x+ +x n 1. G = [ 1 1 1 1 1 1 ] Odd parity-check codes are not linear and therefore not cyclic by definition. They are cosets of cyclic codes and have the same error protection ability in most situations. EE 387, October 23, 2015 Notes 14, Page 10
Examples of binary cyclic codes (cont.) Systematic generator matrix for (4, 3) simple parity-check code: 1 1 0 0 g(x) = x+1 = x j mod g(x) = 1 = G = 1 0 1 0 1 0 0 1 Over GF(2), x 7 1 = (x+1)(x 3 +x+1)(x 3 +x 2 +1). There are 2 3 = 8 divisors of x 7 1 hence 8 cyclic codes of blocklength 7. For primitive polynomial g(x) = x 3 +x+1 we obtain cyclic Hamming code. 1 1 0 1 0 0 0 G = 0 1 1 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 0 1 0 = H = 0 1 0 1 1 1 0 0 0 1 0 1 1 1 1 0 1 0 0 0 1 Dual code has generator matrix H, the (7, 3) maximum-length code. All nonzero maximum-length codewords have same weight, 2 m 1 = 4. EE 387, October 23, 2015 Notes 14, Page 11
Nonsystematic generator matrix Let C be the (n,k) cyclic code generated by g(x) of degree r = n k. Every codeword m(x)g(x) = m 0 g(x)+m 1 xg(x)+ +m k 1 x k 1 g(x) is a linear combination of x i g(x). Therefore {x i g(x):i = 0,1,...,k 1} is a basis for C. The matrix with rows x i g(x) is a nonsystematic generator matrix for C. g(x) g 0 g 1 g r 0 0 0 xg(x) 0 g 0 g 1 g r 0 0 G 1 =. =............... x k 2 g(x) 0 0 0 g 0 g 1 g r 0 x k 1 g(x) 0 0 0 0 g 0 g 1 g r Every row of G 1 is a right (cyclic) shift of the first row. EE 387, October 23, 2015 Notes 14, Page 12
Systematic generator matrix A systematic encoder copies message digits to consecutive positions in codeword. Convention: most significant digits transmitted first: c n 1,c n 2,...,c n n In order for k message digits to appear at beginning of a codeword, they must be shifted right by n k positions: m(x) (0,0,...,0,m 0,m 1,...,m k 1 ) = x n k m(x). To generate a valid codeword, low order n k coefficients must be chosen so that the complete n-tuple is a multiple of g(x). Suppose that x n k m(x) has nonzero remainder when divided by g(x). x n k m(x) mod g(x) = R g(x) (x n k m(x)) We can create a codeword by subtracting the remainder from x n k m(x). Integer example: 31 mod 7 = 3 hence 31 3 = 28 is a multiple of 7. EE 387, October 23, 2015 Notes 14, Page 13
Systematic generator matrix (cont.) The systematic encoder for cyclic code with generator polynomial g(x): m(x) x n k m(x) (x n k m(x) mod g(x)) ) = x n k m(x) R g(x) (x n k m(x) = (0,...,0,m 0,...,m k 1 ) (p 0,...,p n k 1,0,...,0) The two polynomials in the above sum have no nonzero coefficients of powers of x in common. This polynomial subtraction is multiplexing. m(x) x n k mod g(x) 1 c(x) This encoder creates a codeword by appending to the message digits the negative of the remainder modulo g(x) of the shifted message polynomial. EE 387, October 23, 2015 Notes 14, Page 14
Systematic generator matrix (cont.) Systematic encoder uses division to produce multiple of generator polynomial. The remainder of division by a fixed polynomial is a linear function. The systematic encoder is a linear transformation, so its output is determined by the output values for any basis. The standard basis consists of the k unit vectors {1,x,...,x k 1 }. Check symbols for message x i are (x n k x i ) mod g(x) = x n k+i mod g(x). The rows of the systematic generator matrix for i = 0,1,...,k 1 are where s [j] (x) = x j mod g(x). g i (x) = x n k+i mod g(x) + x n k+i = s [n k+i] (x) + x n k+i, We will see that s [j] (x) is the j-th feedback shift of s [0] (x). EE 387, October 23, 2015 Notes 14, Page 15
Systematic generator matrix (cont.) Coefficients of s [j] (x) form check portion of systematic generator matrix. s [n k] 0 s [n k] n k 1 1 0 0 s [n k+1] G 2 = 0 s [n k+1] n k 1 0 1 0........... s [n 1] 0 s [n 1] n k 1 0 0 1 First row of G 2 is simply g(x), same as first row of nonsystematic G 1. G 2 has k(n k+1) nonzero elements, same as G 1. Both G 1 and G 2 are determined by n k values (coefficients of g(x)). The parity-check portion of each row of G 2 comes from the first row by using a linear feedback shift register whose scalers the coefficients of g(x). For example, this shift register multiplies by x modulo x 16 +x 12 +x 5 +1. EE 387, October 23, 2015 Notes 14, Page 16