Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the...

16

Click here to load reader

Transcript of Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the...

Page 1: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Cyclic codes: overviewEE 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 (xn − 1), where h(x) is parity-check polynomial

◮ c(β1) = 0, . . . , c(βt) = 0, where β1, . . . , βt ∈ GF(qm)

◮ 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

Page 2: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Cyclic shifts of n-tuples and polynomials

The right cyclic shift of (v0, v1, . . . , vn−1) is (vn−1, v0, . . . , vn−2) .

Circuit diagrams:

≡CLK

D QQ D QQ D QQ D QQ D QQ D QQ D QQ

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) = (v0, v1, . . . , vn−2, vn−1)

= v0 + v1x+ · · ·+ vn−2xn−2 + vn−1x

n−1

is also a polynomial of degree ≤ n− 1:

v(1)(x) = (vn−1, v0, . . . , vn−2) = vn−1 + v0x+ · · ·+ vn−2xn−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

Page 3: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

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) = vS1, where

S1 is a permutation matrix :

S1 =

0 1 0 · · · 00 0 1 · · · 0...

......

. . ....

0 0 0 · · · 11 0 0 · · · 0

.

Every linear feedback shift register corresponds to a matrix in rationalcanonical form. The cyclic register is the simplest feedback shift register.

EE 387, October 23, 2015 Notes 14, Page 3

Page 4: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Numbers vs. polynomials

When binary n-tuples represent integers, bit shifts perform multiplicationand 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 2n − 1.

When n-tuples represent polynomials over a field, cyclic shifts correspond tomultiplication and division by powers of x mod (xn − 1).

We write polynomials with the most significant coefficients on the right.

(v0, v1, . . . , vn−1) ↔ v0 + v1x+ · · · + vn−1xn−1

Cyclic right shifts are multiplication by x, except coefficient of xn becomescoefficient of x0 = 1.

Thus right cyclic shift differs from product with x by a multiple of xn − 1.

EE 387, October 23, 2015 Notes 14, Page 4

Page 5: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Polynomial description of cyclic shifts

Lemma: The right cyclic shift of v(x) is

v(1)(x) = xv(x) − vn−1(xn − 1)

= xv(x) mod (xn − 1) .

Proof : By the definition of right cyclic shift,

v(1)(x) = vn−1 + v0x+ · · ·+ vn−2xn−1

= vn−1 + v0x+ · · ·+ vn−2xn−1 + vn−1x

n − vn−1xn

= xv(x)− vn−1(xn − 1)

= xv(x) mod (xn − 1)

When vn−1 = 0, the right cyclic shift is same as the right logical shift:

vn−1 = 0 ⇐⇒ v(1)(x) = xv(x)

EE 387, October 23, 2015 Notes 14, Page 5

Page 6: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Cyclic codes: definition and basic properties

Definition: A cyclic code is a linear block code such that the right cyclicshift of any codeword is a codeword.

By iteration, all cyclic shifts of codewords are codewords. The right cyclicshift i positions of any codeword c(x) is a codeword:

c(i)(x) = xic(x) mod (xn − 1)

Since cyclic codes are linear, sums of cyclic shifts are codewords.

For any polynomial a(x) = a0 + a1x+ · · ·+ amxm,

a(x)c(x) mod (xn − 1) =

m∑

i=0

(

aixic(x) mod (xn − 1)

)

is a codeword. Important special case: deg a(x) < n−deg c(x). Then

deg a(x)c(x) < n =⇒ a(x)c(x) mod (xn − 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

Page 7: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

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 acodeword 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 xn − 1.

Proof : When k = 0 we can take g(x) = xn − 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 xn− 1. So xn

− 1generates the code consisting of only the zero vector.

xn− 1 is called the “cyclic” polynomial of degree n.

EE 387, October 23, 2015 Notes 14, Page 7

Page 8: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Generator polynomial proof (1)

1. Let g(x) be the monic greatest common divisor of {ci(x)}, the set ofnonzero codewords. Then there exist polynomials {ai(x)} such that

g(x) =∑

i

ai(x)ci(x)

=

(

i

ai(x)ci(x)

)

mod (xn − 1) since deg g(x) < n

=∑

i

(

ai(x)ci(x) mod (xn − 1))

The final expression shows that g(x) is a linear combination ofcodewords. Therefore g(x) is a divisor of all other codewords.

2. If there were two generator polynomials, each would be a divisor of theother. Since both are monic, the ratio is 1, so they are equal.

EE 387, October 23, 2015 Notes 14, Page 8

Page 9: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Generator polynomial proof (2)

3. Let r = deg g(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), thatis, c(x) = m(x)g(x) where degm(x) < n− r.

So there are qn−r codewords. But every (n, k) code over GF(q) hasqk codewords.

Therefore qn−r = qk =⇒ 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, g0, g1, . . . , gn−k−1)

= 1 + g0xk + g1x

k+1 + · · · + gn−k−1xn−1 + xn − xn

= xkg(x) − (xn − 1)

Thereforexn − 1 = xkg(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

Page 10: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Examples of binary cyclic codes

◮ The (n, 0) code consisting of the zero vector: gn(x) = xn − 1.

◮ The (n, n) code of all n-tuples is another trivial cyclic code: g0(x) = 1.

The (n, 0) and (n, n) codes are duals. Note: g0(x)gn(x) = xn − 1.

◮ Even-parity simple parity-check codes are cyclic: g1(x) = x− 1 = x+ 1.Nonsystematic generator matrix:

G =

1 1 0 · · · 0 0 00 1 1 · · · 0 0 0...

......

. . ....

......

0 0 0 · · · 1 1 00 0 0 · · · 0 1 1

◮ Repetition codes have generator polynomial gn−1 = 1 + x+ · · · + xn−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

Page 11: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Examples of binary cyclic codes (cont.)

◮ Systematic generator matrix for (4, 3) simple parity-check code:

g(x) = x+ 1 =⇒ xj mod g(x) = 1 =⇒ G =

1 1 0 01 0 1 01 0 0 1

◮ Over GF(2), x7 − 1 = (x+ 1)(x3 + x+ 1)(x3 + x2 + 1).

There are 23 = 8 divisors of x7 − 1 hence 8 cyclic codes of blocklength 7.

For primitive polynomial g(x) = x3 + x+ 1 we obtain cyclic Hammingcode.

G =

1 1 0 1 0 0 00 1 1 0 1 0 01 1 1 0 0 1 01 0 1 0 0 0 1

=⇒ H =

1 0 0 1 0 1 10 1 0 1 1 1 00 0 1 0 1 1 1

“Dual” code has generator matrix H, the (7, 3) maximum-length code.

All nonzero maximum-length codewords have same weight, 2m−1 = 4.

EE 387, October 23, 2015 Notes 14, Page 11

Page 12: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

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) = m0g(x) +m1xg(x) + · · ·+mk−1xk−1g(x)

is a linear combination of xig(x).

Therefore {xig(x): i = 0, 1, . . . , k − 1} is a basis for C.

The matrix with rows xig(x) is a nonsystematic generator matrix for C.

G1 =

g(x)xg(x)

...

xk−2g(x)

xk−1g(x)

=

g0 g1 · · · gr 0 0 · · · 00 g0 g1 · · · gr 0 · · · 0

......

. . .. . . · · ·

. . .. . .

...0 0 0 g0 g1 · · · gr 00 0 0 0 g0 g1 · · · gr

Every row of G1 is a right (cyclic) shift of the first row.

EE 387, October 23, 2015 Notes 14, Page 12

Page 13: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Systematic generator matrix

A systematic encoder copies message digits to consecutive positions incodeword.

Convention: most significant digits transmitted first: cn−1, cn−2, . . . , cn−n

In order for k message digits to appear at beginning of a codeword, theymust be shifted right by n− k positions:

m(x) 7→ (0, 0, . . . , 0,m0,m1, . . . ,mk−1) = xn−km(x) .

To generate a valid codeword, low order n− k coefficients must be chosenso that the complete n-tuple is a multiple of g(x).

Suppose that xn−km(x) has nonzero remainder when divided by g(x).

xn−km(x) mod g(x) = Rg(x)(xn−km(x))

We can create a codeword by subtracting the remainder from xn−km(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

Page 14: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Systematic generator matrix (cont.)

The systematic encoder for cyclic code with generator polynomial g(x):

m(x) 7→ xn−km(x)− (xn−km(x) mod g(x))

= xn−km(x)−Rg(x)

(

xn−km(x))

= (0, . . . , 0,m0, . . . ,mk−1)− (p0, . . . , pn−k−1, 0, . . . , 0)

The two polynomials in the above sum have no nonzero coefficients ofpowers of x in common. This polynomial subtraction is multiplexing.

−1

m(x)c(x)

× xn−k mod g(x)

This encoder creates a codeword by appending to the message digits thenegative of the remainder modulo g(x) of the shifted message polynomial.

EE 387, October 23, 2015 Notes 14, Page 14

Page 15: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Systematic generator matrix (cont.)

Systematic encoder uses division to produce multiple of generatorpolynomial.

The remainder of division by a fixed polynomial is a linear function.

The systematic encoder is a linear transformation, so its output isdetermined by the output values for any basis.

The standard basis consists of the k unit vectors {1, x, . . . , xk−1}.

Check symbols for message xi are

−(xn−k · xi) mod g(x) = −xn−k+i mod g(x) .

The rows of the systematic generator matrix for i = 0, 1, . . . , k − 1 are

gi(x) = −xn−k+i mod g(x) + xn−k+i

= −s[n−k+i](x) + xn−k+i ,

where s[j](x) = xj mod g(x).

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

Page 16: Cyclic codes: overview - Stanford University · PDF fileA linear block code is cyclic if the cyclic shift of a codeword is a codeword. ... Since cyclic codes are linear, ... To generate

Systematic generator matrix (cont.)

Coefficients of s[j](x) form check portion of systematic generator matrix.

G2 =

−s[n−k]0 · · · −s

[n−k]n−k−1 1 0 · · · 0

−s[n−k+1]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 G2 is simply g(x), same as first row of nonsystematic G1.

G2 has k(n− k + 1) nonzero elements, same as G1.

Both G1 and G2 are determined by n− k values (coefficients of g(x)).

The parity-check portion of each row of G2 comes from the first row byusing a linear feedback shift register whose scalers the coefficients of g(x).

For example, this shift register multiplies by x modulo x16 + x12 + x5 + 1.

EE 387, October 23, 2015 Notes 14, Page 16