GENERIC REED SOLOMON ENCODER

Reed Solomon (RS) codes is a mechanism to detect and correct burst of errors in data transmission and storage systems. It provides a solid introduction to foundation mathematical concept of Galois Field algebra and its application. With the development of digital hardware technology, the RS concepts were brought into reality, i.e. the implementation of RS codec chips. This paper presents the development steps of a generic RS encoder using VHDL. The encoder is able to handle generic width of data, variable length of information, number of error as well as variable form of primitive polynomial and generator polynomial used in the system. The design has been implemented for FPGA chip Xilinx XC3S200-5FT256 and has a better performance than commercially available equivalent encoder.


Introduction
Reed Solomon (RS) codes are block-based error-correcting mechanism in a wide range of applications in digital transmission and storage.The RS encoder takes a block of data and adds extra redundant bits.A block of RS codes described in Figure 1 consists of K information symbols added by 2t parity symbols to make an N symbol codeword.In this scheme, the RS decoder can correct up to t symbols that contain errors in the codeword, and specified as RS(N,K).Given a symbol size m-bit, the maximum codeword length is N=2 m -1.These variables are referred frequently throughout the discussion in this paper.
While most published RS codec implementation have specific size and features [1][2][3], this paper presents the development of a generic Reed-Solomon encoder, whose characteristics can be altered by modifying the parameters.They are: length of information symbol (K), length of parity symbol (2t), size of symbol (m), primitive polynomial p(x) and generator polynomial P(x).The motivation of designing a generic encoder is to increase modularity and reusability, whereas design reuse is one of best practices in increasing productivity and efficiency.
It is assumed that the readers are familiar with fundamental aspects of finite fields discussed in many textbooks, some of them are [4,5].

RS Encoding Process
This section gives an overview of RS encoding process with a short data as an example, i.e.RS (7,3).It means that the RS codes have seven codeword symbols, three of which are the original information symbols and the rest are parity symbols.Let each is 3-bit symbol.The information that will be transmitted is divided into three 3-bit blocks, each of which is added by four 3-bit symbols to make 7 codewords symbols.The field elements for m = 3 using primitive polynomial x 3 + x + 1 are presented in Table 1.
A Reed Solomon codeword is constructed using a special polynomial called generator polynomial.All valid codewords are divisible by the generator poly-nomial.The general form of a generator polynomial is: and the codeword is constructed using: where g(x) is the generator polynomial, i(x) is the information block, c(x) is a valid codeword.
In this example, the maximum error can be corrected is t = 2. Let we use i = 1 for equation (1), hence the generator polynomial is The generator polynomial g(x) is used to divide the information symbols multiplied by x (N-K) .The remainder must be added to the information symbols to make it divisible by g(x).Hence, the remainder of the division is the parity symbols P i .
Therefore, the dividend symbols plus parity symbols are the codewords to be transmitted through a communi-cation channel.

c(x) = i(x).x N-K + p(x)
(5 ) Manual calculation can be done by applying GF algebra in a long division of the symbols.The remainder symbols p(x) = 3 0 4 2 are added to the information symbols that have been shifted 4 'spaces' to the left.
Now we have the whole codeword to be transmitted, i.e. the binary representation of all symbols: 100 011 110 011 001 110 100.
Thus, a Reed Solomon encoding process consists of the following steps: 1. Multiply the information symbols with X (N-K) .This can be done by shifting the information symbols to the left to allow space for 2t parity symbols.2. Divide the result of step 1 with the generator polynomial using GF algebra 3. Add the result of step 2 (remainder of division) to the result of step 1

Implementation Methods
Adapted from [4], the schematic design of RS Encoder is shown in Figure 2. g(x) is the generator polynomial used to generate parity symbols P(x).The number of registers used is equal to N-K.Parity symbols are generated by serial entry of the information symbols into i(X).Right after N-K pulses of clock, P holds the generated parity symbols.In our sample codes, the sequence of parity symbols constructed in P(x) is described in Table 2.
The benefit of a generic or parameterized design is the ease of system's characteristics modification by changing a set of parameters.Specifically in hardware description language (HDL), a single parameterized design can be compiled for any size of data.Hardware space and time consumptions can be quickly evaluated  modifying the values of parameters and recompilation.The following sections describe major steps in developing a parameterized RS Encoder using Very High Speed Integrated Circuit HDL (VHDL).VHDL is a hardware description language used to describe the behavior and structure of digital systems.It allows a digital system to be designed and debugged at a higher level before converted to the gate and flip-flop levels.More on VHDL can be learnt from [6] and the RS VHDL design will be described in section 3.3.
Apparently from Figure 2, GF multipliers and adders are required for the system.Adders can easily be implemented by m-bit XOR gates.However, we need to implement a multiplier module, whose process depends on the primitive polynomial used for generating field elements.
To hold variable and temporary values, we use Shift Register with Parallel Load (SRwPL) as described in [7] for all registers used in the circuit.The SRwPL has generic width input and output, 2-bit operation mode (00=hold, 01=load, 10=shift left, 11=shift right), and 2-bit input (1-bit Left Input and 1-bit Right Input).

Generic Bit-Serial Multiplication
In building a parameterized encoder, we need to develop a generic serial multiplicator.A parallel multiplicator with fixed combinatorial logics cannot be used here, because its characteristic is tied to a certain size of data and polynomial type.The original design of standard-shift-register (SSR) was introduced by Peterson [8] and republished by Scott et.al.[9].Multiplication holds the following equation: According to Mastrovito [10], C(x) can be calculated as follows:

.((b i xA(x) mod P(x))x mod P(x)) ...)x mod P(x) (9)
with x appears i times in the equation.Based on equation ( 8) and ( 9), we obtain the sequential multiplier design in Figure 3.The internal process of multiplication can be described as follows: For example we want to compute 10 6 in GF( 2 As we can see from the simulation in Figure 4, multiplication module has four main registers, i.e. two registers for the operands (A and B), one register for primitive polynomial (P), and one register for the result (C).Each register has 2-bit selector mode Sa, Sb, Sp and Sc.As described in Figure 2, this multiplicator module is duplicated N-K times and concurrently driven by clock to perform synchronous multiplications.

Controller
We have learnt from Figure 4 that a certain number of states are required for the multiplication.To produce parity symbols in RS codes, the multiplication process is performed N-K times.A controller is required to perform this series of multiplication.In addition, it also drives the behavior of register P(x) and feeds the i(x) input with appropriate symbols serially.Algorithm of the controller behaves as follows: 1. Reset all registers 2. Set primitive polynomial and generator polynomial used 3. Initialize all registers (all Sx = "1" to load new values) 4. Loop m times for multiplication process: Sa = Sp = "0" (hold) and Sb = "2" (shift left) 5. Store the product for next iteration Repeat step 2 -5 (N-K) times.6. Deliver the final result (parity codes) The final result is the parity codes added to the information codes to form the RS codeword.Figure 5 shows controller states for N-K=3 and m=4.

Main VHDL File
The main VHDL codes has the following tasks: 1. generates N-K registers, multiplicators and adders, each is of m-bit wide.2. connects internal signals within the encoder 3. connects controller outputs to the corresponding encoder's signals.
Thanks to VHDL's feature, we can duplicate module easily with 'generate' command and define variable values with 'generic' keyword.Both features are shown in the VHDL codes in Figure 6.For clarity, the codes show main signals only.The signal names in the codes refer to the implementation of RS Encoder illustrated in Figure 7.A set of generator polynomial and information symbols as well as the primitive polynomial are stored in a text file.During simulation, these symbols are sequentially read from the file and fed to the encoding process.The result of encoding process is written to an output file.To keep the encoder remains synthesizable, all read and write processes are done externally from the encoder to simulate on-the-fly encoding process during real data transmission.

Experimental Results and Discussion
The generic RS Encoder has been exercised for a great variety of parameters using Xilinx ISE 8.1i Simulator.For short data and small number of bits, the output written to files was compared with the result of manual calculation.For long information symbols, say N>7 and m>3, the results were examined using the Reed-Solomon Calculator available in [11].Experiments with great variety of parameter combinations show that the RS Encoder works correctly.[12], the encoder requires 388 clocks per block.In other words, 255 8-bit symbols are ready for transmission every 1.6 s.Thus, the throughput is 1.275Gbps or 159Mbytes/sec.This is much faster than commercially available equivalent encoder in [13], whose throughput is 750Mbps and maximum frequency is 100MHz.The performance of [13] is measured based on the implementation on Xilinx Spartan III 50-4, which is the same family with XC3S200-5FT256.The result is also much better than [14] whose maximum throughput is 108Mbytes/sec implemented on Spartan II XC2S100.

Conclusion
A generic Reed Solomon encoder has been developed with the following parameters: information symbol (K), parity symbol (2t), size of symbol (m), primitive polynomial p(x) and generator polynomial P(x).Hence, its characteristics can be altered simply by modifying the parameters.The encoder has greater flexibility and reusability compared to the other similar implementa-tions such as in [1][2][3] whose characteristics are fixed for certain configuration and features.The encoder's codes in VHDL has been verified by simulation for any values of N, K and m to represent m-bit RS(N,K) using Xilinx ISE 8.1i.The codes can be compiled into bitstream for FPGA/CPLD chip implementation.It has been shown that the design's space and time complexity increases linearly by the number of parity symbols (N-K).The code implementation on FPGA chip Xilinx XC3S200-5FT256 results in an RS encoder with throughput 1.275 Gbps.It has a better performance than several commercially available encoders, such as [13], [14] and [15].

4 )
with primitive polynomial P(x)=x 4 +x+1.Referring to Figure 3, initially all registers are reset at the first clock.With P(x) = x 4 + x + 1, P is set to 0011 or 3 10 .Input A(x)= 10 =0111=7 10 and B(x)= 6 = 1100 = 12 10 .During the cycle, the polynomial b m-1 A(x) is entered into Z register.Shifting Z register is equivalent to multiplication by x, and since this could result in a term of degree greater than m-1, the polynomial P(x) provides for a reduction of such a term by the equation x m = p m-1 x m-1 + p m-2 x m-2 + ... + p 0 .The result is b m-1 A(x) mod P(x).b m-2 A(x) is added to this polynomial to produce the result [b m-1 xA(x) + b m-2 A(x)] mod P(x).Upon the application of next clock cycles, the sequence of operations repeats itself to produce the polynomial {[b m-1 xA(x) + b m-2 A(x)]x + b m-3 A(x)} mod P(x) in the Z register.The product C(x) is obtained after n clock cycles, where n is the degree of polynomial P(x).