source: XOpenSparcT1/trunk/T1-common/srams/bw_r_icd.v @ 22

Revision 22, 33.4 KB checked in by pntsvt00, 13 years ago (diff)

checkpoint: la DDR effettua l'init

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: bw_r_icd.v
4// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6//
7// The above named program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public
9// License version 2 as published by the Free Software Foundation.
10//
11// The above named program is distributed in the hope that it will be
12// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public
17// License along with this work; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19//
20// ========== Copyright Header End ============================================
21////////////////////////////////////////////////////////////////////////
22/*
23 //  Module Name:  bw_r_icd
24 //  Description:       
25 //    The ICD contains the icache data. 
26 //    32B line size. 
27 //    Write BW: 16B
28 //    Read BW: 16Bx2 (fetdata and topdata), collapsed to 4Bx2
29 //    Associativity: 4
30 //    Write boundary: 34b (32b inst + parity + predec bit)
31 //    NOTES:
32 //    1. No clock enable.  Rd/Wr enable is used to trigger the
33 //    operation.
34 //    2. 2:1 mux on address input.  Selects provided externally.
35 //    3. 3:1 mux on data input.   Selects provided and guaranteed
36 //    exclusive, externally.
37 //   
38 */
39
40
41////////////////////////////////////////////////////////////////////////
42// Global header file includes
43////////////////////////////////////////////////////////////////////////
44//`include "sys.h" // system level definition file which contains the
45// time scale definition
46
47
48////////////////////////////////////////////////////////////////////////
49// Local header file includes / local defines
50////////////////////////////////////////////////////////////////////////
51
52`include "ifu.h"
53
54//FPGA_SYN enables all FPGA related modifications
55`ifdef FPGA_SYN 
56`define FPGA_SYN_ICD
57`endif
58
59`ifdef FPGA_SYN_ICD
60
61module bw_r_icd(icd_wsel_fetdata_s1, icd_wsel_topdata_s1, icd_fuse_repair_value,
62        icd_fuse_repair_en, so, rclk, se, si, reset_l, sehold, fdp_icd_index_bf,
63        ifq_icd_index_bf, fcl_icd_index_sel_ifq_bf, ifq_icd_wrway_bf, 
64        ifq_icd_worden_bf, ifq_icd_wrdata_i2, fcl_icd_rdreq_bf, 
65        fcl_icd_wrreq_bf, bist_ic_data, rst_tri_en, ifq_icd_data_sel_old_i2, 
66        ifq_icd_data_sel_fill_i2, ifq_icd_data_sel_bist_i2, fuse_icd_wren, 
67        fuse_icd_rid, fuse_icd_repair_value, fuse_icd_repair_en, 
68        efc_spc_fuse_clk1);
69
70        input                   rclk;
71        input                   se;
72        input                   si;
73        input                   reset_l;
74        input                   sehold;
75        input   [11:2]          fdp_icd_index_bf;
76        input   [11:2]          ifq_icd_index_bf;
77        input                   fcl_icd_index_sel_ifq_bf;
78        input   [1:0]           ifq_icd_wrway_bf;
79        input   [3:0]           ifq_icd_worden_bf;
80        input   [135:0]         ifq_icd_wrdata_i2;
81        input                   fcl_icd_rdreq_bf;
82        input                   fcl_icd_wrreq_bf;
83        input   [7:0]           bist_ic_data;
84        input                   rst_tri_en;
85        input                   ifq_icd_data_sel_old_i2;
86        input                   ifq_icd_data_sel_fill_i2;
87        input                   ifq_icd_data_sel_bist_i2;
88        input                   fuse_icd_wren;
89        input   [3:0]           fuse_icd_rid;
90        input   [7:0]           fuse_icd_repair_value;
91        input   [1:0]           fuse_icd_repair_en;
92        input                   efc_spc_fuse_clk1;
93        output  [135:0]         icd_wsel_fetdata_s1;
94        output  [135:0]         icd_wsel_topdata_s1;
95        output  [7:0]           icd_fuse_repair_value;
96        output  [1:0]           icd_fuse_repair_en;
97        output                  so;
98
99        reg     [7:0]           icd_fuse_repair_value;
100        reg     [1:0]           icd_fuse_repair_en;
101        reg     [135:0]         fetdata_f;
102        reg     [135:0]         topdata_f;
103        reg     [135:0]         fetdata_sa;
104        reg     [135:0]         topdata_sa;
105        reg     [135:0]         fetdata_s1;
106        reg     [135:0]         topdata_s1;
107        wire                    clk;
108        wire    [135:0]         next_wrdata_bf;
109        wire    [135:0]         wrdata_f;
110        wire    [135:0]         bist_data_expand;
111    `ifdef FPGA_SYN_ALTERA
112        reg     [11:2]          index_bf;
113    `else
114        wire [11:2]     index_bf;
115    `endif
116        reg     [11:2]          index_f;
117        reg     [11:0]          wr_index0;
118        reg     [11:0]          wr_index1;
119        reg     [11:0]          wr_index2;
120        reg     [11:0]          wr_index3;
121        reg                     rdreq_f;
122        reg                     wrreq_f;
123        reg     [3:0]           worden_f;
124        reg     [1:0]           wrway_f;
125    `ifdef FPGA_SYN_ALTERA
126
127        reg [33:0]     icdata_ary_00_00  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
128        reg [33:0]     icdata_ary_00_01  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
129        reg [33:0]     icdata_ary_00_10  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
130        reg [33:0]     icdata_ary_00_11  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
131        reg [33:0]     icdata_ary_01_00  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
132        reg [33:0]     icdata_ary_01_01  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
133        reg [33:0]     icdata_ary_01_10  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
134        reg [33:0]     icdata_ary_01_11  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
135        reg [33:0]     icdata_ary_10_00  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
136        reg [33:0]     icdata_ary_10_01  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
137        reg [33:0]     icdata_ary_10_10  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
138        reg [33:0]     icdata_ary_10_11  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
139        reg [33:0]     icdata_ary_11_00  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
140        reg [33:0]     icdata_ary_11_01  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
141        reg [33:0]     icdata_ary_11_10  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
142        reg [33:0]     icdata_ary_11_11  [255:0] /* synthesis syn_ramstyle = block_ram  */ ;/* syn_ramstyle = no_rw_check */ 
143    `else
144        reg [33:0]     icdata_ary_00_00  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
145        reg [33:0]     icdata_ary_00_01  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
146        reg [33:0]     icdata_ary_00_10  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
147        reg [33:0]     icdata_ary_00_11  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
148        reg [33:0]     icdata_ary_01_00  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
149        reg [33:0]     icdata_ary_01_01  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
150        reg [33:0]     icdata_ary_01_10  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
151        reg [33:0]     icdata_ary_01_11  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
152        reg [33:0]     icdata_ary_10_00  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
153        reg [33:0]     icdata_ary_10_01  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
154        reg [33:0]     icdata_ary_10_10  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
155        reg [33:0]     icdata_ary_10_11  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
156        reg [33:0]     icdata_ary_11_00  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
157        reg [33:0]     icdata_ary_11_01  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
158        reg [33:0]     icdata_ary_11_10  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
159        reg [33:0]     icdata_ary_11_11  [255:0] /* synthesis syn_ramstyle = block_ram  syn_ramstyle = no_rw_check */ ;
160    `endif
161
162
163
164
165
166        assign clk = rclk;
167    `ifdef FPGA_SYN_ALTERA
168    `else
169        assign index_bf = (fcl_icd_index_sel_ifq_bf ? ifq_icd_index_bf : 
170            fdp_icd_index_bf);
171    `endif
172//      assign index_bf = (fcl_icd_index_sel_ifq_bf ? ifq_icd_index_bf :
173//              fdp_icd_index_bf);
174        wire [11:2] top_index = {index_f[11:3] , 1'b1};
175
176        assign bist_data_expand = 136'b0;
177        assign icd_wsel_fetdata_s1 = fetdata_s1;
178        assign icd_wsel_topdata_s1 = topdata_s1;
179
180        mux3ds #(136) icden_mux(
181                .dout                           (next_wrdata_bf), 
182                .in0                            (wrdata_f), 
183                .in1                            (ifq_icd_wrdata_i2), 
184                .in2                            (bist_data_expand), 
185                .sel0                           (ifq_icd_data_sel_old_i2), 
186                .sel1                           (ifq_icd_data_sel_fill_i2), 
187                .sel2                           (ifq_icd_data_sel_bist_i2));
188        dffe_s #(136) wrdata_reg(
189                .din                            (next_wrdata_bf), 
190                .clk                            (clk), 
191                .q                              (wrdata_f), 
192                .en                             ((~sehold)), 
193                .se                             (se),
194                .si                             (),
195                .so());
196
197        always @(posedge clk) begin
198          if (~sehold) begin
199            rdreq_f <= fcl_icd_rdreq_bf;
200            wrreq_f <= fcl_icd_wrreq_bf;
201        `ifdef FPGA_SYN_ALTERA
202        `else
203            index_f <= index_bf;
204        `endif
205            wrway_f <= ifq_icd_wrway_bf;
206            worden_f <= ifq_icd_worden_bf;
207            wr_index0 <= {index_bf[11:4], 2'b0, ifq_icd_wrway_bf};
208            wr_index1 <= {index_bf[11:4], 2'b1, ifq_icd_wrway_bf};
209            wr_index2 <= {index_bf[11:4], 2'b10, ifq_icd_wrway_bf};
210            wr_index3 <= {index_bf[11:4], 2'b11, ifq_icd_wrway_bf};
211          end
212          fetdata_s1 <= fetdata_f;
213          topdata_s1 <= topdata_f;
214  end
215
216
217        reg [33:0] fetch_00_00;
218        reg [33:0] fetch_00_01;
219        reg [33:0] fetch_00_10;
220        reg [33:0] fetch_00_11;
221
222        reg [33:0] fetch_01_00;
223        reg [33:0] fetch_01_01;
224        reg [33:0] fetch_01_10;
225        reg [33:0] fetch_01_11;
226
227        reg [33:0] fetch_10_00;
228        reg [33:0] fetch_10_01;
229        reg [33:0] fetch_10_10;
230        reg [33:0] fetch_10_11;
231
232        reg [33:0] fetch_11_00;
233        reg [33:0] fetch_11_01;
234        reg [33:0] fetch_11_10;
235        reg [33:0] fetch_11_11;
236    `ifdef FPGA_SYN_ALTERA
237
238        reg [33:0] fetch_00_00_d;
239        reg [33:0] fetch_00_01_d;
240        reg [33:0] fetch_00_10_d;
241        reg [33:0] fetch_00_11_d;
242
243        reg [33:0] fetch_01_00_d;
244        reg [33:0] fetch_01_01_d;
245        reg [33:0] fetch_01_10_d;
246        reg [33:0] fetch_01_11_d;
247
248        reg [33:0] fetch_10_00_d;
249        reg [33:0] fetch_10_01_d;
250        reg [33:0] fetch_10_10_d;
251        reg [33:0] fetch_10_11_d;
252
253        reg [33:0] fetch_11_00_d;
254        reg [33:0] fetch_11_01_d;
255        reg [33:0] fetch_11_10_d;
256        reg [33:0] fetch_11_11_d;
257    reg        delay_half_cycle;
258
259
260        always @(negedge clk) begin // Sandeep Changed this to negedge clock from posedge clock
261        // Can we push the reads to the next negedge? Delay this read!! Looks
262        // like the previous write does not get through
263    `else
264    always @(posedge clk) begin
265    `endif
266          fetch_00_00 <= icdata_ary_00_00[index_bf[11:4]];
267          fetch_00_01 <= icdata_ary_00_01[index_bf[11:4]];
268          fetch_00_10 <= icdata_ary_00_10[index_bf[11:4]];
269          fetch_00_11 <= icdata_ary_00_11[index_bf[11:4]];
270         
271          fetch_01_00 <= icdata_ary_01_00[index_bf[11:4]];
272          fetch_01_01 <= icdata_ary_01_01[index_bf[11:4]];
273          fetch_01_10 <= icdata_ary_01_10[index_bf[11:4]];
274          fetch_01_11 <= icdata_ary_01_11[index_bf[11:4]];
275         
276          fetch_10_00 <= icdata_ary_10_00[index_bf[11:4]];
277          fetch_10_01 <= icdata_ary_10_01[index_bf[11:4]];
278          fetch_10_10 <= icdata_ary_10_10[index_bf[11:4]];
279          fetch_10_11 <= icdata_ary_10_11[index_bf[11:4]];
280         
281          fetch_11_00 <= icdata_ary_11_00[index_bf[11:4]];
282          fetch_11_01 <= icdata_ary_11_01[index_bf[11:4]];
283          fetch_11_10 <= icdata_ary_11_10[index_bf[11:4]];
284          fetch_11_11 <= icdata_ary_11_11[index_bf[11:4]];
285      `ifdef FPGA_SYN_ALTERA
286          index_f <= index_bf; // Sandeep moved this logic 1/2 cycle forward for altera
287          index_bf <= (fcl_icd_index_sel_ifq_bf ? ifq_icd_index_bf : // Moved this logic from a continuous assignment to a synchronous assignment
288              fdp_icd_index_bf);
289      `endif
290        end
291
292
293        always @(index_f or rdreq_f or fetch_00_00 or fetch_01_00 or fetch_10_00 or fetch_11_00
294                                    or fetch_00_01 or fetch_01_01 or fetch_10_01 or fetch_11_01
295                                    or fetch_00_10 or fetch_01_10 or fetch_10_10 or fetch_11_10
296                                    or fetch_00_11 or fetch_01_11 or fetch_10_11 or fetch_11_11) begin
297//        if (rdreq_f) begin
298            case(index_f[3:2])
299              2'b00: fetdata_f[33:0] = fetch_00_00;
300              2'b01: fetdata_f[33:0] = fetch_01_00;
301              2'b10: fetdata_f[33:0] = fetch_10_00;
302              2'b11: fetdata_f[33:0] = fetch_11_00;
303            endcase
304            case(index_f[3:2])
305              2'b00: fetdata_f[67:34] = fetch_00_01;
306              2'b01: fetdata_f[67:34] = fetch_01_01;
307              2'b10: fetdata_f[67:34] = fetch_10_01;
308              2'b11: fetdata_f[67:34] = fetch_11_01;
309            endcase
310            case(index_f[3:2])
311              2'b00: fetdata_f[101:68] = fetch_00_10;
312              2'b01: fetdata_f[101:68] = fetch_01_10;
313              2'b10: fetdata_f[101:68] = fetch_10_10;
314              2'b11: fetdata_f[101:68] = fetch_11_10;
315            endcase
316            case(index_f[3:2])
317              2'b00: fetdata_f[135:102] = fetch_00_11;
318              2'b01: fetdata_f[135:102] = fetch_01_11;
319              2'b10: fetdata_f[135:102] = fetch_10_11;
320              2'b11: fetdata_f[135:102] = fetch_11_11;
321            endcase
322            case(index_f[3])
323              1'b0: topdata_f[33:0] = fetch_01_00;
324              1'b1: topdata_f[33:0] = fetch_11_00;
325            endcase
326            case(index_f[3])
327              1'b0: topdata_f[67:34] = fetch_01_01;
328              1'b1: topdata_f[67:34] = fetch_11_01;
329            endcase
330            case(index_f[3])
331              1'b0: topdata_f[101:68] = fetch_01_10;
332              1'b1: topdata_f[101:68] = fetch_11_10;
333            endcase
334            case(index_f[3])
335              1'b0: topdata_f[135:102] = fetch_01_11;
336              1'b1: topdata_f[135:102] = fetch_11_11;
337            endcase
338          end
339//        else
340//          begin
341//            fetdata_f = 136'b0;
342//            topdata_f = 136'b0;
343//          end
344//      end
345
346        always @(negedge clk) begin // Writes happening at the negedge
347          if (wrreq_f & (~rst_tri_en)) begin
348            if (worden_f[0]) begin
349              if (wr_index0[1:0] == 2'b0) begin
350                icdata_ary_00_00[wr_index0[11:4]] <= wrdata_f[135:102];
351              end
352              if (wr_index0[1:0] == 2'b1) begin
353                icdata_ary_00_01[wr_index0[11:4]] <= wrdata_f[135:102];
354              end
355              if (wr_index0[1:0] == 2'b10) begin
356                icdata_ary_00_10[wr_index0[11:4]] <= wrdata_f[135:102];
357              end
358              if (wr_index0[1:0] == 2'b11) begin
359                icdata_ary_00_11[wr_index0[11:4]] <= wrdata_f[135:102];
360              end
361            end
362            if (worden_f[1]) begin
363              if (wr_index1[1:0] == 2'b0) begin
364                icdata_ary_01_00[wr_index1[11:4]] <= wrdata_f[101:68];
365              end
366              if (wr_index1[1:0] == 2'b1) begin
367                icdata_ary_01_01[wr_index1[11:4]] <= wrdata_f[101:68];
368              end
369              if (wr_index1[1:0] == 2'b10) begin
370                icdata_ary_01_10[wr_index1[11:4]] <= wrdata_f[101:68];
371              end
372              if (wr_index1[1:0] == 2'b11) begin
373                icdata_ary_01_11[wr_index1[11:4]] <= wrdata_f[101:68];
374              end
375            end
376            if (worden_f[2]) begin
377              if (wr_index2[1:0] == 2'b0) begin
378                icdata_ary_10_00[wr_index2[11:4]] <= wrdata_f[67:34];
379              end
380              if (wr_index2[1:0] == 2'b1) begin
381                icdata_ary_10_01[wr_index2[11:4]] <= wrdata_f[67:34];
382              end
383              if (wr_index2[1:0] == 2'b10) begin
384                icdata_ary_10_10[wr_index2[11:4]] <= wrdata_f[67:34];
385              end
386              if (wr_index2[1:0] == 2'b11) begin
387                icdata_ary_10_11[wr_index2[11:4]] <= wrdata_f[67:34];
388              end
389            end
390            if (worden_f[3]) begin
391              if (wr_index3[1:0] == 2'b0) begin
392                icdata_ary_11_00[wr_index3[11:4]] <= wrdata_f[33:0];
393              end
394              if (wr_index3[1:0] == 2'b1) begin
395                icdata_ary_11_01[wr_index3[11:4]] <= wrdata_f[33:0];
396              end
397              if (wr_index3[1:0] == 2'b10) begin
398                icdata_ary_11_10[wr_index3[11:4]] <= wrdata_f[33:0];
399              end
400              if (wr_index3[1:0] == 2'b11) begin
401                icdata_ary_11_11[wr_index3[11:4]] <= wrdata_f[33:0];
402              end
403            end
404          end
405        end
406endmodule
407
408`else
409
410module bw_r_icd(/*AUTOARG*/
411   // Outputs
412   icd_wsel_fetdata_s1, icd_wsel_topdata_s1, icd_fuse_repair_value, 
413   icd_fuse_repair_en, so, 
414   // Inputs
415   rclk, se, si, reset_l, sehold, fdp_icd_index_bf, ifq_icd_index_bf, 
416   fcl_icd_index_sel_ifq_bf, ifq_icd_wrway_bf, ifq_icd_worden_bf, 
417   ifq_icd_wrdata_i2, fcl_icd_rdreq_bf, fcl_icd_wrreq_bf, 
418   bist_ic_data, rst_tri_en, ifq_icd_data_sel_old_i2, 
419   ifq_icd_data_sel_fill_i2, ifq_icd_data_sel_bist_i2, fuse_icd_wren, 
420   fuse_icd_rid, fuse_icd_repair_value, fuse_icd_repair_en, 
421   efc_spc_fuse_clk1
422   );
423
424   input          rclk, 
425                  se, 
426                  si,
427                  reset_l;
428   input          sehold;
429   
430   input [11:2]   fdp_icd_index_bf,    // index to write to/read from
431                  ifq_icd_index_bf;
432   input          fcl_icd_index_sel_ifq_bf;
433
434   input [1:0]    ifq_icd_wrway_bf;    // way to write to
435   input [3:0]    ifq_icd_worden_bf;   // word to write to (ignore index 1:0)
436   input [135:0]  ifq_icd_wrdata_i2;   // 128b data, 4b sw, 4b parity
437
438   input          fcl_icd_rdreq_bf,
439                              fcl_icd_wrreq_bf;
440
441   input [7:0]    bist_ic_data;        // needs to be expanded
442   input          rst_tri_en;
443   
444   // datain mux selects
445   input          ifq_icd_data_sel_old_i2,
446                  ifq_icd_data_sel_fill_i2,
447                  ifq_icd_data_sel_bist_i2;
448
449   // efuse values for redundancy
450   input         fuse_icd_wren;         
451   input [3:0]   fuse_icd_rid;         
452   input [7:0]   fuse_icd_repair_value;
453   input [1:0]   fuse_icd_repair_en;
454
455   // efuse non ovl clks
456   input         efc_spc_fuse_clk1;  // use this clk to talk to fuse hdr
457   // outputs
458   output [135:0]  icd_wsel_fetdata_s1,
459                               icd_wsel_topdata_s1;
460
461   // redundancy reg read
462   output [7:0]    icd_fuse_repair_value;
463   output [1:0]    icd_fuse_repair_en;
464   
465   output          so;
466   
467
468   //----------------------------------------------------------------------
469   // Declarations
470   //----------------------------------------------------------------------
471
472   // local signals
473`ifdef DEFINE_0IN
474   reg [135:0]    fetdata_s1, 
475                  topdata_s1;
476   wire [135:0]   fetdata_sa, 
477                  topdata_sa;
478`else
479   reg [33:0]     icdata_ary  [4095:0];
480
481   reg [135:0]    fetdata_f,             // way0 is lsb, way3 is msb
482                              topdata_f,
483                  fetdata_sa,
484                  topdata_sa,
485                            fetdata_s1,
486                              topdata_s1;
487`endif
488
489   wire           clk;
490   
491   wire [135:0]   next_wrdata_bf,
492                  wrdata_f,
493                  bist_data_expand;
494
495   wire [11:2]     top_index,
496                   index_bf;
497   
498   reg  [11:2]     index_f;
499
500   wire [11:0]     wr_index0,
501                               wr_index1,
502                               wr_index2,
503                               wr_index3;
504   
505   reg            rdreq_f,
506                              wrreq_f;
507   reg [3:0]      worden_f;
508   reg [1:0]      wrway_f;
509
510
511   // redundancy crap
512   reg [7:0] red0_ev_row,
513             red0_od_row;
514   reg [9:0] red0_ev_col,
515             red0_od_col;
516   reg [7:0] red1_ev_row,
517             red1_od_row;
518   reg [9:0] red1_ev_col,
519             red1_od_col;
520   reg [7:0] red2_ev_row,
521             red2_od_row;
522   reg [9:0] red2_ev_col,
523             red2_od_col;
524   reg [7:0] red3_ev_row,
525             red3_od_row;
526   reg [9:0] red3_ev_col,
527             red3_od_col;
528
529   reg [7:0] icd_fuse_repair_value;
530   reg [1:0] icd_fuse_repair_en;
531   
532   
533   //
534   // Code start here
535   //
536
537   // clk header derives clk from rclk
538   assign         clk = rclk;
539
540
541   // mux merged with flop
542   assign index_bf = fcl_icd_index_sel_ifq_bf ? ifq_icd_index_bf :
543                                                fdp_icd_index_bf;
544
545   always @ (posedge clk)
546     begin
547              // input flops
548        if (~sehold)
549          begin
550                   rdreq_f <= fcl_icd_rdreq_bf;
551                   wrreq_f <= fcl_icd_wrreq_bf;
552                   index_f <= index_bf;
553                   wrway_f <= ifq_icd_wrway_bf;
554                   worden_f <= ifq_icd_worden_bf;
555          end
556              // S stage flops (for rd data)
557              fetdata_s1 <= fetdata_sa;
558              topdata_s1 <= topdata_sa;
559             
560     end // always @ (posedge clk)
561
562   // BIST data
563   assign   bist_data_expand = {bist_ic_data[1:0], {4{bist_ic_data[7:0]}},
564                                bist_ic_data[1:0], {4{bist_ic_data[7:0]}},
565                                bist_ic_data[1:0], {4{bist_ic_data[7:0]}},
566                                bist_ic_data[1:0], {4{bist_ic_data[7:0]}}};   
567
568   
569   // Mux + flop for write data input
570   // ic data enable mux
571   mux3ds #(136) icden_mux(.dout (next_wrdata_bf),
572                                             .in0  (wrdata_f),
573                                             .in1  (ifq_icd_wrdata_i2),
574                                             .in2  (bist_data_expand),
575                                             .sel0 (ifq_icd_data_sel_old_i2),
576                                             .sel1 (ifq_icd_data_sel_fill_i2),
577                                             .sel2 (ifq_icd_data_sel_bist_i2));
578   // write data regsiter
579   // se hold is taken care of by external logic (in ifqctl)
580   dffe_s #(136)  wrdata_reg(.din (next_wrdata_bf),
581                                             .clk (clk),
582                                             .q   (wrdata_f),
583                           .en  (~sehold),
584                                             .se  (se), .si(), .so());
585
586   
587   //----------------------------------------------------------------------
588   // Read Operation
589   //----------------------------------------------------------------------
590
591   // The index has 2 parts.
592   //    1. The 16B half-line index -- bits 11:4
593   //    2. The word offset -- bits 3:2 for reads, xx for writes
594   //    3. The way -- wrway_f for writes, xx for reads
595   // i.e. we read 1 word from each of 4 ways, but
596   //      we write 4 words to 1 way
597   
598   assign top_index = {index_f[11:3] , 1'b1};
599
600`ifdef DEFINE_0IN
601// physical implmentation: ignore this and use else portion
602   
603   wire [15:0] we_wrd = ({ 3'b0,worden_f[3], 3'b0,worden_f[2],
604                           3'b0,worden_f[1], 3'b0,worden_f[0] }) << wrway_f;
605
606   wire [543:0] we = (~wrreq_f        )   ? 544'h0 : 
607                { {34{we_wrd[15]}}, {34{we_wrd[14]}}, {34{we_wrd[13]}}, {34{we_wrd[12]}},
608                  {34{we_wrd[11]}}, {34{we_wrd[10]}}, {34{we_wrd[ 9]}}, {34{we_wrd[ 8]}},
609                  {34{we_wrd[ 7]}}, {34{we_wrd[ 6]}}, {34{we_wrd[ 5]}}, {34{we_wrd[ 4]}},
610                  {34{we_wrd[ 3]}}, {34{we_wrd[ 2]}}, {34{we_wrd[ 1]}}, {34{we_wrd[ 0]}} };
611
612   wire [543:0] din = ({ {4{wrdata_f[ 33: 0]}}, {4{wrdata_f[ 67: 34]}},
613                         {4{wrdata_f[101:68]}}, {4{wrdata_f[135:102]}} });
614   wire [543:0] dout;
615
616   ic_data ic_data ( .nclk(~clk), .adr(index_f[11:4]), .we(we), .din(din), .dout(dout) );
617
618   wire [271:0] dout_l1 = index_f[3] ? dout[543:272] : dout[271:0];
619
620   assign       fetdata_sa[135:0] = index_f[2] ? dout_l1[271:136] : dout_l1[135:0];
621   assign       topdata_sa[135:0] =              dout_l1[271:136];
622
623
624`else 
625
626   // for physical implementation use this
627   
628   // read (inst[31:0] + sw bit + par bit) * 4 ways
629   always @(/*AUTOSENSE*/ /*memory or*/ index_f or rdreq_f
630            or top_index or wrreq_f)
631     begin
632        if (rdreq_f)
633          begin
634             if (wrreq_f)  // rd-wr contention
635               begin
636                        fetdata_f = 136'bx;
637                        topdata_f = 136'bx;
638                     end
639                   else 
640                     begin  // regular read
641                        fetdata_f[33:0] = icdata_ary[{index_f,2'b00}];    // way 0
642                        fetdata_f[67:34] = icdata_ary[{index_f,2'b01}];   // way 1
643                        fetdata_f[101:68] = icdata_ary[{index_f,2'b10}];  // way 2
644                        fetdata_f[135:102] = icdata_ary[{index_f,2'b11}]; // way 3
645
646                        topdata_f[33:0] = icdata_ary[{top_index, 2'b00}];
647                        topdata_f[67:34] = icdata_ary[{top_index, 2'b01}];
648                        topdata_f[101:68] = icdata_ary[{top_index, 2'b10}];
649                        topdata_f[135:102] = icdata_ary[{top_index, 2'b11}];
650                     end // else: !if(wrreq_f)
651          end // if (rdreq_f)
652
653              else      // icache disabled or rd disabled
654                begin
655// JC modified begin
656//                 fetdata_f = 136'bx;
657//                 topdata_f = 136'bx;
658                   fetdata_f = 136'b0;
659                   topdata_f = 136'b0;
660// JC modified end
661                end // else: !if(rdreq_f)
662     end // always @ (...
663
664
665   // SA latch -- to make 0in happy
666   always @ (clk or fetdata_f or topdata_f)
667     begin
668        if (~clk)
669          begin
670             fetdata_sa <= fetdata_f;
671             topdata_sa <= topdata_f;
672          end
673     end
674`endif // !`ifdef DEFINE_0IN
675
676   // final outputs (272bits)
677   assign icd_wsel_fetdata_s1 = fetdata_s1;
678   assign icd_wsel_topdata_s1 = topdata_s1;
679   
680   
681   //----------------------------------------------------------------------
682   // Write Operation
683   //----------------------------------------------------------------------
684   
685   // The index has 3 parts.
686   //    1. The 16B half-line index -- bits 11:4 of index_f
687   //    2. The word offset -- bits 3:2 for reads, xx for writes
688   //    3. The way -- wrway_f for writes, xx for reads
689
690   //                  index          word    way
691   //                  -----          ----    ---
692   assign wr_index0 = {index_f[11:4], 2'b00, wrway_f};
693   assign wr_index1 = {index_f[11:4], 2'b01, wrway_f};
694   assign wr_index2 = {index_f[11:4], 2'b10, wrway_f};
695   assign wr_index3 = {index_f[11:4], 2'b11, wrway_f};
696
697`ifdef DEFINE_0IN
698`else
699   // assume write happens @ negedge clk  (i.e. phase 1)
700   always @ (negedge clk)
701     begin
702              if (wrreq_f & ~rst_tri_en)
703                begin
704                   // instructions always Big Endian
705                   if (worden_f[0]) 
706                        icdata_ary[wr_index0] <= wrdata_f[135:102];
707                   if (worden_f[1]) 
708                        icdata_ary[wr_index1] <= wrdata_f[101:68];
709                   if (worden_f[2]) 
710                        icdata_ary[wr_index2] <= wrdata_f[67:34];
711                   if (worden_f[3]) 
712                        icdata_ary[wr_index3] <= wrdata_f[33:0];
713                end // if (wrreq_f)
714     end // always @ (...
715`endif // !`ifdef DEFINE_0IN
716
717
718   //--------------------------------------------------------------
719   // Redundancy Registers
720   //--------------------------------------------------------------
721   //
722   // read red regs
723   // 16:1 mux
724   always @ (/*AUTOSENSE*/fuse_icd_rid or red0_ev_col or red0_ev_row
725             or red0_od_col or red0_od_row or red1_ev_col
726             or red1_ev_row or red1_od_col or red1_od_row
727             or red2_ev_col or red2_ev_row or red2_od_col
728             or red2_od_row or red3_ev_col or red3_ev_row
729             or red3_od_col or red3_od_row)
730     begin
731        // sub array 0
732        if (fuse_icd_rid[3:0] == 4'b0)
733          begin
734             icd_fuse_repair_value = {2'b0, red0_ev_row[5:0]};
735             icd_fuse_repair_en = red0_ev_row[7:6];
736          end
737        else if (fuse_icd_rid[3:0] == 4'b1)
738          begin
739             icd_fuse_repair_value =  {2'b0, red0_od_row[5:0]};
740             icd_fuse_repair_en = red0_od_row[7:6];
741          end
742        else if (fuse_icd_rid[3:0] == 4'b10)
743          begin
744             icd_fuse_repair_value = red0_ev_col[7:0];
745             icd_fuse_repair_en = red0_ev_col[9:8];
746          end
747        else if (fuse_icd_rid[3:0] == 4'b11)
748          begin
749             icd_fuse_repair_value = red0_od_col[7:0];
750             icd_fuse_repair_en = red0_od_col[9:8];
751          end
752
753        // sub array 1
754        else if (fuse_icd_rid[3:0] == 4'b100)
755          begin
756             icd_fuse_repair_value =  {2'b0, red1_ev_row[5:0]};
757             icd_fuse_repair_en = red1_ev_row[7:6];
758          end
759        else if (fuse_icd_rid[3:0] == 4'b101)
760          begin
761             icd_fuse_repair_value =  {2'b0, red1_od_row[5:0]};
762             icd_fuse_repair_en = red1_od_row[7:6];
763          end
764        else if (fuse_icd_rid[3:0] == 4'b110)
765          begin
766             icd_fuse_repair_value = red1_ev_col[7:0];
767             icd_fuse_repair_en = red1_ev_col[9:8];
768          end
769        else if (fuse_icd_rid[3:0] == 4'b111)
770          begin
771             icd_fuse_repair_value = red1_od_col[7:0];
772             icd_fuse_repair_en = red1_od_col[9:8];
773          end
774
775        // sub array 2
776        else if (fuse_icd_rid[3:0] == 4'b1000)
777          begin
778             icd_fuse_repair_value =  {2'b0, red2_ev_row[5:0]};
779             icd_fuse_repair_en = red2_ev_row[7:6];
780          end
781        else if (fuse_icd_rid[3:0] == 4'b1001)
782          begin
783             icd_fuse_repair_value =  {2'b0, red2_od_row[5:0]};
784             icd_fuse_repair_en = red2_od_row[7:6];
785          end
786        else if (fuse_icd_rid[3:0] == 4'b1010)
787          begin
788             icd_fuse_repair_value = red2_ev_col[7:0];
789             icd_fuse_repair_en = red2_ev_col[9:8];
790          end
791        else if (fuse_icd_rid[3:0] == 4'b1011)
792          begin
793             icd_fuse_repair_value = red2_od_col[7:0];
794             icd_fuse_repair_en = red2_od_col[9:8];
795          end
796
797        // sub array 3
798        else if (fuse_icd_rid[3:0] == 4'b1100)
799          begin
800             icd_fuse_repair_value =  {2'b0, red3_ev_row[5:0]};
801             icd_fuse_repair_en = red3_ev_row[7:6];
802          end
803        else if (fuse_icd_rid[3:0] == 4'b1101)
804          begin
805             icd_fuse_repair_value =  {2'b0, red3_od_row[5:0]};
806             icd_fuse_repair_en = red3_od_row[7:6];
807          end
808        else if (fuse_icd_rid[3:0] == 4'b1110)
809          begin
810             icd_fuse_repair_value = red3_ev_col[7:0];
811             icd_fuse_repair_en = red3_ev_col[9:8];
812          end
813        else // if (fuse_icd_rid[3:0] == 4'b1111)
814          begin
815             icd_fuse_repair_value = red3_od_col[7:0];
816             icd_fuse_repair_en = red3_od_col[9:8];
817          end
818     end // always @ (...
819
820
821   //
822   // write red regs
823   //
824   // use clk1 to latch anything to/from the hdr
825   //
826   // reset_l is an asynchronous reset.  Only the the repair enables [9:8]
827   // need to be reset.  However, the actual circuit resets all the bits.
828   always @ (posedge efc_spc_fuse_clk1 or negedge reset_l)
829     begin
830        if (~reset_l)
831          begin // async reset
832             red0_ev_row[7:0] <= 8'b0;
833             red1_ev_row[7:0] <= 8'b0;
834             red2_ev_row[7:0] <= 8'b0;
835             red3_ev_row[7:0] <= 8'b0;
836
837             red0_od_row[7:0] <= 8'b0;
838             red1_od_row[7:0] <= 8'b0;
839             red2_od_row[7:0] <= 8'b0;
840             red3_od_row[7:0] <= 8'b0;
841
842             red0_ev_col[9:0] <= 10'b0;
843             red1_ev_col[9:0] <= 10'b0;
844             red2_ev_col[9:0] <= 10'b0;
845             red3_ev_col[9:0] <= 10'b0;
846
847             red0_od_col[9:0] <= 10'b0;
848             red1_od_col[9:0] <= 10'b0;
849             red2_od_col[9:0] <= 10'b0;
850             red3_od_col[9:0] <= 10'b0;
851          end // if (~reset_l)
852             
853        else if (fuse_icd_wren & reset_l)
854          begin    // 4:16 decode
855             if (fuse_icd_rid[3:0] == 4'b0)
856               begin
857                  red0_ev_row <= {fuse_icd_repair_en[1:0],
858                                 fuse_icd_repair_value[5:0]};
859               end
860             else if (fuse_icd_rid[3:0] == 4'b1)
861               begin
862                  red0_od_row <= {fuse_icd_repair_en[1:0],
863                                 fuse_icd_repair_value[5:0]};
864               end
865             else if (fuse_icd_rid[3:0] == 4'b10)
866               begin
867                  red0_ev_col <= {fuse_icd_repair_en[1:0],
868                                 fuse_icd_repair_value[7:0]};
869               end
870             else if (fuse_icd_rid[3:0] == 4'b11)
871               begin
872                  red0_od_col <= {fuse_icd_repair_en[1:0],
873                                 fuse_icd_repair_value[7:0]};
874               end
875
876             // sub array 1
877             else if (fuse_icd_rid[3:0] == 4'b100)
878               begin
879                  red1_ev_row <= {fuse_icd_repair_en[1:0],
880                                 fuse_icd_repair_value[5:0]};
881               end
882             else if (fuse_icd_rid[3:0] == 4'b101)
883               begin
884                  red1_od_row <= {fuse_icd_repair_en[1:0],
885                                 fuse_icd_repair_value[5:0]};
886               end
887             else if (fuse_icd_rid[3:0] == 4'b110)
888               begin
889                  red1_ev_col <= {fuse_icd_repair_en[1:0],
890                                 fuse_icd_repair_value[7:0]};
891               end
892             else if (fuse_icd_rid[3:0] == 4'b111)
893               begin
894                  red1_od_col <= {fuse_icd_repair_en[1:0],
895                                 fuse_icd_repair_value[7:0]};
896               end
897
898             // sub array 2
899             else if (fuse_icd_rid[3:0] == 4'b1000)
900               begin
901                  red2_ev_row <= {fuse_icd_repair_en[1:0],
902                                 fuse_icd_repair_value[5:0]};
903               end
904             else if (fuse_icd_rid[3:0] == 4'b1001)
905               begin
906                  red2_od_row <= {fuse_icd_repair_en[1:0],
907                                 fuse_icd_repair_value[5:0]};
908               end
909             else if (fuse_icd_rid[3:0] == 4'b1010)
910               begin
911                  red2_ev_col <= {fuse_icd_repair_en[1:0],
912                                 fuse_icd_repair_value[7:0]};
913               end
914             else if (fuse_icd_rid[3:0] == 4'b1011)
915               begin
916                  red2_od_col <= {fuse_icd_repair_en[1:0],
917                                 fuse_icd_repair_value[7:0]};
918               end
919
920             // sub array 2
921             else if (fuse_icd_rid[3:0] == 4'b1100)
922               begin
923                  red3_ev_row <= {fuse_icd_repair_en[1:0],
924                                 fuse_icd_repair_value[5:0]};
925               end
926             else if (fuse_icd_rid[3:0] == 4'b1101)
927               begin
928                  red3_od_row <= {fuse_icd_repair_en[1:0],
929                                 fuse_icd_repair_value[5:0]};
930               end
931             else if (fuse_icd_rid[3:0] == 4'b1110)
932               begin
933                  red3_ev_col <= {fuse_icd_repair_en[1:0],
934                                 fuse_icd_repair_value[7:0]};
935               end
936             else // if (fuse_icd_rid[3:0] == 4'b1111)
937               begin
938                  red3_od_col <= {fuse_icd_repair_en[1:0],
939                                 fuse_icd_repair_value[7:0]};
940               end
941          end // if (fuse_icd_wren)
942     end // always @ (...
943
944endmodule // bw_r_icd
945
946`endif
Note: See TracBrowser for help on using the repository browser.