📄 crc8_4.v
字号:
////////////////////////////////////////////////////////////////////////////////// crc calculation// This VERILOG code was generated using CRCGEN.PL version 1.7// Last Modified: 01/02/2002// Options Used:// Module Name = crc32// CRC Width = 8// Data Width = 4// CRC Init = 0// Polynomial = [0 -> 8]// 1 1 1 0 0 0 0 0 1//// Disclaimer: THESE DESIGNS ARE PROVIDED "AS IS" WITH NO WARRANTY // WHATSOEVER AND XILINX SPECIFICALLY DISCLAIMS ANY // IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR// A PARTICULAR PURPOSE, OR AGAINST INFRINGEMENT.//// Copyright (c) 2001,2002 Xilinx, Inc. All rights reserved.//////////////////////////////////////////////////////////////////////////////////module crc32 ( crc_reg, crc, d, calc, init, d_valid, clk, reset );output [7:0] crc_reg;output [3:0] crc;input [3:0] d;input calc;input init;input d_valid;input clk;input reset;reg [7:0] crc_reg;reg [3:0] crc;//////////////////////////////////////////////////////////////////////////////// Internal Signals//////////////////////////////////////////////////////////////////////////////wire [7:0] next_crc;//////////////////////////////////////////////////////////////////////////////// Infer CRC-8 registers// // The crc_reg register stores the CRC-8 value.// The crc register is the most significant 4 bits of the // CRC-8 value.//// Truth Table:// -----+---------+----------+----------------------------------------------// calc | d_valid | crc_reg | crc // -----+---------+----------+----------------------------------------------// 0 | 0 | crc_reg | crc // 0 | 1 | shift | bit-swapped, complimented msbyte of crc_reg// 1 | 0 | crc_reg | crc // 1 | 1 | next_crc | bit-swapped, complimented msbyte of next_crc// -----+---------+----------+----------------------------------------------// ////////////////////////////////////////////////////////////////////////////// always @ (posedge clk or posedge reset)begin if (reset) begin crc_reg <= 8'h00; crc <= 4'h0; end else if (init) begin crc_reg <= 8'h00; crc <= 4'h0; end else if (calc & d_valid) begin crc_reg <= next_crc; crc <= ~{next_crc[4], next_crc[5], next_crc[6], next_crc[7]}; end else if (~calc & d_valid) begin crc_reg <= {crc_reg[3:0], 4'h0}; crc <= ~{crc_reg[0], crc_reg[1], crc_reg[2], crc_reg[3]}; endend//////////////////////////////////////////////////////////////////////////////// CRC XOR equations//////////////////////////////////////////////////////////////////////////////assign next_crc[0] = d[3] ^ crc_reg[4];assign next_crc[1] = crc_reg[5] ^ d[2] ^ d[3] ^ crc_reg[4];assign next_crc[2] = crc_reg[5] ^ d[1] ^ crc_reg[6] ^ d[2] ^ d[3] ^ crc_reg[4];assign next_crc[3] = crc_reg[5] ^ d[0] ^ d[1] ^ crc_reg[6] ^ d[2] ^ crc_reg[7];assign next_crc[4] = d[0] ^ d[1] ^ crc_reg[6] ^ crc_reg[7] ^ crc_reg[0];assign next_crc[5] = d[0] ^ crc_reg[7] ^ crc_reg[1];assign next_crc[6] = crc_reg[2];assign next_crc[7] = crc_reg[3];endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -