基于 VerilogHDL 的 CRC16 校验8位并行模块仿真结果不为0,如何解决?

用easics网站的工具(链接发生混乱,请百度 easics crc tool)生成CRC16_D8代码,改写为如下模块:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Purpose : synthesizable CRC function
// * polynomial: x^16 + x^12 + x^5 + 1
// * data width: 8
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

module CRC16_D8
(
input clock,

input                reset,

input        [7:0]            data_in,
input                crc_en,

output    reg    [15:0]    data_out,
output    reg            data_out_valid

);

////////////////////////////////////////////////

wire    [7:0]    d;

wire    [15:0]    c;

////////////////////////////////////////////////

assign    d    = data_in;

assign    c    = data_out;

////////////////////////////////////////////////

always @(posedge clock)
begin
    
    data_out_valid <= crc_en;
    
    if(reset)
        begin
        data_out    <= 16'd0;
        end
    else
        begin
        if(crc_en)
            begin
            data_out[0] <= d[4] ^ d[0] ^ c[8] ^ c[12];
            data_out[1] <= d[5] ^ d[1] ^ c[9] ^ c[13];
            data_out[2] <= d[6] ^ d[2] ^ c[10] ^ c[14];
            data_out[3] <= d[7] ^ d[3] ^ c[11] ^ c[15];
            data_out[4] <= d[4] ^ c[12];
            data_out[5] <= d[5] ^ d[4] ^ d[0] ^ c[8] ^ c[12] ^ c[13];
            data_out[6] <= d[6] ^ d[5] ^ d[1] ^ c[9] ^ c[13] ^ c[14];
            data_out[7] <= d[7] ^ d[6] ^ d[2] ^ c[10] ^ c[14] ^ c[15];
            data_out[8] <= d[7] ^ d[3] ^ c[0] ^ c[11] ^ c[15];
            data_out[9] <= d[4] ^ c[1] ^ c[12];
            data_out[10] <= d[5] ^ c[2] ^ c[13];
            data_out[11] <= d[6] ^ c[3] ^ c[14];
            data_out[12] <= d[7] ^ d[4] ^ d[0] ^ c[4] ^ c[8] ^ c[12] ^ c[15];
            data_out[13] <= d[5] ^ d[1] ^ c[5] ^ c[9] ^ c[13];
            data_out[14] <= d[6] ^ d[2] ^ c[6] ^ c[10] ^ c[14];
            data_out[15] <= d[7] ^ d[3] ^ c[7] ^ c[11] ^ c[15];
            end
        else
            begin
            if(data_out_valid)
                begin
                data_out    <= 16'd0;
                end
            end
        end
end 

endmodule

仿真波形如下:

img

如图,先向模块输入端输入4个字节,然后补上16bit的0,得到CRC值16'h6fe4,然后用这个值替代原序列中的16bit的0,仿真的结果不为0,请问这是为什么?我在这里对CRC校验的理解是否有误?
要想计算得到0值,应如何修改?

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。