Commit | Line | Data |
---|---|---|
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 ============================================ | |
35 | module 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); | |
66 | wire siclk; | |
67 | wire soclk; | |
68 | wire se; | |
69 | wire [2:0] pdmc_pd_cnt_incr; | |
70 | wire [5:0] pdmc_pd_cnt_decr; | |
71 | wire [5:0] pdmc_pd_cnt_in; | |
72 | wire [5:0] pdmc_pd_cnt; | |
73 | wire ff_pd_cnt_scanin; | |
74 | wire ff_pd_cnt_scanout; | |
75 | wire pdmc_pd_cnt_is_zero; | |
76 | wire [3:0] pdmc_state; | |
77 | wire inv_pdmc_state_in_0; | |
78 | wire inv_pdmc_state_0; | |
79 | wire ff_pdmc_state_scanin; | |
80 | wire ff_pdmc_state_scanout; | |
81 | wire pdmc_cke_cnt_is_zero; | |
82 | wire pdmc_precharge_cnt_is_zero; | |
83 | wire pdmc_xp_cnt_is_zero; | |
84 | wire pdmc_cke_reset; | |
85 | wire [1:0] pdmc_cke_cnt_in; | |
86 | wire [1:0] pdmc_cke_cnt; | |
87 | wire ff_cke_cnt_scanin; | |
88 | wire ff_cke_cnt_scanout; | |
89 | wire pdmc_xp_reset; | |
90 | wire [1:0] pdmc_xp_cnt_in; | |
91 | wire [1:0] pdmc_xp_cnt; | |
92 | wire ff_xp_cnt_scanin; | |
93 | wire ff_xp_cnt_scanout; | |
94 | wire pdmc_precharge_rd_reset; | |
95 | wire pdmc_precharge_wr_reset; | |
96 | wire [4:0] pdmc_precharge_cnt_in; | |
97 | wire [4:0] pdmc_precharge_cnt; | |
98 | wire ff_precharge_cnt_scanin; | |
99 | wire ff_precharge_cnt_scanout; | |
100 | ||
101 | ||
102 | output pdmc_pde_pending; | |
103 | output pdmc_pdx_pending; | |
104 | ||
105 | output pdmc_rank_avail; | |
106 | ||
107 | input drq0_pd_mode_rd_incr; | |
108 | input drq1_pd_mode_rd_incr; | |
109 | input drq0_pd_mode_wr_incr; | |
110 | input drq1_pd_mode_wr_incr; | |
111 | input drif_pd_mode_scrub_incr; | |
112 | input drif_pd_mode_err_incr; | |
113 | input woq_pd_mode_wr_err_incr; | |
114 | ||
115 | input drq0_pd_mode_rd_decr; | |
116 | input drq1_pd_mode_rd_decr; | |
117 | input woq_pd_mode_wr_decr; | |
118 | input drif_pd_mode_scrub_decr; | |
119 | input drif_pd_mode_err_decr; | |
120 | input woq_pd_mode_wr_err_decr; | |
121 | ||
122 | input drif_pdx_issued; | |
123 | input drif_pde_issued; | |
124 | ||
125 | input fbdic_l0_state; | |
126 | input drif_pdmc_enable; | |
127 | input drif_refresh_mode; | |
128 | input fbdic_scr_frame_req_d4; | |
129 | ||
130 | input [4:0] dal_reg; | |
131 | input [4:0] ral_reg; | |
132 | ||
133 | input l1clk; | |
134 | input scan_in; | |
135 | output scan_out; | |
136 | input tcu_aclk; | |
137 | input tcu_bclk; | |
138 | input tcu_scan_en; | |
139 | ||
140 | // Clock header connections | |
141 | assign siclk = tcu_aclk; | |
142 | assign soclk = tcu_bclk; | |
143 | assign se = tcu_scan_en; | |
144 | ||
145 | // Count the number of pending transactions | |
146 | assign 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}; | |
150 | assign 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 | ||
154 | assign 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] | |
158 | mcu_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 | ||
167 | assign pdmc_pd_cnt_is_zero = pdmc_pd_cnt[5:0] == 6'h0 & ~drif_refresh_mode; | |
168 | ||
169 | reg [3:0] pdmc_state_in; | |
170 | ||
171 | // 0in one_hot -var pdmc_state[3:0] | |
172 | always @(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) | |
174 | begin | |
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 | ||
219 | end | |
220 | ||
221 | assign inv_pdmc_state_in_0 = ~pdmc_state_in[0]; | |
222 | assign pdmc_state[0] = ~inv_pdmc_state_0; | |
223 | mcu_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 | ||
232 | assign pdmc_pde_pending = pdmc_state[1] & pdmc_cke_cnt_is_zero & pdmc_precharge_cnt_is_zero; | |
233 | assign pdmc_pdx_pending = pdmc_state[3] & pdmc_cke_cnt_is_zero; | |
234 | ||
235 | assign 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 | |
238 | assign pdmc_cke_reset = pdmc_state[3] & drif_pdx_issued | pdmc_state[1] & drif_pde_issued; | |
239 | assign 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; | |
240 | mcu_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 | ||
249 | assign 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 | |
252 | assign pdmc_xp_reset = pdmc_state[3] & drif_pdx_issued; | |
253 | assign 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; | |
254 | mcu_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 | ||
263 | assign 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 | |
266 | assign 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; | |
268 | assign pdmc_precharge_wr_reset = woq_pd_mode_wr_decr | woq_pd_mode_wr_err_decr; | |
269 | assign 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; | |
272 | mcu_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 | ||
281 | assign pdmc_precharge_cnt_is_zero = pdmc_precharge_cnt[4:0] == 5'h0; | |
282 | ||
283 | // fixscan start: | |
284 | assign ff_pd_cnt_scanin = scan_in ; | |
285 | assign ff_pdmc_state_scanin = ff_pd_cnt_scanout ; | |
286 | assign ff_cke_cnt_scanin = ff_pdmc_state_scanout ; | |
287 | assign ff_xp_cnt_scanin = ff_cke_cnt_scanout ; | |
288 | assign ff_precharge_cnt_scanin = ff_xp_cnt_scanout ; | |
289 | assign scan_out = ff_precharge_cnt_scanout ; | |
290 | // fixscan end: | |
291 | endmodule | |
292 | ||
293 | ||
294 | ||
295 | ||
296 | ||
297 | ||
298 | // any PARAMS parms go into naming of macro | |
299 | ||
300 | module mcu_pdmchi_ctl_msff_ctl_macro__width_6 ( | |
301 | din, | |
302 | l1clk, | |
303 | scan_in, | |
304 | siclk, | |
305 | soclk, | |
306 | dout, | |
307 | scan_out); | |
308 | wire [5:0] fdin; | |
309 | wire [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; | |
321 | assign fdin[5:0] = din[5:0]; | |
322 | ||
323 | ||
324 | ||
325 | ||
326 | ||
327 | ||
328 | dff #(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 | ||
349 | endmodule | |
350 | ||
351 | ||
352 | ||
353 | ||
354 | ||
355 | ||
356 | ||
357 | ||
358 | ||
359 | ||
360 | ||
361 | ||
362 | ||
363 | // any PARAMS parms go into naming of macro | |
364 | ||
365 | module mcu_pdmchi_ctl_msff_ctl_macro__width_4 ( | |
366 | din, | |
367 | l1clk, | |
368 | scan_in, | |
369 | siclk, | |
370 | soclk, | |
371 | dout, | |
372 | scan_out); | |
373 | wire [3:0] fdin; | |
374 | wire [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; | |
386 | assign fdin[3:0] = din[3:0]; | |
387 | ||
388 | ||
389 | ||
390 | ||
391 | ||
392 | ||
393 | dff #(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 | ||
414 | endmodule | |
415 | ||
416 | ||
417 | ||
418 | ||
419 | ||
420 | ||
421 | ||
422 | ||
423 | ||
424 | ||
425 | ||
426 | ||
427 | ||
428 | // any PARAMS parms go into naming of macro | |
429 | ||
430 | module mcu_pdmchi_ctl_msff_ctl_macro__width_2 ( | |
431 | din, | |
432 | l1clk, | |
433 | scan_in, | |
434 | siclk, | |
435 | soclk, | |
436 | dout, | |
437 | scan_out); | |
438 | wire [1:0] fdin; | |
439 | wire [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; | |
451 | assign fdin[1:0] = din[1:0]; | |
452 | ||
453 | ||
454 | ||
455 | ||
456 | ||
457 | ||
458 | dff #(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 | ||
479 | endmodule | |
480 | ||
481 | ||
482 | ||
483 | ||
484 | ||
485 | ||
486 | ||
487 | ||
488 | ||
489 | ||
490 | ||
491 | ||
492 | ||
493 | // any PARAMS parms go into naming of macro | |
494 | ||
495 | module mcu_pdmchi_ctl_msff_ctl_macro__width_5 ( | |
496 | din, | |
497 | l1clk, | |
498 | scan_in, | |
499 | siclk, | |
500 | soclk, | |
501 | dout, | |
502 | scan_out); | |
503 | wire [4:0] fdin; | |
504 | wire [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; | |
516 | assign fdin[4:0] = din[4:0]; | |
517 | ||
518 | ||
519 | ||
520 | ||
521 | ||
522 | ||
523 | dff #(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 | ||
544 | endmodule | |
545 | ||
546 | ||
547 | ||
548 | ||
549 | ||
550 | ||
551 | ||
552 |