diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-03-01 11:48:48 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-03-01 11:48:48 +0100 |
commit | 63b7d214239ec994258153d8fbccf59d07b4ea26 (patch) | |
tree | 827e3978e1fa886a569f71e2074440cfc7cf4dd5 /testsuite/gna/issue1138/crc_pkg.vhdl | |
parent | b8ea7696f5e7fee31fb39c13e08a241514caecd4 (diff) | |
download | ghdl-63b7d214239ec994258153d8fbccf59d07b4ea26.tar.gz ghdl-63b7d214239ec994258153d8fbccf59d07b4ea26.tar.bz2 ghdl-63b7d214239ec994258153d8fbccf59d07b4ea26.zip |
testsuite/gna: add a test for #1138
Diffstat (limited to 'testsuite/gna/issue1138/crc_pkg.vhdl')
-rw-r--r-- | testsuite/gna/issue1138/crc_pkg.vhdl | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/testsuite/gna/issue1138/crc_pkg.vhdl b/testsuite/gna/issue1138/crc_pkg.vhdl new file mode 100644 index 000000000..ca8d93079 --- /dev/null +++ b/testsuite/gna/issue1138/crc_pkg.vhdl @@ -0,0 +1,53 @@ +library ieee; + use ieee.std_logic_1164.all; + use ieee.numeric_std.all; + use ieee.math_real.all; + +package crc_pkg is + + type crcParam_t is record + selLen : integer; + poly : std_ulogic_vector; + iniVect : std_ulogic_vector; + refIn : boolean; + refOut : boolean; + xorOut : std_ulogic_vector; + end record; + + pure function getCrc32Param( stdCrc : string + ; datLen : integer + ) return crcParam_t; + +end crc_pkg; + +package body crc_pkg is + + pure function getCrc32Param( stdCrc : string + ; datLen : integer + ) return crcParam_t is + variable crcParam_v : crcParam_t( poly ( 31 downto 0) + , iniVect ( 31 downto 0) + , xorOut ( 31 downto 0) ); + begin + if ( "CRC-32/CCITT-FALSE" = stdCrc ) then + crcParam_v.selLen := datLen / 8 ; + crcParam_v.poly := X"04C11DB7" ; + crcParam_v.iniVect := X"FFFFFFFF" ; + crcParam_v.refIn := true ; + crcParam_v.refOut := true ; + crcParam_v.xorOut := X"FFFFFFFF" ; + else + crcParam_v.selLen := datLen / 8 ; + crcParam_v.poly := X"000000AF" ; + crcParam_v.iniVect := X"00000000" ; + crcParam_v.refIn := false ; + crcParam_v.refOut := false ; + crcParam_v.xorOut := X"00000000" ; + assert false report + " Standard crc not implemented Yet." + severity failure; + end if; + return crcParam_v; + end function; + +end package body crc_pkg; |