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)是一种数据传输检错 ...
随机推荐
- http https 干货
HTTPS原理 在谈HTTPS原理之前,首先了解一下Http和Https的区别. Http(全称:Hyper Text Transfer Protocol),一般称为超文本传输协议,也是互联 ...
- maven详解 之仓库
Maven仓库分类 MAVEN仓库分类 Maven仓库分为:本地仓库+远程仓库两大类 远程仓库又分为:中央仓库+私服+其它公共远程仓库 1,在Maven中,任何一个依赖.插件或者项目构建的输出,都 ...
- Phoenix5.0的部署
官网下载编译好的二进制包 http://phoenix.apache.org/download.html2 上传并解压到指定目录, 再修改目录名称 tar -zxvf apache-phoenix-5 ...
- ApplicationListener监听使用ContextRefreshedEvent事件类型会触发多次
@Componentpublic class TestApplicationListener implements ApplicationListener<ContextRefreshedEve ...
- 自制spring中bean加载机制,仅做笔记自用
- JavaScript中的apply()方法和call()
apply()和call()的真正用武之地是能够扩充函数赖以运行的作用域 两个函数的第一个参数是都是,要执行语句的作业域,即this 区别是 apply后面只能传一个大参数,call后面参数只能一 ...
- Html5 经验
http://knockoutjs.com/documentation/introduction.html knockout的模式 MVVM 四大重要概念 声明式绑定UI界面自动刷新依赖跟踪模版 一些 ...
- Git TortoiseGit github 操作
由于公司采用了分布式架构,选择的是gitlab git 来管理代码等工作,鉴于github和gitlab的相似性,网上查看好多都是用git的命令上传,或者是一部分,为此,借鉴多方网络,并进行实际操作, ...
- SpringBoot#RestControllerAdvice
__震惊! 不可避免的访问一些控制器会产生一些异常,这些异常不经处理传递到前台页面,会很难看. 涉及到的注解: org.springframework.web.bind.annotation.Rest ...
- jquery实现常用UI布局
tab html <div class="tab"> <ul class="tab-title"> <li class=" ...