Network Wizard for VHDL Test Benches
nw_crc_pkg Package Body Reference
Package >> nw_crc_pkg

Functions

std_logic_vector   f_gen_crc (
poly: in std_logic_vector
data: in t_slv_arr
init: in std_logic_vector
msb_first: in boolean C_MSB_FIRST
)
 Calculate CRC.
std_logic_vector   f_gen_chksum (
data: in t_slv_arr
chksum_width: in positive
use_carry: in boolean True
)
 Calculate sum-of-words checksum.

Member Function Documentation

◆ f_gen_crc()

std_logic_vector f_gen_crc (   poly in std_logic_vector ,
  data in t_slv_arr ,
  init in std_logic_vector ,
  msb_first in boolean C_MSB_FIRST  
)
Function

Calculate CRC.

Parameters
polyCRC polynomial to use (3-bit or longer)
dataData array
initCRC init value (same width as poly)
msb_firstExtract most significant bits first if True (default), least significant bits if False
Returns
CRC

Calculate CRC checksum of data array.

Example use

array_8bit := (x"11", x"22", x"33", x"44", x"55", x"66", x"77");
v_crc_32 := f_gen_crc(C_ETH_CRC32, array_8bit, x"ffffffff"); -- v_crc_32 is now x"97aee1d3"

◆ f_gen_chksum()

std_logic_vector f_gen_chksum (   data in t_slv_arr ,
  chksum_width in positive ,
  use_carry in boolean True  
)
Function

Calculate sum-of-words checksum.

Parameters
dataData array
chksum_widthChecksum width
use_carryAdd carry to checksum (default True)
Returns
Checksum

Calculate sum-of-words checksum of data array. The data array should have the same width as the checksum, which is accomplished with e.g. f_repack().

Example use

array_16bit := (x"4500", x"0073", x"0000", x"4000", x"4011", x"0000", x"c0a8", x"0001", x"c0a8", x"00c7"); -- IPv4 Header
v_chksum := not f_gen_chksum(array_16bit, 16); -- v_chksum is now x"b861", which is the IPv4 header checksum

The documentation for this class was generated from the following file: