7/30/2019 CODE THEROY CYCLIC CODES
1/29
Chapter 4
Linear Cyclic Codes
4.1 Definition of Cyclic Code
An ( n, k) linear code C is called a cyclic code if any cyclic shift of a
codeword is another codeword. That is,
if C c , , c , c c 1- n10 = )( L
then C c , , c , c , c c 2- n101- n1
= )()( L
Cyclic structure makes the encoding and syndrome computation
very easy.
In polynomial form
1- n1- n
2 210 x c x c x c c x c ++++= L)(
1- n 2- n
2101- n
1 x c x c x c c x c ++++= L)()(
7/30/2019 CODE THEROY CYCLIC CODES
2/29
4.2 Generator Polynomial
Every nonzero code polynomial c( x) in C must have degree at
least n-k but not greater than n-1 .
There exists one and only one nonzero generator polynomial g( x)
for a cyclic code.
Uniqueness:
Suppose g( x) is not unique, then there would exist another such
code polynomial of the same degree of the form,
k- n1- k- n1- k- n
2 21 x x g' x g' x g'1 x g' +++++= L)( .
Thus one obtains the code polynomial
1- k- n1- k- n1- k- n11 x g g' x g g' x g" )()( ++= L)( .
Polynomial )( x g" corresponds to the word
))( 0 , g g' , , g g' , g g'0, 1- k- n1- k- n 2 211 (L .
Since k- n g" deg
7/30/2019 CODE THEROY CYCLIC CODES
3/29
Every code polynomial c( x) is divisible by g( x), i.e. a multiple of
g( x).
7/30/2019 CODE THEROY CYCLIC CODES
4/29
4.3 Selecting the Parameters of a Cyclic Code
It can be shown that the generator polynomial g( x) of an ( n, k)
cyclic code is always a polynomial factor of the polynomial 1- x n ,
(or 1 x n + ).
This means that any factor of 1- x n of degree n-k is a possible
generator of an ( n, k) cyclic code.
Since g( x) divides 1- x n , it follows that
)()( x g x h1- x n =
where k k 2
210 x h x h x h h x h ++++= L)(
where 1 h h k0 ==
i.e. k1- k1- k 2
21 x x h x h x h1 x h +++++= L)( .
h( x) is called the parity polynomial of an ( n, k) cyclic code.
Since )()( x g x h1- x n
= , one has the important relation
)()()( 1- x mod 0 x g x h n= .
7/30/2019 CODE THEROY CYCLIC CODES
5/29
Define message polynomial as
1- k1- k
2 210 x m x m x m m x m ++++= L)(
Clearly, the product m( x) g( x) is the polynomial that represents
the codeword polynomial of degree n-1 or less.
An ( n, k) cyclic code is completely specified by the monic
generator polynomial
k- n1- k- n1- k- n1 x x g x g1 x g ++++= L)(
The codeword polynomial is expressed as
1- n1- n
2 210 x c x c x c c x c ++++= L)( .
1- n 2- n
2101- n
1 x c x c x c c x c ++++= L)()( .
7/30/2019 CODE THEROY CYCLIC CODES
6/29
c( x) and )()( x c 1 are related by the formula
)()()()( 1- x mod x xc x c n1 =
This follows from the fact that since both c( x) and )()( x c 1 are
code polynomials
and
)()(
)(
)(
)(
1- x c x c
1- x c x c x c c
c- x c x c c
x c x c x xc
n1- n
1
n1- n
1- n 2- n01- n
1- n n
1- n01- n
n1- n0
+=
++++=
+++=
++=
LL
L
Now,
)()(
)()()()()(
)(
x g x m
1- x mod x g x m x x ci
nii
=
=
This identity proves that if any codeword is cyclically shifted i
times, that another codeword in the cyclic code C is formed.
Thus, any set of kq codewords which possesses the cyclic
property is generated by some generator polynomial g( x).
7/30/2019 CODE THEROY CYCLIC CODES
7/29
4.4 Encoding of Cyclic Codes
Consider an ( n, k) cyclic code with generator polynomial g( x).
Suppose )( 1- k10 m , , m , m m L= is the message to be encoded.
1- k1- k10 x m x m m x m +++= L)( .
Multiplying m( x) by k- n x we obtain
1- n1- k
1 k- n1
k- n k- n x m x m x x m x +++= + L)(
Dividing )( x m x k- n by g( x), we have
)()()()( x p x g xq x m x k- n +=
where 1- k- n1- k- n10 x p x p p x p +++= L)( is the remainder.
Then, )()()()( x g xq x m x x p k- n =+ is a multiple of g( x) and
has degree n-1 . Hence it is the code polynomial for the message
m( x).
7/30/2019 CODE THEROY CYCLIC CODES
8/29
Note that
4 4 4 4 4 4 34 4 4 4 4 4 21L
4 4 4 4 34 4 4 4 21L
messageparity
)()(1- n
1- k1 k- n
1 k- n
01- k- n
1- k- n10
k- n
x m x m x m x p x p p
x m x x p
+++++++=
+
+
The code polynomial is in systematic form where p( x) is the
parity-check part.
The encoding can be implemented by using a division circuit
which is a shift register with feedback connections based on the
generator polynomial g( x), as shown below.
Figure 4.2.
Note that the right-most symbol of the word is the first symbol to
enter the encoder, subscript-order notwithstanding.
7/30/2019 CODE THEROY CYCLIC CODES
9/29
The gate is turned on until all the information digits have been
shifted into the circuit.
Note that
1- n1-i- n
1i1
i0
1-i1- n1i- ni- n
i
x c x c x c
x c x c c x c
++++
+++=
+
+
L
L)()(
and 1-i n1- n1i
1i
0i x c x c x c x c x ++ +++= L)(
Thus
)())((
)()()(
)(
)( x c1- x xq
1- x c1- x c1- x c
x c x c x c x c c x c x
i n
n1- n
n1i- n
ni- n
1- n1-i- n
i0
1-i1- n1i- ni- n
i
+=
++++
++++++=
+
+
L
LL
Syndrome circuit with input from the right end. ( Fig. 4.5(b) )
)( x r
7/30/2019 CODE THEROY CYCLIC CODES
10/29
After the entire r ( x) has been shifted into the register, the
contents in the register do not form the syndrome of r ( x);
Rather, they form the syndrome )()( x s k- n of )()( x r k- n , which is
the cyclic shift of r ( x).
This is because shifting r ( x) from the right end is equivalent to
premultiplying r ( x) by k- n x .
Since)())(()(
)()()()()( x r1- x x b x r x
x x g x a x r x k- n n k- n
k- n
+=
+=
and )()( x g x h1- x n =
we have )()()]()()([)()( x x g x a x h x b x r k- n ++=
This says that, when )()( x r k- n is divided by g( x), )( x is also
the remainder. Therefore )( x is )()( x s k- n .
7/30/2019 CODE THEROY CYCLIC CODES
11/29
Example 4.9 (page 153)
For a ( 7, 4) code, 3 x x1 x g ++=)(
)()( 0101100 c0101 m ==
Figure 4.3 Encoder for the ( 7, 4 ) cyclic code generated by3 x x1 x g ++=)( .
shift number i register contentsR 1 R 2 R 3
switch gate output
0 0 0 0 1 on 01 0 0 0 1 on 102 1 1 0 1 on 0103 0 1 1 1 on 10104 0 0 1 2 off 110105 0 0 0 2 off 0110106 0 0 0 2 off 0011010
Table 4.5 Encoding operation for the (7, 4) cyclic encoder shown in Fig. 4.3.
7/30/2019 CODE THEROY CYCLIC CODES
12/29
Code generation by using parity polynomial h ( x)
k k
2 210 x h x h x h h x h ++++= L)(
with 1 h h k0 ==
We want to show that a parity-check matrix C may be obtained
from h ( x).
Let )( 1- n10 c , , c , c c L= be a code vector of C
Then )()()( x g x m x c =
Multiply c( x) by h ( x), we obtain
)()(
))((
)()()()()(
x m x m x
1- x x m
x h x g x m x h x c
n
n
=
=
=
Since the degree of m( x) is k-1 or less, the powers
1- n1 k k x , , x , x L+ do not appear in )()( x m x m x n . If we expand
the product c( x) h( x) on the LHS of the above equation, the
coefficients of 1- n1 k k x , , x , x L+ must be equal to zero. Therefore,
we obtain the following n-k equalities:
k- n j10 c h k
0i j-i- ni
==
for (4.22)
7/30/2019 CODE THEROY CYCLIC CODES
13/29
Since 1 h k = , the above equation (4.22) can be put into the
following form:
k- n j1 c h c1- k
0i j-i- ni j- k- n
= =
for (4.24)
For a cyclic code in systematic form, the components
1- n1 k- n k- n c , , c , c L+ of each code vector are information (message)
digits.
Given these k message digits, the above equation is a rule to
determine the n-k parity-check digits, 1- k- n10 c , , c , c L .
An encoding circuit (with k-stage shift register) based on the
above equation is shown below. (Fig. 4.4)
Figure 4.4 A k-stage shift-register encoder for an ( n, k ) cyclic code generated by
the parity-check polynomialk
k
2
210 x h x h x h h x h++++= L
)( .
7/30/2019 CODE THEROY CYCLIC CODES
14/29
4.5 Syndrome Computation
Let c( x) and r ( x) be the transmitted code polynomial & received
polynomials, respectively.
Dividing r ( x) by the generator polynomial g( x), we have
)()()()( x s x g xq x r +=
where k- n1- k- n1- k- n 2
210 x x g x g x g g x g +++++= L)(
and 1- k- n1- k- n 2
210 x s x s x s s x s ++++= L)( is the remainder.
Then s( x) is the syndrome of r ( x).
r( x) is a code polynomial if and only if s( x) = 0.
Syndrome computation is done by a division circuit as shown
below:
)( x r
7/30/2019 CODE THEROY CYCLIC CODES
15/29
As soon as the entire r( x) has been shifted into the register, the
contents in the register form the syndrome s( x).
Since )()()( xe x c x r +=
and also )()()()( x s x g xq x r +=
we have
)()()]()([
)()()()()(
)()()()(
)()()(
x s x g x m xq
x g x m x s x g xq
x c x s x g xq
x c x r xe
++=
++=
++=
+=
or )()()( x g mod xe x s =
Hence the syndrome polynomial s( x) is also the remainder that
results from dividing e( x) by g( x).
7/30/2019 CODE THEROY CYCLIC CODES
16/29
4.6 Error Detection and Syndrome Decoding
Cyclic codes are very effective for error detection.
Suppose r ( x) is the received polynomial,
)()(-)]()()([
)(-)(
)()(
x h x g r x s x g xq x
1- x r x xr
x r x r x r r x r
1- n
n1- n
1- n 2- n
2101- n
1
+=
=
++++= L
(4.33)
Also denote that )()()()( )()( x s x g x a x r 11 +=
Where )()( x s 1 is the remainder that results from dividing
)()( x r 1 by g( x), i.e. the syndrome polynomial of the
cyclically-shifted received word )()( x r 1 .
From (4.33)
)()()]()()([
)()(-)()()()()()()(
)(
x s x g x h r x xq x a
x g x xq x h x g r x s x g x a x xs1
1- n
1- n1
++=
++=
Thus, )()( x s 1 is also the remainder which results from the
division of xs( x) by g( x).
That is, if )()( x r 1 is the cyclic shift of r ( x) one step to the right,
the syndrome )()( x s 1 which corresponds to )()( x r 1 satisfies
)()()()( x g mod x xs x s 1 = ( 4 . 35 )
7/30/2019 CODE THEROY CYCLIC CODES
17/29
Equation (4.35) generalizes easily to the i-th cyclical shift case.
That is, the remainder obtained by dividing )( x s x i by g( x) is
the syndrome )()( x s i corresponding to )()( x r i .
Example:
Consider the syndrome circuit for ( 7, 4) cyclic code generated by
3 x x1 x g ++=)( .
The code has 3 d min = and is capable of correcting any single
error in e( x).
Since the error patterns consist of the cyclic shifts of
(0 0 0 0 0 0 1 ), the decoder needs only to be able to recognize one
of the seven nonzero syndromes to be able to correct all of the
nonzero error patterns.
The syndrome s = (1 0 1), corresponding to the error pattern e =
(0 0 0 0 0 0 1), is the best choice since it allows one to release the
corrected codeword bits before the error location actually is
identified.
7/30/2019 CODE THEROY CYCLIC CODES
18/29
Fig. 4.6. (page 160)
)( x r)( x c
Decoding begins by first setting all of the shift-register cells to
zero. The received word r is then shifted bit-by-bit into the
7 -bit received word buffer and the syndrome-computation circuit,
simultaneously.
Once the received word is completely shifted into the buffer, the
shift-registers of the syndrome computation circuit contain the
syndrome for the received word. As one continues to shift
cyclically the contents of the received-word buffer and the
syndrome computation circuit, the syndrome computation circuit
computes the syndrome for the cyclically shifted versions of the
received word.
7/30/2019 CODE THEROY CYCLIC CODES
19/29
If at any point the computed syndrome is s = (1 0 1), i t is
detected by the AND gate when its output goes to 1. This value
is then used to complement and correct the error in the rightmost
bit in the buffer as it leaves the buffer.
7/30/2019 CODE THEROY CYCLIC CODES
20/29
A general decoder (Meggitt decoder) for an ( n, k) cyclic code is
shown below. (Lin / Costello p. 105)
The decoding operation is described as follows:
1. Shift the received polynomial r( x) into a buffer and the
syndrome registers simultaneously. (That is, syndrome is
formed.)
2. Check whether the syndrome s( x) corresponds to a correctable
error pattern 1- n1- n10 xe xee xe +++= L)( with an error at
the highest-order position 1- n x . (i.e. 1e 1- n = ?)
3. Correct 1- n r if 1e 1- n = .
4. Cyclically shift the buffer and syndrome registers once
simultaneously. Now the buffer register contains )()( x r 1 and
the syndrome register contains the syndrome )()( x s 1 of
)()( x r 1 .
5. Check whether )()(
x s1
corresponds to a correctable error
pattern )()( xe 1 with an error at the highest-order position
1- n x .
6. Correct 2- n r if it is erroneous.
7. Repeat the same process until n shifts.
7/30/2019 CODE THEROY CYCLIC CODES
21/29
8. If the error pattern is correctable, the buffer register contains
the transmitted codeword and the syndrome register contains
zeros.
9. If the syndrome register does not contain all zero at the end of
the decoding process, an uncorrectable error pattern has been
detected.
)( x r i r
ie
Figure 4.8 General cyclic code decoder with received polynomial r( x) shifted into
the syndrome register from left end.
7/30/2019 CODE THEROY CYCLIC CODES
22/29
4.7 Shortened Cyclic Codes
Suppose we wish to have information blocks of ( k-l ) digits, but we
use ( n, k) code with l < k.
Let )(876
LL
l
l -1- k10 000 , m , , m , m m =
If the code is a cyclic code in systematic form, the code words
generated are )(876
LLL
l
1-l - k101- k- n10 000 , m , , m , m , c , , c , c c =
There is no need to transmit the l zeros, since the receiver will
know this (because we are designing it). The code length is
l - n n' = .
In general, a code obtained from shortening a cyclic code is no
longer cyclic.
Shortened codes have error detection and correction capabilities
that are at least as good as the original codes.
7/30/2019 CODE THEROY CYCLIC CODES
23/29
Example:
Consider the ( 7, 4) cyclic code generated by 3 x x1 x g ++=)(
=
1000100
0100111
0010110
0001011
G
The generator matrix of the ( 6, 3) shortened code is obtained by
omitting the last row and column from G of the original ( 7, 4)
code.
=
100111
010110
001011
G'
and the parity-check matrix H' is obtained by omitting the last
column of H .
=
110100
111010
011001
H'
Decoding of shortened code
A shortened cyclic code ( n-l, k-l ) can be decoded by a decoder
similar to the original ( n, k) cyclic code. (Fig. 4.4)
7/30/2019 CODE THEROY CYCLIC CODES
24/29
Let 1-l - nl -1- n10 x r x r r x r +++= L)( be received polynomial.
Suppose that r ( x) is shifted into the syndrome register from the
right end. (Fig. 4.5(b))
If the decoding circuit for the original cyclic code is used for
decoding the shortened code, the proper syndrome for decoding
the received digit 1-l - n r is equal to the remainder resulting from
dividing )( x r x l - k- n by the generator polynomial g( x).
Since shifting r( x) into the syndrome register from the right end
is equivalent to premultiplying r ( x) by k- n x , the syndrome
register must be cyclically shifted for another l times after the
entire r ( x) has been shifted into the register.
These extra l shifts can be eliminated by modifying the
connection of the syndrome register:
Dividing )( x r x l - k- n by g( x), we obtain
)()()()( x s x g x a x r xl - k- n
1l - k- n
+=
Next, we divide l - k- n x by g( x).
Let 1- k- n1- k- n10 x x x +++= L)( be the remainder resulting
from this division. That is )()()( x g x a x x 2l - k- n +=
and then )()()]()()([)()()(
x s x g x r x a x a x r xl - k- n
21++=
7/30/2019 CODE THEROY CYCLIC CODES
25/29
The equation above suggests that we can obtain the syndrome
)()( x s l - k- n by multiplying r ( x) by )( x and dividing the product
)()( x r x by g( x).
Computing )( x s l - k- n this way, the extra l shifts of the syndrome
register can be avoided.
The circuit is shown below. (Lin / Costello, p. 117)
0 1 2 2- k- n 1- k- n
1- k- ng 2- k- ng 2g1g
Figure 4.15 Circuit for multiply by and dividing by
1- k- n1- k- n10 x x x +++= L)( and dividing )()( x r x by
k- n10 x x g g x g +++= L)(
7/30/2019 CODE THEROY CYCLIC CODES
26/29
4.8 CRC Codes
Cyclic Redundancy Check (CRC) Codes are error-detecting codes
typically used in automatic repeat request (ARQ) systems.
CRC codes have no error-correction capability but they can be
used in combination with an error-correcting code to improve the
performance of the system.
CRC codes are shortened cyclic codes.
Concatenated Coding System
7/30/2019 CODE THEROY CYCLIC CODES
27/29
CRC codes are often (but not always) constructed of polynomials
of the form )()()( x p1 x x g +=
where p( x) is a primitive polynomial of degree ( r-1 ) that divides
1- x1- r 2 .
16 -bit CRC-CCITT
1 x x x x g 51216 +++=)(
The 16 -bit CRC-CCITT is defined as the remainder obtained by
dividing the message polynomial 16 x x m )( by g( x).
The codewords are formed as a k-bit information sequence
followed by a check pattern of 16 bits (two 8-bit bytes) at the end
of message. The result is a ( k+16, k ) code.
7/30/2019 CODE THEROY CYCLIC CODES
28/29
Fig. 4.9. (page 178)
Figure 4.9 Systematic encoder for CCITT polynomial code with
1 x x x x g 51216 +++=)( .
In the encoding process, two zero bytes are added to the end of
the message, which are used when computing the CRC.
At the receiver the decoder simply computes the CRC of the
message part and adds the results to the CRC bytes, and then
tests to see whether the result equals zero.
7/30/2019 CODE THEROY CYCLIC CODES
29/29
A CRC constructed by an ( n, k) cyclic code is capable of detecting
any error burst of length n-k or less.
Also, the fraction of undetectable error burst of length n-k+1 is
)( 1 k- n- 2 + .
CRC in spread spectrum cellular system
1 x x x x x
x x x x x x x x x g 26 7 8
11121315 20 21 29 30
++++++
+++++++=)(
CRC used in ATM protocol (CRC-ATM)
1 x x x x g 28 +++=)(