1 |
113 |
albert.wat |
// ========== 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 |
|
|
`ifndef SIMPLY_RISC_TWEAKS
|
25 |
|
|
module zznor64_32 ( znor64, znor32, a );
|
26 |
|
|
input [63:0] a;
|
27 |
|
|
output znor64;
|
28 |
|
|
output znor32;
|
29 |
|
|
|
30 |
|
|
assign znor32 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
31 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
32 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
33 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]);
|
34 |
|
|
|
35 |
|
|
assign znor64 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
36 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
37 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
38 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
39 |
|
|
| a[32] | a[33] | a[34] | a[35] | a[36] | a[37] | a[38] | a[39]
|
40 |
|
|
| a[40] | a[41] | a[42] | a[43] | a[44] | a[45] | a[46] | a[47]
|
41 |
|
|
| a[48] | a[49] | a[50] | a[51] | a[52] | a[53] | a[54] | a[55]
|
42 |
|
|
| a[56] | a[57] | a[58] | a[59] | a[60] | a[61] | a[62] | a[63]);
|
43 |
|
|
|
44 |
|
|
endmodule // zznor64_32
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
49 |
|
|
// 36 bit or gate
|
50 |
|
|
|
51 |
|
|
module zzor36 ( z, a );
|
52 |
|
|
input [35:0] a;
|
53 |
|
|
output z;
|
54 |
|
|
|
55 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
56 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
57 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
58 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
59 |
|
|
| a[32] | a[33] | a[34] | a[35]);
|
60 |
|
|
|
61 |
|
|
endmodule // zzor36
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
66 |
|
|
// 32 bit or gate
|
67 |
|
|
|
68 |
|
|
module zzor32 ( z, a );
|
69 |
|
|
input [31:0] a;
|
70 |
|
|
output z;
|
71 |
|
|
|
72 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
73 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
74 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
75 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]);
|
76 |
|
|
|
77 |
|
|
endmodule // zzor32
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
82 |
|
|
// 24 bit nor gate
|
83 |
|
|
|
84 |
|
|
module zznor24 ( z, a );
|
85 |
|
|
input [23:0] a;
|
86 |
|
|
output z;
|
87 |
|
|
|
88 |
|
|
assign z = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
89 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
90 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]);
|
91 |
|
|
|
92 |
|
|
endmodule // zznor24
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
97 |
|
|
// 16 bit nor gate
|
98 |
|
|
|
99 |
|
|
module zznor16 ( z, a );
|
100 |
|
|
input [15:0] a;
|
101 |
|
|
output z;
|
102 |
|
|
|
103 |
|
|
assign z = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
104 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]);
|
105 |
|
|
|
106 |
|
|
endmodule // zznor16
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
111 |
|
|
// 8 bit or gate
|
112 |
|
|
|
113 |
|
|
module zzor8 ( z, a );
|
114 |
|
|
input [7:0] a;
|
115 |
|
|
output z;
|
116 |
|
|
|
117 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]);
|
118 |
|
|
|
119 |
|
|
endmodule // zzor8
|
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 |
|
|
`endif
|
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 |
|
|
`ifndef SIMPLY_RISC_TWEAKS
|
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 |
|
|
`endif
|
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 |
|
|
`ifndef SIMPLY_RISC_TWEAKS
|
703 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
704 |
|
|
//Module Name: zzecc_sctag_pgen_32b
|
705 |
|
|
//Function: Generate 7 parity bits for 32bits input data
|
706 |
|
|
//
|
707 |
|
|
|
708 |
|
|
module zzecc_sctag_pgen_32b ( dout, parity, din);
|
709 |
|
|
|
710 |
|
|
//Output: 32bit dout and 7bit parity bit
|
711 |
|
|
output[31:0] dout;
|
712 |
|
|
output [6:0] parity;
|
713 |
|
|
|
714 |
|
|
//Input: 32bit data din
|
715 |
|
|
input [31:0] din;
|
716 |
|
|
|
717 |
|
|
//input data passing through this module
|
718 |
|
|
assign dout = din ;
|
719 |
|
|
|
720 |
|
|
//generate parity bits based on the hamming codes
|
721 |
|
|
//the method to generate parity bit is shown as follows
|
722 |
|
|
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
723 |
|
|
//P1 P2 d0 P4 d1 d2 d3 P8 d4 d5 d6 d7 d8 d9 d10 P16 d11 d12 d13
|
724 |
|
|
//
|
725 |
|
|
// 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
726 |
|
|
//d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 P32 d26 d27 d28
|
727 |
|
|
//
|
728 |
|
|
// 36 37 38
|
729 |
|
|
//d29 d30 d31
|
730 |
|
|
//For binary numbers B1-B2-B3-B4-B5-B6:
|
731 |
|
|
//B1=1 for (1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,...)
|
732 |
|
|
//B2=1 for (2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39...)
|
733 |
|
|
//B3=1 for (4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39....)
|
734 |
|
|
//B4=1 for (8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,....)
|
735 |
|
|
//B5=1 for (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,...)
|
736 |
|
|
//B6=1 for (32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49...)
|
737 |
|
|
//Parity bit P1,P2,P4,P8,P16,P32 can be generated from the above group of
|
738 |
|
|
//bits B1=1,B2=1,B3=1,B4=1,B5=1,B6=1 respectively.
|
739 |
|
|
|
740 |
|
|
//use parity[5:0] to stand for P1,P2,P4,P8,P16,P32
|
741 |
|
|
assign parity[0] = (din[0]^din[1])^(din[3]^din[4])^(din[6]^din[8])
|
742 |
|
|
^(din[10]^din[11])^(din[13]^din[15])^(din[17]^din[19])
|
743 |
|
|
^(din[21]^din[23])^(din[25]^din[26])^(din[28]^din[30]);
|
744 |
|
|
//
|
745 |
|
|
assign parity[1] = (din[0]^din[2])^(din[3]^din[5])^(din[6]^din[9])
|
746 |
|
|
^(din[10]^din[12])^(din[13]^din[16])^(din[17]^din[20])
|
747 |
|
|
^(din[21]^din[24])^(din[25]^din[27])^(din[28]^din[31]);
|
748 |
|
|
//
|
749 |
|
|
assign parity[2] = (din[1]^din[2])^(din[3]^din[7])^(din[8]^din[9])
|
750 |
|
|
^(din[10]^din[14])^(din[15]^din[16])^(din[17]^din[22])
|
751 |
|
|
^(din[23]^din[24])^(din[25]^din[29])^(din[30]^din[31]);
|
752 |
|
|
//
|
753 |
|
|
assign parity[3] = (din[4]^din[5])^(din[6]^din[7])^(din[8]^din[9])
|
754 |
|
|
^(din[10]^din[18])^(din[19]^din[20])^(din[21]^din[22])
|
755 |
|
|
^(din[23]^din[24])^din[25];
|
756 |
|
|
//
|
757 |
|
|
assign parity[4] = (din[11]^din[12])^(din[13]^din[14])^(din[15]^din[16])
|
758 |
|
|
^(din[17]^din[18])^(din[19]^din[20])^(din[21]^din[22])
|
759 |
|
|
^(din[23]^din[24])^din[25];
|
760 |
|
|
//
|
761 |
|
|
assign parity[5] = (din[26]^din[27])^(din[28]^din[29])^(din[30]^din[31]);
|
762 |
|
|
|
763 |
|
|
//the last parity bit is the xor of all 38bits
|
764 |
|
|
//assign parity[6] = (^din)^(^parity[5:0]);
|
765 |
|
|
//it can be further simplified as:
|
766 |
|
|
//din= d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15
|
767 |
|
|
//p0 = x x x x x x x x x x
|
768 |
|
|
//p1 = x x x x x x x x x
|
769 |
|
|
//p2 = x x x x x x x x x
|
770 |
|
|
//p3 = x x x x x x x
|
771 |
|
|
//p4 = x x x x x
|
772 |
|
|
//p5 =
|
773 |
|
|
//-------------------------------------------------------------------
|
774 |
|
|
//Total 3 3 3 4 3 3 4 3 4 4 5 3 3 4 3 4
|
775 |
|
|
//
|
776 |
|
|
//din=d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31
|
777 |
|
|
//p0= x x x x x x x x
|
778 |
|
|
//p1= x x x x x x x x x
|
779 |
|
|
//p2= x x x x x x x x x
|
780 |
|
|
//p3= x x x x x x x x
|
781 |
|
|
//p4= x x x x x x x x x x
|
782 |
|
|
//p5= x x x x x x
|
783 |
|
|
//-------------------------------------------------------------------
|
784 |
|
|
//total 4 5 3 4 4 5 4 5 5 6 3 3 4 3 4 4
|
785 |
|
|
|
786 |
|
|
//so total=even number, the corresponding bit will not show up in the
|
787 |
|
|
//final xor tree.
|
788 |
|
|
assign parity[6] = din[0] ^ din[1] ^ din[2] ^ din[4] ^ din[5] ^ din[7]
|
789 |
|
|
^ din[10] ^ din[11] ^ din[12] ^ din[14] ^ din[17]
|
790 |
|
|
^ din[18] ^ din[21] ^ din[23] ^ din[24] ^ din[26]
|
791 |
|
|
^ din[27] ^ din[29];
|
792 |
|
|
|
793 |
|
|
endmodule // zzecc_sctag_pgen_32b
|
794 |
|
|
|
795 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
796 |
|
|
// 34 bit parity tree
|
797 |
|
|
|
798 |
|
|
module zzpar34 ( z, d );
|
799 |
|
|
input [33:0] d;
|
800 |
|
|
output z;
|
801 |
|
|
|
802 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
803 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
804 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
805 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31]
|
806 |
|
|
^ d[32] ^ d[33];
|
807 |
|
|
|
808 |
|
|
endmodule // zzpar34
|
809 |
|
|
|
810 |
|
|
|
811 |
|
|
|
812 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
813 |
|
|
// 32 bit parity tree
|
814 |
|
|
|
815 |
|
|
module zzpar32 ( z, d );
|
816 |
|
|
input [31:0] d;
|
817 |
|
|
output z;
|
818 |
|
|
|
819 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
820 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
821 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
822 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31];
|
823 |
|
|
|
824 |
|
|
endmodule // zzpar32
|
825 |
|
|
|
826 |
|
|
|
827 |
|
|
|
828 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
829 |
|
|
// 28 bit parity tree
|
830 |
|
|
|
831 |
|
|
module zzpar28 ( z, d );
|
832 |
|
|
input [27:0] d;
|
833 |
|
|
output z;
|
834 |
|
|
|
835 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
836 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
837 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
838 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27];
|
839 |
|
|
|
840 |
|
|
endmodule // zzpar28
|
841 |
|
|
|
842 |
|
|
|
843 |
|
|
|
844 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
845 |
|
|
// 16 bit parity tree
|
846 |
|
|
|
847 |
|
|
module zzpar16 ( z, d );
|
848 |
|
|
input [15:0] d;
|
849 |
|
|
output z;
|
850 |
|
|
|
851 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
852 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15];
|
853 |
|
|
|
854 |
|
|
endmodule // zzpar16
|
855 |
|
|
|
856 |
|
|
|
857 |
|
|
|
858 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
859 |
|
|
// 8 bit parity tree
|
860 |
|
|
|
861 |
|
|
module zzpar8 ( z, d );
|
862 |
|
|
input [7:0] d;
|
863 |
|
|
output z;
|
864 |
|
|
|
865 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7];
|
866 |
|
|
|
867 |
|
|
endmodule // zzpar8
|
868 |
|
|
|
869 |
|
|
|
870 |
|
|
|
871 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
872 |
|
|
// 64 -> 6 priority encoder
|
873 |
|
|
// Bit 63 has the highest priority
|
874 |
|
|
|
875 |
|
|
module zzpenc64 (/*AUTOARG*/
|
876 |
|
|
// Outputs
|
877 |
|
|
z,
|
878 |
|
|
// Inputs
|
879 |
|
|
a
|
880 |
|
|
);
|
881 |
|
|
|
882 |
|
|
input [63:0] a;
|
883 |
|
|
output [5:0] z;
|
884 |
|
|
|
885 |
|
|
integer i;
|
886 |
|
|
reg [5:0] z;
|
887 |
|
|
|
888 |
|
|
always @ (a)
|
889 |
|
|
begin
|
890 |
|
|
z = 6'b0;
|
891 |
|
|
for (i=0;i<64;i=i+1)
|
892 |
|
|
if (a[i])
|
893 |
|
|
z = i;
|
894 |
|
|
end
|
895 |
|
|
|
896 |
|
|
endmodule // zzpenc64
|
897 |
|
|
|
898 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
899 |
|
|
// 4-bit 60x buffers
|
900 |
|
|
|
901 |
|
|
module zzbufh_60x4 (/*AUTOARG*/
|
902 |
|
|
// Outputs
|
903 |
|
|
z,
|
904 |
|
|
// Inputs
|
905 |
|
|
a
|
906 |
|
|
);
|
907 |
|
|
|
908 |
|
|
input [3:0] a;
|
909 |
|
|
output [3:0] z;
|
910 |
|
|
|
911 |
|
|
assign z = a;
|
912 |
|
|
|
913 |
|
|
endmodule //zzbufh_60x4
|
914 |
|
|
|
915 |
|
|
// LVT modules added below
|
916 |
|
|
|
917 |
|
|
module zzadd64_lv ( rs1_data, rs2_data, cin, adder_out, cout32, cout64 );
|
918 |
|
|
|
919 |
|
|
input [63:0] rs1_data; // 1st input operand
|
920 |
|
|
input [63:0] rs2_data; // 2nd input operand
|
921 |
|
|
input cin; // carry in
|
922 |
|
|
|
923 |
|
|
output [63:0] adder_out; // result of adder
|
924 |
|
|
output cout32; // carry out from lower 32 bit add
|
925 |
|
|
output cout64; // carry out from 64 bit add
|
926 |
|
|
|
927 |
|
|
assign {cout32, adder_out[31:0]} = rs1_data[31:0] + rs2_data[31:0] + cin;
|
928 |
|
|
assign {cout64, adder_out[63:32]} = rs1_data[63:32] + rs2_data[63:32] + cout32;
|
929 |
|
|
|
930 |
|
|
endmodule // zzadd64_lv
|
931 |
|
|
|
932 |
|
|
module zzpar8_lv ( z, d );
|
933 |
|
|
input [7:0] d;
|
934 |
|
|
output z;
|
935 |
|
|
|
936 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7];
|
937 |
|
|
|
938 |
|
|
endmodule // zzpar8_lv
|
939 |
|
|
|
940 |
|
|
|
941 |
|
|
module zzpar32_lv ( z, d );
|
942 |
|
|
input [31:0] d;
|
943 |
|
|
output z;
|
944 |
|
|
|
945 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
946 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
947 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
948 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31];
|
949 |
|
|
|
950 |
|
|
endmodule // zzpar32_lv
|
951 |
|
|
|
952 |
|
|
|
953 |
|
|
|
954 |
|
|
module zznor64_32_lv ( znor64, znor32, a );
|
955 |
|
|
input [63:0] a;
|
956 |
|
|
output znor64;
|
957 |
|
|
output znor32;
|
958 |
|
|
|
959 |
|
|
assign znor32 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
960 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
961 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
962 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]);
|
963 |
|
|
|
964 |
|
|
assign znor64 = ~(a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
965 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
966 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
967 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
968 |
|
|
| a[32] | a[33] | a[34] | a[35] | a[36] | a[37] | a[38] | a[39]
|
969 |
|
|
| a[40] | a[41] | a[42] | a[43] | a[44] | a[45] | a[46] | a[47]
|
970 |
|
|
| a[48] | a[49] | a[50] | a[51] | a[52] | a[53] | a[54] | a[55]
|
971 |
|
|
| a[56] | a[57] | a[58] | a[59] | a[60] | a[61] | a[62] | a[63]);
|
972 |
|
|
|
973 |
|
|
endmodule // zznor64_32_lv
|
974 |
|
|
|
975 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
976 |
|
|
// 64 -> 6 priority encoder
|
977 |
|
|
// Bit 63 has the highest priority
|
978 |
|
|
// LVT version
|
979 |
|
|
|
980 |
|
|
module zzpenc64_lv (/*AUTOARG*/
|
981 |
|
|
// Outputs
|
982 |
|
|
z,
|
983 |
|
|
// Inputs
|
984 |
|
|
a
|
985 |
|
|
);
|
986 |
|
|
|
987 |
|
|
input [63:0] a;
|
988 |
|
|
output [5:0] z;
|
989 |
|
|
|
990 |
|
|
integer i;
|
991 |
|
|
reg [5:0] z;
|
992 |
|
|
|
993 |
|
|
always @ (a)
|
994 |
|
|
begin
|
995 |
|
|
z = 6'b0;
|
996 |
|
|
for (i=0;i<64;i=i+1)
|
997 |
|
|
if (a[i])
|
998 |
|
|
z = i;
|
999 |
|
|
end
|
1000 |
|
|
|
1001 |
|
|
endmodule // zzpenc64_lv
|
1002 |
|
|
|
1003 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
1004 |
|
|
// 36 bit or gate
|
1005 |
|
|
// LVT version
|
1006 |
|
|
|
1007 |
|
|
module zzor36_lv ( z, a );
|
1008 |
|
|
input [35:0] a;
|
1009 |
|
|
output z;
|
1010 |
|
|
|
1011 |
|
|
assign z = (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7]
|
1012 |
|
|
| a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15]
|
1013 |
|
|
| a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23]
|
1014 |
|
|
| a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31]
|
1015 |
|
|
| a[32] | a[33] | a[34] | a[35]);
|
1016 |
|
|
|
1017 |
|
|
endmodule // zzor36_lv
|
1018 |
|
|
|
1019 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
1020 |
|
|
// 34 bit parity tree
|
1021 |
|
|
// LVT version
|
1022 |
|
|
|
1023 |
|
|
module zzpar34_lv ( z, d );
|
1024 |
|
|
input [33:0] d;
|
1025 |
|
|
output z;
|
1026 |
|
|
|
1027 |
|
|
assign z = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6] ^ d[7]
|
1028 |
|
|
^ d[8] ^ d[9] ^ d[10] ^ d[11] ^ d[12] ^ d[13] ^ d[14] ^ d[15]
|
1029 |
|
|
^ d[16] ^ d[17] ^ d[18] ^ d[19] ^ d[20] ^ d[21] ^ d[22] ^ d[23]
|
1030 |
|
|
^ d[24] ^ d[25] ^ d[26] ^ d[27] ^ d[28] ^ d[29] ^ d[30] ^ d[31]
|
1031 |
|
|
^ d[32] ^ d[33];
|
1032 |
|
|
|
1033 |
|
|
endmodule // zzpar34_lv
|
1034 |
|
|
`endif
|
1035 |
|
|
|