source: XOpenSparcT1/trunk/T1-CPU/lsu/lsu_qctl1.v @ 6

Revision 6, 163.7 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: lsu_qctl1.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//  Description:  LSU Queue Control for Sparc Core 
24//      - includes monitoring for pcx queues
25//      - control for lsu datapath
26//      - rd/wr control of dfq
27*/
28////////////////////////////////////////////////////////////////////////
29// header file includes
30////////////////////////////////////////////////////////////////////////
31`include  "sys.h" // system level definition file which contains the
32                  // time scale definition
33`include  "iop.h" 
34
35`include  "lsu.h" 
36
37////////////////////////////////////////////////////////////////////////
38// Local header file includes / local defines
39////////////////////////////////////////////////////////////////////////
40
41module lsu_qctl1 ( /*AUTOARG*/
42   // Outputs
43   lsu_bld_helper_cmplt_m, lsu_bld_cnt_m, lsu_bld_reset, 
44   lsu_pcx_rq_sz_b3, lsu_ramtest_rd_w, ld_stb_full_raw_w2, 
45   lsu_ld_pcx_rq_sel_d2, spc_pcx_req_pq, spc_pcx_atom_pq, 
46   lsu_ifu_pcxpkt_ack_d, pcx_pkt_src_sel, lmq_enable, 
47   imiss_pcx_mx_sel, fwd_int_fp_pcx_mx_sel, lsu_ffu_bld_cnt_w, 
48   lsu_ld_pcx_rq_mxsel, ld_pcx_thrd, lsu_spu_ldst_ack, 
49   pcx_rq_for_stb, pcx_rq_for_stb_d1, lsu_ffu_ack, 
50   lsu_ifu_ld_pcxpkt_vld, lsu_pcx_req_squash0, lsu_pcx_req_squash1, 
51   lsu_pcx_req_squash2, lsu_pcx_req_squash3, lsu_pcx_req_squash_d1, 
52   lsu_pcx_ld_dtag_perror_w2, lsu_tlu_dcache_miss_w2, lsu_bld_pcx_rq, 
53   lsu_bld_rq_addr, lsu_fwdpkt_pcx_rq_sel, lsu_imiss_pcx_rq_sel_d1, 
54   lsu_tlu_pcxpkt_ack, lsu_intrpt_cmplt, lsu_lmq_byp_misc_sel, 
55   lsu_sscan_data, so, lsu_dfq_byp_tid_d1_sel, lmq0_pcx_pkt_way, 
56   lmq1_pcx_pkt_way, lmq2_pcx_pkt_way, lmq3_pcx_pkt_way, 
57   lsu_st_pcx_rq_pick, lsu_stb_pcx_rvld_d1, lsu_stb_rd_tid, 
58   lsu_ld0_spec_vld_kill_w2, lsu_ld1_spec_vld_kill_w2, 
59   lsu_ld2_spec_vld_kill_w2, lsu_ld3_spec_vld_kill_w2, 
60   lsu_st_pcx_rq_vld, 
61   // Inputs
62   rclk, si, se, sehold, grst_l, arst_l, lsu_quad_word_access_g, 
63   pcx_spc_grant_px, ld_inst_vld_e, lsu_ldst_va_m, stb0_l2b_addr, 
64   stb1_l2b_addr, stb2_l2b_addr, stb3_l2b_addr, lsu_ld_miss_g, 
65   ifu_lsu_ldst_fp_e, ld_rawp_st_ced_w2, ld_rawp_st_ackid_w2, 
66   stb0_crnt_ack_id, stb1_crnt_ack_id, stb2_crnt_ack_id, 
67   stb3_crnt_ack_id, ifu_tlu_thrid_e, ldxa_internal, 
68   spu_lsu_ldst_pckt, spu_lsu_ldst_pckt_vld, ifu_tlu_inst_vld_m, 
69   ifu_lsu_flush_w, ifu_lsu_casa_e, lsu_ldstub_g, lsu_swap_g, 
70   stb0_atm_rq_type, stb1_atm_rq_type, stb2_atm_rq_type, 
71   stb3_atm_rq_type, tlb_pgnum_g, stb_rd_for_pcx, ffu_lsu_data, 
72   ffu_lsu_fpop_rq_vld, ifu_lsu_ldst_dbl_e, ifu_lsu_pcxreq_d, 
73   ifu_lsu_destid_s, ifu_lsu_pref_inst_e, tlb_cam_hit_g, 
74   lsu_blk_asi_m, stb_cam_hit_bf, lsu_fwdpkt_vld, 
75   lsu_dcfill_active_e, dfq_byp_sel, lsu_dfq_ld_vld, lsu_fldd_vld_en, 
76   lsu_dfill_dcd_thrd, lsu_fwdpkt_dest, tlu_lsu_pcxpkt_tid, 
77   lsu_stb_empty, tlu_lsu_pcxpkt_vld, tlu_lsu_pcxpkt_l2baddr, 
78   ld_sec_hit_thrd0, ld_sec_hit_thrd1, ld_sec_hit_thrd2, 
79   ld_sec_hit_thrd3, ld_thrd_byp_sel_e, lsu_st_pcx_rq_kill_w2, 
80   ifu_lsu_alt_space_e, lsu_dfq_byp_tid, dfq_byp_ff_en, 
81   stb_ld_full_raw, stb_ld_partial_raw, stb_cam_mhit, 
82   lsu_ldquad_inst_m, stb_cam_wr_no_ivld_m, lsu_ldst_va_way_g, 
83   lsu_dcache_rand, lsu_encd_way_hit, lsu_way_hit_or, dc_direct_map, 
84   lsu_tlb_perr_ld_rq_kill_w, lsu_dcache_tag_perror_g, 
85   lsu_ld_inst_vld_g, asi_internal_m, ifu_lsu_pcxpkt_e_b50, 
86   lda_internal_m, atomic_m, lsu_dcache_iob_rd_w, 
87   ifu_lsu_fwd_data_vld, rst_tri_en, lsu_no_spc_pref, 
88   tlu_early_flush_pipe2_w, lsu_ttype_vld_m2
89   );
90
91
92input     rclk ;
93input                   si;
94input                   se;
95input                   sehold;
96input                   grst_l;
97input                   arst_l;
98
99//input [1:0]           ld_pcx_pkt_wy_g ;
100input                   lsu_quad_word_access_g ;
101
102// LSU <- PCX
103// bit5 - FP, bit4 - IO.
104input [4:0]             pcx_spc_grant_px ;    // pcx grants packet to destination.
105input                   ld_inst_vld_e;        // valid ld inst; d-stage
106input [7:6]             lsu_ldst_va_m ;           // Virt. Addr. of ld/st/atomic.
107
108input [2:0]             stb0_l2b_addr ;         // st's addr for pcx - thread0.
109input [2:0]             stb1_l2b_addr ;         // st's addr for pcx - thread1.
110input [2:0]             stb2_l2b_addr ;         // st's addr for pcx - thread2.
111input [2:0]             stb3_l2b_addr ;         // st's addr for pcx - thread3.
112input                   lsu_ld_miss_g ;         // load misses in dcache.
113//input                   lsu_ld_hit_g ;          // load hits in dcache.
114input                   ifu_lsu_ldst_fp_e ;     // fp load/store.
115
116//input                   ld_stb_full_raw_g ;    // full raw for load - thread0
117//input                   ld_stb_partial_raw_g ; // partial raw for load - thread0
118input                   ld_rawp_st_ced_w2 ;      // store has been acked - thread0
119//input                   ld_rawp_st_ced_g ;      // store has been acked - thread0
120input   [2:0]           ld_rawp_st_ackid_w2 ;    // ackid for acked store - thread0
121input [2:0]             stb0_crnt_ack_id ;      // ackid for crnt outstanding st.
122input [2:0]             stb1_crnt_ack_id ;      // ackid for crnt outstanding st.
123input [2:0]             stb2_crnt_ack_id ;      // ackid for crnt outstanding st.
124input [2:0]             stb3_crnt_ack_id ;      // ackid for crnt outstanding st.
125input [1:0]             ifu_tlu_thrid_e ;       // thread-id
126input                   ldxa_internal ;         // internal ldxa, stg g
127
128input [`PCX_AD_LO+7:`PCX_AD_LO+6] spu_lsu_ldst_pckt ;  // addr bits
129input                   spu_lsu_ldst_pckt_vld ; // vld
130input                   ifu_tlu_inst_vld_m ;    // inst is vld - wstage
131
132input                   ifu_lsu_flush_w ;       // ifu's flush
133input                   ifu_lsu_casa_e ;        // compare-swap instr
134input                   lsu_ldstub_g ;          // ldstub(a) instruction
135input                   lsu_swap_g ;            // swap(a) instruction
136input  [2:1]            stb0_atm_rq_type ;      // stb pcx rq type - atomic
137input  [2:1]            stb1_atm_rq_type ;      // stb pcx rq type - atomic
138input  [2:1]            stb2_atm_rq_type ;      // stb pcx rq type - atomic
139input  [2:1]            stb3_atm_rq_type ;      // stb_pcx_rq_type - atomic
140input [39:37]           tlb_pgnum_g ;           // ldst access to io
141input [3:0]             stb_rd_for_pcx ;        // rd for pcx can be scheduled
142input [80:79]           ffu_lsu_data ;
143input                   ffu_lsu_fpop_rq_vld ;   // ffu dispatches fpop issue request.
144input                   ifu_lsu_ldst_dbl_e ;    // ld/st double
145input                   ifu_lsu_pcxreq_d ;
146input   [2:0]           ifu_lsu_destid_s ;
147input                   ifu_lsu_pref_inst_e ;      // prefetch inst
148input                   tlb_cam_hit_g ;            // tlb cam hit ; error included
149input                   lsu_blk_asi_m ;
150//input                   stb_cam_wptr_vld;
151input                   stb_cam_hit_bf;
152
153input                   lsu_fwdpkt_vld;
154//input  [3:0]            lsu_error_rst;
155input                   lsu_dcfill_active_e;
156input  [3:0]            dfq_byp_sel ;   
157//input  [3:0]            lsu_dfq_byp_mxsel ;   
158//input  [3:0]            lsu_st_ack_rq_stb ;
159input                   lsu_dfq_ld_vld;
160input                   lsu_fldd_vld_en;
161input  [3:0]            lsu_dfill_dcd_thrd ;
162input  [4:0]            lsu_fwdpkt_dest ;
163   
164input [19:18]           tlu_lsu_pcxpkt_tid ;
165input   [3:0]           lsu_stb_empty ;
166input                   tlu_lsu_pcxpkt_vld ;
167input [11:10]           tlu_lsu_pcxpkt_l2baddr ;
168input                   ld_sec_hit_thrd0 ;      // ld has sec. hit against th0
169input                   ld_sec_hit_thrd1 ;      // ld has sec. hit against th1
170input                   ld_sec_hit_thrd2 ;      // ld has sec. hit against th2
171input                   ld_sec_hit_thrd3 ;      // ld has sec. hit against th3
172input [2:0]             ld_thrd_byp_sel_e ;       // stb,ldxa thread byp sel
173input   [3:0]           lsu_st_pcx_rq_kill_w2 ;
174
175input                   ifu_lsu_alt_space_e ;
176input   [1:0]           lsu_dfq_byp_tid;
177
178input                   dfq_byp_ff_en;
179
180//input [3:0]           lsu_dtag_perror_w2 ;
181
182input [7:0]             stb_ld_full_raw ;
183input [7:0]             stb_ld_partial_raw ;
184
185input                   stb_cam_mhit ;          // multiple hits in stb
186input                   lsu_ldquad_inst_m ; // ldquad inst
187
188input                   stb_cam_wr_no_ivld_m ;
189
190input  [1:0]            lsu_ldst_va_way_g ;          // 12:11 for direct map
191input  [1:0]            lsu_dcache_rand;
192input  [1:0]            lsu_encd_way_hit;
193input                   lsu_way_hit_or;
194input                   dc_direct_map;
195//input                   lsu_quad_asi_g;
196
197input                   lsu_tlb_perr_ld_rq_kill_w ;
198
199input                   lsu_dcache_tag_perror_g ;  // dcache tag parity error
200input   [3:0]           lsu_ld_inst_vld_g ;
201//input                  lsu_pcx_ld_dtag_perror_w2 ;    // from qctl2
202
203input                   asi_internal_m ;
204
205input                   ifu_lsu_pcxpkt_e_b50 ;
206
207input                   lda_internal_m ;
208input                   atomic_m ;
209
210input                   lsu_dcache_iob_rd_w ;
211input                   ifu_lsu_fwd_data_vld ;
212
213input                   rst_tri_en ;
214
215output                  lsu_bld_helper_cmplt_m ;
216output  [2:0]           lsu_bld_cnt_m ;
217output                  lsu_bld_reset ;
218
219output                  lsu_pcx_rq_sz_b3 ;
220
221output                  lsu_ramtest_rd_w ;
222
223
224output                  ld_stb_full_raw_w2 ;
225
226output  [3:0]           lsu_ld_pcx_rq_sel_d2 ;
227   
228output  [4:0]           spc_pcx_req_pq;         // request destination for packet.
229              // FPU, IO, L2_BANK[3:0].
230              // 1-hot - create monitor !
231output                  spc_pcx_atom_pq ;       // atomic packet.
232output                  lsu_ifu_pcxpkt_ack_d ;  // ack for I$ fill request.
233output  [3:0]           pcx_pkt_src_sel ;       // - qdp1
234output  [3:0]           lmq_enable ;    // - qdp1
235output                  imiss_pcx_mx_sel ;      // - qdp1
236output  [2:0]           fwd_int_fp_pcx_mx_sel ; // - qdp1
237output  [2:0]           lsu_ffu_bld_cnt_w ;
238//output  [3:0]           ld_pcx_rq_sel ;       // - qctl2
239output  [3:0]           lsu_ld_pcx_rq_mxsel ;   // - qdp1
240output  [1:0]           ld_pcx_thrd ;   // - qdp1
241output                  lsu_spu_ldst_ack ;  // strm ld/st ack to spu
242//output                  strm_sldst_cam_vld; // strm ld/st xslate rq
243//output                  strm_sld_dc_rd_vld; // strm alloc. ld xslate rq.
244//output                  strm_sldst_cam_d2;  // strm ld/st xslate rq-d2
245output  [3:0]           pcx_rq_for_stb ;      // pcx demands rd for store - stb_ctl
246output  [3:0]           pcx_rq_for_stb_d1 ;  // pcx demands rd for store - qdp2
247output                  lsu_ffu_ack ;         // ack to ffu.
248output                  lsu_ifu_ld_pcxpkt_vld ;
249//output  [3:0]           lsu_iobrdge_rply_data_sel ;   // - qdp1
250//output                  lsu_pcx_req_squash ;
251output                  lsu_pcx_req_squash0 ;
252output                  lsu_pcx_req_squash1 ;
253output                  lsu_pcx_req_squash2 ;
254output                  lsu_pcx_req_squash3 ;
255output                  lsu_pcx_req_squash_d1 ;
256output                  lsu_pcx_ld_dtag_perror_w2 ;     // - qdp1
257output  [3:0]           lsu_tlu_dcache_miss_w2 ;
258output                  lsu_bld_pcx_rq ;        // cycle after request  // - qdp1
259output [1:0]            lsu_bld_rq_addr ;       // cycle after request  // - qdp1
260//output                        lsu_ifu_flush_ireg ;
261
262output                 lsu_fwdpkt_pcx_rq_sel ;
263//output                 lsu_ld0_pcx_rq_sel_d1, lsu_ld1_pcx_rq_sel_d1 ;
264//output                 lsu_ld2_pcx_rq_sel_d1, lsu_ld3_pcx_rq_sel_d1 ;
265output                 lsu_imiss_pcx_rq_sel_d1 ;
266output                 lsu_tlu_pcxpkt_ack;
267output  [3:0]           lsu_intrpt_cmplt ;      // intrpt can restart thread
268//output                  lsu_ld_sec_hit_l2access_g ;
269//output  [1:0]           lsu_ld_sec_hit_wy_g ;
270output  [3:0]           lsu_lmq_byp_misc_sel ;    // select g-stage lmq source
271
272output  [12:0]          lsu_sscan_data ;
273
274output                  so;
275output  [3:0]           lsu_dfq_byp_tid_d1_sel;
276
277
278   input [3:0]          lsu_no_spc_pref;
279   
280//output  [1:0]           lsu_lmq_pkt_way_g;
281output  [1:0]           lmq0_pcx_pkt_way;
282output  [1:0]           lmq1_pcx_pkt_way;
283output  [1:0]           lmq2_pcx_pkt_way;
284output  [1:0]           lmq3_pcx_pkt_way;
285output  [3:0]           lsu_st_pcx_rq_pick;
286
287// signals related to logic moved from stb_rwctl
288output                  lsu_stb_pcx_rvld_d1;
289output  [1:0]           lsu_stb_rd_tid;
290
291output                  lsu_ld0_spec_vld_kill_w2 ;
292output                  lsu_ld1_spec_vld_kill_w2 ;
293output                  lsu_ld2_spec_vld_kill_w2 ;
294output                  lsu_ld3_spec_vld_kill_w2 ;
295
296output                  lsu_st_pcx_rq_vld ;
297
298
299   input                tlu_early_flush_pipe2_w;
300   input                lsu_ttype_vld_m2;
301   
302/*AUTOWIRE*/
303// Beginning of automatic wires (for undeclared instantiated-module outputs)
304// End of automatics
305
306wire  thread0_e,thread1_e,thread2_e,thread3_e;
307wire  thread0_w2,thread1_w2,thread2_w2,thread3_w2;
308wire    ld0_inst_vld_e,ld1_inst_vld_e,ld2_inst_vld_e,ld3_inst_vld_e ;
309wire    ld0_inst_vld_g,ld1_inst_vld_g,ld2_inst_vld_g,ld3_inst_vld_g ;
310wire    ld0_inst_vld_w2,ld1_inst_vld_w2,ld2_inst_vld_w2,ld3_inst_vld_w2 ;
311//wire    st_inst_vld_m,st_inst_vld_g;
312wire  imiss_pcx_rq_sel_d1, strm_pcx_rq_sel_d1 ;
313wire  imiss_pcx_rq_sel_d2 ;
314wire    fpop_pcx_rq_sel_d1, fpop_pcx_rq_sel_d2 ;
315wire        imiss_pcx_rq_sel ;
316wire        imiss_pkt_vld ;
317wire  [2:0]     imiss_l2bnk_addr ;
318wire  [4:0]     imiss_l2bnk_dest ;
319wire    fpst_vld_m, fpst_vld_g ;
320wire    fpop_vld_reset ;
321wire    fpop_pcx_rq_sel ;
322wire    fpop_pcx_rq_sel_tmp ;
323wire    fpop_vld_en ;
324wire    fpop_pkt1 ;
325wire    fpop_pkt_vld,fpop_pkt_vld_unmasked ;
326wire    fpop_atom_req, fpop_atom_rq_pq ;
327wire  [4:0] fpop_l2bnk_dest ;
328wire        pcx_req_squash ;
329wire  [4:0] strm_l2bnk_dest ;
330wire    strm_pkt_vld;
331wire        st0_pkt_vld ;
332wire        st1_pkt_vld ;
333wire        st2_pkt_vld ;
334wire        st3_pkt_vld ;
335wire    st0_pcx_rq_sel_d1, st1_pcx_rq_sel_d1;
336wire    st2_pcx_rq_sel_d1, st3_pcx_rq_sel_d1;
337wire    st0_pcx_rq_sel_d2, st1_pcx_rq_sel_d2;
338wire    st2_pcx_rq_sel_d2, st3_pcx_rq_sel_d2;
339wire    st0_pcx_rq_sel_d3, st1_pcx_rq_sel_d3;
340wire    st2_pcx_rq_sel_d3, st3_pcx_rq_sel_d3;
341wire    st0_cas_vld, st1_cas_vld, st2_cas_vld, st3_cas_vld ;
342wire    st0_atomic_vld, st1_atomic_vld, st2_atomic_vld, st3_atomic_vld ;
343wire  [4:0]     st0_l2bnk_dest,st1_l2bnk_dest ;
344wire  [4:0]     st2_l2bnk_dest,st3_l2bnk_dest ;
345wire    bld_helper_cmplt_e, bld_helper_cmplt_m, bld_helper_cmplt_g ;   
346wire    bld_din,bld_dout ;
347wire    bld_g ;
348wire    bld_en ;
349wire    [1:0]   bld_cnt ;
350wire    [1:0]   bcnt_din ;
351wire    [2:0]   bld_rd_din, bld_rd_dout, bld_rd_dout_m ;
352wire    [3:0]   bld_annul,bld_annul_d1 ;
353wire    bld_rd_en ;
354wire    casa_m, casa_g ;
355wire        ld0_vld_reset, ld0_pkt_vld ;
356wire        ld0_pcx_rq_sel_d2, ld1_pcx_rq_sel_d2 ;
357wire        ld2_pcx_rq_sel_d2, ld3_pcx_rq_sel_d2 ;
358wire    ld0_fill_reset, ld1_fill_reset,ld2_fill_reset,ld3_fill_reset;
359wire    ld0_fill_reset_d1,ld1_fill_reset_d1,ld2_fill_reset_d1,ld3_fill_reset_d1;
360wire    ld0_fill_reset_d2,ld1_fill_reset_d2,ld2_fill_reset_d2,ld3_fill_reset_d2;
361wire    ld0_fill_reset_d2_tmp,ld1_fill_reset_d2_tmp,ld2_fill_reset_d2_tmp,ld3_fill_reset_d2_tmp;
362wire  [4:0]     ld0_l2bnk_dest, ld1_l2bnk_dest ;
363wire  [4:0]     ld2_l2bnk_dest, ld3_l2bnk_dest ;
364wire        ld1_vld_reset, ld1_pkt_vld ;
365wire        ld2_vld_reset, ld2_pkt_vld ;
366wire        ld3_vld_reset, ld3_pkt_vld ;
367//wire    casa0_g, casa1_g, casa2_g, casa3_g;
368wire    ld0_rawp_reset,ld0_rawp_en,ld0_rawp_disabled;
369wire    ld1_rawp_reset,ld1_rawp_en,ld1_rawp_disabled;
370wire    ld2_rawp_reset,ld2_rawp_en,ld2_rawp_disabled;
371wire    ld3_rawp_reset,ld3_rawp_en,ld3_rawp_disabled;
372wire  [2:0] ld0_rawp_ackid,ld1_rawp_ackid ;
373wire  [2:0] ld2_rawp_ackid,ld3_rawp_ackid ;
374wire        ld0_pcx_rq_vld, ld1_pcx_rq_vld ;
375wire        ld2_pcx_rq_vld, ld3_pcx_rq_vld ;
376wire  [4:0]     queue_write ;
377wire    mcycle_squash_d1 ;
378//wire        ld_pcx_rq_vld, st_pcx_rq_vld ;
379wire  [4:0] st0_q_wr,st1_q_wr,st2_q_wr,st3_q_wr ;
380wire  [4:0]     sel_qentry0 ;
381wire    st0_atom_rq,st1_atom_rq,st2_atom_rq,st3_atom_rq ;
382wire    st0_atom_rq_d1,st1_atom_rq_d1,st2_atom_rq_d1,st3_atom_rq_d1 ;
383wire    st0_cas_vld_d1,st1_cas_vld_d1,st2_cas_vld_d1,st3_cas_vld_d1 ;
384wire    st0_atom_rq_d2,st1_atom_rq_d2,st2_atom_rq_d2,st3_atom_rq_d2 ;
385wire    st0_cas_vld_d2,st1_cas_vld_d2,st2_cas_vld_d2,st3_cas_vld_d2 ;
386//wire    st_cas_rq_d2,st_quad_rq_d2;
387wire    st_cas_rq_d2 ;
388wire        st0_pcx_rq_vld, st1_pcx_rq_vld;
389wire        st2_pcx_rq_vld, st3_pcx_rq_vld;
390wire    st_atom_rq ;
391wire    st_atom_rq_d1 ;
392wire        imiss_pcx_rq_vld ;
393wire  [4:0] spc_pcx_req_update_g,spc_pcx_req_update_w2 ;
394wire    strm_pcx_rq_vld ;
395wire    fwdpkt_rq_vld ;
396wire    intrpt_pcx_rq_vld ;
397wire    fpop_pcx_rq_vld ;
398wire    [4:0]   pre_qwr ;
399wire        ld0_pcx_rq_sel, ld1_pcx_rq_sel ;
400wire        ld2_pcx_rq_sel, ld3_pcx_rq_sel ;
401wire    strm_pcx_rq_sel ;
402wire    intrpt_pcx_rq_sel ;
403//wire    imiss_strm_pcx_rq_sel ;
404//wire  [2:0]     dest_pkt_sel ;
405wire  [4:0] spc_pcx_req_g ;
406wire  [1:0]   strm_l2bnk_addr ;
407wire  [2:0]     ld0_l2bnk_addr, ld1_l2bnk_addr ;
408wire  [2:0]     ld2_l2bnk_addr, ld3_l2bnk_addr ;
409wire  [4:0]     current_pkt_dest ;
410wire  [7:6]      ldst_va_m, ldst_va_g ;
411wire  [4:0]     ld_pkt_dest ;
412wire  [4:0] st_pkt_dest  ;
413
414
415wire  [4:0]            intrpt_l2bnk_dest ;
416wire                   pcx_req_squash_d1, pcx_req_squash_d2 ;
417wire                   intrpt_pcx_rq_sel_d1 ;
418wire  [2:0] intrpt_l2bnk_addr ;
419//wire                  st0_stq_vld,st1_stq_vld,st2_stq_vld,st3_stq_vld ;
420wire        st0_pcx_rq_sel, st1_pcx_rq_sel;
421wire        st2_pcx_rq_sel, st3_pcx_rq_sel;
422//wire    ld0_sec_hit_g,ld1_sec_hit_g,ld2_sec_hit_g,ld3_sec_hit_g;
423wire    ld0_sec_hit_w2,ld1_sec_hit_w2,ld2_sec_hit_w2,ld3_sec_hit_w2;
424//wire  [3:0] dfq_byp_sel_m, dfq_byp_sel_g ;
425//wire  [3:0] dfq_byp_sel_m;
426wire                 ld0_unfilled,ld1_unfilled,ld2_unfilled,ld3_unfilled;
427wire                 ld0_unfilled_tmp,ld1_unfilled_tmp,ld2_unfilled_tmp,ld3_unfilled_tmp;
428wire  [1:0]          ld0_unfilled_wy,ld1_unfilled_wy,ld2_unfilled_wy,ld3_unfilled_wy ;
429wire        ld0_l2cache_rq,ld1_l2cache_rq ;
430wire        ld2_l2cache_rq,ld3_l2cache_rq ;
431wire                 ld0_pcx_rq_sel_d1, ld1_pcx_rq_sel_d1 ;
432wire                 ld2_pcx_rq_sel_d1, ld3_pcx_rq_sel_d1 ;
433wire         intrpt_pkt_vld;
434wire                 fwdpkt_pcx_rq_sel;
435wire            fwdpkt_pcx_rq_sel_d1,fwdpkt_pcx_rq_sel_d2,fwdpkt_pcx_rq_sel_d3 ;
436wire         reset,dbb_reset_l;
437wire         clk;
438//wire         st_inst_vld_unflushed;
439wire         ldst_dbl_g;
440//wire                  lsu_ld_sec_hit_l2access_g ;
441wire                  lsu_ld_sec_hit_l2access_w2 ;
442//wire  [1:0]           lsu_ld_sec_hit_wy_g ;
443wire  [1:0]           lsu_ld_sec_hit_wy_w2 ;
444//wire  [1:0]  ld_way;
445//wire [1:0]          ld_pcx_pkt_wy_g ;
446
447wire    [3:0]           lsu_dtag_perror_w2 ;
448
449wire    [3:0]           lmq_enable_w2 ;
450wire  ld0_spec_pick_vld_g ,
451      ld0_spec_pick_vld_w2 ;
452wire  ld1_spec_pick_vld_g ,
453      ld1_spec_pick_vld_w2 ;
454wire  ld2_spec_pick_vld_g ,
455      ld2_spec_pick_vld_w2 ;
456wire  ld3_spec_pick_vld_g ,
457      ld3_spec_pick_vld_w2 ;
458wire  non_l2bnk_mx0_d1 ;
459wire  non_l2bnk_mx1_d1 ;
460wire  non_l2bnk_mx2_d1 ;
461wire  non_l2bnk_mx3_d1 ;
462wire  lsu_pcx_req_squash ;
463wire  spc_pcx_atom_pq_buf2 ;
464wire  [4:0]  spc_pcx_req_pq_buf2 ;
465wire         lsu_ld0_pcx_rq_sel_d1, lsu_ld1_pcx_rq_sel_d1 ;
466wire         lsu_ld2_pcx_rq_sel_d1, lsu_ld3_pcx_rq_sel_d1 ;
467
468wire  [3:0]  ld_thrd_force_d1 ;
469wire  [3:0]  st_thrd_force_d1 ;
470wire  [3:0]  misc_thrd_force_d1 ;
471wire  [3:0]  ld_thrd_force_vld ;
472wire  [3:0]  st_thrd_force_vld ;
473wire  [3:0]  misc_thrd_force_vld ;
474wire  [3:0]  all_thrd_force_vld ;
475wire  [3:0]  ld_thrd_pick_din ;
476wire  [3:0]  st_thrd_pick_din ;
477wire  [3:0]  misc_thrd_pick_din ;
478wire  [3:0]  ld_thrd_pick_status_din ;
479wire  [3:0]  st_thrd_pick_status_din ;
480wire  [3:0]  misc_thrd_pick_status_din ;
481wire  [3:0]  ld_thrd_pick_status ;
482wire  [3:0]  st_thrd_pick_status ;
483wire  [3:0]  misc_thrd_pick_status ;
484wire         ld_thrd_pick_rst ;
485wire         st_thrd_pick_rst ;
486wire         misc_thrd_pick_rst ;
487wire         all_thrd_pick_rst ;
488
489
490   
491   
492assign  clk = rclk;
493
494    dffrl_async rstff(.din (grst_l),
495                        .q   (dbb_reset_l),
496                        .clk (clk), .se(se), .si(), .so(),
497                        .rst_l (arst_l));
498
499assign  reset  =  ~dbb_reset_l;
500
501
502//assign        lsu_ifu_flush_ireg = 1'b0 ;
503//=================================================================================================
504// TEMP !! rm from vlin.filter also !!
505//=================================================================================================
506
507wire atm_in_stb_g ;
508assign atm_in_stb_g = 1'b0 ;
509
510//=================================================================================================
511// LOGIC MOVED FROM STB_RWCTL
512//=================================================================================================
513
514// pcx is making request for data in current cycle. Can be multi-hot.
515//assign  pcx_any_rq_for_stb = |pcx_rq_for_stb[3:0] ;
516//assign  pcx_any_rq_for_stb =
517//        (pcx_rq_for_stb[0] & ~lsu_st_pcx_rq_kill_w2[0]) |
518//        (pcx_rq_for_stb[1] & ~lsu_st_pcx_rq_kill_w2[1]) |
519//        (pcx_rq_for_stb[2] & ~lsu_st_pcx_rq_kill_w2[2]) |
520//        (pcx_rq_for_stb[3] & ~lsu_st_pcx_rq_kill_w2[3]) ;
521//
522//dff #(1)  prvld_stgd1 (
523//  .din  (pcx_any_rq_for_stb),
524//  .q  (lsu_stb_pcx_rvld_d1),
525//  .clk  (clk),
526//  .se (1'b0), .si (), .so ()
527//  );
528
529// replacement for above logic - pcx_rq_for_stb is already qual'ed w/ lsu_st_pcx_rq_kill_w2
530// this signal is used in qdp1 and qdp2 as pcx paket valids.
531assign  lsu_stb_pcx_rvld_d1  =  st3_pcx_rq_sel_d1 |
532                                st2_pcx_rq_sel_d1 |
533                                st1_pcx_rq_sel_d1 | 
534                                st0_pcx_rq_sel_d1 ;
535
536
537//assign  stb_rd_tid[0] = pcx_rq_for_stb[1] | pcx_rq_for_stb[3] ;
538//assign  stb_rd_tid[1] = pcx_rq_for_stb[2] | pcx_rq_for_stb[3] ;
539//
540//dff #(2) stbtid_stgd1 (
541//  .din    (stb_rd_tid[1:0]),  .q  (lsu_stb_rd_tid[1:0]),
542//  .clk    (clk),
543//  .se   (1'b0), .si (), .so ()
544//  );
545
546assign  lsu_stb_rd_tid[0]  =  st1_pcx_rq_sel_d1 | st3_pcx_rq_sel_d1;
547assign  lsu_stb_rd_tid[1]  =  st2_pcx_rq_sel_d1 | st3_pcx_rq_sel_d1;
548
549//=================================================================================================
550
551assign  lsu_ramtest_rd_w = lsu_dcache_iob_rd_w | ifu_lsu_fwd_data_vld ;
552
553//=================================================================================================
554// LD PCX PKT WAY
555//=================================================================================================
556
557
558// For direct-map mode, assume that addition set-index bits 12:11 are
559// used to file line in set.
560// timing fix: 5/19/03: move secondary hit way generation to w2
561//assign  ld_way[1:0] =
562//    lsu_way_hit_or ? lsu_encd_way_hit[1:0]:
563//                lsu_ld_sec_hit_l2access_g ? lsu_ld_sec_hit_wy_g[1:0] :
564//                        (dc_direct_map ? lsu_ldst_va_way_g[1:0] : lsu_dcache_rand[1:0]) ;
565//
566//assign  lsu_lmq_pkt_way_g[1:0] =
567//(ldst_dbl_g & st_inst_vld_unflushed & lsu_quad_asi_g) ? 2'b01 :
568//        casa_g ? 2'b00 : ld_way[1:0] ;
569//
570//assign  ld_pcx_pkt_wy_g[1:0] = lsu_lmq_pkt_way_g[1:0];
571wire  [1:0]  ld_way_mx1_g , ld_way_mx2_g , ld_way_mx2_w2;
572
573assign  ld_way_mx1_g[1:0] = 
574    lsu_way_hit_or ? lsu_encd_way_hit[1:0]: 
575                        (dc_direct_map ? lsu_ldst_va_way_g[1:0] : lsu_dcache_rand[1:0]) ;
576
577assign  ld_way_mx2_g[1:0] = 
578//(ldst_dbl_g & st_inst_vld_unflushed & lsu_quad_asi_g) ? 2'b01 :  //quad st, obsolete
579        casa_g ? 2'b00 : ld_way_mx1_g[1:0] ;
580
581dff_s #(2)  ff_ld_way_mx2_w2 (
582        .din    (ld_way_mx2_g[1:0]),
583        .q      (ld_way_mx2_w2[1:0]),
584        .clk    (clk),
585        .se     (1'b0),       .si (),          .so ()
586        );
587
588wire  [1:0]  lsu_lmq_pkt_way_w2;
589assign  lsu_lmq_pkt_way_w2[1:0] =  lsu_ld_sec_hit_l2access_w2 ? lsu_ld_sec_hit_wy_w2[1:0] :
590                                         ld_way_mx2_w2[1:0];
591
592//bug2705 - add mx for way in w2-cycle
593wire  [1:0]  lmq0_pcx_pkt_way_tmp, lmq1_pcx_pkt_way_tmp, lmq2_pcx_pkt_way_tmp, lmq3_pcx_pkt_way_tmp ;
594
595assign  lmq0_pcx_pkt_way[1:0] =  ld0_spec_pick_vld_w2 ? lsu_lmq_pkt_way_w2[1:0] : lmq0_pcx_pkt_way_tmp[1:0] ;
596assign  lmq1_pcx_pkt_way[1:0] =  ld1_spec_pick_vld_w2 ? lsu_lmq_pkt_way_w2[1:0] : lmq1_pcx_pkt_way_tmp[1:0] ;
597assign  lmq2_pcx_pkt_way[1:0] =  ld2_spec_pick_vld_w2 ? lsu_lmq_pkt_way_w2[1:0] : lmq2_pcx_pkt_way_tmp[1:0] ;
598assign  lmq3_pcx_pkt_way[1:0] =  ld3_spec_pick_vld_w2 ? lsu_lmq_pkt_way_w2[1:0] : lmq3_pcx_pkt_way_tmp[1:0] ;
599
600wire    qword_access0,qword_access1,qword_access2,qword_access3;
601
602// Extend by 1-b to add support for 3rd size bit for iospace.
603// move the flops from qdp1 to qctl1
604dffe_s #(2)  ff_lmq0_pcx_pkt_way (
605           .din    (lsu_lmq_pkt_way_w2[1:0]),
606           .q      (lmq0_pcx_pkt_way_tmp[1:0]),
607           .en     (lmq_enable_w2[0]),
608           .clk    (clk),
609           .se     (1'b0),       .si (),          .so ()
610           );
611dffe_s #(2)  ff_lmq1_pcx_pkt_way (
612           .din    (lsu_lmq_pkt_way_w2[1:0]),
613           .q      (lmq1_pcx_pkt_way_tmp[1:0]),
614           .en     (lmq_enable_w2[1]),
615           .clk    (clk),
616           .se     (1'b0),       .si (),          .so ()
617           );
618dffe_s #(2)  ff_lmq2_pcx_pkt_way (
619           .din    (lsu_lmq_pkt_way_w2[1:0]),
620           .q      (lmq2_pcx_pkt_way_tmp[1:0]),
621           .en     (lmq_enable_w2[2]),
622           .clk    (clk),
623           .se     (1'b0),       .si (),          .so ()
624           );
625dffe_s #(2)  ff_lmq3_pcx_pkt_way (
626           .din    (lsu_lmq_pkt_way_w2[1:0]),
627           .q      (lmq3_pcx_pkt_way_tmp[1:0]),
628           .en     (lmq_enable_w2[3]),
629           .clk    (clk),
630           .se     (1'b0),       .si (),          .so ()
631           );
632
633// Q Word Access to IO
634dffe_s   ff_lmq0_qw (
635           .din    (lsu_quad_word_access_g),
636           .q      (qword_access0),
637           .en     (lmq_enable[0]),
638           .clk    (clk),
639           .se     (1'b0),       .si (),          .so ()
640           );
641dffe_s   ff_lmq1_qw (
642           .din    (lsu_quad_word_access_g),
643           .q      (qword_access1),
644           .en     (lmq_enable[1]),
645           .clk    (clk),
646           .se     (1'b0),       .si (),          .so ()
647           );
648dffe_s   ff_lmq2_qw(
649           .din    (lsu_quad_word_access_g),
650           .q      (qword_access2),
651           .en     (lmq_enable[2]),
652           .clk    (clk),
653           .se     (1'b0),       .si (),          .so ()
654           );
655dffe_s   ff_lmq3_qw (
656           .din    (lsu_quad_word_access_g),
657           .q      (qword_access3),
658           .en     (lmq_enable[3]),
659           .clk    (clk),
660           .se     (1'b0),       .si (),          .so ()
661           );
662
663assign  lsu_pcx_rq_sz_b3 =
664        (ld0_pcx_rq_sel_d1 & qword_access0) |
665        (ld1_pcx_rq_sel_d1 & qword_access1) |
666        (ld2_pcx_rq_sel_d1 & qword_access2) |
667        (ld3_pcx_rq_sel_d1 & qword_access3) ;
668
669//=================================================================================================
670// SHADOW SCAN
671//=================================================================================================
672
673
674// Monitors outstanding loads. This would hang a thread.
675assign  lsu_sscan_data[3:0] = 
676                {ld0_pcx_rq_vld, ld1_pcx_rq_vld , ld2_pcx_rq_vld , ld3_pcx_rq_vld} ;
677// Monitors outstanding loads. This would hang issue from stb
678assign  lsu_sscan_data[7:4] = 
679                {st0_pcx_rq_vld, st1_pcx_rq_vld, st2_pcx_rq_vld, st3_pcx_rq_vld} ;
680assign  lsu_sscan_data[8] = imiss_pcx_rq_vld ;  // imiss
681assign  lsu_sscan_data[9] = strm_pcx_rq_vld ;   // strm
682assign  lsu_sscan_data[10] = fwdpkt_rq_vld ;    // fwd rply/rq
683assign  lsu_sscan_data[11] = intrpt_pcx_rq_vld ; // intrpt
684assign  lsu_sscan_data[12] = fpop_pcx_rq_vld ;  // fpop
685
686
687//=================================================================================================
688// QDP1 selects
689//=================================================================================================
690
691wire [3:0] dfq_byp_tid_sel;
692   
693assign dfq_byp_tid_sel[0]  =  (lsu_dfq_byp_tid[1:0]==2'b00);
694assign dfq_byp_tid_sel[1]  =  (lsu_dfq_byp_tid[1:0]==2'b01);
695assign dfq_byp_tid_sel[2]  =  (lsu_dfq_byp_tid[1:0]==2'b10);
696assign dfq_byp_tid_sel[3]  =  (lsu_dfq_byp_tid[1:0]==2'b11);
697//assign dfq_byp_tid__sel[3]  =  ~|(lsu_dfq_byp_d1_sel[2:0]);
698
699wire  [3:0]  lsu_dfq_byp_tid_d1_sel_tmp ;
700   
701dffe_s #(4)  dfq_byp_tid_sel_ff (
702           .din    (dfq_byp_tid_sel[3:0]),
703           .q      (lsu_dfq_byp_tid_d1_sel_tmp[3:0]),
704           .en     (dfq_byp_ff_en),
705           .clk    (clk),
706           .se     (1'b0),       .si (),          .so ()
707           );
708
709//11/21/03 - add rst_tri_en to lsu_dfq_byp_tid_d1_sel[3:0] going to qdp1 as dfq_byp_sel[3:0]
710
711assign  lsu_dfq_byp_tid_d1_sel[2:0]  =  lsu_dfq_byp_tid_d1_sel_tmp[2:0]  & {3{~rst_tri_en}};
712assign  lsu_dfq_byp_tid_d1_sel[3]    =  lsu_dfq_byp_tid_d1_sel_tmp[3]    | rst_tri_en;
713
714
715//=================================================================================================
716// INST_VLD_W GENERATION
717//=================================================================================================
718
719
720wire [1:0] thrid_m, thrid_g ;
721dff_s #(2)  stgm_thrid (
722        .din    (ifu_tlu_thrid_e[1:0]),
723        .q      (thrid_m[1:0]),
724        .clk    (clk),
725        .se     (1'b0),       .si (),          .so ()
726        );
727
728dff_s  #(2) stgg_thrid (
729        .din    (thrid_m[1:0]),
730        .q      (thrid_g[1:0]),
731        .clk    (clk),
732        .se     (1'b0),       .si (),          .so ()
733        );
734
735wire    flush_w_inst_vld_m ;
736wire    lsu_inst_vld_w,lsu_inst_vld_tmp ;
737wire    other_flush_pipe_w ;
738wire  qctl1_flush_pipe_w;
739   
740assign  flush_w_inst_vld_m = 
741        ifu_tlu_inst_vld_m & 
742        ~(qctl1_flush_pipe_w & (thrid_m[1:0] == thrid_g[1:0])) ; // really lsu_flush_pipe_w
743   
744dff_s  stgw_ivld (
745        .din    (flush_w_inst_vld_m),
746        .q      (lsu_inst_vld_tmp),
747        .clk    (clk),
748        .se     (1'b0),       .si (),          .so ()
749        );
750
751
752assign  other_flush_pipe_w = tlu_early_flush_pipe2_w | (lsu_ttype_vld_m2 & lsu_inst_vld_tmp);     
753assign  qctl1_flush_pipe_w = other_flush_pipe_w | ifu_lsu_flush_w ;
754
755assign  lsu_inst_vld_w = lsu_inst_vld_tmp & ~qctl1_flush_pipe_w ;
756
757
758//=================================================================================================
759// SECONDARY VS. PRIMARY LOADS
760//=================================================================================================
761
762// An incoming load can hit can match addresses with an outstanding load request
763// from another thread. In this case, the secondary load must wait until the primary
764// load returns and then it will bypass (but not fill). There can only be one primary
765// load but multiple secondary loads. The secondary loads will not enter the dfq.
766// The primary load will however be recirculated until all secondary loads have bypassed.
767
768// Could have multiple secondary hits. Only one thread can be chosen
769// as primary though.
770
771//An incoming load can match addresses with any outstanding load request from other threads.
772//can be multiple hits
773// timing fix: 5/19/03: move secondary hit way generation to w2
774//
775//assign  ld0_sec_hit_g = ld_sec_hit_thrd0 & ld0_unfilled  ;
776//assign  ld1_sec_hit_g = ld_sec_hit_thrd1 & ld1_unfilled  ;
777//assign  ld2_sec_hit_g = ld_sec_hit_thrd2 & ld2_unfilled  ;
778//assign  ld3_sec_hit_g = ld_sec_hit_thrd3 & ld3_unfilled  ;
779//
780//
781// Fix for Bug1606
782//assign  lsu_ld_sec_hit_l2access_g =
783//         ld0_sec_hit_g | ld1_sec_hit_g | ld2_sec_hit_g | ld3_sec_hit_g ;
784//
785//phase 2
786//since can be multiple hits, it isn't one-hot mux, but fix priority-sel mux
787//assign  lsu_ld_sec_hit_wy_g[1:0] =
788//    ld0_sec_hit_g ? ld0_unfilled_wy[1:0] :
789//      ld1_sec_hit_g ? ld1_unfilled_wy[1:0] :
790//        ld2_sec_hit_g ? ld2_unfilled_wy[1:0] :
791//          ld3_sec_hit_g ? ld3_unfilled_wy[1:0] : 2'bxx ;
792
793wire  ld_sec_hit_thrd0_w2,ld_sec_hit_thrd1_w2,ld_sec_hit_thrd2_w2,ld_sec_hit_thrd3_w2;
794
795dff_s #(4) ff_ld_sec_hit_thrd0to3_d1 (
796        .din    ({ld_sec_hit_thrd0,ld_sec_hit_thrd1,ld_sec_hit_thrd2,ld_sec_hit_thrd3}),
797        .q      ({ld_sec_hit_thrd0_w2,ld_sec_hit_thrd1_w2,ld_sec_hit_thrd2_w2,ld_sec_hit_thrd3_w2}),
798        .clk    (clk),
799        .se     (1'b0),       .si (),          .so ()
800        );
801
802assign  ld0_sec_hit_w2 = ld_sec_hit_thrd0_w2 & ld0_unfilled  ;
803assign  ld1_sec_hit_w2 = ld_sec_hit_thrd1_w2 & ld1_unfilled  ;
804assign  ld2_sec_hit_w2 = ld_sec_hit_thrd2_w2 & ld2_unfilled  ;
805assign  ld3_sec_hit_w2 = ld_sec_hit_thrd3_w2 & ld3_unfilled  ;
806
807// Fix for Bug1606
808assign  lsu_ld_sec_hit_l2access_w2 =
809         ld0_sec_hit_w2 | ld1_sec_hit_w2 | ld2_sec_hit_w2 | ld3_sec_hit_w2 ;
810
811//phase 2
812//since can be multiple hits, it isn't one-hot mux, but fix priority-sel mux
813assign  lsu_ld_sec_hit_wy_w2[1:0] =
814    ld0_sec_hit_w2 ? ld0_unfilled_wy[1:0] :
815      ld1_sec_hit_w2 ? ld1_unfilled_wy[1:0] :
816        ld2_sec_hit_w2 ? ld2_unfilled_wy[1:0] :
817          ld3_sec_hit_w2 ? ld3_unfilled_wy[1:0] : 2'bxx ;
818
819//dff #(4)  stgm_dbypsel (
820//        .din    (dfq_byp_sel[3:0]),
821//        .q      (dfq_byp_sel_m[3:0]),
822//        .clk    (clk),
823//        .se     (1'b0),       .si (),          .so ()
824//        );
825
826//dff #(4)  stgg_dbypsel (
827//        .din    (dfq_byp_sel_m[3:0]),
828//        .q      (dfq_byp_sel_g[3:0]),
829//        .clk    (clk),
830//        .se     (1'b0),       .si (),          .so ()
831//        );
832
833// select g-stage lmq source.
834// Selects for lmq contents shared by fill/hit and alternate sources such as ldxa/raw.
835// Is qualification of dfq_byp_sel_g by ld_thrd_byp_sel necessary ???
836
837wire    [3:0] lmq_byp_misc_sel_e ;
838
839assign  lmq_byp_misc_sel_e[0] = ld_thrd_byp_sel_e[0]  |        // select for ldxa/raw.
840                                dfq_byp_sel[0]  ;              // select for dfq.
841assign  lmq_byp_misc_sel_e[1] = ld_thrd_byp_sel_e[1]  |        // select for ldxa/raw.
842                                dfq_byp_sel[1] ;               // select for dfq.
843assign  lmq_byp_misc_sel_e[2] = ld_thrd_byp_sel_e[2]  |        // select for ldxa/raw.
844                                dfq_byp_sel[2] ;               // select for dfq.
845assign  lmq_byp_misc_sel_e[3] = ~|lmq_byp_misc_sel_e[2:0];
846                                //ld_thrd_byp_sel_e[3]  |        // select for ldxa/raw.
847                                //dfq_byp_sel[3] ;               // select for dfq.
848
849/*
850assign  lmq_byp_misc_sel_e[0] = ld_thrd_byp_sel_e[0]  |        // select for ldxa/raw.
851          (dfq_byp_sel[0] & ~ld_thrd_byp_sel_e[0]) ;  // select for dfq.
852assign  lmq_byp_misc_sel_e[1] = ld_thrd_byp_sel_e[1]  |        // select for ldxa/raw.
853          (dfq_byp_sel[1] & ~ld_thrd_byp_sel_e[1]) ; // select for dfq.
854assign  lmq_byp_misc_sel_e[2] = ld_thrd_byp_sel_e[2]  |        // select for ldxa/raw.
855          (dfq_byp_sel[2] & ~ld_thrd_byp_sel_e[2]) ; // select for dfq.
856assign  lmq_byp_misc_sel_e[3] = ld_thrd_byp_sel_e[3]  |        // select for ldxa/raw.
857          (dfq_byp_sel[3] & ~ld_thrd_byp_sel_e[3]) ; // select for dfq.
858*/
859
860// M-Stage
861//10/27/03 - add rst_tri_en for the select - lsu_lmq_byp_misc_sel to qdp1
862wire  [3:0]  lsu_lmq_byp_misc_sel_tmp ;
863dff_s #(4)  stgg_lbsel (
864        .din    (lmq_byp_misc_sel_e[3:0]),
865        .q      (lsu_lmq_byp_misc_sel_tmp[3:0]),
866        .clk    (clk),
867        .se     (1'b0),       .si (),          .so ()
868        );
869
870assign lsu_lmq_byp_misc_sel[2:0]=  lsu_lmq_byp_misc_sel_tmp[2:0] & {3{~rst_tri_en}} ;
871assign lsu_lmq_byp_misc_sel[3]  =  lsu_lmq_byp_misc_sel_tmp[3] | rst_tri_en ;
872
873
874/*
875assign  lsu_lmq_byp_misc_sel[0] = ld_thrd_byp_sel[0]  |        // select for ldxa/raw.
876          (dfq_byp_sel_g[0] & ~ld_thrd_byp_sel[0]) ;  // select for dfq.
877assign  lsu_lmq_byp_misc_sel[1] = ld_thrd_byp_sel[1]  |        // select for ldxa/raw.
878          (dfq_byp_sel_g[1] & ~ld_thrd_byp_sel[1]) ; // select for dfq.
879assign  lsu_lmq_byp_misc_sel[2] = ld_thrd_byp_sel[2]  |        // select for ldxa/raw.
880          (dfq_byp_sel_g[2] & ~ld_thrd_byp_sel[2]) ; // select for dfq.
881assign  lsu_lmq_byp_misc_sel[3] = ld_thrd_byp_sel[3]  |        // select for ldxa/raw.
882          (dfq_byp_sel_g[3] & ~ld_thrd_byp_sel[3]) ; // select for dfq.
883*/
884
885
886
887//=================================================================================================
888//  Miscellaneous Staging
889//=================================================================================================
890
891   
892assign  thread0_e = ~ifu_tlu_thrid_e[1] & ~ifu_tlu_thrid_e[0] ;
893assign  thread1_e = ~ifu_tlu_thrid_e[1] &  ifu_tlu_thrid_e[0] ;
894assign  thread2_e =  ifu_tlu_thrid_e[1] & ~ifu_tlu_thrid_e[0] ;
895assign  thread3_e =  ifu_tlu_thrid_e[1] &  ifu_tlu_thrid_e[0] ;
896
897assign  ld0_inst_vld_e = ld_inst_vld_e & thread0_e ;
898assign  ld1_inst_vld_e = ld_inst_vld_e & thread1_e ;
899assign  ld2_inst_vld_e = ld_inst_vld_e & thread2_e ;
900assign  ld3_inst_vld_e = ld_inst_vld_e & thread3_e ;
901     
902assign ldst_va_m[7:6] = lsu_ldst_va_m[7:6];
903   
904dff_s  #(6) stgm_ad_m (
905        .din    ({ld0_inst_vld_e,ld1_inst_vld_e,
906    ld2_inst_vld_e,ld3_inst_vld_e,ifu_lsu_ldst_fp_e,
907    ifu_lsu_ldst_dbl_e}),
908        .q      ({ld0_inst_vld_m,ld1_inst_vld_m,
909    ld2_inst_vld_m,ld3_inst_vld_m,ldst_fp_m,
910    ldst_dbl_m}),
911        .clk  (clk),
912        .se     (1'b0),       .si (),          .so ()
913        ); 
914
915
916dff_s  #(8) stgm_ad_g (
917        .din    ({ldst_va_m[7:6],ld0_inst_vld_m,ld1_inst_vld_m,
918        //.din    ({ldst_va_m[8:6],ld0_inst_vld_m,ld1_inst_vld_m,
919    ld2_inst_vld_m,ld3_inst_vld_m,ldst_fp_m,
920    //ld2_inst_vld_m,ld3_inst_vld_m,st_inst_vld_m,ldst_fp_m,
921    ldst_dbl_m}),
922        .q      ({ldst_va_g[7:6],ld0_inst_vld_unflushed,ld1_inst_vld_unflushed,
923        //.q      ({ldst_va_g[8:6],ld0_inst_vld_unflushed,ld1_inst_vld_unflushed,
924    ld2_inst_vld_unflushed,ld3_inst_vld_unflushed,
925    //ld2_inst_vld_unflushed,ld3_inst_vld_unflushed,st_inst_vld_unflushed,
926    ldst_fp_g,ldst_dbl_g}),
927        .clk  (clk),
928        .se     (1'b0),       .si (),          .so ()
929  );
930
931assign  ld0_inst_vld_g = ld0_inst_vld_unflushed & lsu_inst_vld_w ;
932assign  ld1_inst_vld_g = ld1_inst_vld_unflushed & lsu_inst_vld_w ;
933assign  ld2_inst_vld_g = ld2_inst_vld_unflushed & lsu_inst_vld_w ;
934assign  ld3_inst_vld_g = ld3_inst_vld_unflushed & lsu_inst_vld_w ;
935//assign  st_inst_vld_g  = st_inst_vld_unflushed & lsu_inst_vld_w  ;
936
937dff_s  #(4) ivld_stgw2 (
938        .din    ({ld0_inst_vld_g,ld1_inst_vld_g,ld2_inst_vld_g,ld3_inst_vld_g}),
939        .q      ({ld0_inst_vld_w2,ld1_inst_vld_w2,ld2_inst_vld_w2,ld3_inst_vld_w2}),
940        .clk  (clk),
941        .se     (1'b0),       .si (),          .so ()
942  );
943
944dff_s  #(4) th_stgm (
945        .din    ({thread0_e,thread1_e,thread2_e,thread3_e}),
946        .q      ({thread0_m,thread1_m,thread2_m,thread3_m}),
947        .clk  (clk),
948        .se     (1'b0),       .si (),          .so ()
949  );
950
951dff_s  #(4) th_stgg (
952        .din    ({thread0_m,thread1_m,thread2_m,thread3_m}),
953        .q      ({thread0_g,thread1_g,thread2_g,thread3_g}),
954        .clk  (clk),
955        .se     (1'b0),       .si (),          .so ()
956  );
957
958dff_s  #(4) th_stgw2 (
959        .din    ({thread0_g,thread1_g,thread2_g,thread3_g}),
960        .q      ({thread0_w2,thread1_w2,thread2_w2,thread3_w2}),
961        .clk  (clk),
962        .se     (1'b0),       .si (),          .so ()
963  );
964
965
966
967//=================================================================================================
968//
969// IMISS PCX PKT REQ CTL
970//
971//=================================================================================================
972
973
974// ** ifu request packet should be sent out in e-stage **
975// ** Prefer not to make dfq dual-ported **
976
977// Format of IFU pcx packet (50b) :
978//  b49 - valid
979//  b48:44 - req type
980//  b43:42 - rep way (for "eviction" - maintains directory consistency )
981//  b41:40 - mil id
982//  b39:0  - imiss address
983// *
984// destid :
985//  b2  - b39 of pa
986//  b1  - b8  of pa
987//  b0  - b7  of pa
988// pcxpkt :
989//  b51 - valid
990//  b50 - reserved
991//  b49 - NC
992//  b48:44 - req type
993//  b43:42 - rep way (for "eviction" - maintains directory consistency )
994//  b41:40 - mil id
995//  b39:0  - imiss address
996
997// IMISS REQUEST CONTROL
998// Vld is reset if imiss pkt requests and request is not subsequently
999// squashed and new imiss pkt unavailable.
1000
1001// Request rate is 1/3 cycles.
1002
1003/*dff  iack_stg (
1004        .din    (imiss_pcx_rq_sel),
1005        .q      (lsu_ifu_pcxpkt_ack_d),
1006        .clk    (clk),
1007        .se     (1'b0),       .si (),          .so ()
1008        ); */
1009
1010assign  lsu_ifu_pcxpkt_ack_d = imiss_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
1011
1012assign  imiss_pkt_vld =  ifu_lsu_pcxreq_d & ~(imiss_pcx_rq_sel_d1 | imiss_pcx_rq_sel_d2) ;
1013
1014//timing fix: 5/21/03 - ifu sends destid 1 cycle early
1015//assign  imiss_l2bnk_addr[2:0] = ifu_lsu_destid_d[2:0] ;
1016
1017wire  ifu_destid_en ;
1018assign  ifu_destid_en  =  ~ifu_lsu_pcxreq_d | (lsu_ifu_pcxpkt_ack_d & ~ifu_lsu_pcxpkt_e_b50);
1019
1020wire  [2:0]  ifu_destid_d;
1021dffe_s #(3)  ff_ifu_destid_d (
1022           .din    (ifu_lsu_destid_s[2:0]),
1023           .q      (ifu_destid_d[2:0]),
1024           .en     (ifu_destid_en),
1025           .clk    (clk),
1026           .se     (1'b0),       .si (),          .so ()
1027           );
1028assign  imiss_l2bnk_addr[2:0] = ifu_destid_d[2:0] ;
1029
1030assign imiss_l2bnk_dest[0] = 
1031~imiss_l2bnk_addr[2] & ~imiss_l2bnk_addr[1] & ~imiss_l2bnk_addr[0] ;
1032assign imiss_l2bnk_dest[1] = 
1033~imiss_l2bnk_addr[2] & ~imiss_l2bnk_addr[1] &  imiss_l2bnk_addr[0] ;
1034assign imiss_l2bnk_dest[2] = 
1035~imiss_l2bnk_addr[2] & imiss_l2bnk_addr[1] & ~imiss_l2bnk_addr[0] ;
1036assign imiss_l2bnk_dest[3] = 
1037~imiss_l2bnk_addr[2] & imiss_l2bnk_addr[1] &  imiss_l2bnk_addr[0] ;
1038assign imiss_l2bnk_dest[4] = imiss_l2bnk_addr[2] ;
1039
1040
1041//=================================================================================================
1042//  FPOP PCX RQ CTL
1043//=================================================================================================
1044
1045
1046assign  fpst_vld_m = ffu_lsu_data[80] & ffu_lsu_data[79] ;
1047
1048dff_s  fpst_stg (
1049        .din    (fpst_vld_m),
1050        .q      (fpst_vld_g),
1051        .clk  (clk),
1052        .se     (1'b0),       .si (),          .so ()
1053        );
1054
1055// ffu req is  never speculative as it must always begin with the queue empty
1056assign  lsu_ffu_ack =   
1057        fpop_pcx_rq_sel_d1 |   // fpop needs to wait until selected;d1 for timing
1058        //fpop_pcx_rq_sel |   // fpop needs to wait until selected
1059        fpst_vld_g ;    // fpst responds immediately.
1060
1061// req_squash needs to match up with rq_sel_d1 !!!
1062// keep vld around for two cycles.
1063assign fpop_vld_reset = 
1064  (reset | fpop_pcx_rq_sel) ; 
1065  //(reset | fpop_pcx_rq_sel_d1) ;
1066
1067assign fpop_vld_en = ffu_lsu_fpop_rq_vld ;
1068
1069// fpop valid
1070dffre_s #(1)  fpop_vld (
1071        .din  (ffu_lsu_fpop_rq_vld),
1072        .q    (fpop_pkt_vld_unmasked),
1073        .rst  (fpop_vld_reset), .en (fpop_vld_en),
1074        .clk  (clk),
1075        .se   (1'b0),       .si (),          .so ()
1076        );
1077
1078// ** fpop_pkt1 should not be required.
1079assign  fpop_pkt1 = fpop_pkt_vld_unmasked & ~fpop_pcx_rq_sel_d1 ;
1080
1081assign  fpop_pkt_vld = fpop_pkt_vld_unmasked ; // & ~ffu_lsu_kill_fpop_rq ;
1082
1083assign  fpop_atom_req = fpop_pkt1 & fpop_pcx_rq_sel ;
1084
1085dff_s  fpatm_stg (
1086        .din    (fpop_atom_req),
1087        .q      (fpop_atom_rq_pq),
1088        .clk  (clk),
1089        .se     (1'b0),       .si (),          .so ()
1090        );
1091
1092assign fpop_l2bnk_dest[4:0]   = 5'b10000 ;
1093
1094
1095
1096//=================================================================================================
1097//  SPU PCX PKT REQ CONTROL
1098//=================================================================================================
1099 
1100// If ack is sent in a given cycle, then the earliest the spu can send
1101// a response is in the same cycle.
1102
1103wire    strm_pcx_rq_sel_d2 ;
1104assign  lsu_spu_ldst_ack = 
1105  strm_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;  // spu request sent to pcx.
1106  //strm_pcx_rq_sel_d1 & ~pcx_req_squash ;  // spu request sent to pcx.
1107
1108dff_s #(1) rqsel_d2 (
1109  .din (strm_pcx_rq_sel_d1),
1110  .q   (strm_pcx_rq_sel_d2),
1111  .clk (clk),
1112  .se     (1'b0),       .si (),          .so ()
1113);             
1114
1115wire spu_ack_d1 ;
1116dff_s #(1) spuack_d1 (
1117  .din (lsu_spu_ldst_ack),
1118  .q   (spu_ack_d1),
1119  .clk (clk),
1120  .se     (1'b0),       .si (),          .so ()
1121);             
1122
1123dff_s #(2) ff_spu_lsu_ldst_pckt_d1 (
1124  .din (spu_lsu_ldst_pckt[`PCX_AD_LO+7:`PCX_AD_LO+6]),
1125  .q   (strm_l2bnk_addr[1:0]),
1126  .clk (clk),
1127  .se     (1'b0),       .si (),          .so ()
1128);             
1129                             
1130// Streaming does not access io space.
1131assign strm_l2bnk_dest[0] = 
1132~strm_l2bnk_addr[1] & ~strm_l2bnk_addr[0] ;
1133assign strm_l2bnk_dest[1] = 
1134~strm_l2bnk_addr[1] &  strm_l2bnk_addr[0] ;
1135assign strm_l2bnk_dest[2] = 
1136strm_l2bnk_addr[1] & ~strm_l2bnk_addr[0] ;
1137assign strm_l2bnk_dest[3] = 
1138strm_l2bnk_addr[1] &  strm_l2bnk_addr[0] ;
1139assign strm_l2bnk_dest[4] = 1'b0 ;
1140
1141wire  strm_pkt_vld_unmasked ;
1142
1143dff_s #(1) spu_pkt_vld_d1 (
1144        .din    (spu_lsu_ldst_pckt_vld),
1145        .q      (strm_pkt_vld_unmasked),
1146        .clk    (clk),
1147        .se     (1'b0),       .si (),          .so ()
1148        );             
1149                                 
1150assign  strm_pkt_vld = 
1151        strm_pkt_vld_unmasked & ~(strm_pcx_rq_sel_d1 | lsu_spu_ldst_ack | spu_ack_d1);
1152
1153// temp = remove strming interface
1154//assign strm_sldst_cam_vld = 1'b0 ;
1155//assign strm_sld_dc_rd_vld = 1'b0 ;
1156//assign strm_sldst_cam_d2 = 1'b0 ;
1157// temp = remove strming interface
1158
1159
1160//=================================================================================================
1161//  STORE PCX PKT REQ CONTROL
1162//=================================================================================================
1163
1164// Stage by a cycle.
1165
1166// Thread0
1167wire    [2:1]   stb0_rqtype ;
1168wire    [2:0]   stb0_rqaddr ; 
1169dff_s #(5) stgd1_s0rq (
1170        .din    ({stb0_atm_rq_type[2:1], stb0_l2b_addr[2:0]}),
1171        .q      ({stb0_rqtype[2:1],stb0_rqaddr[2:0]}),
1172        .clk    (clk),
1173        .se     (1'b0),       .si (),          .so ()
1174        );
1175
1176// Thread1
1177wire    [2:1]   stb1_rqtype ;
1178wire    [2:0]   stb1_rqaddr ; 
1179dff_s #(5) stgd1_s1rq (
1180        .din    ({stb1_atm_rq_type[2:1], stb1_l2b_addr[2:0]}),
1181        .q      ({stb1_rqtype[2:1],stb1_rqaddr[2:0]}),
1182        .clk    (clk),
1183        .se     (1'b0),       .si (),          .so ()
1184        );
1185
1186// Thread2
1187wire    [2:1]   stb2_rqtype ;
1188wire    [2:0]   stb2_rqaddr ; 
1189dff_s #(5) stgd1_s2rq (
1190        .din    ({stb2_atm_rq_type[2:1], stb2_l2b_addr[2:0]}),
1191        .q      ({stb2_rqtype[2:1],stb2_rqaddr[2:0]}),
1192        .clk    (clk),
1193        .se     (1'b0),       .si (),          .so ()
1194        );
1195
1196// Thread3
1197wire    [2:1]   stb3_rqtype ;
1198wire    [2:0]   stb3_rqaddr ; 
1199dff_s #(5) stgd1_s3rq (
1200        .din    ({stb3_atm_rq_type[2:1], stb3_l2b_addr[2:0]}),
1201        .q      ({stb3_rqtype[2:1],stb3_rqaddr[2:0]}),
1202        .clk    (clk),
1203        .se     (1'b0),       .si (),          .so ()
1204        );
1205
1206wire    stb0_rd_for_pcx,stb1_rd_for_pcx,stb2_rd_for_pcx,stb3_rd_for_pcx ;
1207wire    stb0_rd_for_pcx_tmp,stb1_rd_for_pcx_tmp,stb2_rd_for_pcx_tmp,stb3_rd_for_pcx_tmp ;
1208dff_s #(4) stgd1_rdpcx (
1209        .din    (stb_rd_for_pcx[3:0]),
1210        .q      ({stb3_rd_for_pcx_tmp,stb2_rd_for_pcx_tmp,stb1_rd_for_pcx_tmp,stb0_rd_for_pcx_tmp}),
1211        .clk    (clk),
1212        .se     (1'b0),       .si (),          .so ()
1213        );
1214
1215// timing fix: 5/6 - move kill qual after store pick
1216//assign        stb0_rd_for_pcx = stb0_rd_for_pcx_tmp & ~lsu_st_pcx_rq_kill_w2[0] ;
1217//assign        stb1_rd_for_pcx = stb1_rd_for_pcx_tmp & ~lsu_st_pcx_rq_kill_w2[1] ;
1218//assign        stb2_rd_for_pcx = stb2_rd_for_pcx_tmp & ~lsu_st_pcx_rq_kill_w2[2] ;
1219//assign        stb3_rd_for_pcx = stb3_rd_for_pcx_tmp & ~lsu_st_pcx_rq_kill_w2[3] ;
1220
1221assign  stb0_rd_for_pcx = stb0_rd_for_pcx_tmp;
1222assign  stb1_rd_for_pcx = stb1_rd_for_pcx_tmp;
1223assign  stb2_rd_for_pcx = stb2_rd_for_pcx_tmp;
1224assign  stb3_rd_for_pcx = stb3_rd_for_pcx_tmp;
1225
1226// STORE REQUEST CONTROL
1227// ** Data must come from bypass mux output.
1228// THREAD0
1229
1230// Reads for stores will have to be made non-speculative ????
1231// or delay when ced bit is set such that there is no need
1232// to replay store.
1233// The size of atm_rq_type can be reduced in stb_ctl etc !!!
1234assign  st0_pkt_vld = stb0_rd_for_pcx & ~st0_pcx_rq_sel_d1 ;
1235assign  st0_cas_vld = ~stb0_rqtype[2] & stb0_rqtype[1] ;
1236// stquad not supported.
1237//assign  st0_stq_vld = 1'b0 ;
1238assign  st0_atomic_vld = st0_cas_vld ;
1239  //st0_stq_vld |               // stq(1)
1240  //(~stb0_rqtype[2] & stb0_rqtype[1] & ~stb0_rqtype[0]) ; // cas(1)
1241
1242assign  st1_pkt_vld = stb1_rd_for_pcx & ~st1_pcx_rq_sel_d1 ;
1243assign  st1_cas_vld = ~stb1_rqtype[2] & stb1_rqtype[1] ;
1244//assign  st1_stq_vld = 1'b0 ;
1245assign  st1_atomic_vld = st1_cas_vld ;
1246
1247assign  st2_pkt_vld = stb2_rd_for_pcx & ~st2_pcx_rq_sel_d1 ;
1248assign  st2_cas_vld = ~stb2_rqtype[2] & stb2_rqtype[1] ;
1249//assign  st2_stq_vld = 1'b0 ;
1250assign  st2_atomic_vld = st2_cas_vld ;
1251
1252assign  st3_pkt_vld = stb3_rd_for_pcx & ~st3_pcx_rq_sel_d1 ;
1253assign  st3_cas_vld = ~stb3_rqtype[2] & stb3_rqtype[1] ;
1254//assign  st3_stq_vld = 1'b0 ;
1255assign  st3_atomic_vld = st3_cas_vld ;
1256
1257// Can this be based on st0_pcx_rq_vld instead to ease critical path.
1258
1259//assign  pcx_rq_for_stb[0] = st_pcx_rq_mhot_sel[0] ;
1260//assign  pcx_rq_for_stb[1] = st_pcx_rq_mhot_sel[1] ;
1261//assign  pcx_rq_for_stb[2] = st_pcx_rq_mhot_sel[2] ;
1262//assign  pcx_rq_for_stb[3] = st_pcx_rq_mhot_sel[3] ;
1263
1264   
1265assign st0_l2bnk_dest[0] = 
1266~stb0_rqaddr[2] & ~stb0_rqaddr[1] & ~stb0_rqaddr[0] ;
1267assign st0_l2bnk_dest[1] = 
1268~stb0_rqaddr[2] & ~stb0_rqaddr[1] &  stb0_rqaddr[0] ;
1269assign st0_l2bnk_dest[2] = 
1270~stb0_rqaddr[2] &  stb0_rqaddr[1] & ~stb0_rqaddr[0] ;
1271assign st0_l2bnk_dest[3] = 
1272~stb0_rqaddr[2] &  stb0_rqaddr[1] &  stb0_rqaddr[0] ;
1273assign st0_l2bnk_dest[4] =  stb0_rqaddr[2] ;
1274
1275assign st1_l2bnk_dest[0] = 
1276~stb1_rqaddr[2] & ~stb1_rqaddr[1] & ~stb1_rqaddr[0] ;
1277assign st1_l2bnk_dest[1] = 
1278~stb1_rqaddr[2] & ~stb1_rqaddr[1] &  stb1_rqaddr[0] ;
1279assign st1_l2bnk_dest[2] = 
1280~stb1_rqaddr[2] &  stb1_rqaddr[1] & ~stb1_rqaddr[0] ;
1281assign st1_l2bnk_dest[3] = 
1282~stb1_rqaddr[2] &  stb1_rqaddr[1] &  stb1_rqaddr[0] ;
1283assign st1_l2bnk_dest[4] =  stb1_rqaddr[2] ;
1284
1285assign st2_l2bnk_dest[0] = 
1286~stb2_rqaddr[2] & ~stb2_rqaddr[1] & ~stb2_rqaddr[0] ;
1287assign st2_l2bnk_dest[1] = 
1288~stb2_rqaddr[2] & ~stb2_rqaddr[1] &  stb2_rqaddr[0] ;
1289assign st2_l2bnk_dest[2] = 
1290~stb2_rqaddr[2] &  stb2_rqaddr[1] & ~stb2_rqaddr[0] ;
1291assign st2_l2bnk_dest[3] = 
1292~stb2_rqaddr[2] &  stb2_rqaddr[1] &  stb2_rqaddr[0] ;
1293assign st2_l2bnk_dest[4] =  stb2_rqaddr[2] ;
1294
1295assign st3_l2bnk_dest[0] = 
1296~stb3_rqaddr[2] & ~stb3_rqaddr[1] & ~stb3_rqaddr[0] ;
1297assign st3_l2bnk_dest[1] = 
1298~stb3_rqaddr[2] & ~stb3_rqaddr[1] &  stb3_rqaddr[0] ;
1299assign st3_l2bnk_dest[2] = 
1300~stb3_rqaddr[2] &  stb3_rqaddr[1] & ~stb3_rqaddr[0] ;
1301assign st3_l2bnk_dest[3] = 
1302~stb3_rqaddr[2] &  stb3_rqaddr[1] &  stb3_rqaddr[0] ;
1303assign st3_l2bnk_dest[4] =  stb3_rqaddr[2] ;
1304
1305//=================================================================================================
1306//      BLK-LOAD TRACKING
1307//=================================================================================================
1308
1309// The 64B load request is divided into 4 16B requests, i.e., 4 pcx pkts.
1310// The last bld request to the pcx must be marked as so.
1311// Only one bld can be processed at any time.
1312
1313   wire [1:0] bld_thrd_din;
1314   wire [1:0] bld_thrd_dout;
1315   wire [3:0] bld_dcd_thrd;
1316   wire       ld_03_inst_vld_g;
1317   wire       bld_pcx_rq_sel_d1;
1318   
1319dff_s  stgg_blkasi (
1320        .din    (lsu_blk_asi_m),
1321        .q      (blk_asi_g),
1322        .clk    (clk),
1323        .se     (1'b0),       .si (),          .so ()
1324        );
1325
1326assign  bld_helper_cmplt_e = lsu_fldd_vld_en & bld_dout & (
1327                             bld_dcd_thrd[0] & lsu_dfill_dcd_thrd[0] |
1328                             bld_dcd_thrd[1] & lsu_dfill_dcd_thrd[1] |
1329                             bld_dcd_thrd[2] & lsu_dfill_dcd_thrd[2] |
1330                             bld_dcd_thrd[3] & lsu_dfill_dcd_thrd[3] );
1331
1332   
1333dff_s #(1) stgm_bldhlpr (
1334        .din    (bld_helper_cmplt_e),
1335        .q      (bld_helper_cmplt_m),
1336        .clk    (clk),
1337        .se     (1'b0),       .si (),          .so ()
1338        );
1339
1340assign  lsu_bld_helper_cmplt_m = bld_helper_cmplt_m ;
1341
1342dff_s #(1) stgg_bldhlpr (
1343        .din    (bld_helper_cmplt_m),
1344        .q      (bld_helper_cmplt_g),
1345        .clk    (clk),
1346        .se     (1'b0),       .si (),          .so ()
1347        );
1348
1349wire    alt_space_m, alt_space_g, alt_space_w2 ;
1350dff_s stg_aspacem(
1351        .din    (ifu_lsu_alt_space_e),
1352        .q      (alt_space_m),
1353        .clk    (clk),
1354        .se     (1'b0),       .si (),          .so ()
1355        );
1356
1357dff_s stg_aspaceg(
1358        .din    (alt_space_m),
1359        .q      (alt_space_g),
1360        .clk    (clk),
1361        .se     (1'b0),       .si (),          .so ()
1362        );
1363
1364dff_s stg_aspacew2 (
1365        .din    (alt_space_g),
1366        .q      (alt_space_w2),
1367        .clk    (clk),
1368        .se     (1'b0),       .si (),          .so ()
1369        );
1370
1371
1372// PCX bld helper issue :
1373// 00-1st->01-2nd->10-3rd->11-4th->00
1374   
1375   assign     bld_thrd_din[0] = ld1_inst_vld_unflushed | ld3_inst_vld_unflushed;
1376   assign     bld_thrd_din[1] = ld2_inst_vld_unflushed | ld3_inst_vld_unflushed;
1377
1378
1379   assign ld_03_inst_vld_g =  lsu_inst_vld_w & (
1380                              ld0_inst_vld_unflushed | ld1_inst_vld_unflushed | 
1381                              ld2_inst_vld_unflushed | ld3_inst_vld_unflushed );
1382   
1383   assign       bld_g = blk_asi_g & ldst_fp_g & ldst_dbl_g & alt_space_g & ld_03_inst_vld_g ;
1384                //~lsu_tlb_perr_ld_rq_kill_w ; // Bug 4645
1385
1386wire    bld_w2 ;
1387dff_s #(1) bldstg (
1388        .din    (bld_g),
1389        .q      (bld_w2),
1390        .clk  (clk),
1391        .se     (1'b0),       .si (),          .so ()
1392        );
1393
1394wire    perr_ld_rq_kill_w2 ;
1395wire    bld_perr_kill_w2 ;
1396assign  bld_perr_kill_w2 = bld_w2 & perr_ld_rq_kill_w2 ;
1397   
1398dffre_s #(2) bld_thrd (
1399        .din  (bld_thrd_din[1:0] ),
1400        .q    (bld_thrd_dout[1:0]),
1401        .rst  (bld_reset), .en (bld_g),
1402        .clk  (clk),
1403        .se   (1'b0),       .si (),          .so ()
1404        );                     
1405   assign bld_dcd_thrd[0] = ~bld_thrd_dout[1] & ~bld_thrd_dout[0];
1406   assign bld_dcd_thrd[1] = ~bld_thrd_dout[1] &  bld_thrd_dout[0];
1407   assign bld_dcd_thrd[2] =  bld_thrd_dout[1] & ~bld_thrd_dout[0];
1408   assign bld_dcd_thrd[3] =  bld_thrd_dout[1] &  bld_thrd_dout[0];
1409
1410//bug 2757   
1411   assign bld_pcx_rq_sel_d1 = ld0_pcx_rq_sel_d1 & bld_dcd_thrd[0] | 
1412                              ld1_pcx_rq_sel_d1 & bld_dcd_thrd[1] |
1413                              ld2_pcx_rq_sel_d1 & bld_dcd_thrd[2] | 
1414                              ld3_pcx_rq_sel_d1 & bld_dcd_thrd[3];
1415
1416   //wire   bld_pcx_rq_sel_d2, bld_pcx_rq_sel;
1417   wire    bld_pcx_rq_sel;
1418   //bug 3322
1419//   assign bld_pcx_rq_sel = bld_pcx_rq_sel_d2 & ~pcx_req_squash_d1;
1420   
1421//dff #(1) ff_bld_pcx_rq_sel_d2 (
1422//        .din  (bld_pcx_rq_sel_d1),
1423//        .q    (bld_pcx_rq_sel_d2),
1424//        .clk  (clk),
1425//        .se   (1'b0),       .si (),          .so ()
1426//        );                 
1427
1428  assign bld_pcx_rq_sel = (ld0_pcx_rq_sel_d2 & bld_dcd_thrd[0] | 
1429                           ld1_pcx_rq_sel_d2 & bld_dcd_thrd[1] |
1430                           ld2_pcx_rq_sel_d2 & bld_dcd_thrd[2] | 
1431                           ld3_pcx_rq_sel_d2 & bld_dcd_thrd[3] ) &
1432                           ~pcx_req_squash_d1;
1433     
1434  assign        bld_en = bld_g |  (bld_pcx_rq_sel & bld_dout & ~(bld_cnt[1] & bld_cnt[0])) ; 
1435  assign        bld_din = bld_g | bld_dout ;
1436  assign        bcnt_din[1:0] = bld_cnt[1:0] + {1'b0,(bld_pcx_rq_sel & bld_dout)} ;
1437
1438// Reset by last completing bld helper. 
1439  assign        bld_reset = 
1440        reset | bld_perr_kill_w2 |
1441        (bld_rd_dout[2] & bld_rd_dout[1] & bld_rd_dout[0] & bld_helper_cmplt_g) ;
1442
1443assign  lsu_bld_reset = bld_reset ;
1444
1445wire    bld_dout_tmp ;
1446dffre_s #(3)   bld_pcx_cnt (
1447        .din  ({bcnt_din[1:0],bld_din}),
1448        .q    ({bld_cnt[1:0], bld_dout_tmp}),
1449        .rst  (bld_reset), .en (bld_en),
1450        .clk  (clk),
1451        .se   (1'b0),       .si (),          .so ()
1452        );
1453
1454assign  bld_dout = bld_dout_tmp & ~bld_perr_kill_w2 ;
1455
1456// Last one allows ld-rq-vld to be reset.
1457assign  bld_annul[0] =  bld_dcd_thrd[0] & (bld_dout & ~(bld_cnt[1] & bld_cnt[0])) ;
1458assign  bld_annul[1] =  bld_dcd_thrd[1] & (bld_dout & ~(bld_cnt[1] & bld_cnt[0])) ;
1459assign  bld_annul[2] =  bld_dcd_thrd[2] & (bld_dout & ~(bld_cnt[1] & bld_cnt[0])) ;
1460assign  bld_annul[3] =  bld_dcd_thrd[3] & (bld_dout & ~(bld_cnt[1] & bld_cnt[0])) ;
1461
1462dff_s #(4) bannul_d1 (
1463        .din    (bld_annul[3:0]),
1464        .q      (bld_annul_d1[3:0]),
1465        .clk  (clk),
1466        .se     (1'b0),       .si (),          .so ()
1467        );
1468   
1469// Maintain rd (cpx return pkt counter). This is based on when the blk ld helper completes.
1470// lower 3b of rd have to start out as zero.
1471// Should be asserted 8 times for the entire bld.
1472assign  bld_rd_en = (bld_helper_cmplt_m & bld_dout) ;
1473assign  bld_rd_din[2:0] = bld_rd_dout_m[2:0] + {2'b00,(bld_helper_cmplt_m & bld_dout)} ;
1474//assign        bld_rd_en = (bld_helper_cmplt_g & bld_dout) ;
1475//assign        bld_rd_din[2:0] = bld_rd_dout[2:0] + {2'b00,(bld_helper_cmplt_g & bld_dout)} ;
1476
1477dffre_s #(3)   bld_cpx_cnt (
1478        .din  (bld_rd_din[2:0]),
1479        .q    (bld_rd_dout_m[2:0]),
1480            .rst  (bld_reset), .en   (bld_rd_en),
1481        .clk  (clk),
1482        .se   (1'b0),       .si (),          .so ()
1483        );
1484
1485dff_s #(3) bld_cnt_stg (
1486        .din    (bld_rd_dout_m[2:0]),
1487        .q      (bld_rd_dout[2:0]),
1488        .clk  (clk),
1489        .se     (1'b0),       .si (),          .so ()
1490        );
1491
1492// Select appr. rd. (cpx return pkt counter)
1493assign  lsu_ffu_bld_cnt_w[2:0] = bld_rd_dout[2:0] ;
1494assign  lsu_bld_cnt_m[2:0] = bld_rd_dout_m[2:0] ;
1495
1496// pcx pkt address cntrl.
1497wire    [1:0]   addr_b54 ;
1498assign   addr_b54[1:0] = bld_cnt[1:0];
1499
1500/*wire bld_rq_w2 ;
1501assign bld_rq_w2 = bld_dout; */
1502
1503dff_s #(2) blkrq_d1 (
1504        .din    ({addr_b54[1:0]}),
1505        .q      ({lsu_bld_rq_addr[1:0]}),
1506        .clk  (clk),
1507        .se     (1'b0),       .si (),          .so ()
1508        );
1509
1510assign  lsu_bld_pcx_rq = bld_pcx_rq_sel_d1 & bld_dout ;
1511
1512/*dff #(3) blkrq_d1 (
1513        .din    ({addr_b54[1:0],bld_rq_w2}),
1514        .q      ({lsu_bld_rq_addr[1:0],lsu_bld_pcx_rq}),
1515        .clk  (clk),
1516        .se     (1'b0),       .si (),          .so ()
1517        );*/
1518
1519
1520//=================================================================================================
1521//      LOAD PCX PKT REQ CONTROL
1522//=================================================================================================
1523
1524// Staging pref.
1525wire pref_inst_m, pref_inst_g ;
1526
1527dff_s  stgm_prf (
1528        .din    (ifu_lsu_pref_inst_e),
1529        .q      (pref_inst_m),
1530        .clk  (clk),
1531        .se     (1'b0),       .si (),          .so ()
1532        );
1533
1534dff_s  stgg_prf (
1535        .din    (pref_inst_m),
1536        .q      (pref_inst_g),
1537        .clk  (clk),
1538        .se     (1'b0),       .si (),          .so ()
1539        );
1540
1541// Performance Ctr Info
1542dff_s #(4)  stgg_dmiss (
1543        .din    ({ld3_l2cache_rq,ld2_l2cache_rq,ld1_l2cache_rq,ld0_l2cache_rq}),
1544        .q      (lsu_tlu_dcache_miss_w2[3:0]),
1545        .clk  (clk),
1546        .se     (1'b0),       .si (),          .so ()
1547        );
1548
1549wire  ld0_l2cache_rq_w2, ld1_l2cache_rq_w2, ld2_l2cache_rq_w2, ld3_l2cache_rq_w2 ;
1550
1551assign ld0_l2cache_rq_w2  =  lsu_tlu_dcache_miss_w2[0];
1552assign ld1_l2cache_rq_w2  =  lsu_tlu_dcache_miss_w2[1];
1553assign ld2_l2cache_rq_w2  =  lsu_tlu_dcache_miss_w2[2];
1554assign ld3_l2cache_rq_w2  =  lsu_tlu_dcache_miss_w2[3];
1555
1556wire    pref_vld0_g, pref_vld1_g, pref_vld2_g, pref_vld3_g ;
1557wire    pref_rq_vld0_g, pref_rq_vld1_g, pref_rq_vld2_g, pref_rq_vld3_g ;
1558wire    pref_vld_g ;
1559assign  pref_vld_g = pref_inst_g & ~tlb_pgnum_g[39] & tlb_cam_hit_g ; // Bug 4318.
1560assign  pref_rq_vld0_g = pref_vld_g & thread0_g & lsu_inst_vld_w ;
1561assign  pref_rq_vld1_g = pref_vld_g & thread1_g & lsu_inst_vld_w ;
1562assign  pref_rq_vld2_g = pref_vld_g & thread2_g & lsu_inst_vld_w ;
1563assign  pref_rq_vld3_g = pref_vld_g & thread3_g & lsu_inst_vld_w ;
1564assign  pref_vld0_g = pref_inst_g & thread0_g ;
1565assign  pref_vld1_g = pref_inst_g & thread1_g ;
1566assign  pref_vld2_g = pref_inst_g & thread2_g ;
1567assign  pref_vld3_g = pref_inst_g & thread3_g ;
1568
1569//=========================================================================================
1570// Shift full-raw/partial-raw logic from rw_ctl to qctl1
1571
1572wire    ldquad_inst_g ;
1573dff_s  ldq_stgg (
1574  .din    (lsu_ldquad_inst_m), .q (ldquad_inst_g),
1575  .clk    (clk),
1576  .se   (1'b0), .si (), .so ()
1577  );
1578
1579wire    io_ld,io_ld_w2 ;
1580assign  io_ld = tlb_pgnum_g[39] ; // Bug 4362
1581//assign  io_ld = tlb_pgnum_g[39]  & ~(~tlb_pgnum_g[38]  & tlb_pgnum_g[37]) ;
1582
1583wire    stb_not_empty ;
1584assign  stb_not_empty  =
1585  thread0_g ? ~lsu_stb_empty[0] :
1586    thread1_g ? ~lsu_stb_empty[1] :
1587      thread2_g ? ~lsu_stb_empty[2] :
1588                        ~lsu_stb_empty[3] ;
1589
1590wire    ldq_hit_g,ldq_hit_w2 ;
1591wire    ldq_stb_cam_hit ;
1592assign  ldq_stb_cam_hit = stb_cam_hit_bf & ldquad_inst_g ;
1593// Terms can be made common.
1594assign  ldq_hit_g = ldq_stb_cam_hit ;
1595
1596wire    full_raw_g,partial_raw_g ;
1597wire    full_raw_w2,partial_raw_w2 ;
1598assign  full_raw_g = |stb_ld_full_raw[7:0] ;
1599assign  partial_raw_g = |stb_ld_partial_raw[7:0] ;
1600
1601wire    stb_cam_mhit_w2 ;
1602wire    stb_not_empty_w2 ;
1603dff_s #(6) stgw2_rawcond (
1604        .din    ({full_raw_g,partial_raw_g,stb_cam_mhit,ldq_hit_g,io_ld,stb_not_empty}),
1605        .q      ({full_raw_w2,partial_raw_w2,stb_cam_mhit_w2,ldq_hit_w2,io_ld_w2,
1606                stb_not_empty_w2}),
1607        .clk    (clk),
1608        .se     (1'b0),       .si (),          .so ()
1609        );
1610
1611// BEGIN !!! ld_stb_full_raw_g for SAS support only !!!
1612//wire  ld_stb_full_raw_g ;
1613//wire  ld_stb_partial_raw_g ;
1614
1615// END !!! ld_stb_full_raw_g for SAS support only !!!
1616assign  ld_stb_full_raw_w2 =
1617        (full_raw_w2 & ~(stb_cam_mhit_w2 | ldq_hit_w2 | io_ld_w2)) ;
1618        //(full_raw_w2 & ~(stb_cam_mhit_w2 | ldq_hit_w2 | io_ld_w2)) ; // Bug 3624
1619wire    ld_stb_partial_raw_w2 ;
1620wire    stb_cam_hit_w2 ;
1621assign  ld_stb_partial_raw_w2 =
1622        (partial_raw_w2 | stb_cam_mhit_w2 | ldq_hit_w2 | 
1623        (io_ld_w2 & stb_not_empty_w2)) ;
1624        //(partial_raw_w2 | stb_cam_mhit_w2 | ldq_hit_w2 | (io_ld_w2 & stb_not_empty_w2)) ;
1625
1626//=========================================================================================
1627
1628/*wire  ld_stb_full_raw_w2 ;
1629dff_s #(1) stgw2_fraw (
1630        .din    (ld_stb_full_raw_g),
1631        .q      (ld_stb_full_raw_w2),
1632        .clk  (clk),
1633        .se     (1'b0),       .si (),          .so ()
1634        ); */
1635
1636// THREAD0 LOAD PCX REQUEST CONTROL
1637
1638//=====
1639// For delayed ld0,1,2,3_l2cache_rq, we need to delay certain
1640// inputs to flops enabled by ld0,1,2,3_l2cache_rq.
1641
1642wire    ld0_ldbl_rq_w2 ;
1643wire    ld1_ldbl_rq_w2 ;
1644wire    ld2_ldbl_rq_w2 ;
1645wire    ld3_ldbl_rq_w2 ;
1646// wire [1:0]   ld_pcx_pkt_wy_w2 ;
1647 wire           pref_rq_vld0_w2,pref_rq_vld1_w2,pref_rq_vld2_w2,pref_rq_vld3_w2 ;
1648 wire           non_l2bnk ;
1649 wire           non_l2bnk_w2 ;
1650 wire [7:6]     ldst_va_w2 ;
1651
1652dff_s #(7) stgw2_l2crqmx (
1653        .din    ({
1654                //ld_pcx_pkt_wy_g[1:0],
1655                pref_rq_vld0_g,pref_rq_vld1_g,pref_rq_vld2_g,pref_rq_vld3_g,
1656                non_l2bnk,
1657                ldst_va_g[7:6]}),
1658        .q      ({
1659                //ld_pcx_pkt_wy_w2[1:0],
1660                pref_rq_vld0_w2,pref_rq_vld1_w2,pref_rq_vld2_w2,pref_rq_vld3_w2,
1661                non_l2bnk_w2,
1662                ldst_va_w2[7:6]}),
1663        .clk  (clk),
1664        .se     (1'b0),       .si (),          .so ()
1665        );
1666
1667// wire [1:0]   ld_pcx_pkt_wy_mx0,ld_pcx_pkt_wy_mx1,ld_pcx_pkt_wy_mx2,ld_pcx_pkt_wy_mx3 ;
1668 wire           pref_rq_vld0_mx,pref_rq_vld1_mx,pref_rq_vld2_mx,pref_rq_vld3_mx ;
1669 wire           non_l2bnk_mx0,non_l2bnk_mx1,non_l2bnk_mx2,non_l2bnk_mx3 ;
1670 wire [7:6]     ldst_va_mx0,ldst_va_mx1,ldst_va_mx2,ldst_va_mx3 ;
1671
1672// timing fix: 5/19/03: move secondary hit way generation to w2
1673//                      remove ld_pcx_pkt_wy_mx[0-3] and replace w/ lsu_lmq_pkt_way_w2
1674// assign       ld_pcx_pkt_wy_mx0[1:0] =
1675//      ld0_ldbl_rq_w2 ? ld_pcx_pkt_wy_w2[1:0] : ld_pcx_pkt_wy_g[1:0] ;
1676// assign       ld_pcx_pkt_wy_mx1[1:0] =
1677//      ld1_ldbl_rq_w2 ? ld_pcx_pkt_wy_w2[1:0] : ld_pcx_pkt_wy_g[1:0] ;
1678// assign       ld_pcx_pkt_wy_mx2[1:0] =
1679//      ld2_ldbl_rq_w2 ? ld_pcx_pkt_wy_w2[1:0] : ld_pcx_pkt_wy_g[1:0] ;
1680// assign       ld_pcx_pkt_wy_mx3[1:0] =
1681//      ld3_ldbl_rq_w2 ? ld_pcx_pkt_wy_w2[1:0] : ld_pcx_pkt_wy_g[1:0] ;
1682
1683
1684 assign pref_rq_vld0_mx =
1685        ld0_ldbl_rq_w2 ? pref_rq_vld0_w2 : pref_rq_vld0_g ;
1686 assign pref_rq_vld1_mx =
1687        ld1_ldbl_rq_w2 ? pref_rq_vld1_w2 : pref_rq_vld1_g ;
1688 assign pref_rq_vld2_mx =
1689        ld2_ldbl_rq_w2 ? pref_rq_vld2_w2 : pref_rq_vld2_g ;
1690 assign pref_rq_vld3_mx =
1691        ld3_ldbl_rq_w2 ? pref_rq_vld3_w2 : pref_rq_vld3_g ;
1692 assign non_l2bnk_mx0 =
1693        ld0_ldbl_rq_w2 ? non_l2bnk_w2 : non_l2bnk ;
1694 assign non_l2bnk_mx1 =
1695        ld1_ldbl_rq_w2 ? non_l2bnk_w2 : non_l2bnk ;
1696 assign non_l2bnk_mx2 =
1697        ld2_ldbl_rq_w2 ? non_l2bnk_w2 : non_l2bnk ;
1698 assign non_l2bnk_mx3 =
1699        ld3_ldbl_rq_w2 ? non_l2bnk_w2 : non_l2bnk ;
1700
1701//timing fix: 10/13/03 - ldst_va_mx[0-3] is used in the same cycle 'cos of perf bug fix-bug2705
1702//            this delays the ld request valid which in turn delays pcx_rq_for_stb
1703//            fix is to isolate this mux and the following l2bank addr mux from ld?_ldbl_rq_w2;
1704//            use ld[0-3]_inst_vld_w2 instead of ld[0-3]_ldbl_rq_w2 as select
1705 assign ldst_va_mx0[7:6] =
1706        ld0_inst_vld_w2 ? ldst_va_w2[7:6] : ldst_va_g[7:6] ;
1707 assign ldst_va_mx1[7:6] =
1708        ld1_inst_vld_w2 ? ldst_va_w2[7:6] : ldst_va_g[7:6] ;
1709 assign ldst_va_mx2[7:6] =
1710        ld2_inst_vld_w2 ? ldst_va_w2[7:6] : ldst_va_g[7:6] ;
1711 assign ldst_va_mx3[7:6] =
1712        ld3_inst_vld_w2 ? ldst_va_w2[7:6] : ldst_va_g[7:6] ;
1713
1714//=====
1715
1716wire    atomic_g ;
1717assign  atomic_g = casa_g | lsu_swap_g | lsu_ldstub_g ;
1718
1719   wire dbl_force_l2access_g;
1720   wire dbl_force_l2access_w2;
1721   assign dbl_force_l2access_g = ldst_dbl_g & ~(ldst_fp_g & ~(alt_space_g & blk_asi_g));
1722   
1723dff_s #(2) stgw2_atm (
1724        .din    ({atomic_g, dbl_force_l2access_g}),
1725        .q      ({atomic_w2,dbl_force_l2access_w2}),
1726        .clk  (clk),
1727        .se     (1'b0),       .si (),          .so ()
1728        );
1729
1730dff_s #(1) stgw2_perrkill (
1731        .din    (lsu_tlb_perr_ld_rq_kill_w),
1732        .q      (perr_ld_rq_kill_w2),
1733        .clk  (clk),
1734        .se     (1'b0),       .si (),          .so ()
1735        );
1736
1737wire    asi_internal_g,asi_internal_w2;
1738dff_s #(1) stgg_intasi (
1739        .din    (asi_internal_m),
1740        .q      (asi_internal_g),
1741        .clk  (clk),
1742        .se     (1'b0),       .si (),          .so ()
1743        );
1744
1745dff_s #(1) stgw2_intasi (
1746        .din    (asi_internal_g),
1747        .q      (asi_internal_w2),
1748        .clk  (clk),
1749        .se     (1'b0),       .si (),          .so ()
1750        );
1751
1752wire    ld0_l2cache_rq_kill ; 
1753assign  ld0_l2cache_rq_kill = 
1754        ld0_inst_vld_w2 & ((ld_stb_full_raw_w2 & ~dbl_force_l2access_w2) | perr_ld_rq_kill_w2) ; 
1755                                                // full-raw which looks like partial
1756assign  ld0_ldbl_rq_w2 = 
1757                ((ld_stb_full_raw_w2 & dbl_force_l2access_w2) | ld_stb_partial_raw_w2)
1758                        & ~atomic_w2 & ~perr_ld_rq_kill_w2 & ~(asi_internal_w2 & alt_space_w2) 
1759                        & ld0_inst_vld_w2 ;
1760
1761//bug:2877 - dtag parity error 2nd packet request; dont reset if dtag parity error 2nd pkt valid
1762//           dtag error is reset 1 cycle after 1st pkt sent
1763//----------------------------------------------------------------------------------------------------------
1764// |       1       |        2       |         3          |        4       |        5        |        6    |
1765//  spc_pcx_rq_pq=1   ld_err-pkt1                                           spc_pcx_rq_pq=1   ld_err-pkt2
1766//                                     ld0_vld_reset=0       pick 2nd pkt
1767//                                     error_rst=1
1768//----------------------------------------------------------------------------------------------------------
1769
1770wire   [3:0]  dtag_perr_pkt2_vld_d1 ;
1771assign ld0_vld_reset = 
1772  (reset | (ld0_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld0_inst_vld_g | bld_annul_d1[0] | dtag_perr_pkt2_vld_d1[0]))) |
1773  ld0_l2cache_rq_kill ;
1774  //(reset | (ld0_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld0_inst_vld_g | bld_annul_d1[0]))) |
1775
1776// The equation for partial raw has redundancy !! Change it.
1777// prefetch will not bypass from stb
1778/* prim vs sec phase 2 change
1779assign ld0_l2cache_rq =
1780        (((lsu_ld_miss_g & ~ld_stb_full_raw_g  & ~ld_sec_hit_g & ~ldxa_internal) |
1781        ((lsu_ld_hit_g | lsu_ld_miss_g) & (ld_stb_partial_raw_g | (ld_stb_full_raw_g & ldst_dbl_g))))
1782        & ~atomic_g & ld0_inst_vld_g) |
1783        | (pref_inst_g & tlb_cam_hit_g & thread0_g) ;
1784*/
1785
1786
1787wire  ld0_l2cache_rq_g;
1788
1789assign ld0_l2cache_rq_g = 
1790        (((lsu_ld_miss_g & ~ldxa_internal))
1791        //((lsu_ld_hit_g | lsu_ld_miss_g) & (ld_stb_partial_raw_g)))
1792        & ~atomic_g & ld0_inst_vld_g)
1793        | pref_rq_vld0_g; 
1794
1795assign ld0_l2cache_rq = ld0_l2cache_rq_g | ld0_ldbl_rq_w2 ;
1796   
1797wire  ld0_pkt_vld_unmasked ;
1798wire  ld1_pkt_vld_unmasked ;
1799wire  ld2_pkt_vld_unmasked ;
1800wire  ld3_pkt_vld_unmasked ;
1801   
1802// ld valid until request made.
1803wire pref_rq_vld0;         
1804dffre_s #(2)  ld0_vld (
1805        .din    ({ld0_l2cache_rq, pref_rq_vld0_mx}    ),
1806        .q      ({ld0_pkt_vld_unmasked, pref_rq_vld0}),
1807  .rst  (ld0_vld_reset),  .en (ld0_l2cache_rq),
1808        .clk  (clk),
1809        .se     (1'b0),       .si (),          .so ()
1810        );
1811
1812// bug2705 - speculative pick in w-cycle -begin
1813// dbl_force_l2access_g is set for ldd(f),std(f),ldq,stq
1814//perf fix: 7/29/03 - kill spec vld if other thread non-spec valids are set
1815//timing fix: 8/29/03 - flop atomic_m and ldxa_internal_m from dctl for spec req
1816wire    atomic_or_ldxa_internal_rq_m ;
1817assign  atomic_or_ldxa_internal_rq_m  =  atomic_m | lda_internal_m ;
1818
1819dff_s #(1) ff_atomic_or_ldxa_internal_rq_g (
1820        .din    (atomic_or_ldxa_internal_rq_m),
1821        .q      (atomic_or_ldxa_internal_rq_g),
1822        .clk  (clk),
1823        .se     (1'b0),       .si (),          .so ()
1824        );
1825
1826wire    ld0_spec_vld_g ;
1827assign  ld0_spec_vld_g  =  ld0_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g &
1828                           ~atomic_or_ldxa_internal_rq_g &
1829                           ~(ld1_pkt_vld_unmasked | ld2_pkt_vld_unmasked | ld3_pkt_vld_unmasked);
1830//assign  ld0_spec_vld_g  =  ld0_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g ;
1831
1832dff_s #(1) ff_ld0_spec_pick_vld_w2 (
1833        .din    (ld0_spec_pick_vld_g),
1834        .q      (ld0_spec_pick_vld_w2),
1835        .clk  (clk),
1836        .se     (1'b0),       .si (),          .so ()
1837        );
1838
1839// kill packet valid if spec req is picked in w and stb hits in w2
1840// cannot use ld0_ldbl_rawp_en_w2 because it is late signal instead use ld0_ldbl_rq_w2
1841//timing fix: 7/21/03 - kill pkt vld if spec pick in w-cycle was to non$ address
1842//timing fix: 8/6/03 - kill pkt_vld if ld?_l2cache_rq_g=0 in w-cycle but spec_pick=1
1843wire    ld0_pkt_vld_tmp ;
1844//bug 3964 - replace ld0_pkt_vld_unmasked w/ ld0_l2cache_rq_w2
1845//assign lsu_ld0_spec_vld_kill_w2  =  ld0_spec_pick_vld_w2 & (~ld0_pkt_vld_unmasked | ld0_l2cache_rq_kill | ld0_ldbl_rq_w2 | non_l2bnk_mx0_d1) ;
1846assign lsu_ld0_spec_vld_kill_w2  =  ld0_spec_pick_vld_w2 & (~ld0_l2cache_rq_w2 | ld0_l2cache_rq_kill | ld0_ldbl_rq_w2 | non_l2bnk_mx0_d1) ;
1847
1848assign  ld0_pkt_vld_tmp =  ld0_pkt_vld_unmasked & ~(ld0_pcx_rq_sel_d1 | ld0_pcx_rq_sel_d2) &
1849                      ~(ld0_l2cache_rq_kill | ld0_ldbl_rq_w2) &
1850                      ~(pref_rq_vld0 & lsu_no_spc_pref[0]) ;  // prefetch pending
1851                       
1852assign  ld0_pkt_vld = ld0_pkt_vld_tmp | ld0_spec_vld_g ;
1853// bug2705 - speculative pick in w-cycle -end
1854
1855//assign  ld0_pkt_vld = ld0_pkt_vld_unmasked & ~ld0_pcx_rq_sel_d1 ;
1856
1857assign  ld0_fill_reset = reset | (lsu_dfq_ld_vld & lsu_dcfill_active_e & dfq_byp_sel[0]) ;
1858
1859
1860dff_s #(4) stgm_lduwyd1 (
1861        .din    ({ld0_fill_reset,ld1_fill_reset,ld2_fill_reset,ld3_fill_reset}),
1862        .q      ({ld0_fill_reset_d1,ld1_fill_reset_d1,ld2_fill_reset_d1,ld3_fill_reset_d1}),
1863        .clk  (clk),
1864        .se     (1'b0),       .si (),          .so ()
1865        );
1866
1867dff_s #(4) stgm_lduwyd2 (
1868        .din    ({ld0_fill_reset_d1,ld1_fill_reset_d1,ld2_fill_reset_d1,ld3_fill_reset_d1}),
1869        .q      ({ld0_fill_reset_d2_tmp,ld1_fill_reset_d2_tmp,ld2_fill_reset_d2_tmp,ld3_fill_reset_d2_tmp}),
1870        .clk  (clk),
1871        .se     (1'b0),       .si (),          .so ()
1872        );
1873
1874wire  ld0_l2cache_rq_w2_tmp;
1875wire  ld0_l2cache_rq_g_tmp;
1876
1877assign ld0_l2cache_rq_g_tmp  =  ld0_l2cache_rq_g & ~pref_inst_g ;
1878
1879dff_s #(1) ff_ld0_l2cache_rq_w2 (
1880        .din    (ld0_l2cache_rq_g_tmp),
1881        .q      (ld0_l2cache_rq_w2_tmp),
1882        .clk  (clk),
1883        .se     (1'b0),       .si (),          .so ()
1884        );
1885
1886
1887//wire ld0_unfilled_en ;
1888//assign        ld0_unfilled_en = ld0_l2cache_rq & ~pref_inst_g ;
1889wire ld0_unfilled_wy_en ;
1890assign  ld0_unfilled_wy_en = ld0_l2cache_rq_w2_tmp | ld0_ldbl_rq_w2 ;
1891
1892wire  ld0_l2cache_rq_tmp;
1893assign ld0_l2cache_rq_tmp  = ld0_unfilled_wy_en & ~ld0_l2cache_rq_kill;
1894
1895// ld valid until fill occur.
1896dffre_s #(1)  ld0out_state (
1897        //.din    (ld0_l2cache_rq),
1898        .din    (ld0_l2cache_rq_tmp),
1899        .q      (ld0_unfilled_tmp),
1900        .rst    (ld0_fill_reset_d2),  .en     (ld0_unfilled_wy_en),
1901        .clk    (clk),
1902        .se     (1'b0),       .si (),          .so ()
1903        );
1904
1905dffre_s #(2)  ld0out_state_way (
1906        //.din    (ld_pcx_pkt_wy_mx0[1:0]}),
1907        .din    (lsu_lmq_pkt_way_w2[1:0]),
1908        .q      (ld0_unfilled_wy[1:0]),
1909        .rst    (ld0_fill_reset_d2),  .en     (ld0_unfilled_wy_en),
1910        .clk    (clk),
1911        .se     (1'b0),       .si (),          .so ()
1912        );
1913
1914assign  ld0_fill_reset_d2 = ld0_fill_reset_d2_tmp | ld0_l2cache_rq_kill ;
1915//assign        ld0_unfilled = ld0_unfilled_tmp & ~ld0_l2cache_rq_kill ;
1916assign  ld0_unfilled = ld0_unfilled_tmp ;
1917
1918//bug3516
1919//assign  non_l2bnk = tlb_pgnum_g[39] & tlb_pgnum_g[38] ;
1920assign  non_l2bnk = tlb_pgnum_g[39]  & ~(~tlb_pgnum_g[38]  & tlb_pgnum_g[37]) ;
1921
1922// ld l2bank address
1923dffe_s  #(3) ld0_l2bnka (
1924        .din    ({non_l2bnk_mx0,ldst_va_mx0[7:6]}),
1925        .q      (ld0_l2bnk_addr[2:0]),
1926  .en (ld0_l2cache_rq),
1927        .clk  (clk),
1928        .se     (1'b0),       .si (),          .so ()
1929        );
1930
1931//bug2705 - add byp for address to be available in w-cycle
1932//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
1933//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
1934//         spec pick and kill pkt vld in w2 if non_l2bnk_mx0=1 (non$ access)
1935wire  [2:0]  ld0_l2bnk_addr_mx ;
1936assign  ld0_l2bnk_addr_mx[2:0]  =  ld0_pkt_vld_unmasked ? ld0_l2bnk_addr[2:0] :
1937                                                          {1'b0,ldst_va_mx0[7:6]} ;             // assume $able access for spec pick
1938
1939//assign  ld0_l2bnk_addr_mx[2:0]  =  (ld0_inst_vld_unflushed  & lsu_inst_vld_tmp) ?
1940//                                        {1'b0,ldst_va_mx0[7:6]} :             // assume $able access for spec pick
1941//                                        //{non_l2bnk_mx0,ldst_va_mx0[7:6]} :
1942//                                           ld0_l2bnk_addr[2:0] ;
1943
1944//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
1945//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
1946//         spec pick and kill pkt vld in w2
1947dff_s #(1) ff_non_l2bnk_mx0_d1 (
1948        .din    (non_l2bnk_mx0),
1949        .q      (non_l2bnk_mx0_d1),
1950        .clk  (clk),
1951        .se     (1'b0),       .si (),          .so ()
1952        );
1953
1954//bug2705 - change ld0_l2bnk_addr[2:0] to ld0_l2bnk_addr_mx[2:0]
1955assign ld0_l2bnk_dest[0] = ~ld0_l2bnk_addr_mx[2] & ~ld0_l2bnk_addr_mx[1] & ~ld0_l2bnk_addr_mx[0] ;
1956assign ld0_l2bnk_dest[1] = ~ld0_l2bnk_addr_mx[2] & ~ld0_l2bnk_addr_mx[1] &  ld0_l2bnk_addr_mx[0] ;
1957assign ld0_l2bnk_dest[2] = ~ld0_l2bnk_addr_mx[2] &  ld0_l2bnk_addr_mx[1] & ~ld0_l2bnk_addr_mx[0] ;
1958assign ld0_l2bnk_dest[3] = ~ld0_l2bnk_addr_mx[2] &  ld0_l2bnk_addr_mx[1] &  ld0_l2bnk_addr_mx[0] ;
1959assign ld0_l2bnk_dest[4] =  ld0_l2bnk_addr_mx[2] ;
1960
1961// THREAD1 LOAD PCX REQUEST CONTROL
1962
1963wire    ld1_l2cache_rq_kill ; 
1964assign  ld1_l2cache_rq_kill = 
1965        ld1_inst_vld_w2 & ((ld_stb_full_raw_w2 & ~dbl_force_l2access_w2) | perr_ld_rq_kill_w2) ;       
1966                                        // full-raw which looks like partial
1967assign  ld1_ldbl_rq_w2 = 
1968                ((ld_stb_full_raw_w2 & dbl_force_l2access_w2) | ld_stb_partial_raw_w2)
1969                        & ~atomic_w2 & ~perr_ld_rq_kill_w2 & ~(asi_internal_w2 & alt_space_w2) &
1970                        ld1_inst_vld_w2 ;
1971
1972assign ld1_vld_reset = 
1973  (reset | (ld1_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld1_inst_vld_g | bld_annul_d1[1] | dtag_perr_pkt2_vld_d1[1]))) |
1974  ld1_l2cache_rq_kill ;
1975  //(reset | (ld1_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld1_inst_vld_g | bld_annul_d1[1]))) | // bug2877
1976  //(reset | (ld1_pcx_rq_sel_d1 & ~(pcx_req_squash | ld1_inst_vld_g | bld_annul[1]))) ;
1977
1978wire  ld1_l2cache_rq_g;
1979assign ld1_l2cache_rq_g = 
1980        (((lsu_ld_miss_g & ~ldxa_internal))
1981        //((lsu_ld_hit_g | lsu_ld_miss_g) & (ld_stb_partial_raw_g))) // ldst_dbl always rqs
1982        & ~atomic_g & ld1_inst_vld_g) 
1983        | pref_rq_vld1_g ;
1984
1985assign ld1_l2cache_rq =  ld1_l2cache_rq_g | ld1_ldbl_rq_w2 ;
1986
1987   
1988// ld valid
1989wire pref_rq_vld1;   
1990dffre_s #(2)  ld1_vld (
1991        .din    ({ld1_l2cache_rq, pref_rq_vld1_mx}),
1992        .q      ({ld1_pkt_vld_unmasked, pref_rq_vld1}),
1993  .rst  (ld1_vld_reset),  .en (ld1_l2cache_rq),
1994        .clk  (clk),
1995        .se     (1'b0),       .si (),          .so ()
1996        );
1997
1998// bug2705 - speculative pick in w-cycle-begin
1999wire    ld1_spec_vld_g ;
2000assign  ld1_spec_vld_g  =  ld1_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g  &
2001                           ~atomic_or_ldxa_internal_rq_g &
2002                           ~(ld0_pkt_vld_unmasked | ld2_pkt_vld_unmasked | ld3_pkt_vld_unmasked);
2003//assign  ld1_spec_vld_g  =  ld1_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g ;
2004
2005dff_s #(1) ff_ld1_spec_pick_vld_w2 (
2006        .din    (ld1_spec_pick_vld_g),
2007        .q      (ld1_spec_pick_vld_w2),
2008        .clk  (clk),
2009        .se     (1'b0),       .si (),          .so ()
2010        );
2011
2012// kill packet valid if spec req is picked in w and stb hits in w2
2013wire    ld1_pkt_vld_tmp ;
2014assign lsu_ld1_spec_vld_kill_w2  =  ld1_spec_pick_vld_w2 & (~ld1_l2cache_rq_w2 | ld1_l2cache_rq_kill | ld1_ldbl_rq_w2 | non_l2bnk_mx1_d1) ;
2015
2016assign  ld1_pkt_vld_tmp =  ld1_pkt_vld_unmasked & ~(ld1_pcx_rq_sel_d1 | ld1_pcx_rq_sel_d2) &
2017                      ~(ld1_l2cache_rq_kill | ld1_ldbl_rq_w2) &
2018                      ~(pref_rq_vld1 & lsu_no_spc_pref[1]) ; 
2019
2020assign  ld1_pkt_vld = ld1_pkt_vld_tmp | ld1_spec_vld_g ;
2021// bug2705 - speculative pick in w-cycle-end
2022
2023//assign  ld1_pkt_vld = ld1_pkt_vld_unmasked & ~ld1_pcx_rq_sel_d1 ;
2024
2025
2026assign  ld1_fill_reset = reset | (lsu_dfq_ld_vld & lsu_dcfill_active_e & dfq_byp_sel[1]) ;
2027
2028wire  ld1_l2cache_rq_g_tmp;
2029wire  ld1_l2cache_rq_w2_tmp;
2030
2031assign ld1_l2cache_rq_g_tmp  =  ld1_l2cache_rq_g & ~pref_inst_g ;
2032 
2033dff_s #(1) ff_ld1_l2cache_rq_w2 (
2034         .din    (ld1_l2cache_rq_g_tmp),
2035         .q      (ld1_l2cache_rq_w2_tmp),
2036         .clk  (clk),
2037         .se     (1'b0),       .si (),          .so ()
2038         );
2039
2040//wire ld1_unfilled_en ;
2041//assign        ld1_unfilled_en = ld1_l2cache_rq & ~pref_inst_g ;
2042wire ld1_unfilled_wy_en ;
2043assign  ld1_unfilled_wy_en = ld1_l2cache_rq_w2_tmp | ld1_ldbl_rq_w2 ;
2044
2045wire  ld1_l2cache_rq_tmp;
2046assign ld1_l2cache_rq_tmp  = ld1_unfilled_wy_en & ~ld1_l2cache_rq_kill;
2047
2048// ld valid until fill occur.
2049dffre_s  #(1)  ld1out_state (
2050        //.din    (ld1_l2cache_rq),
2051        .din    (ld1_l2cache_rq_tmp),
2052        .q      (ld1_unfilled_tmp),
2053        .rst    (ld1_fill_reset_d2),  .en     (ld1_unfilled_wy_en),
2054        .clk    (clk),
2055        .se     (1'b0),       .si (),          .so ()
2056  );
2057dffre_s  #(2)  ld1out_state_way (
2058        //.din    (ld_pcx_pkt_wy_mx1[1:0]),
2059        .din    (lsu_lmq_pkt_way_w2[1:0]),
2060        .q      (ld1_unfilled_wy[1:0]),
2061        .rst    (ld1_fill_reset_d2),  .en     (ld1_unfilled_wy_en),
2062        .clk    (clk),
2063        .se     (1'b0),       .si (),          .so ()
2064  );
2065
2066
2067assign  ld1_fill_reset_d2 = ld1_fill_reset_d2_tmp | ld1_l2cache_rq_kill ;
2068//assign        ld1_unfilled = ld1_unfilled_tmp & ~ld1_l2cache_rq_kill ;
2069assign  ld1_unfilled = ld1_unfilled_tmp ;
2070
2071// ld l2bank address
2072dffe_s  #(3) ld1_l2bnka (
2073        .din    ({non_l2bnk_mx1,ldst_va_mx1[7:6]}),
2074        .q      (ld1_l2bnk_addr[2:0]),
2075  .en (ld1_l2cache_rq),
2076        .clk  (clk),
2077        .se     (1'b0),       .si (),          .so ()
2078        );
2079
2080//bug2705 - add byp for address to be available in w-cycle
2081//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
2082//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
2083//         spec pick and kill pkt vld in w2 if non_l2bnk_mx0=1 (non$ access)
2084
2085wire  [2:0]  ld1_l2bnk_addr_mx ;
2086assign  ld1_l2bnk_addr_mx[2:0]  =  ld1_pkt_vld_unmasked  ? ld1_l2bnk_addr[2:0] :
2087                                           {1'b0,ldst_va_mx1[7:6]} ; 
2088
2089//assign  ld1_l2bnk_addr_mx[2:0]  =  (ld1_inst_vld_unflushed  & lsu_inst_vld_tmp) ?
2090//                                         {1'b0,ldst_va_mx1[7:6]} :
2091//                                         //{non_l2bnk_mx1,ldst_va_mx1[7:6]} :
2092//                                              ld1_l2bnk_addr[2:0] ;
2093
2094//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
2095//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
2096//         spec pick and kill pkt vld in w2
2097dff_s #(1) ff_non_l2bnk_mx1_d1 (
2098        .din    (non_l2bnk_mx1),
2099        .q      (non_l2bnk_mx1_d1),
2100        .clk  (clk),
2101        .se     (1'b0),       .si (),          .so ()
2102        );
2103
2104//bug2705 - change ld1_l2bnk_addr[2:0] to ld1_l2bnk_addr_mx[2:0]
2105assign ld1_l2bnk_dest[0] = ~ld1_l2bnk_addr_mx[2] & ~ld1_l2bnk_addr_mx[1] & ~ld1_l2bnk_addr_mx[0] ;
2106assign ld1_l2bnk_dest[1] = ~ld1_l2bnk_addr_mx[2] & ~ld1_l2bnk_addr_mx[1] &  ld1_l2bnk_addr_mx[0] ;
2107assign ld1_l2bnk_dest[2] = ~ld1_l2bnk_addr_mx[2] &  ld1_l2bnk_addr_mx[1] & ~ld1_l2bnk_addr_mx[0] ;
2108assign ld1_l2bnk_dest[3] = ~ld1_l2bnk_addr_mx[2] &  ld1_l2bnk_addr_mx[1] &  ld1_l2bnk_addr_mx[0] ;
2109assign ld1_l2bnk_dest[4] =  ld1_l2bnk_addr_mx[2] ;
2110
2111
2112// THREAD2 LOAD PCX REQUEST CONTROL
2113
2114wire    ld2_l2cache_rq_kill ; 
2115assign  ld2_l2cache_rq_kill = 
2116        ld2_inst_vld_w2 & ((ld_stb_full_raw_w2 & ~dbl_force_l2access_w2) | perr_ld_rq_kill_w2) ;       
2117                                                // full-raw which looks like partial
2118assign  ld2_ldbl_rq_w2 = 
2119                ((ld_stb_full_raw_w2 & dbl_force_l2access_w2) | ld_stb_partial_raw_w2)
2120                        & ~atomic_w2 & ~perr_ld_rq_kill_w2 & ~(asi_internal_w2 & alt_space_w2) & 
2121                        ld2_inst_vld_w2 ;
2122//assign        ld2_l2cache_rq_kill = ld2_inst_vld_w2 & ld_stb_full_raw_w2 & ~dbl_force_l2access_w2 ;
2123//assign        ld2_ldbl_rq_w2 = ld_stb_full_raw_w2 & dbl_force_l2access_w2 & ~atomic_w2 & ld2_inst_vld_w2 ;
2124
2125assign ld2_vld_reset = 
2126  (reset | (ld2_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld2_inst_vld_g | bld_annul_d1[2] | dtag_perr_pkt2_vld_d1[2]))) |
2127  ld2_l2cache_rq_kill ;
2128  //(reset | (ld2_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld2_inst_vld_g | bld_annul_d1[2]))) | // bug2877
2129  //(reset | (ld2_pcx_rq_sel_d1 & ~(pcx_req_squash | ld2_inst_vld_g | bld_annul[2]))) ;
2130
2131wire  ld2_l2cache_rq_g;
2132
2133assign ld2_l2cache_rq_g = 
2134        (((lsu_ld_miss_g & ~ldxa_internal)) 
2135        //((lsu_ld_hit_g | lsu_ld_miss_g) & (ld_stb_partial_raw_g))) // ldst_dbl always rqs
2136        & ~atomic_g & ld2_inst_vld_g )
2137        | pref_rq_vld2_g ;
2138   
2139assign ld2_l2cache_rq = ld2_l2cache_rq_g | ld2_ldbl_rq_w2 ;
2140
2141   
2142// ld valid
2143wire pref_rq_vld2;         
2144dffre_s #(2) ld2_vld (
2145        .din    ({ld2_l2cache_rq, pref_rq_vld2_mx}),
2146        .q      ({ld2_pkt_vld_unmasked, pref_rq_vld2} ),
2147  .rst  (ld2_vld_reset),  .en (ld2_l2cache_rq),
2148        .clk  (clk),
2149        .se     (1'b0),       .si (),          .so ()
2150        );
2151
2152// bug2705 - speculative pick in w-cycle - begin
2153wire    ld2_spec_vld_g ;
2154assign  ld2_spec_vld_g  =  ld2_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g  &
2155                           ~atomic_or_ldxa_internal_rq_g &
2156                           ~(ld0_pkt_vld_unmasked | ld1_pkt_vld_unmasked | ld3_pkt_vld_unmasked);
2157//assign  ld2_spec_vld_g  =  ld2_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g ;
2158
2159dff_s #(1) ff_ld2_spec_pick_vld_w2 (
2160        .din    (ld2_spec_pick_vld_g),
2161        .q      (ld2_spec_pick_vld_w2),
2162        .clk  (clk),
2163        .se     (1'b0),       .si (),          .so ()
2164        );
2165
2166// kill packet valid if spec req is picked in w and stb hits in w2
2167wire    ld2_pkt_vld_tmp ;
2168assign lsu_ld2_spec_vld_kill_w2  =  ld2_spec_pick_vld_w2 & (~ld2_l2cache_rq_w2 | ld2_l2cache_rq_kill | ld2_ldbl_rq_w2 | non_l2bnk_mx2_d1) ;
2169
2170assign  ld2_pkt_vld_tmp = ld2_pkt_vld_unmasked & ~(ld2_pcx_rq_sel_d1 | ld2_pcx_rq_sel_d2) & 
2171                      ~(ld2_l2cache_rq_kill | ld2_ldbl_rq_w2) &
2172                      ~(pref_rq_vld2 & lsu_no_spc_pref[2]) ; 
2173
2174assign  ld2_pkt_vld = ld2_pkt_vld_tmp | ld2_spec_vld_g ;
2175// bug2705 - speculative pick in w-cycle - end
2176
2177//assign  ld2_pkt_vld = ld2_pkt_vld_unmasked & ~ld2_pcx_rq_sel_d1 ;
2178
2179
2180assign  ld2_fill_reset = reset | (lsu_dfq_ld_vld & lsu_dcfill_active_e & dfq_byp_sel[2]) ;
2181
2182wire  ld2_l2cache_rq_g_tmp;
2183wire  ld2_l2cache_rq_w2_tmp;
2184
2185assign ld2_l2cache_rq_g_tmp  =  ld2_l2cache_rq_g & ~pref_inst_g ;
2186
2187dff_s #(1) ff_ld2_l2cache_rq_w2 (
2188         .din    (ld2_l2cache_rq_g_tmp),
2189         .q      (ld2_l2cache_rq_w2_tmp),
2190         .clk  (clk),
2191         .se     (1'b0),       .si (),          .so ()
2192         );
2193
2194//wire ld2_unfilled_en ;
2195//assign        ld2_unfilled_en = ld2_l2cache_rq & ~pref_inst_g ;
2196wire ld2_unfilled_wy_en ;
2197assign  ld2_unfilled_wy_en = ld2_l2cache_rq_w2_tmp | ld2_ldbl_rq_w2 ;
2198
2199wire  ld2_l2cache_rq_tmp;
2200assign ld2_l2cache_rq_tmp  = ld2_unfilled_wy_en & ~ld2_l2cache_rq_kill;
2201
2202// ld valid until fill occur.
2203dffre_s  #(1) ld2out_state (
2204        //.din    (ld2_l2cache_rq),
2205        .din    (ld2_l2cache_rq_tmp),
2206        .q      (ld2_unfilled_tmp),
2207        .rst    (ld2_fill_reset_d2),  .en     (ld2_unfilled_wy_en),
2208        .clk    (clk),
2209        .se     (1'b0),       .si (),          .so ()
2210        );
2211dffre_s  #(2) ld2out_state_way (
2212        .din    (lsu_lmq_pkt_way_w2[1:0]),
2213        .q      (ld2_unfilled_wy[1:0]),
2214        .rst    (ld2_fill_reset_d2),  .en     (ld2_unfilled_wy_en),
2215        .clk    (clk),
2216        .se     (1'b0),       .si (),          .so ()
2217        );
2218
2219
2220assign  ld2_fill_reset_d2 = ld2_fill_reset_d2_tmp | ld2_l2cache_rq_kill ;
2221//assign        ld2_unfilled = ld2_unfilled_tmp & ~ld2_l2cache_rq_kill ;
2222assign  ld2_unfilled = ld2_unfilled_tmp ;
2223
2224// ld l2bank address
2225dffe_s  #(3) ld2_l2bnka (
2226        .din    ({non_l2bnk_mx2,ldst_va_mx2[7:6]}),
2227        .q      (ld2_l2bnk_addr[2:0]),
2228  .en (ld2_l2cache_rq),
2229        .clk  (clk),
2230        .se     (1'b0),       .si (),          .so ()
2231        );
2232
2233//bug2705 - add byp for address to be available in w-cycle
2234//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
2235//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
2236//         spec pick and kill pkt vld in w2 if non_l2bnk_mx0=1 (non$ access)
2237
2238wire  [2:0]  ld2_l2bnk_addr_mx ;
2239assign  ld2_l2bnk_addr_mx[2:0]  =  ld2_pkt_vld_unmasked ? ld2_l2bnk_addr[2:0] :
2240                                        {1'b0,ldst_va_mx2[7:6]} ; 
2241
2242//assign  ld2_l2bnk_addr_mx[2:0]  =  (ld2_inst_vld_unflushed  & lsu_inst_vld_tmp) ?
2243//                                      {1'b0,ldst_va_mx2[7:6]} :
2244//                                      //{non_l2bnk_mx2,ldst_va_mx2[7:6]} :
2245//                                              ld2_l2bnk_addr[2:0] ;
2246
2247//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
2248//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
2249//         spec pick and kill pkt vld in w2
2250dff_s #(1) ff_non_l2bnk_mx2_d1 (
2251        .din    (non_l2bnk_mx2),
2252        .q      (non_l2bnk_mx2_d1),
2253        .clk  (clk),
2254        .se     (1'b0),       .si (),          .so ()
2255        );
2256
2257//bug2705 - change ld2_l2bnk_addr[2:0] to ld2_l2bnk_addr_mx[2:0]
2258assign ld2_l2bnk_dest[0] = ~ld2_l2bnk_addr_mx[2] & ~ld2_l2bnk_addr_mx[1] & ~ld2_l2bnk_addr_mx[0] ;
2259assign ld2_l2bnk_dest[1] = ~ld2_l2bnk_addr_mx[2] & ~ld2_l2bnk_addr_mx[1] &  ld2_l2bnk_addr_mx[0] ;
2260assign ld2_l2bnk_dest[2] = ~ld2_l2bnk_addr_mx[2] &  ld2_l2bnk_addr_mx[1] & ~ld2_l2bnk_addr_mx[0] ;
2261assign ld2_l2bnk_dest[3] = ~ld2_l2bnk_addr_mx[2] &  ld2_l2bnk_addr_mx[1] &  ld2_l2bnk_addr_mx[0] ;
2262assign ld2_l2bnk_dest[4] =  ld2_l2bnk_addr_mx[2] ;
2263
2264// THREAD3 LOAD PCX REQUEST CONTROL
2265
2266wire    ld3_l2cache_rq_kill ; 
2267assign  ld3_l2cache_rq_kill = 
2268        ld3_inst_vld_w2 & ((ld_stb_full_raw_w2 & ~dbl_force_l2access_w2) | perr_ld_rq_kill_w2) ;       
2269                                                // full-raw which looks like partial
2270assign  ld3_ldbl_rq_w2 = 
2271                ((ld_stb_full_raw_w2 & dbl_force_l2access_w2) | ld_stb_partial_raw_w2)
2272                        & ~atomic_w2 & ~perr_ld_rq_kill_w2 & ~(asi_internal_w2 & alt_space_w2) &
2273                        ld3_inst_vld_w2 ;
2274//assign        ld3_l2cache_rq_kill = ld3_inst_vld_w2 & ld_stb_full_raw_w2 & ~dbl_force_l2access_w2 ;
2275//assign        ld3_ldbl_rq_w2 = ld_stb_full_raw_w2 & dbl_force_l2access_w2 & ~atomic_w2 & ld3_inst_vld_w2 ;
2276
2277assign ld3_vld_reset = 
2278  (reset | (ld3_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld3_inst_vld_g | bld_annul_d1[3] | dtag_perr_pkt2_vld_d1[3]))) |
2279  ld3_l2cache_rq_kill ;
2280  //(reset | (ld3_pcx_rq_sel_d2 & ~(pcx_req_squash_d1 | ld3_inst_vld_g | bld_annul_d1[3]))) | // bug 2877
2281  //(reset | (ld3_pcx_rq_sel_d1 & ~(pcx_req_squash | ld3_inst_vld_g | bld_annul[3]))) ;
2282
2283wire  ld3_l2cache_rq_g;
2284assign ld3_l2cache_rq_g = 
2285        (((lsu_ld_miss_g & ~ldxa_internal))
2286        //((lsu_ld_hit_g | lsu_ld_miss_g) & (ld_stb_partial_raw_g))) // ldst_dbl always rqs
2287        & ~atomic_g & ld3_inst_vld_g) 
2288        | pref_rq_vld3_g ;
2289
2290assign  ld3_l2cache_rq =  ld3_l2cache_rq_g | ld3_ldbl_rq_w2 ;
2291   
2292   
2293// ld valid
2294wire pref_rq_vld3;         
2295dffre_s  #(2) ld3_vld (
2296        .din    ({ld3_l2cache_rq, pref_rq_vld3_mx} ),
2297        .q      ({ld3_pkt_vld_unmasked, pref_rq_vld3}),
2298  .rst  (ld3_vld_reset),  .en (ld3_l2cache_rq),
2299        .clk  (clk),
2300        .se     (1'b0),       .si (),          .so ()
2301        );
2302
2303// bug2705 - speculative pick in w-cycle - begin
2304wire    ld3_spec_vld_g ;
2305assign  ld3_spec_vld_g  =  ld3_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g  &
2306                           ~atomic_or_ldxa_internal_rq_g &
2307                           ~(ld0_pkt_vld_unmasked | ld1_pkt_vld_unmasked | ld2_pkt_vld_unmasked);
2308//assign  ld3_spec_vld_g  =  ld3_inst_vld_unflushed & lsu_inst_vld_tmp & ~dbl_force_l2access_g & tlb_cam_hit_g ;
2309
2310
2311dff_s #(1) ff_ld3_spec_pick_vld_w2 (
2312        .din    (ld3_spec_pick_vld_g),
2313        .q      (ld3_spec_pick_vld_w2),
2314        .clk  (clk),
2315        .se     (1'b0),       .si (),          .so ()
2316        );
2317
2318// kill packet valid if spec req is picked in w and stb hits in w2
2319wire    ld3_pkt_vld_tmp ;
2320assign lsu_ld3_spec_vld_kill_w2  =  ld3_spec_pick_vld_w2 & (~ld3_l2cache_rq_w2 | ld3_l2cache_rq_kill | ld3_ldbl_rq_w2 | non_l2bnk_mx3_d1) ;
2321
2322assign  ld3_pkt_vld_tmp = ld3_pkt_vld_unmasked & ~(ld3_pcx_rq_sel_d1 | ld3_pcx_rq_sel_d2) & 
2323                      ~(ld3_l2cache_rq_kill | ld3_ldbl_rq_w2) &
2324                      ~(pref_rq_vld3 & lsu_no_spc_pref[3]) ;
2325
2326assign  ld3_pkt_vld = ld3_pkt_vld_tmp | ld3_spec_vld_g ;
2327// bug2705 - speculative pick in w-cycle - end
2328
2329//assign  ld3_pkt_vld = ld3_pkt_vld_unmasked & ~ld3_pcx_rq_sel_d1 ;
2330
2331assign  ld3_fill_reset = reset | (lsu_dfq_ld_vld & lsu_dcfill_active_e & dfq_byp_sel[3]) ;
2332
2333wire  ld3_l2cache_rq_g_tmp;
2334wire  ld3_l2cache_rq_w2_tmp;
2335
2336assign ld3_l2cache_rq_g_tmp  =  ld3_l2cache_rq_g & ~pref_inst_g ;
2337
2338dff_s #(1) ff_ld3_l2cache_rq_w2 (
2339         .din    (ld3_l2cache_rq_g_tmp),
2340         .q      (ld3_l2cache_rq_w2_tmp),
2341         .clk  (clk),
2342         .se     (1'b0),       .si (),          .so ()
2343         );
2344
2345//wire ld3_unfilled_en ;
2346//assign        ld3_unfilled_en = ld3_l2cache_rq & ~pref_inst_g ;
2347wire ld3_unfilled_wy_en ;
2348assign  ld3_unfilled_wy_en = ld3_l2cache_rq_w2_tmp | ld3_ldbl_rq_w2 ;
2349
2350wire  ld3_l2cache_rq_tmp;
2351assign ld3_l2cache_rq_tmp  = ld3_unfilled_wy_en & ~ld3_l2cache_rq_kill;
2352
2353// ld valid until fill occur.
2354dffre_s #(1)  ld3out_state (
2355        //.din    (ld3_l2cache_rq),
2356        .din    (ld3_l2cache_rq_tmp),
2357        .q      (ld3_unfilled_tmp),
2358        .rst    (ld3_fill_reset_d2),  .en     (ld3_unfilled_wy_en),
2359        .clk    (clk),
2360        .se     (1'b0),       .si (),          .so ()
2361        );
2362dffre_s #(2)  ld3out_state_way (
2363        .din    (lsu_lmq_pkt_way_w2[1:0]),
2364        .q      (ld3_unfilled_wy[1:0]),
2365        .rst    (ld3_fill_reset_d2),  .en     (ld3_unfilled_wy_en),
2366        .clk    (clk),
2367        .se     (1'b0),       .si (),          .so ()
2368        );
2369
2370
2371assign  ld3_fill_reset_d2 = ld3_fill_reset_d2_tmp | ld3_l2cache_rq_kill ;
2372//assign        ld3_unfilled = ld3_unfilled_tmp & ~ld3_l2cache_rq_kill ;
2373assign  ld3_unfilled = ld3_unfilled_tmp;
2374
2375// ld l2bank address
2376dffe_s  #(3) ld3_l2bnka (
2377        .din    ({non_l2bnk_mx3,ldst_va_mx3[7:6]}),
2378        .q      (ld3_l2bnk_addr[2:0]),
2379  .en (ld3_l2cache_rq),
2380        .clk  (clk),
2381        .se     (1'b0),       .si (),          .so ()
2382        );
2383
2384//bug2705 - add byp for address to be available in w-cycle
2385//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
2386//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
2387//         spec pick and kill pkt vld in w2 if non_l2bnk_mx0=1 (non$ access)
2388
2389wire  [2:0]  ld3_l2bnk_addr_mx ;
2390assign  ld3_l2bnk_addr_mx[2:0]  =  ld3_pkt_vld_unmasked ? ld3_l2bnk_addr[2:0] :
2391                                        {1'b0,ldst_va_mx3[7:6]} ; 
2392
2393//assign  ld3_l2bnk_addr_mx[2:0]  =  (ld3_inst_vld_unflushed  & lsu_inst_vld_tmp) ?
2394//                                      {1'b0,ldst_va_mx3[7:6]} :
2395//                                      //{non_l2bnk_mx3,ldst_va_mx3[7:6]} :
2396//                                              ld3_l2bnk_addr[2:0] ;
2397
2398//7/21/03: timing fix - non_l2bnk_mx0 (uses tlb_pgnum_g[39:37] which arrives in qctl1 ~400ps)
2399//         this will cause timing paths in spec pick in w-cycle; hence assume $able access for
2400//         spec pick and kill pkt vld in w2
2401dff_s #(1) ff_non_l2bnk_mx3_d1 (
2402        .din    (non_l2bnk_mx3),
2403        .q      (non_l2bnk_mx3_d1),
2404        .clk  (clk),
2405        .se     (1'b0),       .si (),          .so ()
2406        );
2407
2408
2409//bug2705 - change ld3_l2bnk_addr[2:0] to ld3_l2bnk_addr_mx[2:0]
2410assign ld3_l2bnk_dest[0] = ~ld3_l2bnk_addr_mx[2] & ~ld3_l2bnk_addr_mx[1] & ~ld3_l2bnk_addr_mx[0] ;
2411assign ld3_l2bnk_dest[1] = ~ld3_l2bnk_addr_mx[2] & ~ld3_l2bnk_addr_mx[1] &  ld3_l2bnk_addr_mx[0] ;
2412assign ld3_l2bnk_dest[2] = ~ld3_l2bnk_addr_mx[2] &  ld3_l2bnk_addr_mx[1] & ~ld3_l2bnk_addr_mx[0] ;
2413assign ld3_l2bnk_dest[3] = ~ld3_l2bnk_addr_mx[2] &  ld3_l2bnk_addr_mx[1] &  ld3_l2bnk_addr_mx[0] ;
2414assign ld3_l2bnk_dest[4] =  ld3_l2bnk_addr_mx[2] ;
2415
2416//=================================================================================================
2417//  LMQ Miscellaneous Control
2418//=================================================================================================
2419
2420dff_s #(1) stgm_cas (
2421        .din    (ifu_lsu_casa_e),
2422        .q      (casa_m),
2423        .clk  (clk),
2424        .se     (1'b0),       .si (),          .so ()
2425        );
2426
2427dff_s  #(1) stgg_cas (
2428        .din    (casa_m),
2429        .q      (casa_g),
2430        .clk  (clk),
2431        .se     (1'b0),       .si (),          .so ()
2432        );
2433
2434//assign  casa0_g = casa_g & thread0_g ;
2435//assign  casa1_g = casa_g & thread1_g ;
2436//assign  casa2_g = casa_g & thread2_g ;
2437//assign  casa3_g = casa_g & thread3_g ;
2438
2439// PARTIAL RAW BYPASSING.
2440
2441// Partial raw of load in stb. Even if the load hits in the dcache, it must follow
2442// the st to the pcx, obtain merged data to bypass to the pipeline. This load will
2443// also fill the dcache. i.e., once the store is received it looks like a normal load.
2444
2445// This path is also used for 2nd cas pkt. rs1(addr) and rs2(cmp data) are in 1st
2446// pkt which is written to stb. rd(swap value) is written to lmq as 2nd pkt. The
2447// 2nd pkt will wait in the lmq until the 1st pkt is sent.
2448
2449// *** Atomics need to switch out the thread ***
2450
2451// THREAD0
2452
2453// timing fix: 9/15/03 - reduce loading on pcx_rq_for_stb[3:0] to stb_clt[0-3]. it had FO2 (stb_ctl,qdp2 - cap=0.5-0.8)
2454//             move the flop from qdp2 to qctl1
2455
2456dff_s #(4)  ff_pcx_rq_for_stb_d1 (
2457        .din    (pcx_rq_for_stb[3:0]),
2458        .q      (pcx_rq_for_stb_d1[3:0]),
2459        .clk    (clk),
2460        .se     (1'b0),       .si (),          .so ()
2461        );                               
2462
2463dff_s #(4)  srqsel_d1 (
2464        .din    (pcx_rq_for_stb[3:0]),
2465        //.q      ({st3_pcx_rq_tmp, st2_pcx_rq_tmp,st1_pcx_rq_tmp, st0_pcx_rq_tmp}),
2466        .q      ({st3_pcx_rq_sel_d1, st2_pcx_rq_sel_d1,st1_pcx_rq_sel_d1, st0_pcx_rq_sel_d1}),
2467        .clk    (clk),
2468        .se     (1'b0),       .si (),          .so ()
2469        );                               
2470
2471dff_s #(4)  srqsel_d2 (
2472        .din      ({st3_pcx_rq_sel_d1, st2_pcx_rq_sel_d1,st1_pcx_rq_sel_d1, st0_pcx_rq_sel_d1}),
2473        .q      ({st3_pcx_rq_sel_d2, st2_pcx_rq_sel_d2,st1_pcx_rq_sel_d2, st0_pcx_rq_sel_d2}),
2474        .clk    (clk),
2475        .se     (1'b0),       .si (),          .so ()
2476        );                               
2477
2478dff_s #(4)  srqsel_d3 (
2479        .din    ({st3_pcx_rq_sel_d2, st2_pcx_rq_sel_d2,st1_pcx_rq_sel_d2, st0_pcx_rq_sel_d2}),
2480        .q      ({st3_pcx_rq_sel_d3, st2_pcx_rq_sel_d3,st1_pcx_rq_sel_d3, st0_pcx_rq_sel_d3}),
2481        .clk    (clk),
2482        .se     (1'b0),       .si (),          .so ()
2483        );                               
2484
2485wire    ld0_ldbl_rawp_en_w2 ;
2486assign  ld0_ldbl_rawp_en_w2 = ld0_ldbl_rq_w2 & ~ld_rawp_st_ced_w2 & ~ld0_rawp_reset ;
2487
2488/*assign        st3_pcx_rq_sel_d1 = st3_pcx_rq_tmp & ~pcx_req_squash ;
2489assign  st2_pcx_rq_sel_d1 = st2_pcx_rq_tmp & ~pcx_req_squash ;
2490assign  st1_pcx_rq_sel_d1 = st1_pcx_rq_tmp & ~pcx_req_squash ;
2491assign  st0_pcx_rq_sel_d1 = st0_pcx_rq_tmp & ~pcx_req_squash ;*/
2492
2493assign ld0_rawp_reset =
2494        (reset | (st0_pcx_rq_sel_d3 & ~pcx_req_squash_d2 & ld0_rawp_disabled & (ld0_rawp_ackid[2:0] == stb0_crnt_ack_id[2:0])));
2495        //(reset | (st0_pcx_rq_sel_d2 & ~pcx_req_squash_d1 & ld0_rawp_disabled & (ld0_rawp_ackid[2:0] == stb0_crnt_ack_id[2:0])));
2496
2497// TO BE REMOVED ALONG WITH defines !!!
2498//wire  ld_rawp_st_ced_g ;
2499//assign        ld_rawp_st_ced_g = 1'b0 ;
2500
2501// reset needs to be dominant in case ack comes on fly.
2502// atomics will not set rawp_disabled
2503assign ld0_rawp_en = 
2504        //(((ld_stb_partial_raw_g) & ~ld_rawp_st_ced_g & ~ld0_rawp_reset)     // partial_raw
2505        //& ~atomic_g & ld0_inst_vld_g) |          // cas inst - 2nd pkt
2506        ld0_ldbl_rawp_en_w2 ;
2507
2508// ack-id and wait-for-ack disable - Thread 0
2509dffre_s #(1)  ldrawp0_dis (
2510        .din    (ld0_rawp_en),
2511        .q      (ld0_rawp_disabled),
2512        .rst    (ld0_rawp_reset),  .en     (ld0_rawp_en),
2513        .clk    (clk),
2514        .se     (1'b0),       .si (),          .so ()
2515        );                               
2516
2517dffe_s #(3)  ldrawp0_ackid (
2518        .din    (ld_rawp_st_ackid_w2[2:0]),
2519        .q      (ld0_rawp_ackid[2:0]),
2520        .en     (ld0_inst_vld_w2),
2521        .clk    (clk),
2522        .se     (1'b0),       .si (),          .so ()
2523        );                               
2524
2525// THREAD1
2526
2527wire    ld1_ldbl_rawp_en_w2 ;
2528assign  ld1_ldbl_rawp_en_w2 = ld1_ldbl_rq_w2 & ~ld_rawp_st_ced_w2 & ~ld1_rawp_reset ;
2529
2530// 1st st ack for st-quad will not cause ack.
2531
2532assign ld1_rawp_reset =
2533        (reset | (st1_pcx_rq_sel_d3 & ~pcx_req_squash_d2 & ld1_rawp_disabled & 
2534        //(reset | (st1_pcx_rq_sel_d2 & ~pcx_req_squash_d1 & ld1_rawp_disabled &
2535                        (ld1_rawp_ackid[2:0] == stb1_crnt_ack_id[2:0])));
2536
2537// reset needs to be dominant in case ack comes on fly.
2538// atomics will not set rawp_disabled
2539assign ld1_rawp_en = 
2540        //(((ld_stb_partial_raw_g) & ~ld_rawp_st_ced_g & ~ld1_rawp_reset) // partial raw
2541        //(((ld_stb_partial_raw_g | (ld_stb_full_raw_g & ldst_dbl_g)) & ~ld_rawp_st_ced_g & ~ld1_rawp_reset) // partial raw
2542        //& ~atomic_g  & ld1_inst_vld_g)  |                // cas inst - 2nd pkt
2543        ld1_ldbl_rawp_en_w2 ;
2544
2545// ack-id and wait-for-ack disable - Thread 0
2546dffre_s #(1)  ldrawp1_dis (
2547        .din    (ld1_rawp_en),
2548        .q      (ld1_rawp_disabled),
2549        .rst    (ld1_rawp_reset),  .en     (ld1_rawp_en),
2550        .clk    (clk),
2551        .se     (1'b0),       .si (),          .so ()
2552        );                               
2553
2554dffe_s #(3)  ldrawp1_ackid (
2555        .din    (ld_rawp_st_ackid_w2[2:0]),
2556        .q      (ld1_rawp_ackid[2:0]),
2557        .en     (ld1_inst_vld_w2),
2558        .clk    (clk),
2559        .se     (1'b0),       .si (),          .so ()
2560        );                               
2561
2562// THREAD2
2563
2564wire    ld2_ldbl_rawp_en_w2 ;
2565assign  ld2_ldbl_rawp_en_w2 = ld2_ldbl_rq_w2 & ~ld_rawp_st_ced_w2 & ~ld2_rawp_reset ;
2566
2567assign ld2_rawp_reset =
2568        (reset | (st2_pcx_rq_sel_d3 & ~pcx_req_squash_d2 & ld2_rawp_disabled & 
2569        //(reset | (st2_pcx_rq_sel_d2 & ~pcx_req_squash_d1 & ld2_rawp_disabled &
2570                        (ld2_rawp_ackid[2:0] == stb2_crnt_ack_id[2:0])));
2571
2572// reset needs to be dominant in case ack comes on fly.
2573// atomics will not set rawp_disabled
2574assign ld2_rawp_en = 
2575        //(((ld_stb_partial_raw_g) & ~ld_rawp_st_ced_g & ~ld2_rawp_reset) // partial raw
2576        //& ~atomic_g & ld2_inst_vld_g) |          // cas inst - 2nd pkt
2577        ld2_ldbl_rawp_en_w2 ;
2578
2579// ack-id and wait-for-ack disable - Thread 0
2580dffre_s #(1)  ldrawp2_dis (
2581        .din    (ld2_rawp_en),
2582        .q      (ld2_rawp_disabled),
2583        .rst    (ld2_rawp_reset),  .en     (ld2_rawp_en),
2584        .clk    (clk),
2585        .se     (1'b0),       .si (),          .so ()
2586        );                               
2587
2588dffe_s #(3)  ldrawp2_ackid (
2589        .din    (ld_rawp_st_ackid_w2[2:0]),
2590        .q      (ld2_rawp_ackid[2:0]),
2591        .en     (ld2_inst_vld_w2),
2592        .clk    (clk),
2593        .se     (1'b0),       .si (),          .so ()
2594        );                               
2595
2596// THREAD3
2597
2598wire    ld3_ldbl_rawp_en_w2 ;
2599assign  ld3_ldbl_rawp_en_w2 = ld3_ldbl_rq_w2 & ~ld_rawp_st_ced_w2 & ~ld3_rawp_reset ;
2600
2601assign ld3_rawp_reset =
2602        (reset | (st3_pcx_rq_sel_d3 & ~pcx_req_squash_d2 & ld3_rawp_disabled & 
2603        //(reset | (st3_pcx_rq_sel_d2 & ~pcx_req_squash_d1 & ld3_rawp_disabled &
2604                                (ld3_rawp_ackid[2:0] == stb3_crnt_ack_id[2:0])));
2605
2606// reset needs to be dominant in case ack comes on fly.
2607// atomics will not set rawp_disabled
2608assign ld3_rawp_en = 
2609        //(((ld_stb_partial_raw_g) & ~ld_rawp_st_ced_g & ~ld3_rawp_reset) // partial raw
2610        //& ~atomic_g & ld3_inst_vld_g) |          // cas inst - 2nd pkt
2611        ld3_ldbl_rawp_en_w2 ;
2612
2613// ack-id and wait-for-ack disable - Thread 0
2614dffre_s #(1)  ldrawp3_dis (
2615        .din    (ld3_rawp_en),
2616        .q      (ld3_rawp_disabled),
2617        .rst    (ld3_rawp_reset),  .en     (ld3_rawp_en),
2618        .clk    (clk),
2619        .se     (1'b0),       .si (),          .so ()
2620        );                               
2621
2622dffe_s #(3)  ldrawp3_ackid (
2623        .din    (ld_rawp_st_ackid_w2[2:0]),
2624        .q      (ld3_rawp_ackid[2:0]),
2625        .en     (ld3_inst_vld_w2),
2626        .clk    (clk),
2627        .se     (1'b0),       .si (),          .so ()
2628        );                               
2629
2630
2631
2632//=================================================================================================
2633//  INTERRUPT PCX PKT REQ CTL
2634//=================================================================================================
2635
2636wire    intrpt_pcx_rq_sel_d2 ;
2637wire    intrpt_vld_reset;
2638wire    intrpt_vld_en ;
2639wire  [3:0] intrpt_thread ;
2640wire    intrpt_clr ;
2641
2642
2643assign  lsu_tlu_pcxpkt_ack = intrpt_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
2644
2645assign intrpt_vld_reset =
2646        reset | lsu_tlu_pcxpkt_ack ;
2647        //reset | (intrpt_pcx_rq_sel_d1 & ~pcx_req_squash);
2648wire    intrpt_pkt_vld_unmasked ;
2649// assumption is that pkt vld cannot be turned around in same cycle
2650assign intrpt_vld_en = ~intrpt_pkt_vld_unmasked ;
2651//assign intrpt_vld_en = ~lsu_intrpt_pkt_vld ;
2652
2653dff_s #(1) intpkt_stgd2 (
2654        .din    (intrpt_pcx_rq_sel_d1),
2655        .q      (intrpt_pcx_rq_sel_d2),
2656        .clk    (clk),
2657        .se     (1'b0),       .si (),          .so ()
2658        );
2659
2660// intrpt valid
2661dffre_s  intrpt_vld (
2662        .din    (tlu_lsu_pcxpkt_vld),
2663        .q      (intrpt_pkt_vld_unmasked),
2664        .rst    (intrpt_vld_reset),     .en     (intrpt_vld_en),
2665        .clk    (clk),
2666        .se     (1'b0),       .si (),          .so ()
2667        );
2668
2669assign  intrpt_thread[0] = ~tlu_lsu_pcxpkt_tid[19] & ~tlu_lsu_pcxpkt_tid[18] ;
2670assign  intrpt_thread[1] = ~tlu_lsu_pcxpkt_tid[19] &  tlu_lsu_pcxpkt_tid[18] ;
2671assign  intrpt_thread[2] =  tlu_lsu_pcxpkt_tid[19] & ~tlu_lsu_pcxpkt_tid[18] ;
2672assign  intrpt_thread[3] =  tlu_lsu_pcxpkt_tid[19] &  tlu_lsu_pcxpkt_tid[18] ;
2673
2674assign  intrpt_clr =
2675  (intrpt_thread[0] & lsu_stb_empty[0]) |
2676  (intrpt_thread[1] & lsu_stb_empty[1]) |
2677  (intrpt_thread[2] & lsu_stb_empty[2]) |
2678  (intrpt_thread[3] & lsu_stb_empty[3]) ;
2679
2680wire    intrpt_clr_d1 ;
2681dff_s #(1) intclr_stgd1 (
2682        .din    (intrpt_clr),
2683        .q      (intrpt_clr_d1),
2684        .clk    (clk),
2685        .se     (1'b0),       .si (),          .so ()
2686        );
2687
2688wire    [3:0]   intrpt_cmplt ;
2689
2690assign  intrpt_cmplt[0] = lsu_tlu_pcxpkt_ack & intrpt_thread[0] ;
2691assign  intrpt_cmplt[1] = lsu_tlu_pcxpkt_ack & intrpt_thread[1] ;
2692assign  intrpt_cmplt[2] = lsu_tlu_pcxpkt_ack & intrpt_thread[2] ;
2693assign  intrpt_cmplt[3] = lsu_tlu_pcxpkt_ack & intrpt_thread[3] ;
2694
2695dff_s #(4) intrpt_stg (
2696        .din    (intrpt_cmplt[3:0]),
2697        .q      (lsu_intrpt_cmplt[3:0]),
2698        .clk    (clk),
2699        .se     (1'b0),       .si (),          .so ()
2700        );
2701
2702assign  intrpt_pkt_vld =
2703intrpt_pkt_vld_unmasked & ~(intrpt_pcx_rq_sel_d1 | intrpt_pcx_rq_sel_d2) & intrpt_clr_d1 ;
2704
2705// ** enabled flop should not be required !!
2706// intrpt l2bank address
2707// ?? Can interrupt requests go to io-bridge ??
2708// Using upper 3b of 5b thread field of INTR_W to address 4 l2 banks
2709dffe_s #(3) intrpt_l2bnka (
2710        .din    ({1'b0,tlu_lsu_pcxpkt_l2baddr[11:10]}),
2711        .q      (intrpt_l2bnk_addr[2:0]),
2712        .en     (intrpt_vld_en),
2713        .clk    (clk),
2714        .se     (1'b0),       .si (),          .so ()
2715        );
2716
2717// IO Requests should not go to iobrdge.
2718assign intrpt_l2bnk_dest[0] =
2719~intrpt_l2bnk_addr[2] & ~intrpt_l2bnk_addr[1] & ~intrpt_l2bnk_addr[0] ;
2720assign intrpt_l2bnk_dest[1] =
2721~intrpt_l2bnk_addr[2] & ~intrpt_l2bnk_addr[1] &  intrpt_l2bnk_addr[0] ;
2722assign intrpt_l2bnk_dest[2] =
2723~intrpt_l2bnk_addr[2] & intrpt_l2bnk_addr[1] & ~intrpt_l2bnk_addr[0] ;
2724assign intrpt_l2bnk_dest[3] =
2725~intrpt_l2bnk_addr[2] & intrpt_l2bnk_addr[1] &  intrpt_l2bnk_addr[0] ;
2726assign intrpt_l2bnk_dest[4] = intrpt_l2bnk_addr[2] ;
2727
2728//=================================================================================================
2729//
2730// QDP Specific Control
2731//
2732//=================================================================================================
2733
2734
2735// Qualify with thread.
2736// Write cas pckt 2 to lmq
2737// Timing Change : ld0_l2cache_rq guarantees validity.
2738//assign lmq_enable[0] = lsu_ld_miss_g & thread0_g ;
2739//assign lmq_enable[0] = ld0_inst_vld_g | pref_vld0_g ;
2740
2741//assign lmq_enable[0] = (ld0_inst_vld_unflushed & lsu_inst_vld_w) | pref_vld0_g ;
2742//assign lmq_enable[1] = (ld1_inst_vld_unflushed & lsu_inst_vld_w) | pref_vld1_g ;
2743//assign lmq_enable[2] = (ld2_inst_vld_unflushed & lsu_inst_vld_w) | pref_vld2_g ;
2744//assign lmq_enable[3] = (ld3_inst_vld_unflushed & lsu_inst_vld_w) | pref_vld3_g ;
2745
2746//bug 2771; timing path - remove flush-pipe, add ifu's flush signal
2747//assign lmq_enable[0] = (ld0_inst_vld_unflushed | pref_vld0_g) & lsu_inst_vld_w ;
2748assign lmq_enable[0] = (ld0_inst_vld_unflushed | pref_vld0_g) & lsu_inst_vld_tmp & ~ifu_lsu_flush_w ;
2749assign lmq_enable[1] = (ld1_inst_vld_unflushed | pref_vld1_g) & lsu_inst_vld_tmp & ~ifu_lsu_flush_w ;
2750assign lmq_enable[2] = (ld2_inst_vld_unflushed | pref_vld2_g) & lsu_inst_vld_tmp & ~ifu_lsu_flush_w ;
2751assign lmq_enable[3] = (ld3_inst_vld_unflushed | pref_vld3_g) & lsu_inst_vld_tmp & ~ifu_lsu_flush_w ; 
2752       
2753// timing fix: 5/19/03: move secondary hit way generation to w2
2754dff_s #(4) ff_lmq_enable_w2 (
2755        .din    (lmq_enable[3:0]),
2756        .q      (lmq_enable_w2[3:0]),
2757        .clk    (clk),
2758        .se     (1'b0),       .si (),          .so ()
2759        );
2760
2761
2762// needs to be 1-hot always.
2763assign imiss_pcx_mx_sel = imiss_pcx_rq_sel_d1 ;
2764//assign imiss_pcx_mx_sel[1] = strm_pcx_rq_sel_d1 ;
2765//assign imiss_pcx_mx_sel[2] = intrpt_pcx_rq_sel_d1 ;
2766//assign imiss_pcx_mx_sel[3] = fpop_pcx_rq_sel_d1 ;
2767
2768//11/7/03: add rst_tri_en
2769wire  [2:0]  fwd_int_fp_pcx_mx_sel_tmp ;
2770
2771assign fwd_int_fp_pcx_mx_sel_tmp[0]= ~fwd_int_fp_pcx_mx_sel[1] & ~fwd_int_fp_pcx_mx_sel[2];
2772assign fwd_int_fp_pcx_mx_sel_tmp[1]=  intrpt_pcx_rq_sel_d1 ;
2773assign fwd_int_fp_pcx_mx_sel_tmp[2]=  fpop_pcx_rq_sel_d1 | fpop_pcx_rq_sel_d2 ;
2774
2775assign fwd_int_fp_pcx_mx_sel[1:0] = fwd_int_fp_pcx_mx_sel_tmp[1:0] & ~{2{rst_tri_en}} ;
2776assign fwd_int_fp_pcx_mx_sel[2]   = fwd_int_fp_pcx_mx_sel_tmp[2] | rst_tri_en ;
2777
2778
2779//*************************************************************************************************
2780//                      PCX REQUEST GENERATION (BEGIN)
2781
2782//=================================================================================================
2783//  PCX REQUEST SELECTION CONTROL
2784//=================================================================================================
2785
2786// LOAD
2787// fpops have to squash other rqs in the 2nd cycle also.
2788//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2789assign ld0_pcx_rq_vld = 
2790  (|(queue_write[4:0] & ld0_l2bnk_dest[4:0])) & 
2791    ld0_pkt_vld & ~ld0_rawp_disabled;
2792    //ld0_pkt_vld & ~ld0_rawp_disabled & ~mcycle_squash_d1;
2793    //ld0_pkt_vld & ~ld0_rawp_disabled & ~st_atom_rq_d1 ;
2794assign ld1_pcx_rq_vld = 
2795  (|(queue_write[4:0] & ld1_l2bnk_dest[4:0])) & 
2796    ld1_pkt_vld & ~ld1_rawp_disabled;
2797    //ld1_pkt_vld & ~ld1_rawp_disabled & ~mcycle_squash_d1;
2798    //ld1_pkt_vld & ~ld1_rawp_disabled & ~st_atom_rq_d1 ;
2799assign ld2_pcx_rq_vld = 
2800  (|(queue_write[4:0] & ld2_l2bnk_dest[4:0])) & 
2801    ld2_pkt_vld & ~ld2_rawp_disabled ;
2802    //ld2_pkt_vld & ~ld2_rawp_disabled & ~mcycle_squash_d1;
2803    //ld2_pkt_vld & ~ld2_rawp_disabled & ~st_atom_rq_d1 ;
2804assign ld3_pcx_rq_vld = 
2805  (|(queue_write[4:0] & ld3_l2bnk_dest[4:0])) & 
2806    ld3_pkt_vld & ~ld3_rawp_disabled;
2807    //ld3_pkt_vld & ~ld3_rawp_disabled & ~mcycle_squash_d1;
2808    //ld3_pkt_vld & ~ld3_rawp_disabled & ~st_atom_rq_d1 ;
2809
2810//assign  ld_pcx_rq_vld = ld0_pcx_rq_vld | ld1_pcx_rq_vld
2811//      | ld2_pcx_rq_vld | ld3_pcx_rq_vld ;
2812
2813wire    st0_atomic_pend_d1, st1_atomic_pend_d1, st2_atomic_pend_d1, st3_atomic_pend_d1 ;
2814
2815assign  st0_q_wr[4:0] = st0_atomic_pend_d1 ? pre_qwr[4:0] : queue_write[4:0] ;
2816assign  st1_q_wr[4:0] = st1_atomic_pend_d1 ? pre_qwr[4:0] : queue_write[4:0] ;
2817assign  st2_q_wr[4:0] = st2_atomic_pend_d1 ? pre_qwr[4:0] : queue_write[4:0] ;
2818assign  st3_q_wr[4:0] = st3_atomic_pend_d1 ? pre_qwr[4:0] : queue_write[4:0] ;
2819
2820assign  st0_atom_rq = (st0_pcx_rq_sel & st0_atomic_vld) ; 
2821assign  st1_atom_rq = (st1_pcx_rq_sel & st1_atomic_vld) ;
2822assign  st2_atom_rq = (st2_pcx_rq_sel & st2_atomic_vld) ;
2823assign  st3_atom_rq = (st3_pcx_rq_sel & st3_atomic_vld) ;
2824
2825dff_s #(8)  avlds_d1 (
2826        .din    ({st0_atom_rq,st1_atom_rq,st2_atom_rq,st3_atom_rq,
2827    st0_cas_vld,st1_cas_vld,st2_cas_vld,st3_cas_vld}),
2828        .q      ({st0_atom_rq_d1,st1_atom_rq_d1,st2_atom_rq_d1,st3_atom_rq_d1,
2829    st0_cas_vld_d1,st1_cas_vld_d1,st2_cas_vld_d1,st3_cas_vld_d1}),
2830        .clk  (clk),
2831        .se     (1'b0),       .si (),          .so ()
2832        );
2833
2834dff_s #(8)  avlds_d2 (
2835        .din    ({st0_atom_rq_d1,st1_atom_rq_d1,st2_atom_rq_d1,st3_atom_rq_d1,
2836    st0_cas_vld_d1,st1_cas_vld_d1,st2_cas_vld_d1,st3_cas_vld_d1}),
2837        .q      ({st0_atom_rq_d2,st1_atom_rq_d2,st2_atom_rq_d2,st3_atom_rq_d2,
2838    st0_cas_vld_d2,st1_cas_vld_d2,st2_cas_vld_d2,st3_cas_vld_d2}),
2839        .clk  (clk),
2840        .se     (1'b0),       .si (),          .so ()
2841        );
2842
2843//timing fix : 7/28/03 - move the OR before flop
2844assign st_atom_rq = st0_atom_rq | st1_atom_rq | st2_atom_rq | st3_atom_rq ; 
2845//assign st_atom_rq_d1 = st0_atom_rq_d1 | st1_atom_rq_d1 | st2_atom_rq_d1 | st3_atom_rq_d1 ;
2846
2847// timing fix: 7/28/03 - move the OR before flop
2848dff_s #(1)  ff_st_atom_pq (
2849  .din (st_atom_rq),
2850  .q   (st_atom_rq_d1),
2851  .clk (clk),
2852  .se  (1'b0), .si (), .so ()
2853  );
2854
2855
2856assign st_cas_rq_d2 = 
2857  (st0_atom_rq_d2 & st0_cas_vld_d2)  | 
2858  (st1_atom_rq_d2 & st1_cas_vld_d2)  | 
2859  (st2_atom_rq_d2 & st2_cas_vld_d2)  | 
2860  (st3_atom_rq_d2 & st3_cas_vld_d2)  ; 
2861//assign st_quad_rq_d2 =
2862//  (st0_atom_rq_d2 & ~st0_cas_vld_d2)  |
2863//  (st1_atom_rq_d2 & ~st1_cas_vld_d2)  |
2864//  (st2_atom_rq_d2 & ~st2_cas_vld_d2)  |
2865//  (st3_atom_rq_d2 & ~st3_cas_vld_d2)  ;
2866
2867//timing fix: 9/17/03 - move the OR to previous cycle and add flop for spc_pcx_atom_pq
2868//                      instantiate buf30 for flop output
2869//assign  spc_pcx_atom_pq =
2870//    st_atom_rq_d1 | 
2871//    fpop_atom_rq_pq ;
2872
2873wire  spc_pcx_atom_w, spc_pcx_atom_pq_tmp ;
2874assign spc_pcx_atom_w  =  st_atom_rq | fpop_atom_req ;
2875
2876dff_s #(1)  ff_spc_pcx_atom_pq (
2877  .din (spc_pcx_atom_w),
2878  .q   (spc_pcx_atom_pq_tmp),
2879  .clk (clk),
2880  .se  (1'b0), .si (), .so ()
2881  );
2882
2883bw_u1_buf_30x UZfix_spc_pcx_atom_pq_buf1 ( .a(spc_pcx_atom_pq_tmp), .z(spc_pcx_atom_pq) );
2884bw_u1_buf_30x UZsize_spc_pcx_atom_pq_buf2 ( .a(spc_pcx_atom_pq_tmp), .z(spc_pcx_atom_pq_buf2) );
2885
2886// STORE
2887// st will wait in pcx bypass until previous st in chain is acked !!!!
2888//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2889assign st0_pcx_rq_vld = 
2890  (|(st0_q_wr[4:0] & st0_l2bnk_dest[4:0])) & st0_pkt_vld ;
2891  //(|(st0_q_wr[4:0] & st0_l2bnk_dest[4:0])) & st0_pkt_vld & ~mcycle_squash_d1;
2892  //(|(st0_q_wr[4:0] & st0_l2bnk_dest[4:0])) & st0_pkt_vld & ~st_atom_rq_d1 ;
2893assign st1_pcx_rq_vld = 
2894  (|(st1_q_wr[4:0] & st1_l2bnk_dest[4:0])) & st1_pkt_vld ;
2895  //(|(st1_q_wr[4:0] & st1_l2bnk_dest[4:0])) & st1_pkt_vld & ~mcycle_squash_d1;
2896  //(|(st1_q_wr[4:0] & st1_l2bnk_dest[4:0])) & st1_pkt_vld & ~st_atom_rq_d1 ;
2897assign st2_pcx_rq_vld = 
2898  (|(st2_q_wr[4:0] & st2_l2bnk_dest[4:0])) & st2_pkt_vld ;
2899  //(|(st2_q_wr[4:0] & st2_l2bnk_dest[4:0])) & st2_pkt_vld & ~mcycle_squash_d1;
2900  //(|(st2_q_wr[4:0] & st2_l2bnk_dest[4:0])) & st2_pkt_vld & ~st_atom_rq_d1 ;
2901assign st3_pcx_rq_vld = 
2902  (|(st3_q_wr[4:0] & st3_l2bnk_dest[4:0])) & st3_pkt_vld ;
2903  //(|(st3_q_wr[4:0] & st3_l2bnk_dest[4:0])) & st3_pkt_vld & ~mcycle_squash_d1;
2904  //(|(st3_q_wr[4:0] & st3_l2bnk_dest[4:0])) & st3_pkt_vld & ~st_atom_rq_d1 ;
2905
2906// IMISS
2907// imiss requests will not speculate - ** change !!!
2908//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2909assign imiss_pcx_rq_vld = 
2910  (|(queue_write[4:0] & imiss_l2bnk_dest[4:0])) & imiss_pkt_vld ;
2911  //(|(queue_write[4:0] & imiss_l2bnk_dest[4:0])) & imiss_pkt_vld & ~mcycle_squash_d1;
2912  //(|((queue_write[4:0] & (sel_qentry0[4:0] | (~sel_qentry0[4:0] & ~spc_pcx_req_update_w2[4:0]))) & imiss_l2bnk_dest[4:0])) & imiss_pkt_vld & ~mcycle_squash_d1;
2913
2914// SPU
2915//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2916assign strm_pcx_rq_vld = 
2917  (|(queue_write[4:0] & strm_l2bnk_dest[4:0])) & strm_pkt_vld ;
2918  //(|(queue_write[4:0] & strm_l2bnk_dest[4:0])) & strm_pkt_vld & ~mcycle_squash_d1;
2919
2920wire lsu_fwdpkt_vld_d1 ;
2921wire    [4:0]   fwdpkt_dest_d1 ;
2922// This delay is to compensate for the 1-cycle delay for internal rd/wr.
2923dff_s #(6)  fvld_stgd1 (
2924  .din ({lsu_fwdpkt_vld,lsu_fwdpkt_dest[4:0]}),
2925  .q   ({lsu_fwdpkt_vld_d1,fwdpkt_dest_d1[4:0]}),
2926  .clk (clk),
2927  .se  (1'b0), .si (), .so ()
2928  );
2929
2930// FWD PKT
2931//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2932assign fwdpkt_rq_vld = 
2933  (|(queue_write[4:0] & fwdpkt_dest_d1[4:0])) & 
2934        lsu_fwdpkt_vld_d1 & 
2935        ~(fwdpkt_pcx_rq_sel_d1 | fwdpkt_pcx_rq_sel_d2 |  // screen vld until reset can be sent.
2936        fwdpkt_pcx_rq_sel_d3) ; // extra cycle since fwdpkt_vld is now flop delayed.
2937        //~mcycle_squash_d1;
2938
2939// This to reset state. It must thus take into account speculative requests.
2940assign lsu_fwdpkt_pcx_rq_sel =  fwdpkt_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
2941
2942// INTERRUPT
2943//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2944assign intrpt_pcx_rq_vld = 
2945  (|(queue_write[4:0] & intrpt_l2bnk_dest[4:0])) & intrpt_pkt_vld ;
2946  //(|(queue_write[4:0] & intrpt_l2bnk_dest[4:0])) & intrpt_pkt_vld & ~mcycle_squash_d1;
2947
2948// FFU
2949// fpop will never get squashed.
2950// ** Should be able to simplify equation.
2951//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
2952//for fpop pre_qwr is good enough to qual 'cos there are no ld/st atomics to IOB
2953wire [4:0]  fpop_q_wr ;
2954assign fpop_pcx_rq_vld = 
2955  //sel_qentry0[4] & fpop_l2bnk_dest[4] & fpop_pkt_vld ;
2956  //(|(queue_write[4:0] & fpop_l2bnk_dest[4:0])) &
2957  //(|(pre_qwr[4:0] & fpop_l2bnk_dest[4:0])) &
2958  (|(fpop_q_wr[4:0] & fpop_l2bnk_dest[4:0])) & 
2959        // change sel_qentry0[5] to sel_qentry0[4] for fpio merge
2960      fpop_pkt_vld ;
2961      //fpop_pkt_vld & ((sel_qentry0[4] & fpop_pkt1) | ~fpop_pkt1) ;
2962        //~mcycle_squash_d1 ;
2963
2964
2965//=================================================================================================
2966// HIERARCHICAL PICKER FOR PCX REQ GENERATION
2967//=================================================================================================
2968
2969// 13 requests to choose from :
2970// - imiss, 4 ld, 4 st, (intrpt,strm,fpop,fwdpkt).
2971// - 4 categories are thus formed, each with equal weight.
2972// - As a consequence, imiss has the highest priority (because it is one vs. 4 in others)
2973// - Fair scheduling thru round-robin is ensured between and within categories.
2974// - Starvation for 2-cycle b2b ops (cas/fpop) is prevented.
2975// - strm requests, even though they lie in the misc category, will get good
2976// thruput as the other misc requests will be infrequent.
2977
2978// LEVEL ONE - PICK WITHIN CATEGORIES
2979
2980// Note : picker defaults to 1-hot.
2981
2982wire    [3:0]   all_pcx_rq_pick ;
2983wire    [3:0]   ld_events_raw ;
2984//wire  [3:0]   ld_events_final ;
2985wire    ld3_pcx_rq_pick,ld2_pcx_rq_pick,ld1_pcx_rq_pick,ld0_pcx_rq_pick ;
2986
2987//bug6807 - kill load events raw when partial raw is detected.
2988assign ld_events_raw[0]  =  (ld0_pkt_vld_unmasked & ~ld0_rawp_disabled) | ld0_pcx_rq_sel_d1 | ld0_pcx_rq_sel_d2 ;
2989assign ld_events_raw[1]  =  (ld1_pkt_vld_unmasked & ~ld1_rawp_disabled) | ld1_pcx_rq_sel_d1 | ld1_pcx_rq_sel_d2 ;
2990assign ld_events_raw[2]  =  (ld2_pkt_vld_unmasked & ~ld2_rawp_disabled) | ld2_pcx_rq_sel_d1 | ld2_pcx_rq_sel_d2 ;
2991assign ld_events_raw[3]  =  (ld3_pkt_vld_unmasked & ~ld3_rawp_disabled) | ld3_pcx_rq_sel_d1 | ld3_pcx_rq_sel_d2 ;
2992
2993//bug4814 - change rrobin_picker1 to rrobin_picker2
2994// Choose one among 4 loads.
2995//lsu_rrobin_picker1 ld4_rrobin  (
2996//    .events             ({ld3_pcx_rq_vld,ld2_pcx_rq_vld,
2997//                  ld1_pcx_rq_vld,ld0_pcx_rq_vld}),
2998//    .events_raw   ({ld3_pkt_vld_unmasked,ld2_pkt_vld_unmasked,
2999//                  ld1_pkt_vld_unmasked,ld0_pkt_vld_unmasked}),
3000//    .pick_one_hot ({ld3_pcx_rq_pick,ld2_pcx_rq_pick,
3001//                  ld1_pcx_rq_pick,ld0_pcx_rq_pick}),
3002//    .events_final (ld_events_final[3:0]),
3003//    .rclk         (rclk),
3004//    .grst_l       (grst_l),
3005//    .arst_l       (arst_l),
3006//    .si(),
3007//    .se(se),
3008//    .so()
3009//  );
3010
3011lsu_rrobin_picker2 ld4_rrobin  (
3012    .events       ({ld3_pcx_rq_vld,ld2_pcx_rq_vld,ld1_pcx_rq_vld,ld0_pcx_rq_vld}),
3013    .thread_force (ld_thrd_force_vld[3:0]),
3014    .pick_one_hot ({ld3_pcx_rq_pick,ld2_pcx_rq_pick,ld1_pcx_rq_pick,ld0_pcx_rq_pick}),
3015    .events_picked({ld3_pcx_rq_sel,ld2_pcx_rq_sel,ld1_pcx_rq_sel,ld0_pcx_rq_sel}),
3016    .rclk         (rclk),
3017    .grst_l       (grst_l),
3018    .arst_l       (arst_l),
3019    .si(),
3020    .se(se),
3021    .so()
3022  );
3023
3024
3025
3026
3027//timing fix: 05/20/03 - move mcycle_squash_d1 after pick instead of before pick
3028//assign        ld3_pcx_rq_sel = ld3_pcx_rq_pick & ld3_pcx_rq_vld & all_pcx_rq_pick[1] ;
3029//assign        ld2_pcx_rq_sel = ld2_pcx_rq_pick & ld2_pcx_rq_vld & all_pcx_rq_pick[1] ;
3030//assign        ld1_pcx_rq_sel = ld1_pcx_rq_pick & ld1_pcx_rq_vld & all_pcx_rq_pick[1] ;
3031//assign        ld0_pcx_rq_sel = ld0_pcx_rq_pick & ld0_pcx_rq_vld & all_pcx_rq_pick[1] ;
3032//bug2705 - add spec valid qualification
3033//assign        ld3_pcx_rq_sel = ld3_pcx_rq_pick & ld3_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3034//timing fix: 08/06/03 - tag_rdata->gen tag_parity_err->lsu_ld_miss_g arrives @625 in qctl1
3035//                       cache_way_hit ->lsu_ld_miss_g arrives @525 in qctl1
3036//                       cache_way_hit ->lsu_way_hit_or arrives @510 in qctl1
3037//                       625ps + ld?_l2cache_rq_g (130ps) + urq_stgpq flop logic(100ps) (slack=-100ps)
3038//assign  ld0_spec_pick_vld_g  =   ld0_spec_vld_g & ld0_l2cache_rq_g & ld0_pcx_rq_pick & ld0_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3039wire    ld0_nspec_pick_vld ,
3040        ld1_nspec_pick_vld ,
3041        ld2_nspec_pick_vld ,
3042        ld3_nspec_pick_vld ;
3043
3044assign  ld0_spec_pick_vld_g  =   ld0_spec_vld_g & ~lsu_way_hit_or & ld0_pcx_rq_pick & ld0_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3045assign  ld0_nspec_pick_vld   =  ~ld0_spec_vld_g &                   ld0_pcx_rq_pick & ld0_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3046
3047assign  ld1_spec_pick_vld_g  =   ld1_spec_vld_g & ~lsu_way_hit_or & ld1_pcx_rq_pick & ld1_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3048assign  ld1_nspec_pick_vld   =  ~ld1_spec_vld_g &                   ld1_pcx_rq_pick & ld1_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3049
3050assign  ld2_spec_pick_vld_g  =   ld2_spec_vld_g & ~lsu_way_hit_or & ld2_pcx_rq_pick & ld2_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3051assign  ld2_nspec_pick_vld   =  ~ld2_spec_vld_g &                   ld2_pcx_rq_pick & ld2_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3052
3053assign  ld3_spec_pick_vld_g  =   ld3_spec_vld_g & ~lsu_way_hit_or & ld3_pcx_rq_pick & ld3_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3054assign  ld3_nspec_pick_vld   =  ~ld3_spec_vld_g &                   ld3_pcx_rq_pick & ld3_pcx_rq_vld & all_pcx_rq_pick[1] & ~mcycle_squash_d1 ;
3055
3056
3057assign  ld0_pcx_rq_sel = (ld0_spec_pick_vld_g | ld0_nspec_pick_vld) ;
3058assign  ld1_pcx_rq_sel = (ld1_spec_pick_vld_g | ld1_nspec_pick_vld) ;
3059assign  ld2_pcx_rq_sel = (ld2_spec_pick_vld_g | ld2_nspec_pick_vld) ;
3060assign  ld3_pcx_rq_sel = (ld3_spec_pick_vld_g | ld3_nspec_pick_vld) ;
3061
3062//bug3506: set mask in the level1 pick in w3-cycle if picked by pcx
3063//assign  ld_events_final[3] = ld3_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3064//assign  ld_events_final[2] = ld2_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3065//assign  ld_events_final[1] = ld1_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3066//assign  ld_events_final[0] = ld0_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3067
3068
3069
3070wire    st3_pcx_rq_pick,st2_pcx_rq_pick,st1_pcx_rq_pick,st0_pcx_rq_pick ;
3071
3072// Choose one among 4 st.
3073
3074wire   pcx_rq_for_stb_en;
3075//wire [3:0]  st_events_final ;
3076wire [3:0]  st_events_raw ;
3077
3078//8/20/03: bug3506 fix is incomplete - vld may not be held until d2 cycle
3079assign st_events_raw[0]  =  stb0_rd_for_pcx | st0_pcx_rq_sel_d1 | st0_pcx_rq_sel_d2 ;
3080assign st_events_raw[1]  =  stb1_rd_for_pcx | st1_pcx_rq_sel_d1 | st1_pcx_rq_sel_d2 ;
3081assign st_events_raw[2]  =  stb2_rd_for_pcx | st2_pcx_rq_sel_d1 | st2_pcx_rq_sel_d2 ;
3082assign st_events_raw[3]  =  stb3_rd_for_pcx | st3_pcx_rq_sel_d1 | st3_pcx_rq_sel_d2 ;
3083
3084//bug4814 - change rrobin_picker1 to rrobin_picker2
3085//lsu_rrobin_picker1 st4_rrobin  (
3086//    .events             ({st3_pcx_rq_vld,st2_pcx_rq_vld,
3087//                              st1_pcx_rq_vld,st0_pcx_rq_vld}),
3088//    .events_raw         (st_events_raw[3:0]),
3089//    .pick_one_hot ({st3_pcx_rq_pick,st2_pcx_rq_pick,
3090//                              st1_pcx_rq_pick,st0_pcx_rq_pick}),
3091//    //.en           (pcx_rq_for_stb_en),                                                               
3092//    .events_final (st_events_final[3:0]),
3093//    .rclk         (rclk),
3094//    .grst_l       (grst_l),
3095//    .arst_l       (arst_l),
3096//    .si(),
3097//    .se(se),
3098//    .so()
3099//
3100//  );
3101
3102lsu_rrobin_picker2 st4_rrobin  (
3103    .events       ({st3_pcx_rq_vld,st2_pcx_rq_vld,st1_pcx_rq_vld,st0_pcx_rq_vld}),
3104    .thread_force(st_thrd_force_vld[3:0]),
3105    .pick_one_hot ({st3_pcx_rq_pick,st2_pcx_rq_pick,st1_pcx_rq_pick,st0_pcx_rq_pick}),
3106
3107    .events_picked(pcx_rq_for_stb[3:0]),
3108    .rclk         (rclk),
3109    .grst_l       (grst_l),
3110    .arst_l       (arst_l),
3111    .si(),
3112    .se(se),
3113    .so()
3114  );
3115
3116
3117
3118assign lsu_st_pcx_rq_pick[3:0]  =  {st3_pcx_rq_pick,st2_pcx_rq_pick,st1_pcx_rq_pick,st0_pcx_rq_pick};
3119//timing fix: 9/2/03 - reduce fanout in stb_rwctl for lsu_st_pcx_rq_pick - gen separate signal for
3120//                     stb_cam_rptr_vld and stb_data_rptr_vld
3121assign lsu_st_pcx_rq_vld  =  st0_pcx_rq_vld | st1_pcx_rq_vld | st2_pcx_rq_vld | st3_pcx_rq_vld ;
3122
3123//wire        st0_pcx_rq_sel_tmp, st1_pcx_rq_sel_tmp;
3124//wire        st2_pcx_rq_sel_tmp, st3_pcx_rq_sel_tmp;
3125   
3126
3127   wire stb_cam_hit_w;
3128
3129//bug3503
3130assign stb_cam_hit_w  =  stb_cam_hit_bf & lsu_inst_vld_w ;
3131
3132dff_s #(1)  stb_cam_hit_stg_w2  (
3133  .din (stb_cam_hit_w),
3134  .q   (stb_cam_hit_w2),
3135  .clk (clk),
3136  .se  (1'b0), .si (), .so ()
3137  );
3138
3139
3140//RAW read STB at W3 (not W2), so stb_cam_hit_w2 isn't critical   
3141//assign pcx_rq_for_stb_en = ~(|lsu_st_ack_rq_stb[3:0]) &   ~stb_cam_hit_w2 & ~stb_cam_wptr_vld;
3142//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
3143assign pcx_rq_for_stb_en = ~stb_cam_hit_w2 & ~stb_cam_wr_no_ivld_m & ~mcycle_squash_d1 ;
3144
3145//timing fix : 5/6 - move kill_w2 after store pick
3146//assign        pcx_rq_for_stb[3] = st3_pcx_rq_pick & st3_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en;
3147//assign        pcx_rq_for_stb[2] = st2_pcx_rq_pick & st2_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en;
3148//assign        pcx_rq_for_stb[1] = st1_pcx_rq_pick & st1_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en;
3149//assign        pcx_rq_for_stb[0] = st0_pcx_rq_pick & st0_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en;
3150
3151//timing fix: 05/20/03 - move mcycle_squash_d1 after pick instead of before pick
3152//bug4513 - kill pcx_rq_for_stb if atomic request is picked and 2 entries to the l2bank are not available
3153
3154wire  [3:0]  pcx_rq_for_stb_tmp ;
3155wire   st0_qmon_2entry_avail,st1_qmon_2entry_avail,st2_qmon_2entry_avail,st3_qmon_2entry_avail ;
3156
3157assign  pcx_rq_for_stb_tmp[3] =
3158        st3_pcx_rq_pick & st3_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[3] & ~mcycle_squash_d1 ;
3159        //st3_pcx_rq_pick & st3_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[3];
3160
3161assign  pcx_rq_for_stb_tmp[2] =
3162        st2_pcx_rq_pick & st2_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[2] & ~mcycle_squash_d1 ;
3163        //st2_pcx_rq_pick & st2_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[2];
3164
3165assign  pcx_rq_for_stb_tmp[1] =
3166        st1_pcx_rq_pick & st1_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[1] & ~mcycle_squash_d1 ;
3167        //st1_pcx_rq_pick & st1_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[1];
3168
3169assign  pcx_rq_for_stb_tmp[0] = 
3170        st0_pcx_rq_pick & st0_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[0] & ~mcycle_squash_d1 ;
3171        //st0_pcx_rq_pick & st0_pcx_rq_vld & all_pcx_rq_pick[2] & pcx_rq_for_stb_en & ~lsu_st_pcx_rq_kill_w2[0];
3172
3173//bug4513 - kill pcx_rq_for_stb if atomic request is picked and 2 entries to the l2bank are not available
3174assign  pcx_rq_for_stb[3] = ((st3_atomic_vld & st3_qmon_2entry_avail) | ~st3_atomic_vld) & pcx_rq_for_stb_tmp[3] ;
3175assign  pcx_rq_for_stb[2] = ((st2_atomic_vld & st2_qmon_2entry_avail) | ~st2_atomic_vld) & pcx_rq_for_stb_tmp[2] ;
3176assign  pcx_rq_for_stb[1] = ((st1_atomic_vld & st1_qmon_2entry_avail) | ~st1_atomic_vld) & pcx_rq_for_stb_tmp[1] ;
3177assign  pcx_rq_for_stb[0] = ((st0_atomic_vld & st0_qmon_2entry_avail) | ~st0_atomic_vld) & pcx_rq_for_stb_tmp[0] ;
3178
3179//assign        st3_pcx_rq_sel_tmp = st3_pcx_rq_pick & st3_pcx_rq_vld & all_pcx_rq_pick[2] ;
3180//assign        st2_pcx_rq_sel_tmp = st2_pcx_rq_pick & st2_pcx_rq_vld & all_pcx_rq_pick[2] ;
3181//assign        st1_pcx_rq_sel_tmp = st1_pcx_rq_pick & st1_pcx_rq_vld & all_pcx_rq_pick[2] ;
3182//assign        st0_pcx_rq_sel_tmp = st0_pcx_rq_pick & st0_pcx_rq_vld & all_pcx_rq_pick[2] ;
3183
3184//bug3506: set mask in the level1 pick in w3-cycle if picked by pcx
3185//assign  st_events_final[3] = st3_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3186//assign  st_events_final[2] = st2_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3187//assign  st_events_final[1] = st1_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3188//assign  st_events_final[0] = st0_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3189
3190
3191
3192wire    strm_pcx_rq_pick,fpop_pcx_rq_pick,intrpt_pcx_rq_pick,fwdpkt_pcx_rq_pick;
3193//wire [3:0]  misc_events_final ;
3194wire [3:0]  misc_events_raw ;
3195
3196//8/20/03: bug3506 fix is incomplete - vld may not be held until d2 cycle
3197assign  misc_events_raw[0]   =  lsu_fwdpkt_vld_d1 | fwdpkt_pcx_rq_sel_d1 | fwdpkt_pcx_rq_sel_d2 ;
3198//bug6807 - kill interrupt events raw when store buffer is not empty i.e. interrupt clear=0
3199assign  misc_events_raw[1]   =  (intrpt_pkt_vld_unmasked & intrpt_clr_d1) | intrpt_pcx_rq_sel_d1 | intrpt_pcx_rq_sel_d2 ;
3200assign  misc_events_raw[2]   =  fpop_pkt_vld_unmasked | fpop_pcx_rq_sel_d1 | fpop_pcx_rq_sel_d2 ;
3201assign  misc_events_raw[3]   =  strm_pkt_vld_unmasked | strm_pcx_rq_sel_d1 | strm_pcx_rq_sel_d2 ;
3202
3203
3204//bug4814 - change rrobin_picker1 to rrobin_picker2
3205//lsu_rrobin_picker1 misc4_rrobin  (
3206//    .events             ({strm_pcx_rq_vld,fpop_pcx_rq_vld,
3207//                  intrpt_pcx_rq_vld,fwdpkt_rq_vld}),
3208//    .events_raw   (misc_events_raw[3:0]),
3209//    .pick_one_hot ({strm_pcx_rq_pick,fpop_pcx_rq_pick,
3210//                  intrpt_pcx_rq_pick,fwdpkt_pcx_rq_pick}),
3211//    .events_final (misc_events_final[3:0]),
3212//    .rclk         (rclk),
3213//    .grst_l       (grst_l),
3214//    .arst_l       (arst_l),
3215//    .si(),
3216//    .se(se),
3217//    .so()
3218//  );
3219
3220lsu_rrobin_picker2 misc4_rrobin  (
3221    .events       ({strm_pcx_rq_vld,fpop_pcx_rq_vld,intrpt_pcx_rq_vld,fwdpkt_rq_vld}),
3222    .thread_force(misc_thrd_force_vld[3:0]),
3223    .pick_one_hot ({strm_pcx_rq_pick,fpop_pcx_rq_pick,intrpt_pcx_rq_pick,fwdpkt_pcx_rq_pick}),
3224
3225    .events_picked({strm_pcx_rq_sel,fpop_pcx_rq_sel,intrpt_pcx_rq_sel,fwdpkt_pcx_rq_sel}),
3226    .rclk         (rclk),
3227    .grst_l       (grst_l),
3228    .arst_l       (arst_l),
3229    .si(),
3230    .se(se),
3231    .so()
3232  );
3233
3234
3235//timing fix: 05/20/03 - move mcycle_squash_d1 after pick instead of before pick
3236//assign        strm_pcx_rq_sel = strm_pcx_rq_pick & strm_pcx_rq_vld & all_pcx_rq_pick[3] ;
3237//assign        fpop_pcx_rq_sel = fpop_pcx_rq_pick & fpop_pcx_rq_vld & all_pcx_rq_pick[3] ;
3238//assign        intrpt_pcx_rq_sel = intrpt_pcx_rq_pick & intrpt_pcx_rq_vld & all_pcx_rq_pick[3] ;
3239//assign        fwdpkt_pcx_rq_sel = fwdpkt_pcx_rq_pick & fwdpkt_rq_vld & all_pcx_rq_pick[3] ;
3240assign  strm_pcx_rq_sel = strm_pcx_rq_pick & strm_pcx_rq_vld & all_pcx_rq_pick[3] & ~mcycle_squash_d1 ;
3241
3242//11/15/03 - change fpop atomic to be same as store atomic (bug4513)
3243//assign        fpop_pcx_rq_sel = fpop_pcx_rq_pick & fpop_pcx_rq_vld & all_pcx_rq_pick[3] & ~mcycle_squash_d1 ;
3244wire    fpop_qmon_2entry_avail ;
3245assign  fpop_pcx_rq_sel_tmp = fpop_pcx_rq_pick & fpop_pcx_rq_vld & all_pcx_rq_pick[3] & ~mcycle_squash_d1 ;
3246assign  fpop_pcx_rq_sel = fpop_pcx_rq_sel_tmp & fpop_qmon_2entry_avail ;
3247
3248assign  intrpt_pcx_rq_sel = intrpt_pcx_rq_pick & intrpt_pcx_rq_vld & all_pcx_rq_pick[3] & ~mcycle_squash_d1 ;
3249assign  fwdpkt_pcx_rq_sel = fwdpkt_pcx_rq_pick & fwdpkt_rq_vld & all_pcx_rq_pick[3] & ~mcycle_squash_d1 ;
3250
3251
3252//bug3506: set mask in the level1 pick in w3-cycle if picked by pcx
3253//assign  misc_events_final[3] = lsu_spu_ldst_ack ;
3254//assign  misc_events_final[2] = lsu_tlu_pcxpkt_ack ;
3255//assign  misc_events_final[1] = lsu_fwdpkt_pcx_rq_sel ;
3256//assign  misc_events_final[0] = fpop_pcx_rq_sel_d2 & ~pcx_req_squash_d1 ;
3257
3258
3259
3260
3261// LEVEL TWO - PICK AMONG CATEGORIES
3262// In parallel with level one
3263
3264wire    ld_pcx_rq_all, st_pcx_rq_all, misc_pcx_rq_all ;
3265assign  ld_pcx_rq_all = ld3_pcx_rq_vld | ld2_pcx_rq_vld | ld1_pcx_rq_vld | ld0_pcx_rq_vld ;     
3266assign  st_pcx_rq_all = st3_pcx_rq_vld | st2_pcx_rq_vld | st1_pcx_rq_vld | st0_pcx_rq_vld ; 
3267assign  misc_pcx_rq_all = strm_pcx_rq_vld | fpop_pcx_rq_vld | intrpt_pcx_rq_vld | fwdpkt_rq_vld ;
3268
3269//bug3506- raw valid used in resetting pick status
3270//8/20/03: bug3506 fix is incomplete - vld may not be held until d2 cycle
3271
3272//wire all4_rrobin_en;
3273//timing fix: 5/20/03 - pcx_rq_for_stb will be independent of ifu_lsu_pcxreq_d
3274//assign all4_rrobin_en = ~(all_pcx_rq_pick[2] & ~pcx_rq_for_stb_en) ;
3275//timing fix: 05/20/03 - move mycle_squash_d1 after pick instead of before pick
3276//assign all4_rrobin_en = ~((all_pcx_rq_pick[2] & ~pcx_rq_for_stb_en) | imiss_pcx_rq_vld );
3277//bug3348 - setting history moved from w-stage to w3-stage(1-cycle after spc_pcx_req_pq)
3278//          and hence there are no cases to disable logging of history
3279//assign all4_rrobin_en = ~((all_pcx_rq_pick[2] & ~pcx_rq_for_stb_en) | imiss_pcx_rq_vld | mcycle_squash_d1);
3280//wire   spc_pcx_req_vld_pq1 ;
3281//assign all4_rrobin_en =  spc_pcx_req_vld_pq1 ;
3282 
3283//wire  [3:1]  all_pcx_rq_pick_no_iqual;
3284wire  [3:0]  all_pcx_rq_pick_no_iqual; 
3285//wire  [3:0]  all_pcx_pick_status_d2;  // bug 3348
3286//wire  [3:0]  all_pick_status_rst_d2;    //bug 3506
3287wire  [3:0]  all_pick_status_set;
3288
3289//bug3506: set pick status in the same cycle
3290assign  all_pick_status_set[3]  =  |{ strm_pcx_rq_sel, intrpt_pcx_rq_sel,fpop_pcx_rq_sel, fwdpkt_pcx_rq_sel} ;
3291assign  all_pick_status_set[2]  =  |pcx_rq_for_stb[3:0] ;
3292assign  all_pick_status_set[1]  =  |{ld0_pcx_rq_sel,ld1_pcx_rq_sel,ld2_pcx_rq_sel,ld3_pcx_rq_sel} ;
3293assign  all_pick_status_set[0]  =  1'b0 ;
3294
3295
3296
3297lsu_rrobin_picker2 all4_rrobin  (
3298    .events       ({misc_pcx_rq_all,st_pcx_rq_all,ld_pcx_rq_all,1'b0}),
3299    .thread_force(all_thrd_force_vld[3:0]),
3300    .pick_one_hot (all_pcx_rq_pick_no_iqual[3:0]),
3301
3302    .events_picked(all_pick_status_set[3:0]),
3303    //.en           (all4_rrobin_en),      // bug 3348
3304    .rclk         (rclk),
3305    .grst_l       (grst_l),
3306    .arst_l       (arst_l),
3307    .si(),
3308    .se(se),
3309    .so()
3310  );
3311
3312
3313// 5/22/03: cmp1_regr fail - qual all pick w/  ~mcycle_squash_d1; not doing this causes multi-hot select to
3314//          pcx_pkt mux
3315assign all_pcx_rq_pick[0]    =  imiss_pcx_rq_vld & ~mcycle_squash_d1;
3316assign all_pcx_rq_pick[3:1]  =  all_pcx_rq_pick_no_iqual[3:1] & ~{3{imiss_pcx_rq_vld | mcycle_squash_d1}};
3317
3318wire   all_pcx_rq_dest_sel3 ;
3319assign all_pcx_rq_dest_sel3  =  ~|all_pcx_rq_pick[2:0];
3320
3321//timing fix: 5/20/03 - pcx_rq_for_stb will be independent of ifu_lsu_pcxreq_d
3322//assign        imiss_pcx_rq_sel = imiss_pcx_rq_vld & all_pcx_rq_pick[0] ;
3323//timing fix: 05/20/03 - move mcycle_squash_d1 after pick instead of before pick
3324//assign        imiss_pcx_rq_sel = imiss_pcx_rq_vld;
3325assign  imiss_pcx_rq_sel = imiss_pcx_rq_vld & ~mcycle_squash_d1 ;
3326
3327//=================================================================================================
3328
3329// Select appr. load. Need a scheme which allows threads to
3330// make fwd progress.
3331/*assign  ld0_pcx_rq_sel = ld0_pcx_rq_vld ;
3332assign  ld1_pcx_rq_sel = ld1_pcx_rq_vld & ~ld0_pcx_rq_vld ;
3333assign  ld2_pcx_rq_sel = ld2_pcx_rq_vld & ~(ld0_pcx_rq_vld | ld1_pcx_rq_vld);
3334assign  ld3_pcx_rq_sel = ld3_pcx_rq_vld & ~(ld0_pcx_rq_vld | ld1_pcx_rq_vld | ld2_pcx_rq_vld)   ; */
3335
3336dff_s #(4)  lrsel_stgd1 (
3337        .din    ({ld0_pcx_rq_sel, ld1_pcx_rq_sel, ld2_pcx_rq_sel, ld3_pcx_rq_sel}),
3338        .q      ({ld0_pcx_rq_sel_d1, ld1_pcx_rq_sel_d1, ld2_pcx_rq_sel_d1, ld3_pcx_rq_sel_d1}),
3339        .clk  (clk),
3340        .se     (1'b0),       .si (),          .so ()
3341        ); 
3342
3343//bug2705- kill pcx pick if spec vld kill is set
3344assign  lsu_ld0_pcx_rq_sel_d1  =  ld0_pcx_rq_sel_d1 & ~lsu_ld0_spec_vld_kill_w2 ;
3345assign  lsu_ld1_pcx_rq_sel_d1  =  ld1_pcx_rq_sel_d1 & ~lsu_ld1_spec_vld_kill_w2 ;
3346assign  lsu_ld2_pcx_rq_sel_d1  =  ld2_pcx_rq_sel_d1 & ~lsu_ld2_spec_vld_kill_w2 ;
3347assign  lsu_ld3_pcx_rq_sel_d1  =  ld3_pcx_rq_sel_d1 & ~lsu_ld3_spec_vld_kill_w2 ;
3348
3349
3350dff_s #(4)  lrsel_stgd2 (
3351        .din    ({lsu_ld0_pcx_rq_sel_d1, lsu_ld1_pcx_rq_sel_d1, lsu_ld2_pcx_rq_sel_d1, lsu_ld3_pcx_rq_sel_d1}),
3352        .q      ({ld0_pcx_rq_sel_d2, ld1_pcx_rq_sel_d2, ld2_pcx_rq_sel_d2, ld3_pcx_rq_sel_d2}),
3353        .clk  (clk),
3354        .se     (1'b0),       .si (),          .so ()
3355        ); 
3356
3357// Used to complete prefetch. Be careful ! ld could be squashed. Add pcx_req_squash.
3358assign  lsu_ld_pcx_rq_sel_d2[3] = ld3_pcx_rq_sel_d2 ;
3359assign  lsu_ld_pcx_rq_sel_d2[2] = ld2_pcx_rq_sel_d2 ;
3360assign  lsu_ld_pcx_rq_sel_d2[1] = ld1_pcx_rq_sel_d2 ;
3361assign  lsu_ld_pcx_rq_sel_d2[0] = ld0_pcx_rq_sel_d2 ;
3362
3363//bug2705- kill pcx pick if spec vld kill is set
3364wire    ld_pcxpkt_vld ;
3365assign  ld_pcxpkt_vld = 
3366  lsu_ld0_pcx_rq_sel_d1 | lsu_ld1_pcx_rq_sel_d1 | lsu_ld2_pcx_rq_sel_d1 | lsu_ld3_pcx_rq_sel_d1 ;
3367  //ld0_pcx_rq_sel_d1 | ld1_pcx_rq_sel_d1 | ld2_pcx_rq_sel_d1 | ld3_pcx_rq_sel_d1 ;
3368
3369dff_s #(1)  icindx_stgd1 (
3370        .din    (ld_pcxpkt_vld), 
3371        .q      (lsu_ifu_ld_pcxpkt_vld),
3372        .clk    (clk),
3373        .se     (1'b0),       .si (),          .so ()
3374        ); 
3375
3376wire  [3:0]           ld_pcx_rq_sel ;   
3377
3378assign  ld_pcx_rq_sel[0] =  ld0_pcx_rq_sel_d1 | st0_atom_rq_d2 ;
3379assign  ld_pcx_rq_sel[1] =  ld1_pcx_rq_sel_d1 | st1_atom_rq_d2 ;
3380assign  ld_pcx_rq_sel[2] =  ld2_pcx_rq_sel_d1 | st2_atom_rq_d2 ;
3381assign  ld_pcx_rq_sel[3] =  ld3_pcx_rq_sel_d1 | st3_atom_rq_d2 ;
3382
3383//11/7/03: add rst_tri_en
3384assign  lsu_ld_pcx_rq_mxsel[2:0]  =    ld_pcx_rq_sel[2:0] & {3{~rst_tri_en}} ;
3385assign  lsu_ld_pcx_rq_mxsel[3]    =  (~|ld_pcx_rq_sel[2:0]) | rst_tri_en ;
3386
3387assign ld_pcx_thrd[0] = ld_pcx_rq_sel[1] | ld_pcx_rq_sel[3] ;
3388assign ld_pcx_thrd[1] = ld_pcx_rq_sel[2] | ld_pcx_rq_sel[3] ;
3389   
3390// Assume a simple priority based scheme for now.
3391// This should not be prioritized at this point.
3392//assign st_pcx_rq_mhot_sel[0] = st0_pcx_rq_sel_tmp ;
3393//assign st_pcx_rq_mhot_sel[1] = st1_pcx_rq_sel_tmp ;
3394//assign st_pcx_rq_mhot_sel[2] = st2_pcx_rq_sel_tmp ;
3395//assign st_pcx_rq_mhot_sel[3] = st3_pcx_rq_sel_tmp ;
3396   
3397/*assign st_pcx_rq_mhot_sel[0] =
3398  ~ld_pcx_rq_vld  & st0_pcx_rq_vld ;
3399assign st_pcx_rq_mhot_sel[1] =
3400  ~ld_pcx_rq_vld  & st1_pcx_rq_vld ;
3401assign st_pcx_rq_mhot_sel[2] =
3402  ~ld_pcx_rq_vld  & st2_pcx_rq_vld ;
3403assign st_pcx_rq_mhot_sel[3] =
3404  ~ld_pcx_rq_vld  & st3_pcx_rq_vld ;*/
3405
3406   
3407assign  st0_pcx_rq_sel = pcx_rq_for_stb[0] ;
3408assign  st1_pcx_rq_sel = pcx_rq_for_stb[1] ;
3409assign  st2_pcx_rq_sel = pcx_rq_for_stb[2] ;
3410assign  st3_pcx_rq_sel = pcx_rq_for_stb[3] ;
3411
3412//assign  st_pcx_rq_vld =  (|pcx_rq_for_stb[3:0]);
3413
3414// Temporary.
3415//assign  st0_pcx_rq_sel = stb_rd_for_pcx_sel[0] ;
3416//assign  st1_pcx_rq_sel = stb_rd_for_pcx_sel[1] ;
3417//assign  st2_pcx_rq_sel = stb_rd_for_pcx_sel[2] ;
3418//assign  st3_pcx_rq_sel = stb_rd_for_pcx_sel[3] ;
3419
3420// This will be on a critical path. Massage !!!
3421// Allows for speculative requests.
3422//assign  st_pcx_rq_vld =
3423//    (st0_pcx_rq_sel & stb_rd_for_pcx_sel[0]) |
3424//    (st1_pcx_rq_sel & stb_rd_for_pcx_sel[1]) |
3425//    (st2_pcx_rq_sel & stb_rd_for_pcx_sel[2]) |
3426//    (st3_pcx_rq_sel & stb_rd_for_pcx_sel[3])  ;
3427
3428
3429   
3430/*assign imiss_pcx_rq_sel =
3431  imiss_pcx_rq_vld & ~(ld_pcx_rq_vld | st_pcx_rq_vld) ;
3432assign strm_pcx_rq_sel =
3433  strm_pcx_rq_vld & ~(ld_pcx_rq_vld | st_pcx_rq_vld | imiss_pcx_rq_sel) ;
3434assign fpop_pcx_rq_sel =
3435  fpop_pcx_rq_vld & ~(ld_pcx_rq_vld | st_pcx_rq_vld | imiss_pcx_rq_vld | strm_pcx_rq_vld) ;
3436assign intrpt_pcx_rq_sel =
3437  intrpt_pcx_rq_vld & ~(ld_pcx_rq_vld | st_pcx_rq_vld | imiss_pcx_rq_vld | strm_pcx_rq_vld | fpop_pcx_rq_sel) ;
3438assign fwdpkt_pcx_rq_sel =
3439  fwdpkt_rq_vld & ~(ld_pcx_rq_vld | st_pcx_rq_vld | imiss_pcx_rq_vld | strm_pcx_rq_vld | intrpt_pcx_rq_vld
3440                        | fpop_pcx_rq_sel) ; */
3441
3442
3443//assign imiss_strm_pcx_rq_sel = imiss_pcx_rq_sel | strm_pcx_rq_sel ;
3444
3445// request was made with the queues full but not grant.
3446assign  pcx_req_squash = 
3447  (|(spc_pcx_req_pq_buf2[4:0] & ~pre_qwr[4:0] & ~pcx_spc_grant_px[4:0])) ;
3448//(|(spc_pcx_req_pq[4:0] & ~queue_write[4:0] & ~pcx_spc_grant_px[4:0])) ;
3449//  (|lsu_error_rst[3:0]) | // dtag parity error requires two ld pkts
3450//  (st_atom_rq_d1) ; // cas,stq - 2 pkt requests
3451
3452//bug:2877 - dtag parity error 2nd packet request;
3453//wire  error_rst ;
3454
3455//assign        error_rst =
3456//      (ld0_pcx_rq_sel_d1 & lsu_dtag_perror_w2[0]) |
3457//      (ld1_pcx_rq_sel_d1 & lsu_dtag_perror_w2[1]) |
3458//      (ld2_pcx_rq_sel_d1 & lsu_dtag_perror_w2[2]) |
3459//      (ld3_pcx_rq_sel_d1 & lsu_dtag_perror_w2[3]) ;
3460
3461//wire  error_rst_d1 ;
3462//dff #(1)  erst_stgd1 (
3463//        .din    (error_rst),
3464//      .q      (error_rst_d1),
3465//        .clk          (clk),
3466//        .se     (1'b0),       .si (),          .so ()
3467//        );
3468
3469wire   [3:0]  dtag_perr_pkt2_vld ;
3470assign  dtag_perr_pkt2_vld[0] =  lsu_ld0_pcx_rq_sel_d1 & lsu_dtag_perror_w2[0];
3471assign  dtag_perr_pkt2_vld[1] =  lsu_ld1_pcx_rq_sel_d1 & lsu_dtag_perror_w2[1];
3472assign  dtag_perr_pkt2_vld[2] =  lsu_ld2_pcx_rq_sel_d1 & lsu_dtag_perror_w2[2];
3473assign  dtag_perr_pkt2_vld[3] =  lsu_ld3_pcx_rq_sel_d1 & lsu_dtag_perror_w2[3];
3474
3475//bug:2877 - dtag parity error 2nd packet request; flop to sync w/ ld?_pcx_rq_sel_d2
3476dff_s #(4) ff_dtag_perr_pkt2_vld_d1 (
3477        .din    (dtag_perr_pkt2_vld[3:0]), 
3478        .q      (dtag_perr_pkt2_vld_d1[3:0]),
3479        .clk    (clk),
3480        .se     (1'b0),       .si (),          .so ()
3481        ); 
3482
3483
3484
3485//bug:2877 - dtag parity error 2nd packet request; error_rst can be removed from mcycle_mask_d1 since
3486//           it does not behave like an atomic i.e. it is sent as 2 separate packets.
3487assign  mcycle_squash_d1 =
3488 // error_rst | // dtag parity error requires two ld pkts
3489  //(|lsu_error_rst[3:0]) | // dtag parity error requires two ld pkts
3490  spc_pcx_atom_pq_buf2 ;   // cas/fpop
3491
3492dff_s #(1)  sqsh_stgd1 (
3493        .din    (pcx_req_squash), 
3494        .q      (pcx_req_squash_d1),
3495        .clk    (clk),
3496        .se     (1'b0),       .si (),          .so ()
3497        ); 
3498
3499dff_s #(1)  sqsh_stgd2 (
3500        .din    (pcx_req_squash_d1), 
3501        .q      (pcx_req_squash_d2),
3502        .clk    (clk),
3503        .se     (1'b0),       .si (),          .so ()
3504        ); 
3505//timing fix: 9/19/03 - split the lsu_pcx_req_squash to 4 signals to stb_ctl[0-3] to reduce loading
3506assign  lsu_pcx_req_squash = pcx_req_squash & ~st_atom_rq_d1 ;
3507assign  lsu_pcx_req_squash0 = lsu_pcx_req_squash ;
3508assign  lsu_pcx_req_squash1 = lsu_pcx_req_squash ;
3509assign  lsu_pcx_req_squash2 = lsu_pcx_req_squash ;
3510assign  lsu_pcx_req_squash3 = lsu_pcx_req_squash ;
3511
3512assign  lsu_pcx_req_squash_d1 = pcx_req_squash_d1 ;
3513
3514dff_s #(5)  rsel_stgd1 (
3515        //.din    ({imiss_strm_pcx_rq_sel,
3516        .din    ({
3517    imiss_pcx_rq_sel, strm_pcx_rq_sel, intrpt_pcx_rq_sel, fpop_pcx_rq_sel,
3518    fwdpkt_pcx_rq_sel}), 
3519        //.q      ({imiss_strm_pcx_rq_sel_d1,
3520        .q      ({
3521    imiss_pcx_rq_sel_d1, strm_pcx_rq_sel_d1, intrpt_pcx_rq_sel_d1,fpop_pcx_rq_sel_d1,
3522    fwdpkt_pcx_rq_sel_d1}), 
3523        .clk  (clk),
3524        .se     (1'b0),       .si (),          .so ()
3525        ); 
3526
3527assign  lsu_imiss_pcx_rq_sel_d1  =  imiss_pcx_rq_sel_d1;
3528
3529dff_s  imrqs_stgd2 (
3530        .din    (imiss_pcx_rq_sel_d1), 
3531        .q      (imiss_pcx_rq_sel_d2),
3532        .clk    (clk),
3533        .se     (1'b0),       .si (),          .so ()
3534        ); 
3535
3536dff_s  fwdrqs_stgd2 (
3537        .din    (fwdpkt_pcx_rq_sel_d1), 
3538        .q      (fwdpkt_pcx_rq_sel_d2),
3539        .clk    (clk),
3540        .se     (1'b0),       .si (),          .so ()
3541        ); 
3542
3543dff_s  fwdrqs_stgd3 (
3544        .din    (fwdpkt_pcx_rq_sel_d2), 
3545        .q      (fwdpkt_pcx_rq_sel_d3),
3546        .clk    (clk),
3547        .se     (1'b0),       .si (),          .so ()
3548        ); 
3549
3550dff_s  fpop_stgd2 (
3551        .din    (fpop_pcx_rq_sel_d1), .(fpop_pcx_rq_sel_d2),
3552        .clk    (clk),
3553        .se     (1'b0),       .si (),          .so ()
3554        ); 
3555
3556//bug4665: add sehold to pcx_pkt_src_sel[1]
3557//wire  ld_pcx_rq_sel_d1,st_pcx_rq_sel_d1,misc_pcx_rq_sel_d1;
3558wire    ld_pcx_rq_sel_d1,st_pcx_rq_sel_d1;
3559wire    all_pcx_rq_pick_b2 ;
3560assign  all_pcx_rq_pick_b2  =  sehold ? st_pcx_rq_sel_d1 : all_pcx_rq_pick[2] ;
3561
3562dff_s #(2)  pick_stgd1 (
3563        .din    ({all_pcx_rq_pick_b2, all_pcx_rq_pick[1]}), 
3564        .q      ({st_pcx_rq_sel_d1,ld_pcx_rq_sel_d1}),
3565        //.din    ({all_pcx_rq_pick[3], all_pcx_rq_pick_b2, all_pcx_rq_pick[1]}),
3566        //.q      ({misc_pcx_rq_sel_d1,st_pcx_rq_sel_d1,ld_pcx_rq_sel_d1}),
3567        //.din    (all_pcx_rq_pick[2:1]), .q      ({st_pcx_rq_sel_d1,ld_pcx_rq_sel_d1}),
3568        .clk  (clk),
3569        .se     (1'b0),       .si (),          .so ()
3570        ); 
3571
3572// add other sources in such as interrupt and fpop.
3573//bug:2877 - dtag parity error 2nd packet request; remove error_rst_d1 since dtag parity error does not
3574//           behave as an atomic
3575//assign pcx_pkt_src_sel[0] = ld_pcx_rq_sel_d1 | st_cas_rq_d2 | error_rst_d1 ;
3576
3577//11/7/03 - add rst_tri_en
3578wire  [3:0]  pcx_pkt_src_sel_tmp ;
3579assign pcx_pkt_src_sel_tmp[0] = ld_pcx_rq_sel_d1 | st_cas_rq_d2 ;
3580assign pcx_pkt_src_sel_tmp[1] = st_pcx_rq_sel_d1 ;
3581assign pcx_pkt_src_sel_tmp[2] = ~|{pcx_pkt_src_sel[3],pcx_pkt_src_sel[1:0]};
3582                                //imiss_strm_pcx_rq_sel_d1  ;
3583assign pcx_pkt_src_sel_tmp[3] = fpop_pcx_rq_sel_d1 | fpop_pcx_rq_sel_d2 |
3584                                fwdpkt_pcx_rq_sel_d1 | intrpt_pcx_rq_sel_d1 ;
3585
3586//bug4888 -  change rst_tri_en to select b[1] instead of b[3]
3587
3588assign pcx_pkt_src_sel[3:2]  =  pcx_pkt_src_sel_tmp[3:2] & {2{~rst_tri_en}} ;
3589assign pcx_pkt_src_sel[1]    =  pcx_pkt_src_sel_tmp[1] | rst_tri_en ;
3590assign pcx_pkt_src_sel[0]    =  pcx_pkt_src_sel_tmp[0] & ~rst_tri_en ;
3591
3592//assign  dest_pkt_sel[0] = ld_pcx_rq_vld ;
3593//assign  dest_pkt_sel[1] = st_pcx_rq_vld ;
3594//assign  dest_pkt_sel[2] = ~(ld_pcx_rq_vld | st_pcx_rq_vld);
3595
3596//=================================================================================================
3597//              SELECT DESTINATION
3598//=================================================================================================
3599
3600// Select dest for load.
3601mux4ds  #(5) ldsel_dest (
3602  .in0  (ld0_l2bnk_dest[4:0]),
3603  .in1  (ld1_l2bnk_dest[4:0]),
3604  .in2  (ld2_l2bnk_dest[4:0]),
3605  .in3  (ld3_l2bnk_dest[4:0]),
3606  .sel0 (ld0_pcx_rq_pick),
3607  .sel1 (ld1_pcx_rq_pick),
3608  .sel2 (ld2_pcx_rq_pick),
3609  .sel3 (ld3_pcx_rq_pick),
3610  .dout (ld_pkt_dest[4:0])
3611);
3612
3613// Select dest for store
3614mux4ds  #(5) stsel_dest (
3615  .in0  (st0_l2bnk_dest[4:0]),
3616  .in1  (st1_l2bnk_dest[4:0]),
3617  .in2  (st2_l2bnk_dest[4:0]),
3618  .in3  (st3_l2bnk_dest[4:0]),
3619  .sel0 (st0_pcx_rq_pick),
3620  .sel1 (st1_pcx_rq_pick),
3621  .sel2 (st2_pcx_rq_pick),
3622  .sel3 (st3_pcx_rq_pick),
3623  .dout (st_pkt_dest[4:0])
3624);
3625
3626wire    [4:0]   misc_pkt_dest ;
3627mux4ds  #(5) miscsel_dest (
3628  .in0  (strm_l2bnk_dest[4:0]),
3629  .in1  (fpop_l2bnk_dest[4:0]),
3630  .in2  (intrpt_l2bnk_dest[4:0]),
3631  .in3  (fwdpkt_dest_d1[4:0]),
3632  .sel0 (strm_pcx_rq_pick),
3633  .sel1 (fpop_pcx_rq_pick),
3634  .sel2 (intrpt_pcx_rq_pick),
3635  .sel3 (fwdpkt_pcx_rq_pick),
3636  .dout (misc_pkt_dest[4:0])
3637);
3638
3639// This is temporary until the req/ack path is restructured
3640/*assign  imiss_strm_pkt_dest[4:0] =
3641  imiss_pcx_rq_sel ? imiss_l2bnk_dest[4:0] : 
3642    strm_pcx_rq_sel ? strm_l2bnk_dest[4:0] :
3643      fpop_pcx_rq_sel ? fpop_l2bnk_dest[4:0] :
3644        intrpt_pcx_rq_sel ? intrpt_l2bnk_dest[4:0] :
3645                lsu_fwdpkt_dest[4:0] ;  */
3646
3647/*
3648// This needs to be replaced with structural mux once rq/ack resolved.
3649mux4ds  #(5) istrmsel_dest (
3650  .in0  (imiss_l2bnk_dest[4:0]),
3651  .in1  (strm_l2bnk_dest[4:0]),
3652  .in2  (fpop_l2bnk_dest[4:0]),
3653  .in3  (intrpt_l2bnk_dest[4:0]),
3654  .sel0 (imiss_pcx_rq_sel), 
3655  .sel1   (strm_pcx_rq_sel),
3656  .sel2   (fpop_pcx_rq_sel),
3657  .sel3   (intrpt_pcx_rq_sel),
3658  .dout (imiss_strm_pkt_dest[4:0])
3659);
3660*/
3661
3662mux4ds  #(5) sel_final_dest (
3663  .in0  (imiss_l2bnk_dest[4:0]),
3664  .in1  (ld_pkt_dest[4:0]),
3665  .in2  (st_pkt_dest[4:0]),
3666  .in3  (misc_pkt_dest[4:0]),
3667  .sel0 (all_pcx_rq_pick[0]), 
3668  .sel1 (all_pcx_rq_pick[1]),
3669  .sel2 (all_pcx_rq_pick[2]), 
3670  .sel3 (all_pcx_rq_dest_sel3), 
3671  //.sel3 (all_pcx_rq_pick[3]),
3672  .dout (current_pkt_dest[4:0])
3673);
3674
3675/*mux3ds  #(5) sel_dest (
3676  .in0  (ld_pkt_dest[4:0]),
3677  .in1  (st_pkt_dest[4:0]),
3678  .in2    (imiss_strm_pkt_dest[4:0]),
3679  .sel0 (dest_pkt_sel[0]), 
3680  .sel1   (dest_pkt_sel[1]),
3681  .sel2   (dest_pkt_sel[2]),
3682  .dout (current_pkt_dest[4:0])
3683);*/
3684
3685wire    pcx_rq_sel ;
3686assign  pcx_rq_sel = 
3687  ld0_pcx_rq_sel | ld1_pcx_rq_sel | ld2_pcx_rq_sel | ld3_pcx_rq_sel |
3688  st0_pcx_rq_sel | st1_pcx_rq_sel | st2_pcx_rq_sel | st3_pcx_rq_sel |
3689  imiss_pcx_rq_sel | strm_pcx_rq_sel | fpop_pcx_rq_sel | intrpt_pcx_rq_sel |
3690  fwdpkt_pcx_rq_sel ;
3691
3692assign spc_pcx_req_g[4:0] = 
3693  (current_pkt_dest[4:0] & {5{pcx_rq_sel}}) ;
3694  //(current_pkt_dest[4:0] &
3695  //{5{(ld_pcx_rq_vld | st_pcx_rq_vld | imiss_pcx_rq_vld | strm_pcx_rq_vld | intrpt_pcx_rq_vld | fpop_atom_req | fwdpkt_rq_vld)}}) ;
3696
3697//timing fix: 9/19/03 - instantiate buffer for spc_pcx_req_pq
3698wire  [4:0]  spc_pcx_req_pq_tmp ;
3699dff_s #(5)  rq_stgpq (
3700        .din    (spc_pcx_req_g[4:0]), .(spc_pcx_req_pq_tmp[4:0]),
3701        .clk  (clk),
3702        .se     (1'b0),       .si (),          .so ()
3703        ); 
3704
3705
3706bw_u1_buf_30x UZfix_spc_pcx_req_pq0_buf1 ( .a(spc_pcx_req_pq_tmp[0]), .z(spc_pcx_req_pq[0]) );
3707bw_u1_buf_30x UZfix_spc_pcx_req_pq1_buf1 ( .a(spc_pcx_req_pq_tmp[1]), .z(spc_pcx_req_pq[1]) );
3708bw_u1_buf_30x UZfix_spc_pcx_req_pq2_buf1 ( .a(spc_pcx_req_pq_tmp[2]), .z(spc_pcx_req_pq[2]) );
3709bw_u1_buf_30x UZfix_spc_pcx_req_pq3_buf1 ( .a(spc_pcx_req_pq_tmp[3]), .z(spc_pcx_req_pq[3]) );
3710bw_u1_buf_30x UZfix_spc_pcx_req_pq4_buf1 ( .a(spc_pcx_req_pq_tmp[4]), .z(spc_pcx_req_pq[4]) );
3711
3712bw_u1_buf_30x UZsize_spc_pcx_req_pq0_buf2 ( .a(spc_pcx_req_pq_tmp[0]), .z(spc_pcx_req_pq_buf2[0]) );
3713bw_u1_buf_30x UZsize_spc_pcx_req_pq1_buf2 ( .a(spc_pcx_req_pq_tmp[1]), .z(spc_pcx_req_pq_buf2[1]) );
3714bw_u1_buf_30x UZsize_spc_pcx_req_pq2_buf2 ( .a(spc_pcx_req_pq_tmp[2]), .z(spc_pcx_req_pq_buf2[2]) );
3715bw_u1_buf_30x UZsize_spc_pcx_req_pq3_buf2 ( .a(spc_pcx_req_pq_tmp[3]), .z(spc_pcx_req_pq_buf2[3]) );
3716bw_u1_buf_30x UZsize_spc_pcx_req_pq4_buf2 ( .a(spc_pcx_req_pq_tmp[4]), .z(spc_pcx_req_pq_buf2[4]) );
3717
3718//bug3348 - not needed
3719//wire   spc_pcx_req_vld_pq ;
3720//assign spc_pcx_req_vld_pq =  |spc_pcx_req_pq[4:0];
3721//
3722//dff #(1)  rq_stgpq1 (
3723//        .din    (spc_pcx_req_vld_pq), .q  (spc_pcx_req_vld_pq1),
3724//        .clk  (clk),
3725//        .se     (1'b0),       .si (),          .so ()
3726//        );
3727
3728assign spc_pcx_req_update_g[4:0] = 
3729        (st_atom_rq_d1 | fpop_atom_rq_pq) ?
3730        spc_pcx_req_pq_buf2[4:0] :           // Recirculate same request if back to back case - stda, cas etc
3731        (current_pkt_dest[4:0] & 
3732        {5{pcx_rq_sel}}) ;
3733        //{5{(ld_pcx_rq_vld | st_pcx_rq_vld | imiss_pcx_rq_vld | strm_pcx_rq_vld | intrpt_pcx_rq_vld | fpop_pcx_rq_vld | fwdpkt_rq_vld)}}) ;
3734                                        // Standard request
3735
3736dff_s #(5)  urq_stgpq (
3737        .din    (spc_pcx_req_update_g[4:0]), .(spc_pcx_req_update_w2[4:0]),
3738        .clk  (clk),
3739        .se     (1'b0),       .si (),          .so ()
3740        ); 
3741
3742//=================================================================================================
3743//      2-CYCLE OP HANDLING
3744//=================================================================================================
3745
3746// cas,fpop,dtag-error pkt. dtag-error pkt does not have to be b2b.
3747// prevent starvation, ensure requests are b2b.
3748// fpop can only request to fpu.(bit4) cas can only request to L2 (b3:0)
3749// ** error rst needs to be handled correctly.
3750
3751// ** This needs to be massaged for timing.
3752// timing fix: 5/7/03 - delay the mask 1 cycle for stores.
3753wire    [3:0]   mcycle_mask_qwr ;
3754wire    [4:0]   mcycle_mask_qwr_d1 ;
3755//assign        mcycle_mask_qwr[3:0] =
3756//      ({4{(stb0_rd_for_pcx & st0_atomic_vld)}} & st0_l2bnk_dest[3:0]) |
3757//      ({4{(stb1_rd_for_pcx & st1_atomic_vld)}} & st1_l2bnk_dest[3:0]) |
3758//      ({4{(stb2_rd_for_pcx & st2_atomic_vld)}} & st2_l2bnk_dest[3:0]) |
3759//      ({4{(stb3_rd_for_pcx & st3_atomic_vld)}} & st3_l2bnk_dest[3:0]) ;
3760
3761
3762//bug4513- kill the atomic store pcx req in this cycle if only 1 entry is available -
3763//         atomic packets have to be sent b2bto pcx.
3764//
3765// ex. thread0 to l2 bank0 atomic store - w/ only 1 bank0 entry available
3766//---------------------------------------------------------------------------------
3767//                              1       2       3       4       5       6       7
3768//---------------------------------------------------------------------------------
3769// st0_atomic_vld-------------->1
3770// pcx_rq_for_stb_tmp[0]------->1
3771// pcx_rq_for_stb[0]----------->0                               1
3772// st0_qmon_2entry_avail------->0                               1
3773//---------------------------------------------------------------------------------
3774// st0_atomic_pend------------->1                               0
3775// st0_atomic_pend_d1------------------>1                               0
3776// mcycle_mask_qwr_d1[0]--------------->1                               0
3777//---------------------------------------------------------------------------------
3778
3779
3780assign  st0_qmon_2entry_avail =  |(st0_l2bnk_dest[3:0] & sel_qentry0[3:0]) ;
3781assign  st1_qmon_2entry_avail =  |(st1_l2bnk_dest[3:0] & sel_qentry0[3:0]) ;
3782assign  st2_qmon_2entry_avail =  |(st2_l2bnk_dest[3:0] & sel_qentry0[3:0]) ;
3783assign  st3_qmon_2entry_avail =  |(st3_l2bnk_dest[3:0] & sel_qentry0[3:0]) ;
3784assign  fpop_qmon_2entry_avail =  fpop_l2bnk_dest[4] & sel_qentry0[4] ;
3785
3786
3787//bug4513 - when atomic is picked, if 2 entries are not free, kill all requests until 2entries are free
3788wire    st0_atomic_pend, st1_atomic_pend, st2_atomic_pend, st3_atomic_pend ;
3789
3790assign  st0_atomic_pend  =  (pcx_rq_for_stb_tmp[0] & st0_atomic_vld & ~st0_qmon_2entry_avail) |  //set
3791                            (st0_atomic_pend_d1 & ~st0_qmon_2entry_avail) ;                  //recycle/reset
3792
3793assign  st1_atomic_pend  =  (pcx_rq_for_stb_tmp[1] & st1_atomic_vld & ~st1_qmon_2entry_avail) |  //set
3794                            (st1_atomic_pend_d1 & ~st1_qmon_2entry_avail) ;                  //recycle/reset
3795
3796assign  st2_atomic_pend  =  (pcx_rq_for_stb_tmp[2] & st2_atomic_vld & ~st2_qmon_2entry_avail) |  //set
3797                            (st2_atomic_pend_d1 & ~st2_qmon_2entry_avail) ;                  //recycle/reset
3798
3799assign  st3_atomic_pend  =  (pcx_rq_for_stb_tmp[3] & st3_atomic_vld & ~st3_qmon_2entry_avail) |  //set
3800                            (st3_atomic_pend_d1 & ~st3_qmon_2entry_avail) ;                  //recycle/reset
3801
3802dff_s #(4)  ff_st0to3_atomic_pend_d1 (
3803        .din ({st3_atomic_pend,st2_atomic_pend,st1_atomic_pend,st0_atomic_pend}),
3804        .q   ({st3_atomic_pend_d1,st2_atomic_pend_d1,st1_atomic_pend_d1,st0_atomic_pend_d1}),
3805        .clk  (clk),
3806        .se     (1'b0),       .si (),          .so ()
3807        ); 
3808
3809//bug4513 - kill all requests after atomic if 2 entries to the bank are not available
3810assign  mcycle_mask_qwr[3:0] =
3811        ({4{st0_atomic_pend}} & st0_l2bnk_dest[3:0]) |
3812        ({4{st1_atomic_pend}} & st1_l2bnk_dest[3:0]) |
3813        ({4{st2_atomic_pend}} & st2_l2bnk_dest[3:0]) |
3814        ({4{st3_atomic_pend}} & st3_l2bnk_dest[3:0]) ;
3815
3816//11/15/03 - change fpop atomic to be same as store atomic (bug4513)
3817//assign        mcycle_mask_qwr[4] = fpop_pkt_vld | fpop_pcx_rq_sel_d1 ;
3818
3819wire    fpop_atomic_pend, fpop_atomic_pend_d1 ;
3820
3821
3822assign fpop_atomic_pend = (fpop_pcx_rq_sel_tmp & ~fpop_qmon_2entry_avail) |
3823                          (fpop_atomic_pend_d1 & ~fpop_qmon_2entry_avail) ;
3824
3825assign  fpop_q_wr[4:0] = fpop_atomic_pend_d1 ? pre_qwr[4:0] : queue_write[4:0] ;
3826
3827dff_s #(1)  ff_fpop_atomic_pend_d1 (
3828        .din (fpop_atomic_pend),
3829        .q   (fpop_atomic_pend_d1),
3830        .clk  (clk),
3831        .se     (1'b0),       .si (),          .so ()
3832        ); 
3833
3834
3835dff_s #(5)  ff_mcycle_mask_qwr_b4to0 (
3836        .din ({fpop_atomic_pend,mcycle_mask_qwr[3:0]}), 
3837        .q   (mcycle_mask_qwr_d1[4:0]),
3838        .clk  (clk),
3839        .se     (1'b0),       .si (),          .so ()
3840        ); 
3841
3842
3843//                      PCX REQUEST GENERATION (END)
3844//*************************************************************************************************
3845
3846//=================================================================================================
3847//
3848// CPX Packet Processing
3849//
3850//=================================================================================================
3851
3852
3853// D-SIDE PROCESSING
3854
3855/*input  [3:0]   lsu_cpx_pkt_rqtype ;
3856input          lsu_cpx_pkt_vld ;*/
3857
3858// non-cacheables are processed at the head of the dfq.
3859// cpx_ld_type may not have to factor in strm load.
3860
3861//=================================================================================================
3862//
3863// PCX Queue Control
3864//
3865//=================================================================================================
3866
3867//timing fix: 5/7/03 - delay mask 1 cycle for stores
3868//11/15/03 - change fpop atomic to be same as store atomic (bug4513)
3869//assign        queue_write[4:0] = pre_qwr[4:0] & ~{mcycle_mask_qwr[4],mcycle_mask_qwr_d1[3:0]} ;
3870assign  queue_write[4:0] = pre_qwr[4:0] & ~mcycle_mask_qwr_d1[4:0] ;
3871
3872//bug4513 - mcycle_mask_qwr will kill all requests other than stores. stores can be killed
3873//          by fpop atomics
3874//11/14/03- fox for bug4513 was incorrect ; st_queue_write[3:0] not needed 'cos st[0-3]_q_wr
3875//          has been changed to use st0_atomic_pend instead of st0_atomic_vld
3876//assign        st_queue_write[4] = pre_qwr[4] & ~mcycle_mask_qwr[4] ;
3877//assign        st_queue_write[3:0] = pre_qwr[3:0] ;
3878
3879//assign        queue_write[4:0] = pre_qwr[4:0] & ~mcycle_mask_qwr[4:0] ; // timing fix
3880// assign       queue_write[4:0] = pre_qwr[4:0] ;
3881
3882// PCX Queue Control
3883// - qctl tracks 2-input queue state for each of 6 destinations
3884// through grant signals available from pcx.
3885
3886// L2 Bank0 Queue Monitor
3887lsu_pcx_qmon  l2bank0_qmon (
3888    .rclk         (rclk),
3889    .grst_l       (grst_l),
3890    .arst_l       (arst_l),
3891    .si(),
3892    .se(se),
3893    .so(),
3894  .send_by_pcx  (pcx_spc_grant_px[0]),
3895  .send_to_pcx  (spc_pcx_req_update_w2[0]),
3896  //.qwrite   (queue_write[0]),
3897  .qwrite   (pre_qwr[0]),
3898  .sel_qentry0  (sel_qentry0[0])
3899);
3900
3901// L2 Bank1 Queue Monitor
3902lsu_pcx_qmon  l2bank1_qmon (
3903    .rclk         (rclk),
3904    .grst_l       (grst_l),
3905    .arst_l       (arst_l),
3906    .si(),
3907    .se(se),
3908    .so(),
3909  .send_by_pcx  (pcx_spc_grant_px[1]),
3910  .send_to_pcx  (spc_pcx_req_update_w2[1]),
3911  //.qwrite   (queue_write[1]),
3912  .qwrite   (pre_qwr[1]),
3913  .sel_qentry0  (sel_qentry0[1])
3914);
3915
3916// L2 Bank2 Queue Monitor
3917lsu_pcx_qmon  l2bank2_qmon (
3918    .rclk         (rclk),
3919    .grst_l       (grst_l),
3920    .arst_l       (arst_l),
3921    .si(),
3922    .se(se),
3923    .so(),
3924  .send_by_pcx  (pcx_spc_grant_px[2]),
3925  .send_to_pcx  (spc_pcx_req_update_w2[2]),
3926  //.qwrite   (queue_write[2]),
3927  .qwrite   (pre_qwr[2]),
3928  .sel_qentry0  (sel_qentry0[2])
3929);
3930
3931// L2 Bank3 Queue Monitor
3932lsu_pcx_qmon  l2bank3_qmon (
3933    .rclk         (rclk),
3934    .grst_l       (grst_l),
3935    .arst_l       (arst_l),
3936    .si(),
3937    .se(se),
3938    .so(),
3939  .send_by_pcx  (pcx_spc_grant_px[3]),
3940  .send_to_pcx  (spc_pcx_req_update_w2[3]),
3941  //.qwrite   (queue_write[3]),
3942  .qwrite   (pre_qwr[3]),
3943  .sel_qentry0  (sel_qentry0[3])
3944);
3945
3946// FP/IO Bridge Queue Monitor
3947lsu_pcx_qmon  fpiobridge_qmon (
3948    .rclk         (rclk),
3949    .grst_l       (grst_l),
3950    .arst_l       (arst_l),
3951    .si(),
3952    .se(se),
3953    .so(),
3954  .send_by_pcx  (pcx_spc_grant_px[4]),
3955  .send_to_pcx  (spc_pcx_req_update_w2[4]),
3956  //.qwrite   (queue_write[4]),
3957  .qwrite   (pre_qwr[4]),
3958  .sel_qentry0  (sel_qentry0[4])
3959);
3960
3961
3962
3963
3964// 5/13/03: timing fix for lsu_dtag_perror_w2 thru st_pick
3965wire  [3:0]  error_en;
3966wire  [3:0]  error_rst_thrd;
3967
3968//assign  error_en[0] = lmq_enable[0] | (lsu_cpx_pkt_atm_st_cmplt & dcfill_active_e & dfq_byp_sel[0]);
3969assign  error_en[0] = lsu_ld_inst_vld_g[0];
3970assign  error_en[1] = lsu_ld_inst_vld_g[1];
3971assign  error_en[2] = lsu_ld_inst_vld_g[2];
3972assign  error_en[3] = lsu_ld_inst_vld_g[3];
3973
3974//assign  error_rst_thrd[0] = reset | (lsu_ld0_pcx_rq_sel_d1 & lsu_pcx_ld_dtag_perror_w2) ;
3975//assign  error_rst_thrd[1] = reset | (lsu_ld1_pcx_rq_sel_d1 & lsu_pcx_ld_dtag_perror_w2) ;
3976//assign  error_rst_thrd[2] = reset | (lsu_ld2_pcx_rq_sel_d1 & lsu_pcx_ld_dtag_perror_w2) ;
3977//assign  error_rst_thrd[3] = reset | (lsu_ld3_pcx_rq_sel_d1 & lsu_pcx_ld_dtag_perror_w2) ;
3978
3979// reset moved to d2 'cos if 1st pkt is speculative and grant=0, error should not be reset.
3980//bug4512 - stb_full_raw has to be qual w/ ld[0-3] inst_vld_w2
3981//          also, need to qualify stb_full_raw w/ fp loads i.e. dont reset error if full raw is for fp double loads
3982assign  error_rst_thrd[0] = reset | (ld0_pcx_rq_sel_d2 & ~pcx_req_squash_d1) 
3983                                | (ld0_inst_vld_w2 & ld_stb_full_raw_w2 & ~dbl_force_l2access_w2 & thread0_w2) ; // Bug4512
3984                                //| (ld_stb_full_raw_w2 & thread0_w2) ; // Bug 4361
3985
3986assign  error_rst_thrd[1] = reset | (ld1_pcx_rq_sel_d2 & ~pcx_req_squash_d1)
3987                                | (ld1_inst_vld_w2 & ld_stb_full_raw_w2 & ~dbl_force_l2access_w2 & thread1_w2) ;
3988
3989assign  error_rst_thrd[2] = reset | (ld2_pcx_rq_sel_d2 & ~pcx_req_squash_d1)
3990                                | (ld2_inst_vld_w2 & ld_stb_full_raw_w2 & ~dbl_force_l2access_w2 & thread2_w2) ;
3991
3992assign  error_rst_thrd[3] = reset | (ld3_pcx_rq_sel_d2 & ~pcx_req_squash_d1)
3993                                | (ld3_inst_vld_w2 & ld_stb_full_raw_w2 & ~dbl_force_l2access_w2 & thread3_w2) ;
3994
3995//assign  lsu_error_rst[3:0]  =  error_rst[3:0];
3996
3997wire    dtag_perror3,dtag_perror2,dtag_perror1,dtag_perror0;
3998
3999// Thread 0
4000dffre_s  #(1) error_t0 (
4001        .din    (lsu_dcache_tag_perror_g),
4002        .q      (dtag_perror0),
4003        .rst  (error_rst_thrd[0]), .en     (error_en[0]),               
4004        .clk    (clk),
4005        .se     (1'b0),       .si (),          .so ()
4006        );           
4007
4008// Thread 1
4009dffre_s  #(1) error_t1 (
4010        .din    (lsu_dcache_tag_perror_g),
4011        .q      (dtag_perror1),
4012        .rst  (error_rst_thrd[1]), .en     (error_en[1]),               
4013        .clk    (clk),
4014        .se     (1'b0),       .si (),          .so ()
4015        );           
4016
4017// Thread 2
4018dffre_s  #(1) error_t2 (
4019        .din    (lsu_dcache_tag_perror_g),
4020        .q      (dtag_perror2),
4021        .rst  (error_rst_thrd[2]), .en     (error_en[2]),               
4022        .clk    (clk),
4023        .se     (1'b0),       .si (),          .so ()
4024        );           
4025
4026// Thread 3
4027dffre_s  #(1) error_t3 (
4028        .din    (lsu_dcache_tag_perror_g),
4029        .q      (dtag_perror3),
4030        .rst  (error_rst_thrd[3]), .en     (error_en[3]),               
4031        .clk    (clk),
4032        .se     (1'b0),       .si (),          .so ()
4033        );           
4034
4035assign  lsu_dtag_perror_w2[3] = dtag_perror3 ;
4036assign  lsu_dtag_perror_w2[2] = dtag_perror2 ;
4037assign  lsu_dtag_perror_w2[1] = dtag_perror1 ;
4038assign  lsu_dtag_perror_w2[0] = dtag_perror0 ;
4039
4040// Determine if ld pkt requires correction due to dtag parity error.
4041assign  lsu_pcx_ld_dtag_perror_w2 =
4042  ld_pcx_rq_sel[0] ? dtag_perror0 :
4043    ld_pcx_rq_sel[1] ? dtag_perror1 :
4044      ld_pcx_rq_sel[2] ? dtag_perror2 : dtag_perror3 ;
4045
4046
4047//=================================================================================================
4048//
4049// THREAD RETRY DETECTION (picker related logic)
4050//
4051//=================================================================================================
4052
4053//bug4814 - move pick_staus out of picker and reset pick status when all 12 valid requests have
4054//          is picked and not squashed.
4055
4056assign  ld_thrd_pick_din[0]  =  ld_thrd_pick_status[0] | (ld0_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4057assign  ld_thrd_pick_din[1]  =  ld_thrd_pick_status[1] | (ld1_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4058assign  ld_thrd_pick_din[2]  =  ld_thrd_pick_status[2] | (ld2_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4059assign  ld_thrd_pick_din[3]  =  ld_thrd_pick_status[3] | (ld3_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4060
4061assign  ld_thrd_pick_rst  =  ~|(ld_events_raw[3:0] & ~ld_thrd_pick_din[3:0]) ;
4062   
4063assign  ld_thrd_pick_status_din[3:0] =  ld_thrd_pick_din[3:0] & ~{4{all_thrd_pick_rst}} ;
4064//assign  ld_thrd_pick_status_din[3:0]  =  ld_thrd_pick_din[3:0] & ~{4{ld_thrd_pick_rst}} ;
4065
4066assign  st_thrd_pick_din[0] = st_thrd_pick_status[0] | (st0_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4067assign  st_thrd_pick_din[1] = st_thrd_pick_status[1] | (st1_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4068assign  st_thrd_pick_din[2] = st_thrd_pick_status[2] | (st2_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4069assign  st_thrd_pick_din[3] = st_thrd_pick_status[3] | (st3_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4070
4071assign  st_thrd_pick_rst  =  ~|(st_events_raw[3:0] & ~st_thrd_pick_din[3:0]) ;
4072assign  st_thrd_pick_status_din[3:0]  =  st_thrd_pick_din[3:0] & ~{4{all_thrd_pick_rst}} ;
4073//assign  st_thrd_pick_status_din[3:0]  =  st_thrd_pick_din[3:0] & ~{4{st_thrd_pick_rst}} ;
4074
4075assign  misc_thrd_pick_din[3] = misc_thrd_pick_status[3] | lsu_spu_ldst_ack ;
4076assign  misc_thrd_pick_din[2] = misc_thrd_pick_status[2] | (fpop_pcx_rq_sel_d2 & ~pcx_req_squash_d1) ;
4077assign  misc_thrd_pick_din[1] = misc_thrd_pick_status[1] | lsu_tlu_pcxpkt_ack ;
4078assign  misc_thrd_pick_din[0] = misc_thrd_pick_status[0] | lsu_fwdpkt_pcx_rq_sel ;
4079
4080assign  misc_thrd_pick_rst  =  ~|(misc_events_raw[3:0] & ~misc_thrd_pick_din[3:0]) ;
4081   
4082assign  misc_thrd_pick_status_din[3:0]  =  misc_thrd_pick_din[3:0] & ~{4{all_thrd_pick_rst}} ;
4083//assign  misc_thrd_pick_status_din[3:0]  =  misc_thrd_pick_din[3:0] & ~{4{misc_thrd_pick_rst}} ;
4084
4085assign  all_thrd_pick_rst  =  ld_thrd_pick_rst & st_thrd_pick_rst & misc_thrd_pick_rst ;
4086
4087
4088dff_s    #(4) ff_ld_thrd_force(
4089        .din    (ld_thrd_pick_status_din[3:0]),
4090        .q      (ld_thrd_pick_status[3:0]),
4091        .clk    (clk),
4092        .se     (1'b0),       .si (),          .so ()
4093        );
4094
4095dff_s    #(4) ff_st_thrd_force(
4096        .din    (st_thrd_pick_status_din[3:0]),
4097        .q      (st_thrd_pick_status[3:0]),
4098        .clk    (clk),
4099        .se     (1'b0),       .si (),          .so ()
4100        );
4101
4102dff_s    #(4) ff_misc_thrd_force(
4103        .din    (misc_thrd_pick_status_din[3:0]),
4104        .q      (misc_thrd_pick_status[3:0]),
4105        .clk    (clk),
4106        .se     (1'b0),       .si (),          .so ()
4107        );
4108
4109assign  ld_thrd_force_d1[3:0]  =  ~ld_thrd_pick_status[3:0] ;
4110assign  st_thrd_force_d1[3:0]  =  ~st_thrd_pick_status[3:0] ;
4111assign  misc_thrd_force_d1[3:0]  =  ~misc_thrd_pick_status[3:0] ;
4112
4113assign ld_thrd_force_vld[0]  =  ld_thrd_force_d1[0] & 
4114                               ~(ld0_pcx_rq_sel_d1 | ld0_pcx_rq_sel_d2) ;
4115
4116assign ld_thrd_force_vld[1]  =  ld_thrd_force_d1[1] &
4117                               ~(ld1_pcx_rq_sel_d1 | ld1_pcx_rq_sel_d2) ;
4118
4119assign ld_thrd_force_vld[2]  =  ld_thrd_force_d1[2] &
4120                               ~(ld2_pcx_rq_sel_d1 | ld2_pcx_rq_sel_d2) ;
4121
4122assign ld_thrd_force_vld[3]  =  ld_thrd_force_d1[3] &
4123                               ~(ld3_pcx_rq_sel_d1 | ld3_pcx_rq_sel_d2) ;
4124
4125
4126// force valid to store picker if 1 entry is free and if it not picked in d1/d2
4127assign st_thrd_force_vld[0]  =  st_thrd_force_d1[0] &
4128                               ~(st0_pcx_rq_sel_d1 | st0_pcx_rq_sel_d2) ;
4129
4130assign st_thrd_force_vld[1]  =  st_thrd_force_d1[1] &
4131                               ~(st1_pcx_rq_sel_d1 | st1_pcx_rq_sel_d2) ;
4132
4133assign st_thrd_force_vld[2]  =  st_thrd_force_d1[2] &
4134                               ~(st2_pcx_rq_sel_d1 | st2_pcx_rq_sel_d2) ;
4135
4136assign st_thrd_force_vld[3]  =  st_thrd_force_d1[3] &
4137                               ~(st3_pcx_rq_sel_d1 | st3_pcx_rq_sel_d2) ;
4138
4139
4140
4141// force valid to misc picker if 1 entry is free and if it is not picked in d1/d2
4142assign misc_thrd_force_vld[0]  =  misc_thrd_force_d1[0] &
4143                                 ~(fwdpkt_pcx_rq_sel_d1 | fwdpkt_pcx_rq_sel_d2) ;
4144
4145assign misc_thrd_force_vld[1]  =  misc_thrd_force_d1[1] &
4146                                 ~(intrpt_pcx_rq_sel_d1 | intrpt_pcx_rq_sel_d2);
4147
4148assign misc_thrd_force_vld[2]  =  misc_thrd_force_d1[2] &
4149                                 ~(fpop_pcx_rq_sel_d1 | fpop_pcx_rq_sel_d2) ;
4150
4151assign misc_thrd_force_vld[3]  =  misc_thrd_force_d1[3] &
4152                                 ~(strm_pcx_rq_sel_d1 | strm_pcx_rq_sel_d2) ;
4153
4154//2nd level pick thread force - force only req are valid and l2bnk is free
4155assign all_thrd_force_vld[0]  =  1'b0 ;
4156
4157assign all_thrd_force_vld[1]  = 
4158                    |(ld_thrd_force_vld[3:0] & 
4159                     {ld3_pcx_rq_vld,ld2_pcx_rq_vld,ld1_pcx_rq_vld,ld0_pcx_rq_vld}) ;
4160
4161assign all_thrd_force_vld[2]  = 
4162                    |(st_thrd_force_vld[3:0] &
4163                     {st3_pcx_rq_vld,st2_pcx_rq_vld,st1_pcx_rq_vld,st0_pcx_rq_vld}) ;
4164
4165assign all_thrd_force_vld[3]  = 
4166                    |(misc_thrd_force_vld[3:0] &
4167                     {strm_pcx_rq_vld,fpop_pcx_rq_vld,intrpt_pcx_rq_vld,fwdpkt_rq_vld}) ;
4168
4169
4170endmodule
Note: See TracBrowser for help on using the repository browser.