Electronic – CRC implementation for ethernet

crcethernet

With an example for data with a hexadecimal value of 0xda and a polynomial 0x07, I would find the CRC as follows (using the methodology from Wikipedia)

0xda = 11011010

11011010|00000000
111
00111010|00000000
  111
00000010|00000000
      11 1
00000001|10000000
       1 11
00000000|01000000

But the answer should be 0x08 according to this calculator.

I need the answer to be correct for the IEEE standard Ethernet. I've found that some sources pad the data and some don't. IEEE seem to suggest padding is required if the data is less than the CRC width.

Note: I know that the CRC is not strictly the remainder of the data divided by the polynomial either.

0xda = 11011010 = 218
0x07 = 00000111 = 7
218/7 = 31 r 1

As you can see below, the IEEE outlines a lot more steps than suggested on Wikipedia. How can I be certain that the CRC calculators online give the correct values for Ethernet?

Ethernet crc standard

For my attempt at following the standard (with the 8 bit CRC example)
a.) First 8 bits of the frame are complemented

11011010 -> 00100101

c.) Multiply by x^8 is equivalent to shifting by 8 bits (padded with zeros)

00100101 -> 00100101 00000000 = 18688

d.) Divide by G(x) and get remainder R(x)

18688/7 = 2669 r 5

Update: I have since got an 8 bit vhdl implementation using a 256 entry lookup table working. Or at least it gives the same results as the calculator online.

Best Answer

Your misunderstanding happens right at the beginning. The polynomial given as 0x7 (when given in normal notation) is at least a 4 bit CRC, the calculator you reference calculates an 8 bit CRC.

In the normal notation, the leading bit of the polynomial is 1 and omitted. So for an 8 bit CRC (if we want to check the calculator) the actual polynomial is not just 111 but 9 bit long: 10000011 1 because the leading 9th bit is omitted in that notation.

If I do the calculation with that:

11011010 00000000
10000011 1
-----------------
01011001 10000000
 1000001 11
-----------------
00011000 01000000
   10000 0111
-----------------
00001000 00110000
    1000 00111
-----------------
00000000 00001000

Voilá the result from the calculator pops out 0x08.

When dealing with CRCs they are always talking about polynomial division and not normal division with remainder.

I suggest you read up on the mathematics behind that and as you are interested in a VHDL implementation I guess that the computations are also quite useful.

The step a) corresponds to an init value in the calculator of all FF in case someone wonders. With that step added the result looks like this:

00100101 00000000
  100000 111
-----------------
00000101 11100000
     100 000111
-----------------
00000001 11111100
       1 00000111
-----------------
00000000 11111011

So the result is 0xFB. The calculator linked in the OP doesn't provide that value (not a standard polynomial it seems). This calculator allows to define a CRC yourself. And if I use the CRC-8 polynomial and an initial value of 0xFF, the result is the following:

CRC8 calculation

So the same as my hand calculation.