Network Wizard for VHDL Test Benches
Checksum and CRC

CRC & Checksum

This library provides functions for calculation of checksums and CRC.

Functionality

  • Checksum of any data width, with or without carry
  • CRC from any polynomial


More details in nw_crc_pkg

Example use

Include the libraries:

library nw_util;
context nw_util.nw_util_context;

Calculation of internet checksum (IPv4 header checksum):

v_chksum16 := not f_gen_chksum(array_16bit, 16);

Calculation of 8bit checksum (no carry):

v_chksum8 := not f_gen_chksum(array_8bit, 8, False);

Calculation of ethernet CRC - here we need to postprocess the CRC by bit-reversing, swap endianess and inverting:

v_crc_32 := not f_swap_endian(f_bitflip(f_gen_crc(C_ETH_CRC32, array_8bit, x"ffffffff", C_LSB_FIRST)));

See further examples in the test bench nw_util_tb.vhd.