Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

ECE 7670 Lecture 5 - Cyclic Codes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

ECE 7670

Lecture 5 Cyclic codes


Objective: To become acquainted with the basic concepts of cyclic codes and
some aspects of encoder implementations for them.
Reading:
Chapter 5.
1 Cyclic codes
Denition 1 An (n, k) linear block code C is said to be cyclic if for every code
word c = (c
0
, c
1
, . . . , c
n1
) in C, there is also a code word c

= (c
n1
, c
0
, . . . , c
n2
)
that is also in C. (c

is a cyclic shift of c.) 2


It will be convenient to represent our codewords as polynomials. The codeword
c = (c
0
, c
1
, . . . , c
n1
)
is represented by the polynomial
c(x) = c
0
+c
1
x + +c
n1
x
n1
using the obvious one-to-one correspondence. A cyclic shift can therefore be repre-
sented as follows. Observe that
xc(x) = c
0
x +c
1
x + +c
n1
x
n
.
If we not take this product modulo x
n
1 we get
xc(x) (mod x
n
1) = c
n1
+c
0
x + +x
n2
x
n1
.
So multiplication by x in the ring GF(q)[x]/(x
n
1) corresponds to a cyclic shift.
Furthermore, any power of x times a codeword yields a codeword (apply the de-
nition recursively), so that, for example,
(c
n1
, c
0
, c
1
, . . . , c
n2
) xc(x)
(c
n2
, c
n1
, c
0
, . . . , c
n3
) x
2
c(x)
.
.
.
(c
1
, c
2
, . . . , c
n1
, c
0
) x
n1
c(x)
where the arithmetic is done in the ring GF(q)[x]/(x
n
1). Now observe that if we
take an polynomial a(x) GF(q)[x] of the form
a(x) = a
0
+a
1
x + +a
n1
x
n1
then
c(x)a(a)
is simply a linear combination of cyclic shifts of c(x) and hence, must also be a
codeword. Hence: a cyclic code is an ideal in GF(q)[x]/(x
n
1). Because of
what we know about ideals in GF(q)[x]/(x
n
1) we can immediately make some
observations about cyclic codes:
A cyclic code has a generator polynomial g(x), which is the generator of the
ideal. Let the degree of g be r, where r < n.
ECE 7670: Lecture 5 Cyclic codes 2
Every code polynomial in the code can be expressed as a multiple of the
generator.
c(x) = m(x)g(x),
where m(x) is the message polynomial. The degree of m is less than n r.
The generator is a factor of x
n
1 in GF(q)[x].
Example 1 We will consider cyclic codes of length 15 with binary coecients. We
need to nd the factors of x
n
1 in some eld. Observe that
15|2
4
1,
so we are dealing in the eld GF(16). The conjugacy classes in GF(16) are
{1} x + 1
{,
2
,
4
,
8
} 1 +x +x
4
{
3
,
6
,
9
,
12
} 1 +x +x
2
+x
3
+x
4
{
5
,
10
} 1 +x +x
2
{
7
,
14
,
13
,
11
} 1 +x
3
+x
4
Thus
x
15
1 = (x + 1)(1 +x +x
4
)(1 +x +x
2
+x
3
+x
4
)(1 +x +x
2
)(1 +x
3
+x
4
)
So: degrees 1,2,4,4,4. If we want a generator of, say, degree 9, we could take
g(x) = (x + 1)(1 +x +x
4
)(1 +x +x
2
+x
3
+x
4
)
If we want a generator of degree 5 we could take
g(x) = (x + 1)(1 +x +x
4
)
or
g(x) = (x + 1)(1 +x +x
2
+x
3
+x
4
)
In fact, in this case, we can get generator polynomials of any degree from 1 to 15.
So we have codes
(15, 0)(15, 1), . . . , (15, 15)
2
A message sequence (m
0
, m
1
, . . . , m
k1
) (where k = n r) corresponds to a
message polynomial
m(x) = m
0
+ +m
k1
x
k1
.
Then the message polynomial corresponding to m is
c
m
(x) = m(x)g(x).
We can write this as
c
m
(x) = [m
0
, m
1
, . . . , m
k1
]

g(x)
xg(x)
.
.
.
x
k1
g(x)

ECE 7670: Lecture 5 Cyclic codes 3


Taking the next step, we can go back to a matrix representation,
c
m
=

m
0
, m
1
, . . . , m
k1

g
0
g
1
g
r
g
0
g
1
g
r
g
0
g
1
g
r
.
.
.
.
.
.
.
.
.
g
0
g
1
g
r
g
0
g
1
g
r

= mG
So we have a linear code, and can write the generator matrix corresponding to it.
Note: G is k n.
Let h(x) be parity check polynomial, that is a polynomial such that
x
n
1 = g(x)h(x).
Since codewords are multiples of g(x), then for a codeword,
c(x)h(x) = m(x)g(x)h(x) = m(x)(x
n
1) 0 (mod x
n
1).
We let
s(x) = c(x)h(x) (mod x
n
1).
be the syndrome polynomial. If s(x) is identically zero, then c(x) is a codeword.
Now lets put this in matrix form.
s(x) = c(x)h(x) =
n1

i=0
c
i
x
i
n1

j=0
h
j
x
j
(mod x
n
1).
Performing the multiplication,
s
k
=
n1

i=0
c
i
h
((ki))n
k = 0, 1, . . . , n 1.
Writing the last n k of these out, we have
[s
k
, s
k+1
, . . . , s
n1
] = [c
0
, c
1
, . . . , c
n1
]

h
k
h
k1
h
1
h
0
h
k
h
k1
h
1
h
0
.
.
.
.
.
.
h
k
h
k1
h
1
h
0
h
k
h
k1
h
1
h
0

T
= cH
T
.
Note: H is n k n
Example 2 Some cyclic codes of length 7. In GF(8) we have elements of order 7.
The minimal polynomials are
x + 1 x
3
+x + 1 x
3
+x
2
+ 1
We can choose any combination of these factors as factors of g(x). Let us take
g(x) = (x
3
+x + 1)(x + 1) = x
4
+x
3
+x
2
+ 1
Then h(x) = x
3
+x
2
+ 1. Here is the list of codewords
m(x)g(x) code polynomial code word
0g(x) 0 0000000
1g(x) 1 +x
2
+x
3
+x
4
1011100
xg(x) x +x
3
+x
4
+x
5
0101110
x
2
g(x) x
2
+x
4
+x
5
+x
6
0010111
(x
2
+ 1)g(x) 1 +x
3
+x
5
+x
6
1001011
(x
2
+x + 1)g(x) 1 +x +x
4
+x
6
1100101
(x + 1)g(x) 1 +x +x
2
+x
5
1110010
(x
2
+x)g(x) x +x
2
+x
3
+x
6
0111001
ECE 7670: Lecture 5 Cyclic codes 4
The corresponding generator and parity check matrix are
G =

1 0 1 1 1 0 0
0 1 0 1 1 1 0
0 0 1 0 1 1 1

H =

1 1 0 1 0 0 0
0 1 1 0 1 0 0
0 0 1 1 0 1 0
0 0 0 1 1 0 1

2
The codes to this point have not been systematic, but are easy to produce. We
will now do some tricks to make the code be systematic. We take the message block
m = (m
0
, m
1
, . . . , m
k1
) m(x) = m
0
+m
1
x + +m
k1
x
k1
.
Now take the code polynomial and shift it:
x
nk
m(x) = m
0
x
nk
+m
1
x
nk+1
+ +m
k1
x
n1
.
Observe that the code sequence corresponding to this is
(0, 0, . . . , 0, m
0
, m
1
, . . . , m
k1
)
Now we employ the division algorithm (this is the trick) to write
x
nk
m(x) = q(x)g(x) +d(x),
where d(x) has degree less than n k. That is, d(x) has the code sequence
(d
0
, d
1
, . . . , d
nk1
, 0, 0, . . . , 0)
Now form
x
nk
(x) d(x) = q(x)g(x).
Since the LHS is a multiple of g(x), it is a codeword. It has the form
(d
0
, d
1
, . . . , d
nk1
, m
0
, m
1
, . . . , m
k1
)
We have thus obtained a codeword in which the message data appears explicitly.
We have obtained by this trick a systematic code.
Example 3 We will demonstrate systematic coding in the (7, 3) code from before.
Let m(x) = 1 +x
2
from (1,0,1).
1. Compute x
nk
m(x) = x
4
m(x) = x
6
+x
4
.
2. Employ the division algorithm:
x
6
+x
4
= (x
2
+x + 1)(x
4
+x
3
+x
2
+ 1) + (x + 1).
3. Then our code polynomial is
c(x) = x
nk
m(x) d(x) = (1 +x) + (x
6
+x
4
) (1, 1, 0, 0, 1, 0, 1).
We can still explicitly see the message part. 2
2 Some hardware considerations
One of the justications for using cyclic codes, and using the polynomial repre-
sentation in general, is that there are some interesting and ecient hardware con-
gurations for performing the encoding operation. This has been of particularly
historical importance.
ECE 7670: Lecture 5 Cyclic codes 5
2.0.1 Galois eld operations
If we represent elements in a Galois eld using the m-tuple representation, addition
is easy, element-by element, using exclusive-or gates to perform the addition.
Multiplication by a xed Galois eld element is also fairly straightforward. Let
us take, as an example, multiplication in GF(2
4
). Let be in GF(2
4
), and represent
it as
= b
0
+b
1
+b
2

2
+b
3

3
.
That is, has the m-tuple representation (b
0
, b
1
, b
2
, b
3
). Let g be a xed element in
GF(2
4
), and suppose for this example, that g = 1 +. Let = g. Then
= c
0
+c
1
+c
2

2
+c
3

3
= (b
0
+b
1
+b
2

2
+b
3

3
)(1 +)
= b
0
+ (b
0
+b
1
) + (b
1
+b
2
)
2
+ (b
2
+b
3
)
3
+b
3

4
= (b
0
+b
3
) + (b
0
+b
1
+b
3
) + (b
1
+b
2
)
2
+ (b
2
+b
3
)
3
.
A hardware implementation is straightforward. (Draw a diagram.)
2.0.2 Polynomial multiplication
Now to compute m(x)g(x). This is simply a feed-forward (FIR) lter. The message
bits are fed in in descending order: m
k1
, m
k2
, . . . , m
0
:
As a specic example, we have, for g(x) = 1 +x
2
+x
3
+x
4
the following
Consider a specic example: m(x) = m
0
+m
1
x+m
2
x
2
and g(x) = g
0
+g
1
x+g
2
x
2
.
What about further shifts?
For the systematic encoding, we have three steps:
ECE 7670: Lecture 5 Cyclic codes 6
1. Multiply by x
nk
. This is accomplished by feeding into the middle of the shift
register:
2. Divide by g(x). Polynomial division is obtained using LFSR. To forma(x)/g(x),
we recognize (from signal processing experience) that division is accomplished
using a feedback connection.
The inputs are fed in in decreasing index order: a
n1
, a
n2
, . . . , a
0
. After the
last symbol has been fed in, the LFSR contains the remainder of a(x)/g(x).
ECE 7670: Lecture 5 Cyclic codes 7
3. Set c(x) = x
nk
m(x)d(x). Here we simply employ some switching circuitry:
Start in X: pass in message, which appears at output and goes into divider.
Then switch to Y and read out the parity bits.
3 Syndrome decoding
We now examine the question of decoding cyclic codes. Recall that for any linear
code, we can form a standard array; or we can use the reduced standard array using
syndromes. We will be able to exploit the cyclic structure of the codes to decrease
the memory requirements.
Consider the systematically-encoded codeword
c = (d
0
, d
1
, . . . , d
nk1
, m
0
, m
1
, . . . , m
k1
) = (d, m)
We can perform error detection as follows:
1. Estimate a message based on the systematic message part. Call this m

.
2. We then encode m

. Compute the parity bits from this to the received parity


bits. If they dont match, then an error is detected.
We can also use shift-register techniques. Recall that if we take r(x)h(x) modulo
x
n
1, we get a syndrome polynomial. But since
g(x)h(x) = x
n
1
we can use the division algorithm, dividing by g(x)
r(x) = a(x)g(x) +s(x).
But the division we can compute as we saw before.
We have the following useful result about cyclic codes and syndromes.
ECE 7670: Lecture 5 Cyclic codes 8
theorem 1 Let s(x) be the syndrome corresponding to r(x). Let r
(1)
(x) be the
polynomial obtained by cyclicly right-shifting r(x). Then the remainder obtained
when dividing xs(x) by g(x) is the syndrome denoted s
(1)
corresponding to r
(1)
(x).
In other words, shifts of r (mod x
n
1) correspond to shifts of s (modulo g).
Proof Write
r
(1)
(x) = xr(x) r
n1
(x
n
1).
(Show how this works.) Let us write
r(x) = a(x)g(x) +s(x).
Then
r
(1)
(x) = x[a(x)g(x) +sb(x)] r
n1
[g(x)h(x)].
Let us write this as
r
(1)
(x) = b(x)g(x) +d(x).
We note that d(x) must be the syndrome of r
(1)
(x). We also note from the previous
result, solving for xs(x),
xs(x) = [b(x)g(x)+d(x)]xa(x)g(x)+r
n1
g(x)h(x) = (b(x)xa(x)+r
n1
h(x))g(x)+d(x).
Thus d(x) is the remainder of xs(s) divided by g(x), establishing the theorem. 2
We conclude we can reduce the size of the syndrome lookup table. We need to only
store one syndrome s for an error e and all cyclic shifts of e. And we can compute
the shifts necessary using the same circuit that computes the syndrome in the rst
place.
Example 4
error syndrome syndrome poly
0000000 000 0
1000000 100 1
0100000 010 x
0010000 001 x
2
0001000 110 1 +x
0000100 011 x +x
2
0000010 111 1 +x +x
2
0000001 101 1 +x
2
Comment on the pattern. So all we have to do in this case is look for is any one
of the syndrome patterns (instead of many of them). We choose to look for 101,
ECE 7670: Lecture 5 Cyclic codes 9
since if we nd the error in that location, we can shift correct it on the end.
2
4 CRC codes
CRC codes are very commonly used for ARQ (automatic repeat request). Every
modem and network protocol uses ARQ, reverse error correction, even where for-
ward error correction may not be. They provide powerful error detection capability,
and are easily implemented. They are appropriate to talk about here, because they
are basically cyclic codes, with syndrome computation computed using LFSR.
CRC codes are simply binary cyclic codes with particular polynomials, chosen
to obtain good error detection capability.
We will explain the idea using notation from Data and Computer Communica-
tions by W. Stallings (5th Ed., Prentice-Hall). Let M(x) be a message polynomial
of degree k 1, and let R(X) be a parity check polynomial of degree n 1. Then
form
T(x) = x
n
M(x) +R(x).
Then we have a systematic representation of M(x) in T. This is the encoding
operation. The decoder takes the received signal and divides by some polynomial
P(x). We want to choose R(x) so that the remainder when T(x) is divided by P(x)
ECE 7670: Lecture 5 Cyclic codes 10
is exactly zero. We obtain R(x) as follows: Observe that we can write
x
n
M(x)
P(x)
= Q(x) +
r(x)
P(x)
Then if we set R(x) = r(x) (the remainder) we get the zero remainder that we
want. That is, we encode by forming
T(x) = x
n
M(x) +R(x).
Then we decode by dividing:
T(x)
P(x)
=
x
n
M(x) +R(x)
P(x)
= Q(x) +
R(x)
P(x)
+
R(x)
P(x)
= Q(x).
(all operations in GF(2)).
Example 5 Let M = 1010001101 M(x) = x
9
+ x
7
+ x
3
+ x
2
+ 1 and P =
110101 P(x) = x
5
+x
4
+x
2
+ 1.
1. Message is shifted by 2
5
, yielding 10100011010000.
2. Product is divided by P:
3. The remainder R = 01110 is added to give T = 101000110101110.
ECE 7670: Lecture 5 Cyclic codes 11
4. At the receiver, divide again by P:
If there is no remainder, it is assumed that there have been no errors.
2
A couple of common polynomials:
CRC-16x
16
+x
14
+x
2
+ 1
CRC-CCITTx
16
+x
12
+x
5
+ 1
How well do they work? We rst observe that an error is undetectable only if it
is divisible by P(x). A summary of some performance results follows for detectable
errors.
All single-bit errors.
All double-bit errors if weight(P(x)) 3.
Any odd number of errors if x + 1|P(x).
Any burst error for which the length of the burst is less than the length of
P(x).
Most larger burst errors.
The book provides some specics: CRC-16 or CRC-CCITT detects the following:
1. All single bursts of length 16 or less.
2. 99.997% of all error bursts of length 17.
3. 99.9985% of all error bursts of length > 17.

You might also like