Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / mcu / rtl / mcu_ucbin_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: mcu_ucbin_ctl.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 ============================================
35module mcu_ucbin_ctl (
36 l1clk,
37 scan_in,
38 scan_out,
39 tcu_aclk,
40 tcu_bclk,
41 tcu_scan_en,
42 vld,
43 data,
44 stall,
45 indata_buf_vld,
46 indata_buf,
47 stall_a1);
48wire siclk;
49wire soclk;
50wire se;
51wire not_stall_d1;
52wire not_stall_a1;
53wire vld_d1_ff_scanin;
54wire vld_d1_ff_scanout;
55wire data_d1_ff_scanin;
56wire data_d1_ff_scanout;
57wire stall_ff_scanin;
58wire stall_ff_scanout;
59wire stall_d1_ff_scanin;
60wire stall_d1_ff_scanout;
61wire vld_buf0_ff_scanin;
62wire vld_buf0_ff_scanout;
63wire data_buf0_ff_scanin;
64wire data_buf0_ff_scanout;
65wire skid_buf1_en_ff_scanin;
66wire skid_buf1_en_ff_scanout;
67wire vld_buf1_ff_scanin;
68wire vld_buf1_ff_scanout;
69wire data_buf1_ff_scanin;
70wire data_buf1_ff_scanout;
71wire skid_buf1_sel_ff_scanin;
72wire skid_buf1_sel_ff_scanout;
73wire indata_vec_ff_scanin;
74wire indata_vec_ff_scanout;
75wire indata_buf_ff_scanin;
76wire indata_buf_ff_scanout;
77wire indata_vec0_d1_ff_scanin;
78wire indata_vec0_d1_ff_scanout;
79
80
81// parameter UCB_BUS_WIDTH = 4;
82// parameter REG_WIDTH = 64;
83
84
85////////////////////////////////////////////////////////////////////////
86// Signal declarations
87////////////////////////////////////////////////////////////////////////
88 // Global interface
89input l1clk;
90input scan_in;
91output scan_out;
92input tcu_aclk;
93input tcu_bclk;
94input tcu_scan_en;
95
96// UCB bus interface
97input vld;
98input [3:0] data;
99output stall;
100
101
102// Local interface
103output indata_buf_vld;
104output [127:0] indata_buf;
105input stall_a1;
106
107
108// Internal signals
109wire vld_d1;
110wire stall_d1;
111wire [3:0] data_d1;
112wire skid_buf0_en;
113wire vld_buf0;
114wire [3:0] data_buf0;
115wire skid_buf1_en;
116wire vld_buf1;
117wire [3:0] data_buf1;
118wire skid_buf0_sel;
119wire skid_buf1_sel;
120wire vld_mux;
121wire [3:0] data_mux;
122wire [31:0] indata_vec_next;
123wire [31:0] indata_vec;
124wire [127:0] indata_buf_next;
125wire indata_vec0_d1;
126
127////////////////////////////////////////////////////////////////////////
128// Code starts here
129////////////////////////////////////////////////////////////////////////
130
131// Scan reassigns
132assign siclk = tcu_aclk;
133assign soclk = tcu_bclk;
134assign se = tcu_scan_en;
135
136assign not_stall_d1 = ~stall_d1;
137assign not_stall_a1 = ~stall_a1;
138
139/************************************************************
140 * UCB bus interface flops
141 * This is to make signals going between IOB and UCB flop-to-flop
142 * to improve timing.
143 ************************************************************/
144mcu_ucbin_ctl_msff_ctl_macro__en_1__width_1 vld_d1_ff (
145 .scan_in(vld_d1_ff_scanin),
146 .scan_out(vld_d1_ff_scanout),
147 .din(vld),
148 .en(not_stall_d1),
149 .l1clk(l1clk),
150 .dout(vld_d1),
151 .siclk(siclk),
152 .soclk(soclk));
153
154mcu_ucbin_ctl_msff_ctl_macro__en_1__width_4 data_d1_ff (
155 .scan_in(data_d1_ff_scanin),
156 .scan_out(data_d1_ff_scanout),
157 .din(data),
158 .en(not_stall_d1),
159 .l1clk(l1clk),
160 .dout(data_d1),
161 .siclk(siclk),
162 .soclk(soclk));
163
164mcu_ucbin_ctl_msff_ctl_macro__width_1 stall_ff (
165 .scan_in(stall_ff_scanin),
166 .scan_out(stall_ff_scanout),
167 .din(stall_a1),
168 .l1clk(l1clk),
169 .dout(stall),
170 .siclk(siclk),
171 .soclk(soclk));
172
173mcu_ucbin_ctl_msff_ctl_macro__width_1 stall_d1_ff (
174 .scan_in(stall_d1_ff_scanin),
175 .scan_out(stall_d1_ff_scanout),
176 .din(stall),
177 .l1clk(l1clk),
178 .dout(stall_d1),
179 .siclk(siclk),
180 .soclk(soclk));
181
182
183/************************************************************
184 * Skid buffer
185 * We need a two deep skid buffer to handle stalling.
186 ************************************************************/
187// Assertion: stall has to be deasserted for more than 1 cycle
188// ie time between two separate stalls has to be
189// at least two cycles. Otherwise, contents from
190// skid buffer will be lost.
191
192// Buffer 0
193assign skid_buf0_en = stall_a1 & ~stall;
194
195mcu_ucbin_ctl_msff_ctl_macro__en_1 vld_buf0_ff (
196 .scan_in(vld_buf0_ff_scanin),
197 .scan_out(vld_buf0_ff_scanout),
198 .din(vld_d1),
199 .en(skid_buf0_en),
200 .l1clk(l1clk),
201 .dout(vld_buf0),
202 .siclk(siclk),
203 .soclk(soclk));
204
205mcu_ucbin_ctl_msff_ctl_macro__en_1__width_4 data_buf0_ff (
206 .scan_in(data_buf0_ff_scanin),
207 .scan_out(data_buf0_ff_scanout),
208 .din(data_d1),
209 .en(skid_buf0_en),
210 .l1clk(l1clk),
211 .dout(data_buf0),
212 .siclk(siclk),
213 .soclk(soclk));
214
215// Buffer 1
216mcu_ucbin_ctl_msff_ctl_macro__width_1 skid_buf1_en_ff (
217 .scan_in(skid_buf1_en_ff_scanin),
218 .scan_out(skid_buf1_en_ff_scanout),
219 .din(skid_buf0_en),
220 .l1clk(l1clk),
221 .dout(skid_buf1_en),
222 .siclk(siclk),
223 .soclk(soclk));
224
225mcu_ucbin_ctl_msff_ctl_macro__en_1__width_1 vld_buf1_ff (
226 .scan_in(vld_buf1_ff_scanin),
227 .scan_out(vld_buf1_ff_scanout),
228 .din(vld_d1),
229 .en(skid_buf1_en),
230 .l1clk(l1clk),
231 .dout(vld_buf1),
232 .siclk(siclk),
233 .soclk(soclk));
234
235mcu_ucbin_ctl_msff_ctl_macro__en_1__width_4 data_buf1_ff (
236 .scan_in(data_buf1_ff_scanin),
237 .scan_out(data_buf1_ff_scanout),
238 .din(data_d1),
239 .en(skid_buf1_en),
240 .l1clk(l1clk),
241 .dout(data_buf1),
242 .siclk(siclk),
243 .soclk(soclk));
244
245
246/************************************************************
247 * Mux between skid buffer and interface flop
248 ************************************************************/
249// Assertion: stall has to be deasserted for more than 1 cycle
250// ie time between two separate stalls has to be
251// at least two cycles. Otherwise, contents from
252// skid buffer will be lost.
253
254assign skid_buf0_sel = ~stall_a1 & stall;
255
256mcu_ucbin_ctl_msff_ctl_macro__width_1 skid_buf1_sel_ff (
257 .scan_in(skid_buf1_sel_ff_scanin),
258 .scan_out(skid_buf1_sel_ff_scanout),
259 .din(skid_buf0_sel),
260 .l1clk(l1clk),
261 .dout(skid_buf1_sel),
262 .siclk(siclk),
263 .soclk(soclk));
264
265assign vld_mux = skid_buf0_sel ? vld_buf0 :
266 skid_buf1_sel ? vld_buf1 : vld_d1;
267
268assign data_mux = skid_buf0_sel ? data_buf0 :
269 skid_buf1_sel ? data_buf1 : data_d1;
270
271
272/************************************************************
273 * Assemble inbound data
274 ************************************************************/
275// valid vector
276assign indata_vec_next = {vld_mux, indata_vec[31:1]};
277mcu_ucbin_ctl_msff_ctl_macro__en_1__width_32 indata_vec_ff (
278 .scan_in(indata_vec_ff_scanin),
279 .scan_out(indata_vec_ff_scanout),
280 .din(indata_vec_next),
281 .en(not_stall_a1),
282 .l1clk(l1clk),
283 .dout(indata_vec),
284 .siclk(siclk),
285 .soclk(soclk));
286
287// data buffer
288assign indata_buf_next = {data_mux, indata_buf[127:4]};
289mcu_ucbin_ctl_msff_ctl_macro__en_1__width_128 indata_buf_ff (
290 .scan_in(indata_buf_ff_scanin),
291 .scan_out(indata_buf_ff_scanout),
292 .din(indata_buf_next),
293 .en(not_stall_a1),
294 .l1clk(l1clk),
295 .dout(indata_buf),
296 .siclk(siclk),
297 .soclk(soclk));
298
299// detect a new packet
300mcu_ucbin_ctl_msff_ctl_macro__en_1__width_1 indata_vec0_d1_ff (
301 .scan_in(indata_vec0_d1_ff_scanin),
302 .scan_out(indata_vec0_d1_ff_scanout),
303 .din(indata_vec[0]),
304 .en(not_stall_a1),
305 .l1clk(l1clk),
306 .dout(indata_vec0_d1),
307 .siclk(siclk),
308 .soclk(soclk));
309
310assign indata_buf_vld = indata_vec[0] & ~indata_vec0_d1;
311
312
313// fixscan start:
314assign vld_d1_ff_scanin = scan_in ;
315assign data_d1_ff_scanin = vld_d1_ff_scanout ;
316assign stall_ff_scanin = data_d1_ff_scanout ;
317assign stall_d1_ff_scanin = stall_ff_scanout ;
318assign vld_buf0_ff_scanin = stall_d1_ff_scanout ;
319assign data_buf0_ff_scanin = vld_buf0_ff_scanout ;
320assign skid_buf1_en_ff_scanin = data_buf0_ff_scanout ;
321assign vld_buf1_ff_scanin = skid_buf1_en_ff_scanout ;
322assign data_buf1_ff_scanin = vld_buf1_ff_scanout ;
323assign skid_buf1_sel_ff_scanin = data_buf1_ff_scanout ;
324assign indata_vec_ff_scanin = skid_buf1_sel_ff_scanout ;
325assign indata_buf_ff_scanin = indata_vec_ff_scanout ;
326assign indata_vec0_d1_ff_scanin = indata_buf_ff_scanout ;
327assign scan_out = indata_vec0_d1_ff_scanout;
328// fixscan end:
329endmodule
330
331
332
333
334
335
336// any PARAMS parms go into naming of macro
337
338module mcu_ucbin_ctl_msff_ctl_macro__en_1__width_1 (
339 din,
340 en,
341 l1clk,
342 scan_in,
343 siclk,
344 soclk,
345 dout,
346 scan_out);
347wire [0:0] fdin;
348
349 input [0:0] din;
350 input en;
351 input l1clk;
352 input scan_in;
353
354
355 input siclk;
356 input soclk;
357
358 output [0:0] dout;
359 output scan_out;
360assign fdin[0:0] = (din[0:0] & {1{en}}) | (dout[0:0] & ~{1{en}});
361
362
363
364
365
366
367dff #(1) d0_0 (
368.l1clk(l1clk),
369.siclk(siclk),
370.soclk(soclk),
371.d(fdin[0:0]),
372.si(scan_in),
373.so(scan_out),
374.q(dout[0:0])
375);
376
377
378
379
380
381
382
383
384
385
386
387
388endmodule
389
390
391
392
393
394
395
396
397
398
399
400
401
402// any PARAMS parms go into naming of macro
403
404module mcu_ucbin_ctl_msff_ctl_macro__en_1__width_4 (
405 din,
406 en,
407 l1clk,
408 scan_in,
409 siclk,
410 soclk,
411 dout,
412 scan_out);
413wire [3:0] fdin;
414wire [2:0] so;
415
416 input [3:0] din;
417 input en;
418 input l1clk;
419 input scan_in;
420
421
422 input siclk;
423 input soclk;
424
425 output [3:0] dout;
426 output scan_out;
427assign fdin[3:0] = (din[3:0] & {4{en}}) | (dout[3:0] & ~{4{en}});
428
429
430
431
432
433
434dff #(4) d0_0 (
435.l1clk(l1clk),
436.siclk(siclk),
437.soclk(soclk),
438.d(fdin[3:0]),
439.si({scan_in,so[2:0]}),
440.so({so[2:0],scan_out}),
441.q(dout[3:0])
442);
443
444
445
446
447
448
449
450
451
452
453
454
455endmodule
456
457
458
459
460
461
462
463
464
465
466
467
468
469// any PARAMS parms go into naming of macro
470
471module mcu_ucbin_ctl_msff_ctl_macro__width_1 (
472 din,
473 l1clk,
474 scan_in,
475 siclk,
476 soclk,
477 dout,
478 scan_out);
479wire [0:0] fdin;
480
481 input [0:0] din;
482 input l1clk;
483 input scan_in;
484
485
486 input siclk;
487 input soclk;
488
489 output [0:0] dout;
490 output scan_out;
491assign fdin[0:0] = din[0:0];
492
493
494
495
496
497
498dff #(1) d0_0 (
499.l1clk(l1clk),
500.siclk(siclk),
501.soclk(soclk),
502.d(fdin[0:0]),
503.si(scan_in),
504.so(scan_out),
505.q(dout[0:0])
506);
507
508
509
510
511
512
513
514
515
516
517
518
519endmodule
520
521
522
523
524
525
526
527
528
529
530
531
532
533// any PARAMS parms go into naming of macro
534
535module mcu_ucbin_ctl_msff_ctl_macro__en_1 (
536 din,
537 en,
538 l1clk,
539 scan_in,
540 siclk,
541 soclk,
542 dout,
543 scan_out);
544wire [0:0] fdin;
545
546 input [0:0] din;
547 input en;
548 input l1clk;
549 input scan_in;
550
551
552 input siclk;
553 input soclk;
554
555 output [0:0] dout;
556 output scan_out;
557assign fdin[0:0] = (din[0:0] & {1{en}}) | (dout[0:0] & ~{1{en}});
558
559
560
561
562
563
564dff #(1) d0_0 (
565.l1clk(l1clk),
566.siclk(siclk),
567.soclk(soclk),
568.d(fdin[0:0]),
569.si(scan_in),
570.so(scan_out),
571.q(dout[0:0])
572);
573
574
575
576
577
578
579
580
581
582
583
584
585endmodule
586
587
588
589
590
591
592
593
594
595
596
597
598
599// any PARAMS parms go into naming of macro
600
601module mcu_ucbin_ctl_msff_ctl_macro__en_1__width_32 (
602 din,
603 en,
604 l1clk,
605 scan_in,
606 siclk,
607 soclk,
608 dout,
609 scan_out);
610wire [31:0] fdin;
611wire [30:0] so;
612
613 input [31:0] din;
614 input en;
615 input l1clk;
616 input scan_in;
617
618
619 input siclk;
620 input soclk;
621
622 output [31:0] dout;
623 output scan_out;
624assign fdin[31:0] = (din[31:0] & {32{en}}) | (dout[31:0] & ~{32{en}});
625
626
627
628
629
630
631dff #(32) d0_0 (
632.l1clk(l1clk),
633.siclk(siclk),
634.soclk(soclk),
635.d(fdin[31:0]),
636.si({scan_in,so[30:0]}),
637.so({so[30:0],scan_out}),
638.q(dout[31:0])
639);
640
641
642
643
644
645
646
647
648
649
650
651
652endmodule
653
654
655
656
657
658
659
660
661
662
663
664
665
666// any PARAMS parms go into naming of macro
667
668module mcu_ucbin_ctl_msff_ctl_macro__en_1__width_128 (
669 din,
670 en,
671 l1clk,
672 scan_in,
673 siclk,
674 soclk,
675 dout,
676 scan_out);
677wire [127:0] fdin;
678wire [126:0] so;
679
680 input [127:0] din;
681 input en;
682 input l1clk;
683 input scan_in;
684
685
686 input siclk;
687 input soclk;
688
689 output [127:0] dout;
690 output scan_out;
691assign fdin[127:0] = (din[127:0] & {128{en}}) | (dout[127:0] & ~{128{en}});
692
693
694
695
696
697
698dff #(128) d0_0 (
699.l1clk(l1clk),
700.siclk(siclk),
701.soclk(soclk),
702.d(fdin[127:0]),
703.si({scan_in,so[126:0]}),
704.so({so[126:0],scan_out}),
705.q(dout[127:0])
706);
707
708
709
710
711
712
713
714
715
716
717
718
719endmodule
720
721
722
723
724
725
726
727