Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / mcu / rtl / mcu_dmmdly_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: mcu_dmmdly_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_dmmdly_ctl (
36 rrd_cnt_is_zero,
37 rtw_cnt_is_zero,
38 wtr_cnt_is_zero,
39 rtr_cnt_is_zero,
40 wtw_cnt_is_zero,
41 dmmdly_4_activate_stall,
42 rrd_reg,
43 rtw_reg,
44 wtr_reg,
45 faw_reg,
46 drif_rd_ras_picked,
47 drif_wr_ras_picked,
48 drif_wrbc_ras_picked,
49 fbdic_sync_frame_req_l,
50 l1clk,
51 scan_in,
52 scan_out,
53 tcu_aclk,
54 tcu_bclk,
55 tcu_scan_en);
56wire siclk;
57wire soclk;
58wire se;
59wire drif_ras_picked;
60wire [3:0] rrd_cnt_next;
61wire [3:0] rrd_cnt;
62wire ff_rrd_cnt_scanin;
63wire ff_rrd_cnt_scanout;
64wire [3:0] rtw_cnt_next;
65wire [3:0] rtw_cnt;
66wire ff_rtw_cnt_scanin;
67wire ff_rtw_cnt_scanout;
68wire [3:0] wtr_cnt_next;
69wire [3:0] wtr_cnt;
70wire ff_wtr_cnt_scanin;
71wire ff_wtr_cnt_scanout;
72wire rtr_cnt_next;
73wire dmmdly_rd_cas_picked;
74wire rtr_cnt;
75wire ff_rtr_cnt_scanin;
76wire ff_rtr_cnt_scanout;
77wire [1:0] wtw_cnt_next;
78wire dmmdly_wr_cas_picked;
79wire dmmdly_wrbc_cas_picked;
80wire [1:0] wtw_cnt;
81wire ff_wtw_cnt_scanin;
82wire ff_wtw_cnt_scanout;
83wire drif_activate_cmd;
84wire [4:0] faw0_cnt_in;
85wire faw0_cnt_is_zero;
86wire [4:0] faw0_cnt;
87wire ff_faw0_cnt_scanin;
88wire ff_faw0_cnt_scanout;
89wire [4:0] faw1_cnt_in;
90wire faw1_cnt_is_zero;
91wire [4:0] faw1_cnt;
92wire ff_faw1_cnt_scanin;
93wire ff_faw1_cnt_scanout;
94wire [4:0] faw2_cnt_in;
95wire faw2_cnt_is_zero;
96wire [4:0] faw2_cnt;
97wire ff_faw2_cnt_scanin;
98wire ff_faw2_cnt_scanout;
99wire [4:0] faw3_cnt_in;
100wire faw3_cnt_is_zero;
101wire [4:0] faw3_cnt;
102wire ff_faw3_cnt_scanin;
103wire ff_faw3_cnt_scanout;
104wire ff_cas_picked_scanin;
105wire ff_cas_picked_scanout;
106
107
108output rrd_cnt_is_zero;
109output rtw_cnt_is_zero;
110output wtr_cnt_is_zero;
111output rtr_cnt_is_zero;
112output wtw_cnt_is_zero;
113output dmmdly_4_activate_stall;
114
115input [3:0] rrd_reg;
116input [3:0] rtw_reg;
117input [3:0] wtr_reg;
118input [4:0] faw_reg;
119
120input drif_rd_ras_picked;
121input drif_wr_ras_picked;
122input drif_wrbc_ras_picked;
123
124input fbdic_sync_frame_req_l;
125
126input l1clk;
127input scan_in;
128output scan_out;
129input tcu_aclk;
130input tcu_bclk;
131input tcu_scan_en;
132
133assign siclk = tcu_aclk;
134assign soclk = tcu_bclk;
135assign se = tcu_scan_en;
136
137assign drif_ras_picked = drif_rd_ras_picked | drif_wr_ras_picked;
138
139// ras to ras (bankA to bankB) delay timer.
140assign rrd_cnt_next[3:0] = drif_ras_picked & rrd_cnt_is_zero ? rrd_reg[3:0] - 4'h1 :
141 drif_wrbc_ras_picked & rrd_cnt_is_zero ? rrd_reg[3:0] :
142 (rrd_cnt[3:0] == 4'h0) ? 4'h0 :
143 fbdic_sync_frame_req_l ? rrd_cnt[3:0] - 4'h1 : rrd_cnt[3:0];
144
145mcu_dmmdly_ctl_msff_ctl_macro__width_4 ff_rrd_cnt (
146 .scan_in(ff_rrd_cnt_scanin),
147 .scan_out(ff_rrd_cnt_scanout),
148 .din(rrd_cnt_next[3:0]),
149 .dout(rrd_cnt[3:0]),
150 .l1clk(l1clk),
151 .siclk(siclk),
152 .soclk(soclk));
153
154assign rrd_cnt_is_zero = (rrd_cnt[3:0] == 4'h0);
155
156// read to write cas to cas (bankA to bankA/bankB) delay timer for not clashing read and write data.
157// If read is picked during cas assert rtw_cnt to regular cnt + rtw delay.
158assign rtw_cnt_next[3:0] = drif_rd_ras_picked ? rtw_reg[3:0] :
159 (rtw_cnt[3:0] == 4'h0) ? 4'h0 :
160 fbdic_sync_frame_req_l ? rtw_cnt[3:0] - 4'h1 : rtw_cnt[3:0];
161
162mcu_dmmdly_ctl_msff_ctl_macro__width_4 ff_rtw_cnt (
163 .scan_in(ff_rtw_cnt_scanin),
164 .scan_out(ff_rtw_cnt_scanout),
165 .din(rtw_cnt_next[3:0]),
166 .dout(rtw_cnt[3:0]),
167 .l1clk(l1clk),
168 .siclk(siclk),
169 .soclk(soclk));
170
171assign rtw_cnt_is_zero = (rtw_cnt[3:0] == 4'h0);
172
173// write to read cas to cas (bankA to bankA/bankB) delay timer for not clashing read and write data.
174assign wtr_cnt_next[3:0] = drif_wr_ras_picked ? wtr_reg[3:0] :
175 drif_wrbc_ras_picked ? wtr_reg[3:0] + 4'h1:
176 (wtr_cnt[3:0] == 4'h0) ? 4'h0 :
177 fbdic_sync_frame_req_l ? wtr_cnt[3:0] - 4'h1 : wtr_cnt[3:0];
178
179mcu_dmmdly_ctl_msff_ctl_macro__width_4 ff_wtr_cnt (
180 .scan_in(ff_wtr_cnt_scanin),
181 .scan_out(ff_wtr_cnt_scanout),
182 .din(wtr_cnt_next[3:0]),
183 .dout(wtr_cnt[3:0]),
184 .l1clk(l1clk),
185 .siclk(siclk),
186 .soclk(soclk));
187
188assign wtr_cnt_is_zero = (wtr_cnt[3:0] == 4'h0);
189
190// read to read cas to cas (bankA to bankA/bankB) delay timer for not clashing read data.
191assign rtr_cnt_next = dmmdly_rd_cas_picked & fbdic_sync_frame_req_l ? 1'h1 :
192 (rtr_cnt == 1'h0) ? 1'h0 : rtr_cnt - 1'h1;
193
194mcu_dmmdly_ctl_msff_ctl_macro__width_1 ff_rtr_cnt (
195 .scan_in(ff_rtr_cnt_scanin),
196 .scan_out(ff_rtr_cnt_scanout),
197 .din(rtr_cnt_next),
198 .dout(rtr_cnt),
199 .l1clk(l1clk),
200 .siclk(siclk),
201 .soclk(soclk));
202
203assign rtr_cnt_is_zero = (rtr_cnt == 1'h0);
204
205// write to write cas to cas (bankA to bankA/bankB) delay timer for not clashing store data.
206assign wtw_cnt_next[1:0] = dmmdly_wr_cas_picked & fbdic_sync_frame_req_l ? 2'h1 :
207 dmmdly_wrbc_cas_picked & fbdic_sync_frame_req_l ? 2'h1 :
208 (wtw_cnt[1:0] == 2'h0) ? 2'h0 : wtw_cnt[1:0] - 2'h1;
209
210mcu_dmmdly_ctl_msff_ctl_macro__width_2 ff_wtw_cnt (
211 .scan_in(ff_wtw_cnt_scanin),
212 .scan_out(ff_wtw_cnt_scanout),
213 .din(wtw_cnt_next[1:0]),
214 .dout(wtw_cnt[1:0]),
215 .l1clk(l1clk),
216 .siclk(siclk),
217 .soclk(soclk));
218
219assign wtw_cnt_is_zero = (wtw_cnt[1:0] == 2'h0);
220
221//////////////////////////////////////////////////////////////////
222// Limit number of activates within tFAW to 4
223// Whenever an activate cmd is detected, a counter is started at
224// the tFAW value. If all four counters are active, then the scheduler
225// is stalled until one becomes inactive.
226//////////////////////////////////////////////////////////////////
227
228assign drif_activate_cmd = drif_rd_ras_picked | drif_wr_ras_picked | drif_wrbc_ras_picked;
229
230assign faw0_cnt_in[4:0] = faw0_cnt_is_zero & drif_activate_cmd & fbdic_sync_frame_req_l ? faw_reg[4:0] - 5'h1 :
231 faw0_cnt_is_zero ? 5'h0 : faw0_cnt[4:0] - 5'h1;
232
233mcu_dmmdly_ctl_msff_ctl_macro__en_0__width_5 ff_faw0_cnt (
234 .scan_in(ff_faw0_cnt_scanin),
235 .scan_out(ff_faw0_cnt_scanout),
236 .din(faw0_cnt_in[4:0]),
237 .dout(faw0_cnt[4:0]),
238// .en(drif_sync_frame_req_l),
239 .l1clk(l1clk),
240 .siclk(siclk),
241 .soclk(soclk));
242
243assign faw0_cnt_is_zero = (faw0_cnt[4:0] == 5'h0);
244
245assign faw1_cnt_in[4:0] = faw1_cnt_is_zero & ~faw0_cnt_is_zero & drif_activate_cmd & fbdic_sync_frame_req_l ? faw_reg[4:0] - 5'h1 :
246 faw1_cnt_is_zero ? 5'h0 : faw1_cnt[4:0] - 5'h1;
247
248mcu_dmmdly_ctl_msff_ctl_macro__en_0__width_5 ff_faw1_cnt (
249 .scan_in(ff_faw1_cnt_scanin),
250 .scan_out(ff_faw1_cnt_scanout),
251 .din(faw1_cnt_in[4:0]),
252 .dout(faw1_cnt[4:0]),
253// .en(drif_sync_frame_req_l),
254 .l1clk(l1clk),
255 .siclk(siclk),
256 .soclk(soclk));
257
258assign faw1_cnt_is_zero = (faw1_cnt[4:0] == 5'h0);
259
260assign faw2_cnt_in[4:0] = faw2_cnt_is_zero & ~faw1_cnt_is_zero & ~faw0_cnt_is_zero & drif_activate_cmd & fbdic_sync_frame_req_l ? faw_reg[4:0] - 5'h1 :
261 faw2_cnt_is_zero ? 5'h0 : faw2_cnt[4:0] - 5'h1;
262
263mcu_dmmdly_ctl_msff_ctl_macro__en_0__width_5 ff_faw2_cnt (
264 .scan_in(ff_faw2_cnt_scanin),
265 .scan_out(ff_faw2_cnt_scanout),
266 .din(faw2_cnt_in[4:0]),
267 .dout(faw2_cnt[4:0]),
268// .en(drif_sync_frame_req_l),
269 .l1clk(l1clk),
270 .siclk(siclk),
271 .soclk(soclk));
272
273assign faw2_cnt_is_zero = (faw2_cnt[4:0] == 5'h0);
274
275assign faw3_cnt_in[4:0] = faw3_cnt_is_zero & ~faw2_cnt_is_zero & ~faw1_cnt_is_zero & ~faw0_cnt_is_zero & drif_activate_cmd & fbdic_sync_frame_req_l ?
276 faw_reg[4:0] - 5'h1 : faw3_cnt_is_zero ? 5'h0 : faw3_cnt[4:0] - 5'h1;
277
278mcu_dmmdly_ctl_msff_ctl_macro__en_0__width_5 ff_faw3_cnt (
279 .scan_in(ff_faw3_cnt_scanin),
280 .scan_out(ff_faw3_cnt_scanout),
281 .din(faw3_cnt_in[4:0]),
282 .dout(faw3_cnt[4:0]),
283// .en(drif_sync_frame_req_l),
284 .l1clk(l1clk),
285 .siclk(siclk),
286 .soclk(soclk));
287
288assign faw3_cnt_is_zero = (faw3_cnt[4:0] == 5'h0);
289
290assign dmmdly_4_activate_stall = ~faw0_cnt_is_zero & ~faw1_cnt_is_zero & ~faw2_cnt_is_zero & ~faw3_cnt_is_zero;
291
292mcu_dmmdly_ctl_msff_ctl_macro__width_3 ff_cas_picked (
293 .scan_in(ff_cas_picked_scanin),
294 .scan_out(ff_cas_picked_scanout),
295 .din({drif_rd_ras_picked,drif_wr_ras_picked,drif_wrbc_ras_picked}),
296 .dout({dmmdly_rd_cas_picked,dmmdly_wr_cas_picked,dmmdly_wrbc_cas_picked}),
297 .l1clk(l1clk),
298 .siclk(siclk),
299 .soclk(soclk));
300
301// fixscan start:
302assign ff_rrd_cnt_scanin = scan_in ;
303assign ff_rtw_cnt_scanin = ff_rrd_cnt_scanout ;
304assign ff_wtr_cnt_scanin = ff_rtw_cnt_scanout ;
305assign ff_rtr_cnt_scanin = ff_wtr_cnt_scanout ;
306assign ff_wtw_cnt_scanin = ff_rtr_cnt_scanout ;
307assign ff_faw0_cnt_scanin = ff_wtw_cnt_scanout ;
308assign ff_faw1_cnt_scanin = ff_faw0_cnt_scanout ;
309assign ff_faw2_cnt_scanin = ff_faw1_cnt_scanout ;
310assign ff_faw3_cnt_scanin = ff_faw2_cnt_scanout ;
311assign ff_cas_picked_scanin = ff_faw3_cnt_scanout ;
312assign scan_out = ff_cas_picked_scanout ;
313// fixscan end:
314endmodule
315
316
317
318
319
320
321// any PARAMS parms go into naming of macro
322
323module mcu_dmmdly_ctl_msff_ctl_macro__width_4 (
324 din,
325 l1clk,
326 scan_in,
327 siclk,
328 soclk,
329 dout,
330 scan_out);
331wire [3:0] fdin;
332wire [2:0] so;
333
334 input [3:0] din;
335 input l1clk;
336 input scan_in;
337
338
339 input siclk;
340 input soclk;
341
342 output [3:0] dout;
343 output scan_out;
344assign fdin[3:0] = din[3:0];
345
346
347
348
349
350
351dff #(4) d0_0 (
352.l1clk(l1clk),
353.siclk(siclk),
354.soclk(soclk),
355.d(fdin[3:0]),
356.si({scan_in,so[2:0]}),
357.so({so[2:0],scan_out}),
358.q(dout[3:0])
359);
360
361
362
363
364
365
366
367
368
369
370
371
372endmodule
373
374
375
376
377
378
379
380
381
382
383
384
385
386// any PARAMS parms go into naming of macro
387
388module mcu_dmmdly_ctl_msff_ctl_macro__width_1 (
389 din,
390 l1clk,
391 scan_in,
392 siclk,
393 soclk,
394 dout,
395 scan_out);
396wire [0:0] fdin;
397
398 input [0:0] din;
399 input l1clk;
400 input scan_in;
401
402
403 input siclk;
404 input soclk;
405
406 output [0:0] dout;
407 output scan_out;
408assign fdin[0:0] = din[0:0];
409
410
411
412
413
414
415dff #(1) d0_0 (
416.l1clk(l1clk),
417.siclk(siclk),
418.soclk(soclk),
419.d(fdin[0:0]),
420.si(scan_in),
421.so(scan_out),
422.q(dout[0:0])
423);
424
425
426
427
428
429
430
431
432
433
434
435
436endmodule
437
438
439
440
441
442
443
444
445
446
447
448
449
450// any PARAMS parms go into naming of macro
451
452module mcu_dmmdly_ctl_msff_ctl_macro__width_2 (
453 din,
454 l1clk,
455 scan_in,
456 siclk,
457 soclk,
458 dout,
459 scan_out);
460wire [1:0] fdin;
461wire [0:0] so;
462
463 input [1:0] din;
464 input l1clk;
465 input scan_in;
466
467
468 input siclk;
469 input soclk;
470
471 output [1:0] dout;
472 output scan_out;
473assign fdin[1:0] = din[1:0];
474
475
476
477
478
479
480dff #(2) d0_0 (
481.l1clk(l1clk),
482.siclk(siclk),
483.soclk(soclk),
484.d(fdin[1:0]),
485.si({scan_in,so[0:0]}),
486.so({so[0:0],scan_out}),
487.q(dout[1:0])
488);
489
490
491
492
493
494
495
496
497
498
499
500
501endmodule
502
503
504
505
506
507
508
509
510
511
512
513
514
515// any PARAMS parms go into naming of macro
516
517module mcu_dmmdly_ctl_msff_ctl_macro__en_0__width_5 (
518 din,
519 l1clk,
520 scan_in,
521 siclk,
522 soclk,
523 dout,
524 scan_out);
525wire [4:0] fdin;
526wire [3:0] so;
527
528 input [4:0] din;
529 input l1clk;
530 input scan_in;
531
532
533 input siclk;
534 input soclk;
535
536 output [4:0] dout;
537 output scan_out;
538assign fdin[4:0] = din[4:0];
539
540
541
542
543
544
545dff #(5) d0_0 (
546.l1clk(l1clk),
547.siclk(siclk),
548.soclk(soclk),
549.d(fdin[4:0]),
550.si({scan_in,so[3:0]}),
551.so({so[3:0],scan_out}),
552.q(dout[4:0])
553);
554
555
556
557
558
559
560
561
562
563
564
565
566endmodule
567
568
569
570
571
572
573
574
575
576
577
578
579
580// any PARAMS parms go into naming of macro
581
582module mcu_dmmdly_ctl_msff_ctl_macro__width_3 (
583 din,
584 l1clk,
585 scan_in,
586 siclk,
587 soclk,
588 dout,
589 scan_out);
590wire [2:0] fdin;
591wire [1:0] so;
592
593 input [2:0] din;
594 input l1clk;
595 input scan_in;
596
597
598 input siclk;
599 input soclk;
600
601 output [2:0] dout;
602 output scan_out;
603assign fdin[2:0] = din[2:0];
604
605
606
607
608
609
610dff #(3) d0_0 (
611.l1clk(l1clk),
612.siclk(siclk),
613.soclk(soclk),
614.d(fdin[2:0]),
615.si({scan_in,so[1:0]}),
616.so({so[1:0],scan_out}),
617.q(dout[2:0])
618);
619
620
621
622
623
624
625
626
627
628
629
630
631endmodule
632
633
634
635
636
637
638
639