Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 24

Chapter-1

1.1 Background

Coding is used for

– error detection and/or error correction (channel coding)


– ciphering (security) and compression (source coding)

In coding extra bits are added or removed in data transmission.

Channel coding can be realized by two approaches

– FEC (forward error coding)

block coding, often realized by cyclic coding

convolutional coding

– ARQ (automatic repeat request)

stop-and-wait

go-back-N

selective repeat … etc.

Note: ARQ applies FEC for error detection

A code is a set of binary vectors of the same fixed length


Definitions Parameters of codes
n = length of code vectors
R = code rate = (# info bits)/n
PU = Prob. of undetectable error

1
1.2 Introduction:

Cyclic codes are a special type of linear block code. Cyclic codes form an important
subclass of linear codes. These codes are attractive for two reasons:

 first, encoding and decoding can be implemented easily by employing shift-


registers with feedback connections (as will be seen later);
 second, because they have considerable inherent algebric structure, it is possible
to find various practical methods for decoding them.

In this section we can find a general overview of binary cyclic codes followed by their
mathematical representation and their main algebric properties (section 2). The third
section deals with the encoding procedure and decoding procedure of cyclic codes. But in
order to fully understand the cyclic codes, it becomes a little bit necessary to understand
thoroughly the linear block codes issue first.

1.3 Importance of Cyclic codes

• They are popular because they are very effective for error detection and correction
and their coders and decoders are easy to implement in hardware.
• They posses rich algebraic structure that can be utilized in a variety of ways.

• Encoding, decoding and syndrome computation easy by shift registers.

• They have extremely concise specifications.

• They can be efficiently implemented using simple shift registers.

• Many practically important codes are cyclic.

1.4 Some block codes that can be realized by cyclic codes

(n,1) Repetition codes. High coding gain, but low rate

2
(n,k) Hamming codes. Minimum distance always 3. Thus can detect 2 errors and correct
one error. n=2m-1, k = n - m, m≥3

Maximum-length codes. For every integer k ≥ 3 there exists a maximum length code
(n,k) with n = 2k - 1,dmin = 2k-1. Hamming codes are dual of maximal codes.

BCH-codes. For every integer there exist a code with n = 2m-1, k ≥ n – mt and dmin≥2t+1
and where t is the error correction capability

(n,k) Reed-Solomon (RS) codes. Works with k symbols that consists of m bits that are
encoded to yield code words of n symbols. For these codes n = 2m – 1, number of check
symbols n –k = 2t and dmin = 2t + 1.
Nowadays BCH and RS are very popular due to large dmin, large number of codes, and
easy generation

1.5 Polynomials and words

1.5.1 Polynomial of degree n over K


K [x ]  {a 0  a1x  a2x 2  a 3x 3  ....  an x n }
a 0 ,...., an  K , deg(f ( x ))  n

Example :

Let f (x )  1  x  x 3  x 4 g (x )  x  x 2  x 3 h (x )  1  x 2  x 4 then
(a ) f ( x )  g ( x )  1  x 2  x 4
(b ) f ( x )  h ( x )  x  x 2  x 3
(c ) f ( x )g ( x )  ( x  x 2  x 3 )  x ( x  x 2  x 3 )  x 3 ( x  x 2  x 3 ) 
x 4 (x  x 2  x 3 )  x  x 7

1.5.2 Division algorithm


Let f ( x ) and h ( x ) be in K [x ] with h ( x )  0. Then there exist
unique polynomial q ( x ) and r ( x ) in K [x ] such that

f ( x )  q ( x )h ( x )  r ( x ),
3
with r ( x )  0 or deg(r ( x ))  deg(h ( x ))
Example:

f (x )  x  x 2  x 6  x 8 , h (x )  1  x  x 2  x 4
q (x )  x 3  x 4 , r (x )  x  x 2  x 3
f ( X )  h ( x )( x 3  x 4 )  ( x  x 2  x 3 )
deg(r ( x ))  deg(h ( x ))  4

1.5.3 Code represented by a set of polynomials

A code C of length n can be represented as a set of polynomials over K of degree at most


n-1

f ( x )  a 0  a1x  a2x 2  ....  an 1x n 1 over K

c  a 0a1a2 ...an 1 of length n in K n

Example :

Polynomial c(x)
Codeword c
0000
0
1010 1+x2
0101 x+x3
1111 1+x+x2+x3

1.5.4 f(x) and p(x) are equivalent modulo h(x)

f ( x ) mod h (x )  r ( x )  p ( x ) mod h ( x )
ie . f ( x )  p ( x )(mod h ( x ))
Example :

f (x )  1  x 4  x 9  x 11 , h ( x )  1  x 5 , p ( x )  1  x 6
f ( x )mod h ( x )  r ( x )  14  x  p ( x ) mod h ( x )
=>f(x) and p(x) are equivalent mod h(x)!!
Example :
f ( x )  1  x 2  x 6  x 9  x 11 , h (x )  1  x 2  x 5 , p ( x )  x 2  x 8
f ( x ) mod h ( x )  x  x 4 , p ( x ) mod h ( x )  1  x 3
=>f(x) and p(x) are NOT equivalent mod h(x)!!

Lemma :
If f ( x )  g ( x )(mod h (x )), then
f ( x )  p ( x )  g ( x )  p ( x )(mod h ( x ))
and
f ( x ) p ( x )  g ( x ) p ( x )(mod h ( x ))

Example :

f (x )  1  x  x 7 , g (x )  1  x  x 2 , h (x )  1  x 5 , p (x )  1  x 6
so f ( x )  g ( x )(mod h ( x )), then

f (x )  p ( x ) and g ( x )  p (x ) :
((1  x  x 7 )  (1  x 6 ))mod h ( x )  x 2  ((1  x  x 2 )  (1  x 6 )) mod h ( x )

f (x ) p (x ) and g ( x ) p ( x ) :
((1  x  x 7 )(1  x 6 ))mod h ( x )  1  x 3  ((1  x  x 2 )(1  x 6 ))mod h ( x )

1.5.5 Cyclic shift π(v)

V: 010110, π(V) : 001011

5
v 10110 111000 0000 1011
 (v )
01011 011100 0000 1101

Chapter – 2

Cyclic Codes description

2.1 Cyclic code definition:

Lets start with the definition of cyclic shift:

If the components of an n-tuple are cyclically shifted one place to the

right, we obtain another n-tuple: which is called a cyclic shift of

. If the components of are cyclically shifted i places to the right, the resultant n-tuple

wouldbe: .

Clearly, cyclically shifting i places to the right is equivalent to cyclically shifting n-i
places to the left.

Definition:

A cyclic code is a linear (n,k) block code with the property that every cyclic shift of a
codeword results in another codeword. Cyclic shifts of any finite word [bn-1, bn-2, ..., b0] of
binary digits are generated by writing out the sequence and shifting the bits (left or right)
by the desired number, in such a way that any bits which exit the word at one end re-enter
the word at the other end. In other words, we shift bits with carry-around of bits that fall
of one end to the other end.
For example, the code with the generator matrix
1 0 1 1 1 0 0
 
G  0 1 0 1 1 1 0
0 0 1 0 1 1 1 

6
has codewords

c1 = 1011100 c2 = 0101110 c3 =0010111

c1 + c2 = 1110010 c1 + c3 = 1001011 c2 + c3 = 0111001

c1 + c2 + c3 = 1100101

and it is cyclic because the right shifts have the following impacts
c1 c2, c2 c3, c3 c1 + c3

c1 + c2 c2 + c3, c1 + c3 c1 + c2 + c3,

c2 + c3 c1, c1 + c2 + c3 c1 + c2

Example:
1 C = {(0000), (1111)} is cyclic
2 C = {(000), (110), (101), (011)} is cyclic
3 C = {(000), (100), (011), (111)} is not cyclic

2.2 Polynomial representation:

In order to develop the algebric properties of a cyclic code, we treat the components of a

code vector as the coefficients of a polynomial as follows:

7
Thus, each code vector corresponds to a polynomial of degree n-1 or less. We shall call

the code polynomial of . Before looking further into cyclic codes, we'll go over
some polynomial basics first:

 Polynomial division:

Division of two polynomials is best explained using an example :

Example: Compute (1 + x + x2 + x5)/(1 + x2).

Solution:

(Remember that because Thus

divides evenly and the result is .

 Arithmetic modulo p(x) (where p(x) is a polynomial):

8
In order to find , we simply divide by (as in example 2.1)

and take the remainder (we should note that if the degree of is smaller than

then the result is simply ).

Example: Compute 1 + x2 + x5 (mod 1 + x2).

Solution:

Hence:

 Cyclic shift using code polynomials:

A useful property of code polynomials is that the code polynomial (see above) is

simply the remainder resulting from dividing the polynomial by (the


reader is encouraged to prove it).

Example: Shift the codeword [1011] to the right once using polynomial manipulation.

Solution:

The vector (1011) corresponds to the polynomial . To Shift this polynomial

to the right once we first multiply by to get .

9
Then we find (mod )= (mod ):

Our result is .

Note that corresponds to [1101] which is [1011] shifted once to the right.

2.3 Cyclic codes algebric properties:

Cyclic codes are


– linear: sum of any two code words is a code word
– cyclic: any cyclic shift of a code word produces another code word
Advantages: Encoding, decoding and syndrome computation easy by shift registers.

Next, we state number of important algebraic properties of cyclic codes which make
possible the simple implementation of encoding and decoding computation:

Theorem 2.3.1:
The nonzero code polynomial of minimum degree in a cyclic code C is unique.
Theorem 2.3.2:

Let be the nonzero code polynomial of

minimum degree in an (n,k) cyclic code C. Then the constant term must be equal to 1.

2.4 Frequency of Cyclic Codes


Comparing with linear codes, the cyclic codes are quite scarce. For, example there are 11
811 linear (7,3) linear binary codes, but only two of them are cyclic.

10
Trivial cyclic codes. For any field F and any integer n >= 3 there are always the
following cyclic codes of length n over F:

• No-information code - code consisting of just one all-zero codeword.

• Repetition code - code consisting of codewords (a, a, …,a) for a Î F.

• Single-parity-check code - code consisting of all codewords with parity 0.

• No-parity code - code consisting of all codewords of length n

For some cases, for example for n = 19 and F = GF(2), the above four trivial cyclic codes
are the only cyclic codes.

2.5 Defining cyclic codes: code polynomial and generator polynomial


 An (n,k) linear code X is called a cyclic code when every cyclic shift of a code X,
as for instance X’, is also a code, e.g.

 Each (n,k) cyclic code has the associated code vector with the n-bit code
polynomial

 Note that the (n,k) code vector has the polynomial of degree of n-1 or less.
Mapping between code vector and code polynomial is one-to-one, e.g. they
specify each other uniquely
 Manipulation of the associated polynomial is done in a Galois field (for instance
GF(2)) having elements {0,1}, where operations are performed mod-2. Thus
results are always {0,1} -> binary logic circuits applicable
 For each cyclic code, there exists only one generator polynomial whose degree
equals the number of check bits q=n-k in the encoded word

11
Multiplication by a shift register

generator polynomial
determines connection Word to be
of taps encoded

(p + 1)(p2 + p + 1)
= p4 + p2 + p + p3 + p + 1
= p4 + p2 + p3 + 1 11101 Encoded word

Example: Generating of (7,4) cyclic code, by generator polynomial


G(p)=p3 +p+1
A polynomial to represent a binary word

M = (1101) = p3 + p2 + 1
G = (1011) = p3 + p + 1
X = MG = p3 (p3 + p2 + 1) + p (p3 + p2 + 1) + p3 + p2 + 1
= p6 + p5 + p3 + p4 + p3 + p + p3 + p2 + 1

12
= p6 + p5 + p4 + p3 + p2 + p + 1 = (1111111)

Factoring cyclic code generator polynomial


Any factor of pn+1 with the degree of q=n-k generates an (n,k) cyclic code
Example: Consider the polynomial p7+1. This can be factored as

p 7  1  ( p  1)( p 3  p  1)( p 3  p 2  1)

For instance the factors p3+p+1 or p3,+p2+1 can be used to generate an unique cyclic
code. For a message polynomial p2 +1 the following encoded word is generated:

( p 2  1)( p 3  p  1)  p 5  p 2  p  1
and the respective code vector (of degree n-1 or smaller) is
Hence, in this example

q  3  n  k k-bits n-bits

n  7  k  4 (n,k)
block coder

0101 100111

13
Chapter-3
Encoding and Decoding of Cyclic Codes

3.1 Encoding Cyclic codes


There are two ways of encoding
- nonsystematic
- systematic
Nonsystematic is easiest, but not preferred because of non symmetric codewords

3.1.1 Systematic cyclic codes


In systematic
1. multiply d(x) by xn-k
2. divide d(x) xn-k by g(x) to give remainder
3. add r(x) (remainder) to d(x) xn-k to give codeword
i.e. C(x)= d(x) xn-k + r(x)

Define the length q=n-k, check vector C and the length-k message
vector M by
M (p) = mk-1 pk-1 + ………… + m1 p + m0
C (p) = cq-1 pq-1 + …………. + c1 P + C0

14
Thus the systematic nth degree codeword polynomial is
X (p) = pn-k(mk-1 pk-1 + ……. + m1 p + m0 )
+ cq-1 pq-1 + ……. + c1 p + c0
message bits

check bits
= pq M(p) + C (p)

X (p) = M(p) G(p)


= pq M(p) + C(p) Definition of systematic cyclic code
Example: Encode 1011 in systematic form in the (7,4) codeword, having generator
polynomial x3+ x + 1.

Solution: 1. Express the data in polynomial form as d(x).


2. Multiply d(x) by xn-k
3. Divide the result by g(x) and take the remainder r(x).
4. Form the codeword polynomial as, add r(x) (remainder) to
d(x) xn-k to give codeword.

(1) d(x) = 1 + x2 + x3

15
(2) xn-k .d(x)= x3 + x5 + x6

(3)
x3+ x + 1 ) x6+ x5 + x3 (x + x + x + 1
3 2

x6 + x4 + x3

x4 + x3
x5 + x3+ x2

x4 + x3+ x2
x4 + x2 + x

x3+ x
x3+ x +1

1
So, r(x) = 1 or r =100

(4) c(x) = r(x) + xn-k d(x) = 1 + x3 + x5 + x6

c = rd = 1001011
which is systematic although the data word is found at the end of the codeword, rather
than at the beginning. The same data, encoded using the generator matrix of (6,1), would
yield the codeword 1011100.

3.1.2 Circuit for encoding systematic cyclic codes

16
Small circles represent multiplication by the corresponding constant, Å nodes represent
modular addition, squares are delay elements
We noticed earlier that cyclic codes can be generated by using shift registers whose
feedback coefficients are determined directly by the generating polynomial
For cyclic codes the generator polynomial is of the form
G(p) = pq + pq-1 gq-1 + pq-2 gq-2 + …. + p g1 + 1
In the circuit, first the message flows to the transmitter, and feedback switch is set to ‘1’,
where after check-bit-switch is turned on, and the feedback switch to ‘0’, enabling the
check bits to be outputted.

3.1.3 Shift Register Systematic Encoding

Cyclic codes involve shifting the polynomial bit by bit to include all the parity check bits
necessary for the predetermined code. The parity bits (parity polynomial) are calculated
and then placed in the appropriate location along side the message polynomial. The parity
polynomial is the remainder after dividing by the generator polynomial. It appears in the
register after n shifts through the (n – k) stage feedback register shown in the following
diagram.

17
(Figure 7)

Since the first n - k shifts through the register are merely filling the register, there cannot
be any feedback until the rightmost stage has been filled. Loading the input data to the
output of the last stage can shorten the shifting cycle. The circuit feedback connections
correspond to the coefficients of the generator polynomial G(X) which can be expressed
by equation shown below

G(X) = 1 + g1X + g2X2 + … + gn-k-1Xn-k-1+ xn-k [1]

The following describes the encoding procedure for the circuit shown in Figure 7:

1. Switch 1 is closed during the first k shifts, to allow transmission of the message into
the n- k stage encoding shift register.
2. Switch 2 is in the down position to allow transmission of the message bits directly to
anoutput register during the first k shifts.
3. After transmission of the kth message bit, switch 1 is opened and switch 2 is moved to
the up position.
4. The remaining n – k shifts clear the encoding register by moving the parity bits to the
output register.
5. The total number of shifts is equal to n, and the contents of the output register is the
codeword polynomial r(X) + xn-km(X).
For example, lets set the generator vector to 1101 and the message vector to 1011. If we

18
follow through the above steps, we see the redundant bits are calculated as shown in
Figure 8.
(Figure 8)
Input Queue Shift Number Register Contents Output
1011 0 000 -------
100 1 110 1
10 2 101 1
1 3 100 0
------- 4 100 1

Thus, for this example, the theoretical codeword will be the message bits appended by the
redundant bits held in the register contents of Figure 8, which yields 1001011.

3.2 Decoding Cyclic codes


1. Every valid, received code word R(p) must be a multiple of G(p), otherwise an
error has occurred. (Assume that the probability for noise to convert code words
to other code words is very small.)
2. Therefore dividing the R(p)/G(p) and considering the remainder as a syndrome
can reveal if an error has happened and sometimes also to reveal in which bit
(depending on code strength)
3. Division is accomplished by a shift registers whose tap order is reversed
4. The error syndrome of q=n-k bits is therefore

5. This can be expressed also in terms of the error E(p) and the
code word X(p) while noting that the received word is in terms of error

S(p) = mod [R(p) / G(p)]


Hence

S(p) = mod {[X(p) + E(p)] / G (p)}


[
S(p) = mod E(p) / G(p) ]

19
Example: Construct the decoding table for the single error correcting (7,4) code in the
table given. Determine the data vectors transmitted for the following received vectors r :
(a) 1101101; (b) 0101000; (c) 0001100.

Solution:
The first step is to construct the decoding table. Because n – k – 1 = 2, the syndrome
polynomial is of the 2nd order, and there are seven possible non zero syndrome. There are
also seven possible correctable single error patterns because n = 7. using equation
S(x) = mod [e(x)/g(x)]

We compute the syndrome for each of the seven correctable error patterns. For example,
for e = 1000000, e(x) = x6. because g(x) = x3 + x2 + 1 for this code.

Given table:
3 2
x +x +1 x ) 6
(x +x +x
3 2
d c
1111 1111111
x6 + x5 + x3 1110 1110010
1101 1101000
x5 + x3 1100 1100101
1011 1011100
x5 + x4 + x2 1010 1010001
1001 1001011
x4 + x3 + x2 1000 1000001
0111 0111001
x4 + x3 + x

x2 + x s(x)

s = 110

Table 1:
Similarly we can calculate rest of seven
e syndromes and sform a table, shown as Table 1
shown: 1000000 110
0100000 011
0010000 111
0001000 101
000010020 100
0000010 010
0000001 001
Then the received word is r is 1101101,

r(x) = x6 + x5 + x3 + x2 + 1

we now compute s(x) = mod [r(x) / g(x)]

x3 + x2 + 1 ) x +x +x +x +1(x
6 5 3 2 3

x6 + x5 + x3
x2 + 1

Hence, s = 101. From table 1. this gives e = 0001000, and

c = r + e = 1101101 + 0001000 = 1100101


Hence from the given table, we have
d = 1100
In a similar way, we can determine for r = 0101000, s = 110 and e = 1000000; hence c =

r + e = 1101000, and d = 1101. For r = 0001100, s = 001 and e = 0000001; hence c = r


+ e = 0001101, and d = 0001

3.2.1 Decoding in Cyclic Codes

21
The decoder for linear consists of three basic steps:
1. Calculating the syndrome of the received vector.
2. Identify the correctable error pattern that corresponds to syndrome calculated in step1.
The correspondence between the syndrome and a correctable error pattern is one-to-one.
This is the error pattern that presumably has occurred.
3. Correct the errors by taking the modulo-2 sum of the received vector and the error
pattern found in step 2.
A general decoder for an (n, k) cyclic code is shown in Figure 9. It consists of three major
parts. - A syndrome register
- An error pattern detector
- A buffer register

(Figure 9)

The correction procedure can be described as follows:


Step 1. Shifting the entire received vector into the syndrome register forms the syndrome.
At the same time, the received vector is stored into the buffer.
Step 2. The syndrome is read into the detector and is tested for the corresponding error
pattern. The detector is a combinational logic. It is designed in such a way that its output
is “ 1” if and only if the syndrome in the syndrome register corresponds to a correctable
error pattern with an error at the highest position order, n. That is if “1” appears at the
output of the detector the received symbol in the right most stage of the buffer register is

22
assumed to be erroneous and must be corrected. On the other hand, if a “0” appears at the
output of the detector, the received symbol at the rightmost stage of the buffer register is
assumed to be correct and no correction is necessary. This implies that the output of the
detector is the estimated error value for the symbol to come out of the buffer.
Step 3. The received symbol is read out of the buffer. At the same time, the syndrome
register is shifted once. If the received symbol is detected to be an erroneous symbol, it is
then corrected by the output of the detector. That output is also fed back into the
syndrome register to modify the syndrome. The result is a new syndrome, which
corresponds to the altered received vector shifted one place to the right.
Step 4. The new syndrome formed in Step 3 is used to detect whether or not the next
received symbol now at the rightmost stage of the buffer register, is an erroneous symbol.
If the symbol is in error, this next received symbol is then corrected in exactly the same
way as the first received symbol was corrected.
Step 5. The decoder decodes the received vector symbol by symbol in the above manner
until the entire received vector is read out of the buffer. After the entire received vector
has shifted through, the errors should have been corrected if they correspond to the error
pattern built into the detector, and the syndrome register will contain all zeros. If at the
end of the process the syndrome register does not contain all zeros, an uncorrectable error
has been detected. The error correction performance of the decoder depends largely on
the capacity of error patterns built into the detector.

3.3 Drawback
These cyclic codes can also be calculated with the help of shift register. But the circuit
needs many shift register to be cascaded, so that the circuit becomes complex.

Reference

1. Bernard Sklar, “Digital Communications Fundamentals and Applications”, Prentice

23
Hall,1988.

2. Dr. Alex Grant, “ECC 1550 Homepage, http://www.itr.unisa.edu.au/~alex/ECC/”.

3. Gilbert, Jimmie, Linda Gilbert, “Elements of Modern Algebra”, Brooks/Cole, 2000.

4. Hill, Raymond, “A First Course In Coding Theory”, New York: Oxford University
Press, 1988.

5. J.H. Van Lint, “Introduction to Coding Theory”, Graduate Texts in Mathematics 86,
Springer Verlag, 1998.

6. Lin, Shu, “ Error Control Coding: Fundamentals and applications ”, Prentice Hall,
1983.

7. Poli, Allen, “ Error Correcting Codes: theory and Applications ”, Prentice Hall, 1992.

8. Roman, Steve, “Introduction to Coding and Information Theory”, Springer, 1997.

9. W. Wesley Peterson, “ Error-correcting codes”, MIT Press, 1961.

24

You might also like