|
发表于 2013-6-28 18:25:36
|
显示全部楼层
这是一个CRC10,数据位宽8,根据easics自动生成的模块修改而成。由于运算复杂度低,整个模块被当作一个只有组合逻辑的黑盒。
在上层模块例化该模块,每个data_in有效的周期,用时钟把crc_out取走更新crc_lst就可以啦
///////////////////////////////////////////////////////////////////////
// File: CRC10_D8.v
// Date:
//
// Copyright (C) 1999-2003 Easics NV.
// This source file may be used and distributed without restriction
// provided that this copyright statement is not removed from the file
// and that any derivative work contains the original copyright notice
// and the associated disclaimer.
//
// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Purpose: Verilog module containing a synthesizable CRC function
// * polynomial: (0 1 4 5 9 10)
// * data width: 8
//
// Info: tools@easics.be
// http://www.easics.com
///////////////////////////////////////////////////////////////////////
module CRC10_D8(
data_in,
crc_lst,
crc_out
);
// polynomial: (0 1 4 5 9 10)
// data width: 8
// convention: the first serial data bit is D[7]
input [7:0] data_in;
input [9:0] crc_lst;
output [9:0] crc_out;
wire [7:0] D;
wire [9:0] C;
wire [9:0] NewCRC;
assign D = data_in;
assign C = crc_lst;
assign NewCRC[0] = D[4] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[2] ^ C[3] ^ C[4] ^
C[5] ^ C[6];
assign NewCRC[1] = D[5] ^ D[0] ^ C[2] ^ C[7];
assign NewCRC[2] = D[6] ^ D[1] ^ C[3] ^ C[8];
assign NewCRC[3] = D[7] ^ D[2] ^ C[4] ^ C[9];
assign NewCRC[4] = D[4] ^ D[2] ^ D[1] ^ D[0] ^ C[2] ^ C[3] ^ C[4] ^ C[6];
assign NewCRC[5] = D[5] ^ D[4] ^ D[0] ^ C[2] ^ C[6] ^ C[7];
assign NewCRC[6] = D[6] ^ D[5] ^ D[1] ^ C[3] ^ C[7] ^ C[8];
assign NewCRC[7] = D[7] ^ D[6] ^ D[2] ^ C[4] ^ C[8] ^ C[9];
assign NewCRC[8] = D[7] ^ D[3] ^ C[0] ^ C[5] ^ C[9];
assign NewCRC[9] = D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[1] ^ C[2] ^ C[3] ^ C[4] ^
C[5];
assign crc_out = NewCRC;
endmodule |
|