[独创算法] HotCRC CRC16L_1021_0000_0000 FPGA模块 HotPower@163.com(菜农独创)

[复制链接]
 楼主| hotpower 发表于 2023-9-21 11:48 | 显示全部楼层 |阅读模式
本帖最后由 hotpower 于 2023-9-21 11:54 编辑
  1. /*-----------------------------------------------------------------------------------------------
  2.       HotCRC CRC16L_1021_0000_0000 FPGA模块 [url=mailto:HotPower@163.com]HotPower@163.com[/url] 2023-09-21 11:47:20
  3. -----------------------------------------------------------------------------------------------*/
  4. module CRC16L_1021(clk, rst, data, outcrc16)
  5. input clk, rst;
  6. input [7:0] data;
  7. output reg[15:0] outcrc16;
  8. reg [15:0] crc16;

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

  14. function [15:0] CRC16L_1021_Table;
  15.     input [7:0] data;
  16.     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]);
  17. endfunction

  18. function [15:0] CRC16L_1021_Table0;
  19.     input[1:0] data;
  20.     case(data)
  21.         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;
  22.         default: CRC16L_1021_Table0 = 16'h0000;
  23.     endcase
  24. endfunction

  25. function [15:0] CRC16L_1021_Table1;
  26.     input[1:0] data;
  27.     case(data)
  28.         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;
  29.         default: CRC16L_1021_Table1 = 16'h0000;
  30.     endcase
  31. endfunction

  32. function [15:0] CRC16L_1021_Table2;
  33.     input[1:0] data;
  34.     case(data)
  35.         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;
  36.         default: CRC16L_1021_Table2 = 16'h0000;
  37.     endcase
  38. endfunction

  39. function [15:0] CRC16L_1021_Table3;
  40.     input[1:0] data;
  41.     case(data)
  42.         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;
  43.         default: CRC16L_1021_Table3 = 16'h0000;
  44.     endcase
  45. endfunction


  46. always [url=home.php?mod=space&uid=72445]@[/url] (posedge clk or negedge rst)
  47. begin
  48.     if (!rst)
  49.     begin
  50.         crc16 <= 16'h0000;
  51.     end
  52.     else
  53.     begin
  54.         CRC16L_1021(crc16, data);
  55.         outcrc16 <= crc16;
  56.         crc16 <= crc16;
  57.     end
  58. end
  59. endmodule
HotCRC CRC16L_1021_0000_0000 FPGA模块 HotPower@163.com(源码自动生成).png
微信扫码截图.jpg
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

1460

主题

21619

帖子

508

粉丝
快速回复 在线客服 返回列表 返回顶部
个人签名:[url=http://www.21ic.com/tools/HotWC3_V1.23.html]

1460

主题

21619

帖子

508

粉丝
快速回复 在线客服 返回列表 返回顶部