Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / mcu / rtl / mcu_pdmchi_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: mcu_pdmchi_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_pdmchi_ctl (
36 pdmc_pde_pending,
37 pdmc_pdx_pending,
38 pdmc_rank_avail,
39 drq0_pd_mode_rd_incr,
40 drq1_pd_mode_rd_incr,
41 drq0_pd_mode_wr_incr,
42 drq1_pd_mode_wr_incr,
43 drif_pd_mode_scrub_incr,
44 drif_pd_mode_err_incr,
45 woq_pd_mode_wr_err_incr,
46 drq0_pd_mode_rd_decr,
47 drq1_pd_mode_rd_decr,
48 woq_pd_mode_wr_decr,
49 drif_pd_mode_scrub_decr,
50 drif_pd_mode_err_decr,
51 woq_pd_mode_wr_err_decr,
52 drif_pdx_issued,
53 drif_pde_issued,
54 fbdic_l0_state,
55 drif_pdmc_enable,
56 drif_refresh_mode,
57 fbdic_scr_frame_req_d4,
58 dal_reg,
59 ral_reg,
60 l1clk,
61 scan_in,
62 scan_out,
63 tcu_aclk,
64 tcu_bclk,
65 tcu_scan_en);
66wire siclk;
67wire soclk;
68wire se;
69wire [2:0] pdmc_pd_cnt_incr;
70wire [5:0] pdmc_pd_cnt_decr;
71wire [5:0] pdmc_pd_cnt_in;
72wire [5:0] pdmc_pd_cnt;
73wire ff_pd_cnt_scanin;
74wire ff_pd_cnt_scanout;
75wire pdmc_pd_cnt_is_zero;
76wire [3:0] pdmc_state;
77wire inv_pdmc_state_in_0;
78wire inv_pdmc_state_0;
79wire ff_pdmc_state_scanin;
80wire ff_pdmc_state_scanout;
81wire pdmc_cke_cnt_is_zero;
82wire pdmc_precharge_cnt_is_zero;
83wire pdmc_xp_cnt_is_zero;
84wire pdmc_cke_reset;
85wire [1:0] pdmc_cke_cnt_in;
86wire [1:0] pdmc_cke_cnt;
87wire ff_cke_cnt_scanin;
88wire ff_cke_cnt_scanout;
89wire pdmc_xp_reset;
90wire [1:0] pdmc_xp_cnt_in;
91wire [1:0] pdmc_xp_cnt;
92wire ff_xp_cnt_scanin;
93wire ff_xp_cnt_scanout;
94wire pdmc_precharge_rd_reset;
95wire pdmc_precharge_wr_reset;
96wire [4:0] pdmc_precharge_cnt_in;
97wire [4:0] pdmc_precharge_cnt;
98wire ff_precharge_cnt_scanin;
99wire ff_precharge_cnt_scanout;
100
101
102output pdmc_pde_pending;
103output pdmc_pdx_pending;
104
105output pdmc_rank_avail;
106
107input drq0_pd_mode_rd_incr;
108input drq1_pd_mode_rd_incr;
109input drq0_pd_mode_wr_incr;
110input drq1_pd_mode_wr_incr;
111input drif_pd_mode_scrub_incr;
112input drif_pd_mode_err_incr;
113input woq_pd_mode_wr_err_incr;
114
115input drq0_pd_mode_rd_decr;
116input drq1_pd_mode_rd_decr;
117input woq_pd_mode_wr_decr;
118input drif_pd_mode_scrub_decr;
119input drif_pd_mode_err_decr;
120input woq_pd_mode_wr_err_decr;
121
122input drif_pdx_issued;
123input drif_pde_issued;
124
125input fbdic_l0_state;
126input drif_pdmc_enable;
127input drif_refresh_mode;
128input fbdic_scr_frame_req_d4;
129
130input [4:0] dal_reg;
131input [4:0] ral_reg;
132
133input l1clk;
134input scan_in;
135output scan_out;
136input tcu_aclk;
137input tcu_bclk;
138input tcu_scan_en;
139
140// Clock header connections
141assign siclk = tcu_aclk;
142assign soclk = tcu_bclk;
143assign se = tcu_scan_en;
144
145// Count the number of pending transactions
146assign pdmc_pd_cnt_incr[2:0] = {2'h0, drq0_pd_mode_rd_incr} + {2'h0, drq0_pd_mode_wr_incr} +
147 {2'h0, drq1_pd_mode_rd_incr} + {2'h0, drq1_pd_mode_wr_incr} +
148 {2'h0, drif_pd_mode_err_incr} + {2'h0, drif_pd_mode_scrub_incr} +
149 {2'h0, woq_pd_mode_wr_err_incr};
150assign pdmc_pd_cnt_decr[5:0] = {5'h0, drq0_pd_mode_rd_decr | drq1_pd_mode_rd_decr |
151 woq_pd_mode_wr_decr | drif_pd_mode_scrub_decr |
152 drif_pd_mode_err_decr | woq_pd_mode_wr_err_decr};
153
154assign pdmc_pd_cnt_in[5:0] = pdmc_pd_cnt[5:0] + {3'h0, pdmc_pd_cnt_incr[2:0]} - pdmc_pd_cnt_decr[5:0];
155
156// 0in overflow -var pdmc_pd_cnt[5:0]
157// 0in underflow -var pdmc_pd_cnt[5:0]
158mcu_pdmchi_ctl_msff_ctl_macro__width_6 ff_pd_cnt (
159 .scan_in(ff_pd_cnt_scanin),
160 .scan_out(ff_pd_cnt_scanout),
161 .din(pdmc_pd_cnt_in[5:0]),
162 .dout(pdmc_pd_cnt[5:0]),
163 .l1clk(l1clk),
164 .siclk(siclk),
165 .soclk(soclk));
166
167assign pdmc_pd_cnt_is_zero = pdmc_pd_cnt[5:0] == 6'h0 & ~drif_refresh_mode;
168
169reg [3:0] pdmc_state_in;
170
171// 0in one_hot -var pdmc_state[3:0]
172always @(pdmc_pd_cnt_is_zero or fbdic_l0_state or drif_pdmc_enable or drif_pde_issued or
173 drif_pdx_issued or pdmc_state or fbdic_scr_frame_req_d4)
174begin
175 pdmc_state_in[3:0] = 4'h0;
176
177 case (1'b1)
178
179 // State 0: In active mode
180 pdmc_state[0] : begin
181 if (pdmc_pd_cnt_is_zero & fbdic_l0_state & drif_pdmc_enable)
182 pdmc_state_in[1] = 1'b1;
183 else
184 pdmc_state_in[0] = 1'b1;
185 end
186
187 // State 1: Entering power down mode
188 pdmc_state[1] : begin
189 if (~fbdic_l0_state | ~drif_pdmc_enable | ~pdmc_pd_cnt_is_zero & ~drif_pde_issued | fbdic_scr_frame_req_d4)
190 pdmc_state_in[0] = 1'b1;
191 else if (drif_pde_issued)
192 pdmc_state_in[2] = 1'b1;
193 else
194 pdmc_state_in[1] = 1'b1;
195 end
196
197 // State 2: In power down mode
198 pdmc_state[2] : begin
199 if (~fbdic_l0_state | fbdic_scr_frame_req_d4)
200 pdmc_state_in[0] = 1'b1;
201 else if (~pdmc_pd_cnt_is_zero | ~drif_pdmc_enable)
202 pdmc_state_in[3] = 1'b1;
203 else
204 pdmc_state_in[2] = 1'b1;
205 end
206
207 // State 3: Exiting power down mode
208 pdmc_state[3] : begin
209 if (~fbdic_l0_state | drif_pdx_issued | fbdic_scr_frame_req_d4)
210 pdmc_state_in[0] = 1'b1;
211 else
212 pdmc_state_in[3] = 1'b1;
213 end
214
215 default: ;
216
217 endcase
218
219end
220
221assign inv_pdmc_state_in_0 = ~pdmc_state_in[0];
222assign pdmc_state[0] = ~inv_pdmc_state_0;
223mcu_pdmchi_ctl_msff_ctl_macro__width_4 ff_pdmc_state (
224 .scan_in(ff_pdmc_state_scanin),
225 .scan_out(ff_pdmc_state_scanout),
226 .din({pdmc_state_in[3:1], inv_pdmc_state_in_0}),
227 .dout({pdmc_state[3:1], inv_pdmc_state_0}),
228 .l1clk(l1clk),
229 .siclk(siclk),
230 .soclk(soclk));
231
232assign pdmc_pde_pending = pdmc_state[1] & pdmc_cke_cnt_is_zero & pdmc_precharge_cnt_is_zero;
233assign pdmc_pdx_pending = pdmc_state[3] & pdmc_cke_cnt_is_zero;
234
235assign pdmc_rank_avail = pdmc_state[0] & pdmc_xp_cnt_is_zero;
236
237// Make sure CKE is asserted or deasserted for tCKE cycles before changing
238assign pdmc_cke_reset = pdmc_state[3] & drif_pdx_issued | pdmc_state[1] & drif_pde_issued;
239assign pdmc_cke_cnt_in[1:0] = pdmc_cke_reset ? 2'h3 : pdmc_cke_cnt_is_zero ? 2'h0 : pdmc_cke_cnt[1:0] - 2'h1;
240mcu_pdmchi_ctl_msff_ctl_macro__width_2 ff_cke_cnt (
241 .scan_in(ff_cke_cnt_scanin),
242 .scan_out(ff_cke_cnt_scanout),
243 .din(pdmc_cke_cnt_in[1:0]),
244 .dout(pdmc_cke_cnt[1:0]),
245 .l1clk(l1clk),
246 .siclk(siclk),
247 .soclk(soclk));
248
249assign pdmc_cke_cnt_is_zero = pdmc_cke_cnt[1:0] == 2'h0;
250
251// Wait for tXP (precharge power down to any command) before enabling rank
252assign pdmc_xp_reset = pdmc_state[3] & drif_pdx_issued;
253assign pdmc_xp_cnt_in[1:0] = pdmc_xp_reset ? 2'h2 : pdmc_xp_cnt_is_zero ? 2'h0 : pdmc_xp_cnt[1:0] - 2'h1;
254mcu_pdmchi_ctl_msff_ctl_macro__width_2 ff_xp_cnt (
255 .scan_in(ff_xp_cnt_scanin),
256 .scan_out(ff_xp_cnt_scanout),
257 .din(pdmc_xp_cnt_in[1:0]),
258 .dout(pdmc_xp_cnt[1:0]),
259 .l1clk(l1clk),
260 .siclk(siclk),
261 .soclk(soclk));
262
263assign pdmc_xp_cnt_is_zero = pdmc_xp_cnt[1:0] == 2'h0;
264
265// Wait for precharge time after a command is issued before going back to power down mode
266assign pdmc_precharge_rd_reset = drq0_pd_mode_rd_decr | drq1_pd_mode_rd_decr |
267 drif_pd_mode_scrub_decr | drif_pd_mode_err_decr;
268assign pdmc_precharge_wr_reset = woq_pd_mode_wr_decr | woq_pd_mode_wr_err_decr;
269assign pdmc_precharge_cnt_in[4:0] = pdmc_precharge_rd_reset ? ral_reg[4:0] :
270 pdmc_precharge_wr_reset ? dal_reg[4:0] :
271 pdmc_precharge_cnt_is_zero ? 5'h0 : pdmc_precharge_cnt[4:0] - 5'h1;
272mcu_pdmchi_ctl_msff_ctl_macro__width_5 ff_precharge_cnt (
273 .scan_in(ff_precharge_cnt_scanin),
274 .scan_out(ff_precharge_cnt_scanout),
275 .din(pdmc_precharge_cnt_in[4:0]),
276 .dout(pdmc_precharge_cnt[4:0]),
277 .l1clk(l1clk),
278 .siclk(siclk),
279 .soclk(soclk));
280
281assign pdmc_precharge_cnt_is_zero = pdmc_precharge_cnt[4:0] == 5'h0;
282
283// fixscan start:
284assign ff_pd_cnt_scanin = scan_in ;
285assign ff_pdmc_state_scanin = ff_pd_cnt_scanout ;
286assign ff_cke_cnt_scanin = ff_pdmc_state_scanout ;
287assign ff_xp_cnt_scanin = ff_cke_cnt_scanout ;
288assign ff_precharge_cnt_scanin = ff_xp_cnt_scanout ;
289assign scan_out = ff_precharge_cnt_scanout ;
290// fixscan end:
291endmodule
292
293
294
295
296
297
298// any PARAMS parms go into naming of macro
299
300module mcu_pdmchi_ctl_msff_ctl_macro__width_6 (
301 din,
302 l1clk,
303 scan_in,
304 siclk,
305 soclk,
306 dout,
307 scan_out);
308wire [5:0] fdin;
309wire [4:0] so;
310
311 input [5:0] din;
312 input l1clk;
313 input scan_in;
314
315
316 input siclk;
317 input soclk;
318
319 output [5:0] dout;
320 output scan_out;
321assign fdin[5:0] = din[5:0];
322
323
324
325
326
327
328dff #(6) d0_0 (
329.l1clk(l1clk),
330.siclk(siclk),
331.soclk(soclk),
332.d(fdin[5:0]),
333.si({scan_in,so[4:0]}),
334.so({so[4:0],scan_out}),
335.q(dout[5:0])
336);
337
338
339
340
341
342
343
344
345
346
347
348
349endmodule
350
351
352
353
354
355
356
357
358
359
360
361
362
363// any PARAMS parms go into naming of macro
364
365module mcu_pdmchi_ctl_msff_ctl_macro__width_4 (
366 din,
367 l1clk,
368 scan_in,
369 siclk,
370 soclk,
371 dout,
372 scan_out);
373wire [3:0] fdin;
374wire [2:0] so;
375
376 input [3:0] din;
377 input l1clk;
378 input scan_in;
379
380
381 input siclk;
382 input soclk;
383
384 output [3:0] dout;
385 output scan_out;
386assign fdin[3:0] = din[3:0];
387
388
389
390
391
392
393dff #(4) d0_0 (
394.l1clk(l1clk),
395.siclk(siclk),
396.soclk(soclk),
397.d(fdin[3:0]),
398.si({scan_in,so[2:0]}),
399.so({so[2:0],scan_out}),
400.q(dout[3:0])
401);
402
403
404
405
406
407
408
409
410
411
412
413
414endmodule
415
416
417
418
419
420
421
422
423
424
425
426
427
428// any PARAMS parms go into naming of macro
429
430module mcu_pdmchi_ctl_msff_ctl_macro__width_2 (
431 din,
432 l1clk,
433 scan_in,
434 siclk,
435 soclk,
436 dout,
437 scan_out);
438wire [1:0] fdin;
439wire [0:0] so;
440
441 input [1:0] din;
442 input l1clk;
443 input scan_in;
444
445
446 input siclk;
447 input soclk;
448
449 output [1:0] dout;
450 output scan_out;
451assign fdin[1:0] = din[1:0];
452
453
454
455
456
457
458dff #(2) d0_0 (
459.l1clk(l1clk),
460.siclk(siclk),
461.soclk(soclk),
462.d(fdin[1:0]),
463.si({scan_in,so[0:0]}),
464.so({so[0:0],scan_out}),
465.q(dout[1:0])
466);
467
468
469
470
471
472
473
474
475
476
477
478
479endmodule
480
481
482
483
484
485
486
487
488
489
490
491
492
493// any PARAMS parms go into naming of macro
494
495module mcu_pdmchi_ctl_msff_ctl_macro__width_5 (
496 din,
497 l1clk,
498 scan_in,
499 siclk,
500 soclk,
501 dout,
502 scan_out);
503wire [4:0] fdin;
504wire [3:0] so;
505
506 input [4:0] din;
507 input l1clk;
508 input scan_in;
509
510
511 input siclk;
512 input soclk;
513
514 output [4:0] dout;
515 output scan_out;
516assign fdin[4:0] = din[4:0];
517
518
519
520
521
522
523dff #(5) d0_0 (
524.l1clk(l1clk),
525.siclk(siclk),
526.soclk(soclk),
527.d(fdin[4:0]),
528.si({scan_in,so[3:0]}),
529.so({so[3:0],scan_out}),
530.q(dout[4:0])
531);
532
533
534
535
536
537
538
539
540
541
542
543
544endmodule
545
546
547
548
549
550
551
552