Cyclic Codes

119
Cyclic Cyclic Codes Codes Cyclic Cyclic Codes Codes Wireless Information Transmission System Lab. Wireless Information Transmission System Lab. Institute of Communications Engineering Institute of Communications Engineering National Sun National Sun Yat Yat-sen sen University University

Transcript of Cyclic Codes

Cyclic Cyclic CodesCodesCyclic Cyclic CodesCodes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Outline Outline

◊ Description of Cyclic CodesG d i Ch k i f C li C d◊ Generator and Parity-Check Matrices of Cyclic Codes

◊ Encoding of Cyclic Codes◊ Syndrome Computation and Error Detection◊ Decoding of Cyclic Codes◊ Decoding of Cyclic Codes◊ Cyclic Hamming Codes

Sh d C li C d◊ Shortened Cyclic Codes

2

IntroductionIntroduction

◊ Cyclic codes form an important subclass of linear codes.

◊ These codes are attractive for two reasons:◊ Encoding and syndrome computation can be implemented easily

by employing shift registers with feedback connections (or linear sequential circuits).

◊ Because they have considerable inherent algebraic structure, it is ibl t fi d i ti l th d f d di thpossible to find various practical methods for decoding them.

◊ Cyclic codes were first studied by Prange in 1957.

3

Description of Cyclic CodesDescription of Cyclic Codes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Description of Cyclic CodesDescription of Cyclic Codes

◊ If the n-tuple v = (v0, v1,…, vn-1) are cyclic shifted one place to the right we obtain another n tupleplace to the right, we obtain another n-tuple

v(1) = (vn-1, v0, v1,…, vn-2)which is called a cyclic shift of v.

◊ If the v are cyclically shifted i places to the right, we have

v(i) = (v v 1 v 1 v0 v1 v 1)v( ) (vn–i, vn–i+1,…, vn-1, v0, v1, …, vn-i-1)

C li ll hif i l h i h i i l◊ Cyclically shifting v i places to the right is equivalent to cyclically shifting v (n – i) place to the left.

5

Description of Cyclic CodesDescription of Cyclic Codes

◊ Definition 5.1 An (n, k) linear code C is called a cyclic code if every cyclic shift of a code vector in C is also acode if every cyclic shift of a code vector in C is also a code vector in C.

◊ The (7 4) linear code given in Table 5 1 is a cyclic code◊ The (7, 4) linear code given in Table 5.1 is a cyclic code◊ To develop the algebraic properties of a cyclic code, we

treat the components of a code vector v = (v0 v1 v 1) astreat the components of a code vector v (v0, v1,…, vn-1) as the coefficients of a polynomial as follows:

v(X) = v0 + v1X + v2X2 + ··· + v 1Xn-1v(X) v0 + v1X + v2X + + vn-1X◊ If vn-1 ≠ 0, the degree of v(X) is n – 1.◊ If v 1 = 0, the degree of v(X) is less than n – 1.◊ If vn-1 0, the degree of v(X) is less than n 1.◊ The correspondence between the vector v and the polynomial v(X)

is one-to-one.

6

Description of Cyclic CodesDescription of Cyclic Codes

7

Description of Cyclic CodesDescription of Cyclic Codes

◊ The code polynomial that corresponds to the code vector v(i) isv( ) is

v(i)(X) = vn-i + vn-i+1X + ··· + vn-1Xi-1 +v Xi + v Xi+1 + + v Xn-1v0Xi + v1Xi+1 + ··· + vn-i-1Xn-1

◊ Multiplying v(X) by Xi, we obtainXi (X) Xi Xi+1 X 1 X +i 1Xiv(X) = v0Xi + v1Xi+1 + ··· + vn-i-1Xn-1 + ··· + vn-1Xn+i-1

◊ The equation above can be manipulated into the following fform :

◊ Xiv(X) = vn-i + vn-i+1X +··+ vn-1Xi-1 + v0Xi + ··· + vn-i-1Xn-1

(X 1) X(X 1) Xi 1(X 1)+ vn-i(Xn+1) + vn-i+1X(Xn+1) + ··· + vn-1Xi-1(Xn+1)= q(X)·(Xn + 1) + v(i)(X) (5.1)

8

Description of Cyclic CodesDescription of Cyclic Codes

◊ Theorem 5.1 The nonzero code polynomial of minimum degree in a cyclic code C is uniqueminimum degree in a cyclic code C is unique

◊ Proof◊ Let g(X) = g + g X + ··· + g Xr-1 + Xr be a nonzero code◊ Let g(X) = g0 + g1X + ··· + gr-1Xr 1 + Xr be a nonzero code

polynomial of minimum degree in C◊ Suppose that g(X) is not uniquepp g( ) q◊ There exists another code polynomial of degree r, say g’(X),

g’(X) = g’0 + g’1X + ··· + g’r-1Xr-1 + Xr

◊ Since C is linear, g(X) + g’(X) = (g0 + g’0) + (g1 + g’1)X + ··· + (gr-1 + g’r-1)Xr-1 is also a code polynomial which has degree less than ralso a code polynomial which has degree less than r

◊ If g(X) + g’(X) ≠ 0, g(X) + g’(X) is a nonzero code polynomial with degree less than the minimum degree r

9

g g

Description of Cyclic CodesDescription of Cyclic Codes

◊ Theorem 5.2 Let g(X) = g0 + g1X + ··· +gr-1Xr-1 + Xr be the nonzero code polynomial of minimum degree in (n k)the nonzero code polynomial of minimum degree in (n, k) cyclic code C. Then the constant term g0 must be equal to 1

◊ Proof◊ Suppose that g0 = 0, then

2 1g(X) = g1X + g2X2 + ··· + gr-1Xr-1 + Xr

= X · (g1+ g2X+ ··· + gr-1Xr-2 + Xr-1 )If hift (X) li ll 1 l t th i ht ( 1 l t◊ If we shift g(X) cyclically n – 1 places to the right (or 1 place to the left), we obtain a nonzero code polynomial, g1+ g2X+ ··· + gr-1Xr-2 + Xr-1, which has a degree less than r1 , g

◊ this is a contradiction to the assumption that g(X) is the nonzero code polynomial with minimum degree

10

Description of Cyclic CodesDescription of Cyclic Codes

◊ Theorem 5.3 Let g(X) = g0 + g1X + ··· +gr-1Xr-1 + Xr be the nonzero code polynomial of minimum degree in an (nthe 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 iff it is a multiple of g(X) .p y p g( )

◊ Proof◊ Let v(X) be a binary polynomial of degree n – 1 or less◊ Let v(X) be a binary polynomial of degree n 1 or less◊ Suppose that v(X) is a multiple of g(X)

v(X) = (a0 + a1X + ··· + an-r-1Xn-r-1)g(X)( ) ( 0 1 n r 1 )g( )= a0g(X) + a1Xg(X) + ··· +an-r-1Xn-r-1g(X)

◊ Since v(X) is a linear combination of the code polynomials, g(X), Xg(X), …, Xn-r-1g(X), it is a code polynomial in C

11

Description of Cyclic CodesDescription of Cyclic Codes

◊ Proof (cont.) N l t (X) b d l i l i C di idi (X) b (X)◊ 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)v(X) = a(X)g(X) + b(X)where either b(X) is identical to zero or the degree of b(X) is less than the degree of g(X)than the degree of g(X)

◊ Rearranging the equation above, we haveb(X) = a(X)g(X) + v(X)b(X) = a(X)g(X) + v(X)

◊ Since both v(X) and a(X)g(X) are code polynomials, b(X) must be a code polynomiala code polynomial

◊ If b(X) ≠ 0, then b(X) is a nonzero code polynomial whose degree is less than the degree of g(X) Contradiction!! => b(X)=0

12

g g( ) Contradiction!! > b(X) 0

Description of Cyclic CodesDescription of Cyclic Codes

◊ Recall that g(X) = g0 + g1X + ··· +gr-1Xr-1 + Xr .h b f bi l i l f d 1 l◊ The number of binary polynomials of degree n-1 or less

that are multiples of g(X) is 2n-r.◊ a(X)=a0Xn-r-1+a1Xn-r-2+…+an-r-1

◊ It follows from Theorem 5.3 that these polynomials form all the code polynomials of the (n,k) cyclic code C.

◊ Since there are 2k code polynomials in C, then 2n-r must be p y ,equal to 2k.

◊ As a result we have r=n-k◊ As a result, we have r n-k.

13

Description of Cyclic CodesDescription of Cyclic Codes

◊ Theorem 5.4 In an (n, k) cyclic code, there exists one and only one code polynomial of degree n – kand only one code polynomial of degree n k,

g(X) = 1 + g1X1 + ··· + gn-k-1Xn-k-1 + Xn-k

Every code polynomial is a multiple of g(X) and everyEvery code polynomial is a multiple of g(X) and every binary polynomial of degree n – 1 or less that is a multiple of g(X) is a code polynomialof g(X) is a code polynomial

◊ An (n,k) cyclic code is completely specified by its nonzero code polynomial of minimum degree g(X)code polynomial of minimum degree, g(X).

◊ The polynomial g(X) is called the generator polynomial of the codethe code

◊ The degree of g(X) is equal to the number of parity-check digits of the code

14

digits of the code

Description of Cyclic CodesDescription of Cyclic Codes

◊ Theorem 5.5 The generator polynomial g(X) of an (n, k) cyclic code is a factor of Xn + 1cyclic code is a factor of X + 1

◊ Proof◊ Multiplying g(X) by Xk results in a polynomial Xkg(X) of degree n◊ Multiplying g(X) by Xk results in a polynomial Xkg(X) of degree n◊ Dividing Xkg(X) by Xn + 1, we obtain

Xkg(X) = (Xn + 1) + g(k)(X) (5 5)X g(X) (X + 1) + g (X) (5.5)where g(k)(X) is the remainder

◊ It follows from (5.1) that g(k)(X) is the code polynomial obtained ( ) g ( ) p yby shifting g(X) to the right cyclically k times

◊ g(k)(X) is a multiple of g(X), g(k)(X) = a(X)g(X) ◊ From (5.5) we obtain, Xn + 1 = {Xk + a(X)}·g(X) Q.E.D.

15

Description of Cyclic CodesDescription of Cyclic Codes

◊ Theorem 5.6 If g(X) is a polynomial of degree n – kand is a factor of Xn + 1 then g(X) generates an (n k)and is a factor of X + 1, then g(X) generates an (n, k) cyclic code

◊ Proof◊ Proof◊ Consider the k polynomials g(X), Xg(X), …, Xk-1g(X), which all

have degree n – 1 or lessg◊ A linear combination of these k polynomials,

v(X) = a0g(X) + a1g(X) + ··· + ak-1Xk-1g(X)= (a0 + a1X + ··· + ak-1Xk-1)g(X)

is also a polynomial of degree n – 1 or less and is a multiple of (X)g(X)

◊ There are a total of 2k such polynomialsThey form an (n k) linear code

16

◊ They form an (n, k) linear code.

Description of Cyclic CodesDescription of Cyclic Codes

◊ Proof (cont.)◊ Let v(X) = v + v X + ··· + v Xn-1 be a code polynomial in this◊ Let v(X) = v0 + v1X + ··· + vn-1Xn 1 be a code polynomial in this

code◊ Multiplying v(X) by X, we obtainp y g ( ) y ,

Xv(X) = v0X + v1X2 + ··· + vn-1Xn

= vn-1(Xn + 1) + (vn-1 + v0X + ··· + vn-2Xn-1)= vn-1(Xn + 1) + v(1)(X)

where v(1)(X) is a cyclic shift of v(X)◊ Since both Xv(X) and (Xn + 1) are divisible by g(X), v(1)(X) must

be divisible by g(X)Th (1)(X) i lti l f (X) d i li bi ti f◊ Thus v(1)(X) is a multiple of g(X) and is a linear combination of g(X), Xg(X), …, Xk-1g(X)

◊ Hence, v(1)(X) is also a code polynomial => Cyclic Code

17

◊ Hence, v (X) is also a code polynomial Cyclic Code

Description of Cyclic CodesDescription of Cyclic Codes

◊ Example 5.1Th l i l X7 + 1 b f t d f ll◊ The polynomial X7 + 1 can be factored as follows :

X7 + 1 = (1 + X)(1 + X + X3)(1 + X2 + X3)◊ There are two factors of degree 3; each generates a (7, 4) cyclic

code◊ The (7, 4) cyclic code given by Table 5.1 is generated by g(X) =

1 + X + X3

Thi d h i i di t 3 d it i i l◊ This code has minimum distance 3 and it is a single-error-correcting code

◊ Each code polynomial is the product of a message polynomial of◊ Each code polynomial is the product of a message polynomial of degree 3 or less and the generator polynomial g(X) = 1 + X + X3

18

Description of Cyclic CodesDescription of Cyclic Codes

◊ Example 5.1 (cont.)L t (1 0 1 0) b th t b d d◊ Let u = (1 0 1 0) be the message to be encoded

◊ The corresponding message polynomial is u(X) = 1 + X2

M l i l i (X) b (X) l i h f ll i d◊ Multiplying u(X) by g(X) results in the following code polynomial :

(X) (1 + X)(1 + X + X3)v(X) = (1 + X)(1 + X + X3)= 1 + X + X2 + X5

th d t (1 1 1 0 0 1 0)or the code vector (1 1 1 0 0 1 0)

19

Description of Cyclic CodesDescription of Cyclic Codes

◊ Suppose that the message to be encoded is u (u u u )u = (u0, u1,…, uk-1)

◊ The corresponding message polynomial is ( ) k 1u(X) = u0 + u1X + ··· + uk-1Xk-1

◊ Multiplying u(X) by Xn-k, we obtain a polynomial of degree n – 1 or less,

Xn-ku(X) = u0Xn-k + u1Xn-k-1 + ··· + uk-1Xn-1

◊ Dividing Xn-ku(X) by the g(X), we have Xn-ku(X) = a(X)g(X) + b(X) (5.6)( ) ( )g( ) ( ) ( )

where a(X) & b(X) are the quotient and the remainder, respectively

20

respectively.

Description of Cyclic CodesDescription of Cyclic Codes

◊ Rearrange (5.6), we obtain the following polynomial of degree n – 1 or less:degree n 1 or less:

b(X) + Xn-ku(X) = a(X)g(X) (5.7)◊ This polynomial is a multiple of the g(X) and therefore it is◊ This polynomial is a multiple of the g(X) and therefore it is

a code polynomial of the cyclic code generated by g(X)◊ Writing out b(X) + Xn-ku(X) we have◊ Writing out b(X) + X u(X) , we have

b(X) +Xn-ku(X) = b0 + b1X + ·· + bn-k-1Xn-k-1

+ u0Xn-k + u1Xn-k-1 + ·· +uk 1Xn-10 1 k-1

which corresponds to the code vector ( b0, b1, ···, bn-k-1, u0, u1, ···, uk-1 )( 0, 1, , n-k-1, 0, 1, , k-1 )

◊ The process above yields an (n, k) cyclic code in systematic form.

21

y

Description of Cyclic CodesDescription of Cyclic Codes

◊ Encoding in systematic form consists of three steps:St 1 P lti l th (X) b Xn k◊ Step 1 Premultiply the message u(X) by Xn-k

◊ Step 2 Obtain the remainder b(X) from dividing Xn-ku(X) by◊ Step 2 Obtain the remainder b(X) from dividing X u(X) by the generator polynomial g(X)

◊ Step 3 Combine b(X) and Xn-ku(X) to obtain the code polynomial b(X) + Xn-ku(X)p y ( ) ( )

22

Description of Cyclic CodesDescription of Cyclic Codes

◊ Example 5.2C id th (7 4) li d t d b (X) 1 + X + X3◊ Consider the (7, 4) cyclic code generated by g(X) = 1 + X + X3

◊ Let u(X) = 1 + X3 be the message to be encodedDi idi X3 (X) X3 X6 b (X)◊ Dividing X3u(X) = X3 +X6 by g(X)

we obtain the remainder b(X) = X + X2 we obtain the remainder b(X) X + X◊ The code polynomial is v(X) = b(X)+X3u(X) = X + X 2 + X 3 + X 6

◊ The corresponding code vector is v = (0 1 1 1 0 0 1)

23

◊ The corresponding code vector is v (0 1 1 1 0 0 1)

Description of Cyclic CodesDescription of Cyclic Codes

24

Generator and ParityGenerator and Parity--Check Check Generator and ParityGenerator and Parity Check Check Matrices of Cyclic CodesMatrices of Cyclic Codes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ Consider an (n, k) cyclic code C with generator polynomial g(X) g + g X + + g Xn-kg(X) = g0 + g1X + ··· + gn-kXn-k

◊ We have shown that the k code polynomials g(X), ( ) 1 ( ) C ( f f h 6)Xg(X), …, Xn-r-1g(X) span C (Proof of Theorem 5.6)

◊ If the k n-tuples corresponding to these k code polynomials are used as the rows of an k × n matrix, we obtain the following generator matrix for C :

(5.9)

26

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ In general, G is not in systematic form.G b i i f i h i◊ G can be put into systematic form with row operations

◊ For example, the (7, 4) cyclic code given in Table 5.1 with generator polynomial g(X) = 1+ X + X3 has the following matrix as a generator matrix :

⎥⎥⎤

⎢⎢⎡

00101100001011

⎥⎥⎥

⎢⎢⎢=

01011000010110

G

◊ G is not in systematic form.

⎥⎦

⎢⎣ 1011000

27

y

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ If the first row is added to the third row and the sum of the first two rows is added to the fourth row we obtain thefirst two rows is added to the fourth row, we obtain the following matrix :

⎤⎡

⎥⎥⎤

⎢⎢⎡

00101100001011

'G

⎥⎥⎥

⎦⎢⎢⎢

=

10001010100111

'G

which is in systematic form⎦⎣ 1000101

◊ This matrix generates the same code as G.

28

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ The generator polynomial g(X) is a factor of Xn + 1, Xn + 1 g(X)h(X) (5 10)Xn + 1 = g(X)h(X) (5.10)

where the h(X) has the degree k and is of the following fform :

h(X) = h0 + h1X + ··· + hkXk

with h0 = hk = 1

◊ We want to show that a parity-check matrix of C may be obtained from h(X)◊ Let v = (v0, v1,…, vn-1) be a code vector in C◊ Then v(X) = a(X)g(X)

29

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ (cont.)M lti l i (X) b h(X) bt i◊ Multiplying v(X) by h(X), we obtain

v(X)h(X) = a(X)g(X)h(X) = a(X)(Xn + 1) (5 11) a(X)(X + 1) (5.11)= a(X) + Xna(X)

◊ Since the degree of a(X) is k – 1 or less, the powers

v(X) = a(X)g(X)n-k≦n-1

◊ S ce t e deg ee o a( ) s k o ess, t e powe sXk, Xk+1,…, Xn-1 don’t appear in a(X) + Xna(X)

◊ If we expand the product v(X)h(X) on the left-hand side of (5.11),◊ If we expand the product v(X)h(X) on the left hand side of (5.11), the coefficients of Xk, Xk+1,…, Xn-1 must be equal to 0 we obtain the following n – k equalities :

◊ (5.12)0

0 for 1k

i n i ji

h v j n k− −=

= ≤ ≤ −∑

30

0i

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ We take the reciprocal of h(X), which is defined as follows:

Xkh(X-1) = hk + hk-1X + ··· + h0Xk (5.13)k ( 1) i f f 1 ( b d)◊ Xkh(X-1) is a factor of Xn + 1 (can be proved)

◊ The polynomial Xkh(X-1) generates an (n, n – k) cyclic code with the following (n – k) × n matrix as a generator matrix:

5.14

31

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ It follows from the n – k equalities of (5.12) that any code vector v in C is orthogonal to every row of Hvector v in C is orthogonal to every row of H.

◊ H is a parity-check matrix of the cyclic code C and the row f i h d l d f Cspace of H is the dual code of C.

◊ Since the parity-check matrix H is obtained from the polynomial h(X), we call h(X) the parity polynomial of C.

◊ A cyclic code is also uniquely specified by the parity y q y p y p ypolynomial.

32

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ Theorem 5.7 let C be an (n, k) cyclic code with generator polynomial g(X) The dual code of C is alsogenerator polynomial g(X). The dual code of C is also cyclic and is generated by the polynomial Xkh(X-1), where h(X) (Xn + 1) / (X)h(X) = (Xn + 1) /g(X)

◊ Example 5.3p◊ Consider the (7, 4) cyclic code given in Table 5.1 with

generator polynomial g(X) = 1 + X + X3generator polynomial g(X) 1 + X + X◊ The parity polynomial is

h(X) = X7 +1 / g(X) = 1 + X + X2 + X4( ) g( )◊ The reciprocal of h(X) is

X4h(X-1) = X4(1 + X-1+ X-2 + X-4) = 1 + X2 + X3 + X4

33

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ Example 5.3 (cont.)Th l i l X4h(X 1) di id X7 +1 h◊ The polynomial X4h(X-1) divides X7 +1, we have

(X7 +1) / X4h(X-1) = 1 + X2 + X3

If we construct all the vectors of the (7 3) code generated by◊ If we construct all the vectors of the (7, 3) code generated by X4h(X-1) = 1 + X2 + X3 + X4, we will find that it has minimum distance 4.d sta ce .

◊ It is capable of correcting any single error and simultaneously detecting any combination double errors.g y

34

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ The generator matrix in systematic form can also be formed easilyformed easily◊ Dividing Xn-k+i by the generator polynomial g(X) for i = 0, 1, …,

k 1 we obtaink – 1, we obtain

Xn-k+i = ai(X)g(X) + bi(X) (5.15)

where bi(X) is the remainder with the following form:

bi(X) = bi0 + bi1X + ··· + bi,n-k-1Xn-k-1

Si b (X) + Xn k+i f i 0 1 k 1 lti l f (X)◊ Since bi(X) + Xn-k+i for i = 0, 1, …, k – 1 are multiples of g(X), they are code polynomials

35

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ (cont.)A i th k d l i l f k t i◊ Arranging these k code polynomials as rows of a k × n matrix, we obtain:

5.16

which is the generator matrix of C in systematic form.Th di it h k t i f C i◊ The corresponding parity-check matrix for C is

5.17

36

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ Example 5.4A i l t (X) 1 + X + X3 di idi X3 X4 X5 d X6 b (X)◊ Again, let g(X) = 1 + X + X3, dividing X3, X4, X5, and X6 by g(X)

◊ We have X3 = g(X) + (1 + X )X3 = g(X) + (1 + X ), X4 = Xg(X) + (X + X2), X5 = (X2 + 1)g(X) + (1 + X + X2), ( )g( ) ( ),X6 = (X3 + X + 1)g(X) + (1 +X2)

◊ Rearranging the equations above, we obtain the following four g g q gcode polynomials:

v0(X) = 1 + X + X3, (X) X X2 X4v1(X) = X + X2 + X4,

v2(X) = 1 + X + X2 + X5, v3(X) = 1 + X2 + X6

37

v3(X) 1 + X + X

Generator and ParityGenerator and Parity--Check Matrices of Cyclic CodesCheck Matrices of Cyclic Codes

◊ Example 5.4 (cont.)T ki th f d l i l f 4 7 t i◊ Taking these four code polynomials as rows of a 4 × 7 matrix, we obtain the following generator matrix in systematic form for the (7 4) cyclic code:(7, 4) cyclic code:

⎥⎤

⎢⎡ 0001011

⎥⎥⎥⎥

⎢⎢⎢⎢

=01001110010110

G

which is identical to the matrix G΄obtain earlier in this section

⎥⎦

⎢⎣ 1000101

which is identical to the matrix G obtain earlier in this section.

38

Encoding of Cyclic CodesEncoding of Cyclic Codes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Encoding of an (n, k) cyclic code in systematic form consists of three steps:consists of three steps:◊ Multiply the message polynomial u(X) by Xn-k

Di id X k (X) b (X) b i h i d b(X)◊ Divide Xn-ku(X) by g(X) to obtain the remainder b(X)◊ Form the code word b(X) + Xn-ku(X)

◊ All these three steps can be accomplished with a division circuit which is a linear (n–k)-stage shift register with feedback connections based on the generator polynomial

g(X) = 1 + g1X + g2X2 + …+ gn-k-1Xn-k-1 + Xn-k

◊ Such a circuit is shown in Fig. 5.1.

40

Encoding of Cyclic CodesEncoding of Cyclic Codes

5.1

41

Encoding of Cyclic CodesEncoding of Cyclic Codes◊ Step 1

◊ With the gate turned on, the k information digits u0, u1, …, uk-1g , g 0, 1, , k-1are shifted into the circuit and simultaneously into the communication channel.

◊ Shifting the message u(X) into the circuit from the front end is◊ Shifting the message u(X) into the circuit from the front end is equivalent to premultiplying u(X) by Xn-k .

◊ As soon as the complete message has entered the circuit, the n – kdi it i th i t f th i d d th th thdigits in the register form the remainder and thus they are the parity-check digits.

◊ Step 2p◊ Brake the feedback connection by turning off the gate.

◊ Step 3Shif h i h k di i d d h i h h l◊ Shift the parity-check digits out and send them into the channel.

◊ These n – k parity-check digits b0, b1, …, bn-k-1, together with the k information digits, form a complete code vector.

42

k information digits, form a complete code vector.

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Example 5.5◊ Consider the (7 4) cyclic code generated by g(X) = 1 + X + X3◊ Consider the (7, 4) cyclic code generated by g(X) = 1 + X + X3

◊ The encoding circuit based on g(X) is shown in Fig. 5.2◊ Suppose that the message u = (1 0 1 1) is to be encoded◊ Suppose that the message u (1 0 1 1) is to be encoded◊ As the message digits are shifted into the register, the contents in

the register are as follows:Input Register contents

0 0 0 (initial state) 1 1 1 0 (first shift)1 1 1 0 (first shift) 1 1 0 1 (second shift) 0 1 0 0 (third shift) 1 1 0 0 (fourth shift)

◊ After four shift, the contents of the register are (1 0 0)

43

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ The complete vector is (1 0 0 1 0 1 1) and code polynomial is 1 + X3 + X5 + X6is 1 + X3 + X5 + X6

5 2

44

5.2

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Encoding of a cyclic code can also be accomplished by using its parity polynomial h(X) h + h X + + h Xkusing its parity polynomial h(X) = h0 + h1X + ··· + hkXk

◊ Let v = (v0, v1,…, vn-1) be a code vector.◊ Since hk = 1, the equalities of (5.12) can be put into the

following form:1

0 for 1 (5.18)

k

n k j i n i ji

v h v j n k−

− − − −=

= ≤ ≤ −∑which is known as a difference equation.

◊ Given the k information digits, (5.18) is a rule to determine the

0i=

g ( )n – k parity-check digits, v0, v1, …, vn-k-1

◊ An encoding circuit based on (5.18) is shown in Fig. 5.3.

45

Encoding of Cyclic CodesEncoding of Cyclic Codes

5.3

46

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ The feedback connections are based on the coefficients of the parity polynomial h(X)the parity polynomial h(X)

◊ The encoding operation can be described in the following steps :

◊ Step 1◊ Initially gate 1 is turned on and gate 2 is turned off.◊ The k information digits u(X) = u0 + u1X + ··· + uk 1Xk-1◊ The k information digits u(X) u0 + u1X + + uk-1X

are shifted into the register and the communication channel simultaneouslychannel simultaneously.

47

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Step 2A h k i f i di i h d h◊ As soon as the k information digits have entered the shift register, gate 1 is turned off and gate 2 is turned on

◊ The first parity-check digit vn-k-1 = h0vn-1 + h1vn-2 + ··· + hk-1vn-k

= uk-1 + h1uk-2 + ··· + hk-1u0

is formed and appears at point Ppp p◊ Step 3

◊ The first parity check digits is shifted into the channel◊ The first parity-check digits is shifted into the channel and is also shifted into the register

48

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Step 3 (cont.)h d i h k di i◊ The second parity-check digits

vn-k-2 = h0vn-2 + h1vn-3 + ··· + hk-1vn-k-1h h h= uk-2 + h1uk-3 + ··· + hk-2u0 + hk-1vn-k-1

is formed at P◊ Step 4

◊ Step 3 is repeated until n – k parity-check digits have p p p y gbeen formed and shifted into the channel

◊ Then gate 1 is turned on and gate 2 is turned off◊ Then gate 1 is turned on and gate 2 is turned off ◊ The next message is now ready to be shifted into the

register

49

register

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Example 5.6Th it l i l f th (7 4) li d t d b◊ The parity polynomial of the (7, 4) cyclic code generated by

g(X) = 1 + X + X3 is

h(X) = X7 + 1 / 1 + X + X3 = 1 + X + X2 + X4

◊ The encoding circuit based on h(X) is shown in Fig. 5.4◊ e e cod g c cu t based o ( ) s s ow g. 5.◊ The difference equation that determines the parity-check digits is

v3-j = 1·v7-j+ 1·v6-j + 1·v5-j + 0·v4-j= v7-j+ v6-j + v5-j for 1 ≤ j ≤ 37 j 6 j 5 j j

◊ Suppose that the message to be encoded is (1 0 1 1), then v3= 1, v4= 0, v5= 1, v6= 1

50

then v3 1, v4 0, v5 1, v6 1

Encoding of Cyclic CodesEncoding of Cyclic Codes

5.4

51

Encoding of Cyclic CodesEncoding of Cyclic Codes

◊ Example 5.6 (cont.)Th fi t it h k di it i◊ The first parity-check digits is

v2 = v6 + v5 + v4 = 1 + 1 + 0 = 0 Th d i h k di i i◊ The second parity-check digits is

v1 = v5 + v4 + v3 = 1 + 0 + 1 = 0 Th hi d i h k di i i◊ The third parity-check digits is

v0 = v4 + v3 + v2 = 0 + 1 + 0 = 1 ◊ Thus, the code vector that corresponds to the message

(1 0 1 1) is (1 0 0 1 0 1 1)

52

Syndrome Computation and Syndrome Computation and Syndrome Computation and Syndrome Computation and Error DetectionError Detection

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Let r = (r0, r1, …, rn-1) be the received vectorSi h h l i h i d b h◊ Since the channel noise, the received vector may not be the same as the transmitted code vector

◊ In the decoding of a linear code, the first step is to compute the syndrome s = r • HT, where H is the parity-check matrix◊ If the syndrome = 0, r is a code vector and decoder accepts r as

the transmitted code vector◊ If the syndrome ≠ 0, r is not a code vector and the presence of

errors has been detected

54

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ The received vector r is treated as a polynomial of degree n – 1 or lessn 1, or less,

r(X) = r0 + r1X + ··· + rn-1Xn-1

◊ Dividing r(X) by the generator polynomial g(X) we obtain◊ Dividing r(X) by the generator polynomial g(X), we obtain

r(X) = a(X)g(X) + s(X) (5.19)Degree:n-k

r(X) a(X)g(X) + s(X) (5.19)◊ The remainder s(X) is a polynomial of degree n – k – 1 or less◊ The n – k coefficients of s(X) form the syndrome s( ) y◊ s(X) is identical to zero if and only if the received polynomial r(X)

is a code polynomial◊ The syndrome computation can be accomplished with a division

circuit as shown in Fig. 5.5

55

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ The received polynomial r(X) is shifted into the register with all stages initially set to 0with all stages initially set to 0

◊ As soon as the entire r(X) has been shifted into the register, h i h i f h d ( )the contents in the register form the syndrome s(X)

56

5.5

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Theorem 5.8 Let s(X) be the syndrome of a received l i l (X) + X + + Xn 1 Th thpolynomial r(X) = r0 + r1X + ··· + rn-1Xn-1. Then the

remainder s(1)(X) resulting from dividing Xs(X) by the l i l (X) i h d f (1)(X)generator polynomial g(X) is the syndrome of r(1)(X),

which is a cyclic shift of r(X) ◊ Proof

◊ It follows from (5.1) that r(X) and r(1)(X) satisfy the following relationship:

Xr(X) = rn-1( Xn + 1 ) + r(1)(X) (5.20)◊ Rearranging (5.20), we have

r(1)(X) = rn-1( Xn + 1 ) + Xr(X) (5.21)

57

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Proof◊ Dividing both sides of (5.21) by g(X) and using the fact that Xn +

1 = g(X)h(X), we obtain:c(X)g(X) +ρ(X) = rn-1g(X)h(X) + X[a(X)g(X) + s(X)] (5.22)where ρ(X) is the remainder resulting from dividing r(1)(X) by ( ) ( ) i h d f (1)( )g(X), ρ(X) is the syndrome of r(1)(X)

◊ Rearranging (5.22), we obtain the following relationship b t (X) d X (X)betweenρ(X) and Xs(X):

Xs(X) = [c(X) + rn-1h(X) + Xa(X)]g(X) +ρ(X) (5.23)◊ From (5 23) we see that ρ(X) is also the remainder resulting from◊ From (5.23) we see that ρ(X) is also the remainder resulting from

dividing Xs(X) by g(X), therefore, ρ(X) = s(1)(X)

58

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ It follows from Theorem 5.8 that the remainder s(i)(X) resulting from dividing Xis(X) by the generator polynomialresulting from dividing Xis(X) by the generator polynomial g(X) is the syndrome of r(i)(X), which is the ith cyclic shift of r(X)of r(X)

◊ The syndrome s(1)(X) of r(1)(X) can be obtained by shifting h d i i h (X) h i i i lthe syndrome register once with s(X) as the initial contents

and with the input gate disabled◊ This is due to the fact that shifting the syndrome register

once with s(X) as the initial contents is equivalent to dividing Xs(X) by g(X)

◊ After the shift, the register contains s(1)(X)

59

, g ( )

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Example 5.7A d i it f th (7 4) li d t d b (X)◊ A syndrome circuit for the (7, 4) cyclic code generated by g(X) = 1 + X + X3 is shown in Fig. 5.6 Suppose that the received vector is r = (0 0 1 0 1 1 0)◊ Suppose that the received vector is r = (0 0 1 0 1 1 0)

◊ The syndrome of r is s = (1 0 1)A th i d t i hift d i t th i it th t t i◊ As the received vector is shifted into the circuit, the contents in the register are given in Table 5.3

◊ At the end of the seventh shift the register contains the syndrome◊ At the end of the seventh shift, the register contains the syndrome s = (1 0 1)

◊ If the register is shifted once more with the input gate disabled◊ If the register is shifted once more with the input gate disabled, the new contents will be s(1)(X) = (1 0 0), which is the syndrome of r(1)(X) = (0 0 0 1 0 1 1), a cyclic shift of r

60

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

5.6

61

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

5.3

62

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ We may shift the received vector r(X) into the syndrome register from the right end as shown in Fig 5 7register from the right end, as shown in Fig. 5.7

◊ They form the syndrome s(n – k)(X) of r(n – k)(X), which is the (n – k)th cyclic shift of r(X) Why?(n k)th cyclic shift of r(X) . Why?

◊ Shifting r(X) from the right end is equivalent to premultiplying r(X) by Xn-k premultiplying r(X) by X

◊ When the entire r(X) has entered the register, the register contains the remainder ρ(X) resulting from dividingcontains the remainder ρ(X) resulting from dividingXn-k r(X) by the generator polynomial g(X)

◊ Thus we have◊ Thus, we haveXn-kr(X) = a(X)g(X) +ρ(X) (5.24)

63

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

Fi 5 7

64

Figure 5.7

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ It follows from (5.1) that r(X) and r(n – k)(X) satisfy the following relation:following relation:

Xn-kr(X) = b(X)(Xn + 1) + r(n – k)(X) (5.25)C bi i ( 24) & ( 2 ) d i h f h◊ Combining (5.24) & (5.25) and using the fact that

Xn + 1 = g(X)h(X) ◊ We have r(n – k)(X) = [b(X)h(X) + a(X)]g(X) +ρ(X) ◊ Therefore,ρ(X) is indeed the syndrome of r(n – k)(X) ,ρ( ) y ( )

◊ Let v(X) be the transmitted code word and let e(X)=e +◊ Let v(X) be the transmitted code word and let e(X)=e0+ e1X+…+en-1Xn-1 be the error pattern.

65

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ The received polynomial is( ) ( ) ( )r(X)=v(X)+e(X)

◊ Since v(X) is a multiple of the generator polynomial g(X), we have:

e(X)=[a(X)+b(X)]g(X)+s(X)( ) [ ( ) ( )]g( ) ( )where b(X)g(X)= v(X).

◊ This shows that the syndrome is actually equal to the◊ This shows that the syndrome is actually equal to the remainder resulting from dividing the error pattern by the generator polynomial (The syndrome has nothing to dogenerator polynomial. (The syndrome has nothing to do with the code word.)

66

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Investigating the error-detecting capability of an (n,k) cyclic codecyclic code◊ Suppose that the error pattern e(X) is a burst of length

k l h ( ) b d i h f ll in-k or less. Then e(X) can be expressed in the following form:

e(X)=XjB(X)where 0≤ j ≤ n-1 and B(X) is a polynomial of degree ≤ j ≤ ( ) p y gn-k-1 or less.

◊ Since the degree of B(X) is less than the degree of the◊ Since the degree of B(X) is less than the degree of the generator polynomial g(X), B(X) is not divisible by g(X).

67

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Since g(X) is a factor of Xn+1 and X is not a factor of g(X) g(X) and Xj must be relatively primeg(X), g(X) and Xj must be relatively prime.

◊ e(X)=XjB(X) is not divisible by g(X).◊ As a result, the syndrome caused by e(X) is not equal to

zero.◊ This implies that an (n,k) cyclic code is capable of

detecting any error burst of length n-k or less.g y g◊ For a cyclic code, an error pattern with errors confined to i

high-order positions and l – i low-order positions is alsohigh order positions and l i low order positions is also regarded as a burst of length l or less

◊ Such a burst is called end around burst

68

◊ Such a burst is called end-around burst

Syndrome Computation and Error DetectionSyndrome Computation and Error Detection

◊ Theorem 5.9 An (n, k) cyclic code is capable of detecting any error burst of length n – k or less includingdetecting any error burst of length n k or less, including the end-around bursts

◊ Theorem 5 10 The fraction of undetectable bursts of◊ Theorem 5.10 The fraction of undetectable bursts of length n – k + 1 is 2-(n–k–1)

◊ Theorem 5 11 for l > n – k + 1 the fraction of◊ Theorem 5.11 for l > n k + 1, the fraction of undetectable error bursts of length l is 2-(n-k)

◊ Example 5 8◊ Example 5.8◊ The (7, 4) cyclic code generated by g(X) = 1 + X + X3 has

minimum distance 3◊ It is capable of detecting any combination of two or fewer

random errors or any burst of length 3 or less

69

Decoding of Cyclic CodesDecoding of Cyclic Codes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Decoding of cyclic code consists of the same three steps as for decoding linear codes:for decoding linear codes:◊ Syndrome computation ◊ Association of the syndrome to an error pattern◊ Association of the syndrome to an error pattern ◊ Error correction

◊ The syndrome computation for cyclic codes can be◊ The syndrome computation for cyclic codes can be accomplished with a division circuit whose complexity is linearly proportional to the number of parity-check digits y p p p y g(i.e., n – k)

◊ A straightforward approach to the design of a decoding g pp g gcircuit is via a combinational logic circuit that implements the table-lookup procedure

71

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ The limit to this approach is that the complexity of the decoding circuit tends to grow exponentially with the codedecoding circuit tends to grow exponentially with the code length and the number of errors that we intend to correct

h li f li d ll d d◊ The cyclic structure of a cyclic code allows us to decode a received vector r(X)=r0+r1X+r2X2+…+rn-1Xn-1 in a serialmanner.◊ The received digits are decoded one at a time and each digit is

d d d i h h i idecoded with the same circuitry.◊ As soon as the syndrome has been computed, the decoding circuit

checks hether the s ndrome s(X) corresponds to a correctablechecks whether the syndrome s(X) corresponds to a correctable error pattern e(X)= e0+ e1X+…+en-1Xn-1 with an

72

Decoding of Cyclic CodesDecoding of Cyclic Codes

error at the highest-order position Xn-1 (i.e. en-1=1).◊ If s(X) does not correspond to an error pattern with e =1 the◊ If s(X) does not correspond to an error pattern with en-1=1, the

received polynomial and the syndrome register are cyclically shifted once simultaneously.y◊ By doing so, we obtain r(1)(X)=rn-1+r0X+r1X2+…+rn-2Xn-1 and

the new contents in the syndrome register form the syndrome y g ys(1)(X) of r(1)(X).

◊ The same decoding circuit will check whether s(1)(X) corresponds to an error pattern with an error at location Xn-1.

◊ If the syndrome s(X) does correspond to an error pattern with 1 h fi i d di i i di i d ien-1=1, the first received digit rn-1 is an erroneous digit and it must

be corrected.Thi ti i i d t b ♁

73

◊ This correction is carried out by rn-1♁en-1 .

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ This correction results in a modified received polynomial r1(X)=r0+r1X+r2X2+ +(r 1♁e 1 )Xn-1r1(X) r0+r1X+r2X +…+(rn-1♁en-1 )X .

◊ The effect of the error digit en-1 on the syndrome is then removed from the syndrome s(X).y ( )◊ This can be achieved by adding the syndrome of

e’(X)= Xn-1 to s(X).e (X) X to s(X).◊ This sum is the syndrome of the modified received

polynomial r1(X).p y 1( )◊ Cyclically shift r1(X) and the syndrome register once

simultaneously.◊ This shift results in a received polynomial

r1(1)(X) =(rn-1♁en-1 ) +r0X+…+rn-2Xn-1.

74

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ The syndrome s1(1)(X) of r1

(1)(X) is the remainder resulting from dividing X[s(X)+Xn-1] by the generator polynomial g(X)dividing X[s(X)+X ] by the generator polynomial g(X).

◊ Since the remainders resulting from dividing Xs(X) and Xn by g(X) are s(1)(X) and 1, respectively, we have s1

(1)(X)= s(1)(X)+1.( ) , p y, 1 ( ) ( )◊ Therefore, if 1 is added to the left end of the syndrome register

while it is shifted, we obtain s1(1)(X).1 ( )

◊ A general decoder for an (n, k) cyclic code is shown in Fig. 5.8◊ It consists of three major partsj p

◊ A syndrome register ◊ An error-pattern detector p◊ A buffer register to hold the received vector

75

Decoding of Cyclic CodesDecoding of Cyclic Codes

Figure 5.8

76

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ To remove the effect of an error digit on the syndrome, we simply feed the error digit into the shift register from thesimply feed the error digit into the shift register from the left end through an EXCLUSIVE-OR gate

◊ The decoding operation is described as follows:◊ The decoding operation is described as follows:◊ Step 1

◊ The syndrome is formed by shifting the entire received vector◊ The syndrome is formed by shifting the entire received vector into the syndrome register

◊ At the same time the received vector is stored into the buffer register

◊ Step 2◊ The syndrome is read into the detector and is tested for the

corresponding error pattern

77

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Step 2 (cont.)◊ The detector is a combinational logic circuit which is designed in◊ The detector is a combinational logic circuit which is designed in

such a way that its output is 1 iff the syndrome in the syndrome register corresponds to a correctable error pattern with an error at the highrst-order position Xn–1

◊ if a “1” appears at the output of the detector, the received symbol in the rightmost stage of the buffer register is assumed to bein the rightmost stage of the buffer register is assumed to be erroneous and must be corrected

◊ If a “0” appears at the output of the detector, the received symbol pp p , yat the rightmost stage of the buffer register is assumed to be correct and no correction necessaryTh t t f th d t t i th ti t d l f th◊ The output of the detector is the estimated error value for the symbol to come out of the buffer

78

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Step 3Th fi t i d b l i d t f th b ff◊ The first received symbol is read out of the buffer

◊ If the first received symbol is detected to be an erroreous symbol, it is corrected by the output of the detectorit is corrected by the output of the detector

◊ The output of the detector is fed back to the syndrome register to modify the syndromemodify the syndrome

◊ This results in a new syndrome, which corresponds to the altered received vector shifted one place to the rightreceived vector shifted one place to the right

◊ Step 4◊ The new syndrome formed in step 3 is used to detect whether or◊ The new syndrome formed in step 3 is used to detect whether or

not the second received symbol is an erroreous symbol◊ The decoder repeats step 2 and 3

79

◊ The decoder repeats step 2 and 3

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Step 5◊ The decoder decodes the received vector symbol by symbol in◊ The decoder decodes the received vector symbol by symbol in

the manner outlined above until the entire received vector is read out of the buffer register

◊ The decoder above is known as Meggitt decoder◊ Example 5.9p

◊ 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 over a block of seven digitsThere are seven single error patterns◊ There are seven single-error patterns

◊ These seven error patterns and the all-zero vector form all the coset leader of the decoding table

80

coset leader of the decoding table

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Example 5.9 (cont.)Th f ll th t bl tt◊ They form all the correctable error patterns

◊ Suppose that the received polynomial r(X) = r + r X +r X2 + + r X6r(X) = r0 + r1X +r2 X2 + … + r6 X6

is shifted into the syndrome register from the left endTh i l tt d th i di◊ The seven single-error patterns and their corresponding syndromes are listed in Table 5.4

5.4

81

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ The complete decoding circuit is shown in Fig. 5.9

82

Figure 5.9

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Fig. 5.10 illustrates the decoding process

83Figure 5.10

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ The decoding process of the decoder shown in Fig. 5.11 is identical to the decoding process of the decoder shown inidentical to the decoding process of the decoder shown in Fig. 5.8

Figure 5 11

84

Figure 5.11

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Example 5.10A i id th d di f th (7 4) li d◊ Again, we consider the decoding of the (7, 4) cyclic code generated by g(X) = 1 + X + X3

Suppose that the received polynomial r(X) is shifted into the◊ 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◊ The seven single-error patterns and their corresponding syndromes are listed in Table 5.5

Table 5.5Table 5.5

85

Decoding of Cyclic CodesDecoding of Cyclic Codes

◊ Example 5.10 (cont.)◊ We see that only when e(X) = X6 occurs the syndrome is (0 0 1)◊ We see that only when e(X) = X6 occurs, the syndrome is (0 0 1)

after the entire received polynomial r(X) has been shifted into the syndrome register

◊ If the single error occurs at the location Xi 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 syndromereceived polynomial r(X) has been shifted into the syndrome register

◊ After another 6 – i shift, the syndrome register will contain , y g(0 0 1), we obtain another decoding circuit for the (7, 4) cyclic code generated by g(X) = 1 + X + X3, as shown in Fig. 5.12W th t th i it h i Fi 5 9 d th i it h i◊ We see that the circuit shown in Fig. 5.9 and the circuit shown in Fig. 5.12 have the same complexity

86

Decoding of Cyclic CodesDecoding of Cyclic Codes

Figure 5.12

87

Figure 5.12

Cyclic Hammin CodesCyclic Hammin CodesCyclic Hamming CodesCyclic Hamming Codes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Cyclic Hamming CodesCyclic Hamming Codes

◊ A cyclic Hamming code of length 2m – 1 with m ≥ 3 is generated by a primitive polynomial p(X) of degree m (m=n-k)primitive polynomial p(X) of degree m (m n k).

◊ In the following, we show that the cyclic code defined above is indeed a Hamming code.g

◊ For this purpose, we examine its parity-check matrix in systematic form using method presented in Section 5.2. (pp. 35-38)g p (pp )

◊ Dividing Xm+i by the generator polynomial p(X) for 0 ≤ i < 2m – m – 1, we obtain Xm+i = ai(X)p(X) + bi(X) (5.28) where the remainder bi(X) is of the form

bi(X) = bi0 + bi1X + ··· + bi,m-1Xm-1

Si X i f f h i i i l i l (X) X +i d◊ Since X is not a factor of the primitive polynomial p(X), Xm+i , and p(X) must be relatively primeA lt b (X)≠0

89

◊ As a result, bi(X)≠0

Cyclic Hamming CodesCyclic Hamming Codes

◊ bi(X) consists of at least two termsProof◊ Proof ◊ Suppose that bi(X) has only one term, say Xj with 0 ≤ j < m◊ It follows from (5 28) that◊ It follows from (5.28) that

Xm+i = ai(X)p(X) + Xj

◊ Rearranging the equation above, we have 0 ≤ i < 2m – m – 10 ≤ j < mg g q ,

Xj(Xm+i-j + 1) = ai(X)p(X) ◊ Since Xj and p(X) are relatively prime, the equation above implies

h (X) di id X +i j 1

j-m < i-j < 2m – m – 1

that p(X) divides Xm+i-j + 1◊ This is impossible since m+i–j < 2m – 1 and p(X) is a primitive

polynomial of degree mpolynomial of degree m◊ For 0 ≤ i < 2m – m – 1, the remainder bi(X) contains at least two

terms

90

Cyclic Hamming CodesCyclic Hamming Codes

◊ For i≠j, bi(X) ≠ bj(X)f◊ Proof

◊ From (5.28), we obtain b (X) X +i (X) (X)bi(X) + Xm+i = ai(X)p(X) bj(X) + Xm+j = aj(X)p(X)

S th t b (X) b (X)◊ Suppose that bi(X) = bj(X) ◊ Assuming that i< j and combining the two equations above, the

following relation is obtained:following relation is obtained: Xm+i(Xj-i + 1) = [ai(X) + aj(X)]p(X)

◊ This equation implies that p(X) divides Xj-i + 1◊ This equation implies that p(X) divides X + 1◊ This is impossible since i≠j and j – i < 2m – 1. (0 ≤ i ,j< 2m – m –

1 and p(X) is primitive.)

91

p( ) p )◊ Therefore, bi(X) ≠ bj(X)

Cyclic Hamming CodesCyclic Hamming Codes

◊ Let H=[Im Q] be the parity-check matrix of the cyclic code generated by p(X) where Q is an m×(2m m 1) matrixgenerated by p(X) where Q is an m×(2m-m-1) matrix.

◊ Let bi=[bi0,bi1,…,bi,m-1] be the m-tuple corresponding to ( )bi(X).

◊ It follows from (5.17) that the matrix Q has the 2m-m-1 bi’s with 0 ≤ i < 2m – m – 1 as its columns.

◊ It follows from the analysis above that no two columns of yQ are alike and each column has at least two 1’s (minimum distance is 3).( )

◊ Therefore, the matrix H is indeed a parity-check matrix of a Hamming code and p(X) generates this code

92

a Hamming code and p(X) generates this code.

Cyclic Hamming CodesCyclic Hamming Codes

◊ Decoding of cyclic Hamming code:◊ Suppose that a single error has occurred at the highest order◊ Suppose that a single error has occurred at the highest-order

position, X2m–2, of the received vector r(X)◊ Suppose that r(X) is shifted into the syndrome register from the pp ( ) y g

right end ◊ After the entire r(X) has entered the register, the syndrome in the

i t i l t th i d lti f di idi XmX2m 2register is equal to the remainder resulting from dividing XmX2m–2

by the generator polynomial p(X) ◊ s(X)=Xm-1 since X2m+m–2=(X2m–1+1) Xm-1 + Xm-1 and p(X) divides◊ s(X) X since X (X +1) X + X and p(X) divides

X2m–1+1.◊ Therefore, if a single error occurs at the highest-order location of

r(X), the resultant syndrome is (0,0,…,0,1).◊ A complete decoding circuit for a cyclic Hamming code is shown

in Fig 5 13

93

in Fig. 5.13

Cyclic Hamming CodesCyclic Hamming Codes

Fi 5 13

94

Figure 5.13

Cyclic Hamming CodesCyclic Hamming Codes

◊ The decoding operation is described in the following :Step 1◊ Step 1◊ The syndrome is obtained by shifting the entire received vector

into the syndrome registerinto the syndrome register ◊ At the same time, the received vector is stored into the buffer

register◊ If the syndrome is zero, the decoder assumes that no error has

occurred, and no correction is necessaryIf h d i h d d h i l◊ If the syndrome is not zero, the decoder assumes that a single error has occurred

◊ Step 2◊ Step 2◊ The received word is read out of the buffer register digits by

digits

95

digits

Cyclic Hamming CodesCyclic Hamming Codes

◊ Step 2 (cont.)A th d i th i t i (0 0 0 0 1) th◊ As soon as the syndrome in the register is (0, 0, 0, …, 0, 1), the next digit come out of the buffer is the erroneous digit, and the output of the m-input AND gate is 1output of the m input AND gate is 1

◊ Step 3Th di it i d t f th b ff i t d i◊ The erroneous digit is read out of the buffer register and is corrected by the output of the m-input AND gate

◊ The correction is accomplished by an EXCLUSIVE OR gate◊ The correction is accomplished by an EXCLUSIVE-OR gate

◊ Step 4Th d i i f h i i d◊ The syndrome register is reset to zero after the entire received vector is read out of the buffer

96

Cyclic Hamming CodesCyclic Hamming Codes

◊ The cyclic Hamming code presented above can be modified to correct any single error and simultaneously tomodified to correct any single error and simultaneously to detect any combination of double errorsA i l i d d bl d i li◊ A single-error-correcting and double-error-detecting cyclic Hamming code of length 2m – 1 is generated by

(X) (X 1) (X)g(X) = (X + 1)p(X)◊ Because both X+1 and p(X) divide X2m-1 +1 and since they

are relative prime, g(X) must also divide X2m-1 +1.◊ We denote the single-error-correcting cyclic Hamming g g y g

code by C1 and denote the cyclic code generated by g(X) = (X + 1)p(X) by C2

97

( )p( ) y 2

Cyclic Hamming CodesCyclic Hamming Codes

◊ Show that the minimum distance of this code is 4Proof◊ Proof ◊ C2 consists of the even-weight code vectors of C1 as all its vectors◊ This is due to the fact that any odd weight code polynomial in C◊ This is due to the fact that any odd-weight code polynomial in C1

does not have X + 1 as a factor◊ Therefore, an odd-weight code polynomial of C1 is not divisible , g p y 1

by g(X) = (X + 1)p(X) and it is not a code polynomial of C2 ◊ An even-weight code polynomial of C1 has X + 1 as a factor◊ Therefore, it is divisible by g(X) = (X + 1)p(X) and it is also a

code polynomial in C2 As a res lt the minim m eight of C is at least 4◊ As a result, the minimum weight of C2 is at least 4

98

Cyclic Hamming CodesCyclic Hamming Codes

◊ Proof (cont.)L t i j d k b th di ti t ti i t l th 2m◊ Let i, j, and k be three distinct nonnegative integers less than 2m –1 such that Xi + Xj + Xk is not divisible by p(X) ◊ For example we choose i and j dividing Xi + Xj by p(X) we obtain◊ For example, we choose i and j, dividing X + Xj by p(X), we obtain

Xi + Xj = a(X)p(X) + b(X) where b(X) is the remainder with degree m – 1 or less

i j◊ Since Xi + Xj is not divisible by p(X), b(X)≠ 0◊ We choose an integer k such that, when Xk is divided by p(X), the

remainder is not equal to b(X) q ( )◊ Therefore, Xi + Xj + Xk is not divisible by p(X)

◊ Dividing this polynomial by p(X), we haveXi + Xj + Xk = c(X)p(X) + d(X) (5.29)

99

Cyclic Hamming CodesCyclic Hamming Codes

◊ Proof (cont.)W h ti i t l l th 2m 1 h th t◊ We choose a nonnegative integer l less than 2m – 1 such that, when Xl is divided by p(X), the remainder is d(X), that is

Xl = f(X)p(X) + d(X) (5 30)X f(X)p(X) + d(X) (5.30)◊ The integer l cannot be equal to any of the three integer i, j, and k◊ Suppose that l = i from (5 29) & (5 30) we obtain◊ Suppose that l = i, from (5.29) & (5.30), we obtain

Xj + Xk = [c(X) + f(X)]p(X)= Xk(Xk-j + 1)◊ This implies that p(X) divides Xk-j + 1, which is impossible, since◊ This implies that p(X) divides X 1, which is impossible, since

k – j < 2m – 1 and p(X) is a primitive polynomial ◊ Therefore l≠i, similarly, we can show that l≠j and l≠k≠ , y, ≠j ≠

100

Cyclic Hamming CodesCyclic Hamming Codes

◊ Proof (cont.)U i thi f t d bi i (5 29) & (5 30) h◊ Using this fact and combining (5.29) & (5.30), we have

Xi + Xj +Xk + Xl = [c(X) + f(X)]p(X)Since X + 1 is a factor of Xi + Xj +Xk + Xl and it is not a factor of◊ Since X + 1 is a factor of Xi + Xj +Xk + Xl and it is not a factor of p(X), c(X) + f(X) must be divisible by X + 1

◊ Xi + Xj +Xk + Xl is divisible by g(X) = (X + 1)p(X)◊ X + Xj +X + X is divisible by g(X) = (X + 1)p(X) ◊ It is a code vector in code generated by g(X) = (X + 1)p(X) has

minimum weight (or distance) 4minimum weight (or distance) 4◊ It is capable of correcting any single error and simultaneously

detecting any combination of double errorsg y

◊ The decoding circuit for the single-error-correcting Hamming code shown in Fig 5 13

101

Hamming code shown in Fig. 5.13

Cyclic Hamming CodesCyclic Hamming Codes

◊ Fig. 5.13 can be modified to decode the single-error-correcting and double error detecting Hamming codecorrecting and double-error-detecting Hamming code

◊ Let r(X) be the received polynomial ◊ Dividing Xmr(X) by p(X) and r(X) by (X + 1) respectively,

we have Xmr(X) = a1(X)p(X) + sp(X)

and r(X) = a2(X)(X + 1) +σwhere sp(X) is of degree m–1 or less andσis either 0 or 1

◊ If sp(X) = 0 andσ=0, r(X) is divisible by (1 + X)p(X) and is p( ) , ( ) y ( )p( )a code polynomial

◊ Otherwise r(X) is not a code polynomial

102

◊ Otherwise, r(X) is not a code polynomial

Cyclic Hamming CodesCyclic Hamming Codes

◊ We define the syndrome of r(X) as s(X) Xs (X) + σs(X) = Xsp(X) + σ

◊ If a single error occurs, sp(X)≠0 andσ= 1◊ When an error pattern with double errors occurs, we have

sp(X)≠0 andσ= 0p

◊ Based on these facts, we implement a decoder for a single-error-correcting and double-error-detecting cyclic g g yHamming code as shown in Fig. 5.14

103

Cyclic Hamming CodesCyclic Hamming Codes

Figure 5.14

104

g

Cyclic Hamming CodesCyclic Hamming Codes

◊ The error-correction and error-detection operations are described as follows:described as follows: ◊ For σ = 0 and sp(X) = 0, the decoder assumes that there is no error

in the received polynomialp y◊ For σ = 1 and sp(X)≠0, the decoder assumes that a single error has

occurred and proceeds with the error-correction process as d ib d i th d di f i l ti lidescribed in the decoding of a single-error-correcting cyclic Hamming code

◊ For σ = 0 and s (X)≠0 the decoder assumes that double errors◊ For σ 0 and sp(X)≠0, the decoder assumes that double errors have occurred. The error alarm is turned on

◊ For σ = 1 and sp(X) = 0, the error alarm is also turned on. This phappens when an error pattern with odd number ( > 1 ) of errors has occurred an the error pattern is divisible by p(X)

105

Shortened Cyclic CodesShortened Cyclic Codes

Wireless Information Transmission System Lab.Wireless Information Transmission System Lab.Institute of Communications EngineeringInstitute of Communications Engineeringg gg gNational Sun National Sun YatYat--sensen UniversityUniversity

Shortened Cyclic CodesShortened Cyclic Codes

◊ If a code of suitable natural length or suitable number of information digits cannot be found it may be desirable toinformation digits cannot be found, it may be desirable to shorten a code to meet the requirements

hi h i l d i l i l i f h◊ This technique leads to simple implementation of the encoding and decoding for the shortened code

◊ Given an (n, k) cyclic code C consider the set of code vectors for which the l leading high-order information digits are identical to zero

◊ There are 2k–l such code vectors and they form a linear ysubcode of C

107

Shortened Cyclic CodesShortened Cyclic Codes

◊ If the l zero information digits are deleted from each of these code vectors we obtain a set of 2k–l vectors of lengththese code vectors, we obtain a set of 2k l vectors of length n – lh 2k l h d f ( l k l) li◊ these 2k–l shortened vectors form an (n – l, k – l) linear

code◊ This code is called a shortened cyclic code (or polynomial

code) and it is not cyclic◊ The encoding and decoding for a shortened cyclic code

can be accomplished by the same circuits as those p yemployed by the original cyclic code

108

Shortened Cyclic CodesShortened Cyclic Codes

◊ In decoding the shortened cyclic code after the entire received vector has been shifted into the syndrome registerreceived vector has been shifted into the syndrome register

◊ The syndrome register must by cyclically shifted l times to generate the proper syndrome for decoding the firstgenerate the proper syndrome for decoding the first received digit rn-l-1

◊ Let r(X) = r0 + r1X + ··· + r l 1Xn-l-1 be the received◊ Let r(X) r0 + r1X + + rn-l-1X be the received polynomial

◊ If the decoding circuit for the original cyclic code is used◊ If the decoding circuit for the original cyclic code is used for decoding the shortened code, the proper syndrome for decoding the received digit rn-l-1 is equal to the remainder g g n-l-1 qresulting from dividing Xn-k+lr(X) by g(X)

109

Shortened Cyclic CodesShortened Cyclic Codes

◊ Since shifting r(X) into the syndrome register must be cyclically shifted for another l times after the entire r(X)cyclically shifted for another l times after the entire r(X) has been shifted into the register

h h h l hif b◊ Now, we want to show how these extra l shifts can be eliminated by modifying the connections of the syndrome

iregister◊ Dividing Xn-k+lr(X) by g(X), we obtain

Xn-k+lr(X) = a1(X)g(X) + s(n-k+l)(X) (5.39)where s(n-k+l)(X) is the remainder and is the syndrome for ( ) ydecoding the received digit rn-l-1

110

Shortened Cyclic CodesShortened Cyclic Codes

◊ We divide Xn-k+l by g(X)L t (X) + X + + Xn l 1 b th i d◊ Letρ(X) =ρ0 +ρ1X + ··· +ρn-l-1Xn-l-1 be the remainder resulting from this division, we have

ρ(X) = X(n-k+l) + a (X)g(X) (5 40)ρ(X) = X(n k+l) + a2(X)g(X) (5.40)◊ Multiplying both sides of (5.40) by r(X) and using the

equality of (5 39) we obtainequality of (5.39), we obtainρ(X)r(X) = [a1(X) + a2(X)r(X)]g(X) + s(n-k+l)(X) (5.41)

◊ The equality above suggests that we can obtain the◊ The equality above suggests that we can obtain the syndrome s(n-k+l)(X) by multiplying r(X) byρ(X) and dividing the productρ(X)r(X) by g(X)dividing the productρ(X)r(X) by g(X)

◊ Computing s(n-k+l)(X) this way, the extra l shifts of the syndrome register can be avoided

111

syndrome register can be avoided

Shortened Cyclic CodesShortened Cyclic Codes

◊ Simultaneously multiplying r(X) byρ(X) and dividing the productρ(X)r(X) by g(X) can be accomplished by a circuitproductρ(X)r(X) by g(X) can be accomplished by a circuit as shown in Fig. 5.19A h i d l i l ( ) h b hif d◊ As soon as the received polynomial r(X) has been shifted into the register, the contents in the register form the

d ( k+l)(X) d h fi i d di i i dsyndrome s(n-k+l)(X) and the first received digit is ready to be decoded

112

Shortened Cyclic CodesShortened Cyclic Codes

Figure 5.19

113

Shortened Cyclic CodesShortened Cyclic Codes

◊ Example 5.12F 5 th i t (31 26) li H i d t d◊ For m = 5, there exists a (31, 26) cyclic Hamming code generated by g(X) = 1 + X2 + X5

Suppose that it is shortened by three digits◊ Suppose that it is shortened by three digits◊ The resultant shortened code is a (28, 23) linear code

Th d di i it f th (31 26) li d i h i Fi◊ The decoding circuit for the (31, 26) cyclic code is shown in Fig. 5.20.

◊ This circuit can be used to decode the (28 23) shortened code◊ This circuit can be used to decode the (28, 23) shortened code◊ To eliminate the extra shifts of the syndrome register, we need to

modify the connections of the syndrome registermodify the connections of the syndrome register

114

Shortened Cyclic CodesShortened Cyclic Codes

Figure 5.20

115

Shortened Cyclic CodesShortened Cyclic Codes

◊ Example 5.12 (cont.)◊ We need to determine the polynomialρ(X)◊ We need to determine the polynomialρ(X) ◊ Dividing Xn-k+3 by g(X) (= 1 + X2 + X5 ), we obtain

and ρ(X) = 1 + X2 + X3

◊ The modified decoding circuit for the (28, 23) shortened code is shown in Fig. 5.21

116

Shortened Cyclic CodesShortened Cyclic Codes

Fi 5 21

117

Figure 5.21

Shortened Cyclic CodesShortened Cyclic Codes

◊ Example 5.13C id th (28 23) h t d li d bt i d b d l ti◊ Consider the (28, 23) shortened cyclic code obtained by deleting three digits from the (31, 26) cyclic Hamming code generated by g(X) = 1 + X2 + X5g(X) 1 + X + X

◊ Suppose that the received vector is shifted into the syndrome register from the right endeg ste o t e g t e d

◊ If a single error occurs at the position X27 (or e(X) = X27)◊ The syndrome corresponding to this error pattern is the remainder◊ The syndrome corresponding to this error pattern is the remainder

resulting from dividing X5e(X) = X32 by g(X)◊ This resultant syndrome is (0 1 0 0 0)y ( )◊ The decoding circuit with syndrome resetting is shown in Fig.

5.22

118

Shortened Cyclic CodesShortened Cyclic Codes

119

Figure 5.22