FPGA CRC-16/XMODEM x16+x12+x5+1
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的更多相关文章
- 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 ...
- 关于FPGA设计16位乘法器的两…
原文地址:关于FPGA设计16位乘法器的两种算法作者:ChrisChan 部分原代码如下: 用特权的右移算法虽复杂点,但节省不少LEs,如下图: 用左移算法尽管浅显易懂,但因每次都会从最右端移位,会占 ...
- CRC(16位)多项式为 X16+X15+X2+1
其对应校验二进制位列为1 1000 0000 0000 0101,可这有17位啊,我怎么和16位信息进行异或啊?是不是不要最高位的1 你没有弄明白crc的意思.这17位后面再添上16个零,然后开始抑或 ...
- C# CRC - 16
using System; static class Program { static void Main() { string input = "8000"; var bytes ...
- Modbus CRC 16 (C#)
算法 1.预置一个值为 0xFFFF 的 16 位寄存器,此寄存器为 CRC 寄存器. 2.把第 1 个 8 位二进制数据(即通信消息帧的第 1 个字节)与 16 位的 CRC 寄存器相异或,异或的结 ...
- 基于FPGA的16阶级联型iir带通滤波器实现
警告 此文章将耗费你成吨的流量,请wifi下阅读,造成的流量浪费本人不承担任何责任.初版源代码获取(请勿用作他用,仅供学习):https://gitee.com/kingstacker/iir.git ...
- HJ212 CRC 16 (C#)
算法 CRC16 校验寄存器赋值为 0xFFFF: 取被校验串的第一个字节赋值给临时寄存器: 临时寄存器与 CRC16 校验寄存器的高位字节进行"异或"运算,赋值给 CRC16 校 ...
- 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 ...
- 用C#实现的几种常用数据校验方法整理(CRC校验;LRC校验;BCC校验;累加和校验)
CRC即循环冗余校验码(Cyclic Redundancy Check):是数据通信领域中最常用的一种查错校验码,其特征是信息字段和校验字段的长度可以任意选定.循环冗余检查(CRC)是一种数据传输检错 ...
随机推荐
- 8 Jvm堆分析
备注:直接内存分配,无法触发GC动作 备注:with outgoing reference (当前选中对象引用的对象),with incoming references(引用当前对象的对象)
- 自己写个tween
public Vector3 begin,end;//起始终止坐标 public float BtoE_time;//用时 float timer,lerp;//计时器和进度值 void Update ...
- SpringBoot-配置Java方式
SpringBoot中使用Java方式配置步骤如下: 在类上加入@Configuration注解,代表作为配置类 在该类方法上加入@Bean注解,代表将方法返回的Bean加入Spring容器 在该类中 ...
- python三大神器===》生成器
1. 认识生成器 利用迭代器,我们可以在每次迭代获取数据(通过next()方法)时按照特定的规律进行生成.但是我们在实现一个迭代器时,关于当前迭代到的状态需要我们自己记录,进而才能根据当前状态生成下一 ...
- LeetCode1005 K次取反后最大化的数组和(贪心+Java简单排序)
题目: 给定一个整数数组 A,我们只能用以下方法修改该数组:我们选择某个个索引 i 并将 A[i] 替换为 -A[i],然后总共重复这个过程 K 次.(我们可以多次选择同一个索引 i.) 以这种方式修 ...
- 英语学习 - 进行时态的被动 ( be being done )
be being done 例: The story book was being read by him .
- hibernate字段值无法保存
通过hibernate对Blogstorage对象进行保存操作,filepath属性的值无论设置多少遍都保存不进去 后来发现是 Blogstorage.hbm.xml 里面根本没有配置filepath ...
- 七、JavaScript之console.log输出和document.write输出
一.代码如下 二.运行效果如下 三.点击之后,效果如下 四.按一下F12,在控制台中可以看到
- 018-PHP判断文件是否存在
<?php print("data.txt文件是否存在?" . "<br>"); if (file_exists("data.txt ...
- PowerDesigner创建索引
防止以后忘记怎么设置索引,记录下来方便查翻 1:选中Table 2:找到Table对应的Indexes 3:选中一条记录,点击红框中的小手(Properties)或双击该记录,进入到详细里面 4:找到 ...