打印
[独创算法]

HotCRC CRC16L_1021_FFFF_0000 FPGA模块 HotPower@163.com(菜农独创)

[复制链接]
75|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
/*-----------------------------------------------------------------------------------------------
      HotCRC CRC16L_1021_FFFF_0000 FPGA模块 HotPower[url=home.php?mod=space&uid=516618]@163.com[/url] 2023-09-21 11:55:44
-----------------------------------------------------------------------------------------------*/
module CRC16L_1021(clk, rst, data, outcrc16)
input clk, rst;
input [7:0] data;
output reg[15:0] outcrc16;
reg [15:0] crc16;

task CRC16L_1021;
inout[15:0] crc16;
input[7:0] indata;
    crc16 = {crc16[7:0], 8'h00} ^ CRC16L_1021_Table(crc16[15:8] ^ indata);
endtask

function [15:0] CRC16L_1021_Table;
    input [7:0] data;
    CRC16L_1021_Table = CRC16L_1021_Table0(data[1:0]) ^ CRC16L_1021_Table1(data[3:2]) ^ CRC16L_1021_Table2(data[5:4]) ^ CRC16L_1021_Table3(data[7:6]);
endfunction

function [15:0] CRC16L_1021_Table0;
    input[1:0] data;
    case(data)
        2'b00: CRC16L_1021_Table0 = 16'h0000; 2'b01: CRC16L_1021_Table0 = 16'h1021; 2'b10: CRC16L_1021_Table0 = 16'h2042; 2'b11: CRC16L_1021_Table0 = 16'h3063;
        default: CRC16L_1021_Table0 = 16'h0000;
    endcase
endfunction

function [15:0] CRC16L_1021_Table1;
    input[1:0] data;
    case(data)
        2'b00: CRC16L_1021_Table1 = 16'h0000; 2'b01: CRC16L_1021_Table1 = 16'h4084; 2'b10: CRC16L_1021_Table1 = 16'h8108; 2'b11: CRC16L_1021_Table1 = 16'hC18C;
        default: CRC16L_1021_Table1 = 16'h0000;
    endcase
endfunction

function [15:0] CRC16L_1021_Table2;
    input[1:0] data;
    case(data)
        2'b00: CRC16L_1021_Table2 = 16'h0000; 2'b01: CRC16L_1021_Table2 = 16'h1231; 2'b10: CRC16L_1021_Table2 = 16'h2462; 2'b11: CRC16L_1021_Table2 = 16'h3653;
        default: CRC16L_1021_Table2 = 16'h0000;
    endcase
endfunction

function [15:0] CRC16L_1021_Table3;
    input[1:0] data;
    case(data)
        2'b00: CRC16L_1021_Table3 = 16'h0000; 2'b01: CRC16L_1021_Table3 = 16'h48C4; 2'b10: CRC16L_1021_Table3 = 16'h9188; 2'b11: CRC16L_1021_Table3 = 16'hD94C;
        default: CRC16L_1021_Table3 = 16'h0000;
    endcase
endfunction


always [url=home.php?mod=space&uid=72445]@[/url] (posedge clk or negedge rst)
begin
    if (!rst)
    begin
        crc16 <= 16'hFFFF;
    end
    else
    begin
        CRC16L_1021(crc16, data);
        outcrc16 <= crc16;
        crc16 <= crc16;
    end
end
endmodule


使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:[url=http://www.21ic.com/tools/HotWC3_V1.23.html]

1538

主题

21697

帖子

505

粉丝