13.2 Polynomial Implementation

The CRC polynomial equation is user configurable, allowing any polynomial equation to be used for the CRC checksum calculation. The polynomial and accumulator sizes are determined by the PLEN bits. For an n-bit accumulator, PLEN = n-1 and the corresponding polynomial is n+1 bits. This allows the accumulator to be any size up to 32 bits with a corresponding polynomial up to 33 bits. The MSb and LSb of the polynomial are always ‘1’ which is forced by hardware. Therefore, the LSb of the CRCXOR Low Byte register is hardwired high and always reads as ‘1’.

All polynomial bits between the MSb and LSb are specified by the CRCXOR registers. For example, when using the standard CRC32, the polynomial is defined as 0x4C11DB7 ( x 32 + x 26 + x 23 + x 22 + x 16 + x 12 + x 11 + x 10 + x 8 + x 7 + x 5 + x 4 + x 2 + x + 1 ) . In this polynomial, the X32 and X0 terms are the MSb and LSb controlled by hardware. The X31 and X1 terms are specified by setting the CRCXOR[31:0] bits with the corresponding polynomial value, which in this example is 0x04C11DB6. Reading the CRCXOR registers will return 0x04C11DB7 because the LSb is always ‘1’. Refer to the following example for more details.

CRC32 Example

Standard CRC32 Polynomial (33 bits):

( x 32 + x 26 + x 23 + x 22 + x 16 + x 12 + x 11 + x 10 + x 8 + x 7 + x 5 + x 4 + x 2 + x + 1 )

Standard 32-bit Polynomial Representation: 0x04C11DB7

CRCXORT = 0x04 = 0b00000100

CRCXORU = 0xC1 = 0b11000001

CRCXORH = 0x1D = 0b00011101

CRCXORL = 0xB7 = 0b1011011- (1)

Data Sequence: 0x55, 0x66, 0x77, 0x88

DLEN = 0b00111 // Number of bits written to CRCDATA registers (Data Length)

PLEN = 0b11111 // MSb position of the polynomial (Polynomial Length)

Data passed into the CRC:

// SHIFTM = 0(Shift Mode: MSb first)

0x55 0x66 0x77 0x88 = 01010101 01100110 01110111 10001000

// SHIFTM = 1(Shift Mode: LSb first)

0x55 0x66 0x77 0x88 = 10101010 01100110 11101110 00010001

CRC Check Value (ACCM = 1, data is augmented with zeros)

// When SHIFTM = 0, CRC Result = 0xC60D8323

CRCOUTT = 0xC6 = 0b11000110

CRCOUTU = 0x0D = 0b00001101

CRCOUTH = 0x83 = 0b10000011

CRCOUTL = 0x23 = 0b00100011

// When SHIFTM = 1, CRC Result = 0x843529CC

CRCOUTT = 0x84 = 0b10000100

CRCOUTU = 0x35 = 0b00110101

CRCOUTH = 0x29 = 0b00101001

CRCOUTL = 0xCC = 0b11001100

Note:
  1. Bit 0 is unimplemented. The LSb of any CRC polynomial is always ‘1’ and will always be treated as a ‘1’ by the CRC for calculating the CRC check value. This bit will be read in software as a ‘0’.