# RF Wireless World

## Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

## Reed Solomon Encoder basics and specifications

This section of MATLAB source code covers Reed solomon Encoder(RS Encoder) matlab code.

Reed solomon codes are basically used for providing FEC(Forward Error Correction) to the received erroneous blocks. RS encoder is used at the transmit end by which redundancy bytes are added to the input data to be transmitted. RS decoder is used at the receiver to correct the errors occured on the way by use of redundant information. RS codes are systematic linear block code. It is a block code because the code is put together by splitting the original message into fixed length blocks.

RS encoder is designated as (N,K,T) where,
N is the number of overall bytes after encoding K is the number of data bytes before encoding T is the number of data bytes which can be corrected by RS Encoder and RS Decoder combination.
T is equal to (N-K)/2.
Most of the common error correction codes work on finite fields called Galois Fields. These fields are constructed by a so-called primitive polynomial p(x).

The page describes RS Encoder based on following polynomials.
code generator polynomial:
g(x) = (x + λ0)(x + λ1)(x + λ2)...(x + λ2T-1), λ = 02hex
Field Generator polynomial:
p(x) = x8 + x4 + x3 + x2 +1

### Reed solomon encoder matlab code

input_data= [113 44 42 179 77 236 149 177 105 250 0 81 64
62 148 223 123 98 95 90 193 216 17 0]
n=32;
k=24;
t=4;
g_f=0;
g_f(2)=1;
for i=1:7
g_f(2+i)=bitshift(g_f(2+i-1),1);
end
x=2+i;

x1=2;x2=4;x3=5;x4=6;
for i=1:247
g_f(x+i)=bitxor(bitxor(g_f(x1),g_f(x2)),bitxor(g_f(x3),g_f(x4)));
x1=x1+1;x2=x2+1;x3=x3+1;x4=x4+1;
end
%------------- code generator polynomial ---------------%
r=[1 59 13 104 189 68 209 30 8 163 65 41 229 98 50 36 59];
for j=2:17
for i=1:256
if(r(j)==g_f(i))
indx(j-1)=i-2;
break
end
end
end

lfsr_op(1:16)=0;

for dc=1:k
lfsr_input=bitxor(lfsr_op(1),input_data(dc));

%get index of data with respect to Galois Field
for i=1:256
if(lfsr_input==g_f(i))
lfsr_input=i-2;
break
end
end
temp1=0;
reg_in=2+mod((indx+lfsr_input),255);
for j=16:-1:1
temp=lfsr_op(j);
if(lfsr_input==-1)
lfsr_op(j)=bitxor(0,temp1);
else
lfsr_op(j)=bitxor(g_f(reg_in(j)),temp1);
end
temp1=temp;
end
end
encoded_data_output=[lfsr_op(1:(n-k)) input_data]

### RS Encoder Input and Output ### Useful Links to MATLAB codes

Refer following as well as links mentioned on left side panel for useful MATLAB codes.
OFDM Preamble generation  Time off estimation corr  Freq off estimation corr  channel estimation  11a WLAN channel  PN sequence generation  OFDMA Tx Rx  AES DES  carrier aggregation  CCDF  FIR Filter  IIR Filter  Low Pass FIR  Viterbi decoder  CRC8 CRC32