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

[复制链接]
 楼主| hotpower 发表于 2023-9-21 12:02 | 显示全部楼层 |阅读模式
  1. /*-----------------------------------------------------------------------------------------------
  2.       HotCRC CRC16R_8408_FFFF_0000 FPGA模块 HotPower[url=home.php?mod=space&uid=516618]@163.com[/url] 2023-09-21 12:02:01
  3. -----------------------------------------------------------------------------------------------*/
  4. module CRC16R_8408(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 CRC16R_8408;
  10. inout[15:0] crc16;
  11. input[7:0] indata;
  12.     crc16 = crc16[15:8] ^ CRC16R_8408_Table(crc16[7:0] ^ indata);
  13. endtask

  14. function [15:0] CRC16R_8408_Table;
  15.     input [7:0] data;
  16.     CRC16R_8408_Table = CRC16R_8408_Table0(data[1:0]) ^ CRC16R_8408_Table1(data[3:2]) ^ CRC16R_8408_Table2(data[5:4]) ^ CRC16R_8408_Table3(data[7:6]);
  17. endfunction

  18. function [15:0] CRC16R_8408_Table0;
  19.     input[1:0] data;
  20.     case(data)
  21.         2'b00: CRC16R_8408_Table0 = 16'h0000; 2'b01: CRC16R_8408_Table0 = 16'h1189; 2'b10: CRC16R_8408_Table0 = 16'h2312; 2'b11: CRC16R_8408_Table0 = 16'h329B;
  22.         default: CRC16R_8408_Table0 = 16'h0000;
  23.     endcase
  24. endfunction

  25. function [15:0] CRC16R_8408_Table1;
  26.     input[1:0] data;
  27.     case(data)
  28.         2'b00: CRC16R_8408_Table1 = 16'h0000; 2'b01: CRC16R_8408_Table1 = 16'h4624; 2'b10: CRC16R_8408_Table1 = 16'h8C48; 2'b11: CRC16R_8408_Table1 = 16'hCA6C;
  29.         default: CRC16R_8408_Table1 = 16'h0000;
  30.     endcase
  31. endfunction

  32. function [15:0] CRC16R_8408_Table2;
  33.     input[1:0] data;
  34.     case(data)
  35.         2'b00: CRC16R_8408_Table2 = 16'h0000; 2'b01: CRC16R_8408_Table2 = 16'h1081; 2'b10: CRC16R_8408_Table2 = 16'h2102; 2'b11: CRC16R_8408_Table2 = 16'h3183;
  36.         default: CRC16R_8408_Table2 = 16'h0000;
  37.     endcase
  38. endfunction

  39. function [15:0] CRC16R_8408_Table3;
  40.     input[1:0] data;
  41.     case(data)
  42.         2'b00: CRC16R_8408_Table3 = 16'h0000; 2'b01: CRC16R_8408_Table3 = 16'h4204; 2'b10: CRC16R_8408_Table3 = 16'h8408; 2'b11: CRC16R_8408_Table3 = 16'hC60C;
  43.         default: CRC16R_8408_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'hFFFF;
  51.     end
  52.     else
  53.     begin
  54.         CRC16R_8408(crc16, data);
  55.         outcrc16 <= crc16;
  56.         crc16 <= crc16;
  57.     end
  58. end
  59. endmodule


HotCRC CRC16R_8408_FFFF_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

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