module crc_16(
input clk,
input [47:0]mac,
input rst,
input hash_enable,//哈希控制器使能位
output reg hash_complete,//哈希转换完成标志位
output reg [15:0]crc_16
); wire[63:0]stemp;
reg[63:0]temp=0;
reg temp_flag;
parameter polynomial=17'b1_0001_0000_0010_0001;
assign stemp={mac,16'b0000000000000000}; always @ (*) begin//posedge clk or negedge rst
if(rst) begin
hash_complete<=0;
crc_16<=0;
temp<=0;
temp_flag<=0;
end
else if(hash_enable && temp_flag)begin
if(temp[63]) temp[63:47]<=temp[63:47]^polynomial;
else if(temp[62]) temp[62:46]<=temp[62:46]^polynomial;
else if(temp[61]) temp[61:45]<=temp[61:45]^polynomial;
else if(temp[60]) temp[60:44]<=temp[60:44]^polynomial;
else if(temp[59]) temp[59:43]<=temp[59:43]^polynomial;
else if(temp[58]) temp[58:42]<=temp[58:42]^polynomial;
else if(temp[57]) temp[57:41]<=temp[57:41]^polynomial;
else if(temp[56]) temp[56:40]<=temp[56:40]^polynomial;
else if(temp[55]) temp[55:39]<=temp[55:39]^polynomial;
else if(temp[54]) temp[54:38]<=temp[54:38]^polynomial;
else if(temp[53]) temp[53:37]<=temp[53:37]^polynomial;
else if(temp[52]) temp[52:36]<=temp[52:36]^polynomial;
else if(temp[51]) temp[51:35]<=temp[51:35]^polynomial;
else if(temp[50]) temp[50:34]<=temp[50:34]^polynomial;
else if(temp[49]) temp[49:33]<=temp[49:33]^polynomial;
else if(temp[48]) temp[48:32]<=temp[48:32]^polynomial;
else if(temp[47]) temp[47:31]<=temp[47:31]^polynomial;
else if(temp[46]) temp[46:30]<=temp[46:30]^polynomial;
else if(temp[45]) temp[45:29]<=temp[45:29]^polynomial;
else if(temp[44]) temp[44:28]<=temp[44:28]^polynomial;
else if(temp[43]) temp[43:27]<=temp[43:27]^polynomial;
else if(temp[42]) temp[42:26]<=temp[42:26]^polynomial;
else if(temp[41]) temp[41:25]<=temp[41:25]^polynomial;
else if(temp[40]) temp[40:24]<=temp[40:24]^polynomial;
else if(temp[39]) temp[39:23]<=temp[39:23]^polynomial;
else if(temp[38]) temp[38:22]<=temp[38:22]^polynomial;
else if(temp[37]) temp[37:21]<=temp[37:21]^polynomial;
else if(temp[36]) temp[36:20]<=temp[36:20]^polynomial;
else if(temp[35]) temp[35:19]<=temp[35:19]^polynomial;
else if(temp[34]) temp[34:18]<=temp[34:18]^polynomial;
else if(temp[33]) temp[33:17]<=temp[33:17]^polynomial;
else if(temp[32]) temp[32:16]<=temp[32:16]^polynomial;
else if(temp[31]) temp[31:15]<=temp[31:15]^polynomial;
else if(temp[30]) temp[30:14]<=temp[30:14]^polynomial;
else if(temp[29]) temp[29:13]<=temp[29:13]^polynomial;
else if(temp[28]) temp[28:12]<=temp[28:12]^polynomial;
else if(temp[27]) temp[27:11]<=temp[27:11]^polynomial;
else if(temp[26]) temp[26:10]<=temp[26:10]^polynomial;
else if(temp[25]) temp[25:9]<=temp[25:9]^polynomial;
else if(temp[24]) temp[24:8]<=temp[24:8]^polynomial;
else if(temp[23]) temp[23:7]<=temp[23:7]^polynomial;
else if(temp[22]) temp[22:6]<=temp[22:6]^polynomial;
else if(temp[21]) temp[21:5]<=temp[21:5]^polynomial;
else if(temp[20]) temp[20:4]<=temp[20:4]^polynomial;
else if(temp[19]) temp[19:3]<=temp[19:3]^polynomial;
else if(temp[18]) temp[18:2]<=temp[18:2]^polynomial;
else if(temp[17]) temp[17:1]<=temp[17:1]^polynomial;
else if(temp[16]) temp[16:0]<=temp[16:0]^polynomial;
else begin crc_16<=temp[15:0]; hash_complete <= 1;end
end
else if(hash_enable)begin
temp<=stemp;
temp_flag<=1;
end
else begin
hash_complete<=0;
temp_flag<=0;
end
end
endmodule

FPGA CRC-16/XMODEM x16+x12+x5+1的更多相关文章

  1. CRC-16/XMODE X16+X12+X5+1 C#、C和java环境下实现

    private byte[] CRC(byte[] x, int len) //CRC校验函数 { ]; UInt16 crc = ; byte da; ; UInt16[] yu = { 0x000 ...

  2. 关于FPGA设计16位乘法器的两…

    原文地址:关于FPGA设计16位乘法器的两种算法作者:ChrisChan 部分原代码如下: 用特权的右移算法虽复杂点,但节省不少LEs,如下图: 用左移算法尽管浅显易懂,但因每次都会从最右端移位,会占 ...

  3. CRC(16位)多项式为 X16+X15+X2+1

    其对应校验二进制位列为1 1000 0000 0000 0101,可这有17位啊,我怎么和16位信息进行异或啊?是不是不要最高位的1 你没有弄明白crc的意思.这17位后面再添上16个零,然后开始抑或 ...

  4. C# CRC - 16

    using System; static class Program { static void Main() { string input = "8000"; var bytes ...

  5. Modbus CRC 16 (C#)

    算法 1.预置一个值为 0xFFFF 的 16 位寄存器,此寄存器为 CRC 寄存器. 2.把第 1 个 8 位二进制数据(即通信消息帧的第 1 个字节)与 16 位的 CRC 寄存器相异或,异或的结 ...

  6. 基于FPGA的16阶级联型iir带通滤波器实现

    警告 此文章将耗费你成吨的流量,请wifi下阅读,造成的流量浪费本人不承担任何责任.初版源代码获取(请勿用作他用,仅供学习):https://gitee.com/kingstacker/iir.git ...

  7. HJ212 CRC 16 (C#)

    算法 CRC16 校验寄存器赋值为 0xFFFF: 取被校验串的第一个字节赋值给临时寄存器: 临时寄存器与 CRC16 校验寄存器的高位字节进行"异或"运算,赋值给 CRC16 校 ...

  8. CRC全套~~~ 转载

    经测试CRC16-CCITT是可以了,其它暂时没有测试哦. 00 0E 00 01 00 01 20 17 12 26 20 19 16 01 00 00 01 01 00 00 00 00 00 0 ...

  9. 用C#实现的几种常用数据校验方法整理(CRC校验;LRC校验;BCC校验;累加和校验)

    CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种查错校验码,其特征是信息字段和校验字段的长度可以任意选定.循环冗余检查(CRC)是一种数据传输检错 ...

随机推荐

  1. DataTable.Copy()

    DataTable dtpocopy = dtPO.Copy(); DataRow[] dr = dtpocopy .Select("客户名称='" + cusName + &qu ...

  2. maven详解之 pom.xml 解释

    <project>:pom.xml的根标签,一个maven项目用一对<peoject></project>标签包裹. <modelVersion>4.0 ...

  3. VMware Workstation上新建虚拟机

    准备开始,话不多少,直接上图 点击创建新的虚拟机或者在文件上面选择新建虚拟机 点击完成就可以了 后面的步骤,是在公司电脑上完成的,新建了一个CentOs1,步骤同上,后面继续,然后需要更改配置,点击虚 ...

  4. 【转】R语言函数总结

    原博: R语言与数据挖掘:公式:数据:方法 R语言特征 对大小写敏感 通常,数字,字母,. 和 _都是允许的(在一些国家还包括重音字母).不过,一个命名必须以 . 或者字母开头,并且如果以 . 开头, ...

  5. Python 比较 相等性 真值

    1 == 操作符测试 值 的相等性: is 测试对象的一致性.注意短字符串的is相等性测试,PVM会缓存短字符串,s1 is s2 将返回true. 2 false:"", [], ...

  6. zoj 1483 划分类DP

    还是看了little_w大神写的才知道怎么写,看完发现自己题意也理解错了,里面有个neighboring,意思就是你指定任务的时候指定的是原序列中连续的一段 然后就是怎么DP了,新学了个很好的dp模型 ...

  7. 实验吧-密码学-Fair-Play(Playfair解密)

    这个题是Playfair解密. Playfair解密算法首先将密钥填写在一个5*5的矩阵中(去Q留Z),矩阵中其它未用到的字母按顺序填在矩阵剩余位置中,根据替换矩阵由密文得到明文. 对密文解密规则如下 ...

  8. zTree的学习

    最近要做一个有关权限的东西,原理和数据库都已经知道了,就是树状图困难. 原先是打算用layui的,因为我孤陋寡闻……吃了大亏,弄了3个小时,屁都没有.只能说是…… 后来百度找到了zTree,进去学习了 ...

  9. 【Android】家庭记账本手机版开发报告七

    一.说在前面  昨天 实现了账单的图标显示  今天 本地化,测试APP,将工程源码放到github上 源码:https://github.com/xiaotian12-call/Android_Boo ...

  10. 把Ubuntu系统自带的源修改为国内的源,中科大源链接:https://mirrors.ustc.edu.cn/repogen/

    https://mirrors.ustc.edu.cn/repogen/ Tips: 可通过 URL 的形式直接下载配置. 例如: https://mirrors.ustc.edu.cn/repoge ...