Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / niu / rtl / fflp_fcram_cntl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: fflp_fcram_cntl.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/*project name: N2 */
37/*module name: fflp_fcram_cntl */
38/*description: FCRAM access protocol */
39/* */
40/*parent module in: fflp_fcram_top */
41/*child modules in: fflp_fcram_cntl_sm */
42/*interface modules: */
43/*author name: Jeanne Cai */
44/*date created: 04-08-04 */
45/* */
46/* Copyright (c) 2004, Sun Microsystems, Inc. */
47/* Sun Proprietary and Confidential */
48/* */
49/*modifications: */
50/* */
51/* */
52
53
54module fflp_fcram_cntl (
55 cclk,
56 reset,
57 disable_chksum,
58 pio_fio_latency,
59 fflp_init_done,
60 fcram_refresh_timer_reg_dout,
61 flow_part_sel_reg0_dout,
62 flow_part_sel_reg1_dout,
63 flow_part_sel_reg2_dout,
64 flow_part_sel_reg3_dout,
65 flow_part_sel_reg4_dout,
66 flow_part_sel_reg5_dout,
67 flow_part_sel_reg6_dout,
68 flow_part_sel_reg7_dout,
69 hash_tbl_addr_reg0_dout,
70 hash_tbl_addr_reg1_dout,
71 hash_tbl_addr_reg2_dout,
72 hash_tbl_addr_reg3_dout,
73 hash_tbl_addr_reg4_dout,
74 hash_tbl_addr_reg5_dout,
75 hash_tbl_addr_reg6_dout,
76 hash_tbl_addr_reg7_dout,
77 hash_tbl_data_reg0_dout,
78 hash_tbl_data_reg1_dout,
79 hash_tbl_data_reg2_dout,
80 hash_tbl_data_reg3_dout,
81 hash_tbl_data_reg4_dout,
82 hash_tbl_data_reg5_dout,
83 hash_tbl_data_reg6_dout,
84 hash_tbl_data_reg7_dout,
85 fcram_err_test_reg_dout,
86 cpu_req_part0_sel,
87 cpu_req_part1_sel,
88 cpu_req_part2_sel,
89 cpu_req_part3_sel,
90 cpu_req_part4_sel,
91 cpu_req_part5_sel,
92 cpu_req_part6_sel,
93 cpu_req_part7_sel,
94 pio_rd,
95 pio_wr_data,
96 pio_fio_cfg_reset,
97 fio_cfg_addr_reg_dout,
98 cpu_fio_req_sync,
99 fcram_driver_imp_ctrl,
100 fcram_qs_mode,
101 srch_no_fc_done,
102 do_srch_cycle,
103 do_cpu_cycle,
104 merg_bus_0_hash_v1,
105 merg_bus_0_rdc_tbl_num,
106 merg_bus_1_fc_lookup,
107 fcram_fflp_mstrready,
108 fcram_fflp_fatal_err,
109 fcram_fflp_data_ready,
110 fcram_fflp_even_din,
111 fcram_fflp_odd_din,
112 fcram_fflp_cfg_datrd,
113 fcram_fflp_cfg_done,
114 fcram_fflp_cfg_err,
115
116 fflp_fcram_cfg_rst,
117 fflp_fcram_cfg_sel,
118 fflp_fcram_cfg_rd,
119 fflp_fcram_cfg_addr,
120 fflp_fcram_cfg_datwr,
121 fflp_fcram_slv_update,
122 fflp_fcram_rd_en,
123 fflp_fcram_cs_l,
124 fflp_fcram_fn,
125 fflp_fcram_pd_l,
126 fflp_fcram_ba0,
127 fflp_fcram_ba1,
128 fflp_fcram_addr,
129 fflp_fcram_ds,
130 fflp_fcram_triz_en_l,
131 fflp_fcram_even_dout,
132 fflp_fcram_odd_dout,
133 fc_din_reg_dout_r,
134 ecc_check_err_r,
135 ecc_corr_err_r,
136 fio_no_fatal_err,
137 srch_burst_done,
138 cpu_burst_done_sm,
139 fcram_sm_state,
140 srch_burst_done_2, //second pipe
141 srch_fio_wait_6, //third pipe
142 srch_fio_rd_en_4, //4th pipe
143 cpu_fc_req_done,
144 fc_rd_data_reg_dout,
145 fc_rd_ecc_err,
146 cpu_fio_req_done, //fio pio req done
147 cpu_fio_rd_data,
148 fio_cal_rd_latency
149
150 );
151
152input cclk;
153input reset;
154input[1:0] pio_fio_latency;
155input disable_chksum;
156input fflp_init_done;
157input[31:0] fcram_refresh_timer_reg_dout;
158input[9:0] flow_part_sel_reg0_dout;
159input[9:0] flow_part_sel_reg1_dout;
160input[9:0] flow_part_sel_reg2_dout;
161input[9:0] flow_part_sel_reg3_dout;
162input[9:0] flow_part_sel_reg4_dout;
163input[9:0] flow_part_sel_reg5_dout;
164input[9:0] flow_part_sel_reg6_dout;
165input[9:0] flow_part_sel_reg7_dout;
166input[23:0] hash_tbl_addr_reg0_dout;
167input[23:0] hash_tbl_addr_reg1_dout;
168input[23:0] hash_tbl_addr_reg2_dout;
169input[23:0] hash_tbl_addr_reg3_dout;
170input[23:0] hash_tbl_addr_reg4_dout;
171input[23:0] hash_tbl_addr_reg5_dout;
172input[23:0] hash_tbl_addr_reg6_dout;
173input[23:0] hash_tbl_addr_reg7_dout;
174input[63:0] hash_tbl_data_reg0_dout;
175input[63:0] hash_tbl_data_reg1_dout;
176input[63:0] hash_tbl_data_reg2_dout;
177input[63:0] hash_tbl_data_reg3_dout;
178input[63:0] hash_tbl_data_reg4_dout;
179input[63:0] hash_tbl_data_reg5_dout;
180input[63:0] hash_tbl_data_reg6_dout;
181input[63:0] hash_tbl_data_reg7_dout;
182input[71:0] fcram_err_test_reg_dout;
183input cpu_req_part0_sel;
184input cpu_req_part1_sel;
185input cpu_req_part2_sel;
186input cpu_req_part3_sel;
187input cpu_req_part4_sel;
188input cpu_req_part5_sel;
189input cpu_req_part6_sel;
190input cpu_req_part7_sel;
191input pio_rd;
192input[15:0] pio_wr_data;
193input pio_fio_cfg_reset;
194input[7:0] fio_cfg_addr_reg_dout;
195input cpu_fio_req_sync;
196input[3:0] fcram_driver_imp_ctrl;
197input fcram_qs_mode;
198input srch_no_fc_done;
199input do_srch_cycle;
200input do_cpu_cycle;
201input[19:0] merg_bus_0_hash_v1;
202input[2:0] merg_bus_0_rdc_tbl_num;
203input merg_bus_1_fc_lookup;
204input fcram_fflp_mstrready;
205input fcram_fflp_fatal_err;
206input[3:0] fcram_fflp_data_ready;
207input[35:0] fcram_fflp_even_din;
208input[35:0] fcram_fflp_odd_din;
209input[15:0] fcram_fflp_cfg_datrd;
210input fcram_fflp_cfg_done;
211input fcram_fflp_cfg_err;
212
213output fflp_fcram_cfg_rst;
214output fflp_fcram_cfg_sel;
215output fflp_fcram_cfg_rd;
216output[7:0] fflp_fcram_cfg_addr;
217output[15:0] fflp_fcram_cfg_datwr;
218output fflp_fcram_slv_update;
219output[1:0] fflp_fcram_rd_en;
220output fflp_fcram_cs_l;
221output fflp_fcram_fn;
222output fflp_fcram_pd_l;
223output fflp_fcram_ba0;
224output fflp_fcram_ba1;
225output[14:0] fflp_fcram_addr;
226output[1:0] fflp_fcram_ds;
227output[1:0] fflp_fcram_triz_en_l;
228output[35:0] fflp_fcram_even_dout;
229output[35:0] fflp_fcram_odd_dout;
230output[71:0] fc_din_reg_dout_r;
231output ecc_check_err_r;
232output ecc_corr_err_r;
233output fio_no_fatal_err;
234output srch_burst_done;
235output cpu_burst_done_sm;
236output[4:0] fcram_sm_state;
237output srch_burst_done_2;
238output srch_fio_wait_6;
239output srch_fio_rd_en_4;
240output cpu_fc_req_done;
241output[71:0] fc_rd_data_reg_dout;
242output fc_rd_ecc_err;
243output cpu_fio_req_done;
244output[31:0] cpu_fio_rd_data;
245output[7:0] fio_cal_rd_latency;
246
247wire cpu_cmd;
248/*
249wire ext_valid0;
250wire ext_valid1;
251wire ext_valid2;
252wire ext_valid3;
253wire ext_valid4;
254wire ext_valid5;
255wire ext_valid6;
256wire ext_valid7;
257*/
258wire[4:0] addr_mask0;
259wire[4:0] addr_mask1;
260wire[4:0] addr_mask2;
261wire[4:0] addr_mask3;
262wire[4:0] addr_mask4;
263wire[4:0] addr_mask5;
264wire[4:0] addr_mask6;
265wire[4:0] addr_mask7;
266wire[4:0] addr_base0;
267wire[4:0] addr_base1;
268wire[4:0] addr_base2;
269wire[4:0] addr_base3;
270wire[4:0] addr_base4;
271wire[4:0] addr_base5;
272wire[4:0] addr_base6;
273wire[4:0] addr_base7;
274
275wire[22:0] cpu_fc_loc;
276wire[1:0] cpu_fc_bk;
277wire cpu_bk0;
278wire cpu_bk1;
279wire[21:0] cpu_fc_addr;
280wire[4:0] cpu_addr_mask;
281wire[4:0] cpu_addr_base;
282wire[4:0] cpu_fc_masked_addr_h;
283wire[21:0] cpu_fc_masked_addr;
284wire[63:0] cpu_fc_data;
285wire[63:0] cpu_fc_data_r;
286wire[71:0] ecc_check_cpu_fc_data;
287wire[71:0] cpu_fc_data_in;
288wire[71:0] ecc_check_cpu_fc_data_r;
289
290reg[4:0] srch_addr_mask;
291reg[4:0] srch_addr_base;
292
293wire[4:0] srch_fc_masked_addr_h;
294wire[21:0] srch_fc_masked_addr;
295
296wire[14:0] mode_reg_data;
297wire[14:0] ext_mode_reg_data;
298wire[14:0] srch_fc_addr_mux_dout;
299wire[14:0] conf_fc_addr_mux_dout;
300wire[14:0] fc_addr_mux_dout;
301
302wire[14:0] fflp_fcram_addr;
303wire[35:0] fflp_fcram_even_dout;
304wire[35:0] fflp_fcram_odd_dout;
305wire[35:0] fc_even_din_reg_dout;
306wire[35:0] fc_odd_din_reg_dout;
307wire[71:0] fc_din_reg_dout;
308wire fio_mstr_ready;
309wire fio_no_fatal_err;
310wire[3:0] fio_data_ready;
311//wire fflp_fcram_cs_l;
312//wire fflp_fcram_fn;
313wire fflp_fcram_pd_l;
314wire fflp_fcram_ba0;
315wire fflp_fcram_ba1;
316wire[1:0] fflp_fcram_ds;
317wire[1:0] fflp_fcram_triz_en_l; //write data enable
318
319reg fflp_fcram_cs_l;
320reg fflp_fcram_fn;
321
322wire[71:0] fc_din_reg_dout_tmp;
323wire[71:0] fc_din_reg_dout_r;
324wire ecc_check_err;
325wire ecc_check_err_r;
326
327wire ecc_corr_err_r;
328wire ecc_check_err_all;
329wire ecc_no_error;
330wire ecc_corr_error;
331wire ecc_error;
332
333wire cpu_burst_done;
334wire cpu_burst_done_1;
335wire cpu_burst_done_2;
336wire cpu_burst_done_3;
337wire cpu_burst_done_4;
338wire cpu_burst_done_5;
339wire cpu_burst_done_6;
340wire cpu_burst_done_7;
341wire cpu_burst_done_8;
342wire cpu_burst_done_9;
343wire cpu_burst_done_10;
344wire cpu_burst_done_11;
345wire cpu_burst_done_12;
346wire cpu_burst_done_13;
347wire cpu_burst_done_14;
348wire cpu_burst_done_15;
349
350wire cpu_burst_done_16;
351wire cpu_burst_done_17;
352wire cpu_burst_done_18;
353wire cpu_burst_done_19;
354
355wire pio_fio_acc_en;
356wire pio_fio_acc_en_1;
357wire pio_fio_acc_en_2;
358wire pio_fio_acc_en_3;
359wire pio_fio_acc_en_4;
360wire pio_fio_acc_en_5;
361wire pio_fio_acc_en_6;
362
363wire pio_fio_rd_en;
364wire pio_fio_rd_en_1;
365wire pio_fio_rd_en_4;
366
367wire cpu_fc_req_done;
368wire cpu_fc_req_done_p;
369wire[71:0] fc_rd_data_reg_dout;
370wire fc_rd_ecc_err;
371
372wire srch_burst_done;
373wire srch_burst_done_all;
374wire srch_burst_done_1;
375wire srch_burst_done_2;
376wire srch_burst_done_3;
377
378wire srch_fio_wait;
379wire srch_fio_wait_1;
380wire srch_fio_wait_2;
381wire srch_fio_wait_3;
382wire srch_fio_wait_4;
383wire srch_fio_wait_5;
384wire srch_fio_wait_6;
385
386wire srch_fio_rd_en;
387wire srch_fio_rd_en_1;
388wire srch_fio_rd_en_2;
389wire srch_fio_rd_en_3;
390wire srch_fio_rd_en_4;
391wire srch_fio_rd_en_5;
392wire srch_fio_rd_en_6;
393wire srch_fio_rd_en_7;
394wire srch_fio_rd_en_8;
395wire srch_fio_rd_en_tmp;
396wire srch_fio_rd_en_p;
397wire srch_fio_rd_en_valid;
398
399wire fcram_ds;
400wire fcram_ds_1;
401wire fcram_ds_2;
402wire fcram_ds_3;
403wire fcram_ds_4;
404wire fcram_ds_5;
405
406wire[1:0] fcram_cmd_sm;
407wire fcram_ba0_sm;
408wire fcram_ba1_sm;
409wire[2:0] fcram_addr_sel;
410wire fcram_addr_en;
411wire fcram_ds_sm;
412wire fflp_fcram_slv_update;
413wire srch_burst_done_sm;
414wire cpu_burst_done_sm;
415wire power_on_wait_cnt_done_r;
416wire[4:0] fcram_sm_state;
417
418wire cpu_fio_req_sync_p;
419wire cpu_fio_req_sync_r;
420wire fcram_cfg_done_p;
421wire fcram_cfg_done;
422wire fcram_cfg_done_r;
423wire fcram_cfg_done_r1;
424wire fcram_cfg_err;
425wire fcram_cfg_sel_in;
426wire cpu_fio_req_done;
427wire[15:0] fcram_cfg_datrd;
428wire[31:0] cpu_fio_rd_data_tmp;
429wire[31:0] cpu_fio_rd_data;
430wire fflp_fcram_cfg_rst;
431wire[7:0] fflp_fcram_cfg_addr;
432wire[15:0] fflp_fcram_cfg_datwr;
433wire fflp_fcram_cfg_rd;
434wire fflp_fcram_cfg_sel;
435wire fflp_fcram_rd_en_p;
436wire[1:0] fflp_fcram_rd_en;
437
438wire fflp_data_ready_p;
439wire fflp_data_ready;
440wire cpu_rd_latency0;
441wire cpu_rd_latency1;
442wire cpu_rd_latency2;
443wire cpu_rd_latency3;
444wire cpu_rd_latency4;
445wire cpu_rd_latency5;
446wire cpu_rd_latency6;
447wire cpu_rd_latency7;
448wire[7:0] cpu_rd_latency_array;
449wire[7:0] fio_cal_rd_latency;
450
451/***********************/
452//CPU Request
453/***********************/
454assign cpu_cmd = !pio_rd;
455
456//assign ext_valid0 = flow_part_sel_reg0_dout[16];
457assign addr_mask0 = flow_part_sel_reg0_dout[9:5];
458assign addr_base0 = flow_part_sel_reg0_dout[4:0];
459
460//assign ext_valid1 = flow_part_sel_reg1_dout[16];
461assign addr_mask1 = flow_part_sel_reg1_dout[9:5];
462assign addr_base1 = flow_part_sel_reg1_dout[4:0];
463
464//assign ext_valid2 = flow_part_sel_reg2_dout[16];
465assign addr_mask2 = flow_part_sel_reg2_dout[9:5];
466assign addr_base2 = flow_part_sel_reg2_dout[4:0];
467
468//assign ext_valid3 = flow_part_sel_reg3_dout[16];
469assign addr_mask3 = flow_part_sel_reg3_dout[9:5];
470assign addr_base3 = flow_part_sel_reg3_dout[4:0];
471
472//assign ext_valid4 = flow_part_sel_reg4_dout[16];
473assign addr_mask4 = flow_part_sel_reg4_dout[9:5];
474assign addr_base4 = flow_part_sel_reg4_dout[4:0];
475
476//assign ext_valid5 = flow_part_sel_reg5_dout[16];
477assign addr_mask5 = flow_part_sel_reg5_dout[9:5];
478assign addr_base5 = flow_part_sel_reg5_dout[4:0];
479
480//assign ext_valid6 = flow_part_sel_reg6_dout[16];
481assign addr_mask6 = flow_part_sel_reg6_dout[9:5];
482assign addr_base6 = flow_part_sel_reg6_dout[4:0];
483
484//assign ext_valid7 = flow_part_sel_reg7_dout[16];
485assign addr_mask7 = flow_part_sel_reg7_dout[9:5];
486assign addr_base7 = flow_part_sel_reg7_dout[4:0];
487
488assign cpu_addr_mask = ({5{cpu_req_part0_sel}} & addr_mask0) |
489 ({5{cpu_req_part1_sel}} & addr_mask1) |
490 ({5{cpu_req_part2_sel}} & addr_mask2) |
491 ({5{cpu_req_part3_sel}} & addr_mask3) |
492 ({5{cpu_req_part4_sel}} & addr_mask4) |
493 ({5{cpu_req_part5_sel}} & addr_mask5) |
494 ({5{cpu_req_part6_sel}} & addr_mask6) |
495 ({5{cpu_req_part7_sel}} & addr_mask7);
496
497assign cpu_addr_base = ({5{cpu_req_part0_sel}} & addr_base0) |
498 ({5{cpu_req_part1_sel}} & addr_base1) |
499 ({5{cpu_req_part2_sel}} & addr_base2) |
500 ({5{cpu_req_part3_sel}} & addr_base3) |
501 ({5{cpu_req_part4_sel}} & addr_base4) |
502 ({5{cpu_req_part5_sel}} & addr_base5) |
503 ({5{cpu_req_part6_sel}} & addr_base6) |
504 ({5{cpu_req_part7_sel}} & addr_base7);
505
506assign cpu_fc_data = (({64{cpu_req_part0_sel}} & hash_tbl_data_reg0_dout) |
507 ({64{cpu_req_part1_sel}} & hash_tbl_data_reg1_dout) |
508 ({64{cpu_req_part2_sel}} & hash_tbl_data_reg2_dout) |
509 ({64{cpu_req_part3_sel}} & hash_tbl_data_reg3_dout) |
510 ({64{cpu_req_part4_sel}} & hash_tbl_data_reg4_dout) |
511 ({64{cpu_req_part5_sel}} & hash_tbl_data_reg5_dout) |
512 ({64{cpu_req_part6_sel}} & hash_tbl_data_reg6_dout) |
513 ({64{cpu_req_part7_sel}} & hash_tbl_data_reg7_dout));
514
515assign cpu_fc_loc = ({23{cpu_req_part0_sel}} & hash_tbl_addr_reg0_dout[22:0]) |
516 ({23{cpu_req_part1_sel}} & hash_tbl_addr_reg1_dout[22:0]) |
517 ({23{cpu_req_part2_sel}} & hash_tbl_addr_reg2_dout[22:0]) |
518 ({23{cpu_req_part3_sel}} & hash_tbl_addr_reg3_dout[22:0]) |
519 ({23{cpu_req_part4_sel}} & hash_tbl_addr_reg4_dout[22:0]) |
520 ({23{cpu_req_part5_sel}} & hash_tbl_addr_reg5_dout[22:0]) |
521 ({23{cpu_req_part6_sel}} & hash_tbl_addr_reg6_dout[22:0]) |
522 ({23{cpu_req_part7_sel}} & hash_tbl_addr_reg7_dout[22:0]);
523
524assign cpu_fc_bk = cpu_fc_loc[2:1];
525assign cpu_bk0 = cpu_fc_bk[0];
526assign cpu_bk1 = cpu_fc_bk[1];
527assign cpu_fc_addr = {cpu_fc_loc[22:3], cpu_fc_loc[0], 1'b0}; //22bits
528
529assign cpu_fc_masked_addr_h = (cpu_addr_mask & cpu_addr_base) | (~cpu_addr_mask & cpu_fc_addr[21:17]);
530assign cpu_fc_masked_addr = {cpu_fc_masked_addr_h, cpu_fc_addr[16:0]};
531
532
533/**********************************/
534//Packet Lookup Addr
535/**********************************/
536always @(merg_bus_0_rdc_tbl_num or
537 addr_mask0 or addr_base0 or
538 addr_mask1 or addr_base1 or
539 addr_mask2 or addr_base2 or
540 addr_mask3 or addr_base3 or
541 addr_mask4 or addr_base4 or
542 addr_mask5 or addr_base5 or
543 addr_mask6 or addr_base6 or
544 addr_mask7 or addr_base7)
545begin
546 case (merg_bus_0_rdc_tbl_num)
547 // 0in < case -full -parallel -message "0in ERROR: case check in fflp_fcram_cntl"
548
549 3'b000:
550 begin
551 srch_addr_mask = addr_mask0;
552 srch_addr_base = addr_base0;
553 end
554 3'b001:
555 begin
556 srch_addr_mask = addr_mask1;
557 srch_addr_base = addr_base1;
558 end
559 3'b010:
560 begin
561 srch_addr_mask = addr_mask2;
562 srch_addr_base = addr_base2;
563 end
564 3'b011:
565 begin
566 srch_addr_mask = addr_mask3;
567 srch_addr_base = addr_base3;
568 end
569 3'b100:
570 begin
571 srch_addr_mask = addr_mask4;
572 srch_addr_base = addr_base4;
573 end
574 3'b101:
575 begin
576 srch_addr_mask = addr_mask5;
577 srch_addr_base = addr_base5;
578 end
579 3'b110:
580 begin
581 srch_addr_mask = addr_mask6;
582 srch_addr_base = addr_base6;
583 end
584 3'b111:
585 begin
586 srch_addr_mask = addr_mask7;
587 srch_addr_base = addr_base7;
588 end
589 default:
590 begin
591 srch_addr_mask = 5'b0;
592 srch_addr_base = 5'b0;
593 end
594 endcase
595end
596
597assign srch_fc_masked_addr_h = (srch_addr_mask & srch_addr_base) | (~srch_addr_mask & merg_bus_0_hash_v1[19:15]);
598assign srch_fc_masked_addr = {srch_fc_masked_addr_h, merg_bus_0_hash_v1[14:0], 2'b00};
599
600
601/*******************************/
602//FCRAM Interface signal
603/*******************************/
604assign mode_reg_data = {8'b0, 3'b110, 1'b0, 3'b010}; //{resed(8), cas_latency, burst_type, burst_len}
605assign ext_mode_reg_data = {8'b0, 1'b1, fcram_qs_mode, fcram_driver_imp_ctrl[3:0], 1'b0};
606
607assign srch_fc_addr_mux_dout = (fcram_addr_sel[1:0] == 2'b00) ? srch_fc_masked_addr[21:7] :
608 (fcram_addr_sel[1:0] == 2'b01) ? {8'b0, srch_fc_masked_addr[6:0]} :
609 (fcram_addr_sel[1:0] == 2'b10) ? cpu_fc_masked_addr[21:7] :
610 {2'b01, 6'b0, cpu_fc_masked_addr[6:0]};
611assign conf_fc_addr_mux_dout = fcram_addr_sel[0] ? ext_mode_reg_data : mode_reg_data;
612assign fc_addr_mux_dout = fcram_addr_sel[2] ? srch_fc_addr_mux_dout : conf_fc_addr_mux_dout;
613
614dffre #(15) fflp_fcram_addr_reg (cclk, reset, fcram_addr_en, fc_addr_mux_dout, fflp_fcram_addr);
615dffre #(36) fcram_even_dout_reg (cclk, reset, fcram_ds, cpu_fc_data_in[35:0], fflp_fcram_even_dout);
616dffre #(36) fcram_odd_dout_reg (cclk, reset, fcram_ds, cpu_fc_data_in[71:36], fflp_fcram_odd_dout);
617
618dffr #(1) fcram_mstr_ready_reg(cclk, reset, fcram_fflp_mstrready, fio_mstr_ready);
619dffr #(1) fcram_fatal_err_reg (cclk, reset, !fcram_fflp_fatal_err, fio_no_fatal_err);
620dffr #(4) fcram_data_ready_reg(cclk, reset, fcram_fflp_data_ready, fio_data_ready);
621dffr #(36) fcram_even_din_reg (cclk, reset, fcram_fflp_even_din, fc_even_din_reg_dout);
622dffr #(36) fcram_odd_din_reg (cclk, reset, fcram_fflp_odd_din, fc_odd_din_reg_dout);
623
624//dffr #(1) fflp_fcram_cs_reg (cclk, reset, fcram_cmd_sm[1], fflp_fcram_cs_l);
625//dffr #(1) fflp_fcram_fn_reg (cclk, reset, fcram_cmd_sm[0], fflp_fcram_fn);
626
627dffr #(1) fflp_fcram_pd_reg (cclk, reset, power_on_wait_cnt_done_r, fflp_fcram_pd_l);
628dffr #(1) fflp_fcram_ba0_reg (cclk, reset, fcram_ba0_sm, fflp_fcram_ba0);
629dffr #(1) fflp_fcram_ba1_reg (cclk, reset, fcram_ba1_sm, fflp_fcram_ba1);
630dffr #(2) fflp_fcram_rd_en_reg(cclk, reset, {2{fflp_fcram_rd_en_p}}, fflp_fcram_rd_en);
631
632always @ (posedge cclk)
633if (reset)
634 fflp_fcram_cs_l <= 1'b1;
635else
636 fflp_fcram_cs_l <= fcram_cmd_sm[1];
637
638always @ (posedge cclk)
639if (reset)
640 fflp_fcram_fn <= 1'b0;
641else
642 fflp_fcram_fn <= fcram_cmd_sm[0];
643
644
645/*******************************/
646//Pipeline Control
647/*******************************/
648assign pio_fio_acc_en = (pio_fio_latency == 2'b00) ? cpu_burst_done_12 :
649 (pio_fio_latency == 2'b01) ? cpu_burst_done_13 :
650 (pio_fio_latency == 2'b10) ? cpu_burst_done_14 :
651 cpu_burst_done_15 ;
652
653assign cpu_fc_req_done_p = pio_fio_acc_en_4 | pio_fio_acc_en_5 | pio_fio_acc_en_6;
654
655assign fc_din_reg_dout = {fc_odd_din_reg_dout, fc_even_din_reg_dout};
656assign srch_burst_done_all = srch_no_fc_done | srch_burst_done;
657assign srch_fio_rd_en = (pio_fio_latency == 2'b00) ? srch_fio_wait_3 :
658 (pio_fio_latency == 2'b01) ? srch_fio_wait_4 :
659 (pio_fio_latency == 2'b10) ? srch_fio_wait_5 :
660 srch_fio_wait_6;
661
662assign srch_fio_rd_en_valid = (srch_fio_rd_en & merg_bus_1_fc_lookup & fio_no_fatal_err);
663assign srch_fio_rd_en_tmp = srch_fio_rd_en_valid ? 1'b1 :
664 srch_fio_rd_en_8 ? 1'b0 : srch_fio_rd_en_p;
665
666assign pio_fio_rd_en = pio_fio_acc_en & pio_rd;
667assign pio_fio_rd_en_1 = pio_fio_acc_en_1 & pio_rd;
668assign pio_fio_rd_en_4 = pio_fio_acc_en_4 & pio_rd;
669
670assign fflp_fcram_rd_en_p = srch_fio_rd_en_p | pio_fio_rd_en | pio_fio_rd_en_1;
671
672dffre #(72) fc_rd_data_reg (cclk, reset, pio_fio_rd_en_4, fc_din_reg_dout_r, fc_rd_data_reg_dout);
673dffre #(1) fc_rd_ecc_err_reg (cclk, reset, pio_fio_rd_en_4, ecc_check_err_all, fc_rd_ecc_err);
674
675dffr #(1) cpu_burst_done_reg (cclk, reset, cpu_burst_done_sm, cpu_burst_done);
676dffr #(1) cpu_burst_done_1_reg (cclk, reset, cpu_burst_done, cpu_burst_done_1);
677dffr #(1) cpu_burst_done_2_reg (cclk, reset, cpu_burst_done_1, cpu_burst_done_2);
678dffr #(1) cpu_burst_done_3_reg (cclk, reset, cpu_burst_done_2, cpu_burst_done_3);
679dffr #(1) cpu_burst_done_4_reg (cclk, reset, cpu_burst_done_3, cpu_burst_done_4);
680dffr #(1) cpu_burst_done_5_reg (cclk, reset, cpu_burst_done_4, cpu_burst_done_5);
681dffr #(1) cpu_burst_done_6_reg (cclk, reset, cpu_burst_done_5, cpu_burst_done_6);
682dffr #(1) cpu_burst_done_7_reg (cclk, reset, cpu_burst_done_6, cpu_burst_done_7);
683dffr #(1) cpu_burst_done_8_reg (cclk, reset, cpu_burst_done_7, cpu_burst_done_8);
684dffr #(1) cpu_burst_done_9_reg (cclk, reset, cpu_burst_done_8, cpu_burst_done_9);
685dffr #(1) cpu_burst_done_10_reg (cclk, reset, cpu_burst_done_9, cpu_burst_done_10);
686dffr #(1) cpu_burst_done_11_reg (cclk, reset, cpu_burst_done_10, cpu_burst_done_11);
687dffr #(1) cpu_burst_done_12_reg (cclk, reset, cpu_burst_done_11, cpu_burst_done_12);
688dffr #(1) cpu_burst_done_13_reg (cclk, reset, cpu_burst_done_12, cpu_burst_done_13);
689dffr #(1) cpu_burst_done_14_reg (cclk, reset, cpu_burst_done_13, cpu_burst_done_14);
690dffr #(1) cpu_burst_done_15_reg (cclk, reset, cpu_burst_done_14, cpu_burst_done_15);
691
692//for calculating fio read latency
693dffr #(1) cpu_burst_done_16_reg (cclk, reset, cpu_burst_done_15, cpu_burst_done_16);
694dffr #(1) cpu_burst_done_17_reg (cclk, reset, cpu_burst_done_16, cpu_burst_done_17);
695dffr #(1) cpu_burst_done_18_reg (cclk, reset, cpu_burst_done_17, cpu_burst_done_18);
696dffr #(1) cpu_burst_done_19_reg (cclk, reset, cpu_burst_done_18, cpu_burst_done_19);
697
698dffr #(1) pio_fio_acc_en_1_reg (cclk, reset, pio_fio_acc_en, pio_fio_acc_en_1);
699dffr #(1) pio_fio_acc_en_2_reg (cclk, reset, pio_fio_acc_en_1, pio_fio_acc_en_2);
700dffr #(1) pio_fio_acc_en_3_reg (cclk, reset, pio_fio_acc_en_2, pio_fio_acc_en_3);
701dffr #(1) pio_fio_acc_en_4_reg (cclk, reset, pio_fio_acc_en_3, pio_fio_acc_en_4);
702dffr #(1) pio_fio_acc_en_5_reg (cclk, reset, pio_fio_acc_en_4, pio_fio_acc_en_5);
703dffr #(1) pio_fio_acc_en_6_reg (cclk, reset, pio_fio_acc_en_5, pio_fio_acc_en_6);
704
705dffr #(1) cpu_fc_req_done_reg (cclk, reset, cpu_fc_req_done_p, cpu_fc_req_done);
706
707dffr #(1) srch_burst_done_reg (cclk, reset, srch_burst_done_sm, srch_burst_done);
708dffr #(1) srch_burst_done_1_reg (cclk, reset, srch_burst_done_all, srch_burst_done_1);
709dffr #(1) srch_burst_done_2_reg (cclk, reset, srch_burst_done_1, srch_burst_done_2);
710dffr #(1) srch_burst_done_3_reg (cclk, reset, srch_burst_done_2, srch_burst_done_3);
711
712dffr #(1) srch_fio_wait_reg (cclk, reset, srch_burst_done_3, srch_fio_wait);
713dffr #(1) srch_fio_wait_1_reg (cclk, reset, srch_fio_wait, srch_fio_wait_1);
714dffr #(1) srch_fio_wait_2_reg (cclk, reset, srch_fio_wait_1, srch_fio_wait_2);
715dffr #(1) srch_fio_wait_3_reg (cclk, reset, srch_fio_wait_2, srch_fio_wait_3);
716dffr #(1) srch_fio_wait_4_reg (cclk, reset, srch_fio_wait_3, srch_fio_wait_4);
717dffr #(1) srch_fio_wait_5_reg (cclk, reset, srch_fio_wait_4, srch_fio_wait_5);
718dffr #(1) srch_fio_wait_6_reg (cclk, reset, srch_fio_wait_5, srch_fio_wait_6);
719
720dffr #(1) srch_fio_rd_en_1_reg (cclk, reset, srch_fio_rd_en, srch_fio_rd_en_1);
721dffr #(1) srch_fio_rd_en_2_reg (cclk, reset, srch_fio_rd_en_1, srch_fio_rd_en_2);
722dffr #(1) srch_fio_rd_en_3_reg (cclk, reset, srch_fio_rd_en_2, srch_fio_rd_en_3);
723dffr #(1) srch_fio_rd_en_4_reg (cclk, reset, srch_fio_rd_en_3, srch_fio_rd_en_4);
724dffr #(1) srch_fio_rd_en_5_reg (cclk, reset, srch_fio_rd_en_4, srch_fio_rd_en_5);
725dffr #(1) srch_fio_rd_en_6_reg (cclk, reset, srch_fio_rd_en_5, srch_fio_rd_en_6);
726dffr #(1) srch_fio_rd_en_7_reg (cclk, reset, srch_fio_rd_en_6, srch_fio_rd_en_7);
727dffr #(1) srch_fio_rd_en_8_reg (cclk, reset, srch_fio_rd_en_7, srch_fio_rd_en_8);
728dffr #(1) srch_fio_rd_en_p_reg (cclk, reset, srch_fio_rd_en_tmp, srch_fio_rd_en_p);
729
730dffr #(1) fcram_ds_reg (cclk, reset, fcram_ds_sm, fcram_ds);
731dffr #(1) fcram_ds_1_reg (cclk, reset, fcram_ds, fcram_ds_1);
732dffr #(1) fcram_ds_2_reg (cclk, reset, fcram_ds_1, fcram_ds_2);
733dffr #(1) fcram_ds_3_reg (cclk, reset, fcram_ds_2, fcram_ds_3);
734dffr #(1) fcram_ds_4_reg (cclk, reset, fcram_ds_3, fcram_ds_4);
735dffr #(1) fcram_ds_5_reg (cclk, reset, fcram_ds_4, fcram_ds_5);
736dffr #(2) fcram_ds_6_reg (cclk, reset, {2{fcram_ds_5}}, fflp_fcram_ds);
737
738assign fflp_fcram_triz_en_l = ~fflp_fcram_ds;
739
740fflp_fcram_cntl_sm fflp_fcram_cntl_sm_inst (
741 .cclk (cclk),
742 .reset (reset),
743 .fflp_init_done (fflp_init_done),
744 .fio_mstr_ready (fio_mstr_ready),
745 .fcram_refresh_timer_reg_dout (fcram_refresh_timer_reg_dout),
746 .do_srch_cycle (do_srch_cycle),
747 .do_cpu_cycle (do_cpu_cycle),
748 .cpu_cmd (cpu_cmd),
749 .cpu_bk0 (cpu_bk0),
750 .cpu_bk1 (cpu_bk1),
751
752 .fcram_cmd_sm (fcram_cmd_sm),
753 .fcram_ba0_sm (fcram_ba0_sm),
754 .fcram_ba1_sm (fcram_ba1_sm),
755 .fcram_addr_sel (fcram_addr_sel),
756 .fcram_addr_en (fcram_addr_en),
757 .fcram_ds_sm (fcram_ds_sm),
758 .fflp_fcram_slv_update (fflp_fcram_slv_update),
759 .srch_burst_done_sm (srch_burst_done_sm),
760 .cpu_burst_done_sm (cpu_burst_done_sm),
761 .power_on_wait_cnt_done_r (power_on_wait_cnt_done_r),
762 .fcram_sm_state (fcram_sm_state)
763
764 );
765
766
767dffr #(64) cpu_fc_data_r_reg (cclk, reset, cpu_fc_data, cpu_fc_data_r);
768dffr #(72) ecc_chk_cpu_fc_data_reg (cclk, reset, ecc_check_cpu_fc_data, ecc_check_cpu_fc_data_r);
769assign cpu_fc_data_in = {ecc_check_cpu_fc_data_r[7:0], ecc_check_cpu_fc_data_r[71:8]} ^ fcram_err_test_reg_dout[71:0];
770
771niu_64data_ecc_generate niu_64data_ecc_generate_inst0 (
772 .din (cpu_fc_data_r),
773 .dout (ecc_check_cpu_fc_data)
774
775 );
776
777niu_64data_ecc_check niu_64data_ecc_check_inst0 (
778 .din ({fc_din_reg_dout[63:0], fc_din_reg_dout[71:64]}),
779 .dout (fc_din_reg_dout_tmp),
780 .no_error (ecc_no_error),
781 .error (ecc_error),
782 .corr_error (ecc_corr_error),
783 .uncorr_error (ecc_check_err)
784
785 );
786
787wire ecc_check_err_in = ecc_check_err & !disable_chksum; //din_en_12
788wire ecc_corr_err_in = ecc_corr_error & !disable_chksum;
789wire[71:0] fc_din_reg_dout_tmp1 = {fc_din_reg_dout[71:64], fc_din_reg_dout_tmp[71:8]};
790
791dffr #(72) fc_din_reg_dout_r_reg (cclk, reset, fc_din_reg_dout_tmp1, fc_din_reg_dout_r); //enable by din_en_12
792dffr #(1) ecc_err_reg (cclk, reset, ecc_check_err_in, ecc_check_err_r);
793dffr #(1) ecc_corr_err_reg (cclk, reset, ecc_corr_err_in, ecc_corr_err_r);
794
795assign ecc_check_err_all = ecc_check_err_r | ecc_corr_err_r;
796
797
798/*************************/
799//FIO Parallel Interface
800/*************************/
801assign cpu_fio_req_sync_p = cpu_fio_req_sync & !cpu_fio_req_sync_r;
802assign fcram_cfg_sel_in = cpu_fio_req_sync_p ? 1'b1 :
803 fcram_cfg_done ? 1'b0 : fflp_fcram_cfg_sel;
804
805assign fcram_cfg_done_p = fcram_cfg_done | fcram_cfg_done_r | fcram_cfg_done_r1;
806assign fflp_fcram_cfg_addr = fio_cfg_addr_reg_dout[7:0];
807assign fflp_fcram_cfg_datwr = pio_wr_data[15:0];
808assign fflp_fcram_cfg_rd = pio_rd;
809assign fflp_fcram_cfg_rst = pio_fio_cfg_reset;
810
811
812dffr #(1) cpu_fio_req_sync_r_reg (cclk, reset, cpu_fio_req_sync, cpu_fio_req_sync_r);
813dffr #(1) fflp_fcram_cfg_sel_reg (cclk, reset, fcram_cfg_sel_in, fflp_fcram_cfg_sel);
814dffr #(1) fcram_cfg_done_reg (cclk, reset, fcram_fflp_cfg_done, fcram_cfg_done);
815dffr #(1) fcram_cfg_err_reg (cclk, reset, fcram_fflp_cfg_err, fcram_cfg_err);
816dffr #(1) fcram_cfg_done_r_reg (cclk, reset, fcram_cfg_done, fcram_cfg_done_r);
817dffr #(1) fcram_cfg_done_r1_reg (cclk, reset, fcram_cfg_done_r, fcram_cfg_done_r1);
818dffr #(1) cpu_fio_req_done_reg (cclk, reset, fcram_cfg_done_p, cpu_fio_req_done);
819dffr #(16) fcram_cfg_datrd_reg (cclk, reset, fcram_fflp_cfg_datrd, fcram_cfg_datrd);
820
821assign cpu_fio_rd_data_tmp = fcram_cfg_err ? 32'hdeadbeef : {16'b0, fcram_cfg_datrd[15:0]};
822
823dffre #(32) cpu_fio_rd_data_reg (cclk, reset, fcram_cfg_done, cpu_fio_rd_data_tmp, cpu_fio_rd_data);
824
825/***********************/
826//Calculate fio latecy
827/***********************/
828assign fflp_data_ready_p = (&fio_data_ready) & !fflp_data_ready;
829
830dffr #(1) fflp_data_ready_reg (cclk, reset, (&fio_data_ready), fflp_data_ready);
831
832assign cpu_rd_latency0 = fflp_data_ready_p & cpu_burst_done_12; //00
833assign cpu_rd_latency1 = fflp_data_ready_p & cpu_burst_done_13;
834assign cpu_rd_latency2 = fflp_data_ready_p & cpu_burst_done_14;
835assign cpu_rd_latency3 = fflp_data_ready_p & cpu_burst_done_15;
836assign cpu_rd_latency4 = fflp_data_ready_p & cpu_burst_done_16;
837assign cpu_rd_latency5 = fflp_data_ready_p & cpu_burst_done_17; //01
838assign cpu_rd_latency6 = fflp_data_ready_p & cpu_burst_done_18; //10
839assign cpu_rd_latency7 = fflp_data_ready_p & cpu_burst_done_19; //11
840
841assign cpu_rd_latency_array = {cpu_rd_latency7, cpu_rd_latency6, cpu_rd_latency5, cpu_rd_latency4,
842 cpu_rd_latency3, cpu_rd_latency2, cpu_rd_latency1, cpu_rd_latency0};
843
844dffre #(8) cpu_rd_latency_reg (cclk, reset, fflp_data_ready_p, cpu_rd_latency_array, fio_cal_rd_latency);
845
846endmodule