打印
[独创算法]

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

[复制链接]
68|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 hotpower 于 2023-9-21 10:52 编辑
/*-----------------------------------------------------------------------------------------------
      HotCRC CRC8L_07_00_00 FPGA模块 HotPower[url=home.php?mod=space&uid=516618]@163.com[/url] 2023-09-21 10:38:58
-----------------------------------------------------------------------------------------------*/
module CRC8L_07(clk, rst, data, outcrc8)
input clk, rst;
input [7:0] data;
output reg[7:0] outcrc8;
reg [7:0] crc8;

task CRC8L_07;
inout[7:0] crc8;
input[7:0] indata;
    crc8 = CRC8L_07_Table(crc8 ^ indata);
endtask

function [7:0] CRC8L_07_Table;
    input [7:0] data;
    CRC8L_07_Table = CRC8L_07_Table0(data[1:0]) ^ CRC8L_07_Table1(data[3:2]) ^ CRC8L_07_Table2(data[5:4]) ^ CRC8L_07_Table3(data[7:6]);
endfunction

function [7:0] CRC8L_07_Table0;
    input[1:0] data;
    case(data)
        2'b00: CRC8L_07_Table0 = 8'h00; 2'b01: CRC8L_07_Table0 = 8'h07; 2'b10: CRC8L_07_Table0 = 8'h0E; 2'b11: CRC8L_07_Table0 = 8'h09;
        default: CRC8L_07_Table0 = 8'h00;
    endcase
endfunction

function [7:0] CRC8L_07_Table1;
    input[1:0] data;
    case(data)
        2'b00: CRC8L_07_Table1 = 8'h00; 2'b01: CRC8L_07_Table1 = 8'h1C; 2'b10: CRC8L_07_Table1 = 8'h38; 2'b11: CRC8L_07_Table1 = 8'h24;
        default: CRC8L_07_Table1 = 8'h00;
    endcase
endfunction

function [7:0] CRC8L_07_Table2;
    input[1:0] data;
    case(data)
        2'b00: CRC8L_07_Table2 = 8'h00; 2'b01: CRC8L_07_Table2 = 8'h70; 2'b10: CRC8L_07_Table2 = 8'hE0; 2'b11: CRC8L_07_Table2 = 8'h90;
        default: CRC8L_07_Table2 = 8'h00;
    endcase
endfunction

function [7:0] CRC8L_07_Table3;
    input[1:0] data;
    case(data)
        2'b00: CRC8L_07_Table3 = 8'h00; 2'b01: CRC8L_07_Table3 = 8'hC7; 2'b10: CRC8L_07_Table3 = 8'h89; 2'b11: CRC8L_07_Table3 = 8'h4E;
        default: CRC8L_07_Table3 = 8'h00;
    endcase
endfunction


always @(posedge clk or negedge rst)
begin
    if (!rst)
    begin
        crc8 <= 8'h00;
    end
    else
    begin
        CRC8L_0(crc8, data);
        outcrc8 <= crc8;
        crc8 <= crc8;
    end
end
endmodule


使用特权

评论回复

相关帖子

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

本版积分规则

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

1538

主题

21697

帖子

505

粉丝