Forum Discussion
Altera_Forum
Honored Contributor
14 years agoFWIW, if you are doing CRC16 (the usual one for hdlc comms) then a custom instruction for the following C can be used:
static __inline__ uint32_t
crc_step(uint32_t crc, uint32_t byte_val)
{
uint32_t t = crc ^ (byte_val & 0xff);
t = (t ^ t << 4) & 0xff;
return crc >> 8 ^ t << 8 ^ t << 3 ^ t >> 4;
}The 4 levels of xor easily execute in a single clock. My notes suggest that the above C compiles to 11 instructions, and a lookup table version to 7 (with the table base in a global register).