When to use it
A CRC is a strong, cheap checksum: append it to a message and the receiver recomputes
it to detect corruption, on a UART link, an SPI flash, or a packet bus. This is a
serial CRC-8 with polynomial x^8 + x^2 + x + 1 (0x07), one message bit per clock.
How it works
It's a linear-feedback shift register. Each clock, XOR the incoming bit with the
top of the register to make the feedback, shift left, and if the feedback is 1, XOR in
the polynomial. After the last bit, crc is the remainder to transmit.
Gotchas
- Sender and receiver must agree on the polynomial, bit order, initial value and final XOR, a mismatch on any of them means every check fails.
- Feed the message MSB-first here. Parallel (per-byte) CRC does the same maths for a
whole word each clock, that's
lfpga_crc.