Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / niu_ipp_sum_lib.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: niu_ipp_sum_lib.v
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35
36`timescale 1ns/10ps
37
38/**********************************************************
39***********************************************************
40
41 Project : Niu
42
43 File name : niu_ipp_sum_lib.v
44
45 Module(s) name :
46
47 Parent modules : niu_ipp_sum.v
48
49 Child modules :
50
51
52 Author's name : George Chu
53
54 Date : March. 2004
55
56 Description : Library cells of the ipp checksum.
57
58 Synthesis Notes:
59
60 Modification History:
61
62 Date Description
63 ---- -----------
64
65************************************************************
66***********************************************************/
67
68module ipp_sum_reg_r_1 (di, rs, ck, qo);
69input di;
70input rs;
71input ck;
72output qo;
73
74reg qo;
75
76 always @(posedge ck)
77 qo <= #1 (!rs & di);
78
79endmodule
80
81
82module ipp_sum_reg_r_2 (di, rs, ck, qo);
83input [1:0] di;
84input rs;
85input ck;
86output [1:0] qo;
87
88reg [1:0] qo;
89
90 always @(posedge ck)
91 begin
92 if (rs)
93 qo <= #1 2'h0;
94 else
95 qo <= #1 di[1:0];
96 end
97
98endmodule
99
100
101module ipp_sum_reg_r_4 (di, rs, ck, qo);
102input [3:0] di;
103input rs;
104input ck;
105output [3:0] qo;
106
107reg [3:0] qo;
108
109 always @(posedge ck)
110 begin
111 if (rs)
112 qo <= #1 4'h0;
113 else
114 qo <= #1 di[3:0];
115 end
116
117endmodule
118
119
120module ipp_sum_reg_r_8 (di, rs, ck, qo);
121input [7:0] di;
122input rs;
123input ck;
124output [7:0] qo;
125
126reg [7:0] qo;
127
128 always @(posedge ck)
129 begin
130 if (rs)
131 qo <= #1 8'h0;
132 else
133 qo <= #1 di[7:0];
134 end
135
136endmodule
137
138
139module ipp_sum_reg_r_9_s0 (di, rs, ck, qo);
140input [8:0] di;
141input rs;
142input ck;
143output [8:0] qo;
144
145reg [8:0] qo;
146
147 always @(posedge ck)
148 begin
149 if (rs)
150 qo <= #1 9'h1;
151 else
152 qo <= #1 di[8:0];
153 end
154
155endmodule
156
157
158module ipp_sum_reg_r_16 (di, rs, ck, qo);
159input [15:0] di;
160input rs;
161input ck;
162output [15:0] qo;
163
164reg [15:0] qo;
165
166 always @(posedge ck)
167 begin
168 if (rs)
169 qo <= #1 16'h0;
170 else
171 qo <= #1 di[15:0];
172 end
173
174endmodule
175
176
177module ipp_sum_reg_r_128 (di, rs, ck, qo);
178input [127:0] di;
179input rs;
180input ck;
181output [127:0] qo;
182
183reg [127:0] qo;
184
185 always @(posedge ck)
186 begin
187 if (rs)
188 qo <= #1 128'h0;
189 else
190 qo <= #1 di[127:0];
191 end
192
193endmodule
194
195
196module ipp_sum_reg_w_r_1 (di, wr, rs, ck, qo);
197input di;
198input wr;
199input rs;
200input ck;
201output qo;
202
203reg n_qo;
204reg qo;
205
206 always @(di or wr or rs or qo)
207 case ({rs,wr}) // synopsys parallel_case
208 (2'h1): n_qo = di;
209 (2'h2): n_qo = 1'b0;
210 (2'h3): n_qo = 1'b0;
211 default: n_qo = qo;
212 endcase
213
214 always @(posedge ck)
215 begin
216 qo <= #1 n_qo;
217 end
218
219endmodule
220
221
222module ipp_sum_reg_w_r_2 (di, wr, rs, ck, qo);
223input [1:0] di;
224input wr;
225input rs;
226input ck;
227output [1:0] qo;
228
229reg [1:0] n_qo;
230reg [1:0] qo;
231
232 always @(di or wr or rs or qo)
233 case ({rs,wr}) // synopsys parallel_case
234 (2'h1): n_qo = di[1:0];
235 (2'h2): n_qo = 2'b0;
236 (2'h3): n_qo = 2'b0;
237 default: n_qo = qo[1:0];
238 endcase
239
240 always @(posedge ck)
241 begin
242 qo <= #1 n_qo[1:0];
243 end
244
245endmodule
246
247
248module ipp_sum_reg_w_r_4 (di, wr, rs, ck, qo);
249input [3:0] di;
250input wr;
251input rs;
252input ck;
253output [3:0] qo;
254
255reg [3:0] n_qo;
256reg [3:0] qo;
257
258 always @(di or wr or rs or qo)
259 case ({rs,wr}) // synopsys parallel_case
260 (2'h1): n_qo = di[3:0];
261 (2'h2): n_qo = 4'b0;
262 (2'h3): n_qo = 4'b0;
263 default: n_qo = qo[3:0];
264 endcase
265
266 always @(posedge ck)
267 begin
268 qo <= #1 n_qo[3:0];
269 end
270
271endmodule
272
273
274module ipp_sum_reg_w_r_13 (di, wr, rs, ck, qo);
275input [12:0] di;
276input wr;
277input rs;
278input ck;
279output [12:0] qo;
280
281reg [12:0] n_qo;
282reg [12:0] qo;
283
284 always @(di or wr or rs or qo)
285 case ({rs,wr}) // synopsys parallel_case
286 (2'h1): n_qo = di[12:0];
287 (2'h2): n_qo = 13'b0;
288 (2'h3): n_qo = 13'b0;
289 default: n_qo = qo[12:0];
290 endcase
291
292 always @(posedge ck)
293 begin
294 qo <= #1 n_qo[12:0];
295 end
296
297endmodule
298
299
300module ipp_sum_reg_w_r_16 (di, wr, rs, ck, qo);
301input [15:0] di;
302input wr;
303input rs;
304input ck;
305output [15:0] qo;
306
307reg [15:0] n_qo;
308reg [15:0] qo;
309
310 always @(di or wr or rs or qo)
311 case ({rs,wr}) // synopsys parallel_case
312 (2'h1): n_qo = di[15:0];
313 (2'h2): n_qo = 16'b0;
314 (2'h3): n_qo = 16'b0;
315 default: n_qo = qo[15:0];
316 endcase
317
318 always @(posedge ck)
319 begin
320 qo <= #1 n_qo[15:0];
321 end
322
323endmodule
324
325
326module ipp_sum_reg_w_r_17 (di, wr, rs, ck, qo);
327input [16:0] di;
328input wr;
329input rs;
330input ck;
331output [16:0] qo;
332
333reg [16:0] n_qo;
334reg [16:0] qo;
335
336 always @(di or wr or rs or qo)
337 case ({rs,wr}) // synopsys parallel_case
338 (2'h1): n_qo = di[16:0];
339 (2'h2): n_qo = 17'b0;
340 (2'h3): n_qo = 17'b0;
341 default: n_qo = qo[16:0];
342 endcase
343
344 always @(posedge ck)
345 begin
346 qo <= #1 n_qo[16:0];
347 end
348
349endmodule
350
351
352module ipp_sum_reg_w_r_23 (di, wr, rs, ck, qo);
353input [22:0] di;
354input wr;
355input rs;
356input ck;
357output [22:0] qo;
358
359reg [22:0] n_qo;
360reg [22:0] qo;
361
362 always @(di or wr or rs or qo)
363 case ({rs,wr}) // synopsys parallel_case
364 (2'h1): n_qo = di[22:0];
365 (2'h2): n_qo = 23'b0;
366 (2'h3): n_qo = 23'b0;
367 default: n_qo = qo[22:0];
368 endcase
369
370 always @(posedge ck)
371 begin
372 qo <= #1 n_qo[22:0];
373 end
374
375endmodule
376
377
378module ipp_sum_cnt_i_r_8 ( incr, rs, ck, qo);
379input incr;
380input rs;
381input ck;
382output [7:0] qo;
383
384reg [7:0] qo;
385
386 always @(posedge ck)
387 begin
388 if (rs)
389 qo <= #1 8'h0;
390 else if (incr)
391 qo <= #1 (qo[7:0] + 8'h1);
392 else
393 qo <= #1 qo[7:0];
394 end
395
396endmodule
397
398
399module ipp_sum_dev_00_00(in1, in2, out);
400input [15:0] in1;
401input [15:0] in2;
402output [16:0] out;
403
404wire [16:0] out;
405
406 assign out = {1'b0,in1[15:0]} + {1'b0,in2[15:0]};
407
408endmodule
409
410
411module ipp_sum_dev_00_01(in1, in2, out);
412input [15:0] in1;
413input [15:0] in2;
414output [15:0] out;
415
416wire [15:0] out;
417
418 assign out = in1[15:0] + in2[15:0] + 16'h1;
419
420endmodule
421
422
423module ipp_sum_dev_01_0q (inp_wd3, inp_wd2, inp_wd1, inp_wrd,
424 byt_ena, sel_awd, sel_add,
425 clr, clk,
426 prt_cksum, cksum_fail);
427input [15:0] inp_wd3;
428input [15:0] inp_wd2;
429input [15:0] inp_wd1;
430input [15:0] inp_wrd;
431input [1:0] byt_ena;
432input [1:0] sel_awd;
433input sel_add;
434input clr;
435input clk;
436output [15:0] prt_cksum;
437output cksum_fail;
438
439reg [15:0] sum_wrd;
440wire [15:0] prt_cksum = ~sum_wrd[15:0];
441
442wire [15:0] out1 = {{8{byt_ena[1]}}&inp_wrd[15:8],{8{byt_ena[0]}}&inp_wrd[7:0]};
443reg [15:0] out2;
444wire [16:0] out3a;
445wire [15:0] out3b;
446wire [15:0] out4;
447wire [15:0] out5;
448
449wire cksum_fail = |(~out5[15:0]);
450
451 always @(sel_awd or
452 out1 or inp_wd1 or inp_wd2 or inp_wd3)
453 case (sel_awd) // synopsys parallel_case
454 (2'h0): out2 = out1[15:0];
455 (2'h1): out2 = inp_wd1[15:0];
456 (2'h2): out2 = inp_wd2[15:0];
457 (2'h3): out2 = inp_wd3[15:0];
458 default: out2 = out1[15:0];
459 endcase
460
461 ipp_sum_dev_00_00 dev_00_00_a (.in1(out2[15:0]), .in2(sum_wrd[15:0]), .out(out3a[16:0]));
462 ipp_sum_dev_00_01 dev_00_01_b (.in1(out2[15:0]), .in2(sum_wrd[15:0]), .out(out3b[15:0]));
463
464 assign out4 = out3a[16] ? out3b[15:0] : out3a[15:0];
465 assign out5 = sel_add ? out4[15:0] : sum_wrd[15:0];
466
467 always @(posedge clk) begin
468 sum_wrd <= #1 ({16{!clr}} & out5[15:0]);
469 end
470
471endmodule
472
473
474module ipp_sum_dev_01_0r ( inp_wd2, inp_wd1, inp_wrd, hdr_off,
475 byt_ena, sel_awd, sel_bwd, sel_add,
476 clr, clk,
477 sum_wrd);
478input [15:0] inp_wd2;
479input [15:0] inp_wd1;
480input [15:0] inp_wrd;
481input [3:0] hdr_off;
482input [1:0] byt_ena;
483input [1:0] sel_awd;
484input sel_bwd;
485input sel_add;
486input clr;
487input clk;
488output [15:0] sum_wrd;
489
490reg [15:0] sum_wrd;
491
492wire [15:0] out1 = {{8{byt_ena[1]}}&inp_wrd[15:8],{8{byt_ena[0]}}&inp_wrd[7:0]};
493reg [15:0] out2;
494reg [15:0] out1b;
495wire [16:0] out3a;
496wire [15:0] out3b;
497wire [15:0] out4;
498wire [15:0] out5;
499
500 always @(sel_awd or
501 out1 or inp_wd1 or inp_wd2)
502 case (sel_awd) // synopsys parallel_case
503 (2'h0): out2 = out1[15:0];
504 (2'h1): out2 = inp_wd1[15:0];
505 (2'h2): out2 = inp_wd2[15:0];
506 (2'h3): out2 = inp_wd2[15:0];
507 default: out2 = out1[15:0];
508 endcase
509
510 always @(sel_bwd or hdr_off or
511 sum_wrd)
512 case (sel_bwd) // synopsys parallel_case
513 (1'h0): out1b = sum_wrd[15:0];
514 (1'h1): out1b = {10'h3ff,hdr_off[3:0],2'h0};
515 default: out1b = sum_wrd[15:0];
516 endcase
517
518 ipp_sum_dev_00_00 dev_00_00_a (.in1(out2[15:0]), .in2(out1b[15:0]), .out(out3a[16:0]));
519 ipp_sum_dev_00_01 dev_00_01_b (.in1(out2[15:0]), .in2(out1b[15:0]), .out(out3b[15:0]));
520
521 assign out4 = out3a[16] && !sel_bwd ? out3b[15:0] : out3a[15:0];
522 assign out5 = sel_add ? out4[15:0] : sum_wrd[15:0];
523
524 always @(posedge clk) begin
525 sum_wrd <= #1 ({16{!clr}} & out5[15:0]);
526 end
527
528endmodule
529
530
531module ipp_sum_dev_01_0s ( inp_wd1, inp_wrd,
532 byt_ena, sel_awd, sel_asw, sel_add,
533 clr, clk,
534 sum_wrd);
535input [15:0] inp_wd1;
536input [15:0] inp_wrd;
537input [1:0] byt_ena;
538input sel_awd;
539input sel_asw;
540input sel_add;
541input clr;
542input clk;
543output [15:0] sum_wrd;
544
545reg [15:0] sum_wrd;
546
547wire [15:0] out1 = {{8{byt_ena[1]}}&inp_wrd[15:8],{8{byt_ena[0]}}&inp_wrd[7:0]};
548wire [15:0] out1a= sel_asw ? {out1[7:0],out1[15:8]} : out1[15:0];
549reg [15:0] out2;
550wire [16:0] out3a;
551wire [15:0] out3b;
552wire [15:0] out4;
553wire [15:0] out5;
554
555 always @(sel_awd or
556 out1a or inp_wd1)
557 case (sel_awd) // synopsys parallel_case
558 (1'h0): out2 = out1a[15:0];
559 (1'h1): out2 = inp_wd1[15:0];
560 default: out2 = out1a[15:0];
561 endcase
562
563 ipp_sum_dev_00_00 dev_00_00_a (.in1(out2[15:0]), .in2(sum_wrd[15:0]), .out(out3a[16:0]));
564 ipp_sum_dev_00_01 dev_00_01_b (.in1(out2[15:0]), .in2(sum_wrd[15:0]), .out(out3b[15:0]));
565
566 assign out4 = out3a[16] ? out3b[15:0] : out3a[15:0];
567 assign out5 = sel_add ? out4[15:0] : sum_wrd[15:0];
568
569 always @(posedge clk) begin
570 sum_wrd <= #1 ({16{!clr}} & out5[15:0]);
571 end
572
573endmodule
574
575
576module ipp_sum_dev_01_0t ( inp_wrd, hdr_off,
577 byt_ena, sel_asw, sel_bwd, sel_add,
578 clr, clk,
579 sum_wrd);
580input [15:0] inp_wrd;
581input [3:0] hdr_off;
582input [1:0] byt_ena;
583input sel_asw;
584input sel_bwd;
585input sel_add;
586input clr;
587input clk;
588output [15:0] sum_wrd;
589
590reg [15:0] sum_wrd;
591
592wire [15:0] out1 = {{8{byt_ena[1]}}&inp_wrd[15:8],{8{byt_ena[0]}}&inp_wrd[7:0]};
593wire [15:0] out2 = sel_asw ? {out1[7:0],out1[15:8]} : out1[15:0];
594reg [15:0] out1b;
595wire [16:0] out3a;
596wire [15:0] out3b;
597wire [15:0] out4;
598wire [15:0] out5;
599
600 always @(sel_bwd or hdr_off or
601 sum_wrd)
602 case (sel_bwd) // synopsys parallel_case
603 (1'h0): out1b = sum_wrd[15:0];
604 (1'h1): out1b = {10'h3ff,hdr_off[3:0],2'h0};
605 default: out1b = sum_wrd[15:0];
606 endcase
607
608 ipp_sum_dev_00_00 dev_00_00_a (.in1(out2[15:0]), .in2(out1b[15:0]), .out(out3a[16:0]));
609 ipp_sum_dev_00_01 dev_00_01_b (.in1(out2[15:0]), .in2(out1b[15:0]), .out(out3b[15:0]));
610
611 assign out4 = out3a[16] && !sel_bwd ? out3b[15:0] : out3a[15:0];
612 assign out5 = sel_add ? out4[15:0] : sum_wrd[15:0];
613
614 always @(posedge clk) begin
615 sum_wrd <= #1 ({16{!clr}} & out5[15:0]);
616 end
617
618endmodule
619
620
621module ipp_sum_dev_01_ut (inp_uln, inp_wrd, hdr_off,
622 byt_ena, sel_asw, sel_bwd, sel_add, get_uln,
623 clr, clk,
624 sum_wrd);
625input [15:0] inp_uln;
626input [15:0] inp_wrd;
627input [3:0] hdr_off;
628input [1:0] byt_ena;
629input sel_asw;
630input sel_bwd;
631input sel_add;
632input get_uln;
633input clr;
634input clk;
635output [15:0] sum_wrd;
636
637reg [15:0] sum_wrd;
638
639wire [15:0] out1 = {{8{byt_ena[1]}}&inp_wrd[15:8],{8{byt_ena[0]}}&inp_wrd[7:0]};
640wire [15:0] out2 = sel_asw ? {out1[7:0],out1[15:8]} : out1[15:0];
641reg [15:0] out2a;
642reg [15:0] out1b;
643wire [16:0] out3a;
644wire [15:0] out3b;
645wire [15:0] out4;
646wire [15:0] out5;
647
648 always @(get_uln or
649 out2 or inp_uln)
650 case (get_uln) // synopsys parallel_case
651 (1'h0): out2a = out2[15:0];
652 (1'h1): out2a = inp_uln[15:0];
653 default: out2a = out2[15:0];
654 endcase
655
656 always @(sel_bwd or hdr_off or get_uln or
657 sum_wrd)
658 case ({get_uln,sel_bwd}) // synopsys parallel_case
659 (2'h0): out1b = sum_wrd[15:0];
660 (2'h1): out1b = {10'h3ff,hdr_off[3:0],2'h0};
661 (2'h2): out1b = 16'h0;
662 (2'h3): out1b = 16'h0;
663 default: out1b = sum_wrd[15:0];
664 endcase
665
666 ipp_sum_dev_00_00 dev_00_00_a (.in1(out2a[15:0]), .in2(out1b[15:0]), .out(out3a[16:0]));
667 ipp_sum_dev_00_01 dev_00_01_b (.in1(out2a[15:0]), .in2(out1b[15:0]), .out(out3b[15:0]));
668
669 assign out4 = out3a[16] && !sel_bwd ? out3b[15:0] : out3a[15:0];
670 assign out5 = (sel_add || get_uln) ? out4[15:0] : sum_wrd[15:0];
671
672 always @(posedge clk) begin
673 sum_wrd <= #1 ({16{!clr}} & out5[15:0]);
674 end
675
676endmodule
677
678