2010年7月23日 星期五

CRC calculation

INPUT: 11010011101100
PATTERN (polynomial): 1011

To calculate n-bit checksum, you need a (n+1)-bit pattern.
In this example, we'll calculate CRC-3 (3-bit).
CRC-n pattern can be found in Wiki.

Method:
1. Align INPU & PATTERN to the left.
2. Read the leftmost bit of INPUT.
If the bit is 0, do nothing.
If the bit is 1, let INPUT = (INPUT XOR PATTERN).
Move PATTERN to the right by one bit.
Repeat step 2 until you got a n-bit INPUT, which is the CRC-n.

Verify:
You should get 3-bit CRC: 101.

Ref: