Atmel ARM-Based Evaluation Kit AT91SAM9N12-EK AT91SAM9N12-EK Data Sheet

Product codes
AT91SAM9N12-EK
Page of 1104
337
SAM9N12/SAM9CN11/SAM9CN12 [DATASHEET]
11063K–ATARM–05-Nov-13
28.5
Software Implementation
28.5.1  Remainder Substitution Procedure
The substitute function evaluates the polynomial remainder, with different values of the field primitive elements. The finite
field arithmetic addition operation is performed with the Exclusive or. The finite field arithmetic multiplication operation is
performed through the gf_log, gf_antilog lookup tables.
The REM2NP1 and REMN2NP3 fields of the PMECC_REMx registers contain only odd remainders. Each bit indicates
whether the coefficient of the polynomial remainder is set to zero or not.
NB_ERROR_MAX defines the maximum value of the error correcting capability.
NB_ERROR defines the error correcting capability selected at encoding/decoding time.
NB_FIELD_ELEMENTS defines the number of elements in the field.
si[] is a table that holds the current syndrome value, an element of that table belongs to the field. This is also a shared
variable for the next step of the decoding operation.
oo[] is a table that contains the degree of the remainders.
int substitute()
{
int i;
int j;
for (i = 1; i < 2 * NB_ERROR_MAX; i++)
{
si[i] = 0;
}
for (i = 1; i < 2*NB_ERROR; i++)
{
for (j = 0; j < oo[i]; j++)
{
if (REM2NPX[i][j])
{
si[i] = gf_antilog[(i * j)%NB_FIELD_ELEMENTS] ^ si[i];
}
}
}
return 0;
}