crc32 again and again :-)

crc32 again and again :-)

Post by T. Irme » Fri, 06 Feb 2004 03:51:26


i,

my question belongs to the boring ones:

I used some code from zlib for crc32 generation. The polynom looks good and
suitable for me.
Then I used the webtool from www.easics.be to generate some hdl to do the
same job for me.
(same polynom /ethernet /AAL). Also the tcl function in package crc was
checked.

tcl and zlib results in the same crc for a given testdata.
the hdl not! On the hdl the MSB is the first, I don know who is the first
on the zlib/tcl implementation. So I reversed bitorder. (0x12 (00010010) ->
0x48 (01001000)), with no success.

Could some experts give me the right pointer?
Thank you,
thomas

here is the generated hdl: (c source below)
------- snip -----
function nextCRC32_D8
( Data: std_logic_vector(7 downto 0);
CRC: std_logic_vector(31 downto 0) )
return std_logic_vector is

variable D: std_logic_vector(7 downto 0);
variable C: std_logic_vector(31 downto 0);
variable NewCRC: std_logic_vector(31 downto 0);

begin

D := Data;
C := CRC;

NewCRC(0) := D(6) xor D(0) xor C(24) xor C(30);
NewCRC(1) := D(7) xor D(6) xor D(1) xor D(0) xor C(24) xor C(25) xor
C(30) xor C(31);
NewCRC(2) := D(7) xor D(6) xor D(2) xor D(1) xor D(0) xor C(24) xor
C(25) xor C(26) xor C(30) xor C(31);
NewCRC(3) := D(7) xor D(3) xor D(2) xor D(1) xor C(25) xor C(26) xor
C(27) xor C(31);
NewCRC(4) := D(6) xor D(4) xor D(3) xor D(2) xor D(0) xor C(24) xor
C(26) xor C(27) xor C(28) xor C(30);
NewCRC(5) := D(7) xor D(6) xor D(5) xor D(4) xor D(3) xor D(1) xor
D(0) xor C(24) xor C(25) xor C(27) xor C(28) xor C(29) xor
C(30) xor C(31);
NewCRC(6) := D(7) xor D(6) xor D(5) xor D(4) xor D(2) xor D(1) xor
C(25) xor C(26) xor C(28) xor C(29) xor C(30) xor C(31);
NewCRC(7) := D(7) xor D(5) xor D(3) xor D(2) xor D(0) xor C(24) xor
C(26) xor C(27) xor C(29) xor C(31);
NewCRC(8) := D(4) xor D(3) xor D(1) xor D(0) xor C(0) xor C(24) xor
C(25) xor C(27) xor C(28);
NewCRC(9) := D(5) xor D(4) xor D(2) xor D(1) xor C(1) xor C(25) xor
C(26) xor C(28) xor C(29);
NewCRC(10) := D(5) xor D(3) xor D(2) xor D(0) xor C(2) xor C(24) xor
C(26) xor C(27) xor C(29);
NewCRC(11) := D(4) xor D(3) xor D(1) xor D(0) xor C(3) xor C(24) xor
C(25) xor C(27) xor C(28);
NewCRC(12) := D(6) xor D(5) xor D(4) xor D(2) xor D(1) xor D(0) xor
C(4) xor C(24) xor C(25) xor C(26) xor C(28) xor C(29) xor
C(30);
NewCRC(13) := D(7) xor D(6) xor D(5) xor D(3) xor D(2) xor D(1) xor
C(5) xor C(25) xor C(26) xor C(27) xor C(29) xor C(30) xor
C(31);
NewCRC(14) := D(7) xor D(6) xor D(4) xor D(3) xor D(2) xor C(6) xor
C(26) xor C(27) xor C(28) xor C(30) xor C(31);
NewCRC(15) := D(7) xor D(5) xor D(4) xor D(3) xor C(7) xor C(27) xor
C(28) xor C(29) xor C(31);
NewCRC(16) := D(5) xor D(4) xor D(0) xor C(8) xor C(24) xor C(28) xor
C(29);
NewCRC(17) := D(6) xor D(5) xor D(1) xor C(9) xor C(25) xor C(29) xor
C(30);
NewCRC(18) := D(7) xor D(6) xor D(2) xor C(10) xor C(26) xor C(30) xor
C(31);
NewCRC(19) := D(7) xor D(3) xor C(11) xor C(27) xor C(31);
New
 
 
 

crc32 again and again :-)

Post by T. Irme » Fri, 06 Feb 2004 22:24:07

i,

as my brute force attack of the polynom (hdl function) was successful
(counter, to test all bytes):

the input data has to be reverted, the crc read as a crc has to be reverted
and complemented (the unconverted crc ist used as a seed for the next, and
so no manipulation is needed!)

that all

:-)

thomas

"T. Irmen" < XXXX@XXXXX.COM > schrieb im Newsbeitrag
news:<bvrevf$n8m$ XXXX@XXXXX.COM >...


































































































































































 
 
 

crc32 again and again :-)

Post by normandavi » Fri, 06 Feb 2004 23:03:47

Hi,

In your HDL code, is the CRC variable being initialized to all 1s like
it is in the C code (crc=0xffffffff)?
 
 
 

crc32 again and again :-)

Post by Allan Herr » Sat, 07 Feb 2004 10:52:16

On 5 Feb 2004 06:03:47 -0800, XXXX@XXXXX.COM (Norman Davis)



Note that similar results can be obtained by initialising the CRC
register to all 0s and then inverting the first 32 bits of the
message. This is commonly done in hardware implementations.

Regards,
Allan.