1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#define mm 6 /* RS code over GF(2**6) */
#define nn 24 /* nn=2**mm -1 length of codeword */
#define tt 6 /* number of errors that can be corrected */
#define kk 12 /* kk = nn-2*tt */
int pp [mm+1] = { 1, 1, 0, 0, 0, 0, 1 } ; /* specify irreducible polynomial coeffts */
int alpha_to [nn+1], index_of [nn+1], gg [nn-kk+1] ;
int recd [nn], data [kk], bb [nn-kk] ;
// 1st parameter is pointer to 144 bit array filled by the hamming decode
// 2nd parameter is pointer to 72 bit array filled by this decoder to be used later
void
ldu1::decode_reed_solomon(uint16_t *rs_codewords, uint16_t *decoded_lcw)
{
generate_gf( ) ;
gen_poly( ) ;
for(int index = 0; index < 6; index++)
{
/*
takes the 144 bits in rs_codewords array filled by the hamming decoder
the first 72 bits are data, the last 72 bits are parity
there are 6 24-bit codewords, first 12 bits are data, last 12 bits are parity bits
*/
// create the codewords, put data and parity in right places
int i;
for (i=0; i<nn-kk; i++) recd[i] = rs_codewords[i*index+kk] ; // 72 parity bits, should start taking values from oridals 72-143
for (i=0; i<kk; i++) recd[i+nn-kk] = rs_codewords[i*index] ; // 72 bits data payload, should start taking values from oridals 0-71
// put recd[i] into index form; should 24-bit codeword
for (i=0; i<nn; i++)
recd[i] = index_of[recd[i]] ;
decode_rs(); // recd[] is returned in polynomial form, should be 12-bits of data
// need to store the 6 corrected 12-bit arrays recd[] into single 72 bit array
for(i=nn-kk; i < nn; i++)
{
decoded_lcw[i - (nn-kk) + index*(nn-kk)] = recd[i];
}
}
}
|