200 资产
如题,我使用的systemverilog,请问一下各位大佬。8bit数据的整数倍,在网上找到了查表法的代码,目前8bit,16bit的数据都能正确计算了。但是20bit,40bit,60bit的不知道如何做,希望有大佬能帮助一下,贴出目前使用的16bit数据crc32代码,如何修改可行呢?或者有其他代码也可以,感激不尽!
function int axi_ipi2axi_data_checker::crc32_calculation_d16(ref bit[7:0] pixel_data1, ref bit[7:0] pixel_data2, ref bit[31:0] crc_data_in);
bit [31:0] POLY = 32'h04c11d87;
bit [15:0] data_in;
bit [31:0] crc;
bit [31:0] tmp;
bit [31:0] crc32_table[] =
'{ 32'h00000000, 32'h04c11db7, 32'h09823b6e, 32'h0d4326d9,
32'h130476dc, 32'h17c56b6b, 32'h1a864db2, 32'h1e475005,
32'h2608edb8, 32'h22c9f00f, 32'h2f8ad6d6, 32'h2b4bcb61,
32'h350c9b64, 32'h31cd86d3, 32'h3c8ea00a, 32'h384fbdbd,
32'h4c11db70, 32'h48d0c6c7, 32'h4593e01e, 32'h4152fda9,
32'h5f15adac, 32'h5bd4b01b, 32'h569796c2, 32'h52568b75,
32'h6a1936c8, 32'h6ed82b7f, 32'h639b0da6, 32'h675a1011,
32'h791d4014, 32'h7ddc5da3, 32'h709f7b7a, 32'h745e66cd,
32'h9823b6e0, 32'h9ce2ab57, 32'h91a18d8e, 32'h95609039,
32'h8b27c03c, 32'h8fe6dd8b, 32'h82a5fb52, 32'h8664e6e5,
32'hbe2b5b58, 32'hbaea46ef, 32'hb7a96036, 32'hb3687d81,
32'had2f2d84, 32'ha9ee3033, 32'ha4ad16ea, 32'ha06c0b5d,
32'hd4326d90, 32'hd0f37027, 32'hddb056fe, 32'hd9714b49,
32'hc7361b4c, 32'hc3f706fb, 32'hceb42022, 32'hca753d95,
32'hf23a8028, 32'hf6fb9d9f, 32'hfbb8bb46, 32'hff79a6f1,
32'he13ef6f4, 32'he5ffeb43, 32'he8bccd9a, 32'hec7dd02d,
32'h34867077, 32'h30476dc0, 32'h3d044b19, 32'h39c556ae,
32'h278206ab, 32'h23431b1c, 32'h2e003dc5, 32'h2ac12072,
32'h128e9dcf, 32'h164f8078, 32'h1b0ca6a1, 32'h1fcdbb16,
32'h018aeb13, 32'h054bf6a4, 32'h0808d07d, 32'h0cc9cdca,
32'h7897ab07, 32'h7c56b6b0, 32'h71159069, 32'h75d48dde,
32'h6b93dddb, 32'h6f52c06c, 32'h6211e6b5, 32'h66d0fb02,
32'h5e9f46bf, 32'h5a5e5b08, 32'h571d7dd1, 32'h53dc6066,
32'h4d9b3063, 32'h495a2dd4, 32'h44190b0d, 32'h40d816ba,
32'haca5c697, 32'ha864db20, 32'ha527fdf9, 32'ha1e6e04e,
32'hbfa1b04b, 32'hbb60adfc, 32'hb6238b25, 32'hb2e29692,
32'h8aad2b2f, 32'h8e6c3698, 32'h832f1041, 32'h87ee0df6,
32'h99a95df3, 32'h9d684044, 32'h902b669d, 32'h94ea7b2a,
32'he0b41de7, 32'he4750050, 32'he9362689, 32'hedf73b3e,
32'hf3b06b3b, 32'hf771768c, 32'hfa325055, 32'hfef34de2,
32'hc6bcf05f, 32'hc27dede8, 32'hcf3ecb31, 32'hcbffd686,
32'hd5b88683, 32'hd1799b34, 32'hdc3abded, 32'hd8fba05a,
32'h690ce0ee, 32'h6dcdfd59, 32'h608edb80, 32'h644fc637,
32'h7a089632, 32'h7ec98b85, 32'h738aad5c, 32'h774bb0eb,
32'h4f040d56, 32'h4bc510e1, 32'h46863638, 32'h42472b8f,
32'h5c007b8a, 32'h58c1663d, 32'h558240e4, 32'h51435d53,
32'h251d3b9e, 32'h21dc2629, 32'h2c9f00f0, 32'h285e1d47,
32'h36194d42, 32'h32d850f5, 32'h3f9b762c, 32'h3b5a6b9b,
32'h0315d626, 32'h07d4cb91, 32'h0a97ed48, 32'h0e56f0ff,
32'h1011a0fa, 32'h14d0bd4d, 32'h19939b94, 32'h1d528623,
32'hf12f560e, 32'hf5ee4bb9, 32'hf8ad6d60, 32'hfc6c70d7,
32'he22b20d2, 32'he6ea3d65, 32'heba91bbc, 32'hef68060b,
32'hd727bbb6, 32'hd3e6a601, 32'hdea580d8, 32'hda649d6f,
32'hc423cd6a, 32'hc0e2d0dd, 32'hcda1f604, 32'hc960ebb3,
32'hbd3e8d7e, 32'hb9ff90c9, 32'hb4bcb610, 32'hb07daba7,
32'hae3afba2, 32'haafbe615, 32'ha7b8c0cc, 32'ha379dd7b,
32'h9b3660c6, 32'h9ff77d71, 32'h92b45ba8, 32'h9675461f,
32'h8832161a, 32'h8cf30bad, 32'h81b02d74, 32'h857130c3,
32'h5d8a9099, 32'h594b8d2e, 32'h5408abf7, 32'h50c9b640,
32'h4e8ee645, 32'h4a4ffbf2, 32'h470cdd2b, 32'h43cdc09c,
32'h7b827d21, 32'h7f436096, 32'h7200464f, 32'h76c15bf8,
32'h68860bfd, 32'h6c47164a, 32'h61043093, 32'h65c52d24,
32'h119b4be9, 32'h155a565e, 32'h18197087, 32'h1cd86d30,
32'h029f3d35, 32'h065e2082, 32'h0b1d065b, 32'h0fdc1bec,
32'h3793a651, 32'h3352bbe6, 32'h3e119d3f, 32'h3ad08088,
32'h2497d08d, 32'h2056cd3a, 32'h2d15ebe3, 32'h29d4f654,
32'hc5a92679, 32'hc1683bce, 32'hcc2b1d17, 32'hc8ea00a0,
32'hd6ad50a5, 32'hd26c4d12, 32'hdf2f6bcb, 32'hdbee767c,
32'he3a1cbc1, 32'he760d676, 32'hea23f0af, 32'heee2ed18,
32'hf0a5bd1d, 32'hf464a0aa, 32'hf9278673, 32'hfde69bc4,
32'h89b8fd09, 32'h8d79e0be, 32'h803ac667, 32'h84fbdbd0,
32'h9abc8bd5, 32'h9e7d9662, 32'h933eb0bb, 32'h97ffad0c,
32'hafb010b1, 32'hab710d06, 32'ha6322bdf, 32'ha2f33668,
32'hbcb4666d, 32'hb8757bda, 32'hb5365d03, 32'hb1f740b4
};
data_in = {pixel_data1,pixel_data2};
crc = crc_data_in;
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ pixel_data1) & 8'hff];
`uvm_info("CRC DBG",$sformatf("crc middle:%0x",crc),UVM_HIGH);
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ pixel_data2) & 8'hff];
crc32_calculation_d16 = crc;
endfunction : crc32_calculation_d16
我来回答