0% found this document useful (0 votes)
250 views16 pages

Verilog Implementation of Reed - Solomon Code

Reed-Solomon codes are non-binary cyclic error-correcting codes that can detect and correct multiple symbol errors. By adding check symbols, an RS code can detect up to t errors and correct up to t/2 errors. Source symbols are viewed as coefficients of a polynomial over a finite field. Encoding creates code symbols by evaluating the polynomial at different points. Decoding uses techniques like Berlekamp-Massey algorithm. RS codes can also correct erasures and are suitable for correcting burst errors.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
250 views16 pages

Verilog Implementation of Reed - Solomon Code

Reed-Solomon codes are non-binary cyclic error-correcting codes that can detect and correct multiple symbol errors. By adding check symbols, an RS code can detect up to t errors and correct up to t/2 errors. Source symbols are viewed as coefficients of a polynomial over a finite field. Encoding creates code symbols by evaluating the polynomial at different points. Decoding uses techniques like Berlekamp-Massey algorithm. RS codes can also correct erasures and are suitable for correcting burst errors.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 16

Verilog Implementation of Reed – Solomon Code

Reed–Solomon (RS) code is non-binary cyclic error-correcting codes. It describes a


systematic way of building codes that could detect and correct multiple random symbol
errors. By adding t check symbols to the data, an RS code can detect any combination of up
to t erroneous symbols, and correct up to ⌊ t/2 ⌋ symbols. As an erasure code, it can correct
up to t known erasures, or it can detect and correct combinations of errors and erasures.
Furthermore, RS codes are suitable as multiple-burst bit-error correcting codes, since a
sequence of b+1 consecutive bit errors can affect at most two symbols of size b.

In Reed-Solomon coding, source symbols are viewed as coefficients of a polynomial p(x)


over a finite field. The original idea was to create n code symbols from k source symbols by
oversampling p(x) at n > k distinct points, transmit the sampled points, and use interpolation
techniques at the receiver to recover the original message. RS codes are viewed as cyclic
BCH codes, where encoding symbols are derived from the coefficients of a polynomial
constructed by multiplying p(x) with a cyclic generator polynomial. This gives rise to an
efficient decoding algorithm, which was discovered by Elwyn Berlekamp and James Massey,
and is known as the Berlekamp-Massey decoding algorithm.

The original concept of Reed-Solomon codes describes encoding of k message symbols by


viewing them as coefficients of a polynomial p(x) of maximum degree k-1 over a finite field
of order N, and evaluating the polynomial at n>k distinct input points. Sampling a
polynomial of degree k-1 at more than k points creates an overdetermined system, and allows
recovery of the polynomial at the receiver given any k out of n sample points using
(Lagrange) interpolation. The sequence of distinct points is created by a generator of the
finite field's multiplicative group, and includes 0, thus permitting any value of n up to N.

Using a mathematical formulation, let (x1, x2, ..., xn) be the input sequence of n distinct values
over the finite field F; then the codebook C created from the tuplets of values obtained by
evaluating every polynomial (over F) of degree less than k at each xi is

where F[x] is the polynomial ring over F, and k and n are chosen such that 1 ≤ k ≤ n ≤ N.

As described above, an input sequence (x1, x2, ..., xn) of n=N values is created as
,

where α is a primitive root of F. When omitting 0 from the sequence, and since αN-1 = 1, it
follows that for every polynomial p(x) the function p(αx) is also a polynomial of the same
degree, and its codeword is a cyclic left-shift of the codeword derived from p(x); thus, a
Reed–Solomon code can be viewed as a cyclic code.

In practice, instead of sending sample values of a polynomial, the encoding symbols


are viewed as the coefficients of an output polynomial s(x) constructed by multiplying the
message polynomial p(x) of maximum degree k-1 by a generator polynomial g(x) of degree
t=N-k-1. The generator polynomial g(x) is defined by having α, α2, ..., αt as its roots, i.e.,

1. GALOIS FIELD:

A Finite Field is a field with a finite field order (i.e., number of elements), also called a
Galois field. The order of a finite field is always a prime or a power of a prime . For each
prime power, there exists exactly one finite field GF(pm ).A Field is said to be infinite if it
consists of infinite number of elements, for e.g. Set of real numbers, complex numbers etc.
Finite field on the other hand consist of finite number of elements. GF(pm ) is an extension
field of the ground field GF(p), where m is a positive integer. For p = 2 , GF(2m ) is an
extension field of the ground field GF(2) of two elements (0,l).

GF(2m ) is a vector space of dimension m over GF(2) and hence is represented using a basis
of m linearly independent vectors. The finite field (2m ) GF contains (2m −1) non zero
elements. All finite fields contain a zero element and an element, called a generator or
primitive element α , such that every non-zero element in the field can be expressed as a
power of this element. The existence of this primitive element (of order 2m -1) is asserted by
the fact that the nonzero elements of GF(2m ) form a cyclic group.

.
1.1 PROPERTIES OF GALOIS FIELDS

1. In GF(2m) fields, there is always a primitive element α , such that you can express
every element of GF(2m ). You can generate every field GF(2m ) using a primitive
polynomial over GF(2), and the arithmetic performed in the GF(2m) field is modulo
this primitive polynomial.
2. If α is a primitive element of GF(2m), its conjugate α 2m is also primitive elements of
3. GF(2m ).
4. If α is an element of order n in GF(2m), all its conjugates have the same order n.
5. If α , an element in GF(2m), is a root of a polynomial f(x) over GF(2), then all the
distinct conjugates of α , also elements in GF(2m), are roots of f(x).
6. Every element α of GF (2m) has a unique minimal polynomial over GF (2).
7. The minimal polynomial φ (x), which is also irreducible, of an element α in GF(pm) is

8. Any operation on elements of the field will preserve the closure property. Every
element has an additive and multiplicative inverse (except for ’0’ which has no
multiplicative inverse).

1.2 CONSTRUCTION OF GALOIS FIELDS

A Galois field GF (2m) with primitive element α is generally represented as (0, 1, α ,α2 ,
2k -2
………. α ). The simplest example of a finite field is the binary field consisting of the
elements (0, 1). Traditionally referred to as GF(2)2 , the operations in this field are defined as
integer addition and multiplication reduced modulo 2. Larger fields can be created by
extending GF(2) into vector space leading to finite fields of size 2m . These are simple
extensions of the base field GF(2) over m dimensions. The field GF(2m) is thus defined as a
field with 2m elements each of which is a binary m-tuple. Using this definition, m bits of
binary data can be grouped and referred to it as an element of GF(2 m). This in turn allows
applying the associated mathematical operations of the field to encode and decode data [10].
Let the primitive polynomial be φ (x), of degree m over GF(2m). Now any ith element of the
field is given by
Hence all the elements of this field can be generated as powers of α . This is the polynomial
representation of the field elements, and also assumes the leading coefficient of φ (x) to be
equal to 1.

1.3 ADDITION/SUBTRACTION:

Generally the field GF (2 m ) represents a set of integers from zero to 2m- 1. Addition and
subtraction of elements of GF(2m) are simple XOR operations of the two operands. Each of
the elements in the GF is first represented as a corresponding polynomial. The addition or
subtraction operation is then represented by the XOR operation of the coefficient of
corresponding polynomials. However since the more complex operations are extensively
used in RS encoding and decoding algorithms, the development of their hardware structures
have received considerable attention. Note that GFA does not distinguish between addition
and subtraction operations; both are considered as XOR operations. Since both operations
follow modulo arithmetic, the result always evaluates to a value within the field.

1.4 MULTIPLICATION

Multiplication operation over the Galois Field is a more complex operation than the
addition/subtraction operation. It is also based on modulo arithmetic.

Let A=a0+a1α+………+am-1αm-1 and B=b0+b1α+………+bm-1αm-1 be two elements from GF(2m),


then A+ B=C= C0+C1α+………+cm-1αm-1
This is the normal add operation and can be achieved by following the methodology
described above. The multiplication over GF(2m) is defined through
a(x) xor b(x) = a(x)b(x) mod f (x)

The first step is building of the partial products,Pi(x)= a(x)bi xi (0 ≤ i <m),


Next, all partial products Pi(x) i have to be added modulo 2. A partial result Cp(x) is thus
obtained.

This partial result, however is not a element of the field GF(2). Hence the highest order term

xh of C (x) has to be reduced using the following property of the irreducible polynomial
p
The substitution starts with the highest order term c2m-2 x2m-2 is used to produce a partial result
Cp of one degree less than Cp :

This shifting operation is continued until Cp(x) is of degree m-1, i.e. it becomes an element of
GF(2m). The result of a GF(2) multiplication is a (2m –1 ) bit word, which represents a degree
(2m– 2) polynomial in extended form. For m=8, the product is represented as follows:
Consider two operands in the GF(28),

the product can be represented as follows:

The product is a 15-bit word, containing the coefficients of the extended form polynomial
Prod(a). This word contains the coefficients of the extended form polynomial Prod (a). The
extended form polynomial is reduced modulo f(x). This is equivalent to calculating the
remainder from the extended form polynomial divided by f(x). The remainder in this case is a
polynomial of degree 7 with 8 binary coefficients and therefore represents a valid element of
GF(28).

[b(0)+b(1)α+b(2)α2+b(3)α3+b(4)α4+b(5)α5+b(6)α6+b(7)α7]*

[a(0)+a(1)α+a(2)α2+a(3)α3+a(4)α4+a(5)α5+a(6)α6+a(7)α7]=

b(0)*[a(0)+a(1)α+a(2)α2+a(3)α3+a(4)α4+a(5)α5+a(6)α6+a(7)α7]+

b(1) α *[ a(0)+a(1)α+a(2)α2+a(3)α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α2+α7
α14=1+α+α4

2. RS ENCODING

Encoding is a process of converting a input message into a corresponding codeword, where


each codeword ∈ GF (2m). A RS codeword is generated by a polynomial g(x) of degree n-k
with coefficient from GF (2m). According to [37] , for a t-error correcting RS code, this
generator polynomial is given by:

where α is a primitive element in GF(2m).

2.1 FORMING CODEWORDS

Let a message or data unit is represented in the polynomial form as

and the codeword be represented as

represent the result of multiplication of the data unit with the generator polynomial. One
important property of G(x) is that it exactly divides c (x), assume Q(x) and P(x) to be the
corresponding quotient and remainder, hence the codeword looks like

Here P(x) is the polynomial which represents the check symbols. Dividing by the generator
polynomial and rewriting gives

Q(x) can be identified as ratio and – P(x) as a remainder after division by G(x). The idea is
that by concatenating these parity symbols to the end of data symbols, a codeword is created
which is exactly divisible by g(x). So when the decoder receives the message block, it divides
it with the RS generator polynomial. If the remainder is zero, then no errors are detected, else
indicates the presence of errors.
The lowest degree term in X n−k M(x) is m0 x n-k 0 , while P(x) is of degree at most n-k-1,
it follows that the codeword is given by
and it
consists of the data symbols followed by the parity-check symbols.

2.2 RS ENCODER

As previously mentioned, RS codes are systematic, so for encoding, the information symbols
in the codeword are placed as the higher power coefficients. This requires that information
symbols must be shifted from power level of n-1 down to n-k and the remaining positions
from power n-k-1 to 0 be filled with zeros. Therefore any RS encoder design should
effectively perform the following two operations, namely division and shifting. [28] suggests
that both operations can be easily implemented using Linear-Feedback Shift Registers.The
parity symbols are computed by performing a polynomial division using GF algebra. The
steps involved in this computation are as follows:
1. Multiply the message symbols by Xn-k. This shifts the message symbols to the left to
make space for the n-k parity symbols.
2. Divide the message polynomial by the code generator polynomial using GF algebra.
3. The parity symbols are the remainder of this division. These steps are accomplished in
hardware using a shift register with feedback. The architecture for the encoder is
shown in Figure 1.

The encoder block diagram shows that one input to each multiplier is a constant fieldelement,
which is a coefficient of the polynomial g(x). For a particular block, the information
polynomial M(x) is given into the encoder symbol by symbol. These symbols appear at the
output of the encoder after a desired latency, where control logic feeds it back through an
adder to produce the related parity. This process continues until all of the k symbols of M(x)
are input to the encoder. During this time, the control logic at the output enables only the
input data path, while keeping the parity path disabled. With an output latency of about one
clock cycle, the encoder outputs the last information symbol at (k+1)th clock pulse. Also,
during the first k clock cycles, the feedback control logic feeds the adder output to the bus.
After the last symbol has been input into the encoder (at the kth clock pulse), a wait period of
at least n-k clock cycles occurs. During this waiting time, the feedback control logic disables.
Feedback
Gate

g0 g1 g2 g2t-1

b b
b0 b1 2t-2 2t-1

Input symbols
Select Input or
Parity symbols

b
2t-2

m bit Galois Galois


register multiplier adder

Figure 1- RS Encoder Circuitry

The encoder block diagram shows that one input to each multiplier is a constant field
element, which is a coefficient of the polynomial g(x). For a particular block, the information
polynomial M(x) is given into the encoder symbol by symbol. These symbols appear at the
output of the encoder after a desired latency, where control logic feeds it back through an
adder to produce the related parity. This process continues until all of the k symbols of M(x)
are input to the encoder. During this time, the control logic at the output enables only the
input data path, while keeping the parity path disabled. With an output latency of about one
clock cycle, the encoder outputs the last information symbol at (k+1)th clock pulse. Also,
during the first k clock cycles, the feedback control logic feeds the adder output to the bus.
After the last symbol has been input into the encoder (at the kth clock pulse), a wait period of
at least n-k clock cycles occurs. During this waiting time, the feedback control logic disables
the adder output from being fed back and supplies a constant zero symbol to the bus. Also,
the output control logic disables the input data path and allows the encoder to output the
parity symbols (k+2th to n+1th clock pulse). Hence, a new block can be started at the n+1th
clock pulse [28].

2.3 Properties

The Reed-Solomon code is a [n, k, n-k+1] code; in other words, it is a linear block code of
length n (over F) with dimension k and minimum Hamming distance n-k+1. The Reed-
Solomon code is optimal in the sense that the minimum distance has the maximum value
possible for a linear code of size (n,k); this is known as the Singleton bound. Such a code is
also called a maximum distance separable code.

The error-correcting ability of a Reed–Solomon code is determined by its minimum distance,


or equivalently, by n − k, the measure of redundancy in the block. If the locations of the error
symbols are not known in advance, then a Reed–Solomon code can correct up to (n − k) / 2
erroneous symbols, i.e., it can correct half as many errors as there are redundant symbols
added to the block. Sometimes error locations are known in advance (e.g., “side information”
in demodulator signal-to-noise ratios)—these are called erasures. A Reed–Solomon code is
able to correct twice as many erasures as errors, and any combination of errors and erasures
can be corrected as long as the relation 2E + S ≤ n - k is satisfied, where E is the number of
errors and S is the number of erasures in the block.

For practical uses of Reed–Solomon codes, it is common to use a finite field F with 2m
elements. In this case, each symbol can be represented as an m-bit value. The sender sends
the data points as encoded blocks, and the number of symbols in the encoded block is n = 2m
− 1. Thus a Reed–Solomon code operating on 8-bit symbols has n = 28 − 1 = 255 symbols per
block. (This is a very popular value because of the prevalence of byte-oriented computer
systems.) The number k, with k < n, of data symbols in the block is a design parameter. A
commonly used code encodes k = 239 eight-bit data symbols plus 16 eight-bit parity symbols
in an n = 255-symbol block; this is denoted as a (n,k) = (255,239) code, and is capable of
correcting up to 8 symbol errors per block.

The above properties of Reed–Solomon codes make them especially well-suited to


applications where errors occur in bursts. This is because it does not matter to the code how
many bits in a symbol are in error — if multiple bits in a symbol are corrupted it only counts
as a single error. Conversely, if a data stream is not characterized by error bursts or drop-outs
but by random single bit errors, a Reed–Solomon code is usually a poor choice compared to a
binary code.

The Reed–Solomon code, like the convolutional code, is a transparent code. This means that
if the channel symbols have been inverted somewhere along the line, the decoders will still
operate. The result will be the inversion of the original data. However, the Reed–Solomon
code loses its transparency when the code is shortened. The "missing" bits in a shortened
code need to be filled by either zeros or ones, depending on whether the data is
complemented or not. (To put it another way, if the symbols are inverted, then the zero-fill
needs to be inverted to a one-fill.) For this reason it is mandatory that the sense of the data
(i.e., true or complemented) be resolved before Reed–Solomon decoding.

3. Simuation results:

1.inputs:

Generation polynomial:

gin0 = 8'b00010000; gin1 = 8'hAB;

gin2 = 8'hCD; gin3 = 8'h8E;

gin4 = 8'h93; gin5=8'hAB;

gin6=8'h8E; gin7=8'hCD;

gin8=8'hFA; gin9=8'hEE;

gin10=8'hFF; gin11=8'h0C;

gin12=8'hAB; gin13= 8'h26;

gin14=8'h35; gin15=8'h89;

datain

datain = 8'hF0;

datain = 8'h82;

datain = 8'hEE;
datain = 8'h71;

datain = 8'h04;

datain = 8'h24;

datain = 8'h9A;

datain = 8'hEA;

datain = 8'h6E;

datain = 8'hEF;

datain = 8'hDD;

datain = 8'hF0;

datain = 8'hAC;

datain = 8'h1C;

q15=E4

q14=9A

q13=AB

q12=86

q11=05

q10=D5

q9=D0

q8=E5

q7=E1

q6=3D

q5=F7

q4=06

q3=2C

q2=0D

q1=D7
q0=62
RTL schematic:

Device utilization summary:

Selected Device : 3s500efg320-5


Number of Slices: 719 out of 4656
Number of Slice Flip Flops: 139 out of 9312
Number of 4 input LUTs: 1378 out of 9312
Number of IOs: 267
Number of bonded IOBs: 267 out of 232
Number of GCLKs: 1 out of 24

Timing Summary:
Minimum period: 5.933ns
Maximum Frequency: 168.554 MHz
Minimum input arrival time before clock: 6.985ns
Maximum output required time after clock: 4.782ns

You might also like