1 |
39 |
fisher5090 |
module CRC32_D8(DATA_IN, CLK, RESET, START, LOAD, CRC_IN, CRC_OUT);
|
2 |
|
|
|
3 |
|
|
input [7:0] DATA_IN;
|
4 |
|
|
input CLK;
|
5 |
|
|
input RESET;
|
6 |
|
|
input START;
|
7 |
|
|
input LOAD;
|
8 |
|
|
input [31:0] CRC_IN;
|
9 |
|
|
output [31:0] CRC_OUT;
|
10 |
|
|
|
11 |
|
|
reg [31:0] CRC_OUT;
|
12 |
|
|
reg start_int;
|
13 |
|
|
reg [7:0] data_int;
|
14 |
|
|
|
15 |
|
|
always @(posedge CLK)
|
16 |
|
|
begin
|
17 |
|
|
start_int <= START;
|
18 |
|
|
data_int <= DATA_IN;
|
19 |
|
|
end
|
20 |
|
|
|
21 |
|
|
always @(posedge CLK or posedge RESET)
|
22 |
|
|
begin
|
23 |
|
|
if (RESET) begin
|
24 |
|
|
CRC_OUT = 0;
|
25 |
|
|
end
|
26 |
|
|
else if (start_int == 1) begin
|
27 |
|
|
CRC_OUT = nextCRC32_D8(data_int, CRC_OUT);
|
28 |
|
|
end
|
29 |
|
|
else if (LOAD == 1) begin
|
30 |
|
|
CRC_OUT = CRC_IN;
|
31 |
|
|
end
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
end
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
///////////////////////////////////////////////////////////////////////
|
39 |
|
|
// File: CRC32_D64.v
|
40 |
|
|
// Date: Sun Nov 27 19:32:12 2005
|
41 |
|
|
//
|
42 |
|
|
// Copyright (C) 1999-2003 Easics NV.
|
43 |
|
|
// This source file may be used and distributed without restriction
|
44 |
|
|
// provided that this copyright statement is not removed from the file
|
45 |
|
|
// and that any derivative work contains the original copyright notice
|
46 |
|
|
// and the associated disclaimer.
|
47 |
|
|
//
|
48 |
|
|
// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
|
49 |
|
|
// OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
50 |
|
|
// WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
51 |
|
|
//
|
52 |
|
|
// Purpose: Verilog module containing a synthesizable CRC function
|
53 |
|
|
// * polynomial: (0 1 2 4 5 7 8 10 11 12 16 22 23 26 32)
|
54 |
|
|
// * data width: 64
|
55 |
|
|
//
|
56 |
|
|
// Info: tools@easics.be
|
57 |
|
|
// http://www.easics.com
|
58 |
|
|
///////////////////////////////////////////////////////////////////////
|
59 |
|
|
|
60 |
|
|
// polynomial: (0 1 2 3 4 5 7 8 10 11 12 16 22 23 26 32)
|
61 |
|
|
// data width: 8
|
62 |
|
|
// convention: the first serial data bit is D[7]
|
63 |
|
|
function [31:0] nextCRC32_D8;
|
64 |
|
|
|
65 |
|
|
input [7:0] Data;
|
66 |
|
|
input [31:0] CRC;
|
67 |
|
|
|
68 |
|
|
reg [7:0] D;
|
69 |
|
|
reg [31:0] C;
|
70 |
|
|
reg [31:0] NewCRC;
|
71 |
|
|
|
72 |
|
|
begin
|
73 |
|
|
|
74 |
|
|
D = Data;
|
75 |
|
|
C = CRC;
|
76 |
|
|
|
77 |
|
|
NewCRC[0] = D[6] ^ D[0] ^ C[24] ^ C[30];
|
78 |
|
|
NewCRC[1] = D[7] ^ D[6] ^ D[1] ^ D[0] ^ C[24] ^ C[25] ^ C[30] ^
|
79 |
|
|
C[31];
|
80 |
|
|
NewCRC[2] = D[7] ^ D[6] ^ D[2] ^ D[1] ^ D[0] ^ C[24] ^ C[25] ^
|
81 |
|
|
C[26] ^ C[30] ^ C[31];
|
82 |
|
|
NewCRC[3] = D[7] ^ D[6] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[24] ^ C[25] ^
|
83 |
|
|
C[26] ^ C[27] ^ C[30] ^ C[31];
|
84 |
|
|
NewCRC[4] = D[7] ^ D[6] ^ D[4] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^ C[24] ^
|
85 |
|
|
C[25] ^ C[26] ^ C[27] ^ C[28] ^ C[30] ^ C[31];
|
86 |
|
|
NewCRC[5] = D[7] ^ D[6] ^ D[5] ^ D[4] ^ D[3] ^ D[2] ^ D[1] ^ D[0] ^
|
87 |
|
|
C[24] ^ C[25] ^ C[26] ^ C[27] ^ C[28] ^ C[29] ^ C[30] ^
|
88 |
|
|
C[31];
|
89 |
|
|
NewCRC[6] = D[7] ^ D[6] ^ D[5] ^ D[4] ^ D[3] ^ D[2] ^ D[1] ^ C[25] ^
|
90 |
|
|
C[26] ^ C[27] ^ C[28] ^ C[29] ^ C[30] ^ C[31];
|
91 |
|
|
NewCRC[7] = D[7] ^ D[5] ^ D[4] ^ D[3] ^ D[2] ^ D[0] ^ C[24] ^ C[26] ^
|
92 |
|
|
C[27] ^ C[28] ^ C[29] ^ C[31];
|
93 |
|
|
NewCRC[8] = D[5] ^ D[4] ^ D[3] ^ D[1] ^ D[0] ^ C[0] ^ C[24] ^ C[25] ^
|
94 |
|
|
C[27] ^ C[28] ^ C[29];
|
95 |
|
|
NewCRC[9] = D[6] ^ D[5] ^ D[4] ^ D[2] ^ D[1] ^ C[1] ^ C[25] ^ C[26] ^
|
96 |
|
|
C[28] ^ C[29] ^ C[30];
|
97 |
|
|
NewCRC[10] = D[7] ^ D[5] ^ D[3] ^ D[2] ^ D[0] ^ C[2] ^ C[24] ^ C[26] ^
|
98 |
|
|
C[27] ^ C[29] ^ C[31];
|
99 |
|
|
NewCRC[11] = D[4] ^ D[3] ^ D[1] ^ D[0] ^ C[3] ^ C[24] ^ C[25] ^
|
100 |
|
|
C[27] ^ C[28];
|
101 |
|
|
NewCRC[12] = D[6] ^ D[5] ^ D[4] ^ D[2] ^ D[1] ^ D[0] ^ C[4] ^ C[24] ^
|
102 |
|
|
C[25] ^ C[26] ^ C[28] ^ C[29] ^ C[30];
|
103 |
|
|
NewCRC[13] = D[7] ^ D[6] ^ D[5] ^ D[3] ^ D[2] ^ D[1] ^ C[5] ^ C[25] ^
|
104 |
|
|
C[26] ^ C[27] ^ C[29] ^ C[30] ^ C[31];
|
105 |
|
|
NewCRC[14] = D[7] ^ D[6] ^ D[4] ^ D[3] ^ D[2] ^ C[6] ^ C[26] ^ C[27] ^
|
106 |
|
|
C[28] ^ C[30] ^ C[31];
|
107 |
|
|
NewCRC[15] = D[7] ^ D[5] ^ D[4] ^ D[3] ^ C[7] ^ C[27] ^ C[28] ^
|
108 |
|
|
C[29] ^ C[31];
|
109 |
|
|
NewCRC[16] = D[5] ^ D[4] ^ D[0] ^ C[8] ^ C[24] ^ C[28] ^ C[29];
|
110 |
|
|
NewCRC[17] = D[6] ^ D[5] ^ D[1] ^ C[9] ^ C[25] ^ C[29] ^ C[30];
|
111 |
|
|
NewCRC[18] = D[7] ^ D[6] ^ D[2] ^ C[10] ^ C[26] ^ C[30] ^ C[31];
|
112 |
|
|
NewCRC[19] = D[7] ^ D[3] ^ C[11] ^ C[27] ^ C[31];
|
113 |
|
|
NewCRC[20] = D[4] ^ C[12] ^ C[28];
|
114 |
|
|
NewCRC[21] = D[5] ^ C[13] ^ C[29];
|
115 |
|
|
NewCRC[22] = D[0] ^ C[14] ^ C[24];
|
116 |
|
|
NewCRC[23] = D[6] ^ D[1] ^ D[0] ^ C[15] ^ C[24] ^ C[25] ^ C[30];
|
117 |
|
|
NewCRC[24] = D[7] ^ D[2] ^ D[1] ^ C[16] ^ C[25] ^ C[26] ^ C[31];
|
118 |
|
|
NewCRC[25] = D[3] ^ D[2] ^ C[17] ^ C[26] ^ C[27];
|
119 |
|
|
NewCRC[26] = D[6] ^ D[4] ^ D[3] ^ D[0] ^ C[18] ^ C[24] ^ C[27] ^
|
120 |
|
|
C[28] ^ C[30];
|
121 |
|
|
NewCRC[27] = D[7] ^ D[5] ^ D[4] ^ D[1] ^ C[19] ^ C[25] ^ C[28] ^
|
122 |
|
|
C[29] ^ C[31];
|
123 |
|
|
NewCRC[28] = D[6] ^ D[5] ^ D[2] ^ C[20] ^ C[26] ^ C[29] ^ C[30];
|
124 |
|
|
NewCRC[29] = D[7] ^ D[6] ^ D[3] ^ C[21] ^ C[27] ^ C[30] ^ C[31];
|
125 |
|
|
NewCRC[30] = D[7] ^ D[4] ^ C[22] ^ C[28] ^ C[31];
|
126 |
|
|
NewCRC[31] = D[5] ^ C[23] ^ C[29];
|
127 |
|
|
|
128 |
|
|
nextCRC32_D8 = NewCRC;
|
129 |
|
|
|
130 |
|
|
end
|
131 |
|
|
|
132 |
|
|
endfunction
|
133 |
|
|
|
134 |
|
|
endmodule
|
135 |
|
|
|