Reply by Cystrin October 17, 20072007-10-17
Using the test vector and Reed-Solomon encoding parameters defined in IEEE
Std 802.16-2004, my MATLAB code returns the required test vector with
extra bytes. My MATLAB code (shown below) is based on an earlier thread in
this group. The problem is that the output vector is longer than expected
even after removing the zero padding and that the parity bytes are in the
wrong position. Has anyone experienced something similar and if so, how is
it fixed?

% Reed-Solomon coding based on the test vectors presented in 
% IEEE Std 802.16-2004

%% Input vector x and output vector z taken from Sect. 8.3.3.5.1, p444

x = ['D4';'BA';'A1';'12';'F2';'74';'96';'30'; ...
     '27';'D4';'88';'9C';'96';'E3';'A9';'52'; ...
     'B3';'15';'AB';'FD';'92';'53';'07';'32'; ...
     'C0';'62';'48';'F0';'19';'22';'E0';'91'; ...
     '62';'1A';'C1'];

z = ['49';'31';'40';'BF';'D4';'BA';'A1';'12'; ...
     'F2';'74';'96';'30';'27';'D4';'88';'9C'; ...
     '96';'E3';'A9';'52';'B3';'15';'AB';'FD'; ...
     '92';'53';'07';'32';'C0';'62';'48';'F0'; ...
     '19';'22';'E0';'91';'62';'1A';'C1';'00'];

x = hex2dec(x)'; % This is the input data from the standard
z = hex2dec(z)'; % This is how the output data should be

% Note that the parity bytes are first four bytes in the vector z, namely
% '49';'31';'40';'BF' (hex).


%% Define Reed-Solomon coding parameters
m = 8; % Number of bits per symbol
n = 2^m-1; % Length of encoded data (255 for m=8)
k = 239; % Required length of source data (ie RS(255,239) ) t=(n-k)/2;

%% Define the field generator primitive polynomial (D^8+D^4+D^3+D^2+1) 
% in decimal form according to eqn.(67), p432. p = 285;

%% Form the msg vector from the input data. If the input data is shorter 
% than required, prefix it with zeros. Nzeros = k-length(x)-1; 
% Calculate how much zero padding to add.

% Make source data. Prefix with zero pads if eeded.
xk=[zeros(1,Nzeros) x 0]; 

%% Creat Galois array from the source data
msg=gf(xk, m, p);

% Calculate the code generator polynomial according to eqn.(66) on p432 
% of the standard (note that the 4th argument is 0 in the function call) 
% Expanding eqn.(66) gives the following polynomial coefficients: 
% 1 59 13 104 189 68 209 30 8 163 65 41 229 98 50 36 59

gen=rsgenpoly(n, k, p, 0);

code = rsenc(msg,n,k,gen); % Encode the information symbols

% Octave and MATLAB do not appear to place the parity bytes where
expected
% so some sorting is required.

code_new = [code(k+1:k+(t/2)) code(Nzeros+1:k)];

Thanks,

Cystrin