1 |
2 |
dmitryr |
// ========== Copyright Header Begin ==========================================
|
2 |
|
|
//
|
3 |
|
|
// OpenSPARC T1 Processor File: m1.behV
|
4 |
|
|
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
|
5 |
|
|
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
|
6 |
|
|
//
|
7 |
|
|
// The above named program is free software; you can redistribute it and/or
|
8 |
|
|
// modify it under the terms of the GNU General Public
|
9 |
|
|
// License version 2 as published by the Free Software Foundation.
|
10 |
|
|
//
|
11 |
|
|
// The above named program is distributed in the hope that it will be
|
12 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public
|
17 |
|
|
// License along with this work; if not, write to the Free Software
|
18 |
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
|
|
//
|
20 |
|
|
// ========== Copyright Header End ============================================
|
21 |
|
|
////////////////////////////////////////////////////////////////////////
|
22 |
|
|
// 64 bit nor gate with first 32 bits out
|
23 |
|
|
|
24 |
|
|
module zznor64_32 ( znor64, znor32, a );
|
25 |
|
|
input [63:0] a;
|
26 |
|
|
output znor64;
|
27 |
|
|
output znor32;
|
28 |
|
|
|
29 |
|
|
assign znor32 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
30 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
31 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
32 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]);
|
33 |
|
|
|
34 |
|
|
assign znor64 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
35 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
36 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
37 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
38 |
|
|
| a[32] | a[33] | a[34] | a[35] | a[36] | a[37] | a[38] | a[39]
|
39 |
|
|
| a[40] | a[41] | a[42] | a[43] | a[44] | a[45] | a[46] | a[47]
|
40 |
|
|
| a[48] | a[49] | a[50] | a[51] | a[52] | a[53] | a[54] | a[55]
|
41 |
|
|
| a[56] | a[57] | a[58] | a[59] | a[60] | a[61] | a[62] | a[63]);
|
42 |
|
|
|
43 |
|
|
endmodule // zznor64_32
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
48 |
|
|
// 36 bit or gate
|
49 |
|
|
|
50 |
|
|
module zzor36 ( z, a );
|
51 |
|
|
input [35:0] a;
|
52 |
|
|
output z;
|
53 |
|
|
|
54 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
55 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
56 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
57 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
58 |
|
|
| a[32] | a[33] | a[34] | a[35]);
|
59 |
|
|
|
60 |
|
|
endmodule // zzor36
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
65 |
|
|
// 32 bit or gate
|
66 |
|
|
|
67 |
|
|
module zzor32 ( z, a );
|
68 |
|
|
input [31:0] a;
|
69 |
|
|
output z;
|
70 |
|
|
|
71 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
72 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
73 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
74 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]);
|
75 |
|
|
|
76 |
|
|
endmodule // zzor32
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
81 |
|
|
// 24 bit nor gate
|
82 |
|
|
|
83 |
|
|
module zznor24 ( z, a );
|
84 |
|
|
input [23:0] a;
|
85 |
|
|
output z;
|
86 |
|
|
|
87 |
|
|
assign z = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
88 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
89 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]);
|
90 |
|
|
|
91 |
|
|
endmodule // zznor24
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
96 |
|
|
// 16 bit nor gate
|
97 |
|
|
|
98 |
|
|
module zznor16 ( z, a );
|
99 |
|
|
input [15:0] a;
|
100 |
|
|
output z;
|
101 |
|
|
|
102 |
|
|
assign z = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
103 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]);
|
104 |
|
|
|
105 |
|
|
endmodule // zznor16
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
110 |
|
|
// 8 bit or gate
|
111 |
|
|
|
112 |
|
|
module zzor8 ( z, a );
|
113 |
|
|
input [7:0] a;
|
114 |
|
|
output z;
|
115 |
|
|
|
116 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]);
|
117 |
|
|
|
118 |
|
|
endmodule // zzor8
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
124 |
|
|
// Description: This block implements the adder for the sparc FPU.
|
125 |
|
|
// It takes two operands and a carry bit. It adds them together
|
126 |
|
|
// and sends the output to adder_out.
|
127 |
|
|
|
128 |
|
|
module zzadd13 ( rs1_data, rs2_data, cin, adder_out );
|
129 |
|
|
|
130 |
|
|
input [12:0] rs1_data; // 1st input operand
|
131 |
|
|
input [12:0] rs2_data; // 2nd input operand
|
132 |
|
|
input cin; // carry in
|
133 |
|
|
|
134 |
|
|
output [12:0] adder_out; // result of adder
|
135 |
|
|
|
136 |
|
|
assign adder_out = rs1_data + rs2_data + cin;
|
137 |
|
|
|
138 |
|
|
endmodule // zzadd13
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
143 |
|
|
// Description: This block implements the adder for the sparc FPU.
|
144 |
|
|
// It takes two operands and a carry bit. It adds them together
|
145 |
|
|
// and sends the output to adder_out.
|
146 |
|
|
|
147 |
|
|
module zzadd56 ( rs1_data, rs2_data, cin, adder_out );
|
148 |
|
|
|
149 |
|
|
input [55:0] rs1_data; // 1st input operand
|
150 |
|
|
input [55:0] rs2_data; // 2nd input operand
|
151 |
|
|
input cin; // carry in
|
152 |
|
|
|
153 |
|
|
output [55:0] adder_out; // result of adder
|
154 |
|
|
|
155 |
|
|
assign adder_out = rs1_data + rs2_data + cin;
|
156 |
|
|
|
157 |
|
|
endmodule // zzadd56
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
162 |
|
|
|
163 |
|
|
module zzadd48 ( rs1_data, rs2_data, cin, adder_out );
|
164 |
|
|
|
165 |
|
|
input [47:0] rs1_data; // 1st input operand
|
166 |
|
|
input [47:0] rs2_data; // 2nd input operand
|
167 |
|
|
input cin; // carry in
|
168 |
|
|
|
169 |
|
|
output [47:0] adder_out; // result of adder
|
170 |
|
|
|
171 |
|
|
assign adder_out = rs1_data + rs2_data + cin;
|
172 |
|
|
|
173 |
|
|
endmodule // zzadd48
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
178 |
|
|
// This adder is primarily used in the multiplier.
|
179 |
|
|
// The cin to out path is optimized.
|
180 |
|
|
|
181 |
|
|
module zzadd34c ( rs1_data, rs2_data, cin, adder_out );
|
182 |
|
|
|
183 |
|
|
input [33:0] rs1_data;
|
184 |
|
|
input [33:0] rs2_data;
|
185 |
|
|
input cin;
|
186 |
|
|
|
187 |
|
|
output [33:0] adder_out;
|
188 |
|
|
|
189 |
|
|
assign adder_out = rs1_data + rs2_data + cin;
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
endmodule // zzadd34c
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
197 |
|
|
|
198 |
|
|
module zzadd32 ( rs1_data, rs2_data, cin, adder_out, cout );
|
199 |
|
|
|
200 |
|
|
input [31:0] rs1_data; // 1st input operand
|
201 |
|
|
input [31:0] rs2_data; // 2nd input operand
|
202 |
|
|
input cin; // carry in
|
203 |
|
|
|
204 |
|
|
output [31:0] adder_out; // result of adder
|
205 |
|
|
output cout; // carry out
|
206 |
|
|
|
207 |
|
|
assign {cout, adder_out} = rs1_data + rs2_data + cin;
|
208 |
|
|
|
209 |
|
|
endmodule // zzadd32
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
214 |
|
|
|
215 |
|
|
module zzadd18 ( rs1_data, rs2_data, cin, adder_out, cout );
|
216 |
|
|
|
217 |
|
|
input [17:0] rs1_data; // 1st input operand
|
218 |
|
|
input [17:0] rs2_data; // 2nd input operand
|
219 |
|
|
input cin; // carry in
|
220 |
|
|
|
221 |
|
|
output [17:0] adder_out; // result of adder
|
222 |
|
|
output cout; // carry out
|
223 |
|
|
|
224 |
|
|
assign {cout, adder_out} = rs1_data + rs2_data + cin;
|
225 |
|
|
|
226 |
|
|
endmodule // zzadd18
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
231 |
|
|
|
232 |
|
|
module zzadd8 ( rs1_data, rs2_data, cin, adder_out, cout );
|
233 |
|
|
|
234 |
|
|
input [7:0] rs1_data; // 1st input operand
|
235 |
|
|
input [7:0] rs2_data; // 2nd input operand
|
236 |
|
|
input cin; // carry in
|
237 |
|
|
|
238 |
|
|
output [7:0] adder_out; // result of add & decrement
|
239 |
|
|
output cout; // carry out
|
240 |
|
|
|
241 |
|
|
assign {cout, adder_out} = rs1_data + rs2_data + cin;
|
242 |
|
|
|
243 |
|
|
endmodule // zzadd8
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
248 |
|
|
// Special 4-operand 32b adder used in spu_shamd5
|
249 |
|
|
// Description: This block implements the 4-operand 32-bit adder for SPU
|
250 |
|
|
// It takes four 32-bit operands. It add them together and
|
251 |
|
|
// output the 32-bit results to adder_out. The overflow of
|
252 |
|
|
// 32th bit and higher will be ignored.
|
253 |
|
|
|
254 |
|
|
module zzadd32op4 ( rs1_data, rs2_data, rs3_data, rs4_data, adder_out );
|
255 |
|
|
|
256 |
|
|
input [31:0] rs1_data; // 1st input operand
|
257 |
|
|
input [31:0] rs2_data; // 2nd input operand
|
258 |
|
|
input [31:0] rs3_data; // 3rd input operand
|
259 |
|
|
input [31:0] rs4_data; // 4th input operand
|
260 |
|
|
|
261 |
|
|
output [31:0] adder_out; // result of add
|
262 |
|
|
|
263 |
|
|
assign adder_out = rs1_data + rs2_data + rs3_data + rs4_data;
|
264 |
|
|
|
265 |
|
|
endmodule // zzadd32op4
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
269 |
|
|
// Description: This block implements the adder for the sparc alu.
|
270 |
|
|
// It takes two operands and a carry bit. It adds them together
|
271 |
|
|
// and sends the output to adder_out. It outputs the overflow
|
272 |
|
|
// and carry condition codes for both 64 bit and 32 bit operations.
|
273 |
|
|
|
274 |
|
|
module zzadd64 ( rs1_data, rs2_data, cin, adder_out, cout32, cout64 );
|
275 |
|
|
|
276 |
|
|
input [63:0] rs1_data; // 1st input operand
|
277 |
|
|
input [63:0] rs2_data; // 2nd input operand
|
278 |
|
|
input cin; // carry in
|
279 |
|
|
|
280 |
|
|
output [63:0] adder_out; // result of adder
|
281 |
|
|
output cout32; // carry out from lower 32 bit add
|
282 |
|
|
output cout64; // carry out from 64 bit add
|
283 |
|
|
|
284 |
|
|
assign {cout32, adder_out[31:0]} = rs1_data[31:0] + rs2_data[31:0] + cin;
|
285 |
|
|
assign {cout64, adder_out[63:32]} = rs1_data[63:32] + rs2_data[63:32] + cout32;
|
286 |
|
|
|
287 |
|
|
endmodule // zzadd64
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
///////////////////////////////////////////////////////////////////////
|
292 |
|
|
/*
|
293 |
|
|
// Description: This is the ffu VIS adder. It can do either
|
294 |
|
|
// 2 16 bit adds or 1 32 bit add.
|
295 |
|
|
*/
|
296 |
|
|
|
297 |
|
|
module zzadd32v (/*AUTOARG*/
|
298 |
|
|
// Outputs
|
299 |
|
|
z,
|
300 |
|
|
// Inputs
|
301 |
|
|
a, b, cin, add32
|
302 |
|
|
) ;
|
303 |
|
|
input [31:0] a;
|
304 |
|
|
input [31:0] b;
|
305 |
|
|
input cin;
|
306 |
|
|
input add32;
|
307 |
|
|
|
308 |
|
|
output [31:0] z;
|
309 |
|
|
|
310 |
|
|
wire cout15; // carry out from lower 16 bit add
|
311 |
|
|
wire cin16; // carry in to the upper 16 bit add
|
312 |
|
|
wire cout31; // carry out from the upper 16 bit add
|
313 |
|
|
|
314 |
|
|
assign cin16 = (add32)? cout15: cin;
|
315 |
|
|
|
316 |
|
|
assign {cout15, z[15:0]} = a[15:0]+b[15:0]+ cin;
|
317 |
|
|
assign {cout31, z[31:16]} = a[31:16]+b[31:16]+ cin16;
|
318 |
|
|
|
319 |
|
|
endmodule // zzadd32v
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
325 |
|
|
// 64-bit incrementer
|
326 |
|
|
|
327 |
|
|
module zzinc64 ( in, out );
|
328 |
|
|
|
329 |
|
|
input [63:0] in;
|
330 |
|
|
|
331 |
|
|
output [63:0] out; // result of increment
|
332 |
|
|
|
333 |
|
|
assign out = in + 1'b1;
|
334 |
|
|
|
335 |
|
|
endmodule // zzinc64
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
339 |
|
|
// 48-bit incrementer
|
340 |
|
|
|
341 |
|
|
module zzinc48 ( in, out, overflow );
|
342 |
|
|
|
343 |
|
|
input [47:0] in;
|
344 |
|
|
|
345 |
|
|
output [47:0] out; // result of increment
|
346 |
|
|
output overflow; // overflow
|
347 |
|
|
|
348 |
|
|
assign out = in + 1'b1;
|
349 |
|
|
assign overflow = ~in[47] & out[47];
|
350 |
|
|
|
351 |
|
|
endmodule // zzinc48
|
352 |
|
|
|
353 |
|
|
|
354 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
355 |
|
|
// 32-bit incrementer
|
356 |
|
|
|
357 |
|
|
module zzinc32 ( in, out );
|
358 |
|
|
|
359 |
|
|
input [31:0] in;
|
360 |
|
|
|
361 |
|
|
output [31:0] out; // result of increment
|
362 |
|
|
|
363 |
|
|
assign out = in + 1'b1;
|
364 |
|
|
|
365 |
|
|
endmodule // zzinc32
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
369 |
|
|
|
370 |
|
|
module zzecc_exu_chkecc2 ( q,ce, ue, ne, d, p, vld );
|
371 |
|
|
input [63:0] d;
|
372 |
|
|
input [7:0] p;
|
373 |
|
|
input vld;
|
374 |
|
|
output [6:0] q;
|
375 |
|
|
output ce,
|
376 |
|
|
ue,
|
377 |
|
|
ne;
|
378 |
|
|
|
379 |
|
|
wire parity;
|
380 |
|
|
|
381 |
|
|
assign ce = vld & parity;
|
382 |
|
|
|
383 |
|
|
assign ue = vld & ~parity & (q[6] | q[5] | q[4] | q[3] | q[2] | q[1] | q[0]);
|
384 |
|
|
|
385 |
|
|
assign ne = ~vld | ~(parity | q[6] | q[5] | q[4] | q[3] | q[2] | q[1] | q[0]);
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
assign q[0] = d[0] ^ d[1] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[10]
|
389 |
|
|
^ d[11] ^ d[13] ^ d[15] ^ d[17] ^ d[19] ^ d[21] ^ d[23]
|
390 |
|
|
^ d[25] ^ d[26] ^ d[28] ^ d[30] ^ d[32] ^ d[34] ^ d[36]
|
391 |
|
|
^ d[38] ^ d[40] ^ d[42] ^ d[44] ^ d[46] ^ d[48] ^ d[50]
|
392 |
|
|
^ d[52] ^ d[54] ^ d[56] ^ d[57] ^ d[59] ^ d[61] ^ d[63]
|
393 |
|
|
^ p[0] ;
|
394 |
|
|
|
395 |
|
|
assign q[1] = d[0] ^ d[2] ^ d[3] ^ d[5] ^ d[6] ^ d[9] ^ d[10]
|
396 |
|
|
^ d[12] ^ d[13] ^ d[16] ^ d[17] ^ d[20] ^ d[21] ^ d[24]
|
397 |
|
|
^ d[25] ^ d[27] ^ d[28] ^ d[31] ^ d[32] ^ d[35] ^ d[36]
|
398 |
|
|
^ d[39] ^ d[40] ^ d[43] ^ d[44] ^ d[47] ^ d[48] ^ d[51]
|
399 |
|
|
^ d[52] ^ d[55] ^ d[56] ^ d[58] ^ d[59] ^ d[62] ^ d[63]
|
400 |
|
|
^ p[1] ;
|
401 |
|
|
|
402 |
|
|
assign q[2] = d[1] ^ d[2] ^ d[3] ^ d[7] ^ d[8] ^ d[9] ^ d[10]
|
403 |
|
|
^ d[14] ^ d[15] ^ d[16] ^ d[17] ^ d[22] ^ d[23] ^ d[24]
|
404 |
|
|
^ d[25] ^ d[29] ^ d[30] ^ d[31] ^ d[32] ^ d[37] ^ d[38]
|
405 |
|
|
^ d[39] ^ d[40] ^ d[45] ^ d[46] ^ d[47] ^ d[48] ^ d[53]
|
406 |
|
|
^ d[54] ^ d[55] ^ d[56] ^ d[60] ^ d[61] ^ d[62] ^ d[63]
|
407 |
|
|
^ p[2] ;
|
408 |
|
|
|
409 |
|
|
assign q[3] = d[4] ^ d[5] ^ d[6] ^ d[7] ^ d[8] ^ d[9] ^ d[10]
|
410 |
|
|
^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23] ^ d[24]
|
411 |
|
|
^ d[25] ^ d[33] ^ d[34] ^ d[35] ^ d[36] ^ d[37] ^ d[38]
|
412 |
|
|
^ d[39] ^ d[40] ^ d[49] ^ d[50] ^ d[51] ^ d[52] ^ d[53]
|
413 |
|
|
^ d[54] ^ d[55] ^ d[56] ^ p[3] ;
|
414 |
|
|
|
415 |
|
|
assign q[4] = d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15] ^ d[16] ^ d[17]
|
416 |
|
|
^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23] ^ d[24]
|
417 |
|
|
^ d[25] ^ d[41] ^ d[42] ^ d[43] ^ d[44] ^ d[45] ^ d[46]
|
418 |
|
|
^ d[47] ^ d[48] ^ d[49] ^ d[50] ^ d[51] ^ d[52] ^ d[53]
|
419 |
|
|
^ d[54] ^ d[55] ^ d[56] ^ p[4] ;
|
420 |
|
|
|
421 |
|
|
assign q[5] = d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31] ^ d[32]
|
422 |
|
|
^ d[33] ^ d[34] ^ d[35] ^ d[36] ^ d[37] ^ d[38] ^ d[39]
|
423 |
|
|
^ d[40] ^ d[41] ^ d[42] ^ d[43] ^ d[44] ^ d[45] ^ d[46]
|
424 |
|
|
^ d[47] ^ d[48] ^ d[49] ^ d[50] ^ d[51] ^ d[52] ^ d[53]
|
425 |
|
|
^ d[54] ^ d[55] ^ d[56] ^ p[5] ;
|
426 |
|
|
|
427 |
|
|
assign q[6] = d[57] ^ d[58] ^ d[59] ^ d[60] ^ d[61] ^ d[62] ^ d[63] ^ p[6] ;
|
428 |
|
|
|
429 |
|
|
assign parity = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
430 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
431 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
432 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31]
|
433 |
|
|
^ d[32] ^ d[33] ^ d[34] ^ d[35] ^ d[36] ^ d[37] ^ d[38] ^ d[39]
|
434 |
|
|
^ d[40] ^ d[41] ^ d[42] ^ d[43] ^ d[44] ^ d[45] ^ d[46] ^ d[47]
|
435 |
|
|
^ d[48] ^ d[49] ^ d[50] ^ d[51] ^ d[52] ^ d[53] ^ d[54] ^ d[55]
|
436 |
|
|
^ d[56] ^ d[57] ^ d[58] ^ d[59] ^ d[60] ^ d[61] ^ d[62] ^ d[63]
|
437 |
|
|
^ p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4] ^ p[5] ^ p[6] ^ p[7];
|
438 |
|
|
|
439 |
|
|
endmodule // zzecc_exu_chkecc2
|
440 |
|
|
|
441 |
|
|
|
442 |
|
|
|
443 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
444 |
|
|
|
445 |
|
|
module zzecc_sctag_24b_gen ( din, dout, parity ) ;
|
446 |
|
|
|
447 |
|
|
// Input Ports
|
448 |
|
|
input [23:0] din ;
|
449 |
|
|
|
450 |
|
|
// Output Ports
|
451 |
|
|
output [23:0] dout ;
|
452 |
|
|
output [5:0] parity ;
|
453 |
|
|
|
454 |
|
|
wire [23:0] dout ;
|
455 |
|
|
wire [5:0] parity ;
|
456 |
|
|
|
457 |
|
|
// Local Reg and Wires
|
458 |
|
|
wire p1 ;
|
459 |
|
|
wire p2 ;
|
460 |
|
|
wire p4 ;
|
461 |
|
|
wire p8 ;
|
462 |
|
|
wire p16 ;
|
463 |
|
|
wire p30 ;
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
467 |
|
|
// |1 |2 |3 |4 |5 |6 |7 |8 |9 |10|11|12|13|14|15 |16 |17 |18 |19 |20 |21 |22 |23 |24 |25 |26 |27 |28 |29 |30 |
|
468 |
|
|
// |P1|P2|D0|P4|D1|D2|D3|P8|D4|D5|D6|D7|D8|D9|D10|P16|D11|D12|D13|D14|D15|D16|D17|D18|D19|D20|D21|D22|D23|P30|
|
469 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
470 |
|
|
//P1 | | |* | |* | |* | |* | |* | |* | | * | | * | | * | | * | | * | | * | | * | | * | |
|
471 |
|
|
//P2 | | |* | | |* |* | | |* |* | | |* | * | | | * | * | | | * | * | | | * | * | | | |
|
472 |
|
|
//P4 | | | | |* |* |* | | | | |* |* |* | * | | | | | * | * | * | * | | | | | * | * | |
|
473 |
|
|
//P8 | | | | | | | | |* |* |* |* |* |* | * | | | | | | | | | * | * | * | * | * | * | |
|
474 |
|
|
//P16 | | | | | | | | | | | | | | | | | * | * | * | * | * | * | * | * | * | * | * | * | * | |
|
475 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
476 |
|
|
//p30 | | |* | |* |* | | |* |* | |* | | | * | | * | * | | * | | | * | * | | | * | | * | |
|
477 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
478 |
|
|
|
479 |
|
|
|
480 |
|
|
assign p1 = din[0] ^ din[1] ^ din[3] ^ din[4] ^ din[6] ^ din[8] ^
|
481 |
|
|
din[10] ^ din[11] ^ din[13] ^ din[15] ^ din[17] ^ din[19] ^
|
482 |
|
|
din[21] ^ din[23] ;
|
483 |
|
|
|
484 |
|
|
assign p2 = din[0] ^ din[2] ^ din[3] ^ din[5] ^ din[6] ^ din[9] ^
|
485 |
|
|
din[10] ^ din[12] ^ din[13] ^ din[16] ^ din[17] ^ din[20] ^
|
486 |
|
|
din[21] ;
|
487 |
|
|
|
488 |
|
|
assign p4 = din[1] ^ din[2] ^ din[3] ^ din[7] ^ din[8] ^ din[9] ^
|
489 |
|
|
din[10] ^ din[14] ^ din[15] ^ din[16] ^ din[17] ^ din[22] ^
|
490 |
|
|
din[23] ;
|
491 |
|
|
|
492 |
|
|
assign p8 = din[4] ^ din[5] ^ din[6] ^ din[7] ^ din[8] ^ din[9] ^
|
493 |
|
|
din[10] ^ din[18] ^ din[19] ^ din[20] ^ din[21] ^ din[22] ^
|
494 |
|
|
din[23] ;
|
495 |
|
|
|
496 |
|
|
assign p16 = din[11] ^ din[12] ^ din[13] ^ din[14] ^ din[15] ^ din[16] ^
|
497 |
|
|
din[17] ^ din[18] ^ din[19] ^ din[20] ^ din[21] ^ din[22] ^
|
498 |
|
|
din[23] ;
|
499 |
|
|
|
500 |
|
|
assign p30 = din[0] ^ din[1] ^ din[2] ^ din[4] ^ din[5] ^
|
501 |
|
|
din[7] ^ din[10] ^ din[11] ^ din[12] ^ din[14] ^
|
502 |
|
|
din[17] ^ din[18] ^ din[21] ^ din[23] ;
|
503 |
|
|
|
504 |
|
|
assign dout = din ;
|
505 |
|
|
assign parity = {p30, p16, p8, p4, p2, p1} ;
|
506 |
|
|
|
507 |
|
|
endmodule
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
|
511 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
512 |
|
|
|
513 |
|
|
module zzecc_sctag_30b_cor ( din, parity, dout, corrected_bit ) ;
|
514 |
|
|
|
515 |
|
|
// Input Ports
|
516 |
|
|
input [23:0] din ;
|
517 |
|
|
input [4:0] parity ;
|
518 |
|
|
|
519 |
|
|
// Output Ports
|
520 |
|
|
output [23:0] dout ;
|
521 |
|
|
output [4:0] corrected_bit ;
|
522 |
|
|
|
523 |
|
|
wire [23:0] dout ;
|
524 |
|
|
wire [4:0] corrected_bit ;
|
525 |
|
|
|
526 |
|
|
// Local Reg and Wires
|
527 |
|
|
wire p1 ;
|
528 |
|
|
wire p2 ;
|
529 |
|
|
wire p4 ;
|
530 |
|
|
wire p8 ;
|
531 |
|
|
wire p16 ;
|
532 |
|
|
wire [23:0] error_bit ;
|
533 |
|
|
|
534 |
|
|
|
535 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
536 |
|
|
// |1 |2 |3 |4 |5 |6 |7 |8 |9 |10|11|12|13|14|15 |16 |17 |18 |19 |20 |21 |22 |23 |24 |25 |26 |27 |28 |29 |30 |
|
537 |
|
|
// |P1|P2|D0|P4|D1|D2|D3|P8|D4|D5|D6|D7|D8|D9|D10|P16|D11|D12|D13|D14|D15|D16|D17|D18|D19|D20|D21|D22|D23|P30|
|
538 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
539 |
|
|
//P1 |* | |* | |* | |* | |* | |* | |* | | * | | * | | * | | * | | * | | * | | * | | * | |
|
540 |
|
|
//P2 | |* |* | | |* |* | | |* |* | | |* | * | | | * | * | | | * | * | | | * | * | | | |
|
541 |
|
|
//P4 | | | |* |* |* |* | | | | |* |* |* | * | | | | | * | * | * | * | | | | | * | * | |
|
542 |
|
|
//P8 | | | | | | | |* |* |* |* |* |* |* | * | | | | | | | | | * | * | * | * | * | * | |
|
543 |
|
|
//P16 | | | | | | | | | | | | | | | | * | * | * | * | * | * | * | * | * | * | * | * | * | * | |
|
544 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
545 |
|
|
//p30 |* |* |* |* |* |* |* |* |* |* |* |* |* |* | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * |
|
546 |
|
|
//----|--|--|--|--|--|--|--|--|--|--|--|--|--|--|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
assign p1 = parity[0] ^
|
550 |
|
|
din[0] ^ din[1] ^ din[3] ^ din[4] ^ din[6] ^ din[8] ^
|
551 |
|
|
din[10] ^ din[11] ^ din[13] ^ din[15] ^ din[17] ^ din[19] ^
|
552 |
|
|
din[21] ^ din[23] ;
|
553 |
|
|
|
554 |
|
|
assign p2 = parity[1] ^
|
555 |
|
|
din[0] ^ din[2] ^ din[3] ^ din[5] ^ din[6] ^ din[9] ^
|
556 |
|
|
din[10] ^ din[12] ^ din[13] ^ din[16] ^ din[17] ^ din[20] ^
|
557 |
|
|
din[21] ;
|
558 |
|
|
|
559 |
|
|
assign p4 = parity[2] ^
|
560 |
|
|
din[1] ^ din[2] ^ din[3] ^ din[7] ^ din[8] ^ din[9] ^
|
561 |
|
|
din[10] ^ din[14] ^ din[15] ^ din[16] ^ din[17] ^ din[22] ^
|
562 |
|
|
din[23] ;
|
563 |
|
|
|
564 |
|
|
assign p8 = parity[3] ^
|
565 |
|
|
din[4] ^ din[5] ^ din[6] ^ din[7] ^ din[8] ^ din[9] ^
|
566 |
|
|
din[10] ^ din[18] ^ din[19] ^ din[20] ^ din[21] ^ din[22] ^
|
567 |
|
|
din[23] ;
|
568 |
|
|
|
569 |
|
|
assign p16 = parity[4] ^
|
570 |
|
|
din[11] ^ din[12] ^ din[13] ^ din[14] ^ din[15] ^ din[16] ^
|
571 |
|
|
din[17] ^ din[18] ^ din[19] ^ din[20] ^ din[21] ^ din[22] ^
|
572 |
|
|
din[23] ;
|
573 |
|
|
|
574 |
|
|
assign error_bit[0] = !p16 & !p8 & !p4 & p2 & p1 ; // 3
|
575 |
|
|
assign error_bit[1] = !p16 & !p8 & p4 & !p2 & p1 ; // 5
|
576 |
|
|
assign error_bit[2] = !p16 & !p8 & p4 & p2 & !p1 ; // 6
|
577 |
|
|
assign error_bit[3] = !p16 & !p8 & p4 & p2 & p1 ; // 7
|
578 |
|
|
assign error_bit[4] = !p16 & p8 & !p4 & !p2 & p1 ; // 9
|
579 |
|
|
assign error_bit[5] = !p16 & p8 & !p4 & p2 & !p1 ; // 10
|
580 |
|
|
assign error_bit[6] = !p16 & p8 & !p4 & p2 & p1 ; // 11
|
581 |
|
|
assign error_bit[7] = !p16 & p8 & p4 & !p2 & !p1 ; // 12
|
582 |
|
|
assign error_bit[8] = !p16 & p8 & p4 & !p2 & p1 ; // 13
|
583 |
|
|
assign error_bit[9] = !p16 & p8 & p4 & p2 & !p1 ; // 14
|
584 |
|
|
assign error_bit[10] = !p16 & p8 & p4 & p2 & p1 ; // 15
|
585 |
|
|
assign error_bit[11] = p16 & !p8 & !p4 & !p2 & p1 ; // 17
|
586 |
|
|
assign error_bit[12] = p16 & !p8 & !p4 & p2 & !p1 ; // 18
|
587 |
|
|
assign error_bit[13] = p16 & !p8 & !p4 & p2 & p1 ; // 19
|
588 |
|
|
assign error_bit[14] = p16 & !p8 & p4 & !p2 & !p1 ; // 20
|
589 |
|
|
assign error_bit[15] = p16 & !p8 & p4 & !p2 & p1 ; // 21
|
590 |
|
|
assign error_bit[16] = p16 & !p8 & p4 & p2 & !p1 ; // 22
|
591 |
|
|
assign error_bit[17] = p16 & !p8 & p4 & p2 & p1 ; // 23
|
592 |
|
|
assign error_bit[18] = p16 & p8 & !p4 & !p2 & !p1 ; // 24
|
593 |
|
|
assign error_bit[19] = p16 & p8 & !p4 & !p2 & p1 ; // 25
|
594 |
|
|
assign error_bit[20] = p16 & p8 & !p4 & p2 & !p1 ; // 26
|
595 |
|
|
assign error_bit[21] = p16 & p8 & !p4 & p2 & p1 ; // 27
|
596 |
|
|
assign error_bit[22] = p16 & p8 & p4 & !p2 & !p1 ; // 28
|
597 |
|
|
assign error_bit[23] = p16 & p8 & p4 & !p2 & p1 ; // 29
|
598 |
|
|
|
599 |
|
|
assign dout = din ^ error_bit ;
|
600 |
|
|
assign corrected_bit = {p16, p8, p4, p2, p1} ;
|
601 |
|
|
|
602 |
|
|
endmodule
|
603 |
|
|
|
604 |
|
|
|
605 |
|
|
|
606 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
607 |
|
|
//Module Name: zzecc_sctag_ecc39
|
608 |
|
|
//Function: Error Detection and Correction
|
609 |
|
|
//
|
610 |
|
|
//
|
611 |
|
|
|
612 |
|
|
module zzecc_sctag_ecc39 ( dout, cflag, pflag, parity, din);
|
613 |
|
|
|
614 |
|
|
//Output: 32bit corrected data
|
615 |
|
|
output[31:0] dout;
|
616 |
|
|
output [5:0] cflag;
|
617 |
|
|
output pflag;
|
618 |
|
|
|
619 |
|
|
//Input: 32bit data din
|
620 |
|
|
input [31:0] din;
|
621 |
|
|
input [6:0] parity;
|
622 |
|
|
|
623 |
|
|
wire c0,c1,c2,c3,c4,c5;
|
624 |
|
|
wire [31:0] err_bit_pos;
|
625 |
|
|
|
626 |
|
|
//refer to the comments in parity_gen_32b.v for the position description
|
627 |
|
|
|
628 |
|
|
assign c0= parity[0]^(din[0]^din[1])^(din[3]^din[4])^(din[6]^din[8])
|
629 |
|
|
^(din[10]^din[11])^(din[13]^din[15])^(din[17]^din[19])
|
630 |
|
|
^(din[21]^din[23])^(din[25]^din[26])^(din[28]^din[30]);
|
631 |
|
|
|
632 |
|
|
assign c1= parity[1]^(din[0]^din[2])^(din[3]^din[5])^(din[6]^din[9])
|
633 |
|
|
^(din[10]^din[12])^(din[13]^din[16])^(din[17]^din[20])
|
634 |
|
|
^(din[21]^din[24])^(din[25]^din[27])^(din[28]^din[31]);
|
635 |
|
|
|
636 |
|
|
assign c2= parity[2]^(din[1]^din[2])^(din[3]^din[7])^(din[8]^din[9])
|
637 |
|
|
^(din[10]^din[14])^(din[15]^din[16])^(din[17]^din[22])
|
638 |
|
|
^(din[23]^din[24])^(din[25]^din[29])^(din[30]^din[31]);
|
639 |
|
|
|
640 |
|
|
assign c3= parity[3]^(din[4]^din[5])^(din[6]^din[7])^(din[8]^din[9])
|
641 |
|
|
^(din[10]^din[18])^(din[19]^din[20])^(din[21]^din[22])
|
642 |
|
|
^(din[23]^din[24])^din[25];
|
643 |
|
|
|
644 |
|
|
assign c4= parity[4]^(din[11]^din[12])^(din[13]^din[14])^
|
645 |
|
|
(din[15]^din[16])^(din[17]^din[18])^(din[19]^din[20])^
|
646 |
|
|
(din[21]^din[22])^(din[23]^din[24])^din[25];
|
647 |
|
|
|
648 |
|
|
assign c5= parity[5]^(din[26]^din[27])^(din[28]^din[29])^
|
649 |
|
|
(din[30]^din[31]);
|
650 |
|
|
|
651 |
|
|
//generate total parity flag
|
652 |
|
|
assign pflag= c0 ^
|
653 |
|
|
(( (((parity[1]^parity[2])^(parity[3]^parity[4])) ^
|
654 |
|
|
((parity[5]^parity[6])^(din[2]^din[5]))) ^
|
655 |
|
|
(((din[7]^din[9])^(din[12]^din[14])) ^
|
656 |
|
|
((din[16]^din[18])^(din[20]^din[22]))) ) ^
|
657 |
|
|
((din[24]^din[27])^(din[29]^din[31])) );
|
658 |
|
|
|
659 |
|
|
assign cflag= {c5,c4,c3,c2,c1,c0};
|
660 |
|
|
|
661 |
|
|
//6 to 32 decoder
|
662 |
|
|
assign err_bit_pos[0] = (c0)&(c1)&(~c2)&(~c3)&(~c4)&(~c5);
|
663 |
|
|
assign err_bit_pos[1] = (c0)&(~c1)&(c2)&(~c3)&(~c4)&(~c5);
|
664 |
|
|
assign err_bit_pos[2] = (~c0)&(c1)&(c2)&(~c3)&(~c4)&(~c5);
|
665 |
|
|
assign err_bit_pos[3] = (c0)&(c1)&(c2)&(~c3)&(~c4)&(~c5);
|
666 |
|
|
assign err_bit_pos[4] = (c0)&(~c1)&(~c2)&(c3)&(~c4)&(~c5);
|
667 |
|
|
assign err_bit_pos[5] = (~c0)&(c1)&(~c2)&(c3)&(~c4)&(~c5);
|
668 |
|
|
assign err_bit_pos[6] = (c0)&(c1)&(~c2)&(c3)&(~c4)&(~c5);
|
669 |
|
|
assign err_bit_pos[7] = (~c0)&(~c1)&(c2)&(c3)&(~c4)&(~c5);
|
670 |
|
|
assign err_bit_pos[8] = (c0)&(~c1)&(c2)&(c3)&(~c4)&(~c5);
|
671 |
|
|
assign err_bit_pos[9] = (~c0)&(c1)&(c2)&(c3)&(~c4)&(~c5);
|
672 |
|
|
assign err_bit_pos[10] = (c0)&(c1)&(c2)&(c3)&(~c4)&(~c5);
|
673 |
|
|
assign err_bit_pos[11] = (c0)&(~c1)&(~c2)&(~c3)&(c4)&(~c5);
|
674 |
|
|
assign err_bit_pos[12] = (~c0)&(c1)&(~c2)&(~c3)&(c4)&(~c5);
|
675 |
|
|
assign err_bit_pos[13] = (c0)&(c1)&(~c2)&(~c3)&(c4)&(~c5);
|
676 |
|
|
assign err_bit_pos[14] = (~c0)&(~c1)&(c2)&(~c3)&(c4)&(~c5);
|
677 |
|
|
assign err_bit_pos[15] = (c0)&(~c1)&(c2)&(~c3)&(c4)&(~c5);
|
678 |
|
|
assign err_bit_pos[16] = (~c0)&(c1)&(c2)&(~c3)&(c4)&(~c5);
|
679 |
|
|
assign err_bit_pos[17] = (c0)&(c1)&(c2)&(~c3)&(c4)&(~c5);
|
680 |
|
|
assign err_bit_pos[18] = (~c0)&(~c1)&(~c2)&(c3)&(c4)&(~c5);
|
681 |
|
|
assign err_bit_pos[19] = (c0)&(~c1)&(~c2)&(c3)&(c4)&(~c5);
|
682 |
|
|
assign err_bit_pos[20] = (~c0)&(c1)&(~c2)&(c3)&(c4)&(~c5);
|
683 |
|
|
assign err_bit_pos[21] = (c0)&(c1)&(~c2)&(c3)&(c4)&(~c5);
|
684 |
|
|
assign err_bit_pos[22] = (~c0)&(~c1)&(c2)&(c3)&(c4)&(~c5);
|
685 |
|
|
assign err_bit_pos[23] = (c0)&(~c1)&(c2)&(c3)&(c4)&(~c5);
|
686 |
|
|
assign err_bit_pos[24] = (~c0)&(c1)&(c2)&(c3)&(c4)&(~c5);
|
687 |
|
|
assign err_bit_pos[25] = (c0)&(c1)&(c2)&(c3)&(c4)&(~c5);
|
688 |
|
|
assign err_bit_pos[26] = (c0)&(~c1)&(~c2)&(~c3)&(~c4)&(c5);
|
689 |
|
|
assign err_bit_pos[27] = (~c0)&(c1)&(~c2)&(~c3)&(~c4)&(c5);
|
690 |
|
|
assign err_bit_pos[28] = (c0)&(c1)&(~c2)&(~c3)&(~c4)&(c5);
|
691 |
|
|
assign err_bit_pos[29] = (~c0)&(~c1)&(c2)&(~c3)&(~c4)&(c5);
|
692 |
|
|
assign err_bit_pos[30] = (c0)&(~c1)&(c2)&(~c3)&(~c4)&(c5);
|
693 |
|
|
assign err_bit_pos[31] = (~c0)&(c1)&(c2)&(~c3)&(~c4)&(c5);
|
694 |
|
|
|
695 |
|
|
//correct the error bit, it can only correct one error bit.
|
696 |
|
|
|
697 |
|
|
assign dout = din ^ err_bit_pos;
|
698 |
|
|
|
699 |
|
|
endmodule // zzecc_sctag_ecc39
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
703 |
|
|
//Module Name: zzecc_sctag_pgen_32b
|
704 |
|
|
//Function: Generate 7 parity bits for 32bits input data
|
705 |
|
|
//
|
706 |
|
|
|
707 |
|
|
module zzecc_sctag_pgen_32b ( dout, parity, din);
|
708 |
|
|
|
709 |
|
|
//Output: 32bit dout and 7bit parity bit
|
710 |
|
|
output[31:0] dout;
|
711 |
|
|
output [6:0] parity;
|
712 |
|
|
|
713 |
|
|
//Input: 32bit data din
|
714 |
|
|
input [31:0] din;
|
715 |
|
|
|
716 |
|
|
//input data passing through this module
|
717 |
|
|
assign dout = din ;
|
718 |
|
|
|
719 |
|
|
//generate parity bits based on the hamming codes
|
720 |
|
|
//the method to generate parity bit is shown as follows
|
721 |
|
|
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
722 |
|
|
//P1 P2 d0 P4 d1 d2 d3 P8 d4 d5 d6 d7 d8 d9 d10 P16 d11 d12 d13
|
723 |
|
|
//
|
724 |
|
|
// 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
725 |
|
|
//d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 P32 d26 d27 d28
|
726 |
|
|
//
|
727 |
|
|
// 36 37 38
|
728 |
|
|
//d29 d30 d31
|
729 |
|
|
//For binary numbers B1-B2-B3-B4-B5-B6:
|
730 |
|
|
//B1=1 for (1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,...)
|
731 |
|
|
//B2=1 for (2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39...)
|
732 |
|
|
//B3=1 for (4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39....)
|
733 |
|
|
//B4=1 for (8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,....)
|
734 |
|
|
//B5=1 for (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,...)
|
735 |
|
|
//B6=1 for (32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49...)
|
736 |
|
|
//Parity bit P1,P2,P4,P8,P16,P32 can be generated from the above group of
|
737 |
|
|
//bits B1=1,B2=1,B3=1,B4=1,B5=1,B6=1 respectively.
|
738 |
|
|
|
739 |
|
|
//use parity[5:0] to stand for P1,P2,P4,P8,P16,P32
|
740 |
|
|
assign parity[0] = (din[0]^din[1])^(din[3]^din[4])^(din[6]^din[8])
|
741 |
|
|
^(din[10]^din[11])^(din[13]^din[15])^(din[17]^din[19])
|
742 |
|
|
^(din[21]^din[23])^(din[25]^din[26])^(din[28]^din[30]);
|
743 |
|
|
//
|
744 |
|
|
assign parity[1] = (din[0]^din[2])^(din[3]^din[5])^(din[6]^din[9])
|
745 |
|
|
^(din[10]^din[12])^(din[13]^din[16])^(din[17]^din[20])
|
746 |
|
|
^(din[21]^din[24])^(din[25]^din[27])^(din[28]^din[31]);
|
747 |
|
|
//
|
748 |
|
|
assign parity[2] = (din[1]^din[2])^(din[3]^din[7])^(din[8]^din[9])
|
749 |
|
|
^(din[10]^din[14])^(din[15]^din[16])^(din[17]^din[22])
|
750 |
|
|
^(din[23]^din[24])^(din[25]^din[29])^(din[30]^din[31]);
|
751 |
|
|
//
|
752 |
|
|
assign parity[3] = (din[4]^din[5])^(din[6]^din[7])^(din[8]^din[9])
|
753 |
|
|
^(din[10]^din[18])^(din[19]^din[20])^(din[21]^din[22])
|
754 |
|
|
^(din[23]^din[24])^din[25];
|
755 |
|
|
//
|
756 |
|
|
assign parity[4] = (din[11]^din[12])^(din[13]^din[14])^(din[15]^din[16])
|
757 |
|
|
^(din[17]^din[18])^(din[19]^din[20])^(din[21]^din[22])
|
758 |
|
|
^(din[23]^din[24])^din[25];
|
759 |
|
|
//
|
760 |
|
|
assign parity[5] = (din[26]^din[27])^(din[28]^din[29])^(din[30]^din[31]);
|
761 |
|
|
|
762 |
|
|
//the last parity bit is the xor of all 38bits
|
763 |
|
|
//assign parity[6] = (^din)^(^parity[5:0]);
|
764 |
|
|
//it can be further simplified as:
|
765 |
|
|
//din= d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15
|
766 |
|
|
//p0 = x x x x x x x x x x
|
767 |
|
|
//p1 = x x x x x x x x x
|
768 |
|
|
//p2 = x x x x x x x x x
|
769 |
|
|
//p3 = x x x x x x x
|
770 |
|
|
//p4 = x x x x x
|
771 |
|
|
//p5 =
|
772 |
|
|
//-------------------------------------------------------------------
|
773 |
|
|
//Total 3 3 3 4 3 3 4 3 4 4 5 3 3 4 3 4
|
774 |
|
|
//
|
775 |
|
|
//din=d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31
|
776 |
|
|
//p0= x x x x x x x x
|
777 |
|
|
//p1= x x x x x x x x x
|
778 |
|
|
//p2= x x x x x x x x x
|
779 |
|
|
//p3= x x x x x x x x
|
780 |
|
|
//p4= x x x x x x x x x x
|
781 |
|
|
//p5= x x x x x x
|
782 |
|
|
//-------------------------------------------------------------------
|
783 |
|
|
//total 4 5 3 4 4 5 4 5 5 6 3 3 4 3 4 4
|
784 |
|
|
|
785 |
|
|
//so total=even number, the corresponding bit will not show up in the
|
786 |
|
|
//final xor tree.
|
787 |
|
|
assign parity[6] = din[0] ^ din[1] ^ din[2] ^ din[4] ^ din[5] ^ din[7]
|
788 |
|
|
^ din[10] ^ din[11] ^ din[12] ^ din[14] ^ din[17]
|
789 |
|
|
^ din[18] ^ din[21] ^ din[23] ^ din[24] ^ din[26]
|
790 |
|
|
^ din[27] ^ din[29];
|
791 |
|
|
|
792 |
|
|
endmodule // zzecc_sctag_pgen_32b
|
793 |
|
|
|
794 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
795 |
|
|
// 34 bit parity tree
|
796 |
|
|
|
797 |
|
|
module zzpar34 ( z, d );
|
798 |
|
|
input [33:0] d;
|
799 |
|
|
output z;
|
800 |
|
|
|
801 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
802 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
803 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
804 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31]
|
805 |
|
|
^ d[32] ^ d[33];
|
806 |
|
|
|
807 |
|
|
endmodule // zzpar34
|
808 |
|
|
|
809 |
|
|
|
810 |
|
|
|
811 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
812 |
|
|
// 32 bit parity tree
|
813 |
|
|
|
814 |
|
|
module zzpar32 ( z, d );
|
815 |
|
|
input [31:0] d;
|
816 |
|
|
output z;
|
817 |
|
|
|
818 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
819 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
820 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
821 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31];
|
822 |
|
|
|
823 |
|
|
endmodule // zzpar32
|
824 |
|
|
|
825 |
|
|
|
826 |
|
|
|
827 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
828 |
|
|
// 28 bit parity tree
|
829 |
|
|
|
830 |
|
|
module zzpar28 ( z, d );
|
831 |
|
|
input [27:0] d;
|
832 |
|
|
output z;
|
833 |
|
|
|
834 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
835 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
836 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
837 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27];
|
838 |
|
|
|
839 |
|
|
endmodule // zzpar28
|
840 |
|
|
|
841 |
|
|
|
842 |
|
|
|
843 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
844 |
|
|
// 16 bit parity tree
|
845 |
|
|
|
846 |
|
|
module zzpar16 ( z, d );
|
847 |
|
|
input [15:0] d;
|
848 |
|
|
output z;
|
849 |
|
|
|
850 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
851 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15];
|
852 |
|
|
|
853 |
|
|
endmodule // zzpar16
|
854 |
|
|
|
855 |
|
|
|
856 |
|
|
|
857 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
858 |
|
|
// 8 bit parity tree
|
859 |
|
|
|
860 |
|
|
module zzpar8 ( z, d );
|
861 |
|
|
input [7:0] d;
|
862 |
|
|
output z;
|
863 |
|
|
|
864 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7];
|
865 |
|
|
|
866 |
|
|
endmodule // zzpar8
|
867 |
|
|
|
868 |
|
|
|
869 |
|
|
|
870 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
871 |
|
|
// 64 -> 6 priority encoder
|
872 |
|
|
// Bit 63 has the highest priority
|
873 |
|
|
|
874 |
|
|
module zzpenc64 (/*AUTOARG*/
|
875 |
|
|
// Outputs
|
876 |
|
|
z,
|
877 |
|
|
// Inputs
|
878 |
|
|
a
|
879 |
|
|
);
|
880 |
|
|
|
881 |
|
|
input [63:0] a;
|
882 |
|
|
output [5:0] z;
|
883 |
|
|
|
884 |
|
|
integer i;
|
885 |
|
|
reg [5:0] z;
|
886 |
|
|
|
887 |
|
|
always @ (a)
|
888 |
|
|
begin
|
889 |
|
|
z = 6'b0;
|
890 |
|
|
for (i=0;i<64;i=i+1)
|
891 |
|
|
if (a[i])
|
892 |
|
|
z = i;
|
893 |
|
|
end
|
894 |
|
|
|
895 |
|
|
endmodule // zzpenc64
|
896 |
|
|
|
897 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
898 |
|
|
// 4-bit 60x buffers
|
899 |
|
|
|
900 |
|
|
module zzbufh_60x4 (/*AUTOARG*/
|
901 |
|
|
// Outputs
|
902 |
|
|
z,
|
903 |
|
|
// Inputs
|
904 |
|
|
a
|
905 |
|
|
);
|
906 |
|
|
|
907 |
|
|
input [3:0] a;
|
908 |
|
|
output [3:0] z;
|
909 |
|
|
|
910 |
|
|
assign z = a;
|
911 |
|
|
|
912 |
|
|
endmodule //zzbufh_60x4
|
913 |
|
|
|
914 |
|
|
// LVT modules added below
|
915 |
|
|
|
916 |
|
|
module zzadd64_lv ( rs1_data, rs2_data, cin, adder_out, cout32, cout64 );
|
917 |
|
|
|
918 |
|
|
input [63:0] rs1_data; // 1st input operand
|
919 |
|
|
input [63:0] rs2_data; // 2nd input operand
|
920 |
|
|
input cin; // carry in
|
921 |
|
|
|
922 |
|
|
output [63:0] adder_out; // result of adder
|
923 |
|
|
output cout32; // carry out from lower 32 bit add
|
924 |
|
|
output cout64; // carry out from 64 bit add
|
925 |
|
|
|
926 |
|
|
assign {cout32, adder_out[31:0]} = rs1_data[31:0] + rs2_data[31:0] + cin;
|
927 |
|
|
assign {cout64, adder_out[63:32]} = rs1_data[63:32] + rs2_data[63:32] + cout32;
|
928 |
|
|
|
929 |
|
|
endmodule // zzadd64_lv
|
930 |
|
|
|
931 |
|
|
module zzpar8_lv ( z, d );
|
932 |
|
|
input [7:0] d;
|
933 |
|
|
output z;
|
934 |
|
|
|
935 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7];
|
936 |
|
|
|
937 |
|
|
endmodule // zzpar8_lv
|
938 |
|
|
|
939 |
|
|
|
940 |
|
|
module zzpar32_lv ( z, d );
|
941 |
|
|
input [31:0] d;
|
942 |
|
|
output z;
|
943 |
|
|
|
944 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
945 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
946 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
947 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31];
|
948 |
|
|
|
949 |
|
|
endmodule // zzpar32_lv
|
950 |
|
|
|
951 |
|
|
|
952 |
|
|
|
953 |
|
|
module zznor64_32_lv ( znor64, znor32, a );
|
954 |
|
|
input [63:0] a;
|
955 |
|
|
output znor64;
|
956 |
|
|
output znor32;
|
957 |
|
|
|
958 |
|
|
assign znor32 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
959 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
960 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
961 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]);
|
962 |
|
|
|
963 |
|
|
assign znor64 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
964 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
965 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
966 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
967 |
|
|
| a[32] | a[33] | a[34] | a[35] | a[36] | a[37] | a[38] | a[39]
|
968 |
|
|
| a[40] | a[41] | a[42] | a[43] | a[44] | a[45] | a[46] | a[47]
|
969 |
|
|
| a[48] | a[49] | a[50] | a[51] | a[52] | a[53] | a[54] | a[55]
|
970 |
|
|
| a[56] | a[57] | a[58] | a[59] | a[60] | a[61] | a[62] | a[63]);
|
971 |
|
|
|
972 |
|
|
endmodule // zznor64_32_lv
|
973 |
|
|
|
974 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
975 |
|
|
// 64 -> 6 priority encoder
|
976 |
|
|
// Bit 63 has the highest priority
|
977 |
|
|
// LVT version
|
978 |
|
|
|
979 |
|
|
module zzpenc64_lv (/*AUTOARG*/
|
980 |
|
|
// Outputs
|
981 |
|
|
z,
|
982 |
|
|
// Inputs
|
983 |
|
|
a
|
984 |
|
|
);
|
985 |
|
|
|
986 |
|
|
input [63:0] a;
|
987 |
|
|
output [5:0] z;
|
988 |
|
|
|
989 |
|
|
integer i;
|
990 |
|
|
reg [5:0] z;
|
991 |
|
|
|
992 |
|
|
always @ (a)
|
993 |
|
|
begin
|
994 |
|
|
z = 6'b0;
|
995 |
|
|
for (i=0;i<64;i=i+1)
|
996 |
|
|
if (a[i])
|
997 |
|
|
z = i;
|
998 |
|
|
end
|
999 |
|
|
|
1000 |
|
|
endmodule // zzpenc64_lv
|
1001 |
|
|
|
1002 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
1003 |
|
|
// 36 bit or gate
|
1004 |
|
|
// LVT version
|
1005 |
|
|
|
1006 |
|
|
module zzor36_lv ( z, a );
|
1007 |
|
|
input [35:0] a;
|
1008 |
|
|
output z;
|
1009 |
|
|
|
1010 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
1011 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
1012 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
1013 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
1014 |
|
|
| a[32] | a[33] | a[34] | a[35]);
|
1015 |
|
|
|
1016 |
|
|
endmodule // zzor36_lv
|
1017 |
|
|
|
1018 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
1019 |
|
|
// 34 bit parity tree
|
1020 |
|
|
// LVT version
|
1021 |
|
|
|
1022 |
|
|
module zzpar34_lv ( z, d );
|
1023 |
|
|
input [33:0] d;
|
1024 |
|
|
output z;
|
1025 |
|
|
|
1026 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
1027 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
1028 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
1029 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31]
|
1030 |
|
|
^ d[32] ^ d[33];
|
1031 |
|
|
|
1032 |
|
|
endmodule // zzpar34_lv
|
1033 |
|
|
|
1034 |
|
|
|