OpenCores
URL https://opencores.org/ocsvn/s1_core/s1_core/trunk

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [lsu_dctl.v] - Blame information for rev 113

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: lsu_dctl.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 113 albert.wat
`ifdef SIMPLY_RISC_TWEAKS
22
`define SIMPLY_RISC_SCANIN .si(0)
23
`define SIMPLY_RISC_SCANOUT .so(0)
24
`else
25
`define SIMPLY_RISC_SCANIN .si()
26
`define SIMPLY_RISC_SCANOUT .so()
27
`endif
28 95 fafa1971
/////////////////////////////////////////////////////////////////
29
/*
30
//  Description:  LSU Data Cache Control and Minor Datapath
31
//      - Tag Comparison - hit/miss.
32
*/
33
////////////////////////////////////////////////////////////////////////
34
// Global header file includes
35
////////////////////////////////////////////////////////////////////////
36 113 albert.wat
`include  "sys.h" // system level definition file which contains the 
37 95 fafa1971
          // time scale definition
38
 
39
////////////////////////////////////////////////////////////////////////
40
// Local header file includes / local defines
41
////////////////////////////////////////////////////////////////////////
42 113 albert.wat
`include  "lsu.h"
43 95 fafa1971
 
44
module lsu_dctl ( /*AUTOARG*/
45
   // Outputs
46
   lsu_tlu_nucleus_ctxt_m, lsu_quad_word_access_g, so, dctl_rst_l,
47
   lsu_tlu_wsr_inst_e, lsu_l2fill_fpld_e, dva_vld_m_bf,
48
   lsu_no_spc_pref, ifu_tlu_flush_fd_w, ifu_tlu_flush_fd2_w,
49
   ifu_tlu_flush_fd3_w, ifu_lsu_flush_w, lsu_tlu_thrid_d,
50
   lsu_diagnstc_data_sel, lsu_diagnstc_va_sel, lsu_err_addr_sel,
51
   dva_bit_wr_en_e, dva_wr_adr_e, lsu_exu_ldst_miss_w2,
52
   lsu_exu_dfill_vld_w2, lsu_ffu_ld_vld, lsu_ld_miss_wb,
53
   lsu_dtlb_bypass_e, ld_pcx_pkt_g, tlb_ldst_cam_vld, ldxa_internal,
54
   lsu_ifu_ldsta_internal_e, lsu_ifu_ldst_cmplt, lsu_ifu_itlb_en,
55
   lsu_ifu_icache_en, lmq_byp_data_en_w2, lmq_byp_data_fmx_sel,
56
   lmq_byp_data_mxsel0, lmq_byp_data_mxsel1, lmq_byp_data_mxsel2,
57
   lmq_byp_data_mxsel3, lmq_byp_ldxa_mxsel0, lmq_byp_ldxa_mxsel1,
58
   lmq_byp_ldxa_mxsel2, lmq_byp_ldxa_mxsel3, lsu_ld_thrd_byp_sel_e,
59
   dcache_byte_wr_en_e, lsu_dcache_wr_vld_e, lsu_ldstub_g,
60
   lsu_swap_g, lsu_tlu_dtlb_done, lsu_exu_thr_m, merge7_sel_byte0_m,
61
   merge7_sel_byte7_m, merge6_sel_byte1_m, merge6_sel_byte6_m,
62
   merge5_sel_byte2_m, merge5_sel_byte5_m, merge4_sel_byte3_m,
63
   merge4_sel_byte4_m, merge3_sel_byte0_m, merge3_sel_byte3_m,
64
   merge3_sel_byte4_m, merge3_sel_byte7_default_m, merge3_sel_byte_m,
65
   merge2_sel_byte1_m, merge2_sel_byte2_m, merge2_sel_byte5_m,
66
   merge2_sel_byte6_default_m, merge2_sel_byte_m, merge0_sel_byte0_m,
67
   merge0_sel_byte1_m, merge0_sel_byte2_m,
68
   merge0_sel_byte3_default_m, merge0_sel_byte4_m,
69
   merge0_sel_byte5_m, merge0_sel_byte6_m,
70
   merge0_sel_byte7_default_m, merge1_sel_byte0_m,
71
   merge1_sel_byte1_m, merge1_sel_byte2_m,
72
   merge1_sel_byte3_default_m, merge1_sel_byte4_m,
73
   merge1_sel_byte5_m, merge1_sel_byte6_m,
74
   merge1_sel_byte7_default_m, merge0_sel_byte_1h_m,
75
   merge1_sel_byte_1h_m, merge1_sel_byte_2h_m, lsu_dtlb_cam_real_e,
76
   lsu_dtagv_wr_vld_e, lsu_dtag_wrreq_x_e, lsu_dtag_index_sel_x_e,
77
   lsu_dtlb_wr_vld_e, lsu_dtlb_tag_rd_e, lsu_dtlb_data_rd_e,
78
   lsu_dtlb_dmp_vld_e, lsu_dtlb_dmp_all_e, lsu_dtlb_rwindex_vld_e,
79
   lsu_dtlb_invalid_all_l_m, lsu_tlu_tlb_ld_inst_m,
80
   lsu_tlu_tlb_st_inst_m, lsu_tlu_tlb_access_tid_m,
81
   lsu_tlb_data_rd_vld_g, lsu_tlb_st_sel_m, lsu_va_wtchpt0_wr_en_l,
82
   lsu_va_wtchpt1_wr_en_l, lsu_va_wtchpt2_wr_en_l,
83
   lsu_va_wtchpt3_wr_en_l, thread0_m, thread1_m, thread2_m,
84
   thread3_m, lsu_dctldp_thread0_m, lsu_dctldp_thread1_m,
85
   lsu_dctldp_thread2_m, lsu_dctldp_thread3_m, thread0_g, thread1_g,
86
   thread2_g, thread3_g, lsu_tlu_nonalt_ldst_m,
87
   lsu_tlu_xslating_ldst_m, lsu_tlu_ctxt_sel_m, lsu_tlu_write_op_m,
88
   lsu_dtlb_addr_mask_l_e, dva_din_e,
89
   lsu_diagnstc_dtagv_prty_invrt_e, lsu_ifu_asi_load,
90
   lsu_ifu_asi_thrid, lsu_ifu_asi_vld, lsu_quad_asi_e,
91
   lsu_local_ldxa_sel_g, lsu_dtag_rsel_m, lsu_tlbop_force_swo,
92
   lsu_atomic_pkt2_bsel_g, lsu_dcache_tag_perror_g,
93
   lsu_dcache_data_perror_g, lsu_ifu_l2_unc_error,
94
   lsu_ifu_l2_corr_error, lsu_ifu_dcache_data_perror,
95
   lsu_ifu_dcache_tag_perror, lsu_ifu_error_tid, lsu_ifu_io_error,
96
   lsu_tlu_squash_va_oor_m, lsu_squash_va_oor_m, tlb_cam_hit_g,
97
   lsu_st_hw_le_g, lsu_st_w_or_dbl_le_g, lsu_st_x_le_g,
98
   lsu_swap_sel_default_g, lsu_swap_sel_default_byte_7_2_g,
99
   lsu_st_rmo_m, lsu_bst_in_pipe_m, lsu_snap_blk_st_m, lsu_blk_st_m,
100
   lsu_blkst_pgnum_m, lsu_ffu_blk_asi_e, lsu_blk_asi_m,
101
   lsu_nonalt_nucl_access_m, dcache_alt_mx_sel_e,
102
   dcache_alt_mx_sel_e_bf, dcache_rvld_e, lsu_dc_iob_access_e,
103
   lsu_ifu_ldst_miss_w, lsu_ifu_dc_parity_error_w2,
104
   lsu_ldst_inst_vld_e, lsu_local_ldxa_tlbrd_sel_g,
105
   lsu_local_diagnstc_tagrd_sel_g, lsu_va_wtchpt_sel_g,
106
   asi_state_wr_thrd, thread0_d, thread1_d, thread2_d, thread3_d,
107
   tlu_lsu_asi_update_g, pctxt_state_wr_thrd, sctxt_state_wr_thrd,
108
   thread_pctxt, thread_sctxt, thread_actxt, thread_default,
109
   thread0_ctxt, thread1_ctxt, thread2_ctxt, thread3_ctxt,
110
   pid_state_wr_en, thread0_e, thread1_e, thread2_e, thread3_e,
111
   dfture_tap_wr_mx_sel, lctl_rst, lsu_ctl_state_wr_en,
112
   lsuctl_ctlbits_wr_en, dfture_tap_rd_en, bist_tap_wr_en,
113
   bistctl_wr_en, bist_ctl_reg_wr_en, mrgn_tap_wr_en, ldiagctl_wr_en,
114
   misc_ctl_sel_din, lsu_asi_sel_fmx1, lsu_asi_sel_fmx2,
115
   tlb_access_en0_g, tlb_access_en1_g, tlb_access_en2_g,
116
   tlb_access_en3_g, tlb_access_sel_thrd0, tlb_access_sel_thrd1,
117
   tlb_access_sel_thrd2, tlb_access_sel_default, mrgnctl_wr_en,
118
   hpv_priv_m, hpstate_en_m, dcache_arry_data_sel_m, dtlb_bypass_m,
119
   lsu_alt_space_m, atomic_m, ldst_dbl_m, fp_ldst_m, lda_internal_m,
120
   sta_internal_m, cam_real_m, data_rd_vld_g, tag_rd_vld_g,
121
   ldst_sz_m, asi_internal_m, rd_only_ltlb_asi_e, wr_only_ltlb_asi_e,
122
   dfill_tlb_asi_e, ifill_tlb_asi_e, nofault_asi_m, as_if_user_asi_m,
123
   atomic_asi_m, phy_use_ec_asi_m, phy_byp_ec_asi_m, quad_asi_m,
124
   binit_quad_asi_m, blk_asi_m, recognized_asi_m, strm_asi_m,
125
   mmu_rd_only_asi_m, rd_only_asi_m, wr_only_asi_m, unimp_asi_m,
126
   va_wtchpt_cmp_en_m, lsu_tlu_async_ttype_vld_w2,
127
   lsu_tlu_async_ttype_w2, lsu_tlu_async_tid_w2, async_tlb_index,
128
   l2fill_vld_m, ld_thrd_byp_mxsel_m, morphed_addr_m,
129
   signed_ldst_byte_m, signed_ldst_hw_m, signed_ldst_w_m,
130
   lsu_tlb_asi_data_perr_g, lsu_tlb_asi_tag_perr_g, lsu_sscan_data,
131
   lsu_ld_inst_vld_g, lsu_dcache_rand, lsu_encd_way_hit,
132
   lsu_way_hit_or, lsu_memref_m, lsu_flsh_inst_m,
133
   lsu_ifu_asi_data_en_l, lsu_dcache_fill_addr_e,
134
   lsu_dcache_fill_addr_e_err, lsu_thread_g, lmq_ldd_vld,
135
   lsu_bist_rsel_way_e, lsu_dcache_fill_way_e, lmq_ld_addr_b3,
136
   lsu_outstanding_rmo_st_max, lsu_dcfill_data_mx_sel_e,
137
   // Inputs
138
   si, se, sehold, rst_tri_en, rclk, grst_l, arst_l,
139
   lsu_diag_va_prty_invrt, dva_svld_e, dva_snp_bit_wr_en_e,
140
   dva_snp_addr_e, lsu_tte_data_cp_g, lsu_l2fill_vld, ld_inst_vld_e,
141
   st_inst_vld_e, ifu_lsu_ldst_fp_e, ldst_sz_e,
142
   lsu_ldst_va_b12_b11_m, lsu_ldst_va_b7_b0_m, ifu_lsu_rd_e,
143
   tlb_cam_hit, ifu_tlu_sraddr_d, ifu_tlu_wsr_inst_d,
144
   ifu_lsu_alt_space_d, tlu_lsu_int_ldxa_vld_w2,
145
   tlu_lsu_int_ld_ill_va_w2, tlu_lsu_ldxa_tid_w2,
146
   ifu_lsu_ldxa_data_vld_w2, ifu_lsu_ldxa_illgl_va_w2,
147
   ifu_lsu_ldxa_tid_w2, ifu_lsu_asi_rd_unc, tlu_lsu_tl_zero,
148
   ifu_lsu_thrid_s, ifu_lsu_ldst_dbl_e, ld_stb_full_raw_w2,
149
   ld_sec_active, ifu_tlu_inst_vld_m, lsu_l2fill_bendian_m,
150
   lmq0_l2fill_fpld, lmq1_l2fill_fpld, lmq2_l2fill_fpld,
151
   lmq3_l2fill_fpld, cache_way_hit_buf1, cache_hit, lmq0_byp_misc_sz,
152
   lmq1_byp_misc_sz, lmq2_byp_misc_sz, lmq3_byp_misc_sz,
153
   lsu_l2fill_sign_extend_m, lsu_l1hit_sign_extend_e,
154
   tlu_lsu_pstate_cle, tlu_lsu_pstate_am, tlb_pgnum, tlb_demap_nctxt,
155
   tlb_demap_pctxt, tlb_demap_sctxt, tlb_demap_actxt,
156
   tlb_demap_thrid, ifu_lsu_casa_e, ifu_lsu_ldstub_e, ifu_lsu_swap_e,
157
   lsu_atm_st_cmplt_e, lsu_cpx_pkt_atm_st_cmplt,
158
   spu_lsu_ldxa_data_vld_w2, spu_lsu_ldxa_illgl_va_w2,
159
   spu_lsu_ldxa_tid_w2, spu_lsu_stxa_ack_tid, spu_lsu_stxa_ack,
160
   spu_lsu_unc_error_w2, spu_lsu_int_w2, tlu_lsu_stxa_ack,
161
   tlu_lsu_stxa_ack_tid, lsu_tlb_invert_endian_g, lmq0_ncache_ld,
162
   lmq1_ncache_ld, lmq2_ncache_ld, lmq3_ncache_ld, ifu_tlu_mb_inst_e,
163
   ifu_tlu_flsh_inst_e, lsu_stb_empty, tlu_dtlb_tag_rd_g,
164
   tlu_dtlb_data_rd_g, tlu_dtlb_dmp_vld_g, tlu_dtlb_dmp_all_g,
165
   tlu_dtlb_rw_index_vld_g, tlu_dtlb_invalidate_all_g,
166
   lsu_st_wr_dcache, tlu_lsu_asi_update_m, tlu_lsu_tid_m,
167
   lsu_rd_dtag_parity_g, dcache_rparity_err_wb,
168
   lsu_diagnstc_wr_data_b0, lsu_byp_ldd_oddrd_m, tlu_lsu_redmode,
169
   tlu_lsu_redmode_rst_d1, dva_vld_m, lsu_dfill_tid_e,
170
   ifu_lsu_asi_ack, lsu_intrpt_cmplt, lsu_iobrdge_tap_rq_type_b8,
171
   lsu_iobrdge_tap_rq_type_b6_b3, lsu_iobrdge_tap_rq_type_b1_b0,
172
   lsu_iobrdge_fwd_pkt_vld, lsu_cpx_ld_dtag_perror_e,
173
   lsu_cpx_ld_dcache_perror_e, lsu_cpx_pkt_ld_err, ifu_lsu_nceen,
174
   tlu_lsu_ldxa_async_data_vld, tlu_lsu_hpv_priv, tlu_lsu_hpstate_en,
175
   ifu_lsu_memref_d, ifu_lsu_pref_inst_e, lsu_pref_pcx_req,
176
   lsu_cpx_pkt_prefetch2, lsu_ld_pcx_rq_sel_d2,
177
   lsu_pcx_req_squash_d1, lsu_bld_helper_cmplt_m, lsu_bld_cnt_m,
178
   lsu_bld_reset, ffu_lsu_blk_st_e, lsu_stb_rmo_st_issue,
179
   lsu_cpx_rmo_st_ack, lsu_dfq_flsh_cmplt, stb_cam_hit,
180
   ifu_tlu_flush_m, ctu_sscan_tid, tte_data_perror_unc,
181
   asi_tte_data_perror, asi_tte_tag_perror, tlu_dtlb_rw_index_g,
182
   lsu_local_early_flush_g, lsu_dfq_vld, gdbginit_l, dc_direct_map,
183
   asi_d, lsu_dctl_asi_state_m, lsu_ldst_va_g, lsu_ifu_err_addr_b39,
184
   lsu_dp_ctl_reg0, lsu_dp_ctl_reg1, lsu_dp_ctl_reg2,
185
   lsu_dp_ctl_reg3, ldd_in_dfq_out, dcache_iob_addr_e,
186
   mbist_dcache_index, mbist_dcache_word, lsu_diagnstc_wr_addr_e,
187
   st_dcfill_addr, lsu_dfq_ld_vld, lsu_dfq_st_vld, lmq0_ldd_vld,
188
   lmq1_ldd_vld, lmq2_ldd_vld, lmq3_ldd_vld, lsu_dfq_byp_tid,
189
   dfq_byp_ff_en, lsu_dcache_iob_way_e, mbist_dcache_way,
190
   lsu_diagnstc_wr_way_e, lsu_st_way_e, lmq0_pcx_pkt_way,
191
   lmq1_pcx_pkt_way, lmq2_pcx_pkt_way, lmq3_pcx_pkt_way,
192
   lmq0_ld_rq_type, lmq1_ld_rq_type, lmq2_ld_rq_type,
193
   lmq3_ld_rq_type, lmq0_pcx_pkt_addr, lmq1_pcx_pkt_addr,
194
   lmq2_pcx_pkt_addr, lmq3_pcx_pkt_addr, lsu_ttype_vld_m2,
195
   tlu_early_flush_pipe2_w, lsu_st_dcfill_size_e, mbist_dcache_write,
196
   mbist_dcache_read
197
   ) ;
198
 
199
 
200
output                  lsu_tlu_nucleus_ctxt_m ;// access is nucleus context 
201
output                  lsu_quad_word_access_g ; // 128b ld request.
202
 
203
input si;
204
input se;
205
input sehold ;
206
input rst_tri_en ;
207
output so;
208
 
209
input      rclk ;
210
input                   grst_l;
211
input                   arst_l;
212
output     dctl_rst_l;
213
 
214
input  lsu_diag_va_prty_invrt ;
215
 
216
   input         dva_svld_e ;
217
   input [15:0] dva_snp_bit_wr_en_e;
218
   input [4:0]  dva_snp_addr_e;
219
 
220
input         lsu_tte_data_cp_g ; // cp bit from tlb    
221
input         lsu_l2fill_vld ;    // fill from dfq to d$.
222
input         ld_inst_vld_e ;     // load accesses d$.
223
input         st_inst_vld_e ;     // load accesses d$.
224
input         ifu_lsu_ldst_fp_e ; // fp load or store
225
input [1:0]   ldst_sz_e ;         // sz of ld/st xsaction.
226
 
227
 
228
input [12:11]  lsu_ldst_va_b12_b11_m;
229
input [7:0]    lsu_ldst_va_b7_b0_m;
230
 
231
input [4:0]   ifu_lsu_rd_e;           // primary rd of ld
232
input         tlb_cam_hit ;           // xlation hits in tlb.     
233
// Read/Write Privileged State Register Access.
234
input [6:0]   ifu_tlu_sraddr_d ;      // addr of sr(st/pr)
235
 
236
input         ifu_tlu_wsr_inst_d ;    // valid wr sr(st/pr)
237
output        lsu_tlu_wsr_inst_e ;    // valid wr sr(st/pr)
238
 
239
input         ifu_lsu_alt_space_d;        // alternate space ld/st
240
 
241
input         tlu_lsu_int_ldxa_vld_w2 ;  // tlu ldxa data is valid (intrpt/scpd)
242
input         tlu_lsu_int_ld_ill_va_w2 ;  // tlu ldxa'va is invalid (intrpt/scpd)
243
 
244
input [1:0]   tlu_lsu_ldxa_tid_w2 ;       // thread id for tlu ldxa data. 
245
 
246
input         ifu_lsu_ldxa_data_vld_w2 ;  // ifu ldxa data is valid
247
input         ifu_lsu_ldxa_illgl_va_w2 ;  // ifu ldxa with illgl va
248
input [1:0]   ifu_lsu_ldxa_tid_w2   ;     // thread id for ifu ldxa data. 
249
input         ifu_lsu_asi_rd_unc ;        // unc error for tlb rd
250
 
251
input [3:0]   tlu_lsu_tl_zero ;           // trap level is zero.
252
input [1:0]   ifu_lsu_thrid_s ;           // thread id
253
input         ifu_lsu_ldst_dbl_e ;        // ldd, atomic quad.
254
 
255
input         ld_stb_full_raw_w2 ;     // full raw for load-thread0
256
input         ld_sec_active ;          // secondary bypassing
257
input         ifu_tlu_inst_vld_m ;     // inst vld in w stage
258
 
259
input         lsu_l2fill_bendian_m ;
260
 
261
//input         lsu_l2fill_fpld_e ;      // fp load
262
output         lsu_l2fill_fpld_e ;      // fp load
263
input         lmq0_l2fill_fpld ;      // fp load
264
input         lmq1_l2fill_fpld ;      // fp load
265
input         lmq2_l2fill_fpld ;      // fp load
266
input         lmq3_l2fill_fpld ;      // fp load
267
 
268
input [3:0]   cache_way_hit_buf1 ;          // hit in set of cache.
269
   input      cache_hit;
270
 
271
//input [3:0]   lsu_byp_misc_addr_m ;   // lower 3bits of addr for ldxa/raw etc
272
 
273
input [1:0]   lmq0_byp_misc_sz ;     // size for ldxa/raw etc
274
input [1:0]   lmq1_byp_misc_sz ;     // size for ldxa/raw etc
275
input [1:0]   lmq2_byp_misc_sz ;     // size for ldxa/raw etc
276
input [1:0]   lmq3_byp_misc_sz ;     // size for ldxa/raw etc
277
 
278
input         lsu_l2fill_sign_extend_m ; // l2fill requires sign-extension
279
input         lsu_l1hit_sign_extend_e ;  // l1hit requires sign-extension
280
input [3:0]   tlu_lsu_pstate_cle ;       // current little endian
281
input [3:0]   tlu_lsu_pstate_am ;        // address mask
282
input [39:10] tlb_pgnum ;
283
input         tlb_demap_nctxt;         // demap with nctxt
284
input         tlb_demap_pctxt;         // demap with pctxt
285
input         tlb_demap_sctxt;         // demap with sctxt
286
input         tlb_demap_actxt;         // demap w autodemap ctxt
287
input [1:0]   tlb_demap_thrid;         // demap thrid
288
 
289
input         ifu_lsu_casa_e ;         // compare-swap instr
290
input         ifu_lsu_ldstub_e ;       // ldstub
291
input         ifu_lsu_swap_e ;         // swap
292
 
293
 
294
input         lsu_atm_st_cmplt_e ;      // atm st ack will restart thread
295
input         lsu_cpx_pkt_atm_st_cmplt ; // applies to atomic ld also.
296
 
297
input         spu_lsu_ldxa_data_vld_w2 ; // ldxa data from spu is valid
298
input         spu_lsu_ldxa_illgl_va_w2 ; // ldxa data from spu with illgl va
299
input [1:0]   spu_lsu_ldxa_tid_w2 ;      // ldxa data from spu is valid
300
input [1:0]   spu_lsu_stxa_ack_tid ;     // stxa data from spu is valid
301
input         spu_lsu_stxa_ack ;         // write to sdata reg complete
302
input         spu_lsu_unc_error_w2 ;
303
input         spu_lsu_int_w2 ;           // spu disrupting trap.
304
 
305
input         tlu_lsu_stxa_ack ;         // for mmu reads/writes/demaps
306
input [1:0]   tlu_lsu_stxa_ack_tid ;      // for mmu reads/writes/demaps - tid
307
 
308
input         lsu_tlb_invert_endian_g ;
309
//input         lsu_ncache_ld_e ;       // non-cacheable ld from dfq
310
   input      lmq0_ncache_ld;
311
   input      lmq1_ncache_ld;
312
   input      lmq2_ncache_ld;
313
   input      lmq3_ncache_ld;
314
 
315
 
316
input         ifu_tlu_mb_inst_e ;     // membar instruction
317
input         ifu_tlu_flsh_inst_e ;   // flush  instruction
318
 
319
input [3:0]   lsu_stb_empty ;         // thread's stb is empty
320
 
321
//input         tlu_dtlb_wr_vld_g ;
322
input         tlu_dtlb_tag_rd_g ;
323
input         tlu_dtlb_data_rd_g ;
324
input         tlu_dtlb_dmp_vld_g ;
325
input         tlu_dtlb_dmp_all_g ;
326
input         tlu_dtlb_rw_index_vld_g ;
327
input         tlu_dtlb_invalidate_all_g ;
328
 
329
input         lsu_st_wr_dcache ;
330
 
331
input         tlu_lsu_asi_update_m ;  // update asi
332
input  [1:0]  tlu_lsu_tid_m ;         // thread for asi update
333
input [3:0]   lsu_rd_dtag_parity_g;     // calculated tag parity
334
 
335
input         dcache_rparity_err_wb;     // calculated tag parity
336
 
337
input         lsu_diagnstc_wr_data_b0 ;
338
input         lsu_byp_ldd_oddrd_m ;   // rd fill for non-alt ldd
339
 
340
input [3:0]   tlu_lsu_redmode ;       // redmode
341
input [3:0]   tlu_lsu_redmode_rst_d1 ;   // redmode
342
//input [2:0]   const_cpuid ;           // cpu's id
343
input [3:0]   dva_vld_m ;             // valid bits for cache.
344
output [3:0]  dva_vld_m_bf;
345
 
346
input [1:0]   lsu_dfill_tid_e ;       // thread id
347
input         ifu_lsu_asi_ack;        // asi ack from ifu
348
 
349
input [3:0]   lsu_intrpt_cmplt ;          // intrpt can restart thread
350
//input [8:0]   lsu_iobrdge_tap_rq_type ;
351
input  [8:8]  lsu_iobrdge_tap_rq_type_b8 ;
352
input  [6:3]  lsu_iobrdge_tap_rq_type_b6_b3 ;
353
input  [1:0]  lsu_iobrdge_tap_rq_type_b1_b0 ;
354
 
355
input         lsu_iobrdge_fwd_pkt_vld ;
356
 
357
input         lsu_cpx_ld_dtag_perror_e ;  // dtag parity error on issue
358
input         lsu_cpx_ld_dcache_perror_e ;// dcache parity error on issue
359
//input [1:1]   lsu_cpx_atm_st_err ;        // atomic st error field
360
input [1:0]   lsu_cpx_pkt_ld_err ;        // err field - cpx ld pkt
361
input [3:0]   ifu_lsu_nceen ;             // uncorrectible error enable 
362
input         tlu_lsu_ldxa_async_data_vld ;   // tlu_lsu_ldxa_data_vld is for async op.
363
input [3:0]   tlu_lsu_hpv_priv ;   // hypervisor privilege modified
364
input [3:0]   tlu_lsu_hpstate_en ;         // enable bit from hpstate
365
 
366
input         ifu_lsu_memref_d;
367
input         ifu_lsu_pref_inst_e ;       // prefetch inst
368
input         lsu_pref_pcx_req ;          // pref sent to pcx
369
 
370
input         lsu_cpx_pkt_prefetch2 ;     // ld is prefetch
371
 
372
// pref counter   
373
input [3:0]   lsu_ld_pcx_rq_sel_d2 ;
374
input         lsu_pcx_req_squash_d1;
375
 
376
input         lsu_bld_helper_cmplt_m ;    // bld helper completes.
377
input [2:0]   lsu_bld_cnt_m ;
378
input         lsu_bld_reset ;
379
 
380
output [3:0]  lsu_no_spc_pref;
381
 
382
input         ffu_lsu_blk_st_e ;        // blk st helper signalled by ffu
383
input   [3:0]    lsu_stb_rmo_st_issue ;  // thread's stb issues rmo st
384
input   [3:0]    lsu_cpx_rmo_st_ack ;    // rmo ack clears
385
 
386
input   [3:0]    lsu_dfq_flsh_cmplt ;
387
 
388
input           stb_cam_hit ;
389
 
390
input   ifu_tlu_flush_m;
391
 
392
output  ifu_tlu_flush_fd_w;
393
output  ifu_tlu_flush_fd2_w;
394
output  ifu_tlu_flush_fd3_w;
395
output  ifu_lsu_flush_w;
396
 
397
input   [3:0]           ctu_sscan_tid ;
398
 
399
//input         tte_data_perror_corr ;
400
input           tte_data_perror_unc ;
401
input           asi_tte_data_perror ;
402
input           asi_tte_tag_perror ;
403
 
404
input   [5:0]    tlu_dtlb_rw_index_g ;
405
 
406
input           lsu_local_early_flush_g ;
407
 
408
//input         lsu_error_pa_b39_m ;
409
 
410
input         lsu_dfq_vld;
411
 
412
input           gdbginit_l ;
413
input           dc_direct_map ;
414
 
415
output  [1:0]    lsu_tlu_thrid_d ;
416
 
417
output  [3:0] lsu_diagnstc_data_sel ;
418
output  [3:0] lsu_diagnstc_va_sel ;
419
 
420
output  [2:0] lsu_err_addr_sel ;
421
 
422
output [15:0] dva_bit_wr_en_e;
423
output [10:6] dva_wr_adr_e;
424
 
425
output      lsu_exu_ldst_miss_w2 ;  // load misses in d$.
426
//output  [3:0]   lsu_way_hit ;   // ld/st access hits in d$.
427
output      lsu_exu_dfill_vld_w2 ;  // data fill to irf(exu).
428
output      lsu_ffu_ld_vld ;  // fp load writes to frf
429
output      lsu_ld_miss_wb ;  // load misses in d$.
430
//output      lsu_ld_hit_wb ;   // load hits in d$.
431
 
432
output      lsu_dtlb_bypass_e ; // dtlb is bypassed
433
 
434 113 albert.wat
output [`LMQ_WIDTH-1:40] ld_pcx_pkt_g ;    // ld miss pkt for thread.
435 95 fafa1971
output      tlb_ldst_cam_vld ;
436
 
437
 
438
//output      stxa_internal ;   // internal stxa, stg g 
439
output      ldxa_internal ;   // internal ldxa, stg g
440
 
441
output      lsu_ifu_ldsta_internal_e ; // any internal asi
442
output  [3:0]   lsu_ifu_ldst_cmplt ;
443
output  [3:0]   lsu_ifu_itlb_en ;
444
output  [3:0]   lsu_ifu_icache_en ;
445
 
446
 
447
output  [3:0]           lmq_byp_data_en_w2 ;
448
 
449
output  [3:0]           lmq_byp_data_fmx_sel ;  // final data sel for lmq byp
450
output  [3:0]           lmq_byp_data_mxsel0 ;     // ldxa vs stb bypass data sel.
451
output  [3:0]           lmq_byp_data_mxsel1 ;     // ldxa vs stb bypass data sel.
452
output  [3:0]           lmq_byp_data_mxsel2 ;     // ldxa vs stb bypass data sel.
453
output  [3:0]           lmq_byp_data_mxsel3 ;     // ldxa vs stb bypass data sel.
454
output  [2:0]           lmq_byp_ldxa_mxsel0 ;     // ldxa data sel - thread0
455
output  [2:0]           lmq_byp_ldxa_mxsel1 ;     // ldxa data sel - thread1
456
output  [2:0]           lmq_byp_ldxa_mxsel2 ;     // ldxa data sel - thread2
457
output  [2:0]           lmq_byp_ldxa_mxsel3 ;     // ldxa data sel - thread3
458
output  [2:0]   lsu_ld_thrd_byp_sel_e ;
459
 
460
output  [15:0]    dcache_byte_wr_en_e ; // 16-byte write enable mask.
461
 
462
output      lsu_dcache_wr_vld_e ; // write to dcache.
463
 
464
output      lsu_ldstub_g ;    // ldstub(a) instruction
465
output      lsu_swap_g ;    // swap(a) instruction
466
output                  lsu_tlu_dtlb_done;  // dtlb rd/dmp/wr cmplt
467
output  [1:0]   lsu_exu_thr_m ;
468
 
469
output                   merge7_sel_byte0_m;
470
output                   merge7_sel_byte7_m;
471
 
472
output                   merge6_sel_byte1_m;
473
output                   merge6_sel_byte6_m;
474
 
475
output                   merge5_sel_byte2_m;
476
output                   merge5_sel_byte5_m;
477
 
478
output                   merge4_sel_byte3_m;
479
output                   merge4_sel_byte4_m;
480
 
481
output                   merge3_sel_byte0_m;
482
output                   merge3_sel_byte3_m;
483
output                   merge3_sel_byte4_m;
484
output                   merge3_sel_byte7_default_m;
485
output                   merge3_sel_byte_m ;
486
 
487
output                   merge2_sel_byte1_m;
488
output                   merge2_sel_byte2_m;
489
output                   merge2_sel_byte5_m;
490
output                   merge2_sel_byte6_default_m;
491
output                   merge2_sel_byte_m ;
492
 
493
output                   merge0_sel_byte0_m, merge0_sel_byte1_m;
494
output                   merge0_sel_byte2_m, merge0_sel_byte3_default_m;
495
 
496
output                   merge0_sel_byte4_m, merge0_sel_byte5_m;
497
output                   merge0_sel_byte6_m, merge0_sel_byte7_default_m;
498
 
499
output                   merge1_sel_byte0_m, merge1_sel_byte1_m;
500
output                   merge1_sel_byte2_m, merge1_sel_byte3_default_m;
501
output                   merge1_sel_byte4_m, merge1_sel_byte5_m;
502
output                   merge1_sel_byte6_m, merge1_sel_byte7_default_m;
503
 
504
output                               merge0_sel_byte_1h_m ;
505
 
506
output                               merge1_sel_byte_1h_m, merge1_sel_byte_2h_m ;
507
 
508
output          lsu_dtlb_cam_real_e ;
509
output      lsu_dtagv_wr_vld_e ;
510
 
511
output      lsu_dtag_wrreq_x_e ;
512
output      lsu_dtag_index_sel_x_e ;
513
 
514
output      lsu_dtlb_wr_vld_e ;
515
output      lsu_dtlb_tag_rd_e ;
516
output      lsu_dtlb_data_rd_e ;
517
output      lsu_dtlb_dmp_vld_e ;
518
output      lsu_dtlb_dmp_all_e ;
519
output      lsu_dtlb_rwindex_vld_e ;
520
output      lsu_dtlb_invalid_all_l_m ;
521
output      lsu_tlu_tlb_ld_inst_m ;
522
output      lsu_tlu_tlb_st_inst_m ;
523
output  [1:0]   lsu_tlu_tlb_access_tid_m ;
524
output      lsu_tlb_data_rd_vld_g ;
525
 
526
 
527
output  [3:0]   lsu_tlb_st_sel_m ;
528
 
529
output         lsu_va_wtchpt0_wr_en_l;
530
output         lsu_va_wtchpt1_wr_en_l;
531
output         lsu_va_wtchpt2_wr_en_l;
532
output         lsu_va_wtchpt3_wr_en_l;
533
 
534
output         thread0_m;
535
output         thread1_m;
536
output         thread2_m;
537
output         thread3_m;
538
 
539
output         lsu_dctldp_thread0_m;
540
output         lsu_dctldp_thread1_m;
541
output         lsu_dctldp_thread2_m;
542
output         lsu_dctldp_thread3_m;
543
 
544
output         thread0_g;
545
output         thread1_g;
546
output         thread2_g;
547
output         thread3_g;
548
 
549
output                  lsu_tlu_nonalt_ldst_m ; // non-alternate load or store
550
output                  lsu_tlu_xslating_ldst_m ;// xslating ldst,atomic etc
551
 
552
output   [2:0]          lsu_tlu_ctxt_sel_m;           // context selected:0-p,1-s,2-n
553
output                  lsu_tlu_write_op_m;           // fault occurs for data write operation
554
 
555
output                  lsu_dtlb_addr_mask_l_e ;  // address mask applies
556
 
557
 
558
output            dva_din_e;
559
 
560
output            lsu_diagnstc_dtagv_prty_invrt_e ;
561
 
562
output                  lsu_ifu_asi_load;   // asi load to ifu
563
output [1:0]            lsu_ifu_asi_thrid;    // asi event thrid to ifu
564
output                  lsu_ifu_asi_vld;    // asi event vld - ld+st
565
output      lsu_quad_asi_e ;
566
//output      lsu_tlu_64kpg_hit_g ;   // 64k page page accessed
567
 
568
output            lsu_local_ldxa_sel_g;
569
output  [3:0]     lsu_dtag_rsel_m ;  // dtag way sel
570
 
571
output      lsu_tlbop_force_swo ;
572
output  [2:0]     lsu_atomic_pkt2_bsel_g ;
573
output      lsu_dcache_tag_perror_g ;       // dcache tag parity error
574
output      lsu_dcache_data_perror_g ;      // dcache data parity error
575
 
576
output      lsu_ifu_l2_unc_error ;    // l2 uncorrectible error
577
output      lsu_ifu_l2_corr_error ;   // l2 correctible error
578
output      lsu_ifu_dcache_data_perror ;  // dcache data parity error
579
output      lsu_ifu_dcache_tag_perror ; // dcache tag parity error
580
output  [1:0]   lsu_ifu_error_tid ;   // thread id for error
581
output      lsu_ifu_io_error ;    // error on io ld
582
//output  [1:0]   lsu_tlu_derr_tid_g ;    // daccess error tid
583
 
584
output      lsu_tlu_squash_va_oor_m ;   // squash va_oor for mem-op.
585
output      lsu_squash_va_oor_m ;   // squash va_oor for mem-op.
586
 
587
output          tlb_cam_hit_g ;           // xlation hits in tlb.     
588
 
589
   output        lsu_st_hw_le_g;
590
   output        lsu_st_w_or_dbl_le_g;
591
   output        lsu_st_x_le_g;
592
   output        lsu_swap_sel_default_g;
593
   output        lsu_swap_sel_default_byte_7_2_g;
594
 
595
output          lsu_st_rmo_m ;          // rmo store in m stage
596
output          lsu_bst_in_pipe_m ;     // 1st helper for bst.
597
output          lsu_snap_blk_st_m ;     // snap blk st state 
598
output          lsu_blk_st_m ;          // blk st in m
599
output  [39:10] lsu_blkst_pgnum_m ;
600
output          lsu_ffu_blk_asi_e ;     // blk
601
output          lsu_blk_asi_m ;
602
 
603
output          lsu_nonalt_nucl_access_m ;
604
 
605
//output        [3:0]   lsu_spu_stb_empty ;
606
 
607
   output     dcache_alt_mx_sel_e;
608
   output     dcache_alt_mx_sel_e_bf;
609
   output     dcache_rvld_e;
610
 
611
output          lsu_dc_iob_access_e ;   // dcache iob access
612
 
613
output          lsu_ifu_ldst_miss_w ;
614
 
615
   output lsu_ifu_dc_parity_error_w2;
616
 
617
   output lsu_ldst_inst_vld_e;
618
 
619
output          lsu_local_ldxa_tlbrd_sel_g;
620
output          lsu_local_diagnstc_tagrd_sel_g;
621
output          lsu_va_wtchpt_sel_g;
622
 
623
 
624
   input [7:0]   asi_d;
625
   input [7:0]   lsu_dctl_asi_state_m;
626
 
627
   output  [3:0] asi_state_wr_thrd;
628
   output        thread0_d;
629
   output        thread1_d;
630
   output        thread2_d;
631
   output        thread3_d;
632
   output        tlu_lsu_asi_update_g;
633
 
634
output  [3:0] pctxt_state_wr_thrd ;
635
output  [3:0] sctxt_state_wr_thrd ;
636
 
637
   output     thread_pctxt;
638
   output     thread_sctxt;
639
 
640
   output     thread_actxt;
641
   output     thread_default;
642
 
643
   output     thread0_ctxt;
644
   output     thread1_ctxt;
645
   output     thread2_ctxt;
646
   output     thread3_ctxt;
647
 
648
   output [3:0] pid_state_wr_en;
649
   output       thread0_e;
650
   output       thread1_e;
651
   output       thread2_e;
652
   output       thread3_e;
653
 
654
   output       dfture_tap_wr_mx_sel;
655
   output [3:0] lctl_rst;
656
   output [3:0] lsu_ctl_state_wr_en;
657
   output [3:0] lsuctl_ctlbits_wr_en;
658
   output [3:0] dfture_tap_rd_en;
659
 
660
   output      bist_tap_wr_en;
661
   output      bistctl_wr_en;
662
   output      bist_ctl_reg_wr_en;
663
   output      mrgn_tap_wr_en;
664
 
665
   output      ldiagctl_wr_en;
666
 
667
   output [3:0]  misc_ctl_sel_din ;
668
 
669
   output [2:0] lsu_asi_sel_fmx1;
670
   output [2:0] lsu_asi_sel_fmx2;
671
 
672
 
673
   output       tlb_access_en0_g;
674
   output       tlb_access_en1_g;
675
   output       tlb_access_en2_g;
676
   output       tlb_access_en3_g;
677
 
678
   output tlb_access_sel_thrd0;
679
   output tlb_access_sel_thrd1;
680
   output tlb_access_sel_thrd2;
681
   output tlb_access_sel_default;
682
 
683
   input [7:0] lsu_ldst_va_g;
684
 
685
   output mrgnctl_wr_en;
686
 
687
   input  lsu_ifu_err_addr_b39;
688
 
689
   input [5:0] lsu_dp_ctl_reg0;
690
   input [5:0] lsu_dp_ctl_reg1;
691
   input [5:0] lsu_dp_ctl_reg2;
692
   input [5:0] lsu_dp_ctl_reg3;
693
 
694
   input       ldd_in_dfq_out;     //from qctl2 
695
 
696
 
697
   output hpv_priv_m;
698
   output hpstate_en_m;
699
 
700
   output                dcache_arry_data_sel_m;
701
 
702
   output                dtlb_bypass_m;
703
 
704
   output                lsu_alt_space_m;
705
   output                atomic_m;
706
 
707
   output                ldst_dbl_m;
708
   output                fp_ldst_m;
709
 
710
   output                lda_internal_m;
711
   output                sta_internal_m;
712
   output                cam_real_m;
713
 
714
   output                data_rd_vld_g;
715
   output                tag_rd_vld_g;
716
   output [1:0]          ldst_sz_m;
717
   output                asi_internal_m;
718
 
719
//   output                ld_inst_vld_unflushed;
720
//   output                st_inst_vld_unflushed;
721
 
722
   output                rd_only_ltlb_asi_e;
723
   output                wr_only_ltlb_asi_e;
724
   output                dfill_tlb_asi_e;
725
   output                ifill_tlb_asi_e;
726
 
727
   output                nofault_asi_m;
728
   output                as_if_user_asi_m;
729
 
730
   output                atomic_asi_m;
731
   output                phy_use_ec_asi_m;
732
   output                phy_byp_ec_asi_m;
733
 
734
   output                quad_asi_m;
735
   output                binit_quad_asi_m;
736
   output                blk_asi_m;
737
 
738
   output                recognized_asi_m;
739
   output                strm_asi_m;
740
   output                mmu_rd_only_asi_m;
741
   output                rd_only_asi_m;
742
   output                wr_only_asi_m;
743
   output                unimp_asi_m;
744
 
745
   output                va_wtchpt_cmp_en_m;
746
 
747
   output               lsu_tlu_async_ttype_vld_w2 ;    // daccess error - asynchronous
748
   output   [6:0]        lsu_tlu_async_ttype_w2 ;
749
   output   [1:0]        lsu_tlu_async_tid_w2 ;          // asynchronous trap - thread 
750
 
751
   output   [5:0]        async_tlb_index ;
752
 
753
//=========================================
754
//dc_fill CP
755
//=========================================   
756
   output                l2fill_vld_m;    //to qdp1
757
   output  [3:0]   ld_thrd_byp_mxsel_m ;  //to qdp1
758
   output [7:0]    morphed_addr_m;        //to dcdp
759
 
760
 
761
   output          signed_ldst_byte_m;    //to dcdp
762
//   output          unsigned_ldst_byte_m;  //to dcdp 
763
   output          signed_ldst_hw_m;      //to dcdp
764
//   output          unsigned_ldst_hw_m;    //to dcdp
765
   output          signed_ldst_w_m;       //to dcdp
766
//   output          unsigned_ldst_w_m;     //to dcdp
767
 
768
   output       lsu_tlb_asi_data_perr_g ;
769
   output       lsu_tlb_asi_tag_perr_g ;
770
 
771
   output  [14:13]   lsu_sscan_data ;
772
 
773
   output  [3:0]         lsu_ld_inst_vld_g ;
774
 
775
   output  [1:0]     lsu_dcache_rand;
776
   output  [1:0]     lsu_encd_way_hit;
777
   output            lsu_way_hit_or;
778
//   output            lsu_quad_asi_g;
779
 
780
   output            lsu_memref_m ;
781
   output            lsu_flsh_inst_m ;
782
 
783
   output               lsu_ifu_asi_data_en_l ;
784
 
785
 
786
//dcfill_addr [10:0]
787
   input [7:0]  dcache_iob_addr_e;
788
   input [6:0]  mbist_dcache_index;
789
   input        mbist_dcache_word;
790
   input [10:0] lsu_diagnstc_wr_addr_e;
791
   input [10:0] st_dcfill_addr;
792
   output [10:3] lsu_dcache_fill_addr_e;
793
   output [10:4] lsu_dcache_fill_addr_e_err;
794
 
795
   input         lsu_dfq_ld_vld;
796
   input         lsu_dfq_st_vld;
797
 
798
   output [3:0]  lsu_thread_g;
799
 
800
//=========================================
801
//LMQ thread sel
802
//=========================================
803
   input         lmq0_ldd_vld;      //from qdp1
804
   input         lmq1_ldd_vld;
805
   input         lmq2_ldd_vld;
806
   input         lmq3_ldd_vld;
807
   output        lmq_ldd_vld;       //to  qctl2 
808
 
809
   input [1:0]   lsu_dfq_byp_tid;   //from qdp2
810
   input         dfq_byp_ff_en;     //from qctl2 
811
 
812
   input [1:0]   lsu_dcache_iob_way_e;   //from qdp2
813
 
814
   input   [1:0]  mbist_dcache_way;
815
   output  [3:0]  lsu_bist_rsel_way_e;
816
 
817
   input   [1:0]   lsu_diagnstc_wr_way_e ;  //from dctldp
818
 
819
   input [1:0]     lsu_st_way_e;    //from qdp2
820
 
821
   input [1:0]     lmq0_pcx_pkt_way;  //from qctl1
822
   input [1:0]     lmq1_pcx_pkt_way;
823
   input [1:0]     lmq2_pcx_pkt_way;
824
   input [1:0]     lmq3_pcx_pkt_way;
825
   output [3:0]    lsu_dcache_fill_way_e;
826
 
827
 
828
input  [2:0]             lmq0_ld_rq_type ;        // for identifying atomic ld.
829
input  [2:0]             lmq1_ld_rq_type ;        // for identifying atomic ld.
830
input  [2:0]             lmq2_ld_rq_type ;        // for identifying atomic ld.
831
input  [2:0]             lmq3_ld_rq_type ;        // for identifying atomic ld.
832
 
833
input  [10:0]            lmq0_pcx_pkt_addr;
834
input  [10:0]            lmq1_pcx_pkt_addr;
835
input  [10:0]            lmq2_pcx_pkt_addr;
836
input  [10:0]            lmq3_pcx_pkt_addr;
837
 
838
output                   lmq_ld_addr_b3;
839
 
840
output [3:0]             lsu_outstanding_rmo_st_max;
841
 
842
input                 lsu_ttype_vld_m2;
843
input                 tlu_early_flush_pipe2_w;
844
input [1:0]           lsu_st_dcfill_size_e;
845
 
846
   input              mbist_dcache_write;
847
   input              mbist_dcache_read;
848
 
849
   output             lsu_dcfill_data_mx_sel_e;
850
 
851
wire  [3:0]   ld_thrd_byp_sel_e ;
852
wire          ifu_asi_vld,ifu_asi_vld_d1 ;
853
wire  [1:0]   dcache_wr_size_e ;
854
wire          lsu_ncache_ld_e;
855
wire          lsu_diagnstc_wr_src_sel_e ; // dcache/dtag/v write - diag
856
 
857
wire         dctl_flush_pipe_w ;   // flush pipe due to error
858
 wire        dctl_early_flush_w;
859
 
860
wire  [10:0] lmq_pcx_pkt_addr;
861
wire  [2:0]  lmq_ld_rq_type_e;
862
 
863
wire [10:0]  dcache_fill_addr_e;
864
wire [2:0]   dcache_wr_addr_e ;
865
wire    lsuctl_dtlb_byp_e ;
866
 
867
wire    cam_perr_unc0,asi_data_perr0,asi_tag_perr0,ifu_unc_err0 ;
868
wire    cam_perr_unc1,asi_data_perr1,asi_tag_perr1,ifu_unc_err1 ;
869
wire    cam_perr_unc2,asi_data_perr2,asi_tag_perr2,ifu_unc_err2 ;
870
wire    cam_perr_unc3,asi_data_perr3,asi_tag_perr3,ifu_unc_err3 ;
871
wire    cam_perr_unc_e, asi_data_perr_e,asi_tag_perr_e,ifu_unc_err_e ;
872
wire    cam_perr_unc_m, asi_data_perr_m,asi_tag_perr_m,ifu_unc_err_m ;
873
wire    cam_perr_unc_g, asi_data_perr_g,asi_tag_perr_g,ifu_unc_err_g ;
874
//wire  cam_real_err_e, cam_real_err_m ;
875
wire    [3:0] squash_byp_cmplt,squash_byp_cmplt_m, squash_byp_cmplt_g ;
876
wire      ld_inst_vld_m,ld_inst_vld_g ;
877
wire      st_inst_vld_m,st_inst_vld_g ;
878
wire      fp_ldst_m,fp_ldst_g,fp_ldst_w2 ;
879
wire      lsu_ld_hit_wb, lsu_ld_miss_wb ;
880
wire  [3:0]   lsu_way_hit ;
881
wire  [1:0]   ldst_sz_m,ldst_sz_g ;
882
wire  [4:0]   ld_rd_m, ld_rd_g ;
883
wire      lsu_dtlb_bypass_g,dtlb_bypass_e,dtlb_bypass_m ;
884
wire [6:0]  lsu_sraddr_e ;
885
//wire    lsu_rsr_inst_e,lsu_rsr_inst_m, lsu_rsr_inst_w ;
886
wire    lsu_wsr_inst_e;
887
wire    pctxt_state_en, sctxt_state_en ;
888
wire    asi_state_wr_en ;
889
//wire  [3:0] pctxt_state_rd_en, sctxt_state_rd_en ;
890
wire    lsu_alt_space_m,lsu_alt_space_g ;
891
wire    ldxa_internal, stxa_internal ;
892
wire    lsu_ctl_state_en;
893
//wire  [3:0] lsu_ctl_state_rd_en;
894
wire  [3:0]   lsu_ctl_state_wr_en ;
895
//wire  [7:0] imm_asi_e,imm_asi_m,imm_asi_g ;
896
//wire    imm_asi_vld_e,imm_asi_vld_m,imm_asi_vld_g;
897
//wire  [7:0]   asi_state0,asi_state1,asi_state2,asi_state3 ;
898
 
899
wire    ldsta_internal_e,sta_internal_e,lda_internal_e;
900
wire    sta_internal_m,lda_internal_m;
901
wire  [7:0] asi_d ;
902
wire    [1:0]   thrid_d,thrid_e,thrid_m, thrid_g, thrid_w2, thrid_w3, ldxa_thrid_w2 ;
903
wire    stxa_internal_d1, stxa_internal_d2 ;
904
wire    ld_pcx_pkt_vld_e ;
905
wire    ld_pcx_pkt_vld_m ;
906
wire    ld_pcx_pkt_vld_g ;
907
wire    ldst_dbl_m, ldst_dbl_g;
908
wire    ldd_force_l2access_w2, ldd_force_l2access_w3;
909
 
910
//wire    ld_stb_full_raw_w2 ;
911
wire    ld_stb_full_raw_w3 ;
912
 
913
wire    ldbyp0_vld_rst, ldbyp0_vld_en, ldbyp0_fpld ;
914
wire    ldbyp1_vld_rst, ldbyp1_vld_en, ldbyp1_fpld ;
915
wire    ldbyp2_vld_rst, ldbyp2_vld_en, ldbyp2_fpld ;
916
wire    ldbyp3_vld_rst, ldbyp3_vld_en, ldbyp3_fpld ;
917
//wire    ldbyp0_vld_en_d1,ldbyp1_vld_en_d1,ldbyp2_vld_en_d1,ldbyp3_vld_en_d1 ;
918
 
919
wire    thread0_e,thread1_e,thread2_e,thread3_e;
920
wire    thread0_d,thread1_d,thread2_d,thread3_d;
921
wire    thread0_m,thread1_m,thread2_m,thread3_m;
922
wire    thread0_g,thread1_g,thread2_g,thread3_g;
923
wire    thread0_w2,thread1_w2,thread2_w2,thread3_w2;
924
wire    thread0_w3,thread1_w3,thread2_w3,thread3_w3;
925
wire    tlu_stxa_thread0_w2,tlu_stxa_thread1_w2 ;
926
wire    tlu_stxa_thread2_w2,tlu_stxa_thread3_w2 ;
927
wire    tlu_ldxa_thread0_w2,tlu_ldxa_thread1_w2 ;
928
wire    tlu_ldxa_thread2_w2,tlu_ldxa_thread3_w2 ;
929
wire    spu_ldxa_thread0_w2,spu_ldxa_thread1_w2 ;
930
wire    spu_ldxa_thread2_w2,spu_ldxa_thread3_w2 ;
931
wire    spu_stxa_thread0,spu_stxa_thread1 ;
932
wire    spu_stxa_thread2,spu_stxa_thread3 ;
933
wire    ifu_ldxa_thread0_w2,ifu_ldxa_thread1_w2 ;
934
wire    ifu_ldxa_thread2_w2,ifu_ldxa_thread3_w2 ;
935
wire    ifu_stxa_thread0_w2,ifu_stxa_thread1_w2 ;
936
wire    ifu_stxa_thread2_w2,ifu_stxa_thread3_w2 ;
937
wire    ldbyp0_vld, ldbyp1_vld, ldbyp2_vld, ldbyp3_vld ;
938
//wire    ld_any_byp_data_vld ;              
939
wire  [3:0] asi_state_wr_thrd;
940
wire  [3:0] pctxt_state_wr_thrd ;
941
wire  [3:0] sctxt_state_wr_thrd ;
942
wire    tlb_cam_hit_g ;
943
wire    ld_inst_vld_unflushed ;
944
wire    st_inst_vld_unflushed ;
945
 
946
wire  [7:0]  baddr_m ;
947
wire  [15:0]  byte_wr_enable ;
948
//wire  [1:0] st_size ;
949
//wire    l2fill_bendian_g ;
950
wire    ldst_byte,ldst_hword,ldst_word,ldst_dword;
951
wire    byte_m,hword_m,word_m,dword_m;
952
wire    tlb_invert_endian_g ;
953
//wire  [7:0] l2fill_bytes_msb_m, l2fill_bytes_msb_g ;
954
//wire    byte_g, hword_g, word_g ;
955
 
956
   wire signed_ldst_m ;
957
//wire  unsigned_ldst_m ;
958
//wire    sign_bit_g  ;
959
//wire  [7:0] align_bytes_msb ;
960
 
961
wire    l2fill_vld_m, l2fill_vld_g ;
962
wire    l2fill_fpld_e, l2fill_fpld_m, l2fill_fpld_g ;
963
wire    pstate_cle_e, pstate_cle_m, pstate_cle_g ;
964
wire    l1hit_lendian_g ;
965
wire    l1hit_sign_extend_m, l1hit_sign_extend_g ;
966
wire    demap_thread0, demap_thread1, demap_thread2, demap_thread3 ;
967
 
968
wire    misc_byte_m,misc_hword_m,misc_word_m,misc_dword_m;
969
wire    byp_word_g;
970
//wire  [15:0]  byp_baddr_g ;
971
//wire    ld_stb_hit_g ;
972
wire    atomic_ld_squash_e ;
973
wire    atomic_m,atomic_g,atomic_w2, atomic_w3 ;
974
wire  [2:0] ld_rq_type ;
975
wire    ncache_pcx_rq_g ;
976
wire    lmq_pkt_vld_g ;
977
wire    tlb_lng_ltncy_asi_d,tlb_lng_ltncy_asi_e, tlb_lng_ltncy_asi_m,tlb_lng_ltncy_asi_g ;
978
wire    recognized_asi_d,recognized_asi_e,recognized_asi_m,recognized_asi_g,recognized_asi_tmp ;
979
wire    asi_internal_d, asi_internal_e ;
980
wire    asi_internal_m, asi_internal_g ;
981
wire    dcache_byp_asi_d, dcache_byp_asi_e ;
982
wire    dcache_byp_asi_m, dcache_byp_asi_g ;
983
wire    phy_use_ec_asi_d,phy_use_ec_asi_e,phy_use_ec_asi_m;
984
wire    phy_byp_ec_asi_d,phy_byp_ec_asi_e,phy_byp_ec_asi_m;
985
wire    lendian_asi_d, lendian_asi_e;
986
wire    lendian_asi_m, lendian_asi_g;
987
wire    intrpt_disp_asi_d,intrpt_disp_asi_e,intrpt_disp_asi_m,intrpt_disp_asi_g ;
988
wire    nofault_asi_d, nofault_asi_e, nofault_asi_m ;
989
wire    nucleus_asi_d, nucleus_asi_e ;
990
wire    primary_asi_d, primary_asi_e ;
991
wire    quad_asi_d,quad_asi_e,quad_asi_m,quad_asi_g;
992
wire    binit_quad_asi_d,binit_quad_asi_e,binit_quad_asi_m,binit_quad_asi_g ;
993
wire    secondary_asi_d, secondary_asi_e ;
994
wire    tlb_byp_asi_d, tlb_byp_asi_e;
995
wire    thread0_ctxt, thread1_ctxt ;
996
wire    thread2_ctxt, thread3_ctxt ;
997
 
998
 
999
wire    altspace_ldst_e, non_altspace_ldst_e ;
1000
wire    altspace_ldst_m, altspace_ldst_g ;
1001
wire    non_altspace_ldst_m, non_altspace_ldst_g ;
1002
wire    thread_pctxt, thread_sctxt, thread_nctxt, thread_actxt ;
1003
wire    ncache_asild_rq_g ;
1004
//SC wire    pstate_priv, pstate_priv_m ;
1005
//SC wire    priv_pg_usr_mode ;
1006
//SC wire    nonwr_pg_st_access ;
1007
//SC wire    nfo_pg_nonnfo_asi ;
1008
//wire    daccess_excptn ;
1009
wire    mbar_inst_m,flsh_inst_m ;
1010
wire    mbar_inst_g,flsh_inst_g ;
1011
wire    bsync0_reset,bsync1_reset;
1012
wire    bsync2_reset,bsync3_reset ;
1013
wire    bsync0_en,bsync1_en ;
1014
wire    bsync2_en,bsync3_en ;
1015
wire    flush_inst0_g,mbar_inst0_g ;
1016
wire    flush_inst1_g,mbar_inst1_g ;
1017
wire    flush_inst2_g,mbar_inst2_g ;
1018
wire    flush_inst3_g,mbar_inst3_g ;
1019
wire    dfill_thread0,dfill_thread1;
1020
wire    dfill_thread2,dfill_thread3;
1021
wire    mbar_vld0, flsh_vld0 ;
1022
wire    mbar_vld1, flsh_vld1 ;
1023
wire    mbar_vld2, flsh_vld2 ;
1024
wire    mbar_vld3, flsh_vld3 ;
1025
   wire [1:0] dfq_tid_m,dfq_tid_g;
1026
 
1027
wire  [1:0]   ldbyp_tid_m ;
1028
wire    stxa_stall_asi_g ;
1029
wire    stxa_stall_wr_cmplt0, stxa_stall_wr_cmplt1 ;
1030
wire    stxa_stall_wr_cmplt2, stxa_stall_wr_cmplt3 ;
1031
wire    stxa_stall_wr_cmplt0_d1, stxa_stall_wr_cmplt1_d1 ;
1032
wire    stxa_stall_wr_cmplt2_d1, stxa_stall_wr_cmplt3_d1 ;
1033
wire    dtlb_done ;
1034
wire    tag_rd_vld_m, tag_rd_vld_g ;
1035
wire    data_rd_vld_m, data_rd_vld_g ;
1036
wire    tlb_demap_vld ;
1037
wire    dtlb_done_d1 ;
1038
wire    dtlb_done_d2 ;
1039
 
1040
 
1041
wire    tlu_lsu_asi_update_g ;
1042
wire  [1:0] tlu_lsu_tid_g ;
1043
wire    tsa_update_asi0,tsa_update_asi1;
1044
wire    tsa_update_asi2,tsa_update_asi3;
1045
wire    tlb_ld_inst0,tlb_ld_inst1,tlb_ld_inst2,tlb_ld_inst3 ;
1046
wire    tlb_st_inst0,tlb_st_inst1,tlb_st_inst2,tlb_st_inst3 ;
1047
wire    tlb_access_en0_e,tlb_access_en1_e,tlb_access_en2_e,tlb_access_en3_e ;
1048
wire    tlb_access_en0_m,tlb_access_en1_m,tlb_access_en2_m,tlb_access_en3_m ;
1049
wire    tlb_access_en0_tmp,tlb_access_en1_tmp,tlb_access_en2_tmp,tlb_access_en3_tmp ;
1050
wire    tlb_access_en0_g,tlb_access_en1_g,tlb_access_en2_g,tlb_access_en3_g ;
1051
wire    tlb_access_en0_unflushed,tlb_access_en1_unflushed,tlb_access_en2_unflushed,tlb_access_en3_unflushed ;
1052
wire    tlb_access_rst0,tlb_access_rst1,tlb_access_rst2,tlb_access_rst3 ;
1053
wire    tlb_access_sel_thrd0,tlb_access_sel_thrd1;
1054
wire    tlb_access_sel_thrd2,tlb_access_sel_thrd3;
1055
wire    tlb_access_blocked ;
1056
wire    tlb_access_pending ;
1057
wire    tlb_access_initiated ;
1058
//wire    tlb_pending_access_rst ;
1059
 
1060
wire    vw_wtchpt_cmp_en_m,vr_wtchpt_cmp_en_m ;
1061
 
1062
 
1063
//wire    va_b12_3_match_m,va_b47_40_match_m ;
1064
//wire    va_b12_3_match_g,va_b47_40_match_g ;
1065
//wire    wtchpt_msk_match_m,wtchpt_msk_match_g ;
1066
 
1067
wire    as_if_user_asi_d,as_if_user_asi_e,as_if_user_asi_m;
1068
//SC wire    as_if_usr_priv_pg ;
1069
//SC wire    priv_action,priv_action_m ;
1070
//SC wire    stdf_maddr_not_align, lddf_maddr_not_align ;
1071
//wire  [8:0] early_ttype_m,early_ttype_g ; 
1072
//wire    early_trap_vld_m, early_trap_vld_g ;  
1073
//SC wire    atm_access_w_nc, atm_access_unsup_asi ;
1074
wire    atomic_asi_d,atomic_asi_e,atomic_asi_m ;
1075
//wire    dflush_asi_d,dflush_asi_e,dflush_asi_m,dflush_asi_g;  
1076
wire    blk_asi_d,blk_asi_e,blk_asi_m, blk_asi_g ;
1077
 
1078
wire    fpld_byp_data_vld ;
1079
//wire  [7:0] dcache_rd_parity ;
1080
wire    dcache_rd_parity_error ;
1081
//SC wire    tte_data_parity_error ;
1082
 
1083
wire  [3:0]   dtag_parity_error;
1084
//wire    dtag_mtag_parity_error ;
1085
//wire    daccess_error ;
1086
//SC wire    dmmu_miss_g ;
1087
wire  [2:0]   ctxt_sel_e ;
1088
wire    dc_diagnstc_asi_d, dc_diagnstc_asi_e ;
1089
wire    dc_diagnstc_asi_m, dc_diagnstc_asi_g ;
1090
wire    dtagv_diagnstc_asi_d, dtagv_diagnstc_asi_e ;
1091
wire    dtagv_diagnstc_asi_m, dtagv_diagnstc_asi_g ;
1092
//wire    dc_diagnstc_wr_e,dtagv_diagnstc_wr_e ;
1093
//wire    dside_diagnstc_wr_e ;
1094
wire    dc_diagnstc_wr_en,dtagv_diagnstc_wr_en ;
1095
 
1096
wire  dtagv_diagnstc_rd_g ;
1097
wire  dc0_diagnstc_asi,dtagv0_diagnstc_asi;
1098
wire  dc1_diagnstc_asi,dtagv1_diagnstc_asi;
1099
wire  dc2_diagnstc_asi,dtagv2_diagnstc_asi;
1100
wire  dc3_diagnstc_asi,dtagv3_diagnstc_asi;
1101
//wire [3:0] lngltncy_st_go ;
1102
wire  [3:0]   tlb_st_data_sel_m ;
1103
wire  dc0_diagnstc_wr_en, dc1_diagnstc_wr_en, dc2_diagnstc_wr_en, dc3_diagnstc_wr_en ;
1104
wire  dtagv0_diagnstc_wr_en, dtagv1_diagnstc_wr_en, dtagv2_diagnstc_wr_en, dtagv3_diagnstc_wr_en ;
1105
//wire  merge2_sel_byte7, merge3_sel_byte7 ; 
1106
//SC wire  hw_align_addr,wd_align_addr,dw_align_addr;
1107
wire   hw_size,wd_size,dw_size;
1108
//SC wire  mem_addr_not_align ;
1109
 
1110
wire  wr_only_asi_d,wr_only_asi_e,wr_only_asi_m ;
1111
wire  rd_only_asi_d,rd_only_asi_e,rd_only_asi_m ;
1112
wire  mmu_rd_only_asi_d,mmu_rd_only_asi_e,mmu_rd_only_asi_m ;
1113
wire  unimp_asi_d,unimp_asi_e,unimp_asi_m;
1114
wire  dmmu_asi58_d,dmmu_asi58_e,dmmu_asi58_m;
1115
wire  immu_asi50_d,immu_asi50_e,immu_asi50_m;
1116
 
1117
wire  ifu_asi_store ;
1118
wire  nontlb_asi0, nontlb_asi1, nontlb_asi2, nontlb_asi3 ;
1119
//wire  stxa_stall_reset ;
1120
wire  ifu_nontlb0_asi,ifu_nontlb1_asi,ifu_nontlb2_asi,ifu_nontlb3_asi;
1121
wire  ifu_nontlb_asi_d, ifu_nontlb_asi_e,ifu_nontlb_asi_m,ifu_nontlb_asi_g ;
1122
wire  [2:0] lsu_asi_sel_fmx1 ;
1123
wire  [2:0] lsu_asi_sel_fmx2;
1124
wire    lsu_asi_rd_en, lsu_asi_rd_en_w2 ;
1125
//wire  [12:0]  pctxt_state ;
1126
//wire  [12:0]  sctxt_state ;
1127
 
1128
//wire  [1:0] dcache_rand,dcache_rand_new ;
1129
wire    dtlb_inv_all_e,dtlb_inv_all_m ;
1130
wire  dtlb_wr_vld_d1,dtlb_tag_rd_d1,dtlb_data_rd_d1,dtlb_dmp_vld_d1,dtlb_inv_all_d1 ;
1131
wire  ldst_in_pipe ;
1132
wire  tlbop_init, tlbop_init_d1, tlbop_init_d2 ;
1133
wire  tlbop_init_d3, tlbop_init_d4, tlbop_init_d5 ;
1134
wire  [3:0] ldxa_illgl_va_cmplt,ldxa_illgl_va_cmplt_d1 ;
1135
 
1136
wire  lsuctl_va_vld ;
1137
wire  lsuctl_illgl_va ;
1138
wire  sctxt_va_vld;
1139
//wire  scxt_ldxa_illgl_va ;
1140
wire  pctxt_va_vld;
1141
 
1142
wire  pscxt_ldxa_illgl_va ;
1143
wire  lsu_asi_illgl_va ;
1144
wire  [3:0] lsu_asi_illgl_va_cmplt,lsu_asi_illgl_va_cmplt_w2 ;
1145
wire  bistctl_va_vld,mrgnctl_va_vld,ldiagctl_va_vld ;
1146
wire  bistctl_state_en,mrgnctl_state_en,ldiagctl_state_en ;
1147
wire  mrgnctl_illgl_va ;
1148
wire  asi42_illgl_va ;
1149
 
1150
wire    [3:0]   tap_thread ;
1151
wire    mrgn_tap_wr_en ;
1152
wire    bist_tap_wr_en ;
1153
 
1154
wire [3:0] dfture_tap_rd_d1;
1155
wire [3:0] dfture_tap_wr_en;
1156
 
1157
//wire  dfture_tap_rd_sel ;
1158
 
1159
wire  misc_asi_rd_en ;
1160
 
1161
wire [3:0]  lsuctl_ctlbits_wr_en ;
1162
wire  bistctl_wr_en;
1163
wire  mrgnctl_wr_en;
1164
//wire  ldiagctl_rd_en,ldiagctl_wr_en;
1165
wire  casa_m, casa_g ;
1166
wire  tte_data_perror_unc ;
1167
wire  asi_tte_data_perror,asi_tte_tag_perror ;
1168
 
1169
wire  [1:0] dfill_tid_m,dfill_tid_g ;
1170
wire  dtag_error_m,dcache_error_m;
1171
wire  dtag_error_g,dcache_error_g;
1172
wire  dtag_error_w2,dcache_error_w2;
1173
wire  l2_unc_error_e,l2_corr_error_e;
1174
wire  l2_unc_error_m,l2_corr_error_m;
1175
wire  l2_unc_error_g,l2_corr_error_g;
1176
wire  l2_unc_error_w2,l2_corr_error_w2;
1177
wire  unc_err_trap_e,unc_err_trap_m,unc_err_trap_g ;
1178
//wire  corr_err_trap_e, corr_err_trap_m, corr_err_trap_g ;
1179
wire  dtag_perror_g ;
1180
 
1181
 
1182
wire  ifill_tlb_asi_d,dfill_tlb_asi_d,rd_only_ltlb_asi_d,wr_only_ltlb_asi_d ;
1183
wire  ifill_tlb_asi_e,dfill_tlb_asi_e,rd_only_ltlb_asi_e,wr_only_ltlb_asi_e ;
1184
//SC wire  tlb_daccess_excptn_e,tlb_daccess_error_e  ;
1185
//SC wire  tlb_daccess_excptn_m,tlb_daccess_error_m  ;
1186
//SC wire  tlb_daccess_excptn_g,tlb_daccess_error_g  ;
1187
wire  thread_tl_zero ;
1188
wire    pid_va_vld, pid_state_en ;
1189
wire    [3:0]    pid_state_wr_en ;
1190
 
1191
//wire  [3:0]   pid_state_rd_en ;
1192
//wire  [2:0]   pid_state ;
1193
wire    [3:0]   intld_byp_cmplt ;
1194
 
1195
//wire  hpv_priv,hpstate_en ;   
1196
wire    hpv_priv_m,hpstate_en_m ;
1197
wire    hpv_priv_e,hpstate_en_e ;
1198
wire    blkst_m, blkst_g ;
1199
//wire  dc_direct_map ;         
1200
wire    spubyp_trap_active_e,spubyp_trap_active_m, spubyp_trap_active_g ;
1201
wire [6:0] spubyp_ttype ;
1202
wire    spu_trap ;
1203
wire    spu_trap0, spu_trap1, spu_trap2, spu_trap3 ;
1204
wire    [6:0]    spu_ttype ;
1205
wire    spubyp0_trap,spubyp1_trap,spubyp2_trap,spubyp3_trap;
1206
wire [6:0]       spubyp0_ttype,spubyp1_ttype,spubyp2_ttype,spubyp3_ttype;
1207
wire    bendian_g ;
1208
//wire va_wtchpt_rd_en, pa_wtchpt_rd_en;   
1209
//wire lsu_bendian_access_g;
1210
wire      lsu_tlb_tag_rd_vld_g ;
1211
wire      lsu_dtlb_invalid_all_m ;
1212
 
1213
wire  [3:0]   dva_vld_g;
1214
wire          lsu_diagnstc_asi_rd_en;
1215
wire  [3:0]   ld_thrd_byp_sel_g ;
1216
wire  [3:0]           lmq_byp_data_sel0 ;     // ldxa vs stb bypass data sel.
1217
wire  [3:0]           lmq_byp_data_sel1 ;     // ldxa vs stb bypass data sel.
1218
wire  [3:0]           lmq_byp_data_sel2 ;     // ldxa vs stb bypass data sel.
1219
wire  [3:0]           lmq_byp_data_sel3 ;     // ldxa vs stb bypass data sel.
1220
wire  [2:0]           lmq_byp_ldxa_sel0 ;     // ldxa data sel - thread0
1221
wire  [2:0]           lmq_byp_ldxa_sel1 ;     // ldxa data sel - thread1
1222
wire  [2:0]           lmq_byp_ldxa_sel2 ;     // ldxa data sel - thread2
1223
wire  [2:0]           lmq_byp_ldxa_sel3 ;     // ldxa data sel - thread3
1224
wire    endian_mispred_g ;
1225
 
1226
   wire       ld_inst_vld_w2, ld_inst_vld_w3;
1227
 
1228
   wire [3:0] lmq_byp_data_raw_sel_d1;
1229
   wire [3:0] lmq_byp_data_raw_sel_d2;
1230
 
1231
wire    asi_st_vld_g ;
1232
wire  ignore_fill;
1233
 
1234
wire  [3:0]  pend_atm_ld_ue ;
1235
 
1236
wire [2:0]   lsu_byp_misc_addr_m ;   // lower 3bits of addr for ldxa/raw etc
1237
wire [1:0]   lsu_byp_misc_sz_m ;     // size for ldxa/raw etc
1238
 
1239 113 albert.wat
`ifdef SIMPLY_RISC_TWEAKS
1240
wire pref_inst_m;
1241
wire pref_inst_g;
1242
wire ldstub_m;
1243
wire swap_m;
1244
wire ldstub_g;
1245
wire swap_g;
1246
`endif
1247
 
1248 95 fafa1971
//==========================================================
1249
//RESET, CLK
1250
//==========================================================     
1251
   wire       reset;
1252
 
1253
//   assign     reset = ~rst_l;
1254
   wire       dbb_reset_l;
1255
   wire       clk;
1256
 
1257
    dffrl_async rstff(.din (grst_l),
1258
                        .q   (dbb_reset_l),
1259 113 albert.wat
                        .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so(),
1260 95 fafa1971
                        .rst_l (arst_l));
1261
 
1262
   assign  reset  =  ~dbb_reset_l;
1263
   assign dctl_rst_l = dbb_reset_l;
1264
   assign clk = rclk;
1265
 
1266
wire      lsu_bist_wvld_e ;           // bist writes to cache
1267
wire            lsu_bist_rvld_e ;                 // bist reads dcache
1268
 
1269 113 albert.wat
dff_s #(2) mbist_stge (
1270 95 fafa1971
   .din ({mbist_dcache_write, mbist_dcache_read}),
1271
   .q   ({lsu_bist_wvld_e,    lsu_bist_rvld_e  }),
1272
   .clk (clk),
1273 113 albert.wat
   .se  (se),       `SIMPLY_RISC_SCANIN,          .so ()
1274 95 fafa1971
);
1275
 
1276
//===========================================================
1277
//from lsu_excpctl
1278
//wire          lsu_flush_pipe_w ;      // flush - local to lsu
1279
 
1280
//   assign lsu_flush_pipe_w = dctl_flush_pipe_w;
1281
 
1282
//===========================================================
1283
//   
1284
   assign     lsu_ldst_inst_vld_e = ld_inst_vld_e | st_inst_vld_e;
1285
 
1286
//wire    lsu_l2fill_bendian_g;
1287
 
1288
wire memref_e;
1289
 
1290 113 albert.wat
dff_s #(1) stge_ad_e (
1291 95 fafa1971
  .din (ifu_lsu_memref_d),
1292
  .q   (memref_e),
1293
  .clk (clk),
1294 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1295 95 fafa1971
);
1296
 
1297
//=================================================================================================
1298
// SHADOW SCAN
1299
//=================================================================================================
1300
 
1301
wire    sscan_data_13, sscan_data_14 ;
1302
// stb status - this monitors the stb state
1303
assign sscan_data_13 =
1304
  ctu_sscan_tid[0] & lsu_stb_empty[0] |
1305
  ctu_sscan_tid[1] & lsu_stb_empty[1] |
1306
  ctu_sscan_tid[2] & lsu_stb_empty[2] |
1307
  ctu_sscan_tid[3] & lsu_stb_empty[3] ;
1308
 
1309
 
1310
// Monitors outstanding long-latency asi transactions - hangs thread. Doesn't cover all asi.
1311
assign  sscan_data_14 =
1312
                ctu_sscan_tid[0] & (tlb_ld_inst0 | tlb_st_inst0) |
1313
                ctu_sscan_tid[1] & (tlb_ld_inst1 | tlb_st_inst1) |
1314
                        ctu_sscan_tid[2] & (tlb_ld_inst2 | tlb_st_inst2) |
1315
                ctu_sscan_tid[3] & (tlb_ld_inst3 | tlb_st_inst3) ;
1316
 
1317
 
1318 113 albert.wat
dff_s #(2) stg_d1 (
1319 95 fafa1971
  .din ({sscan_data_14,sscan_data_13}),
1320
  .q   (lsu_sscan_data[14:13]),
1321
  .clk (clk),
1322 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1323 95 fafa1971
);
1324
 
1325
//=========================================================================================
1326
//  INST_VLD_W GENERATION
1327
//=========================================================================================
1328
 
1329
wire    flush_w_inst_vld_m ;
1330
wire    lsu_inst_vld_w ;
1331
assign  flush_w_inst_vld_m =
1332
        ifu_tlu_inst_vld_m &
1333
        ~(dctl_flush_pipe_w & (thrid_m[1:0] == thrid_g[1:0])) ; // really lsu_flush_pipe_w
1334
 
1335 113 albert.wat
dff_s  stgw_ivld (
1336 95 fafa1971
        .din    (flush_w_inst_vld_m),
1337
        .q      (lsu_inst_vld_w),
1338
        .clk    (clk),
1339 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1340 95 fafa1971
        );
1341
 
1342
 
1343
// Specifically for qctl2. Does not include flush-pipe, but does include ifu's flush.
1344
wire    ld_vld ;
1345
 
1346
   wire ifu_lsu_flush_w;
1347
 
1348
   wire ifu_tlu_flush_fd_w_q, ifu_tlu_flush_fd2_w_q, ifu_tlu_flush_fd3_w_q;
1349
 
1350 113 albert.wat
dff_s #(4) ifu_tlu_flush_stgw (
1351 95 fafa1971
        .din    ({ifu_tlu_flush_m,ifu_tlu_flush_m,     ifu_tlu_flush_m,      ifu_tlu_flush_m}     ),
1352
        .q      ({ifu_lsu_flush_w,ifu_tlu_flush_fd_w_q,ifu_tlu_flush_fd2_w_q,ifu_tlu_flush_fd3_w_q}),
1353
        .clk    (clk),
1354 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1355 95 fafa1971
        );
1356
 
1357
bw_u1_buf_30x UZfix_ifu_tlu_flush_fd_w  ( .a(ifu_tlu_flush_fd_w_q),  .z(ifu_tlu_flush_fd_w)  );
1358
bw_u1_buf_30x UZfix_ifu_tlu_flush_fd2_w ( .a(ifu_tlu_flush_fd2_w_q), .z(ifu_tlu_flush_fd2_w) );
1359
bw_u1_buf_30x UZfix_ifu_tlu_flush_fd3_w ( .a(ifu_tlu_flush_fd3_w_q), .z(ifu_tlu_flush_fd3_w) );
1360
 
1361
assign  ld_vld = ld_inst_vld_unflushed & lsu_inst_vld_w & ~ifu_lsu_flush_w ;
1362
wire    ld_vld_w_flush ;
1363
assign  ld_vld_w_flush = ld_vld & ~dctl_flush_pipe_w ;
1364
assign  lsu_ld_inst_vld_g[0] = ld_vld_w_flush & thread0_g ;
1365
assign  lsu_ld_inst_vld_g[1] = ld_vld_w_flush & thread1_g ;
1366
assign  lsu_ld_inst_vld_g[2] = ld_vld_w_flush & thread2_g ;
1367
assign  lsu_ld_inst_vld_g[3] = ld_vld_w_flush & thread3_g ;
1368
 
1369
//=========================================================================================
1370
//  TLB Control 
1371
//=========================================================================================
1372
 
1373
wire    alt_space_e ;
1374 113 albert.wat
dff_s #(1) aspace_e (
1375 95 fafa1971
        .din    (ifu_lsu_alt_space_d),
1376
        .q      (alt_space_e),
1377
        .clk    (clk),
1378 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1379 95 fafa1971
        );
1380
 
1381
//Atomics require translation.
1382
assign tlb_ldst_cam_vld =
1383
  memref_e &
1384
    ~dtlb_bypass_e & ~(asi_internal_e & alt_space_e)  ;
1385
 
1386
// in hyper-lite mode, assumption is that real translation is not supported -
1387
// a miss in tlb with real-translation enabled would result in real-address
1388
// translation miss. This would be purely accidental on software's part.
1389
//wire  dtlb_real_byp_e ;
1390
//assign        dtlb_real_byp_e = hpstate_en_e & ~hpv_priv_e ;
1391
// In hyper-lite mode, no concept of real xslation.
1392
assign  lsu_dtlb_cam_real_e =
1393
        // lsu-ctl based RA->PA 
1394
  ( lsuctl_dtlb_byp_e & ~hpv_priv_e & hpstate_en_e) |
1395
        // means RA->PA if used by hypervisor.
1396
  ( tlb_byp_asi_e & hpstate_en_e & altspace_ldst_e) ;
1397
  //( tlb_byp_asi_e & dtlb_real_byp_e & altspace_ldst_e) ;  
1398
 
1399
assign  demap_thread0 = ~tlb_demap_thrid[1] & ~tlb_demap_thrid[0] ;
1400
assign  demap_thread1 = ~tlb_demap_thrid[1] &  tlb_demap_thrid[0] ;
1401
assign  demap_thread2 =  tlb_demap_thrid[1] & ~tlb_demap_thrid[0] ;
1402
assign  demap_thread3 =  tlb_demap_thrid[1] &  tlb_demap_thrid[0] ;
1403
 
1404
// demap access and regular ldst access to tlb are assumed to
1405
// be mutex.
1406
assign thread0_ctxt =   ( demap_thread0 & tlb_demap_vld) |
1407
      (~tlb_demap_vld & thread0_e) ;
1408
      //(thread0_e & memref_e) ;
1409
assign thread1_ctxt =   ( demap_thread1 & tlb_demap_vld) |
1410
      (~tlb_demap_vld & thread1_e) ;
1411
      //(thread1_e & memref_e) ;
1412
assign thread2_ctxt =   ( demap_thread2 & tlb_demap_vld) |
1413
      (~tlb_demap_vld & thread2_e) ;
1414
      //(thread2_e & memref_e) ;
1415
assign thread3_ctxt =   ( demap_thread3 & tlb_demap_vld) |
1416
      (~tlb_demap_vld & thread3_e) ;
1417
      //(thread3_e & memref_e) ;
1418
 
1419
assign  altspace_ldst_e   = memref_e &  alt_space_e ;
1420
assign  non_altspace_ldst_e = memref_e & ~alt_space_e ;
1421
 
1422 113 albert.wat
dff_s #(2) aspace_stgm (
1423 95 fafa1971
        .din    ({altspace_ldst_e,non_altspace_ldst_e}),
1424
        .q      ({altspace_ldst_m,non_altspace_ldst_m}),
1425
        .clk    (clk),
1426 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1427 95 fafa1971
        );
1428
 
1429 113 albert.wat
dff_s #(2) aspace_stgg (
1430 95 fafa1971
        .din    ({altspace_ldst_m,non_altspace_ldst_m}),
1431
        .q      ({altspace_ldst_g,non_altspace_ldst_g}),
1432
        .clk    (clk),
1433 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1434 95 fafa1971
        );
1435
 
1436
wire    [3:0]    tl_zero_d1 ;
1437 113 albert.wat
dff_s #(4) tlz_stgd1 (
1438 95 fafa1971
        .din    (tlu_lsu_tl_zero[3:0]),
1439
        .q      (tl_zero_d1[3:0]),
1440
        .clk    (clk),
1441 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1442 95 fafa1971
        );
1443
 
1444
mux4ds  #(1) trap_level_zero_mux (
1445
        .in0    (tl_zero_d1[0]),
1446
        .in1    (tl_zero_d1[1]),
1447
        .in2    (tl_zero_d1[2]),
1448
        .in3    (tl_zero_d1[3]),
1449
        .sel0   (thread0_e),
1450
        .sel1   (thread1_e),
1451
        .sel2   (thread2_e),
1452
        .sel3   (thread3_e),
1453
        .dout   (thread_tl_zero)
1454
);
1455
 
1456
wire    thread_tl_zero_m ;
1457 113 albert.wat
dff_s #(1) ttlz_stgm (
1458 95 fafa1971
        .din    (thread_tl_zero),
1459
        .q      (thread_tl_zero_m),
1460
        .clk    (clk),
1461 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1462 95 fafa1971
        );
1463
 
1464
 
1465
assign  lsu_nonalt_nucl_access_m = non_altspace_ldst_m & ~thread_tl_zero_m ;
1466
 
1467
// Note : autodemap will need to be or'ed into tlb_demap_vld !!!
1468
// use of tlu_lsu_tl_zero needs to be threaded.
1469
assign  thread_pctxt =  ( tlb_demap_pctxt     &  tlb_demap_vld)      |  // demap
1470
      ( non_altspace_ldst_e &  thread_tl_zero) |  // ldst. non-alt- space
1471
      ( altspace_ldst_e     &  primary_asi_e)      |  // ldst. alt_space
1472
      (~(memref_e | tlb_demap_vld)) ; // default for pipe
1473
      //(~(ld_inst_vld_e | st_inst_vld_e | tlb_demap_vld)) ; // default for pipe
1474
assign  thread_sctxt =  ( tlb_demap_sctxt     &  tlb_demap_vld)      |  // demap
1475
      ( altspace_ldst_e     &  secondary_asi_e) ; // ldst. alt_space
1476
assign  thread_nctxt =  ( tlb_demap_nctxt     &  tlb_demap_vld)      |  // demap
1477
      ( non_altspace_ldst_e & ~thread_tl_zero) |  // ldst. non-alt- space
1478
      ( altspace_ldst_e     &  nucleus_asi_e) ; // ldst. alt_space
1479
assign  thread_actxt =  tlb_demap_actxt & tlb_demap_vld ;
1480
 
1481
//tmp
1482
   wire thread_default;
1483
   assign thread_default = ~(thread_pctxt | thread_sctxt | thread_actxt);
1484
 
1485
wire    [3:0]    pstate_am ;
1486 113 albert.wat
dff_s #(4) psam_stgd1 (
1487 95 fafa1971
        .din    (tlu_lsu_pstate_am[3:0]),
1488
        .q      (pstate_am[3:0]),
1489
        .clk    (clk),
1490 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1491 95 fafa1971
        );
1492
 
1493
//assign  lsu_dtlb_addr_mask_l_e = 
1494
//  thread0_e ? ~pstate_am[0] :
1495
//    thread1_e ? ~pstate_am[1] :
1496
//      thread2_e ? ~pstate_am[2] :
1497
//          ~pstate_am[3] ;
1498
 
1499
mux4ds  #(1) pstate_am_mux (
1500
        .in0    (~pstate_am[0]),
1501
        .in1    (~pstate_am[1]),
1502
        .in2    (~pstate_am[2]),
1503
        .in3    (~pstate_am[3]),
1504
        .sel0   (thread0_e),
1505
        .sel1   (thread1_e),
1506
        .sel2   (thread2_e),
1507
        .sel3   (thread3_e),
1508
        .dout   (lsu_dtlb_addr_mask_l_e)
1509
);
1510
 
1511
//=========================================================================================
1512
//  TLB RD/WR/DMP HANDLING
1513
//=========================================================================================
1514
 
1515
// To speed up the tlb miss handler, wr_vld will now be generated based on
1516
// admp occurence. lsu_dtlb_wr_vld_g is to be ignored. The following paths
1517
// can be improved
1518
// admp->write initiation (+2)
1519
// write->completion initiation (+3)
1520
 
1521
wire admp_write ;
1522
assign  admp_write = lsu_dtlb_dmp_vld_e & tlb_demap_actxt ;
1523
wire admp_rst ;
1524
assign  admp_rst = reset | lsu_dtlb_wr_vld_e ;
1525
 
1526
wire    local_dtlb_wr_vld_g ;
1527 113 albert.wat
dffre_s #(1) twr_stgd1 (
1528 95 fafa1971
        .din    (admp_write),
1529
        .q      (local_dtlb_wr_vld_g),
1530
        .clk    (clk),
1531
        .en     (admp_write),   .rst    (admp_rst),
1532 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1533 95 fafa1971
        );
1534
 
1535
 
1536
wire    dtlb_wr_init_d1,dtlb_wr_init_d2,dtlb_wr_init_d3 ;
1537
// Handshake between tlu and lsu needs to be fine-tuned !!!
1538
assign  lsu_dtlb_wr_vld_e =  local_dtlb_wr_vld_g & ~(memref_e | dtlb_wr_init_d1 | dtlb_wr_init_d2) ;
1539
//assign  lsu_dtlb_wr_vld_e =  tlu_dtlb_wr_vld_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1540
assign  lsu_dtlb_tag_rd_e =  tlu_dtlb_tag_rd_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1541
assign  lsu_dtlb_data_rd_e =  tlu_dtlb_data_rd_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1542
assign  lsu_dtlb_dmp_vld_e =  tlu_dtlb_dmp_vld_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1543
 
1544
   wire lsu_dtlb_dmp_all_e_tmp;
1545
 
1546
assign  lsu_dtlb_dmp_all_e_tmp =  tlu_dtlb_dmp_all_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1547
 bw_u1_buf_5x UZsize_lsu_dtlb_dmp_all_e (.a(lsu_dtlb_dmp_all_e_tmp), .z(lsu_dtlb_dmp_all_e));
1548
 
1549
assign  lsu_dtlb_rwindex_vld_e =  tlu_dtlb_rw_index_vld_g & ~(memref_e | dtlb_wr_init_d1 | dtlb_wr_init_d2) ;
1550
//assign  lsu_dtlb_rwindex_vld_e =  tlu_dtlb_rw_index_vld_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1551
// Can remove reset once invalidate asi in place !!!
1552
// assign lsu_dtlb_invalid_all_w2 = reset | tlu_dtlb_invalidate_all_g ;
1553
 
1554
assign  tlb_demap_vld = lsu_dtlb_dmp_vld_e ;
1555
 
1556
// Switchout for threads. Force threads to swo if tlb operation does not occur for over 5 cycles.
1557
 
1558 113 albert.wat
dff_s #(5) tlbop_stgd1 (
1559 95 fafa1971
        //.din    ({tlu_dtlb_wr_vld_g,tlu_dtlb_tag_rd_g,tlu_dtlb_data_rd_g,tlu_dtlb_dmp_vld_g,
1560
        .din    ({local_dtlb_wr_vld_g,tlu_dtlb_tag_rd_g,tlu_dtlb_data_rd_g,tlu_dtlb_dmp_vld_g,
1561
    tlu_dtlb_invalidate_all_g}),
1562
        .q      ({dtlb_wr_vld_d1,dtlb_tag_rd_d1,dtlb_data_rd_d1,dtlb_dmp_vld_d1,
1563
    dtlb_inv_all_d1}),
1564
        .clk    (clk),
1565 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1566 95 fafa1971
        );
1567
 
1568
// Detect event.
1569
//bug6193 / ECO bug6511   
1570
assign  ldst_in_pipe = memref_e ;
1571
assign tlbop_init =
1572
  ((~dtlb_wr_vld_d1 & local_dtlb_wr_vld_g)  |
1573
  (~dtlb_tag_rd_d1  & tlu_dtlb_tag_rd_g)   |
1574
  (~dtlb_data_rd_d1 & tlu_dtlb_data_rd_g) |
1575
  (~dtlb_inv_all_d1 & tlu_dtlb_invalidate_all_g) |
1576
  (~dtlb_dmp_vld_d1 & tlu_dtlb_dmp_vld_g)) & ldst_in_pipe ;
1577
 
1578 113 albert.wat
dff_s #(1) tlbinit_stgd1 ( .din    (tlbop_init), .q      (tlbop_init_d1),
1579
        .clk    (clk), .se     (se),       `SIMPLY_RISC_SCANIN,          .so ());
1580
dff_s #(1) tlbinit_stgd2 ( .din    (tlbop_init_d1 &  ldst_in_pipe), .q      (tlbop_init_d2),
1581
        .clk    (clk), .se     (se),       `SIMPLY_RISC_SCANIN,          .so ());
1582
dff_s #(1) tlbinit_stgd3 ( .din    (tlbop_init_d2 &  ldst_in_pipe), .q      (tlbop_init_d3),
1583
        .clk    (clk), .se     (se),       `SIMPLY_RISC_SCANIN,          .so ());
1584
dff_s #(1) tlbinit_stgd4 ( .din    (tlbop_init_d3 &  ldst_in_pipe), .q      (tlbop_init_d4),
1585
        .clk    (clk), .se     (se),       `SIMPLY_RISC_SCANIN,          .so ());
1586
dff_s #(1) tlbinit_stgd5 ( .din    (tlbop_init_d4 &  ldst_in_pipe), .q      (tlbop_init_d5),
1587
        .clk    (clk), .se     (se),       `SIMPLY_RISC_SCANIN,          .so ());
1588 95 fafa1971
 
1589
 
1590
assign  lsu_tlbop_force_swo = tlbop_init_d5 & ldst_in_pipe ;
1591
 
1592
//assign  dtlb_done =   lsu_dtlb_wr_vld_e  | lsu_dtlb_tag_rd_e | 
1593
assign  dtlb_done =     lsu_dtlb_tag_rd_e | lsu_dtlb_data_rd_e |
1594
                        lsu_dtlb_dmp_vld_e | dtlb_inv_all_e ;
1595
 
1596
assign  dtlb_inv_all_e = tlu_dtlb_invalidate_all_g & ~(memref_e | dtlb_done_d1 | dtlb_done_d2) ;
1597
 
1598 113 albert.wat
dff_s #(3) dn_stgd1 (
1599 95 fafa1971
        .din    ({dtlb_done,lsu_dtlb_tag_rd_e,lsu_dtlb_data_rd_e}),
1600
        .q      ({dtlb_done_d1,tag_rd_vld_m,data_rd_vld_m}),
1601
        .clk    (clk),
1602 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1603 95 fafa1971
        );
1604
 
1605
wire    dtlb_inv_all_din ;
1606
assign  dtlb_inv_all_din = sehold ? dtlb_inv_all_m : dtlb_inv_all_e ;
1607
 
1608 113 albert.wat
dff_s #(1) dinv_stgd1 (
1609 95 fafa1971
        .din    (dtlb_inv_all_din),
1610
        .q      (dtlb_inv_all_m),
1611
        .clk    (clk),
1612 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1613 95 fafa1971
        );
1614
 
1615
assign  lsu_dtlb_invalid_all_m = dtlb_inv_all_m ;
1616
// added by sureshT
1617
assign  lsu_dtlb_invalid_all_l_m = ~lsu_dtlb_invalid_all_m;
1618
 
1619 113 albert.wat
dff_s #(3) dn_stgd2 (
1620 95 fafa1971
        .din    ({dtlb_done_d1,tag_rd_vld_m,data_rd_vld_m}),
1621
        .q      ({dtlb_done_d2,tag_rd_vld_g,data_rd_vld_g}),
1622
        .clk    (clk),
1623 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1624 95 fafa1971
        );
1625
 
1626
assign  lsu_tlb_data_rd_vld_g = data_rd_vld_g ;
1627
assign  lsu_tlb_tag_rd_vld_g  = tag_rd_vld_g ;
1628
//assign  lsu_tlb_st_vld_g = ~lsu_tlb_tag_rd_vld_g & ~lsu_tlb_data_rd_vld_g ;
1629
 
1630
// The handshake will have to change !!!
1631
assign  lsu_tlu_dtlb_done =
1632
        dtlb_done_d2 |          // rest
1633
        dtlb_wr_init_d3 ;       // write
1634
 
1635
// Note : if mx_sel bit is high, then it selects va instead of pa.
1636
 
1637
 
1638
 
1639
//=========================================================================================
1640
//  State/ASI Registers.
1641
//=========================================================================================
1642
 
1643 113 albert.wat
dff_s #(8) stctl_stg_e (
1644 95 fafa1971
        .din    ({ifu_tlu_sraddr_d[6:0],ifu_tlu_wsr_inst_d}),
1645
        .q      ({lsu_sraddr_e[6:0],    lsu_wsr_inst_e}),
1646
        .clk    (clk),
1647 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1648 95 fafa1971
        );
1649
 
1650
assign lsu_tlu_wsr_inst_e = lsu_wsr_inst_e;
1651
 
1652
   wire asi_state_wr_en_e, asi_state_wr_en_m;
1653
 
1654
assign  asi_state_wr_en_e =
1655
              ~lsu_sraddr_e[6] &  // 1=hypervisor
1656
              ~lsu_sraddr_e[5] &  // =0 for state reg. 
1657
        ~lsu_sraddr_e[4] & ~lsu_sraddr_e[3] &
1658
        ~lsu_sraddr_e[2] &  lsu_sraddr_e[1] &
1659
         lsu_sraddr_e[0] &
1660
         lsu_wsr_inst_e ; // write
1661
 
1662 113 albert.wat
dff_s #(2) stctl_stg_m (
1663 95 fafa1971
        .din    ({asi_state_wr_en_e, alt_space_e}),
1664
        .q      ({asi_state_wr_en_m, lsu_alt_space_m}),
1665
        .clk    (clk),
1666 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1667 95 fafa1971
        );
1668
 
1669 113 albert.wat
dff_s #(2) stctl_stg_w (
1670 95 fafa1971
        .din    ({asi_state_wr_en_m, lsu_alt_space_m}),
1671
        .q      ({asi_state_wr_en,   lsu_alt_space_g}),
1672
        .clk    (clk),
1673 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1674 95 fafa1971
        );
1675
 
1676
//assign  asi_state_wr_en =   
1677
//      ~lsu_sraddr_w[6] &  // 1=hypervisor
1678
//      ~lsu_sraddr_w[5] &  // =0 for state reg. 
1679
//        ~lsu_sraddr_w[4] & ~lsu_sraddr_w[3] & 
1680
//        ~lsu_sraddr_w[2] &  lsu_sraddr_w[1] & 
1681
//         lsu_sraddr_w[0] &  
1682
//         lsu_wsr_inst_w ; // write
1683
 
1684
 
1685 113 albert.wat
dff_s #(3) asi_stgw (
1686 95 fafa1971
        .din    ({tlu_lsu_asi_update_m,tlu_lsu_tid_m[1:0]}),
1687
        .q      ({tlu_lsu_asi_update_g,tlu_lsu_tid_g[1:0]}),
1688
        .clk    (clk),
1689 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1690 95 fafa1971
        );
1691
 
1692
 
1693
assign  tsa_update_asi0 =  ~tlu_lsu_tid_g[1] & ~tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
1694
assign  tsa_update_asi1 =  ~tlu_lsu_tid_g[1] &  tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
1695
assign  tsa_update_asi2 =   tlu_lsu_tid_g[1] & ~tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
1696
assign  tsa_update_asi3 =   tlu_lsu_tid_g[1] &  tlu_lsu_tid_g[0] & tlu_lsu_asi_update_g ;
1697
 
1698
assign  asi_state_wr_thrd[0] =
1699
((asi_state_wr_en & thread0_g) | tsa_update_asi0) & lsu_inst_vld_w & ~dctl_early_flush_w ;
1700
//((asi_state_wr_en & thread0_g) | tsa_update_asi0) & lsu_inst_vld_w & ~lsu_flush_pipe_w ;
1701
assign  asi_state_wr_thrd[1] =
1702
((asi_state_wr_en & thread1_g) | tsa_update_asi1) & lsu_inst_vld_w & ~dctl_early_flush_w ;
1703
assign  asi_state_wr_thrd[2] =
1704
((asi_state_wr_en & thread2_g) | tsa_update_asi2) & lsu_inst_vld_w & ~dctl_early_flush_w ;
1705
assign  asi_state_wr_thrd[3] =
1706
((asi_state_wr_en & thread3_g) | tsa_update_asi3) & lsu_inst_vld_w & ~dctl_early_flush_w ;
1707
 
1708
// dc diagnstc will swo on write.                                                       
1709
assign  sta_internal_e = asi_internal_e & st_inst_vld_e & alt_space_e ;
1710
// dc diagnstc will not swo on read.                                                    
1711
assign  lda_internal_e = asi_internal_e & ~dc_diagnstc_asi_e & ld_inst_vld_e & alt_space_e ;
1712
 
1713
assign  ldsta_internal_e = sta_internal_e | lda_internal_e ;
1714
 
1715
// MMU_ASI
1716
// Do no switch out for lds. lds switched out thru ldst_miss.
1717
// qualification must be removed.
1718
assign  lsu_ifu_ldsta_internal_e = asi_internal_e ;
1719
//assign  lsu_ifu_ldsta_internal_e = asi_internal_e & ~ld_inst_vld_e  ;
1720
 
1721
 
1722 113 albert.wat
dff_s #(2)  stai_stgm (
1723 95 fafa1971
        .din    ({sta_internal_e,lda_internal_e}),
1724
        .q      ({sta_internal_m,lda_internal_m}),
1725
        .clk    (clk),
1726 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1727 95 fafa1971
        );
1728
 
1729
   wire stxa_internal_m;
1730
   assign stxa_internal_m = sta_internal_m & ~(dtagv_diagnstc_asi_m | dc_diagnstc_asi_m);
1731
 
1732 113 albert.wat
dff_s #(2)  stai_stgg (
1733 95 fafa1971
        .din    ({stxa_internal_m, lda_internal_m}),
1734
        .q      ({stxa_internal,   ldxa_internal}),
1735
        .clk    (clk),
1736 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1737 95 fafa1971
        );
1738
 
1739
   wire [7:0] ldst_va_g;
1740
 
1741
   assign ldst_va_g[7:0] = lsu_ldst_va_g[7:0];
1742
 
1743
   wire [7:0]    lsu_asi_state ;
1744 113 albert.wat
dff_s #(8)  asistate_stgg (
1745 95 fafa1971
        .din    (lsu_dctl_asi_state_m[7:0]),
1746
        .q      (lsu_asi_state[7:0]),
1747
        .clk    (clk),
1748 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1749 95 fafa1971
        );
1750
 
1751
assign  pctxt_va_vld = (ldst_va_g[7:0] == 8'h08) ;
1752
assign  pctxt_state_en =  (lsu_asi_state[7:0] == 8'h21) & pctxt_va_vld &
1753
        lsu_alt_space_g & lsu_inst_vld_w ;
1754
 
1755
 
1756
//assign  pctxt_state_wr_thrd[0] = pctxt_state_en & st_inst_vld_g & thread0_g ;
1757
assign  pctxt_state_wr_thrd[0] = pctxt_state_en & asi_st_vld_g & thread0_g ;
1758
assign  pctxt_state_wr_thrd[1] = pctxt_state_en & asi_st_vld_g & thread1_g ;
1759
assign  pctxt_state_wr_thrd[2] = pctxt_state_en & asi_st_vld_g & thread2_g ;
1760
assign  pctxt_state_wr_thrd[3] = pctxt_state_en & asi_st_vld_g & thread3_g ;
1761
 
1762
//assign  pctxt_state_rd_en[0] = pctxt_state_en & ld_inst_vld_g & thread0_g ;
1763
 
1764
//assign  pctxt_state_rd_en[0] = pctxt_state_en & asi_ld_vld_g & thread0_g ;
1765
//assign  pctxt_state_rd_en[1] = pctxt_state_en & asi_ld_vld_g & thread1_g ;
1766
//assign  pctxt_state_rd_en[2] = pctxt_state_en & asi_ld_vld_g & thread2_g ;
1767
//assign  pctxt_state_rd_en[3] = pctxt_state_en & asi_ld_vld_g & thread3_g ;
1768
 
1769
 
1770
assign  sctxt_va_vld = (ldst_va_g[7:0] == 8'h10) ;
1771
assign  sctxt_state_en =  (lsu_asi_state[7:0] == 8'h21) & sctxt_va_vld &
1772
        lsu_alt_space_g & lsu_inst_vld_w ;
1773
 
1774
assign  pscxt_ldxa_illgl_va =
1775
        (lsu_asi_state[7:0] == 8'h21) & ~(pctxt_va_vld | sctxt_va_vld) &
1776
        lsu_alt_space_g & lsu_inst_vld_w ;
1777
 
1778
//assign  sctxt_state_wr_thrd[0] = sctxt_state_en & st_inst_vld_g & thread0_g ;
1779
assign  sctxt_state_wr_thrd[0] = sctxt_state_en & asi_st_vld_g & thread0_g ;
1780
assign  sctxt_state_wr_thrd[1] = sctxt_state_en & asi_st_vld_g & thread1_g ;
1781
assign  sctxt_state_wr_thrd[2] = sctxt_state_en & asi_st_vld_g & thread2_g ;
1782
assign  sctxt_state_wr_thrd[3] = sctxt_state_en & asi_st_vld_g & thread3_g ;
1783
 
1784
//assign  sctxt_state_rd_en[0]   = sctxt_state_en & ld_inst_vld_g & thread0_g ;
1785
 
1786
//assign  sctxt_state_rd_en[0]   = sctxt_state_en & asi_ld_vld_g & thread0_g ;
1787
//assign  sctxt_state_rd_en[1]   = sctxt_state_en & asi_ld_vld_g & thread1_g ;
1788
//assign  sctxt_state_rd_en[2]   = sctxt_state_en & asi_ld_vld_g & thread2_g ;
1789
//assign  sctxt_state_rd_en[3]   = sctxt_state_en & asi_ld_vld_g & thread3_g ;
1790
 
1791
 
1792
// LSU CONTROL REGISTER. ASI=0x45,VA=0x00.
1793
// b0 - i$ enable.
1794
// b1 - d$ enable. 
1795
// b2 - immu enable.
1796
// b3 - dmmu enable.
1797
 
1798
assign  lsuctl_va_vld = (ldst_va_g[7:0] == 8'h00);
1799
assign  lsu_ctl_state_en = (lsu_asi_state[7:0] == 8'h45) & lsuctl_va_vld &
1800
        lsu_alt_space_g & lsu_inst_vld_w ;
1801
assign  lsuctl_illgl_va = (lsu_asi_state[7:0] == 8'h45) & ~lsuctl_va_vld &
1802
        lsu_alt_space_g & lsu_inst_vld_w ;
1803
 
1804
wire  [3:0] lctl_rst ;
1805
 
1806
//assign  lsu_ctl_state_wr_en[0] = (lsu_ctl_state_en & st_inst_vld_g & thread0_g) | lctl_rst[0] ;
1807
assign  lsu_ctl_state_wr_en[0] = (lsu_ctl_state_en & asi_st_vld_g & thread0_g) | lctl_rst[0] ;
1808
assign  lsu_ctl_state_wr_en[1] = (lsu_ctl_state_en & asi_st_vld_g & thread1_g) | lctl_rst[1] ;
1809
assign  lsu_ctl_state_wr_en[2] = (lsu_ctl_state_en & asi_st_vld_g & thread2_g) | lctl_rst[2];
1810
assign  lsu_ctl_state_wr_en[3] = (lsu_ctl_state_en & asi_st_vld_g & thread3_g) | lctl_rst[3];
1811
 
1812
//assign  lsu_ctl_state_rd_en[0] = lsu_ctl_state_en & ld_inst_vld_g & thread0_g ;
1813
//assign  lsu_ctl_state_rd_en[0] = lsu_ctl_state_en & asi_ld_vld_g & thread0_g ;
1814
//assign  lsu_ctl_state_rd_en[1] = lsu_ctl_state_en & asi_ld_vld_g & thread1_g ;
1815
//assign  lsu_ctl_state_rd_en[2] = lsu_ctl_state_en & asi_ld_vld_g & thread2_g ;
1816
//assign  lsu_ctl_state_rd_en[3] = lsu_ctl_state_en & asi_ld_vld_g & thread3_g ;
1817
 
1818
 
1819
 
1820
wire    [3:0]    redmode_rst ;
1821
//dff #(4) rdmode_stgd1 (
1822
//        .din    ({tlu_lsu_redmode_rst[3:0]}),
1823
//        .q      ({redmode_rst[3:0]}),
1824
//        .clk    (clk),
1825 113 albert.wat
//        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1826 95 fafa1971
//        );  
1827
 
1828
   assign   redmode_rst[3:0] =  tlu_lsu_redmode_rst_d1[3:0];
1829
 
1830
assign  lctl_rst[0] = redmode_rst[0] | reset ;
1831
assign  lctl_rst[1] = redmode_rst[1] | reset ;
1832
assign  lctl_rst[2] = redmode_rst[2] | reset ;
1833
assign  lctl_rst[3] = redmode_rst[3] | reset ;
1834
 
1835
assign  lsuctl_ctlbits_wr_en[0] = lsu_ctl_state_wr_en[0] | dfture_tap_wr_en[0] | lctl_rst[0];
1836
assign  lsuctl_ctlbits_wr_en[1] = lsu_ctl_state_wr_en[1] | dfture_tap_wr_en[1] | lctl_rst[1];
1837
assign  lsuctl_ctlbits_wr_en[2] = lsu_ctl_state_wr_en[2] | dfture_tap_wr_en[2] | lctl_rst[2];
1838
assign  lsuctl_ctlbits_wr_en[3] = lsu_ctl_state_wr_en[3] | dfture_tap_wr_en[3] | lctl_rst[3];
1839
 
1840
   assign dfture_tap_wr_mx_sel = | dfture_tap_wr_en[3:0];
1841
 
1842
// Could enhance bypass/enable conditions by adding all asi conditions.  
1843
wire   [5:0] lsu_ctl_reg0;
1844
wire   [5:0] lsu_ctl_reg1;
1845
wire   [5:0] lsu_ctl_reg2;
1846
wire   [5:0] lsu_ctl_reg3;
1847
 
1848
   assign lsu_ctl_reg0[5:0] = lsu_dp_ctl_reg0[5:0];
1849
   assign lsu_ctl_reg1[5:0] = lsu_dp_ctl_reg1[5:0];
1850
   assign lsu_ctl_reg2[5:0] = lsu_dp_ctl_reg2[5:0];
1851
   assign lsu_ctl_reg3[5:0] = lsu_dp_ctl_reg3[5:0];
1852
 
1853
wire lsu_dcache_enable;
1854
assign lsu_dcache_enable =
1855
  ((lsu_ctl_reg0[1] & thread0_e) | (lsu_ctl_reg1[1] & thread1_e)  |
1856
   (lsu_ctl_reg2[1] & thread2_e) | (lsu_ctl_reg3[1] & thread3_e)) ;
1857
 
1858
assign  lsuctl_dtlb_byp_e =
1859
  (~lsu_ctl_reg0[3] & thread0_e) | (~lsu_ctl_reg1[3] & thread1_e) |
1860
  (~lsu_ctl_reg2[3] & thread2_e) | (~lsu_ctl_reg3[3] & thread3_e) ;
1861
assign dtlb_bypass_e =
1862
  (lsuctl_dtlb_byp_e & ~hpstate_en_e) | // hpv enabled - byp is RA->PA for supv.
1863
  ( tlb_byp_asi_e & ~hpstate_en_e & altspace_ldst_e) |  // altspace tlb bypass - non-hpv
1864
    ((hpv_priv_e & hpstate_en_e) & ~(alt_space_e & (as_if_user_asi_e | tlb_byp_asi_e)));
1865
        // hpv enabled VA->PA 
1866
 
1867
assign  lsu_dtlb_bypass_e = dtlb_bypass_e ;
1868
wire  dcache_enable_m,dcache_enable_g ;
1869 113 albert.wat
dff_s #(2) dbyp_stgm (
1870 95 fafa1971
        .din    ({dtlb_bypass_e,lsu_dcache_enable}),
1871
        .q      ({dtlb_bypass_m,dcache_enable_m}),
1872
        .clk    (clk),
1873 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1874 95 fafa1971
        );
1875
 
1876 113 albert.wat
dff_s #(2) dbyp_stgg (
1877 95 fafa1971
        .din    ({dtlb_bypass_m,dcache_enable_m}),
1878
        .q      ({lsu_dtlb_bypass_g,dcache_enable_g}),
1879
        .clk    (clk),
1880 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1881 95 fafa1971
        );
1882
 
1883
   wire lsu_ctl_reg0_bf_b0, lsu_ctl_reg1_bf_b0, lsu_ctl_reg2_bf_b0, lsu_ctl_reg3_bf_b0;
1884
   wire lsu_ctl_reg0_bf_b2, lsu_ctl_reg1_bf_b2, lsu_ctl_reg2_bf_b2, lsu_ctl_reg3_bf_b2;
1885
 
1886
bw_u1_buf_1x UZsize_ctl_reg0_b0  ( .a(lsu_ctl_reg0[0]),  .z(lsu_ctl_reg0_bf_b0)  );
1887
bw_u1_buf_1x UZsize_ctl_reg0_b2  ( .a(lsu_ctl_reg0[2]),  .z(lsu_ctl_reg0_bf_b2)  );
1888
bw_u1_buf_1x UZsize_ctl_reg1_b0  ( .a(lsu_ctl_reg1[0]),  .z(lsu_ctl_reg1_bf_b0)  );
1889
bw_u1_buf_1x UZsize_ctl_reg1_b2  ( .a(lsu_ctl_reg1[2]),  .z(lsu_ctl_reg1_bf_b2)  );
1890
bw_u1_buf_1x UZsize_ctl_reg2_b0  ( .a(lsu_ctl_reg2[0]),  .z(lsu_ctl_reg2_bf_b0)  );
1891
bw_u1_buf_1x UZsize_ctl_reg2_b2  ( .a(lsu_ctl_reg2[2]),  .z(lsu_ctl_reg2_bf_b2)  );
1892
bw_u1_buf_1x UZsize_ctl_reg3_b0  ( .a(lsu_ctl_reg3[0]),  .z(lsu_ctl_reg3_bf_b0)  );
1893
bw_u1_buf_1x UZsize_ctl_reg3_b2  ( .a(lsu_ctl_reg3[2]),  .z(lsu_ctl_reg3_bf_b2)  );
1894
 
1895
assign lsu_ifu_icache_en[3:0] =
1896
  {lsu_ctl_reg3_bf_b0,lsu_ctl_reg2_bf_b0,lsu_ctl_reg1_bf_b0,lsu_ctl_reg0_bf_b0} & ~tlu_lsu_redmode[3:0] ;
1897
assign lsu_ifu_itlb_en[3:0] =
1898
  {lsu_ctl_reg3_bf_b2,lsu_ctl_reg2_bf_b2,lsu_ctl_reg1_bf_b2,lsu_ctl_reg0_bf_b2} & ~tlu_lsu_redmode[3:0] ;
1899
 
1900
//=========================================================================================
1901
//  DCACHE Access thru IOBrdge
1902
//=========================================================================================
1903
 
1904
wire    iob_fwdpkt_vld ;
1905 113 albert.wat
dff_s  iobvld_stg (
1906 95 fafa1971
        .din    (lsu_iobrdge_fwd_pkt_vld),
1907
        .q      (iob_fwdpkt_vld),
1908
        .clk    (clk),
1909 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1910 95 fafa1971
        );
1911
 
1912
wire    dcache_iob_wr_e, dcache_iob_rd_e ;
1913
wire    dcache_iob_wr, dcache_iob_rd ;
1914
assign dcache_iob_wr =
1915
~lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[6] & lsu_iobrdge_fwd_pkt_vld ;
1916
assign dcache_iob_rd =
1917
 lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[6] & lsu_iobrdge_fwd_pkt_vld ;
1918
 
1919 113 albert.wat
dff_s #(2) dcrw_stge (
1920 95 fafa1971
        .din    ({dcache_iob_wr,dcache_iob_rd}),
1921
        .q      ({dcache_iob_wr_e,dcache_iob_rd_e}),
1922
        .clk    (clk),
1923 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1924 95 fafa1971
        );
1925
 
1926
assign  lsu_dc_iob_access_e = dcache_iob_wr_e | dcache_iob_rd_e ;
1927
 
1928
//=========================================================================================
1929
//  Miscellaneous ASI
1930
//=========================================================================================
1931
 
1932
// Defeature effects the asi lsu_ctl_reg.
1933
// Margin ASI
1934
// Diag  ASI - No TAP access
1935
// BIST ASI   
1936
 
1937
assign  tap_thread[0] = ~lsu_iobrdge_tap_rq_type_b1_b0[1] & ~lsu_iobrdge_tap_rq_type_b1_b0[0] ;
1938
assign  tap_thread[1] = ~lsu_iobrdge_tap_rq_type_b1_b0[1] &  lsu_iobrdge_tap_rq_type_b1_b0[0] ;
1939
assign  tap_thread[2] =  lsu_iobrdge_tap_rq_type_b1_b0[1] & ~lsu_iobrdge_tap_rq_type_b1_b0[0] ;
1940
assign  tap_thread[3] =  lsu_iobrdge_tap_rq_type_b1_b0[1] &  lsu_iobrdge_tap_rq_type_b1_b0[0] ;
1941
 
1942
wire bist_tap_rd,bist_tap_wr ;
1943
assign  bist_tap_rd =
1944
 lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[5] & iob_fwdpkt_vld ;
1945
assign  bist_tap_wr =
1946
~lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[5] & iob_fwdpkt_vld ;
1947
 
1948
/*
1949 113 albert.wat
dff_s #(2) bstrw_stge (
1950 95 fafa1971
        .din    ({bist_tap_rd,bist_tap_wr}),
1951
        .q      ({bist_tap_rd_en,bist_tap_wr_en}),
1952
        .clk    (clk),
1953 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1954 95 fafa1971
        );
1955
*/
1956 113 albert.wat
dff_s #(1) bstrw_stge (
1957 95 fafa1971
        .din    ({bist_tap_wr}),
1958
        .q      ({bist_tap_wr_en}),
1959
        .clk    (clk),
1960 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1961 95 fafa1971
        );
1962
 
1963
wire mrgn_tap_rd,mrgn_tap_wr ;
1964
assign  mrgn_tap_rd =
1965
lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[4] & iob_fwdpkt_vld ;
1966
assign  mrgn_tap_wr =
1967
~lsu_iobrdge_tap_rq_type_b8[8] & lsu_iobrdge_tap_rq_type_b6_b3[4] & iob_fwdpkt_vld ;
1968
/*
1969 113 albert.wat
dff_s #(2) mrgnrw_stge (
1970 95 fafa1971
        .din    ({mrgn_tap_rd,mrgn_tap_wr}),
1971
        .q      ({mrgn_tap_rd_en,mrgn_tap_wr_en}),
1972
        .clk    (clk),
1973 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1974 95 fafa1971
        );
1975
*/
1976 113 albert.wat
dff_s #(1) mrgnrw_stge (
1977 95 fafa1971
        .din    ({mrgn_tap_wr}),
1978
        .q      ({mrgn_tap_wr_en}),
1979
        .clk    (clk),
1980 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
1981 95 fafa1971
        );
1982
 
1983
wire  dfture_access_vld ;
1984
wire    [3:0]    dfture_tap_rd,dfture_tap_wr ;
1985
assign  dfture_access_vld = lsu_iobrdge_tap_rq_type_b6_b3[3] & iob_fwdpkt_vld ;
1986
 
1987
assign  dfture_tap_rd[0] =
1988
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[0] ;
1989
assign  dfture_tap_rd[1] =
1990
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[1] ;
1991
assign  dfture_tap_rd[2] =
1992
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[2] ;
1993
assign  dfture_tap_rd[3] =
1994
  lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[3] ;
1995
 
1996
   wire dfture_tap_rd_default;
1997
   assign dfture_tap_rd_default = ~| dfture_tap_rd[2:0];
1998
 
1999
assign  dfture_tap_wr[0] =
2000
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[0] ;
2001
assign  dfture_tap_wr[1] =
2002
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[1] ;
2003
assign  dfture_tap_wr[2] =
2004
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[2] ;
2005
assign  dfture_tap_wr[3] =
2006
  ~lsu_iobrdge_tap_rq_type_b8[8] & dfture_access_vld & tap_thread[3] ;
2007
 
2008 113 albert.wat
dff_s #(8) dftrw_stge (
2009 95 fafa1971
        .din    ({dfture_tap_rd_default, dfture_tap_rd[2:0],dfture_tap_wr[3:0]}),
2010
        .q      ({dfture_tap_rd_d1[3:0],                    dfture_tap_wr_en[3:0]}),
2011
        .clk    (clk),
2012 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2013 95 fafa1971
        );
2014
 
2015
 
2016
   assign dfture_tap_rd_en [0] = dfture_tap_rd_d1[0] & ~rst_tri_en;
2017
   assign dfture_tap_rd_en [1] = dfture_tap_rd_d1[1] & ~rst_tri_en;
2018
   assign dfture_tap_rd_en [2] = dfture_tap_rd_d1[2] & ~rst_tri_en;
2019
   assign dfture_tap_rd_en [3] = dfture_tap_rd_d1[3] | rst_tri_en;
2020
 
2021
 
2022
// BIST_Controller ASI
2023
 
2024
wire    bistctl_va_vld_m,bistctl_state_en_m;
2025
assign  bistctl_va_vld_m = (lsu_ldst_va_b7_b0_m[7:0] == 8'h00);
2026
assign  bistctl_state_en_m = (lsu_dctl_asi_state_m[7:0] == 8'h42) & bistctl_va_vld_m &
2027
        lsu_alt_space_m ;
2028 113 albert.wat
dff_s  #(2) bistdcd_stw (
2029 95 fafa1971
        .din    ({bistctl_va_vld_m,bistctl_state_en_m}),
2030
        .q      ({bistctl_va_vld,bistctl_state_en}),
2031
        .clk    (clk),
2032 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2033 95 fafa1971
        );
2034
// asi42 dealt with as a whole.
2035
/*assign  bistctl_illgl_va = (lsu_asi_state[7:0] == 8'h42) & ~bistctl_va_vld &
2036
        lsu_alt_space_g ;*/
2037
//assign  bistctl_rd_en = bistctl_state_en & asi_ld_vld_g ;
2038
assign  bistctl_wr_en = (bistctl_state_en & asi_st_vld_g) | bist_tap_wr_en ;
2039
//assign  bistctl_rd_en = bistctl_state_en & ld_inst_vld_g ;
2040
//assign  bistctl_wr_en = (bistctl_state_en & st_inst_vld_g) | bist_tap_wr_en ;
2041
 
2042
//test_stub interface. bist_tap_wr_en should exclude?
2043
assign  bist_ctl_reg_wr_en = bistctl_wr_en;
2044
 
2045
 
2046
// Self-Timed Margin Control ASI
2047
 
2048
wire    mrgnctl_va_vld_m,mrgnctl_state_en_m;
2049
assign  mrgnctl_va_vld_m = (lsu_ldst_va_b7_b0_m[7:0] == 8'h00);
2050
assign  mrgnctl_state_en_m = (lsu_dctl_asi_state_m[7:0] == 8'h44) & mrgnctl_va_vld_m &
2051
        lsu_alt_space_m ;
2052 113 albert.wat
dff_s  #(2) mrgndcd_stw (
2053 95 fafa1971
        .din    ({mrgnctl_va_vld_m,mrgnctl_state_en_m}),
2054
        .q      ({mrgnctl_va_vld,mrgnctl_state_en}),
2055
        .clk    (clk),
2056 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2057 95 fafa1971
        );
2058
 
2059
assign  mrgnctl_illgl_va = (lsu_asi_state[7:0] == 8'h44) & ~mrgnctl_va_vld &
2060
        lsu_alt_space_g ;
2061
 
2062
assign  mrgnctl_wr_en = ((mrgnctl_state_en & asi_st_vld_g) | mrgn_tap_wr_en | ~dctl_rst_l) & ~sehold; //bug 4508
2063
 
2064
// LSU Diag Reg ASI
2065
// No access from tap.
2066
wire    ldiagctl_va_vld_m,ldiagctl_state_en_m;
2067
assign  ldiagctl_va_vld_m = (lsu_ldst_va_b7_b0_m[7:0] == 8'h10);
2068
assign  ldiagctl_state_en_m = (lsu_dctl_asi_state_m[7:0] == 8'h42) & ldiagctl_va_vld_m &
2069
        lsu_alt_space_m ;
2070 113 albert.wat
dff_s  #(2) ldiagdcd_stw (
2071 95 fafa1971
        .din    ({ldiagctl_va_vld_m,ldiagctl_state_en_m}),
2072
        .q      ({ldiagctl_va_vld,ldiagctl_state_en}),
2073
        .clk    (clk),
2074 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2075 95 fafa1971
        );
2076
// asi42 dealt with as a whole.
2077
/*assign  ldiagctl_illgl_va = (lsu_asi_state[7:0] == 8'h42) & ~ldiagctl_va_vld &
2078
        lsu_alt_space_g ;*/
2079
 
2080
wire    asi42_g ;
2081
wire    ifu_asi42_flush_g ;
2082
assign  ifu_asi42_flush_g =
2083
        bistctl_state_en | ldiagctl_state_en | // lsu's asi42 should not set asi queue.
2084
        (asi42_g & asi42_illgl_va) ;            // illgl-va should not set asi queue.
2085
 
2086
//assign  ldiagctl_rd_en = ldiagctl_state_en & asi_ld_vld_g ;
2087
assign  ldiagctl_wr_en = (ldiagctl_state_en & asi_st_vld_g) | reset;
2088
//assign  ldiagctl_rd_en = ldiagctl_state_en & ld_inst_vld_g ;
2089
//assign  ldiagctl_wr_en = (ldiagctl_state_en & st_inst_vld_g) | reset;
2090
 
2091
wire  instmsk_va_vld ;
2092
assign  instmsk_va_vld = (ldst_va_g[7:0] == 8'h08);
2093
assign  asi42_g = (lsu_asi_state[7:0] == 8'h42) ;
2094
assign  asi42_illgl_va =
2095
        asi42_g &
2096
        ~(ldiagctl_va_vld | bistctl_va_vld | instmsk_va_vld) &
2097
        lsu_alt_space_g ;
2098
 
2099
 
2100
 
2101
//=========================================================================================
2102
//  Partition ID Register
2103
//=========================================================================================
2104
 
2105
// ASI=58, VA=0x80, Per thread
2106
// The pid is to be used by tlb-cam, and writes to tlb. It is kept in the lsu
2107
// as it is used by the dtlb, plus changes to mmu_dp are to be kept to a minimum.
2108
 
2109
// Trap if supervisor accesses hyperpriv asi - see supv_use_hyp. Could be incorrect.
2110
// Correct on merge to mainline.
2111
 
2112
// The VA compares can probably be shortened.
2113
assign  pid_va_vld = (ldst_va_g[7:0] == 8'h80);
2114
assign  pid_state_en = (lsu_asi_state[7:0] == 8'h58) & pid_va_vld &
2115
        lsu_alt_space_g & lsu_inst_vld_w ;
2116
//assign  pid_illgl_va = (lsu_asi_state[7:0] == 8'h58) & ~pid_va_vld &
2117
//        lsu_alt_space_g & lsu_inst_vld_w ; 
2118
 
2119
// remove reset ??
2120
//assign  pid_state_wr_en[0] = (pid_state_en & st_inst_vld_g & thread0_g) | reset ;
2121
assign  pid_state_wr_en[0] = (pid_state_en & asi_st_vld_g & thread0_g) | reset ;
2122
assign  pid_state_wr_en[1] = (pid_state_en & asi_st_vld_g & thread1_g) | reset ;
2123
assign  pid_state_wr_en[2] = (pid_state_en & asi_st_vld_g & thread2_g) | reset ;
2124
assign  pid_state_wr_en[3] = (pid_state_en & asi_st_vld_g & thread3_g) | reset ;
2125
 
2126
//assign  pid_state_rd_en[0] = pid_state_en & ld_inst_vld_g & thread0_g ;
2127
 
2128
//assign  pid_state_rd_en[0] = pid_state_en & asi_ld_vld_g & thread0_g ;
2129
//assign  pid_state_rd_en[1] = pid_state_en & asi_ld_vld_g & thread1_g ;
2130
//assign  pid_state_rd_en[2] = pid_state_en & asi_ld_vld_g & thread2_g ;
2131
//assign  pid_state_rd_en[3] = pid_state_en & asi_ld_vld_g & thread3_g ;
2132
 
2133
 
2134
//=========================================================================================
2135
//  Local LDXA Read
2136
//=========================================================================================
2137
 
2138
// Timing : rd_en changed to _en with inst_vld
2139
 
2140
//wire  [3:0] misc_ctl_sel ;
2141
wire    misc_tap_rd_sel ;
2142
/*
2143
assign  misc_tap_rd_sel = mrgn_tap_rd_en | bist_tap_rd_en |  dfture_tap_rd_sel ;
2144
assign  misc_ctl_sel[0] = bist_tap_rd_en | (~misc_tap_rd_sel &  bistctl_state_en & ld_inst_vld_unflushed) ;
2145
assign  misc_ctl_sel[1] = mrgn_tap_rd_en | (~misc_tap_rd_sel &  mrgnctl_state_en & ld_inst_vld_unflushed) ;
2146
assign  misc_ctl_sel[3] = dfture_tap_rd_sel ;
2147
 
2148
//assign  misc_ctl_sel[2] = (~misc_tap_rd_sel & ldiagctl_state_en & ld_inst_vld_unflushed) ;
2149
assign  misc_ctl_sel[2] = ~(misc_ctl_sel[0] | misc_ctl_sel[1] | misc_ctl_sel[3] ); //force default
2150
*/
2151
 
2152
//****push misc_ctl_sel in previosu cycle*****
2153
   wire [3:0] misc_ctl_sel_din;
2154
 
2155
//0-in bug, priority encode tap requests to prevent illegal type through one-hot mux   
2156
   wire       dfture_tap_rd_or ;
2157
   assign     dfture_tap_rd_or = | (dfture_tap_rd [3:0]);
2158
   assign     misc_tap_rd_sel = mrgn_tap_rd | bist_tap_rd |  dfture_tap_rd_or ;
2159
   assign     misc_ctl_sel_din[0] = bist_tap_rd |
2160
                                   (~misc_tap_rd_sel &  bistctl_state_en_m & ld_inst_vld_m) ;
2161
   assign     misc_ctl_sel_din[1] = (~bist_tap_rd & mrgn_tap_rd) |
2162
                                    (~misc_tap_rd_sel &  mrgnctl_state_en_m & ld_inst_vld_m) ;
2163
   assign     misc_ctl_sel_din[3] = ~bist_tap_rd & ~mrgn_tap_rd & dfture_tap_rd_or;
2164
   assign     misc_ctl_sel_din[2] = ~(misc_ctl_sel_din[0] | misc_ctl_sel_din[1] | misc_ctl_sel_din[3] ) ;
2165
 
2166
 
2167
 
2168
// ASI accesses should be mutex except for non-access cases.
2169
assign  lsu_asi_sel_fmx1[0] = pctxt_state_en & ld_inst_vld_unflushed;
2170
assign  lsu_asi_sel_fmx1[1] = sctxt_state_en & ld_inst_vld_unflushed & ~lsu_asi_sel_fmx1[0];
2171
assign  lsu_asi_sel_fmx1[2] = ~(|lsu_asi_sel_fmx1[1:0]);   //force default
2172
 
2173
assign  lsu_asi_sel_fmx2[0] = |lsu_asi_sel_fmx1[1:0] | (pid_state_en & ld_inst_vld_unflushed) ;
2174
assign  lsu_asi_sel_fmx2[1] = lsu_ctl_state_en & ld_inst_vld_unflushed & ~(lsu_asi_sel_fmx2[0]);
2175
assign  lsu_asi_sel_fmx2[2] = ~(|lsu_asi_sel_fmx2[1:0]) ; //force default
2176
 
2177
   wire va_wtchpt_en;
2178
 
2179
wire    lsu_asi_rd_sel ;
2180
//assign  lsu_asi_rd_sel = ((|lsu_asi_sel_fmx1[1:0]) | 
2181
//                         ((pid_state_en | va_wtchpt_en) & ld_inst_vld_unflushed) |
2182
//                                       (|lsu_asi_sel_fmx2[1:0]) | 
2183
//                          misc_asi_rd_en) & 
2184
//                        lsu_inst_vld_w ;   
2185
 
2186
assign  lsu_asi_rd_sel = ((|lsu_asi_sel_fmx1[1:0]) |
2187
                         (pid_state_en  & ld_inst_vld_unflushed) |     //remove va_wtchpt_en
2188
                                         (|lsu_asi_sel_fmx2[1:0]) |
2189
                          misc_asi_rd_en) &
2190
                          lsu_inst_vld_w ;
2191
 
2192
 
2193
assign  lsu_asi_rd_en = (lsu_asi_rd_sel | lsu_va_wtchpt_sel_g) & ~dctl_early_flush_w ; //add va_wtchpt
2194
 
2195
//assign        lsu_asi_rd_en = lsu_asi_rd_sel & ~lsu_flush_pipe_w ;
2196
 
2197
assign  misc_asi_rd_en = (bistctl_state_en | mrgnctl_state_en | ldiagctl_state_en) & ld_inst_vld_unflushed ;
2198
 
2199
assign        lsu_local_ldxa_sel_g =  lsu_asi_rd_sel  & ~rst_tri_en ; // w/o flush
2200
assign        lsu_local_ldxa_tlbrd_sel_g  =  (lsu_tlb_tag_rd_vld_g | lsu_tlb_data_rd_vld_g) & ~rst_tri_en;
2201
assign        lsu_va_wtchpt_sel_g =  (va_wtchpt_en & ld_inst_vld_unflushed) & ~rst_tri_en;
2202
 
2203
assign        lsu_local_diagnstc_tagrd_sel_g  =  (~(lsu_local_ldxa_sel_g | lsu_local_ldxa_tlbrd_sel_g |
2204
                                                   lsu_va_wtchpt_sel_g)) | rst_tri_en; //add va_wtchpt
2205
 
2206
// or diagnostic read w/ asi read enable
2207
assign  lsu_diagnstc_asi_rd_en  =  lsu_asi_rd_en | dtagv_diagnstc_rd_g  ; //Bug 3959
2208
//assign  lsu_diagnstc_asi_rd_en  =  lsu_asi_rd_en | dtagv_diagnstc_rd_g  | lsu_local_ldxa_tlbrd_sel_g;
2209
 
2210
 
2211 113 albert.wat
dff_s  #(1) lldxa_stw2 (
2212 95 fafa1971
        .din    (lsu_diagnstc_asi_rd_en),
2213
        .q      (lsu_asi_rd_en_w2),
2214
        .clk    (clk),
2215 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2216 95 fafa1971
        );
2217
 
2218
wire    ldxa_tlbrd0_w2,ldxa_tlbrd1_w2,ldxa_tlbrd2_w2,ldxa_tlbrd3_w2;
2219
wire    ldxa_tlbrd0_w3,ldxa_tlbrd1_w3,ldxa_tlbrd2_w3,ldxa_tlbrd3_w3;
2220
 
2221
// stg mismatched intentionally. stxa_tid decode can be used by ldxa.
2222
assign  ldxa_tlbrd3_w2 = tlu_stxa_thread3_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2223
assign  ldxa_tlbrd2_w2 = tlu_stxa_thread2_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2224
assign  ldxa_tlbrd1_w2 = tlu_stxa_thread1_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2225
assign  ldxa_tlbrd0_w2 = tlu_stxa_thread0_w2 & lsu_local_ldxa_tlbrd_sel_g ;
2226
 
2227
// Bug 3959
2228 113 albert.wat
dff_s  #(4) tlbrd_stw3 (
2229 95 fafa1971
        .din    ({ldxa_tlbrd3_w2,ldxa_tlbrd2_w2,
2230
                ldxa_tlbrd1_w2,ldxa_tlbrd0_w2}),
2231
        .q      ({ldxa_tlbrd3_w3,ldxa_tlbrd2_w3,
2232
                ldxa_tlbrd1_w3,ldxa_tlbrd0_w3}),
2233
        .clk    (clk),
2234 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2235 95 fafa1971
        );
2236
 
2237
// pid and va-wtchpt va removed.
2238
assign  lsu_asi_illgl_va =
2239
  lsuctl_illgl_va | pscxt_ldxa_illgl_va | mrgnctl_illgl_va | asi42_illgl_va ;
2240
assign  lsu_asi_illgl_va_cmplt[0] = lsu_asi_illgl_va & ld_inst_vld_g & thread0_g ;
2241
assign  lsu_asi_illgl_va_cmplt[1] = lsu_asi_illgl_va & ld_inst_vld_g & thread1_g ;
2242
assign  lsu_asi_illgl_va_cmplt[2] = lsu_asi_illgl_va & ld_inst_vld_g & thread2_g ;
2243
assign  lsu_asi_illgl_va_cmplt[3] = lsu_asi_illgl_va & ld_inst_vld_g & thread3_g ;
2244
 
2245 113 albert.wat
dff_s  #(4) lsuillgl_stgw2(
2246 95 fafa1971
        .din    (lsu_asi_illgl_va_cmplt[3:0]),
2247
        .q      (lsu_asi_illgl_va_cmplt_w2[3:0]),
2248
        .clk    (clk),
2249 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2250 95 fafa1971
        );
2251
 
2252
//=========================================================================================
2253
//  ASI_DCACHE_TAG way decode
2254
//=========================================================================================
2255
 
2256
// Bug 4569. 
2257
// add sehold. adding in dctldp flop will cause critical path.
2258
 
2259
wire    [3:0]    dtag_rsel_dcd,dtag_rsel_hold ;
2260
assign  dtag_rsel_dcd[3:0]  =    {(lsu_ldst_va_b12_b11_m[12:11] == 2'b11),
2261
                                (lsu_ldst_va_b12_b11_m[12:11] == 2'b10),
2262
                                (lsu_ldst_va_b12_b11_m[12:11] == 2'b01),
2263
                                (lsu_ldst_va_b12_b11_m[12:11] == 2'b00)};
2264
//bug5994
2265 113 albert.wat
dffe_s #(4) dtag_hold (
2266 95 fafa1971
        .din    (dtag_rsel_dcd[3:0]),
2267
        .q      (dtag_rsel_hold[3:0]),
2268
        .en     (sehold),
2269
        .clk    (clk),
2270 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2271 95 fafa1971
        );
2272
 
2273
assign  lsu_dtag_rsel_m[3:0] = sehold ? dtag_rsel_hold[3:0] : dtag_rsel_dcd[3:0] ;
2274
 
2275
 
2276
//=========================================================================================
2277
//  Watchpoint Control
2278
//=========================================================================================
2279
   wire va_vld;
2280
 
2281
assign  va_vld = (ldst_va_g[7:0] == 8'h38);
2282
 
2283
assign  va_wtchpt_en = (lsu_asi_state[7:0] == 8'h58)  & va_vld &
2284
      lsu_alt_space_g & lsu_inst_vld_w ;
2285
 
2286
// Illegal va checking for asi 58 done in MMU.
2287
 
2288
// one VA watchptr supported per thread
2289
 
2290
// Need to read register !!!
2291
// Switchout thread on read.
2292
// qualify with inst_vld_w.
2293
//assign  va_wtchpt_rd_en = va_wtchpt_en & ld_inst_vld_g ;
2294
 
2295
   wire va_wtchpt0_wr_en, va_wtchpt1_wr_en, va_wtchpt2_wr_en, va_wtchpt3_wr_en;
2296
 
2297
//assign  va_wtchpt0_wr_en = va_wtchpt_en & st_inst_vld_g & thread0_g;
2298
assign  va_wtchpt0_wr_en = va_wtchpt_en & asi_st_vld_g & thread0_g;
2299
assign  va_wtchpt1_wr_en = va_wtchpt_en & asi_st_vld_g & thread1_g;
2300
assign  va_wtchpt2_wr_en = va_wtchpt_en & asi_st_vld_g & thread2_g;
2301
assign  va_wtchpt3_wr_en = va_wtchpt_en & asi_st_vld_g & thread3_g;
2302
assign  lsu_va_wtchpt0_wr_en_l = ~va_wtchpt0_wr_en ;
2303
assign  lsu_va_wtchpt1_wr_en_l = ~va_wtchpt1_wr_en ;
2304
assign  lsu_va_wtchpt2_wr_en_l = ~va_wtchpt2_wr_en ;
2305
assign  lsu_va_wtchpt3_wr_en_l = ~va_wtchpt3_wr_en ;
2306
 
2307
assign  vw_wtchpt_cmp_en_m =  // VA Write Watchpoint Enable
2308
  (thread0_m & lsu_ctl_reg0[4]) |
2309
  (thread1_m & lsu_ctl_reg1[4]) |
2310
  (thread2_m & lsu_ctl_reg2[4]) |
2311
  (thread3_m & lsu_ctl_reg3[4]) ;
2312
 
2313
assign  vr_wtchpt_cmp_en_m =  // VA Read Watchpoint Enable
2314
  (thread0_m & lsu_ctl_reg0[5]) |
2315
  (thread1_m & lsu_ctl_reg1[5]) |
2316
  (thread2_m & lsu_ctl_reg2[5]) |
2317
  (thread3_m & lsu_ctl_reg3[5]) ;
2318
 
2319
   assign  va_wtchpt_cmp_en_m =
2320
(vw_wtchpt_cmp_en_m & st_inst_vld_m) |
2321
(vr_wtchpt_cmp_en_m & ld_inst_vld_m) ;
2322
 
2323
//=========================================================================================
2324
//  Hit/Miss/Fill Control
2325
//=========================================================================================
2326 113 albert.wat
dff_s  #(10) stg_m (
2327 95 fafa1971
        .din    ({ld_inst_vld_e, st_inst_vld_e,ldst_sz_e[1:0],
2328
    ifu_lsu_rd_e[4:0],ifu_lsu_ldst_fp_e}),
2329
        .q      ({ld_inst_vld_m, st_inst_vld_m,ldst_sz_m[1:0],
2330
    ld_rd_m[4:0],fp_ldst_m}),
2331
        .clk    (clk),
2332 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2333 95 fafa1971
        );
2334
 
2335
wire    dcache_arry_data_sel_e;
2336
 
2337
assign   dcache_arry_data_sel_e = lsu_bist_rvld_e | ld_inst_vld_e | dcache_iob_rd_e ;
2338 113 albert.wat
dff_s #(1) dcache_arry_data_sel_stgm (
2339 95 fafa1971
  .din (dcache_arry_data_sel_e),
2340
  .q   (dcache_arry_data_sel_m),
2341
  .clk    (clk),
2342 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2343 95 fafa1971
);
2344
 
2345
 
2346 113 albert.wat
dff_s  #(10) stg_g (
2347 95 fafa1971
        .din    ({ld_inst_vld_m, st_inst_vld_m,ldst_sz_m[1:0],
2348
    ld_rd_m[4:0],fp_ldst_m}),
2349
        .q      ({ld_inst_vld_unflushed, st_inst_vld_unflushed,ldst_sz_g[1:0],
2350
    ld_rd_g[4:0],fp_ldst_g}),
2351
        .clk    (clk),
2352 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2353 95 fafa1971
        );
2354
 
2355
 
2356
//assign  asi_ld_vld_g = ld_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_early_flush_w ;
2357
assign  asi_st_vld_g = st_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_early_flush_w ;
2358
assign  ld_inst_vld_g = ld_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
2359
assign  st_inst_vld_g = st_inst_vld_unflushed & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
2360
 
2361
assign  lsu_way_hit[0] = cache_way_hit_buf1[0] & dcache_enable_g ;
2362
assign  lsu_way_hit[1] = cache_way_hit_buf1[1] & dcache_enable_g ;
2363
assign  lsu_way_hit[2] = cache_way_hit_buf1[2] & dcache_enable_g ;
2364
assign  lsu_way_hit[3] = cache_way_hit_buf1[3] & dcache_enable_g ;
2365
 
2366
//assign  st_set_index_g[5:0] = ldst_va_g[9:4] ;
2367
//assign  st_set_way_g[3:1] = lsu_way_hit[3:1] ;
2368
 
2369
// This should contain ld miss, MMU miss, exception. 
2370
// should tlb_cam_miss be factored in or can miss/hit be solely
2371
// based on way_hit.
2372
 
2373
wire  tlb_cam_hit_mod ;
2374 113 albert.wat
dff_s  stgcmiss_g (
2375 95 fafa1971
        .din    (tlb_cam_hit),
2376
        .q      (tlb_cam_hit_mod),
2377
        .clk    (clk),
2378 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2379 95 fafa1971
        );
2380
 
2381
// NOTE !! qualification with tte_data_parity_error removed for timing.
2382
assign tlb_cam_hit_g = tlb_cam_hit_mod ;
2383
//assign tlb_cam_hit_g = tlb_cam_hit_mod & ~tte_data_parity_error ;
2384
 
2385
/*assign  ld_stb_hit_g =
2386
        ld_stb0_full_raw_g | ld_stb1_full_raw_g |
2387
        ld_stb2_full_raw_g | ld_stb3_full_raw_g |
2388
        ld_stb0_partial_raw_g | ld_stb1_partial_raw_g |
2389
        ld_stb2_partial_raw_g | ld_stb3_partial_raw_g ; */
2390
 
2391
wire nceen_pipe_m, nceen_pipe_g ;
2392
 
2393
   wire [3:0] lsu_nceen_d1;
2394
 
2395 113 albert.wat
dff_s #(4) nceen_stg (
2396 95 fafa1971
   .din (ifu_lsu_nceen[3:0]),
2397
   .q   (lsu_nceen_d1[3:0]),
2398
   .clk (clk),
2399 113 albert.wat
   .se  (se),       `SIMPLY_RISC_SCANIN,          .so ()
2400 95 fafa1971
);
2401
 
2402
 
2403
assign  nceen_pipe_m =
2404
(thread0_m & lsu_nceen_d1[0]) | (thread1_m & lsu_nceen_d1[1]) |
2405
(thread2_m & lsu_nceen_d1[2]) | (thread3_m & lsu_nceen_d1[3]) ;
2406
 
2407 113 albert.wat
dff_s #(1)  stgg_een (
2408 95 fafa1971
        .din    (nceen_pipe_m),
2409
        .q      (nceen_pipe_g),
2410
        .clk    (clk),
2411 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2412 95 fafa1971
        );
2413
 
2414
//wire  tte_data_perror_corr_en ;
2415
wire    tte_data_perror_unc_en ;
2416
// separate ld from st for error reporting.
2417
assign  tte_data_perror_unc_en = ld_inst_vld_unflushed & tte_data_perror_unc & nceen_pipe_g ;
2418
//assign        tte_data_perror_unc_en = tte_data_perror_unc & nceen_pipe_g ;
2419
//assign        tte_data_perror_corr_en = tte_data_perror_corr ;
2420
//assign        tte_data_perror_corr_en = tte_data_perror_corr & ceen_pipe_g ;
2421
 
2422
wire    dtlb_perror_en_w,dtlb_perror_en_w2,dtlb_perror_en_w3 ;
2423
assign  dtlb_perror_en_w = tte_data_perror_unc_en ;
2424
//assign        dtlb_perror_en_w = tte_data_perror_unc_en | tte_data_perror_corr_en ;
2425
 
2426 113 albert.wat
dff_s #(1)  stgw2_perr (
2427 95 fafa1971
        .din    (dtlb_perror_en_w),
2428
        .q      (dtlb_perror_en_w2),
2429
        .clk    (clk),
2430 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2431 95 fafa1971
        );
2432
 
2433 113 albert.wat
dff_s #(1)  stgw3_perr (
2434 95 fafa1971
        .din    (dtlb_perror_en_w2),
2435
        .q      (dtlb_perror_en_w3),
2436
        .clk    (clk),
2437 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2438 95 fafa1971
        );
2439
 
2440
// For now, "or" ld_inst_vld_g and ldst_dbl. Ultimately, it ldst_dbl
2441
// needs to cause ld_inst_vld_g to be asserted.
2442
// st and ld ldst_dbl terms are redundant.
2443
// Diagnostic Dcache access will force a hit in cache. Whatever is read
2444
// out will be written back to irf regardless of whether hit or not. The
2445
// expectation is that cache has been set up to hit.
2446
// lsu_dcache_enable is redundant as factored in lsu_way_hit !!!
2447
// squash both ld_miss and ld_hit in cause of dtlb unc data error.
2448
   wire ldd_force_l2access_g;
2449
 
2450
   wire int_ldd_g, fp_ldd_g;
2451
   assign fp_ldd_g = fp_ldst_g & ~(blk_asi_g & lsu_alt_space_g);
2452
 
2453
   //sas code need int_ldd_g
2454
   assign int_ldd_g = ldst_dbl_g  & ~fp_ldd_g;
2455
   assign ldd_force_l2access_g = int_ldd_g;
2456
 
2457
assign  lsu_ld_miss_wb  =
2458
(~(|lsu_way_hit[3:0]) | ~dcache_enable_g | ~(tlb_cam_hit_g | lsu_dtlb_bypass_g) |
2459
  ldxa_internal | ldd_force_l2access_g | atomic_g |  endian_mispred_g | // remove stb_cam_hit
2460
  dcache_rd_parity_error | dtag_perror_g) &
2461
        ~((dc_diagnstc_asi_g & lsu_alt_space_g)) &
2462
        //~(tte_data_perror_unc_en | tte_data_perror_corr_en | (dc_diagnstc_asi_g & lsu_alt_space_g)) & 
2463
  (ld_vld & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g))) |
2464
  //(ld_inst_vld_g & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g))) |
2465
  //(ldst_dbl_g & st_inst_vld_g)  // signal ld-miss for stdbl.
2466
  ncache_asild_rq_g ;   // asi ld requires bypass
2467
 
2468
assign  lsu_ld_hit_wb   =
2469
((|lsu_way_hit[3:0])  & dcache_enable_g & (tlb_cam_hit_g | lsu_dtlb_bypass_g) &  //bug3702
2470
  ~ldxa_internal & ~dcache_rd_parity_error & ~dtag_perror_g & ~endian_mispred_g &
2471
  ~ldd_force_l2access_g & ~atomic_g &  ~ncache_asild_rq_g) &  // remove stb_cam_hit
2472
~((dc_diagnstc_asi_g & lsu_alt_space_g)) &
2473
//~(tte_data_perror_unc_en | tte_data_perror_corr_en | (dc_diagnstc_asi_g & lsu_alt_space_g)) &
2474
  ld_vld & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g)) ;
2475
//ld_inst_vld_g & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g)) ;
2476
// force hit for diagnostic write. 
2477
 
2478
// correctible dtlb data parity error on cam will cause dmmu miss.
2479
// prefetch will rely on the ld_inst_vld/st_inst_vld not being asserted
2480
// to prevent mmu_miss from being signalled if prefetch does not translate.
2481
// Timing Change : Remove data perror from dmmu_miss ; to be treated as disrupting trap.
2482
//SC assign dmmu_miss_g = 
2483
//SC   ~tlb_cam_hit_mod & ~lsu_dtlb_bypass_g & 
2484
//SC   //~(tlb_cam_hit_mod & ~tte_data_perror_corr) & ~lsu_dtlb_bypass_g & 
2485
//SC   ((ld_inst_vld_unflushed & lsu_inst_vld_w) | 
2486
//SC    (st_inst_vld_unflushed & lsu_inst_vld_w)) & 
2487
//SC     ~(ldxa_internal | stxa_internal | early_trap_vld_g) ;
2488
 
2489
//SC    wire dmmu_miss_only_g ;
2490
 
2491
//SC assign dmmu_miss_only_g = 
2492
//SC  ~tlb_cam_hit_mod & ~lsu_dtlb_bypass_g & 
2493
//SC   //~(tlb_cam_hit_mod & ~tte_data_perror_corr) & ~lsu_dtlb_bypass_g & 
2494
//SC   ((ld_inst_vld_unflushed & lsu_inst_vld_w) | 
2495
//SC    (st_inst_vld_unflushed & lsu_inst_vld_w)) & 
2496
//SC     ~(ldxa_internal | stxa_internal);
2497
 
2498
// Atomic Handling :
2499
// Bypass to irf will occur. However, the loads will not write to cache/tag etc.
2500
 
2501
// Exceptions, tlb miss will have to be included.  
2502
// diagnostic dcache/dtagv will read respective arrays in pipeline. (changed!)
2503
// They will not switch out thread with this assumption. 
2504
 
2505
//dc_diagnstc will not switch out, dtagv will switch out
2506
 
2507
//wire dc_diagnstc_rd_g;  
2508
//assign  dc_diagnstc_rd_g = dc_diagnstc_asi_g & ld_inst_vld_g & lsu_alt_space_g ; 
2509
 
2510
//wire  dc0_diagnstc_rd_g,dc1_diagnstc_rd_g,dc2_diagnstc_rd_g,dc3_diagnstc_rd_g ;
2511
//wire  dc0_diagnstc_rd_w2,dc1_diagnstc_rd_w2,dc2_diagnstc_rd_w2,dc3_diagnstc_rd_w2 ;
2512
//assign  dc0_diagnstc_rd_g = dc_diagnstc_rd_g & thread0_g ;
2513
//assign  dc1_diagnstc_rd_g = dc_diagnstc_rd_g & thread1_g ;
2514
//assign  dc2_diagnstc_rd_g = dc_diagnstc_rd_g & thread2_g ;
2515
//assign  dc3_diagnstc_rd_g = dc_diagnstc_rd_g & thread3_g ;
2516
 
2517
//dff #(4)  stgw2_dcdiag (
2518
//        .din  ({dc3_diagnstc_rd_g,dc2_diagnstc_rd_g,dc1_diagnstc_rd_g,dc0_diagnstc_rd_g}),
2519
//        .q    ({dc3_diagnstc_rd_w2,dc2_diagnstc_rd_w2,dc1_diagnstc_rd_w2,dc0_diagnstc_rd_w2}),
2520
//        .clk  (clk),
2521 113 albert.wat
//        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2522 95 fafa1971
//        );
2523
 
2524
assign  dtagv_diagnstc_rd_g = dtagv_diagnstc_asi_g & ld_inst_vld_g & lsu_alt_space_g ;
2525
 
2526
// Prefetch will swo thread if it does not miss in tlb.
2527 113 albert.wat
dff_s  stgm_prf (
2528 95 fafa1971
        .din    (ifu_lsu_pref_inst_e),
2529
        .q      (pref_inst_m),
2530
        .clk  (clk),
2531 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2532 95 fafa1971
        );
2533
 
2534 113 albert.wat
dff_s  stgg_prf (
2535 95 fafa1971
        .din    (pref_inst_m),
2536
        .q      (pref_inst_g),
2537
        .clk  (clk),
2538 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2539 95 fafa1971
        );
2540
 
2541
 
2542
 
2543
//assign        lsu_ifu_data_error_w = 1'b0 ;
2544
 
2545
// is this redundant ? isn't lsu_ncache_ld_e sufficient ?
2546
assign  atomic_ld_squash_e =
2547
  ~lmq_ld_rq_type_e[2] & lmq_ld_rq_type_e[1] & lmq_ld_rq_type_e[0] ;
2548
 
2549
// bypass will occur with hit in d$ or data return from L2.
2550
// Fill for dcache diagnostic rd will happen regardless. dfill vld qualified with
2551
// flush_pipe and inst_vld !!!
2552
 
2553
//timing fix. move logic to previous cycle M.   
2554
//assign  lsu_exu_dfill_vld_w2  =   
2555
//  (l2fill_vld_g & ~(unc_err_trap_g | l2fill_fpld_g))                | // fill
2556
//  (~fp_ldst_g & ld_inst_vld_unflushed & lsu_inst_vld_w)       | // in pipe
2557
//  intld_byp_data_vld ;                                                // bypass
2558
 
2559
   wire lsu_exu_dfill_vld_m;
2560
   wire intld_byp_data_vld_e,intld_byp_data_vld_m ;
2561
   wire intld_byp_data_vld ;
2562
   wire ldxa_swo_annul ;
2563
 
2564
assign lsu_exu_dfill_vld_m =
2565
  (l2fill_vld_m & ~(unc_err_trap_m | l2fill_fpld_m))          | // fill
2566
  (~fp_ldst_m & ld_inst_vld_m &
2567
        ~(ldxa_swo_annul & lsu_alt_space_m) & flush_w_inst_vld_m) | // in pipe
2568
  intld_byp_data_vld_m ;                                              // bypass
2569
 
2570 113 albert.wat
dff_s #(1) dfill_vld_stgg (
2571 95 fafa1971
   .din (lsu_exu_dfill_vld_m),
2572
   .q   (lsu_exu_dfill_vld_w2),
2573
   .clk    (clk),
2574 113 albert.wat
   .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2575 95 fafa1971
);
2576
 
2577
//------              
2578
// Bld errors : Bug 4315
2579
// Errors need to be accummulated across helpers. Once unc error detected 
2580
// in any helper, then all further writes to frf are squashed.
2581
// daccess_error trap taken at very end if *any* helper had an unc error.
2582
 
2583
wire    bld_cnt_max_m,bld_cnt_max_g ;
2584
assign  bld_cnt_max_m = lsu_bld_cnt_m[2] & lsu_bld_cnt_m[1] & lsu_bld_cnt_m[0] ;
2585
 
2586
wire    [1:0]    cpx_ld_err_m ;
2587 113 albert.wat
dff_s #(3) lderr_stgm (
2588 95 fafa1971
   .din ({lsu_cpx_pkt_ld_err[1:0],bld_cnt_max_m}),
2589
   .q   ({cpx_ld_err_m[1:0],bld_cnt_max_g}),
2590
   .clk    (clk),
2591 113 albert.wat
   .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2592 95 fafa1971
);
2593
 
2594
wire [1:0] bld_err ;
2595
wire [1:0] bld_err_din ;
2596
wire       bld_rst ;
2597
// Accummulate errors.
2598
assign  bld_err_din[1:0] = cpx_ld_err_m[1:0] | bld_err[1:0] ;
2599
assign  bld_rst = reset | lsu_bld_reset ;
2600
 
2601 113 albert.wat
dffre_s #(2) blderr_ff (
2602 95 fafa1971
        .din    (bld_err_din[1:0]),
2603
        .q      (bld_err[1:0]),
2604
        .clk    (clk),
2605
        .en     (lsu_bld_helper_cmplt_m), .rst (bld_rst),
2606 113 albert.wat
        .se     (se),   `SIMPLY_RISC_SCANIN,    .so ()
2607 95 fafa1971
        );
2608
 
2609
wire    bld_helper_cmplt_g ;
2610 113 albert.wat
dff_s  bldh_stgg (
2611 95 fafa1971
   .din (lsu_bld_helper_cmplt_m),
2612
   .q   (bld_helper_cmplt_g),
2613
   .clk    (clk),
2614 113 albert.wat
   .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2615 95 fafa1971
);
2616
 
2617
wire    bld_unc_err_pend_g, bld_unc_err_pend_w2 ;
2618
assign  bld_unc_err_pend_g = bld_err[1] & bld_helper_cmplt_g ;
2619
wire    bld_corr_err_pend_g, bld_corr_err_pend_w2 ;
2620
// pended unc error gets priority.
2621
assign  bld_corr_err_pend_g = bld_err[0] & ~bld_err[1] & bld_helper_cmplt_g ;
2622
 
2623
wire    bld_squash_err_g,bld_squash_err_w2 ;
2624
// bld cnt should be vld till g
2625
assign  bld_squash_err_g = bld_helper_cmplt_g & ~bld_cnt_max_g ;
2626
 
2627 113 albert.wat
dff_s #(3)  bldsq_stgw2 (
2628 95 fafa1971
   .din ({bld_squash_err_g,bld_unc_err_pend_g,bld_corr_err_pend_g}),
2629
   .q   ({bld_squash_err_w2,bld_unc_err_pend_w2,bld_corr_err_pend_w2}),
2630
   .clk    (clk),
2631 113 albert.wat
   .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2632 95 fafa1971
);
2633
 
2634
//------              
2635
 
2636
wire    stb_cam_hit_w2 ;
2637
wire    fld_vld_sync_no_camhit,fld_vld_sync_no_camhit_w2 ;
2638
wire    fld_vld_async,fld_vld_async_w2 ;
2639 113 albert.wat
dff_s  #(3) stbchit_stg (
2640 95 fafa1971
        .din    ({stb_cam_hit,fld_vld_sync_no_camhit,fld_vld_async}),
2641
        .q      ({stb_cam_hit_w2,fld_vld_sync_no_camhit_w2,fld_vld_async_w2}),
2642
        .clk    (clk),
2643 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2644 95 fafa1971
        );
2645
 
2646
assign  fld_vld_sync_no_camhit =
2647
        (lsu_ld_hit_wb & ~tte_data_perror_unc_en & fp_ldst_g &
2648
        ~dctl_flush_pipe_w) ; // l1hit 
2649
 
2650
assign  fld_vld_async =
2651
        (l2fill_vld_g & l2fill_fpld_g & ~(unc_err_trap_g | bld_unc_err_pend_g))  |
2652
                                                // fill from l2, // bug 3705, 4315(err_trap)
2653
        fpld_byp_data_vld ;     // bypass data
2654
 
2655
assign  lsu_ffu_ld_vld =
2656
        (fld_vld_sync_no_camhit_w2 & ~stb_cam_hit_w2) |
2657
        fld_vld_async_w2 ;
2658
 
2659
 
2660
/*dff  #(1) fldvld_stgw2 (
2661
        .din    (ffu_ld_vld),
2662
        .q      (lsu_ffu_ld_vld),
2663
        .clk    (clk),
2664 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2665 95 fafa1971
        ); */
2666
 
2667 113 albert.wat
dff_s  #(2) dtid_stgm (
2668 95 fafa1971
        .din    (lsu_dfill_tid_e[1:0]),
2669
        .q      (dfq_tid_m[1:0]),
2670
        .clk    (clk),
2671 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2672 95 fafa1971
        );
2673
 
2674 113 albert.wat
dff_s  #(2) dtid_stgg (
2675 95 fafa1971
        .din    (dfq_tid_m[1:0]),
2676
        .q      (dfq_tid_g[1:0]),
2677
        .clk    (clk),
2678 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2679 95 fafa1971
        );
2680
 
2681
// Timing Change -  shifting dfill-data sel gen. to m-stage
2682
//assign  ldbyp_tid[0] = ld_thrd_byp_sel_g[1] | ld_thrd_byp_sel_g[3] ;
2683
//assign  ldbyp_tid[1] = ld_thrd_byp_sel_g[2] | ld_thrd_byp_sel_g[3] ;
2684
wire    [3:0]    ld_thrd_byp_sel_m ;
2685
assign  ldbyp_tid_m[0] = ld_thrd_byp_sel_m[1] | ld_thrd_byp_sel_m[3] ;
2686
assign  ldbyp_tid_m[1] = ld_thrd_byp_sel_m[2] | ld_thrd_byp_sel_m[3] ;
2687
 
2688
 
2689
/*assign  lsu_exu_thr_g[1:0] = ld_inst_vld_unflushed ? thrid_g[1:0] :
2690
          l2fill_vld_g ? dfq_tid_g[1:0] : ldbyp_tid[1:0] ; */
2691
assign  lsu_exu_thr_m[1:0] = ld_inst_vld_m ? thrid_m[1:0] :
2692
          l2fill_vld_m ? dfq_tid_m[1:0] : ldbyp_tid_m[1:0] ;
2693
 
2694
// What is the policy for load-double/atomics to update cache ?
2695
// cas will not update cache. similary neither will ldstub nor cas.
2696
// BIST will effect dcache only, not tags and vld bits.
2697
// Removed dcache_enable from dc_diagnstc_wr_en !!!
2698
wire    l2fill_vld_e ;
2699
wire    dcache_alt_src_wr_e ;
2700
assign  l2fill_vld_e = lsu_l2fill_vld & ~lsu_cpx_pkt_prefetch2 ;
2701
assign  lsu_dcache_wr_vld_e =
2702
  (l2fill_vld_e & ~ignore_fill & ~atomic_ld_squash_e & ~ld_sec_active & ~lsu_ncache_ld_e) |
2703
  lsu_st_wr_dcache  | // st writes from stb
2704
  dcache_alt_src_wr_e ;
2705
 
2706
assign  dcache_alt_src_wr_e =
2707
  (lsu_diagnstc_wr_src_sel_e & dc_diagnstc_wr_en)
2708
  | lsu_bist_wvld_e     // bist engine writes to cache
2709
  | dcache_iob_wr_e ;  // iobridge request write to dcache
2710
 
2711
//d$ valid bit 
2712
   wire dv_diagnstic_wr;
2713
assign  dv_diagnstic_wr = (lsu_diagnstc_wr_src_sel_e & dtagv_diagnstc_wr_en & lsu_diagnstc_wr_data_b0) ;
2714
 
2715
   wire dva_din_e;
2716
   wire ld_fill_e;
2717
 
2718
   assign ld_fill_e= (l2fill_vld_e & ~atomic_ld_squash_e & ~ld_sec_active & ~lsu_ncache_ld_e) ;   //ld-fill
2719
   //######################################
2720
   //snp      => dva_din = 0
2721
   //ld fill  => dva_din = 1
2722
   //diag wrt => dva_din = wrt_value
2723
   //######################################
2724
   assign dva_din_e =  ld_fill_e  | //ld-fill
2725
                       dv_diagnstic_wr; // diagnostic write valid bit
2726
 
2727
 
2728
// iob rd dominates
2729
   wire lsu_dc_alt_rd_vld_e;
2730
 
2731
assign  lsu_dc_alt_rd_vld_e = dcache_iob_rd_e | lsu_bist_rvld_e ;
2732
 
2733
   //?? default when no ld in pipe
2734
   assign dcache_alt_mx_sel_e =
2735
                //lsu_dcache_wr_vld_e | : Timing
2736
                dcache_alt_src_wr_e | // rm st updates/fill - ~ld_inst_vld_e.
2737
                lsu_dcache_wr_vld_e |
2738
                lsu_dc_alt_rd_vld_e  | ~ld_inst_vld_e;
2739
 
2740
   assign dcache_alt_mx_sel_e_bf = dcache_alt_mx_sel_e;
2741
 
2742
   wire   dcache_rvld_e_tmp, dcache_rvld_e_minbf;
2743
   assign dcache_rvld_e_tmp =  ld_inst_vld_e | lsu_dc_alt_rd_vld_e ;
2744
   bw_u1_minbuf_5x  UZfix_dcache_rvld_e_minbf (.a(dcache_rvld_e_tmp), .z(dcache_rvld_e_minbf));
2745
   assign dcache_rvld_e = dcache_rvld_e_minbf;
2746
 
2747
   wire   lsu_dtag_wr_vld_e_tmp;
2748
 
2749
assign  lsu_dtag_wr_vld_e_tmp =
2750
  ld_fill_e  & ~ignore_fill | //ld fill   //bug3601, 3676
2751
  (lsu_diagnstc_wr_src_sel_e & dtagv_diagnstc_wr_en) ; // dtag/vld diagnostic wr
2752
 
2753
bw_u1_buf_30x UZsize_lsu_dtag_wrreq_x     ( .a(lsu_dtag_wr_vld_e_tmp), .z(lsu_dtag_wrreq_x_e)     );
2754
bw_u1_buf_30x UZsize_lsu_dtag_index_sel_x ( .a(lsu_dtag_wr_vld_e_tmp), .z(lsu_dtag_index_sel_x_e) );
2755
 
2756
assign  lsu_dtagv_wr_vld_e =
2757
  lsu_dtag_wr_vld_e_tmp |       // fill
2758
  dva_svld_e        |   // snp
2759
  lsu_bist_wvld_e ;     // bist clears dva by default
2760
 
2761
// mem cell change for dva
2762
   wire [15:0] dva_fill_bit_wr_en_e;
2763
 
2764
   assign      dva_fill_bit_wr_en_e[15] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
2765
   assign      dva_fill_bit_wr_en_e[14] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
2766
   assign      dva_fill_bit_wr_en_e[13] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
2767
   assign      dva_fill_bit_wr_en_e[12] = dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
2768
 
2769
   assign      dva_fill_bit_wr_en_e[11] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
2770
   assign      dva_fill_bit_wr_en_e[10] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
2771
   assign      dva_fill_bit_wr_en_e[09] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
2772
   assign      dva_fill_bit_wr_en_e[08] = dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
2773
 
2774
   assign      dva_fill_bit_wr_en_e[07] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
2775
   assign      dva_fill_bit_wr_en_e[06] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
2776
   assign      dva_fill_bit_wr_en_e[05] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
2777
   assign      dva_fill_bit_wr_en_e[04] = ~dcache_fill_addr_e[5] & dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
2778
 
2779
   assign      dva_fill_bit_wr_en_e[03] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[3];
2780
   assign      dva_fill_bit_wr_en_e[02] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[2];
2781
   assign      dva_fill_bit_wr_en_e[01] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[1];
2782
   assign      dva_fill_bit_wr_en_e[00] = ~dcache_fill_addr_e[5] & ~dcache_fill_addr_e[4] & lsu_dcache_fill_way_e[0];
2783
 
2784
   wire [15:0] dva_bit_wr_en_e;
2785
   assign      dva_bit_wr_en_e[15:0] = dva_svld_e ? dva_snp_bit_wr_en_e[15:0] : dva_fill_bit_wr_en_e;
2786
 
2787
   wire [4:0]  dva_snp_addr_e_bf;
2788
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b4 (.a(dva_snp_addr_e[4]), .z(dva_snp_addr_e_bf[4]));
2789
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b3 (.a(dva_snp_addr_e[3]), .z(dva_snp_addr_e_bf[3]));
2790
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b2 (.a(dva_snp_addr_e[2]), .z(dva_snp_addr_e_bf[2]));
2791
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b1 (.a(dva_snp_addr_e[1]), .z(dva_snp_addr_e_bf[1]));
2792
   bw_u1_buf_5x UZsize_dva_snp_addr_e_bf_b0 (.a(dva_snp_addr_e[0]), .z(dva_snp_addr_e_bf[0]));
2793
 
2794
   assign      dva_wr_adr_e[10:6] = dva_svld_e ? dva_snp_addr_e_bf[4:0] : dcache_fill_addr_e[10:6];
2795
 
2796
// should ldxa_data_vld be included ?
2797
 
2798
assign  dfill_thread0 = ~lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0] ;
2799
assign  dfill_thread1 = ~lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0] ;
2800
assign  dfill_thread2 =  lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0] ;
2801
assign  dfill_thread3 =  lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0] ;
2802
 
2803
assign  l2fill_fpld_e = lsu_l2fill_fpld_e ;
2804
 
2805
//=========================================================================================
2806
//  LD/ST COMPLETE SIGNAL
2807
//=========================================================================================
2808
 
2809
// Prefetch
2810
 
2811
wire    pref_tlbmiss_g ;
2812
assign  pref_tlbmiss_g =
2813
pref_inst_g &
2814
(~tlb_cam_hit_g | (tlb_cam_hit_g & tlb_pgnum[39])) // nop on tlbmiss or io access
2815
& lsu_inst_vld_w & ~dctl_flush_pipe_w ; // Bug 4318 bug6406/eco6619
2816
 
2817
//assign        pref_tlbmiss_g = pref_inst_g & lsu_inst_vld_w & ~tlb_cam_hit_g ;
2818
wire    [3:0] pref_tlbmiss_cmplt,pref_tlbmiss_cmplt_d1,pref_tlbmiss_cmplt_d2 ;
2819
assign  pref_tlbmiss_cmplt[0] = pref_tlbmiss_g & thread0_g ;
2820
assign  pref_tlbmiss_cmplt[1] = pref_tlbmiss_g & thread1_g ;
2821
assign  pref_tlbmiss_cmplt[2] = pref_tlbmiss_g & thread2_g ;
2822
assign  pref_tlbmiss_cmplt[3] = pref_tlbmiss_g & thread3_g ;
2823
 
2824 113 albert.wat
dff_s  #(4) pfcmpl_stgd1 (
2825 95 fafa1971
        .din    (pref_tlbmiss_cmplt[3:0]),
2826
        .q      (pref_tlbmiss_cmplt_d1[3:0]),
2827
        .clk    (clk),
2828 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2829 95 fafa1971
        );
2830
 
2831 113 albert.wat
dff_s  #(4) pfcmpl_stgd2 (
2832 95 fafa1971
        .din    (pref_tlbmiss_cmplt_d1[3:0]),
2833
        .q      (pref_tlbmiss_cmplt_d2[3:0]),
2834
        .clk    (clk),
2835 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2836 95 fafa1971
        );
2837
 
2838
// *** add diagnstc rd and prefetch(tlb-miss) signals. ***
2839
// *** add ifu asi ack.
2840
 
2841
// This equation is critical and needs to be optimized.
2842
wire [3:0]       lsu_pcx_pref_issue;
2843
wire    diag_wr_cmplt0,diag_wr_cmplt1,diag_wr_cmplt2,diag_wr_cmplt3;
2844
wire    ldst_cmplt_late_0, ldst_cmplt_late_1 ;
2845
wire    ldst_cmplt_late_2, ldst_cmplt_late_3 ;
2846
wire    ldst_cmplt_late_0_d1, ldst_cmplt_late_1_d1 ;
2847
wire    ldst_cmplt_late_2_d1, ldst_cmplt_late_3_d1 ;
2848
 
2849
   assign ignore_fill = lmq_ldd_vld & ~ldd_in_dfq_out;
2850
 
2851
assign  lsu_ifu_ldst_cmplt[0] =
2852
    // * can be early or
2853
    ((stxa_internal_d2 & thread0_w3) | stxa_stall_wr_cmplt0_d1) |
2854
    // * late signal and critical.
2855
    // Can this be snapped earlier ?
2856
    //(((l2fill_vld_e & ~atomic_ld_squash_e & ~ignore_fill)) //Bug 3624
2857
    (((l2fill_vld_e & ~ignore_fill))  // 1st fill for ldd.
2858
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
2859
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[0]) & dfill_thread0)  |
2860
    intld_byp_cmplt[0] |
2861
    // * early-or signals
2862
    ldst_cmplt_late_0_d1 ;
2863
 
2864
wire    atm_st_cmplt0 ;
2865
assign  atm_st_cmplt0 = lsu_atm_st_cmplt_e & dfill_thread0 ;
2866
assign  ldst_cmplt_late_0 =
2867
    (atm_st_cmplt0 & ~pend_atm_ld_ue[0]) |  // Bug 3624,4048
2868
    bsync0_reset    |
2869
    lsu_intrpt_cmplt[0]   |
2870
    diag_wr_cmplt0 |
2871
//    dc0_diagnstc_rd_w2 |
2872
    ldxa_illgl_va_cmplt_d1[0] |
2873
    pref_tlbmiss_cmplt_d2[0] |
2874
    lsu_pcx_pref_issue[0];
2875
 
2876
 
2877
assign  lsu_ifu_ldst_cmplt[1] =
2878
    ((stxa_internal_d2 & thread1_w3) | stxa_stall_wr_cmplt1_d1) |
2879
    (((l2fill_vld_e & ~ignore_fill)) // // 1st fill for ldd
2880
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
2881
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[1]) & dfill_thread1)  |
2882
    intld_byp_cmplt[1] |
2883
    ldst_cmplt_late_1_d1 ;
2884
 
2885
wire    atm_st_cmplt1 ;
2886
assign  atm_st_cmplt1 = lsu_atm_st_cmplt_e & dfill_thread1 ;
2887
assign  ldst_cmplt_late_1 =
2888
    (atm_st_cmplt1 & ~pend_atm_ld_ue[1]) |  // Bug 3624,4048
2889
    bsync1_reset    |
2890
    lsu_intrpt_cmplt[1]   |
2891
    diag_wr_cmplt1 |
2892
//    dc1_diagnstc_rd_w2 |
2893
    ldxa_illgl_va_cmplt_d1[1] |
2894
    pref_tlbmiss_cmplt_d2[1] |
2895
    lsu_pcx_pref_issue[1];
2896
 
2897
assign  lsu_ifu_ldst_cmplt[2] =
2898
    ((stxa_internal_d2 & thread2_w3) | stxa_stall_wr_cmplt2_d1) |
2899
    (((l2fill_vld_e & ~ignore_fill)) // 1st fill for ldd.
2900
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
2901
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[2]) & dfill_thread2)  |
2902
    intld_byp_cmplt[2] |
2903
    ldst_cmplt_late_2_d1 ;
2904
 
2905
wire    atm_st_cmplt2 ;
2906
assign  atm_st_cmplt2 = lsu_atm_st_cmplt_e & dfill_thread2 ;
2907
assign  ldst_cmplt_late_2 =
2908
    (atm_st_cmplt2 & ~pend_atm_ld_ue[2]) |  // Bug 3624,4048
2909
    bsync2_reset    |
2910
    lsu_intrpt_cmplt[2]   |
2911
    diag_wr_cmplt2 |
2912
//    dc2_diagnstc_rd_w2 |
2913
    ldxa_illgl_va_cmplt_d1[2] |
2914
    pref_tlbmiss_cmplt_d2[2] |
2915
    lsu_pcx_pref_issue[2];
2916
 
2917
assign  lsu_ifu_ldst_cmplt[3] =
2918
    ((stxa_internal_d2 & thread3_w3) | stxa_stall_wr_cmplt3_d1) |
2919
    //(((l2fill_vld_e & atomic_st_cmplt) | 
2920
    (((l2fill_vld_e & ~ignore_fill)) // 1st fill for ldd.
2921
      & ~l2fill_fpld_e & ~lsu_cpx_pkt_atm_st_cmplt &
2922
        ~(lsu_cpx_pkt_ld_err[1] & lsu_nceen_d1[3]) & dfill_thread3)  |
2923
    intld_byp_cmplt[3] |
2924
    ldst_cmplt_late_3_d1 ;
2925
 
2926
wire    atm_st_cmplt3 ;
2927
assign  atm_st_cmplt3 = lsu_atm_st_cmplt_e & dfill_thread3 ;
2928
assign  ldst_cmplt_late_3 =
2929
    (atm_st_cmplt3 & ~pend_atm_ld_ue[3]) |  // Bug 3624,4048
2930
    bsync3_reset    |
2931
    lsu_intrpt_cmplt[3]   |
2932
    diag_wr_cmplt3 |
2933
//    dc3_diagnstc_rd_w2 |
2934
    ldxa_illgl_va_cmplt_d1[3] |
2935
    pref_tlbmiss_cmplt_d2[3] |
2936
    lsu_pcx_pref_issue[3];
2937
 
2938 113 albert.wat
dff_s #(4) ldstcmplt_d1 (
2939 95 fafa1971
        .din    ({ldst_cmplt_late_3,ldst_cmplt_late_2,ldst_cmplt_late_1,ldst_cmplt_late_0}),
2940
        .q      ({ldst_cmplt_late_3_d1,ldst_cmplt_late_2_d1,
2941
                ldst_cmplt_late_1_d1,ldst_cmplt_late_0_d1}),
2942
        .clk    (clk),
2943 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2944 95 fafa1971
        );
2945
 
2946
//=========================================================================================
2947
//  LD/ST MISS SIGNAL - IFU
2948
//=========================================================================================
2949
 
2950
// Switchout of internal asi ld
2951
// Do not switchout for tag-target,
2952
assign  ldxa_swo_annul =
2953
        (lsu_dctl_asi_state_m[7:4] == 4'h3)   |         // ldxa to 0x3X does not swo
2954
        (((lsu_dctl_asi_state_m[7:0] == 8'h58) &         // tag-target,tag-access,sfsr,sfar
2955
                ~((lsu_ldst_va_b7_b0_m[7:0] == 8'h38) | (lsu_ldst_va_b7_b0_m[7:0] == 8'h80))) | // wtcpt/pid
2956
         (lsu_dctl_asi_state_m[7:0] == 8'h50)) |
2957
        mmu_rd_only_asi_m ;
2958
 
2959
wire    ldxa_internal_swo_m,ldxa_internal_swo_g ;
2960
assign  ldxa_internal_swo_m = lda_internal_m & ~ldxa_swo_annul ;
2961
 
2962
// This represents *all* ld asi.
2963
wire    asi_internal_ld_m,asi_internal_ld_g ;
2964
assign  asi_internal_ld_m =
2965
        asi_internal_m & ld_inst_vld_m & lsu_alt_space_m ;
2966
 
2967 113 albert.wat
dff_s #(2) ldaswo_stgg (
2968 95 fafa1971
        .din    ({ldxa_internal_swo_m,asi_internal_ld_m}),
2969
        .q      ({ldxa_internal_swo_g,asi_internal_ld_g}),
2970
        .clk    (clk),
2971 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
2972 95 fafa1971
        );
2973
 
2974
wire    common_ldst_miss_w ;
2975
assign  common_ldst_miss_w =
2976
(~(cache_hit & (tlb_cam_hit_g | lsu_dtlb_bypass_g)) |   // include miss in tlb;bypass
2977
   ~dcache_enable_g     |       // 
2978
    //endian_mispred_g    |     // endian mispredict
2979
    ldd_force_l2access_g                |       // ifu to incorporate directly
2980
    ncache_asild_rq_g   ) &     // bypass asi
2981
        ~asi_internal_ld_g ;
2982
 
2983
assign  lsu_ifu_ldst_miss_w =
2984
  (common_ldst_miss_w  |         // common between ifu and exu.
2985
    // MMU_ASI : ifu must switch out early only for stores.
2986
    ldxa_internal_swo_g)
2987
//  ldxa_internal       |       // ifu incorporates directly
2988
//  atomic_g            |       // ifu incorporates directly
2989
//  ld_stb_hit_g        |       // late 
2990
//    stb_cam_hit)              // ** rm once ifu uses late signal. ** 
2991
//  dcache_rd_parity_error |    // late
2992
//  dtag_perror_g) &    |       // late
2993
    & (lsu_inst_vld_w & ld_inst_vld_unflushed) ;        // flush uptil m accounted for.
2994
//  & ld_inst_vld_g ;           // assume flush=1 clears ldst_miss=1
2995
//  ~tte_data_perror_unc &      // in flush 
2996
//  (ld_inst_vld_g & (~lsu_alt_space_g | (lsu_alt_space_g & recognized_asi_g))) |
2997
//  ncache_asild_rq_g ;   // asi ld requires bypass
2998
 
2999
 
3000
   //timing fix
3001
   wire lsu_ifu_dc_parity_error_w;
3002
   assign lsu_ifu_dc_parity_error_w =
3003
        (
3004
        lsu_dcache_data_perror_g | // bug 4267
3005
        lsu_dcache_tag_perror_g  |
3006
  endian_mispred_g         |    // endian mispredict ; mv'ed from ldst_miss
3007
        tte_data_perror_unc_en) ;
3008
 
3009
/*
3010
   wire   lsu_ld_inst_vld_flush_w, lsu_ld_inst_vld_flush_w2;
3011
   assign lsu_ld_inst_vld_flush_w = lsu_inst_vld_w & ld_inst_vld_unflushed & ~dctl_flush_pipe_w ;
3012
 
3013
 
3014 113 albert.wat
dff_s #(1) lsu_ld_inst_vld_flush_stgw2 (
3015 95 fafa1971
        .din    (lsu_ld_inst_vld_flush_w),
3016
        .q      (lsu_ld_inst_vld_flush_w2),
3017
        .clk    (clk),
3018 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3019 95 fafa1971
        );
3020
*/
3021
 
3022
   wire   lsu_ifu_dc_parity_error_w2_q;
3023
 
3024 113 albert.wat
dff_s #(1) lsu_ifu_dc_parity_error_stgw2 (
3025 95 fafa1971
        .din    (lsu_ifu_dc_parity_error_w),
3026
        .q      (lsu_ifu_dc_parity_error_w2_q),
3027
        .clk    (clk),
3028 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3029 95 fafa1971
        );
3030
 
3031
   assign lsu_ifu_dc_parity_error_w2 = (lsu_ifu_dc_parity_error_w2_q | stb_cam_hit_w2) & ld_inst_vld_w2;
3032
 
3033
//=========================================================================================
3034
//  LD/ST MISS SIGNAL - EXU
3035
//=========================================================================================
3036
 
3037
// for a diagnstc access to the cache, the if it misses in the cache, then 
3038
// ldst_miss is asserted, preventing a write into the cache, but code is
3039
// allowed to continue executing.
3040
wire    exu_ldst_miss_g_no_stb_cam_hit ;
3041
assign  exu_ldst_miss_g_no_stb_cam_hit =
3042
  (common_ldst_miss_w     |
3043
   ldxa_internal_swo_g    |
3044
   endian_mispred_g       |
3045
   atomic_g               |
3046
   lsu_dcache_data_perror_g     |
3047
   lsu_dcache_tag_perror_g      |
3048
   tte_data_perror_unc_en       |
3049
   pref_inst_g) & ld_inst_vld_unflushed & lsu_inst_vld_w ; // flush qual done in exu
3050
 
3051
 
3052
   wire ld_inst_vld_no_flush_w, ld_inst_vld_no_flush_w2;
3053
   assign ld_inst_vld_no_flush_w = ld_inst_vld_unflushed & lsu_inst_vld_w;
3054
 
3055 113 albert.wat
dff_s #(1) ld_inst_vld_no_flush_stgw2 (
3056 95 fafa1971
        .din    (ld_inst_vld_no_flush_w),
3057
        .q      (ld_inst_vld_no_flush_w2),
3058
        .clk    (clk),
3059 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3060 95 fafa1971
        );
3061
 
3062
   wire lsu_exu_ldst_miss_w2_tmp;
3063
 
3064 113 albert.wat
dff_s #(1) exuldstmiss_stgw2 (
3065 95 fafa1971
        .din    (exu_ldst_miss_g_no_stb_cam_hit),
3066
        .q      (lsu_exu_ldst_miss_w2_tmp),
3067
        .clk    (clk),
3068 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3069 95 fafa1971
        );
3070
 
3071
   assign lsu_exu_ldst_miss_w2 =  (lsu_exu_ldst_miss_w2_tmp | stb_cam_hit_w2) & ld_inst_vld_no_flush_w2;
3072
 
3073
 
3074
wire    lsu_ldst_miss_w2;
3075
assign  lsu_ldst_miss_w2 = lsu_exu_ldst_miss_w2 ;
3076
 
3077
//=========================================================================================
3078
//  RMO Store control data
3079
//=========================================================================================
3080
 
3081
assign  lsu_st_rmo_m = (st_inst_vld_m & (binit_quad_asi_m | blk_asi_m) & lsu_alt_space_m) | blkst_m ;
3082
assign  lsu_bst_in_pipe_m = (st_inst_vld_m &  blk_asi_m & lsu_alt_space_m) ;
3083
 
3084
//=========================================================================================
3085
//  ASI BUS 
3086
//=========================================================================================
3087
 
3088
// *** This logic is now used by all long-latency asi operations on chip. ***
3089
 
3090
// Start with SDATA Reg for Streaming
3091
wire    strm_asi, strm_asi_m ;
3092
assign  strm_asi_m = (lsu_dctl_asi_state_m[7:0]==8'h40) ;
3093
 
3094 113 albert.wat
dff_s  strm_stgg (
3095 95 fafa1971
        .din    (strm_asi_m),
3096
        .q      (strm_asi),
3097
        .clk    (clk),
3098 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3099 95 fafa1971
        );
3100
 
3101
assign  stxa_stall_asi_g =
3102
  strm_asi & ((ldst_va_g[7:0] == 8'h80)) ;       // ma ctl
3103
  /*strm_asi & (        (ldst_va_g[7:0] == 8'h18) |     // streaming stxa to sdata
3104
                (ldst_va_g[7:0] == 8'h00) |     // stream ctl
3105
                (ldst_va_g[7:0] == 8'h08) ) ;   // ma ctl */
3106
 
3107
wire    dtlb_wr_cmplt0, dtlb_wr_cmplt1;
3108
wire    dtlb_wr_cmplt2, dtlb_wr_cmplt3;
3109
assign  dtlb_wr_cmplt0 = demap_thread0 & lsu_dtlb_wr_vld_e ;
3110
assign  dtlb_wr_cmplt1 = demap_thread1 & lsu_dtlb_wr_vld_e ;
3111
assign  dtlb_wr_cmplt2 = demap_thread2 & lsu_dtlb_wr_vld_e ;
3112
assign  dtlb_wr_cmplt3 = demap_thread3 & lsu_dtlb_wr_vld_e ;
3113
 
3114 113 albert.wat
dff_s  dtlbw_stgd1 (
3115 95 fafa1971
        .din    (lsu_dtlb_wr_vld_e),
3116
        .q      (dtlb_wr_init_d1),
3117
        .clk    (clk),
3118 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3119 95 fafa1971
        );
3120
 
3121 113 albert.wat
dff_s  dtlbw_stgd2 (
3122 95 fafa1971
        .din    (dtlb_wr_init_d1),
3123
        .q      (dtlb_wr_init_d2),
3124
        .clk    (clk),
3125 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3126 95 fafa1971
        );
3127
 
3128 113 albert.wat
dff_s  dtlbw_stgd3 (
3129 95 fafa1971
        .din    (dtlb_wr_init_d2),
3130
        .q      (dtlb_wr_init_d3),
3131
        .clk    (clk),
3132 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3133 95 fafa1971
        );
3134
 
3135
wire    dtlb_wr_init_d4 ;
3136 113 albert.wat
dff_s  dtlbw_stgd4 (
3137 95 fafa1971
        .din    (dtlb_wr_init_d3),
3138
        .q      (dtlb_wr_init_d4),
3139
        .clk    (clk),
3140 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3141 95 fafa1971
        );
3142
 
3143
 
3144
 
3145
wire    tlb_access_sel_thrd3_d1,tlb_access_sel_thrd2_d1;
3146
wire    tlb_access_sel_thrd1_d1,tlb_access_sel_thrd0_d1 ;
3147
wire    ifu_asi_store_cmplt_en, ifu_asi_store_cmplt_en_d1 ;
3148
assign  stxa_stall_wr_cmplt0 =  (spu_lsu_stxa_ack & spu_stxa_thread0) |
3149
        (tlu_stxa_thread0_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3150
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd0_d1) |
3151
        dtlb_wr_cmplt0 ;
3152
assign  stxa_stall_wr_cmplt1 =  (spu_lsu_stxa_ack & spu_stxa_thread1) |
3153
        (tlu_stxa_thread1_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3154
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd1_d1) |
3155
        dtlb_wr_cmplt1 ;
3156
assign  stxa_stall_wr_cmplt2 =  (spu_lsu_stxa_ack & spu_stxa_thread2) |
3157
        (tlu_stxa_thread2_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3158
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd2_d1) |
3159
        dtlb_wr_cmplt2 ;
3160
assign  stxa_stall_wr_cmplt3 =  (spu_lsu_stxa_ack & spu_stxa_thread3) |
3161
        (tlu_stxa_thread3_w2 & tlu_lsu_stxa_ack & ~dtlb_wr_init_d4) |
3162
        (ifu_asi_store_cmplt_en_d1 & tlb_access_sel_thrd3_d1) |
3163
        dtlb_wr_cmplt3 ;
3164
 
3165 113 albert.wat
dff_s  #(4) stxastall_stgd1 (
3166 95 fafa1971
        .din    ({stxa_stall_wr_cmplt3,stxa_stall_wr_cmplt2,
3167
                stxa_stall_wr_cmplt1,stxa_stall_wr_cmplt0}),
3168
        .q      ({stxa_stall_wr_cmplt3_d1,stxa_stall_wr_cmplt2_d1,
3169
                stxa_stall_wr_cmplt1_d1,stxa_stall_wr_cmplt0_d1}),
3170
        .clk    (clk),
3171 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3172 95 fafa1971
        );
3173
 
3174
 
3175
// enable speculates on inst not being flushed
3176
// Only dside diagnostic writes will be logged for long-latency action. dside diagnostic
3177
// reads are aligned to pipe.
3178
wire wr_dc_diag_asi_e, wr_dtagv_diag_asi_e ;
3179
 
3180
assign  wr_dc_diag_asi_e = dc_diagnstc_asi_e & st_inst_vld_e ;
3181
assign  wr_dtagv_diag_asi_e =  dtagv_diagnstc_asi_e & st_inst_vld_e ;
3182
 
3183
assign  tlb_access_en0_e =
3184
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3185
    & thread0_e & alt_space_e ;
3186
assign  tlb_access_en1_e =
3187
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3188
    & thread1_e & alt_space_e ;
3189
assign  tlb_access_en2_e =
3190
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3191
    & thread2_e & alt_space_e ;
3192
assign  tlb_access_en3_e =
3193
  (tlb_lng_ltncy_asi_e | wr_dc_diag_asi_e | wr_dtagv_diag_asi_e | ifu_nontlb_asi_e)
3194
    & thread3_e & alt_space_e ;
3195
 
3196 113 albert.wat
dff_s  #(4) tlbac_stgm (
3197 95 fafa1971
        .din    ({tlb_access_en0_e,tlb_access_en1_e,tlb_access_en2_e,tlb_access_en3_e}),
3198
        .q      ({tlb_access_en0_tmp,tlb_access_en1_tmp,tlb_access_en2_tmp,tlb_access_en3_tmp}),
3199
        .clk    (clk),
3200 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3201 95 fafa1971
        );
3202
 
3203
wire    ldst_vld_m = ld_inst_vld_m | st_inst_vld_m ;
3204
assign  tlb_access_en0_m = tlb_access_en0_tmp & ldst_vld_m ;
3205
assign  tlb_access_en1_m = tlb_access_en1_tmp & ldst_vld_m ;
3206
assign  tlb_access_en2_m = tlb_access_en2_tmp & ldst_vld_m ;
3207
assign  tlb_access_en3_m = tlb_access_en3_tmp & ldst_vld_m ;
3208
 
3209 113 albert.wat
dff_s  #(4) tlbac_stgw (
3210 95 fafa1971
        .din    ({tlb_access_en0_m,tlb_access_en1_m,tlb_access_en2_m,tlb_access_en3_m}),
3211
        .q      ({tlb_access_en0_unflushed,tlb_access_en1_unflushed,tlb_access_en2_unflushed,tlb_access_en3_unflushed}),
3212
        .clk    (clk),
3213 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3214 95 fafa1971
        );
3215
 
3216
// Flush ld/st with as=42 belonging to lsu. bistctl and ldiag
3217
 
3218
assign  tlb_access_en0_g = tlb_access_en0_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3219
//assign  tlb_access_en0_g = tlb_access_en0_unflushed & lsu_inst_vld_w & ~(dctl_flush_pipe_w | ifu_asi42_flush_g) ;
3220
assign  tlb_access_en1_g = tlb_access_en1_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3221
assign  tlb_access_en2_g = tlb_access_en2_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3222
assign  tlb_access_en3_g = tlb_access_en3_unflushed & lsu_inst_vld_w & ~(dctl_early_flush_w | ifu_asi42_flush_g) ;
3223
 
3224
assign  diag_wr_cmplt0 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd0_d1 ;
3225
assign  diag_wr_cmplt1 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd1_d1 ;
3226
assign  diag_wr_cmplt2 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd2_d1 ;
3227
assign  diag_wr_cmplt3 = lsu_diagnstc_wr_src_sel_e & tlb_access_sel_thrd3_d1 ;
3228
 
3229
wire    ifu_tlb_rd_cmplt0,ifu_tlb_rd_cmplt1,ifu_tlb_rd_cmplt2,ifu_tlb_rd_cmplt3 ;
3230
wire    st_sqsh_m, ifu_asi_ack_d1 ;
3231
assign  ifu_tlb_rd_cmplt0 =  (ifu_ldxa_thread0_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb0_asi) ;
3232
assign  ifu_tlb_rd_cmplt1 =  (ifu_ldxa_thread1_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb1_asi) ;
3233
assign  ifu_tlb_rd_cmplt2 =  (ifu_ldxa_thread2_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb2_asi) ;
3234
assign  ifu_tlb_rd_cmplt3 =  (ifu_ldxa_thread3_w2 & ifu_lsu_ldxa_data_vld_w2 & ~ifu_nontlb3_asi) ;
3235
 
3236
// stxa ack will share tid with ldxa
3237
// This should be qualified with inst_vld_w also !!!
3238
// ldxa_data_vld needs to be removed once full interface in !!!
3239
assign  tlb_access_rst0 =  reset |
3240
  (tlu_ldxa_thread0_w2 & tlu_lsu_ldxa_async_data_vld) |
3241
  (tlu_stxa_thread0_w2 & tlu_lsu_stxa_ack) |
3242
  (ifu_tlb_rd_cmplt0) |
3243
  (ifu_stxa_thread0_w2 & ifu_lsu_asi_ack) |
3244
  diag_wr_cmplt0 ;
3245
assign  tlb_access_rst1 =  reset |
3246
  (tlu_ldxa_thread1_w2 & tlu_lsu_ldxa_async_data_vld) |
3247
  (tlu_stxa_thread1_w2 & tlu_lsu_stxa_ack) |
3248
  (ifu_tlb_rd_cmplt1) |
3249
  (ifu_stxa_thread1_w2 & ifu_lsu_asi_ack) |
3250
  diag_wr_cmplt1 ;
3251
assign  tlb_access_rst2 =  reset |
3252
  (tlu_ldxa_thread2_w2 & tlu_lsu_ldxa_async_data_vld) |
3253
  (tlu_stxa_thread2_w2 & tlu_lsu_stxa_ack) |
3254
  (ifu_tlb_rd_cmplt2) |
3255
  (ifu_stxa_thread2_w2 & ifu_lsu_asi_ack) |
3256
  diag_wr_cmplt2 ;
3257
assign  tlb_access_rst3 =  reset |
3258
  (tlu_ldxa_thread3_w2 & tlu_lsu_ldxa_async_data_vld) |
3259
  (tlu_stxa_thread3_w2 & tlu_lsu_stxa_ack) |
3260
  (ifu_tlb_rd_cmplt3) |
3261
  (ifu_stxa_thread3_w2 & ifu_lsu_asi_ack) |
3262
  diag_wr_cmplt3 ;
3263
 
3264
 
3265
// tlb_ld_inst* and tlb_st_inst* are generically used to indicate a read or write. 
3266
// Thread 0
3267
 
3268 113 albert.wat
dffre_s #(2)  asiv_thrd0 (
3269 95 fafa1971
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3270
        .q      ({tlb_ld_inst0,tlb_st_inst0}),
3271
        .rst    (tlb_access_rst0),        .en     (tlb_access_en0_g),
3272
        .clk    (clk),
3273 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3274 95 fafa1971
        );
3275
 
3276 113 albert.wat
dffe_s #(3)  asiv_thrd0_sec (
3277 95 fafa1971
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3278
        .q      ({dc0_diagnstc_asi,dtagv0_diagnstc_asi,ifu_nontlb0_asi}),
3279
        .en     (tlb_access_en0_g),
3280
        .clk    (clk),
3281 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3282 95 fafa1971
        );
3283
 
3284
assign  nontlb_asi0 = dc0_diagnstc_asi | dtagv0_diagnstc_asi | ifu_nontlb0_asi ;
3285
 
3286
// Thread 1
3287
 
3288 113 albert.wat
dffre_s #(2)  asiv_thrd1 (
3289 95 fafa1971
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3290
        .q      ({tlb_ld_inst1,tlb_st_inst1}),
3291
        .rst    (tlb_access_rst1),        .en     (tlb_access_en1_g),
3292
        .clk    (clk),
3293 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3294 95 fafa1971
        );
3295
 
3296 113 albert.wat
dffe_s #(3)  asiv_thrd1_sec (
3297 95 fafa1971
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3298
        .q      ({dc1_diagnstc_asi,dtagv1_diagnstc_asi,ifu_nontlb1_asi}),
3299
        .en     (tlb_access_en1_g),
3300
        .clk    (clk),
3301 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3302 95 fafa1971
        );
3303
 
3304
assign  nontlb_asi1 = dc1_diagnstc_asi | dtagv1_diagnstc_asi | ifu_nontlb1_asi ;
3305
 
3306
// Thread 2
3307
 
3308 113 albert.wat
dffre_s #(2)  asiv_thrd2 (
3309 95 fafa1971
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3310
        .q      ({tlb_ld_inst2,tlb_st_inst2}),
3311
        .rst    (tlb_access_rst2),        .en     (tlb_access_en2_g),
3312
        .clk    (clk),
3313 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3314 95 fafa1971
        );
3315
 
3316 113 albert.wat
dffe_s #(3)  asiv_thrd2_sec (
3317 95 fafa1971
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3318
        .q      ({dc2_diagnstc_asi,dtagv2_diagnstc_asi,ifu_nontlb2_asi}),
3319
        .en     (tlb_access_en2_g),
3320
        .clk    (clk),
3321 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3322 95 fafa1971
        );
3323
 
3324
assign  nontlb_asi2 = dc2_diagnstc_asi | dtagv2_diagnstc_asi | ifu_nontlb2_asi ;
3325
 
3326
// Thread 3
3327
 
3328 113 albert.wat
dffre_s #(2)  asiv_thrd3 (
3329 95 fafa1971
        .din    ({ld_inst_vld_g,st_inst_vld_g}),
3330
        .q      ({tlb_ld_inst3,tlb_st_inst3}),
3331
        .rst    (tlb_access_rst3),        .en     (tlb_access_en3_g),
3332
        .clk    (clk),
3333 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3334 95 fafa1971
        );
3335
 
3336 113 albert.wat
dffe_s #(3)  asiv_thrd3_sec (
3337 95 fafa1971
        .din    ({dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,ifu_nontlb_asi_g}),
3338
        .q      ({dc3_diagnstc_asi,dtagv3_diagnstc_asi,ifu_nontlb3_asi}),
3339
        .en     (tlb_access_en3_g),
3340
        .clk    (clk),
3341 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3342 95 fafa1971
        );
3343
 
3344
assign  nontlb_asi3 = dc3_diagnstc_asi | dtagv3_diagnstc_asi | ifu_nontlb3_asi ;
3345
 
3346
//---
3347
//  Prioritization of threaded events from asi queue.
3348
//  - It is not expected that a significant bias will exist in selecting
3349
//  1 of 4 possible events from the asi queue because of the low frequency
3350
//  of such events. However, to bulletproof we will prioritize the events
3351
//  in a fifo manner.
3352
//---
3353
 
3354
// Control :
3355
 
3356
wire    [3:0]    fifo_top ;
3357
wire    asi_fifo0_vld,asi_fifo1_vld,asi_fifo2_vld,asi_fifo3_vld;
3358
 
3359
assign  fifo_top[0] = ~asi_fifo0_vld ;
3360
assign  fifo_top[1] = ~asi_fifo1_vld & asi_fifo0_vld ;
3361
assign  fifo_top[2] = ~asi_fifo2_vld & asi_fifo1_vld & asi_fifo0_vld ;
3362
assign  fifo_top[3] = ~asi_fifo3_vld & asi_fifo2_vld & asi_fifo1_vld & asi_fifo0_vld ;
3363
 
3364
// Check for timing on flush.
3365
// Do not confuse thread# with fifo entry#.
3366
wire    fifo_wr, fifo_shift ;
3367
assign  fifo_wr =
3368
tlb_access_en0_g | tlb_access_en1_g | tlb_access_en2_g | tlb_access_en3_g ;
3369
assign  fifo_shift =
3370
tlb_access_rst0 | tlb_access_rst1 | tlb_access_rst2 | tlb_access_rst3 ;
3371
 
3372
wire    [3:0]    fifo_top_wr ;
3373
assign  fifo_top_wr[0] = fifo_top[0] & fifo_wr ;
3374
assign  fifo_top_wr[1] = fifo_top[1] & fifo_wr ;
3375
assign  fifo_top_wr[2] = fifo_top[2] & fifo_wr ;
3376
assign  fifo_top_wr[3] = fifo_top[3] & fifo_wr ;
3377
 
3378
// Matrix for Data Selection.
3379
// shift | wr | din for entry
3380
// 0       0    na
3381
// 0       1    thrid_g
3382
// 1       0    q
3383
// 1       1    q if top is not 1 above
3384
// 1       1    thrid_g if top is 1 above
3385
 
3386
// shift writeable entry into correct position, if exists.
3387
wire    asi_fifo0_sel,asi_fifo1_sel,asi_fifo2_sel ;
3388
assign  asi_fifo0_sel = fifo_shift ? fifo_top_wr[1] : fifo_top_wr[0] ;
3389
assign  asi_fifo1_sel = fifo_shift ? fifo_top_wr[2] : fifo_top_wr[1] ;
3390
assign  asi_fifo2_sel = fifo_shift ? fifo_top_wr[3] : fifo_top_wr[2] ;
3391
 
3392
wire    [1:0]    asi_fifo3_din,asi_fifo2_din,asi_fifo1_din,asi_fifo0_din ;
3393
wire    [1:0]    asi_fifo3_q,asi_fifo2_q,asi_fifo1_q,asi_fifo0_q ;
3394
assign  asi_fifo0_din[1:0] = asi_fifo0_sel ? thrid_g[1:0] : asi_fifo1_q[1:0] ;
3395
assign  asi_fifo1_din[1:0] = asi_fifo1_sel ? thrid_g[1:0] : asi_fifo2_q[1:0] ;
3396
assign  asi_fifo2_din[1:0] = asi_fifo2_sel ? thrid_g[1:0] : asi_fifo3_q[1:0] ;
3397
assign  asi_fifo3_din[1:0] = thrid_g[1:0] ; // can never shift into.
3398
 
3399
// Matrix for Enable 
3400
// shift | wr | Entry Written ?
3401
// 0       0    0
3402
// 0       1    if top
3403
// 1       0    if entry+1 is vld
3404
// 1       1    if entry itself is vld => as is.
3405
 
3406
wire    wr_not_sh,sh_not_wr,wr_and_sh ;
3407
assign  wr_not_sh =  fifo_wr & ~fifo_shift ; // write not shift
3408
assign  sh_not_wr = ~fifo_wr &  fifo_shift ; // shift not write
3409
assign  wr_and_sh =  fifo_wr &  fifo_shift ; // shift and write
3410
 
3411
wire    asi_fifo0_vin,asi_fifo1_vin,asi_fifo2_vin,asi_fifo3_vin ;
3412
assign  asi_fifo0_vin =
3413
        (wr_not_sh & fifo_top[0]) |
3414
        (sh_not_wr & asi_fifo1_vld) |
3415
        (wr_and_sh & asi_fifo0_vld) ;
3416
assign  asi_fifo1_vin =
3417
        (wr_not_sh & fifo_top[1]) |
3418
        (sh_not_wr & asi_fifo2_vld) |
3419
        (wr_and_sh & asi_fifo1_vld) ;
3420
assign  asi_fifo2_vin =
3421
        (wr_not_sh & fifo_top[2]) |
3422
        (sh_not_wr & asi_fifo3_vld) |
3423
        (wr_and_sh & asi_fifo2_vld) ;
3424
assign  asi_fifo3_vin =
3425
        (wr_not_sh & fifo_top[3]) |
3426
        (wr_and_sh & asi_fifo3_vld) ;
3427
 
3428
wire    asi_fifo0_en,asi_fifo1_en,asi_fifo2_en,asi_fifo3_en ;
3429
assign  asi_fifo0_en = (fifo_wr & fifo_top[0]) | fifo_shift ;
3430
assign  asi_fifo1_en = (fifo_wr & fifo_top[1]) | fifo_shift ;
3431
assign  asi_fifo2_en = (fifo_wr & fifo_top[2]) | fifo_shift ;
3432
assign  asi_fifo3_en = (fifo_wr & fifo_top[3]) | fifo_shift ;
3433
 
3434
wire    asi_fifo3_rst,asi_fifo2_rst,asi_fifo1_rst,asi_fifo0_rst ;
3435
assign  asi_fifo0_rst = reset ;
3436
assign  asi_fifo1_rst = reset ;
3437
assign  asi_fifo2_rst = reset ;
3438
assign  asi_fifo3_rst = reset ;
3439
 
3440
// Datapath :
3441
// fifo entry 0 is earliest. fifo entry 3 is latest.
3442 113 albert.wat
dffe_s #(2)  asiq_fifo_0 (
3443 95 fafa1971
        .din    (asi_fifo0_din[1:0]),
3444
        .q      (asi_fifo0_q[1:0]),
3445
        .en     (asi_fifo0_en),
3446
        .clk    (clk),
3447 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3448 95 fafa1971
        );
3449
 
3450 113 albert.wat
dffre_s   asiqv_fifo_0 (
3451 95 fafa1971
        .din    (asi_fifo0_vin),
3452
        .q      (asi_fifo0_vld),
3453
        .en     (asi_fifo0_en), .rst (asi_fifo0_rst),
3454
        .clk    (clk),
3455 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3456 95 fafa1971
        );
3457
 
3458
wire    asi_sel_thrd3,asi_sel_thrd2,asi_sel_thrd1,asi_sel_thrd0;
3459
assign  asi_sel_thrd0 = ~asi_fifo0_q[1] & ~asi_fifo0_q[0] & (tlb_ld_inst0 | tlb_st_inst0) ;
3460
assign  asi_sel_thrd1 = ~asi_fifo0_q[1] &  asi_fifo0_q[0] & (tlb_ld_inst1 | tlb_st_inst1) ;
3461
assign  asi_sel_thrd2 =  asi_fifo0_q[1] & ~asi_fifo0_q[0] & (tlb_ld_inst2 | tlb_st_inst2) ;
3462
assign  asi_sel_thrd3 =  asi_fifo0_q[1] &  asi_fifo0_q[0] & (tlb_ld_inst3 | tlb_st_inst3) ;
3463
 
3464 113 albert.wat
dffe_s #(2)  asiq_fifo_1 (
3465 95 fafa1971
        .din    (asi_fifo1_din[1:0]),
3466
        .q      (asi_fifo1_q[1:0]),
3467
        .en     (asi_fifo1_en),
3468
        .clk    (clk),
3469 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3470 95 fafa1971
        );
3471
 
3472 113 albert.wat
dffre_s  asiqv_fifo_1 (
3473 95 fafa1971
        .din    (asi_fifo1_vin),
3474
        .q      (asi_fifo1_vld),
3475
        .en     (asi_fifo1_en), .rst    (asi_fifo1_rst),
3476
        .clk    (clk),
3477 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3478 95 fafa1971
        );
3479
 
3480 113 albert.wat
dffe_s #(2)  asiq_fifo_2 (
3481 95 fafa1971
        .din    (asi_fifo2_din[1:0]),
3482
        .q      (asi_fifo2_q[1:0]),
3483
        .en     (asi_fifo2_en),
3484
        .clk    (clk),
3485 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3486 95 fafa1971
        );
3487
 
3488 113 albert.wat
dffre_s   asiqv_fifo_2 (
3489 95 fafa1971
        .din    (asi_fifo2_vin),
3490
        .q      (asi_fifo2_vld),
3491
        .en     (asi_fifo2_en), .rst    (asi_fifo2_rst),
3492
        .clk    (clk),
3493 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3494 95 fafa1971
        );
3495
 
3496 113 albert.wat
dffe_s #(2)  asiq_fifo_3 (
3497 95 fafa1971
        .din    (asi_fifo3_din[1:0]),
3498
        .q      (asi_fifo3_q[1:0]),
3499
        .en     (asi_fifo3_en),
3500
        .clk    (clk),
3501 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3502 95 fafa1971
        );
3503
 
3504 113 albert.wat
dffre_s  asiqv_fifo_3 (
3505 95 fafa1971
        .din    (asi_fifo3_vin),
3506
        .q      (asi_fifo3_vld),
3507
        .en     (asi_fifo3_en), .rst    (asi_fifo3_rst),
3508
        .clk    (clk),
3509 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3510 95 fafa1971
        );
3511
 
3512
//---
3513
 
3514
assign  tlb_access_initiated =
3515
  ((tlb_access_sel_thrd0 & ~tlb_access_rst0) |
3516
   (tlb_access_sel_thrd1 & ~tlb_access_rst1) |
3517
   (tlb_access_sel_thrd2 & ~tlb_access_rst2) |
3518
   (tlb_access_sel_thrd3 & ~tlb_access_rst3)) & ~tlb_access_pending ;
3519
 
3520
 
3521
wire  tlb_blocking_rst ;
3522
assign  tlb_blocking_rst = reset |
3523
  tlu_lsu_stxa_ack | tlu_lsu_ldxa_async_data_vld |
3524
  ifu_tlb_rd_cmplt0 | ifu_tlb_rd_cmplt1 |
3525
  ifu_tlb_rd_cmplt2 | ifu_tlb_rd_cmplt3 |
3526
  ifu_lsu_asi_ack |
3527
  lsu_diagnstc_wr_src_sel_e;
3528
 
3529
 
3530
// MMU/IFU/DIAG Action is pending
3531 113 albert.wat
dffre_s #(1)  tlbpnd (
3532 95 fafa1971
        .din    (tlb_access_initiated),
3533
        .q      (tlb_access_pending),
3534
        .rst    (tlb_blocking_rst),        .en     (tlb_access_initiated),
3535
        .clk    (clk),
3536 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3537 95 fafa1971
        );
3538
 
3539
/*wire  asi_pend0,asi_pend1,asi_pend2,asi_pend3 ;
3540 113 albert.wat
dffre_s #(4)  asithrdpnd (
3541 95 fafa1971
        .din    ({tlb_access_sel_thrd3,tlb_access_sel_thrd2,
3542
                            tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
3543
        .q    ({asi_pend3,asi_pend2,asi_pend1,asi_pend0}),
3544
        .rst    (tlb_blocking_rst),     .en     (tlb_access_initiated),
3545
        .clk  (clk),
3546 113 albert.wat
        .se   (se),       `SIMPLY_RISC_SCANIN,          .so ()
3547 95 fafa1971
        );
3548
 
3549
wire    asi_pend_non_thrd0 ;
3550
assign  asi_pend_non_thrd0 = asi_pend1 | asi_pend2 | asi_pend3 ;
3551
wire    asi_pend_non_thrd1 ;
3552
assign  asi_pend_non_thrd1 = asi_pend0 | asi_pend2 | asi_pend3 ;
3553
wire    asi_pend_non_thrd2 ;
3554
assign  asi_pend_non_thrd2 = asi_pend0 | asi_pend1 | asi_pend3 ;
3555
wire    asi_pend_non_thrd3 ;
3556
assign  asi_pend_non_thrd3 = asi_pend0 | asi_pend1 | asi_pend2 ; */
3557
 
3558
// Would like to remove st_inst_vld_m. This is however required to
3559
// source rs3 data to tlu/mmu. Send rs3_data directly !!!
3560
 
3561
wire    diag_wr_src, diag_wr_src_d1, diag_wr_src_d2 ;
3562
 
3563
assign  tlb_access_blocked =
3564
  (tlb_access_pending & ~ifu_asi_vld_d1 & ~diag_wr_src_d1) |
3565
  (st_sqsh_m & ~(ifu_asi_vld_d1 & ~ifu_asi_ack_d1) & ~diag_wr_src_d1) ; // Bug 4875
3566
  //(st_inst_vld_m & ~lsu_ifu_asi_vld_d1 & ~diag_wr_src_d1) ;
3567
 
3568
// fixed priority. tlb accesses are issued speculatively in the m-stage and are
3569
// Change priority to round-robin !!!
3570
// flushed in the g-stage in the tlu if necessary.
3571
// diagnstc writes will block for cache/tag access.
3572
// This means that access can be blocked if a st is 
3573
// in the m-stage or a memref in the d stage. (!!!)
3574
// In this case, it is better to stage a different
3575
// bus for rs3 data.
3576
 
3577
// Note : Selection Process.
3578
// 1. Priority Encoded selection if no access pending.
3579
// This may have to be changed to prevent bias towards a
3580
// single thread.
3581
// 2. Once thread is selected :
3582
//      a. generate single pulse - mmu. tlb_access_blocked
3583
//      used for this purpose.
3584
//      b. generate window - ifu/diag. To prevent spurious change
3585
//      in selects, asi_pend_non_thrdx and tlb_access_pending
3586
//      qual. is required.
3587
 
3588
 
3589
assign  tlb_access_sel_thrd0 = ~rst_tri_en &
3590
  asi_sel_thrd0 & ~tlb_access_blocked ;
3591
assign  tlb_access_sel_thrd1 = ~rst_tri_en &
3592
  asi_sel_thrd1 & ~tlb_access_blocked ;
3593
assign  tlb_access_sel_thrd2 = ~rst_tri_en &
3594
  asi_sel_thrd2 & ~tlb_access_blocked ;
3595
assign  tlb_access_sel_thrd3 = ~rst_tri_en &
3596
  asi_sel_thrd3 & ~tlb_access_blocked ;
3597
 
3598
//assign  tlb_access_sel_thrd0 = ~rst_tri_en & ( 
3599
//  (tlb_ld_inst0 | tlb_st_inst0) & ~tlb_access_blocked & 
3600
//  ~asi_pend_non_thrd0 );
3601
//assign  tlb_access_sel_thrd1 = ~rst_tri_en & (
3602
//  (tlb_ld_inst1 | tlb_st_inst1) & 
3603
//  ~(((tlb_ld_inst0 | tlb_st_inst0) & ~tlb_access_pending) | tlb_access_blocked) & 
3604
//  ~asi_pend_non_thrd1 );
3605
//assign  tlb_access_sel_thrd2 = ~rst_tri_en & ( 
3606
//  (tlb_ld_inst2 | tlb_st_inst2) & 
3607
//  ~(((tlb_ld_inst0 | tlb_st_inst0 | tlb_ld_inst1 | tlb_st_inst1) & ~tlb_access_pending) 
3608
//              | tlb_access_blocked) &
3609
//  ~asi_pend_non_thrd2 );
3610
//assign  tlb_access_sel_thrd3 = ~rst_tri_en & ( 
3611
//  (tlb_ld_inst3 | tlb_st_inst3) & 
3612
//  ~(((tlb_ld_inst0 | tlb_st_inst0 | tlb_ld_inst1 | tlb_st_inst1 | 
3613
//    tlb_ld_inst2 | tlb_st_inst2) & ~tlb_access_pending) | tlb_access_blocked) &
3614
//  ~asi_pend_non_thrd3 );
3615
 
3616 113 albert.wat
dff_s  #(4) selt_stgd1 (
3617 95 fafa1971
        .din    ({tlb_access_sel_thrd3,tlb_access_sel_thrd2,
3618
                tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
3619
        .q     ({tlb_access_sel_thrd3_d1,tlb_access_sel_thrd2_d1,
3620
                tlb_access_sel_thrd1_d1,tlb_access_sel_thrd0_d1}),
3621
        .clk    (clk),
3622 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3623 95 fafa1971
        );
3624
 
3625
   wire tlb_access_sel_default;
3626
assign  tlb_access_sel_default = rst_tri_en | (
3627
        ~(tlb_access_sel_thrd2 | tlb_access_sel_thrd1 | tlb_access_sel_thrd0));
3628
 
3629 113 albert.wat
dff_s  #(4) lsu_diagnstc_data_sel_ff (
3630 95 fafa1971
        .din    ({tlb_access_sel_default,tlb_access_sel_thrd2,
3631
                tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
3632
        .q     ({lsu_diagnstc_data_sel[3:0]}),
3633
        .clk    (clk),
3634 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3635 95 fafa1971
        );
3636
 
3637 113 albert.wat
dff_s  #(4) lsu_diagnstc_va_sel_ff (
3638 95 fafa1971
        .din    ({tlb_access_sel_default,tlb_access_sel_thrd2,
3639
                tlb_access_sel_thrd1,tlb_access_sel_thrd0}),
3640
        .q     ({lsu_diagnstc_va_sel[3:0]}),
3641
        .clk    (clk),
3642 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3643 95 fafa1971
        );
3644
 
3645
 
3646
// Begin - Bug 3487
3647
assign  st_sqsh_m =
3648
        (st_inst_vld_m & asi_internal_m & lsu_alt_space_m) ; // Squash as bus required for stxa.
3649
assign  tlb_st_data_sel_m[0] = (tlb_access_sel_thrd0 & ~st_sqsh_m) | (st_sqsh_m & thread0_m) ;
3650
assign  tlb_st_data_sel_m[1] = (tlb_access_sel_thrd1 & ~st_sqsh_m) | (st_sqsh_m & thread1_m) ;
3651
assign  tlb_st_data_sel_m[2] = (tlb_access_sel_thrd2 & ~st_sqsh_m) | (st_sqsh_m & thread2_m) ;
3652
assign  tlb_st_data_sel_m[3] = ~|tlb_st_data_sel_m[2:0];
3653
 
3654
assign  lsu_ifu_asi_data_en_l = ~(ifu_asi_vld & tlb_access_initiated) ;
3655
 
3656
// End - Bug 3487
3657
 
3658
/*assign  tlb_st_data_sel_m[0] = tlb_access_sel_thrd0 | ((st_inst_vld_m & thread0_m) & tlb_access_blocked) ;
3659
assign  tlb_st_data_sel_m[1] = tlb_access_sel_thrd1 | ((st_inst_vld_m & thread1_m) & tlb_access_blocked) ;
3660
assign  tlb_st_data_sel_m[2] = tlb_access_sel_thrd2 | ((st_inst_vld_m & thread2_m) & tlb_access_blocked) ;
3661
assign  tlb_st_data_sel_m[3] = ~|tlb_st_data_sel_m[2:0];*/
3662
 
3663
//assign        lsu_tlb_st_sel_m[3:0] = tlb_st_data_sel_m[3:0] ;
3664
assign  lsu_tlb_st_sel_m[0] = tlb_st_data_sel_m[0] & ~rst_tri_en;
3665
assign  lsu_tlb_st_sel_m[1] = tlb_st_data_sel_m[1] & ~rst_tri_en;
3666
assign  lsu_tlb_st_sel_m[2] = tlb_st_data_sel_m[2] & ~rst_tri_en;
3667
assign  lsu_tlb_st_sel_m[3] = tlb_st_data_sel_m[3] |  rst_tri_en;
3668
 
3669
assign  lsu_tlu_tlb_ld_inst_m =
3670
  (tlb_access_sel_thrd0 & tlb_ld_inst0 & ~nontlb_asi0) |
3671
  (tlb_access_sel_thrd1 & tlb_ld_inst1 & ~nontlb_asi1) |
3672
  (tlb_access_sel_thrd2 & tlb_ld_inst2 & ~nontlb_asi2) |
3673
  (tlb_access_sel_thrd3 & tlb_ld_inst3 & ~nontlb_asi3) ;
3674
 
3675
// diagnstic write for dside will not go thru tlu.
3676
assign  lsu_tlu_tlb_st_inst_m =
3677
  (tlb_access_sel_thrd0 & tlb_st_inst0 & ~nontlb_asi0) |
3678
  (tlb_access_sel_thrd1 & tlb_st_inst1 & ~nontlb_asi1) |
3679
  (tlb_access_sel_thrd2 & tlb_st_inst2 & ~nontlb_asi2) |
3680
  (tlb_access_sel_thrd3 & tlb_st_inst3 & ~nontlb_asi3) ;
3681
 
3682
assign  lsu_tlu_tlb_access_tid_m[0] = tlb_access_sel_thrd1 | tlb_access_sel_thrd3 ;
3683
assign  lsu_tlu_tlb_access_tid_m[1] = tlb_access_sel_thrd2 | tlb_access_sel_thrd3 ;
3684
 
3685
// Diagnostic write to dcache
3686
assign  dc0_diagnstc_wr_en = (tlb_access_sel_thrd0 & tlb_st_inst0 & dc0_diagnstc_asi) ;
3687
assign  dc1_diagnstc_wr_en = (tlb_access_sel_thrd1 & tlb_st_inst1 & dc1_diagnstc_asi) ;
3688
assign  dc2_diagnstc_wr_en = (tlb_access_sel_thrd2 & tlb_st_inst2 & dc2_diagnstc_asi) ;
3689
assign  dc3_diagnstc_wr_en = (tlb_access_sel_thrd3 & tlb_st_inst3 & dc3_diagnstc_asi) ;
3690
assign  dc_diagnstc_wr_en =
3691
  dc0_diagnstc_wr_en | dc1_diagnstc_wr_en | dc2_diagnstc_wr_en | dc3_diagnstc_wr_en ;
3692
 
3693
// Diagnostic write to dtag/vld
3694
assign  dtagv0_diagnstc_wr_en = (tlb_access_sel_thrd0 & tlb_st_inst0 & dtagv0_diagnstc_asi) ;
3695
assign  dtagv1_diagnstc_wr_en = (tlb_access_sel_thrd1 & tlb_st_inst1 & dtagv1_diagnstc_asi) ;
3696
assign  dtagv2_diagnstc_wr_en = (tlb_access_sel_thrd2 & tlb_st_inst2 & dtagv2_diagnstc_asi) ;
3697
assign  dtagv3_diagnstc_wr_en = (tlb_access_sel_thrd3 & tlb_st_inst3 & dtagv3_diagnstc_asi) ;
3698
assign  dtagv_diagnstc_wr_en =
3699
  dtagv0_diagnstc_wr_en | dtagv1_diagnstc_wr_en | dtagv2_diagnstc_wr_en | dtagv3_diagnstc_wr_en ;
3700
 
3701
// If a diagnostic access is selected in a cycle, then the earliest the
3702
// e-stage can occur for the write is 2-cycles later.
3703
 
3704
assign  diag_wr_src = dtagv_diagnstc_wr_en | dc_diagnstc_wr_en ;
3705
 
3706
   wire diag_wr_src_with_rst;
3707
   assign diag_wr_src_with_rst = diag_wr_src & ~lsu_diagnstc_wr_src_sel_e;
3708
 
3709 113 albert.wat
dff_s  #(1) diagwr_d1 (
3710 95 fafa1971
        .din    (diag_wr_src_with_rst),
3711
        .q      (diag_wr_src_d1),
3712
        .clk    (clk),
3713 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3714 95 fafa1971
        );
3715
 
3716
   wire diag_wr_src_d1_with_rst;
3717
   assign diag_wr_src_d1_with_rst = diag_wr_src_d1 & ~lsu_diagnstc_wr_src_sel_e;
3718
 
3719 113 albert.wat
dff_s  #(1) diagwr_d2 (
3720 95 fafa1971
        .din    (diag_wr_src_d1_with_rst),
3721
        .q      (diag_wr_src_d2),
3722
        .clk    (clk),
3723 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3724 95 fafa1971
        );
3725
 
3726
// If there is no memory reference, then the diag access is free to go.
3727
// tlb_access_blocked must be set appr. 
3728
wire diag_wr_src_sel_d1, diag_wr_src_sel_din;
3729
 
3730
//bug4057: kill diagnostic write if dfq has valid requests to l1d$
3731
//assign diag_wr_src_sel_din = diag_wr_src_d2 & ~memref_e;
3732
assign diag_wr_src_sel_din = diag_wr_src_d2 & ~(memref_e | lsu_dfq_vld);
3733
 
3734
assign  lsu_diagnstc_wr_src_sel_e =  ~diag_wr_src_sel_d1 & diag_wr_src_sel_din ;
3735
 
3736 113 albert.wat
dff_s  #(1) diagwrsel_d1 (
3737 95 fafa1971
        .din    (diag_wr_src_sel_din),
3738
        .q      (diag_wr_src_sel_d1),
3739
        .clk    (clk),
3740 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3741 95 fafa1971
        );
3742
 
3743
// Decode for diagnostic cache/dtag/vld write 
3744
   //wire [13:11] lngltncy_ldst_va;
3745
 
3746
   //assign lngltncy_ldst_va[13:11]= lsu_lngltncy_ldst_va[13:11];
3747
 
3748
//assign  lsu_diagnstc_wr_way_e[0] = ~lngltncy_ldst_va[12] & ~lngltncy_ldst_va[11] ;
3749
//assign  lsu_diagnstc_wr_way_e[1] = ~lngltncy_ldst_va[12] &  lngltncy_ldst_va[11] ;
3750
//assign  lsu_diagnstc_wr_way_e[2] =  lngltncy_ldst_va[12] & ~lngltncy_ldst_va[11] ;
3751
//assign  lsu_diagnstc_wr_way_e[3] =  lngltncy_ldst_va[12] &  lngltncy_ldst_va[11] ;
3752
 
3753
assign  lsu_diagnstc_dtagv_prty_invrt_e =
3754
        lsu_diag_va_prty_invrt & dtagv_diagnstc_wr_en & lsu_diagnstc_wr_src_sel_e ;
3755
 
3756
// ASI Interface to IFU
3757
 
3758
assign  lsu_ifu_asi_load =
3759
  (tlb_access_sel_thrd0 & tlb_ld_inst0 & ifu_nontlb0_asi) |
3760
  (tlb_access_sel_thrd1 & tlb_ld_inst1 & ifu_nontlb1_asi) |
3761
  (tlb_access_sel_thrd2 & tlb_ld_inst2 & ifu_nontlb2_asi) |
3762
  (tlb_access_sel_thrd3 & tlb_ld_inst3 & ifu_nontlb3_asi) ;
3763
 
3764
assign  ifu_asi_store =
3765
  (tlb_access_sel_thrd0 & tlb_st_inst0 & ifu_nontlb0_asi) |
3766
  (tlb_access_sel_thrd1 & tlb_st_inst1 & ifu_nontlb1_asi) |
3767
  (tlb_access_sel_thrd2 & tlb_st_inst2 & ifu_nontlb2_asi) |
3768
  (tlb_access_sel_thrd3 & tlb_st_inst3 & ifu_nontlb3_asi) ;
3769
 
3770
assign  ifu_asi_vld = lsu_ifu_asi_load | ifu_asi_store ;
3771
 
3772 113 albert.wat
dff_s  #(2) iasiv_d1 (
3773 95 fafa1971
        .din    ({ifu_asi_vld,ifu_lsu_asi_ack}),
3774
        .q      ({ifu_asi_vld_d1,ifu_asi_ack_d1}),
3775
        .clk    (clk),
3776 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3777 95 fafa1971
        );
3778
 
3779
// Bug 3932 - delay asi_vld for ifu.
3780
assign  lsu_ifu_asi_vld = ifu_asi_vld_d1 & ~ifu_asi_ack_d1 ;
3781
 
3782
assign  ifu_asi_store_cmplt_en = ifu_asi_store & ifu_lsu_asi_ack ;
3783 113 albert.wat
dff_s  #(1) iasist_d1 (
3784 95 fafa1971
        .din    (ifu_asi_store_cmplt_en),
3785
        .q      (ifu_asi_store_cmplt_en_d1),
3786
        .clk    (clk),
3787 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3788 95 fafa1971
        );
3789
 
3790
assign  lsu_ifu_asi_thrid[1:0] = lsu_tlu_tlb_access_tid_m[1:0] ;
3791
 
3792
 
3793
//=========================================================================================
3794
//  MEMBAR/FLUSH HANDLING
3795
//=========================================================================================
3796
 
3797
// Check for skids in this area - verification.
3798
 
3799
wire [3:0] no_spc_rmo_st ;
3800
 
3801
// Can membar/flush cause switch out from front end ??? Need to remove from
3802
// ldst_miss if case.
3803
// membar/flush will both swo thread and assert flush.
3804
// membar will signal completion once stb for thread empty
3805
// flush  will signal completion once flush pkt is visible at head of cfq and
3806
// i-side invalidates are complete
3807
// ** flush bit needs to be added to dfq **
3808
 
3809 113 albert.wat
dff_s  #(2) bsync_stgm (
3810 95 fafa1971
        .din    ({ifu_tlu_mb_inst_e,ifu_tlu_flsh_inst_e}),
3811
        .q      ({mbar_inst_m,flsh_inst_m}),
3812
        .clk    (clk),
3813 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3814 95 fafa1971
        );
3815
 
3816
assign  lsu_flsh_inst_m = flsh_inst_m ;
3817
 
3818
wire  mbar_inst_unflushed,flsh_inst_unflushed ;
3819
 
3820 113 albert.wat
dff_s  #(2) bsync_stgg (
3821 95 fafa1971
        .din    ({mbar_inst_m,flsh_inst_m}),
3822
        .q      ({mbar_inst_unflushed,flsh_inst_unflushed}),
3823
        .clk    (clk),
3824 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3825 95 fafa1971
        );
3826
 
3827
wire    [3:0]    flsh_cmplt_d1 ;
3828
/*dff  #(4) flshcmplt (
3829
        .din    (lsu_dfq_flsh_cmplt[3:0]),
3830
        .q      (flsh_cmplt_d1[3:0]),
3831
        .clk    (clk),
3832 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3833 95 fafa1971
        );*/
3834
 
3835
// now flopped in dctl
3836
assign  flsh_cmplt_d1[3:0] = lsu_dfq_flsh_cmplt[3:0] ;
3837
 
3838
assign  mbar_inst_g = mbar_inst_unflushed & lsu_inst_vld_w ;
3839
assign  flsh_inst_g = flsh_inst_unflushed & lsu_inst_vld_w ;
3840
 
3841
// THREAD0 MEMBAR/FLUSH
3842
 
3843
// barrier sync
3844
assign bsync0_reset =
3845
        reset  | (mbar_vld0 & lsu_stb_empty[0] & no_spc_rmo_st[0])
3846
               | (flsh_vld0 & flsh_cmplt_d1[0]) ;
3847
 
3848
assign  bsync0_en = (flush_inst0_g | mbar_inst0_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
3849
 
3850
assign  flush_inst0_g = flsh_inst_g & thread0_g ;
3851
assign  mbar_inst0_g  = mbar_inst_g & thread0_g ;
3852
 
3853
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
3854
// thread's stb
3855 113 albert.wat
dffre_s #(2)  bsync_vld0 (
3856 95 fafa1971
        .din    ({mbar_inst0_g,flush_inst0_g}),
3857
        .q      ({mbar_vld0,flsh_vld0}),
3858
        .rst    (bsync0_reset),        .en     (bsync0_en),
3859
        .clk    (clk),
3860 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3861 95 fafa1971
        );
3862
 
3863
// THREAD1 MEMBAR/FLUSH
3864
 
3865
// barrier sync
3866
assign bsync1_reset =
3867
        reset  | (mbar_vld1 & lsu_stb_empty[1] & no_spc_rmo_st[1])
3868
               | (flsh_vld1 & flsh_cmplt_d1[1]) ;
3869
 
3870
assign  bsync1_en = (flush_inst1_g | mbar_inst1_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
3871
 
3872
assign  flush_inst1_g = flsh_inst_g & thread1_g ;
3873
assign  mbar_inst1_g  = mbar_inst_g & thread1_g ;
3874
 
3875
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
3876
// thread's stb
3877 113 albert.wat
dffre_s #(2)  bsync_vld1 (
3878 95 fafa1971
        .din    ({mbar_inst1_g,flush_inst1_g}),
3879
        .q      ({mbar_vld1,flsh_vld1}),
3880
        .rst    (bsync1_reset),        .en     (bsync1_en),
3881
        .clk    (clk),
3882 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3883 95 fafa1971
        );
3884
 
3885
// THREAD2 MEMBAR/FLUSH
3886
 
3887
// barrier sync
3888
assign bsync2_reset =
3889
        reset  | (mbar_vld2 & lsu_stb_empty[2] & no_spc_rmo_st[2])
3890
               | (flsh_vld2 & flsh_cmplt_d1[2]) ;
3891
 
3892
assign  bsync2_en = (flush_inst2_g | mbar_inst2_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
3893
 
3894
assign  flush_inst2_g = flsh_inst_g & thread2_g ;
3895
assign  mbar_inst2_g  = mbar_inst_g & thread2_g ;
3896
 
3897
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
3898
// thread's stb
3899 113 albert.wat
dffre_s #(2)  bsync_vld2 (
3900 95 fafa1971
        .din    ({mbar_inst2_g,flush_inst2_g}),
3901
        .q      ({mbar_vld2,flsh_vld2}),
3902
        .rst    (bsync2_reset),        .en     (bsync2_en),
3903
        .clk    (clk),
3904 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3905 95 fafa1971
        );
3906
 
3907
// THREAD3 MEMBAR/FLUSH
3908
 
3909
// barrier sync
3910
assign bsync3_reset =
3911
        reset  | (mbar_vld3 & lsu_stb_empty[3] & no_spc_rmo_st[3])
3912
               | (flsh_vld3 & flsh_cmplt_d1[3]) ;
3913
 
3914
assign  bsync3_en = (flush_inst3_g | mbar_inst3_g) & lsu_inst_vld_w & ~dctl_flush_pipe_w ;
3915
 
3916
assign  flush_inst3_g = flsh_inst_g & thread3_g ;
3917
assign  mbar_inst3_g  = mbar_inst_g & thread3_g ;
3918
 
3919
// bsyncs are set in g-stage to allow earlier stores in pipe to drain to 
3920
// thread's stb
3921 113 albert.wat
dffre_s #(2)  bsync_vld3 (
3922 95 fafa1971
        .din    ({mbar_inst3_g,flush_inst3_g}),
3923
        .q      ({mbar_vld3,flsh_vld3}),
3924
        .rst    (bsync3_reset),        .en     (bsync3_en),
3925
        .clk    (clk),
3926 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3927 95 fafa1971
        );
3928
 
3929
//=========================================================================================
3930
//  RMO Store Ack Count
3931
//=========================================================================================
3932
 
3933
// Each thread maintains an 8b outstanding rmo ack count. To avoid overflow,
3934
// it is the responsiblity of software to insert a membar after at most 256 rmo stores.
3935
// 03/08/2003 now change from 256 to 16
3936
// 8 outstanding instead of 16   
3937
 
3938
wire    [3:0]    ackcnt0,ackcnt1,ackcnt2,ackcnt3 ;
3939
wire    [3:0]    ackcnt0_din,ackcnt1_din,ackcnt2_din,ackcnt3_din ;
3940
 
3941
// st_rmo_issue/st_rmo_ack vectors are one hot.
3942
// Adders(2). Need two as two separate threads can be incremented and decremented
3943
// in a cycle.
3944
wire    [3:0]    ackcnt_incr, ackcnt_decr ;
3945
wire    [3:0]    ackcnt_mx_incr, ackcnt_mx_decr ;
3946
 
3947
   wire [3:0] acknt_mx_incr_sel;
3948
   assign     acknt_mx_incr_sel[3:0] = lsu_stb_rmo_st_issue[3:0];
3949
 
3950
assign ackcnt_mx_incr[3:0] =
3951
  (acknt_mx_incr_sel[0] ? ackcnt0[3:0] :  4'b0) |
3952
  (acknt_mx_incr_sel[1] ? ackcnt1[3:0] :  4'b0) |
3953
  (acknt_mx_incr_sel[2] ? ackcnt2[3:0] :  4'b0) |
3954
  (acknt_mx_incr_sel[3] ? ackcnt3[3:0] :  4'b0) ;
3955
 
3956
 
3957
   wire [3:0] acknt_mx_decr_sel;
3958
   assign     acknt_mx_decr_sel[3:0] = lsu_cpx_rmo_st_ack[3:0];
3959
 
3960
assign ackcnt_mx_decr[3:0] =
3961
  (acknt_mx_decr_sel[0] ? ackcnt0[3:0] : 4'b0 ) |
3962
  (acknt_mx_decr_sel[1] ? ackcnt1[3:0] : 4'b0 ) |
3963
  (acknt_mx_decr_sel[2] ? ackcnt2[3:0] : 4'b0 ) |
3964
  (acknt_mx_decr_sel[3] ? ackcnt3[3:0] : 4'b0 ) ;
3965
 
3966
 
3967
assign  ackcnt_incr[3:0] = ackcnt_mx_incr[3:0] + 4'b0001 ;
3968
assign  ackcnt_decr[3:0] = ackcnt_mx_decr[3:0] - 4'b0001 ;
3969
 
3970
assign  ackcnt0_din[3:0] = lsu_cpx_rmo_st_ack[0] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
3971
assign  ackcnt1_din[3:0] = lsu_cpx_rmo_st_ack[1] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
3972
assign  ackcnt2_din[3:0] = lsu_cpx_rmo_st_ack[2] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
3973
assign  ackcnt3_din[3:0] = lsu_cpx_rmo_st_ack[3] ? ackcnt_decr[3:0] : ackcnt_incr[3:0] ;
3974
 
3975
wire    [3:0]    ackcnt_en ;
3976
// if both occur in the same cycle then they cancel out.
3977
assign  ackcnt_en[0] = lsu_stb_rmo_st_issue[0] ^ lsu_cpx_rmo_st_ack[0] ;
3978
assign  ackcnt_en[1] = lsu_stb_rmo_st_issue[1] ^ lsu_cpx_rmo_st_ack[1] ;
3979
assign  ackcnt_en[2] = lsu_stb_rmo_st_issue[2] ^ lsu_cpx_rmo_st_ack[2] ;
3980
assign  ackcnt_en[3] = lsu_stb_rmo_st_issue[3] ^ lsu_cpx_rmo_st_ack[3] ;
3981
 
3982
// Thread0
3983 113 albert.wat
dffre_s #(4)  ackcnt0_ff (
3984 95 fafa1971
        .din    (ackcnt0_din[3:0]),
3985
        .q      (ackcnt0[3:0]),
3986
        .rst    (reset),        .en     (ackcnt_en[0]),
3987
        .clk    (clk),
3988 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3989 95 fafa1971
        );
3990
 
3991
// Thread1
3992 113 albert.wat
dffre_s #(4)  ackcnt1_ff (
3993 95 fafa1971
        .din    (ackcnt1_din[3:0]),
3994
        .q      (ackcnt1[3:0]),
3995
        .rst    (reset),        .en     (ackcnt_en[1]),
3996
        .clk    (clk),
3997 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
3998 95 fafa1971
        );
3999
 
4000
// Thread2
4001 113 albert.wat
dffre_s #(4)  ackcnt2_ff (
4002 95 fafa1971
        .din    (ackcnt2_din[3:0]),
4003
        .q      (ackcnt2[3:0]),
4004
        .rst    (reset),        .en     (ackcnt_en[2]),
4005
        .clk    (clk),
4006 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4007 95 fafa1971
        );
4008
 
4009
// Thread3
4010 113 albert.wat
dffre_s #(4)  ackcnt3_ff (
4011 95 fafa1971
        .din    (ackcnt3_din[3:0]),
4012
        .q      (ackcnt3[3:0]),
4013
        .rst    (reset),        .en     (ackcnt_en[3]),
4014
        .clk    (clk),
4015 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4016 95 fafa1971
        );
4017
 
4018
assign  no_spc_rmo_st[0] = ~(|ackcnt0[3:0]) ;
4019
assign  no_spc_rmo_st[1] = ~(|ackcnt1[3:0]) ;
4020
assign  no_spc_rmo_st[2] = ~(|ackcnt2[3:0]) ;
4021
assign  no_spc_rmo_st[3] = ~(|ackcnt3[3:0]) ;
4022
 
4023
//8 outstanding rmo st will throttle the PCX issue st   
4024
assign lsu_outstanding_rmo_st_max [0] = ackcnt0[3];
4025
assign lsu_outstanding_rmo_st_max [1] = ackcnt1[3];
4026
assign lsu_outstanding_rmo_st_max [2] = ackcnt2[3];
4027
assign lsu_outstanding_rmo_st_max [3] = ackcnt3[3];
4028
 
4029
// streaming unit does not have to care about outstanding rmo sparc-stores.
4030
// membar will take care of that. spu must insert appr. delay in sampling signal.
4031
 
4032
/*dff #(4)  spustb_d1 ( // moved to stb_rwctl
4033
        .din    (lsu_stb_empty[3:0]),
4034
        .q      (lsu_spu_stb_empty[3:0]),
4035
        .clk    (clk),
4036 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4037 95 fafa1971
        ); */
4038
 
4039
//assign                lsu_spu_stb_empty[3:0] = lsu_stb_empty[3:0] ;
4040
 
4041
//=========================================================================================
4042
//  Thread Staging
4043
//=========================================================================================
4044
 
4045
// Thread staging can be optimized. 
4046
 
4047 113 albert.wat
dff_s  #(2) thrid_stgd (
4048 95 fafa1971
        .din    (ifu_lsu_thrid_s[1:0]),
4049
        .q      (thrid_d[1:0]),
4050
        .clk    (clk),
4051 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4052 95 fafa1971
        );
4053
 
4054 113 albert.wat
dff_s  #(2) lsu_tlu_thrid_stgd (
4055 95 fafa1971
        .din    (ifu_lsu_thrid_s[1:0]),
4056
        .q      (lsu_tlu_thrid_d[1:0]),
4057
        .clk    (clk),
4058 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4059 95 fafa1971
        );
4060
 
4061
//assign        lsu_tlu_thrid_d[1:0] = thrid_d[1:0] ;
4062
 
4063
assign  thread0_d = ~thrid_d[1] & ~thrid_d[0] ;
4064
assign  thread1_d = ~thrid_d[1] &  thrid_d[0] ;
4065
assign  thread2_d =  thrid_d[1] & ~thrid_d[0] ;
4066
assign  thread3_d =  thrid_d[1] &  thrid_d[0] ;
4067
 
4068 113 albert.wat
dff_s  #(2) thrid_stge (
4069 95 fafa1971
        .din    (thrid_d[1:0]),
4070
        .q      (thrid_e[1:0]),
4071
        .clk    (clk),
4072 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4073 95 fafa1971
        );
4074
 
4075
assign  thread0_e = ~thrid_e[1] & ~thrid_e[0] ;
4076
assign  thread1_e = ~thrid_e[1] &  thrid_e[0] ;
4077
assign  thread2_e =  thrid_e[1] & ~thrid_e[0] ;
4078
assign  thread3_e =  thrid_e[1] &  thrid_e[0] ;
4079
 
4080 113 albert.wat
dff_s  #(2) thrid_stgm (
4081 95 fafa1971
        .din    (thrid_e[1:0]),
4082
        .q      (thrid_m[1:0]),
4083
        .clk    (clk),
4084 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4085 95 fafa1971
        );
4086
 
4087
assign  thread0_m = ~thrid_m[1] & ~thrid_m[0] ;
4088
assign  thread1_m = ~thrid_m[1] &  thrid_m[0] ;
4089
assign  thread2_m =  thrid_m[1] & ~thrid_m[0] ;
4090
assign  thread3_m =  thrid_m[1] &  thrid_m[0] ;
4091
 
4092
bw_u1_buf_30x UZfix_thread0_m  ( .a(thread0_m),  .z(lsu_dctldp_thread0_m)  );
4093
bw_u1_buf_30x UZfix_thread1_m  ( .a(thread1_m),  .z(lsu_dctldp_thread1_m)  );
4094
bw_u1_buf_30x UZfix_thread2_m  ( .a(thread2_m),  .z(lsu_dctldp_thread2_m)  );
4095
bw_u1_buf_30x UZfix_thread3_m  ( .a(thread3_m),  .z(lsu_dctldp_thread3_m)  );
4096
 
4097 113 albert.wat
dff_s  #(2) thrid_stgg (
4098 95 fafa1971
        .din    (thrid_m[1:0]),
4099
        .q      (thrid_g[1:0]),
4100
        .clk    (clk),
4101 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4102 95 fafa1971
        );
4103
 
4104
assign  thread0_g = ~thrid_g[1] & ~thrid_g[0] ;
4105
assign  thread1_g = ~thrid_g[1] &  thrid_g[0] ;
4106
assign  thread2_g =  thrid_g[1] & ~thrid_g[0] ;
4107
assign  thread3_g =  thrid_g[1] &  thrid_g[0] ;
4108
 
4109 113 albert.wat
dff_s  #(2) thrid_stgw2 (
4110 95 fafa1971
        .din    (thrid_g[1:0]),
4111
        .q      (thrid_w2[1:0]),
4112
        .clk    (clk),
4113 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4114 95 fafa1971
        );
4115
 
4116
assign  thread0_w2 = ~thrid_w2[1] & ~thrid_w2[0] ;
4117
assign  thread1_w2 = ~thrid_w2[1] &  thrid_w2[0] ;
4118
assign  thread2_w2 =  thrid_w2[1] & ~thrid_w2[0] ;
4119
assign  thread3_w2 =  thrid_w2[1] &  thrid_w2[0] ;
4120
 
4121 113 albert.wat
dff_s  #(2) thrid_stgw3 (
4122 95 fafa1971
        .din    (thrid_w2[1:0]),
4123
        .q      (thrid_w3[1:0]),
4124
        .clk    (clk),
4125 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4126 95 fafa1971
        );
4127
 
4128
assign  thread0_w3 = ~thrid_w3[1] & ~thrid_w3[0] ;
4129
assign  thread1_w3 = ~thrid_w3[1] &  thrid_w3[0] ;
4130
assign  thread2_w3 =  thrid_w3[1] & ~thrid_w3[0] ;
4131
assign  thread3_w3 =  thrid_w3[1] &  thrid_w3[0] ;
4132
 
4133
//dff  #(4) thrid_stgw3 (
4134
//        .din    ({thread0_w2,thread1_w2,thread2_w2,thread3_w2}),
4135
//        .q      ({thread0_w3,thread1_w3,thread2_w3,thread3_w3}),
4136
//        .clk    (clk),
4137 113 albert.wat
//        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4138 95 fafa1971
//        );
4139
 
4140
// ldxa thread id
4141
 
4142
assign  ldxa_thrid_w2[1:0] = tlu_lsu_ldxa_tid_w2[1:0] ;
4143
 
4144
assign  tlu_ldxa_thread0_w2 = ~ldxa_thrid_w2[1] & ~ldxa_thrid_w2[0] ;
4145
assign  tlu_ldxa_thread1_w2 = ~ldxa_thrid_w2[1] &  ldxa_thrid_w2[0] ;
4146
assign  tlu_ldxa_thread2_w2 =  ldxa_thrid_w2[1] & ~ldxa_thrid_w2[0] ;
4147
assign  tlu_ldxa_thread3_w2 =  ldxa_thrid_w2[1] &  ldxa_thrid_w2[0] ;
4148
 
4149
assign  spu_stxa_thread0 = ~spu_lsu_stxa_ack_tid[1] & ~spu_lsu_stxa_ack_tid[0] ;
4150
assign  spu_stxa_thread1 = ~spu_lsu_stxa_ack_tid[1] &  spu_lsu_stxa_ack_tid[0] ;
4151
assign  spu_stxa_thread2 =  spu_lsu_stxa_ack_tid[1] & ~spu_lsu_stxa_ack_tid[0] ;
4152
assign  spu_stxa_thread3 =  spu_lsu_stxa_ack_tid[1] &  spu_lsu_stxa_ack_tid[0] ;
4153
 
4154
assign  spu_ldxa_thread0_w2 = ~spu_lsu_ldxa_tid_w2[1] & ~spu_lsu_ldxa_tid_w2[0] ;
4155
assign  spu_ldxa_thread1_w2 = ~spu_lsu_ldxa_tid_w2[1] &  spu_lsu_ldxa_tid_w2[0] ;
4156
assign  spu_ldxa_thread2_w2 =  spu_lsu_ldxa_tid_w2[1] & ~spu_lsu_ldxa_tid_w2[0] ;
4157
assign  spu_ldxa_thread3_w2 =  spu_lsu_ldxa_tid_w2[1] &  spu_lsu_ldxa_tid_w2[0] ;
4158
 
4159
assign  ifu_ldxa_thread0_w2 = ~ifu_lsu_ldxa_tid_w2[1] & ~ifu_lsu_ldxa_tid_w2[0] ;
4160
assign  ifu_ldxa_thread1_w2 = ~ifu_lsu_ldxa_tid_w2[1] &  ifu_lsu_ldxa_tid_w2[0] ;
4161
assign  ifu_ldxa_thread2_w2 =  ifu_lsu_ldxa_tid_w2[1] & ~ifu_lsu_ldxa_tid_w2[0] ;
4162
assign  ifu_ldxa_thread3_w2 =  ifu_lsu_ldxa_tid_w2[1] &  ifu_lsu_ldxa_tid_w2[0] ;
4163
 
4164
wire    [1:0]    ifu_nontlb_asi_tid ;
4165 113 albert.wat
dff_s  #(2) iasi_tid (
4166 95 fafa1971
        .din    (lsu_ifu_asi_thrid[1:0]),
4167
        .q      (ifu_nontlb_asi_tid[1:0]),
4168
        .clk    (clk),
4169 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4170 95 fafa1971
        );
4171
 
4172
assign  ifu_stxa_thread0_w2 = ~ifu_nontlb_asi_tid[1] & ~ifu_nontlb_asi_tid[0] ;
4173
assign  ifu_stxa_thread1_w2 = ~ifu_nontlb_asi_tid[1] &  ifu_nontlb_asi_tid[0] ;
4174
assign  ifu_stxa_thread2_w2 =  ifu_nontlb_asi_tid[1] & ~ifu_nontlb_asi_tid[0] ;
4175
assign  ifu_stxa_thread3_w2 =  ifu_nontlb_asi_tid[1] &  ifu_nontlb_asi_tid[0] ;
4176
 
4177
assign  tlu_stxa_thread0_w2 = ~tlu_lsu_stxa_ack_tid[1] & ~tlu_lsu_stxa_ack_tid[0] ;
4178
assign  tlu_stxa_thread1_w2 = ~tlu_lsu_stxa_ack_tid[1] &  tlu_lsu_stxa_ack_tid[0] ;
4179
assign  tlu_stxa_thread2_w2 =  tlu_lsu_stxa_ack_tid[1] & ~tlu_lsu_stxa_ack_tid[0] ;
4180
assign  tlu_stxa_thread3_w2 =  tlu_lsu_stxa_ack_tid[1] &  tlu_lsu_stxa_ack_tid[0] ;
4181
 
4182
//=========================================================================================
4183
//  Exception Handling
4184
//=========================================================================================
4185
 
4186
 
4187
// tlb related exceptions/errors
4188
//SC assign  tlb_daccess_excptn_e  =
4189
//SC  ((rd_only_ltlb_asi_e &  st_inst_vld_e)  |
4190
//SC   (wr_only_ltlb_asi_e &  ld_inst_vld_e)) & alt_space_e   ;
4191
 
4192
//SC assign  tlb_daccess_error_e =
4193
//SC   ((dfill_tlb_asi_e & ~lsu_tlb_writeable)     | 
4194
//SC   (ifill_tlb_asi_e & ~ifu_lsu_tlb_writeable)) & st_inst_vld_e & alt_space_e ; 
4195
 
4196
//SC dff  #(2) tlbex_stgm (
4197
//SC         .din    ({tlb_daccess_excptn_e,tlb_daccess_error_e}),
4198
//SC         .q      ({tlb_daccess_excptn_m,tlb_daccess_error_m}),
4199
//SC         .clk    (clk),
4200 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4201 95 fafa1971
//SC         );
4202
 
4203
//SC dff  #(2) tlbex_stgg (
4204
//SC         .din    ({tlb_daccess_excptn_m,tlb_daccess_error_m}),
4205
//SC         .q      ({tlb_daccess_excptn_g,tlb_daccess_error_g}),
4206
//SC         .clk    (clk),
4207 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4208 95 fafa1971
//SC         );
4209
 
4210
//assign  pstate_priv_m = 
4211
//  thread0_m ? tlu_lsu_pstate_priv[0] :
4212
//    thread1_m ? tlu_lsu_pstate_priv[1] :
4213
//      thread2_m ? tlu_lsu_pstate_priv[2] :
4214
//          tlu_lsu_pstate_priv[3] ;
4215
 
4216
//SC mux4ds  #(1) pstate_priv_m_mux (
4217
//SC         .in0    (tlu_lsu_pstate_priv[0]),
4218
//SC         .in1    (tlu_lsu_pstate_priv[1]),
4219
//SC         .in2    (tlu_lsu_pstate_priv[2]),
4220
//SC         .in3    (tlu_lsu_pstate_priv[3]),
4221
//SC         .sel0   (thread0_m),  
4222
//SC         .sel1   (thread1_m),
4223
//SC         .sel2   (thread2_m),  
4224
//SC         .sel3   (thread3_m),
4225
//SC         .dout   (pstate_priv_m)
4226
//SC );
4227
 
4228
//SC dff  priv_stgg (
4229
//SC         .din    (pstate_priv_m),
4230
//SC         .q      (pstate_priv),
4231
//SC         .clk    (clk),
4232 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4233 95 fafa1971
//SC         );
4234
 
4235
// privilege violation - priv page accessed in user mode
4236
//SC assign  priv_pg_usr_mode =  // data access exception; TT=h30
4237
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & ~(pstate_priv | hpv_priv) & tlb_rd_tte_data[`STLB_DATA_P] ;
4238
 
4239
// protection violation - store to a page that does not have write permission
4240
//SC assign  nonwr_pg_st_access =  // data access protection; TT=h33
4241
//SC   st_inst_vld_unflushed   & 
4242
//SC   ~tlb_rd_tte_data[`STLB_DATA_W] & ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
4243
   //lsu_dtlb_bypass_g) ; // W=1 in bypass mode - In bypass mode this trap will never happen !!!
4244
 
4245
//SC wire  daccess_prot ;
4246
//SC assign  daccess_prot = nonwr_pg_st_access  ;
4247
    //((~lsu_dtlb_bypass_g & tlb_cam_hit_g) | (tlb_byp_asi_g & lsu_alt_space_g)) ;
4248
 
4249
// access to a page marked with the nfo with an asi other than nfo asi.
4250
//SC assign  nfo_pg_nonnfo_asi  =  // data access exception; TT=h30
4251
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) &   // any access
4252
//SC   ((~nofault_asi_g & lsu_alt_space_g) | ~lsu_alt_space_g) // in alternate space or not
4253
//SC   & tlb_rd_tte_data[`STLB_DATA_NFO] ;
4254
 
4255
// as_if_usr asi accesses priv page.
4256
//SC assign  as_if_usr_priv_pg  =  // data access exception; TT=h30
4257
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & as_if_user_asi_g & lsu_alt_space_g & 
4258
//SC       tlb_rd_tte_data[`STLB_DATA_P] ;
4259
 
4260
 
4261
// non-cacheable address - iospace or cp=0 (???)
4262
// atomic access to non-cacheable space.
4263
//SC assign  atm_access_w_nc = atomic_g & tlb_pgnum[39] ; // io space 
4264
 
4265
// atomic inst with unsupported asi.
4266
//SC assign  atm_access_unsup_asi = atomic_g & ~atomic_asi_g & lsu_alt_space_g ;
4267
 
4268
//SC wire  tlb_tte_vld_g ;
4269
//SC assign  tlb_tte_vld_g = ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
4270
 
4271
//SC wire  pg_with_ebit ;
4272
//SC assign     pg_with_ebit = 
4273
//SC    (tlb_rd_tte_data[`STLB_DATA_E] & tlb_tte_vld_g)  | // tte
4274
//SC         (lsu_dtlb_bypass_g & ~(phy_use_ec_asi_g & lsu_alt_space_g)) | // regular bypass 
4275
//SC         (tlb_byp_asi_g & ~phy_use_ec_asi_g & lsu_alt_space_g) ; // phy_byp
4276
 
4277
//SC wire  spec_access_epage ;
4278
//SC assign  spec_access_epage = 
4279
//SC   ((ld_inst_vld_unflushed & nofault_asi_g & lsu_alt_space_g) |  // spec load
4280
//SC   flsh_inst_g) & // flush inst
4281
//SC   pg_with_ebit ; // page with side effects
4282
//  tlb_rd_tte_data[`STLB_DATA_E] ; // page with side effects
4283
 
4284
//SC wire  quad_asi_non_ldstda ;
4285
// quad-asi used with non ldda/stda
4286
// remove st_inst_vld - stquad unused
4287
// the equation may be incorrect - needs to be for a non-ldda
4288
//SC assign  quad_asi_non_ldstda = quad_asi_g & lsu_alt_space_g & ~ldst_dbl_g & 
4289
//SC      (ld_inst_vld_unflushed | st_inst_vld_unflushed) ;
4290
// need to put in similar exception for binit st
4291
//SC wire  binit_asi_non_ldda ;
4292
//SC assign  binit_asi_non_ldda = binit_quad_asi_g & lsu_alt_space_g & ~ldst_dbl_g & 
4293
//SC      (ld_inst_vld_unflushed) ;
4294
//SC wire  blk_asi_non_ldstdfa ;
4295
//SC assign  blk_asi_non_ldstdfa = blk_asi_g & lsu_alt_space_g & 
4296
//SC      ~(ldst_dbl_g & fp_ldst_g) & (ld_inst_vld_unflushed | st_inst_vld_unflushed) ;
4297
 
4298
// trap on illegal asi
4299
//SC wire  illegal_asi_trap_g ;
4300
//SC assign  illegal_asi_trap_g = 
4301
//SC (ld_inst_vld_unflushed | st_inst_vld_unflushed) &
4302
//SC lsu_alt_space_g & ~recognized_asi_g & lsu_inst_vld_w ;
4303
 
4304
// This can be pushed back into previous cycle.
4305
//SC wire wr_to_strm_sync ;
4306
//SC assign     wr_to_strm_sync =       
4307
//SC   strm_asi & ((ldst_va_g[7:0] == 8'hA0) | (ldst_va_g[7:0] == 8'h68)) &
4308
//SC   st_inst_vld_unflushed & lsu_alt_space_g ;
4309
 
4310
// This should not be double-anded with tlb_tte_vld_g. Check !!!
4311
//SC assign  daccess_excptn =  
4312
//SC     ((priv_pg_usr_mode | as_if_usr_priv_pg | nfo_pg_nonnfo_asi | 
4313
//SC     atm_access_w_nc | atm_access_unsup_asi)) 
4314
//SC       & tlb_tte_vld_g | 
4315
//SC     spec_access_epage |
4316
//SC     asi_related_trap_g | quad_asi_non_ldstda | tlb_daccess_excptn_g |
4317
//SC     illegal_asi_trap_g | spv_use_hpv | binit_asi_non_ldda | wr_to_strm_sync | 
4318
//SC    blk_asi_non_ldstdfa ;
4319
 
4320
// HPV Changes 
4321
// Push back into previous stage.
4322
// qualification with hpv_priv and hpstate_en required to ensure hypervisor
4323
// is not trying to access.
4324
 
4325
//assign  hpv_priv_e = 
4326
//  thread0_e ? tlu_lsu_hpv_priv[0] :
4327
//    thread1_e ? tlu_lsu_hpv_priv[1] :
4328
//      thread2_e ? tlu_lsu_hpv_priv[2] :
4329
//                      tlu_lsu_hpv_priv[3] ;
4330
 
4331
// Timing change :
4332
 
4333
wire [3:0] hpv_priv_d1 ;
4334
wire [3:0] hpstate_en_d1 ;
4335
 
4336 113 albert.wat
dff_s #(8) hpv_stgd1 (
4337 95 fafa1971
        .din    ({tlu_lsu_hpv_priv[3:0],tlu_lsu_hpstate_en[3:0]}),
4338
        .q      ({hpv_priv_d1[3:0],hpstate_en_d1[3:0]}),
4339
        .clk    (clk),
4340 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4341 95 fafa1971
        );
4342
 
4343
mux4ds  #(1) hpv_priv_e_mux (
4344
        .in0    (hpv_priv_d1[0]),
4345
        .in1    (hpv_priv_d1[1]),
4346
        .in2    (hpv_priv_d1[2]),
4347
        .in3    (hpv_priv_d1[3]),
4348
        .sel0   (thread0_e),
4349
        .sel1   (thread1_e),
4350
        .sel2   (thread2_e),
4351
        .sel3   (thread3_e),
4352
        .dout   (hpv_priv_e)
4353
);
4354
 
4355
//assign  hpstate_en_e = 
4356
//  thread0_e ? tlu_lsu_hpstate_en[0] :
4357
//    thread1_e ? tlu_lsu_hpstate_en[1] :
4358
//      thread2_e ? tlu_lsu_hpstate_en[2] :
4359
//                      tlu_lsu_hpstate_en[3] ;
4360
 
4361
mux4ds  #(1) hpstate_en_e_mux (
4362
        .in0    (hpstate_en_d1[0]),
4363
        .in1    (hpstate_en_d1[1]),
4364
        .in2    (hpstate_en_d1[2]),
4365
        .in3    (hpstate_en_d1[3]),
4366
        .sel0   (thread0_e),
4367
        .sel1   (thread1_e),
4368
        .sel2   (thread2_e),
4369
        .sel3   (thread3_e),
4370
        .dout   (hpstate_en_e)
4371
);
4372
 
4373 113 albert.wat
dff_s #(2) hpv_stgm (
4374 95 fafa1971
        .din    ({hpv_priv_e, hpstate_en_e}),
4375
        .q      ({hpv_priv_m, hpstate_en_m}),
4376
        .clk    (clk),
4377 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4378 95 fafa1971
        );
4379
 
4380
//dff #(2) hpv_stgg (
4381
//        .din    ({hpv_priv_m, hpstate_en_m}),
4382
//        .q            ({hpv_priv,   hpstate_en}),
4383
//        .clk    (clk),
4384 113 albert.wat
//        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4385 95 fafa1971
//        );
4386
 
4387
/*assign  priv_action = (ld_inst_vld_unflushed | st_inst_vld_unflushed) & ~lsu_asi_state[7] &
4388
      ~pstate_priv & ~(hpv_priv & hpstate_en) & lsu_alt_space_g ;*/
4389
// Generate a stage earlier
4390
//SC assign  priv_action_m = (ld_inst_vld_m | st_inst_vld_m) & ~lsu_dctl_asi_state_m[7] & 
4391
//SC       ~pstate_priv_m & ~(hpv_priv_m & hpstate_en_m) & lsu_alt_space_m ;
4392
 
4393
//SC dff  pact_stgg (
4394
//SC         .din    (priv_action_m),
4395
//SC         .q         (priv_action),
4396
//SC         .clk    (clk),
4397 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4398 95 fafa1971
//SC         );
4399
 
4400
// Take data_access exception if supervisor uses hypervisor asi
4401
//SC wire    hpv_asi_range ;
4402
//SC assign  hpv_asi_range =
4403
//SC                     ~lsu_asi_state[7] & (
4404
//SC                          (~lsu_asi_state[6] & lsu_asi_state[5] & lsu_asi_state[4]) | // 0x3?
4405
//SC                          ( lsu_asi_state[6]));                                   // 0x4?,5?,6?,7?
4406
 
4407
// Take data_access exception if supervisor uses hypervisor asi
4408
//SC `ifdef  SPARC_HPV_EN
4409
//SC assign  spv_use_hpv = (ld_inst_vld_unflushed | st_inst_vld_unflushed) &
4410
//SC                          hpv_asi_range &
4411
//SC                          //~lsu_asi_state[7] & lsu_asi_state[6] & lsu_asi_state[5] & // 0x30-0x7f
4412
//SC                          pstate_priv & ~hpv_priv & lsu_alt_space_g ;
4413
//SC `else
4414
//SC assign  spv_use_hpv = 1'b0 ;
4415
//SC `endif
4416
 
4417
 
4418
// EARLY TRAPS
4419
 
4420
// memory address not aligned
4421
//SC wire  qw_align_addr,blk_align_addr ;
4422
//SC assign  hw_align_addr = ~ldst_va_m[0] ;         // half-word addr
4423
//SC assign  wd_align_addr = ~ldst_va_m[1] & ~ldst_va_m[0] ;     // word addr
4424
//SC assign  dw_align_addr = ~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] ; // dw addr
4425
//SC assign  qw_align_addr = ~ldst_va_m[3] & ~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] ; // qw addr
4426
//SC assign  blk_align_addr = 
4427
//SC ~ldst_va_m[5] & ~ldst_va_m[4] & ~ldst_va_m[3] & 
4428
//SC ~ldst_va_m[2] & ~ldst_va_m[1] & ~ldst_va_m[0] ; // 64B aligned addr for block ld/st
4429
 
4430
//assign  byte_size = ~ldst_sz_m[1] &  ~ldst_sz_m[0] ; // byte size    
4431
//assign  hw_size = ~ldst_sz_m[1] &  ldst_sz_m[0] ; // half-word size 
4432
//assign  wd_size =  ldst_sz_m[1] & ~ldst_sz_m[0] ; // word size
4433
//assign  dw_size =  ldst_sz_m[1] &  ldst_sz_m[0] ; // double-word size
4434
 
4435
//assign  byte_size = byte_m;
4436
assign  hw_size = hword_m;
4437
assign  wd_size = word_m;
4438
assign  dw_size = dword_m;
4439
 
4440
//SC assign  mem_addr_not_align
4441
//SC   = ((hw_size & ~hw_align_addr) | // half-word check
4442
//SC     (wd_size & ~wd_align_addr)  | // word check
4443
//SC     (dw_size & ~dw_align_addr)  | // double word check
4444
//SC    ((quad_asi_m | binit_quad_asi_m) & lsu_alt_space_m & ldst_dbl_m & ~qw_align_addr) | // quad word check
4445
//SC     (blk_asi_m & lsu_alt_space_m & fp_ldst_m & ldst_dbl_m & ~blk_align_addr)) & // 64B blk ld/st check
4446
//SC     //(blk_asi_m & lsu_alt_space_m & blk_asi_m & ~blk_align_addr)) & // 64B blk ld/st check
4447
//SC     (ld_inst_vld_m | st_inst_vld_m) ;
4448
 
4449
//SC assign  stdf_maddr_not_align
4450
//SC     = st_inst_vld_m & fp_ldst_m & ldst_dbl_m & wd_align_addr & ~dw_align_addr ;
4451
 
4452
//SC assign  lddf_maddr_not_align
4453
//SC     = ld_inst_vld_m & fp_ldst_m & ldst_dbl_m & wd_align_addr & ~dw_align_addr ;
4454
 
4455
// internal asi access by ld/st other than ldxa/stxa/lddfa/stdfa.
4456
// qual with ldst_dbl_m needed. lda and stda should take trap if accessing internal asi.
4457
//SC assign  asi_internal_non_xdw 
4458
//SC     = (st_inst_vld_m | ld_inst_vld_m) & lsu_alt_space_m & asi_internal_m  & ~(dw_size & ~ldst_dbl_m) ;
4459
 
4460
 
4461
// asi related
4462
// rd-only mmu asi requiring va decode.
4463
//SC wire       mmu_rd_only_asi_wva_m ;
4464
//SC assign     mmu_rd_only_asi_wva_m =
4465
//SC    ((lsu_dctl_asi_state_m[7:0]==8'h58) & (
4466
//SC            (ldst_va_m[8:0] == 9'h000) |    // dtag_target
4467
//SC            (ldst_va_m[8:0] == 9'h020))) |  // dsync_far
4468
//SC    ((lsu_dctl_asi_state_m[7:0]==8'h50) & 
4469
//SC            (ldst_va_m[8:0] == 9'h000)) ;   // itag_target
4470
 
4471
//SC assign  wr_to_rd_only_asi = 
4472
//SC    (mmu_rd_only_asi_wva_m |// mmu with non-unique asi
4473
//SC    mmu_rd_only_asi_m |     // mmu with unique asi
4474
//SC    rd_only_asi_m)          // non mmu
4475
//SC     &  st_inst_vld_m & lsu_alt_space_m ;
4476
 
4477
//SC assign  rd_of_wr_only_asi = wr_only_asi_m &  ld_inst_vld_m & lsu_alt_space_m ;
4478
//SC assign  unimp_asi_used = unimp_asi_m &  (ld_inst_vld_m | st_inst_vld_m) & lsu_alt_space_m ;
4479
//assign  asi_related_trap_m = wr_to_rd_only_asi | rd_of_wr_only_asi | unimp_asi_used | asi_internal_non_xdw ;
4480
 
4481
//SC assign  early_trap_vld_m =  stdf_maddr_not_align | lddf_maddr_not_align | mem_addr_not_align ;
4482
 
4483
//SC assign  lsu_tlu_misalign_addr_ldst_atm_m = early_trap_vld_m ;
4484
 
4485
// mux select order must be maintained
4486
//SC assign  early_ttype_m[8:0] = 
4487
//SC       stdf_maddr_not_align ? 9'h036 :
4488
//SC         lddf_maddr_not_align ? 9'h035 : 
4489
//SC           mem_addr_not_align ? 9'h034 : 9'hxxx ;
4490
 
4491
//SC dff #(11)   etrp_stgg (
4492
//SC         .din    ({early_ttype_m[8:0],early_trap_vld_m,asi_related_trap_m}),
4493
//SC         .q      ({early_ttype_g[8:0],early_trap_vld_g,asi_related_trap_g}),
4494
//SC         .clk    (clk),
4495 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4496 95 fafa1971
//SC         );
4497
 
4498
//SC wire nceen_pipe_g ;
4499
//SC assign  nceen_pipe_g = 
4500
//SC   (thread0_g & ifu_lsu_nceen[0]) | (thread1_g & ifu_lsu_nceen[1]) |
4501
//SC   (thread2_g & ifu_lsu_nceen[2]) | (thread3_g & ifu_lsu_nceen[3]) ;
4502
//SC wire nceen_fill_e,nceen_fill_m,nceen_fill_g ;
4503
//SC assign  nceen_fill_e = 
4504
//SC   (dfill_thread0 & ifu_lsu_nceen[0]) | (dfill_thread1 & ifu_lsu_nceen[1]) |
4505
//SC   (dfill_thread2 & ifu_lsu_nceen[2]) | (dfill_thread3 & ifu_lsu_nceen[3]) ;
4506
 
4507
//SC dff  #(1) nce_stgm (
4508
//SC         .din    (nceen_fill_e),
4509
//SC         .q      (nceen_fill_m),
4510
//SC         .clk    (clk),
4511 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4512 95 fafa1971
//SC         );
4513
 
4514
//SC dff  #(1) nce_stgg (
4515
//SC         .din    (nceen_fill_m),
4516
//SC         .q      (nceen_fill_g),
4517
//SC         .clk    (clk),
4518 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4519 95 fafa1971
//SC         );
4520
 
4521
//SC assign  daccess_error = 1'b0 ;
4522
  // Commented out currently for timing reasons. This needs to be
4523
  // rolled into the ttype_vld sent to the tlu, but can be left out
4524
  // of the flush sent to the remaining units.
4525
  /*((tte_data_perror_unc) & nceen_pipe_g & // on xslate
4526
  ~(early_trap_vld_g | priv_action | va_wtchpt_match | dmmu_miss_g)) |
4527
  tlb_asi_unc_err_g |     // asi read
4528
  (unc_err_trap_g & nceen_fill_g) | // cache data
4529
  tlb_daccess_error_g ;     // tlb not writeable */
4530
 
4531
//SC assign  lsu_tlu_async_dacc_err_g = unc_err_trap_g | tlb_asi_unc_err_g ;
4532
 
4533
//SC assign  lsu_tlu_dmmu_miss_g = dmmu_miss_g ;
4534
 
4535
 wire  cam_real_m ;
4536 113 albert.wat
 dff_s   real_stgm (
4537 95 fafa1971
         .din    (lsu_dtlb_cam_real_e),
4538
         .q      (cam_real_m),
4539
         .clk    (clk),
4540 113 albert.wat
         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4541 95 fafa1971
         );
4542
 
4543
// dff   real_stgg (
4544
//         .din    (cam_real_m),
4545
//         .q      (cam_real_g),
4546
//         .clk    (clk),
4547 113 albert.wat
//         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4548 95 fafa1971
//         );
4549
 
4550
assign  lsu_tlu_nonalt_ldst_m =  (st_inst_vld_m | ld_inst_vld_m) & ~lsu_alt_space_m  ;
4551
assign  lsu_tlu_xslating_ldst_m = (st_inst_vld_m | ld_inst_vld_m) &
4552
        (((~asi_internal_m  & recognized_asi_m) & lsu_alt_space_m)  | // Bug 4327
4553
        ~lsu_alt_space_m) ;
4554
 
4555
assign  ctxt_sel_e[0] = thread_pctxt ;
4556
assign  ctxt_sel_e[1] = thread_sctxt ;
4557
assign  ctxt_sel_e[2] =
4558
        thread_nctxt |
4559
        (~(thread_pctxt | thread_sctxt) &  // default to nucleus - translating asi
4560
        ~(alt_space_e & (asi_internal_e | ~recognized_asi_e ))) ; //bug3660
4561
                                           // nontranslating asi to select 11 in CT
4562
                                           // field of dsfsr.
4563
 
4564 113 albert.wat
dff_s  #(3) ctxsel (
4565 95 fafa1971
        .din    (ctxt_sel_e[2:0]),
4566
        .q      (lsu_tlu_ctxt_sel_m[2:0]),
4567
        .clk    (clk),
4568 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4569 95 fafa1971
        );
4570
 
4571
assign  lsu_tlu_nucleus_ctxt_m = lsu_tlu_ctxt_sel_m[2] ;
4572
 
4573
assign  lsu_tlu_write_op_m = st_inst_vld_m | atomic_m ;
4574
 
4575
// va_oor_m check needs to be in case of bypass, pstate.am=1, internal and illegal asi. 
4576
// pstate.am squashing is done locally in tlu.
4577
 
4578
assign  lsu_tlu_squash_va_oor_m =
4579
  dtlb_bypass_m   |     // bypass
4580
  //sta_internal_m  | lda_internal_m |  // internal asi
4581
  (asi_internal_m & lsu_alt_space_m) |  // Bug 5156
4582
  (~recognized_asi_tmp & lsu_alt_space_m) ; // illegal asi // Timing change.
4583
 
4584
   assign lsu_squash_va_oor_m =  lsu_tlu_squash_va_oor_m;
4585
 
4586
//=========================================================================================
4587
//  Generate Flush Pipe
4588
//=========================================================================================
4589
 
4590
//SC wire       other_flush_pipe_w ;
4591
// lsu_tlu_ttype_vld needs to be optimized in terms of timing.
4592
//SC assign     other_flush_pipe_w = tlu_early_flush_pipe_w | (lsu_tlu_ttype_vld_m2 & lsu_inst_vld_w);
4593
//SC assign     lsu_ifu_flush_pipe_w = other_flush_pipe_w ;
4594
//SC assign     lsu_exu_flush_pipe_w = other_flush_pipe_w ;
4595
//SC assign     lsu_ffu_flush_pipe_w = other_flush_pipe_w ;
4596
 
4597
//SC //assign   lsu_flush_pipe_w = other_flush_pipe_w | ifu_tlu_flush_w ;
4598
 
4599
//=========================================================================================
4600
//  Early Traps to SPU
4601
//=========================================================================================
4602
 
4603
// detect st to ma/strm sync - data-access exception.
4604
//SC wire       st_to_sync_dexcp_m ;
4605
// qual with alt_space not required - spu will do it.
4606
//SC assign     st_to_sync_dexcp_m = 
4607
//SC   strm_asi_m & ((ldst_va_m[7:0] == 8'ha0) | (ldst_va_m[7:0] == 8'h68)) & st_inst_vld_m ;  
4608
 
4609
//SC wire       spu_early_flush_m ;
4610
 
4611
//SC assign     spu_early_flush_m =
4612
//SC    priv_action_m           |
4613
//SC    mem_addr_not_align      |
4614
//SC    st_to_sync_dexcp_m      ; 
4615
 
4616
//SC dff  eflushspu_g (
4617
//SC         .din    (spu_early_flush_m),
4618
//SC         .q      (lsu_spu_early_flush_g),
4619
//SC         .clk    (clk),
4620 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4621 95 fafa1971
//SC         );
4622
 
4623
//SC dff  eflushtlu_g (
4624
//SC         .din    (spu_early_flush_m),
4625
//SC         .q      (lsu_tlu_early_flush_w),
4626
//SC        .clk    (clk),
4627 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4628 95 fafa1971
 //SC        );
4629
 
4630
//=========================================================================================
4631
//  Parity Error Checking
4632
//=========================================================================================
4633
 
4634
// DCache Parity Error
4635
// - Parity Check is done for entire 64b. No attempt is made to match on size. A
4636
// parity error will force a miss and refetch a line to the same way of the cache.
4637
// - Logging of error is done in g-stage of issue.
4638
// - Trap taken on data return
4639
 
4640
wire    dcache_perr_en ;
4641
assign  dcache_perr_en  =
4642
  dcache_enable_g & ~(asi_internal_g & lsu_alt_space_g) &
4643
  ~atomic_g  &
4644
  // dcache_rd_parity_err qualified with cache_way_hit - could be x.
4645
  (lsu_dtlb_bypass_g | (~lsu_dtlb_bypass_g & tlb_cam_hit_g)) ;
4646
assign dcache_rd_parity_error = dcache_rparity_err_wb & dcache_perr_en ;
4647
 
4648
// dtag parity error gets priority over dcache priority.
4649
assign  lsu_dcache_data_perror_g =
4650
  dcache_rd_parity_error & ld_inst_vld_unflushed & lsu_inst_vld_w & ~dtag_perror_g &
4651
  dcache_perr_en ;
4652
//  dcache_enable_g & ~(asi_internal_g & lsu_alt_space_g) & 
4653
//  ~atomic_g ; 
4654
 
4655
// DTLB Parity Errors. 
4656
// ASI read of Tag/Data :
4657
//  - uncorrectible error
4658
//  - logging occurs on read.
4659
//  - precise trap is taken when ldxa completes if nceen set.
4660
//  - if not set then ldxa is allowed to complete.
4661
// CAM Read of Tag/Data :
4662
//  - correctible if locked bit not set.
4663
//    - takes disrupting trap later.
4664
//  - uncorrectible if locked bit set.
4665
//  - both are treated as precise traps.
4666
//  - if errors not enabled, then load completes as if hit in L1.
4667
// ** TLB error will cause a trap which will preclude concurrent dcache,dtag  **
4668
// ** parity errors.                **
4669
 
4670
//SC assign  tte_data_parity_error = 
4671
//SC   tlb_rd_tte_data_parity ^ lsu_rd_tte_data_parity ;
4672
//SC assign  tte_tag_parity_error  = 
4673
//SC   tlb_rd_tte_tag_parity ^ lsu_rd_tte_tag_parity ;
4674
 
4675
// cam related tte data parity error - error assumed correctible if locked
4676
// bit is not set. Will cause a dmmu_miss for correction.
4677
// qualify with cam_hit ??
4678
//SC assign  tte_data_perror_corr = 
4679
//SC   tte_data_parity_error & ~tlb_rd_tte_data_locked & tlb_tte_vld_g & 
4680
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & lsu_inst_vld_w ;
4681
// same as above except error is treated as uncorrectible. This is to be posted to 
4682
// error status register which will cause a disrupting trap later.
4683
//SC assign  tte_data_perror_unc  = 
4684
//SC   tte_data_parity_error &  tlb_rd_tte_data_locked & tlb_tte_vld_g & 
4685
//SC   (ld_inst_vld_unflushed | st_inst_vld_unflushed) & lsu_inst_vld_w ;
4686
// Asi rd parity error detection
4687
//SC assign  asi_tte_data_perror =
4688
//SC   tte_data_parity_error & data_rd_vld_g ;
4689
// For data tte read, both tag and data arrays are read.
4690
// Parity error on asi read of tag should not be reported.
4691
//SC assign  asi_tte_tag_perror =
4692
//SC   tte_tag_parity_error & tag_rd_vld_g & ~data_rd_vld_g ;
4693
//SC assign  lsu_tlu_asi_rd_unc = asi_tte_data_perror | asi_tte_tag_perror ;
4694
 
4695
// asi rd parity errors need to be reported thru asi bus
4696
/*assign  lsu_ifu_tlb_data_ce = tte_data_perror_corr ;
4697
assign  lsu_ifu_tlb_data_ue = tte_data_perror_unc | asi_tte_data_perror ;
4698
assign  lsu_ifu_tlb_tag_ue  = asi_tte_tag_perror ; */
4699
 
4700
 
4701
//SC wire  tlb_data_ue_g ;
4702
//SC assign  tlb_data_ue_g = tte_data_perror_unc | asi_tte_data_perror ;
4703
 
4704
//SC dff  #(3) terr_stgd1 (
4705
//SC         .din    ({tte_data_perror_corr,tlb_data_ue_g,asi_tte_tag_perror}),
4706
//SC         .q      ({lsu_ifu_tlb_data_ce,lsu_ifu_tlb_data_ue,lsu_ifu_tlb_tag_ue}),
4707
//SC         .clk    (clk),
4708 113 albert.wat
//SC         .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4709 95 fafa1971
//SC         );
4710
 
4711
// Dtag Parity Error
4712
// - corrected thru special mechanism
4713
// - correctible error
4714
// - Trap taken on data return
4715
 
4716
// move parity error calculation to g stage
4717
 
4718 113 albert.wat
dff_s  #(4) dva_vld_g_ff (
4719 95 fafa1971
         .din    (dva_vld_m[3:0]),
4720
         .q      (dva_vld_g[3:0]),
4721
        .clk    (clk),
4722 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4723 95 fafa1971
        );
4724
 
4725
   assign dva_vld_m_bf[3:0] = dva_vld_m[3:0];
4726
 
4727
wire    dtag_perr_en ;
4728
assign  dtag_perr_en =
4729
dcache_enable_g & ~(asi_internal_g & lsu_alt_space_g) & // Bug 3541
4730
  ~(lsu_alt_space_g & blk_asi_g) &  // Bug 3926. 
4731
  ~atomic_g & // Bug 4274,4297 
4732
  ~pref_inst_g ; // Bug 5046
4733
assign  dtag_parity_error[0] =
4734
      lsu_rd_dtag_parity_g[0] & dva_vld_g[0] & dtag_perr_en;
4735
assign  dtag_parity_error[1] =
4736
      lsu_rd_dtag_parity_g[1] & dva_vld_g[1] & dtag_perr_en ;
4737
assign  dtag_parity_error[2] =
4738
      lsu_rd_dtag_parity_g[2] & dva_vld_g[2] & dtag_perr_en ;
4739
assign  dtag_parity_error[3] =
4740
      lsu_rd_dtag_parity_g[3] & dva_vld_g[3] & dtag_perr_en ;
4741
 
4742
assign  dtag_perror_g = |dtag_parity_error[3:0] ;
4743
assign  lsu_dcache_tag_perror_g =
4744
  (|dtag_parity_error[3:0]) & ld_inst_vld_unflushed & lsu_inst_vld_w &
4745
  // Correction pkt should not be generated to io.
4746
  ~(tlb_pgnum[39] & (lsu_dtlb_bypass_g | (~lsu_dtlb_bypass_g & tlb_cam_hit_g))) ;
4747
//  (|dtag_parity_error[3:0]) & ld_inst_vld_unflushed & lsu_inst_vld_w &
4748
//  ~(lsu_alt_space_g & blk_asi_g) &  // Bug 3926. 
4749
//  // Correction pkt should not be generated to io.
4750
//  ~(tlb_pgnum[39] & (lsu_dtlb_bypass_g | (~lsu_dtlb_bypass_g & tlb_cam_hit_g))) &
4751
//  ~atomic_g ; // Bug 4274,4297 
4752
//=========================================================================================
4753
//  Error Related Traps 
4754
//=========================================================================================
4755
 
4756
//bug6382/eco6621   
4757 113 albert.wat
dff_s #(2)  derrtrp_stgm (
4758 95 fafa1971
        .din    ({lsu_cpx_ld_dtag_perror_e & ~ignore_fill, lsu_cpx_ld_dcache_perror_e & ~ignore_fill}),
4759
        .q      ({dtag_error_m,dcache_error_m}),
4760
        .clk    (clk),
4761 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4762 95 fafa1971
        );
4763
 
4764 113 albert.wat
dff_s #(2)  derrtrp_stgg (
4765 95 fafa1971
        .din    ({dtag_error_m,dcache_error_m}),
4766
        .q      ({dtag_error_g,dcache_error_g}),
4767
        .clk    (clk),
4768 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4769 95 fafa1971
        );
4770
 
4771 113 albert.wat
dff_s #(2)  derrtrp_stgw2 (
4772 95 fafa1971
        .din    ({dtag_error_g,dcache_error_g}),
4773
        .q      ({dtag_error_w2,dcache_error_w2}),
4774
        .clk    (clk),
4775 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4776 95 fafa1971
        );
4777
 
4778
assign  lsu_ifu_dcache_data_perror = dcache_error_w2 & ~bld_squash_err_w2;  //bug6382/eco6621
4779
assign  lsu_ifu_dcache_tag_perror  = dtag_error_w2  ;
4780
 
4781
assign  l2_unc_error_e  = lsu_cpx_pkt_ld_err[1] & l2fill_vld_e & ~ignore_fill  ; // Bug 4998
4782
assign  l2_corr_error_e = lsu_cpx_pkt_ld_err[0] & l2fill_vld_e & ~ignore_fill  ;
4783
 
4784 113 albert.wat
dff_s #(2)  lerrtrp_stgm (
4785 95 fafa1971
        .din    ({l2_unc_error_e,l2_corr_error_e}),
4786
        .q      ({l2_unc_error_m,l2_corr_error_m}),
4787
        .clk    (clk),
4788 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4789 95 fafa1971
        );
4790
 
4791 113 albert.wat
dff_s #(2)  lerrtrp_stgg (
4792 95 fafa1971
        .din    ({l2_unc_error_m,l2_corr_error_m}),
4793
        .q      ({l2_unc_error_g,l2_corr_error_g}),
4794
        .clk    (clk),
4795 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4796 95 fafa1971
        );
4797
 
4798 113 albert.wat
dff_s #(2)  lerrtrp_stgw2 (
4799 95 fafa1971
        .din    ({l2_unc_error_g,l2_corr_error_g}),
4800
        .q      ({l2_unc_error_w2,l2_corr_error_w2}),
4801
        .clk    (clk),
4802 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4803 95 fafa1971
        );
4804
 
4805
assign  lsu_ifu_l2_unc_error  = // Bug 4315
4806
(l2_unc_error_w2 | bld_unc_err_pend_w2) & ~lsu_ifu_err_addr_b39 & ~bld_squash_err_w2 ;
4807
assign  lsu_ifu_l2_corr_error =
4808
(l2_corr_error_w2 | bld_corr_err_pend_w2) & ~bld_squash_err_w2 ;
4809
 
4810
wire    fill_err_trap_e ;
4811
 
4812
//assign  unc_err_trap_e = 
4813
assign  fill_err_trap_e =
4814
  (lsu_cpx_pkt_ld_err[1] & l2fill_vld_e) ;
4815
   /*(lsu_cpx_atm_st_err[1] & lsu_atm_st_cmplt_e)) &
4816
      ((dfill_thread0 & ifu_lsu_nceen[0]) |
4817
       (dfill_thread1 & ifu_lsu_nceen[1]) |
4818
       (dfill_thread2 & ifu_lsu_nceen[2]) |
4819
       (dfill_thread3 & ifu_lsu_nceen[3])) ; */ // Bug 3624
4820
 
4821
assign  unc_err_trap_e = fill_err_trap_e ;
4822
 
4823
/*assign  corr_err_trap_e =
4824
  ((lsu_cpx_pkt_ld_err[0] | lsu_cpx_ld_dtag_perror_e | lsu_cpx_ld_dcache_perror_e) &
4825
   l2fill_vld_e) |
4826
   (lsu_cpx_atm_st_err[0] & lsu_atm_st_cmplt_e)) &
4827
   & ~unc_err_trap_e &
4828
      ((dfill_thread0 & ifu_lsu_ceen[0]) |
4829
       (dfill_thread1 & ifu_lsu_ceen[1]) |
4830
       (dfill_thread2 & ifu_lsu_ceen[2]) |
4831
       (dfill_thread3 & ifu_lsu_ceen[3])) ; */
4832
 
4833
 
4834 113 albert.wat
dff_s #(1)  errtrp_stgm (
4835 95 fafa1971
        .din    ({unc_err_trap_e}),
4836
        .q      ({unc_err_trap_m}),
4837
        .clk    (clk),
4838 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4839 95 fafa1971
        );
4840
 
4841 113 albert.wat
dff_s #(1)  errtrp_stgg (
4842 95 fafa1971
        .din    ({unc_err_trap_m}),
4843
        .q      ({unc_err_trap_g}),
4844
        .clk    (clk),
4845 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4846 95 fafa1971
        );
4847
 
4848
// The tlu should source demap_thrid for all tlb operations !!!
4849 113 albert.wat
dff_s #(2)  filla_stgm (
4850 95 fafa1971
        .din    ({lsu_dfill_tid_e[1:0]}),
4851
        .q      ({dfill_tid_m[1:0]}),
4852
        .clk    (clk),
4853 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4854 95 fafa1971
        );
4855
 
4856 113 albert.wat
dff_s #(2)  filla_stgg (
4857 95 fafa1971
        .din    ({dfill_tid_m[1:0]}),
4858
        .q      ({dfill_tid_g[1:0]}),
4859
        .clk    (clk),
4860 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4861 95 fafa1971
        );
4862
 
4863
 
4864
 
4865
//=========================================================================================
4866
//  LSU to IRF Data Bypass Control
4867
//=========================================================================================
4868
 
4869
assign  spu_trap =  spu_lsu_unc_error_w2 ;
4870
assign  spu_trap0 = spu_trap & spu_ldxa_thread0_w2 ;
4871
assign  spu_trap1 = spu_trap & spu_ldxa_thread1_w2 ;
4872
assign  spu_trap2 = spu_trap & spu_ldxa_thread2_w2 ;
4873
assign  spu_trap3 = spu_trap & spu_ldxa_thread3_w2 ;
4874
 
4875
assign  spu_ttype[6:0]   = spu_lsu_int_w2 ? 7'h70 : 7'h32 ;
4876
 
4877 113 albert.wat
dff_s #(2)   lfraw_stgw2 (
4878 95 fafa1971
        .din    ({ld_inst_vld_g,fp_ldst_g}),
4879
        .q      ({ld_inst_vld_w2,fp_ldst_w2}),
4880
        .clk    (clk),
4881 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4882 95 fafa1971
        );
4883
 
4884 113 albert.wat
dff_s #(2)   lfraw_stgw3 (
4885 95 fafa1971
        .din    ({ld_stb_full_raw_w2, ld_inst_vld_w2}),
4886
        .q      ({ld_stb_full_raw_w3, ld_inst_vld_w3}),
4887
        .clk    (clk),
4888 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4889 95 fafa1971
        );
4890
 
4891
// Delay all ldbyp*vld_en by a cycle for write of unc error
4892
//dff #(4)  lbypen_stgd1 (
4893
//        .din    ({ldbyp0_vld_en,ldbyp1_vld_en,ldbyp2_vld_en,ldbyp3_vld_en}),
4894
//        .q      ({ldbyp0_vld_en_d1,ldbyp1_vld_en_d1,ldbyp2_vld_en_d1,ldbyp3_vld_en_d1}),
4895
//        .clk    (clk),
4896 113 albert.wat
//        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4897 95 fafa1971
//        ); 
4898
 
4899
 
4900
wire   fp_ldst_thrd0_w2,fp_ldst_thrd1_w2,fp_ldst_thrd2_w2,fp_ldst_thrd3_w2 ;
4901
wire   fp_ldst_thrd0_w3,fp_ldst_thrd1_w3,fp_ldst_thrd2_w3,fp_ldst_thrd3_w3 ;
4902
wire   fp_ldst_thrd0_w4,fp_ldst_thrd1_w4,fp_ldst_thrd2_w4,fp_ldst_thrd3_w4 ;
4903
wire   fp_ldst_thrd0_w5,fp_ldst_thrd1_w5,fp_ldst_thrd2_w5,fp_ldst_thrd3_w5 ;
4904
 
4905
//RAW read STB at W3 (changed from W2)
4906
 
4907 113 albert.wat
dff_s #(4) fp_ldst_stg_w3 (
4908 95 fafa1971
  .din ({fp_ldst_thrd0_w2,fp_ldst_thrd1_w2,fp_ldst_thrd2_w2,fp_ldst_thrd3_w2}),
4909
  .q   ({fp_ldst_thrd0_w3,fp_ldst_thrd1_w3,fp_ldst_thrd2_w3,fp_ldst_thrd3_w3}),
4910
  .clk    (clk),
4911 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4912 95 fafa1971
  );
4913
 
4914 113 albert.wat
dff_s #(4) fp_ldst_stg_w4 (
4915 95 fafa1971
  .din ({fp_ldst_thrd0_w3,fp_ldst_thrd1_w3,fp_ldst_thrd2_w3,fp_ldst_thrd3_w3}),
4916
  .q   ({fp_ldst_thrd0_w4,fp_ldst_thrd1_w4,fp_ldst_thrd2_w4,fp_ldst_thrd3_w4}),
4917
  .clk    (clk),
4918 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4919 95 fafa1971
  );
4920
 
4921 113 albert.wat
dff_s #(4) fp_ldst_stg_w5 (
4922 95 fafa1971
  .din ({fp_ldst_thrd0_w4,fp_ldst_thrd1_w4,fp_ldst_thrd2_w4,fp_ldst_thrd3_w4}),
4923
  .q   ({fp_ldst_thrd0_w5,fp_ldst_thrd1_w5,fp_ldst_thrd2_w5,fp_ldst_thrd3_w5}),
4924
  .clk    (clk),
4925 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4926 95 fafa1971
  );
4927
 
4928
// THREAD 0
4929
 
4930
wire    tte_data_perror_unc_w2,asi_tte_data_perror_w2,asi_tte_tag_perror_w2 ;
4931
// if nceen/ceen=0, then tte_data_perror* are not logged for trap generation. Earlier error-reporting
4932
// is however never screened off.
4933
// asi_tte* however has to be logged in order to report errors thru the asiQ. Traps must be squashed. 
4934 113 albert.wat
dff_s #(3) ltlbrd_w2 (
4935 95 fafa1971
  .din ({tte_data_perror_unc_en,asi_tte_data_perror,asi_tte_tag_perror}),
4936
  .q   ({tte_data_perror_unc_w2,asi_tte_data_perror_w2,asi_tte_tag_perror_w2}),
4937
  .clk    (clk),
4938 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4939 95 fafa1971
  );
4940
 
4941
 
4942
// Error Table for Queue
4943
// ** In all cases; squash writes to irf.
4944
//                              | Error Reporting       | Trap ?        | 
4945
// ifu_lsu_asi_rd_unc           | NA;done by ifu        | daccess-error |
4946
// tte_data_perror_unc_w2       | sync;in pipe          | daccess-error |
4947
// tte_data_perror_corr_w2      | sync;in pipe          | dmmu-miss     | --> NA !! all unc.
4948
// asi_tte_data_perror_w2       | async;out of Q        | daccess-error |
4949
// asi_tte_tag_perror_w2        | async;out of Q        | daccess-error |
4950
 
4951
wire [3:0] tlb_err_en_w2 ;
4952
// used for xslate errors - enable queues
4953
//assign        tlb_err_en_w2[0] = (tte_data_perror_unc_w2 | tte_data_perror_corr_w2) & thread0_w2 ;    
4954
assign  tlb_err_en_w2[0] = tte_data_perror_unc_w2 & thread0_w2 ;
4955
assign  tlb_err_en_w2[1] = tte_data_perror_unc_w2 & thread1_w2 ;
4956
assign  tlb_err_en_w2[2] = tte_data_perror_unc_w2 & thread2_w2 ;
4957
assign  tlb_err_en_w2[3] = tte_data_perror_unc_w2 & thread3_w2 ;
4958
 
4959
assign ldbyp0_vld_rst =
4960
        (reset | (ld_thrd_byp_sel_e[0])) |
4961
        atm_st_cmplt0 ; // Bug 4048
4962
 
4963
// thread qualification required.
4964
//assign ldbyp0_vld_en = (lmq_byp_data_en_w2[0] & 
4965
//        ~(|lmq_byp_data_sel0[2:1]))  // do not set vld for cas/stdbl
4966
//      | spu_trap0 ;
4967
 
4968
wire            atm_ld_w_uerr ;
4969
assign          atm_ld_w_uerr = l2fill_vld_e & lsu_cpx_pkt_atm_st_cmplt & lsu_cpx_pkt_ld_err[1] ;
4970
 
4971
//bug6525 notes
4972
// spu ldxa and spu trap can async with the main pipe, and cause more than one ldbyp*_vld_en asserted 
4973
// at the same cycle   
4974
assign ldbyp0_vld_en = lmq_byp_data_raw_sel_d2[0] |                  //ld hit stb RAW bypass
4975
                       lmq_byp_data_sel0[3]       |                  //ldxa (ifu, spu*, lsu)
4976
                       (atm_ld_w_uerr & lsu_nceen_d1[0] & dfill_thread0) |       //atomic
4977
                       lmq_byp_data_fmx_sel[0]    |                  //tlu ldxa
4978
                       tlb_err_en_w2[0]    |                                      //tlb parity err
4979
                       spu_trap0 ;                                   //spu trap*
4980
 
4981
assign   fp_ldst_thrd0_w2 = fp_ldst_w2 & thread0_w2 & ld_inst_vld_w2 ;
4982
 
4983
// ld valid
4984
wire    ldbyp0_vld_tmp ;
4985 113 albert.wat
dffre_s #(1)  ldbyp0_vld_ff (
4986 95 fafa1971
        .din    (ldbyp0_vld_en),
4987
        .q      (ldbyp0_vld_tmp),
4988
        .rst    (ldbyp0_vld_rst),        .en     (ldbyp0_vld_en),
4989
        .clk    (clk),
4990 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
4991 95 fafa1971
        );
4992
// Bug 5379 - make ld ue invisible in q until atm st ack resets.
4993
 
4994
assign  ldbyp0_vld = ldbyp0_vld_tmp & ~pend_atm_ld_ue[0] ;
4995
 
4996
 
4997
// assumes that rw_index is not reset at mmu.
4998
wire [6:0]       misc_data_in ;
4999
wire [6:0]       misc_data0,misc_data1,misc_data2,misc_data3 ;
5000
wire            misc_sel ;
5001
wire [5:0]       rw_index_d1 ;
5002 113 albert.wat
dff_s #(6)  rwind_d1 (
5003 95 fafa1971
        .din    (tlu_dtlb_rw_index_g[5:0]),
5004
        .q      (rw_index_d1[5:0]),
5005
        .clk    (clk),
5006 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5007 95 fafa1971
        );
5008
assign  misc_sel = asi_tte_data_perror_w2 | asi_tte_tag_perror_w2 ;
5009
assign  misc_data_in[6:0] = misc_sel ? {1'b0,rw_index_d1[5:0]} : spu_ttype[6:0] ;
5010
 
5011 113 albert.wat
dffe_s #(9)  ldbyp0_other_ff (
5012 95 fafa1971
        .din    ({fp_ldst_thrd0_w5,spu_trap0,misc_data_in[6:0]}),  //bug6525 fix2
5013
        .q      ({ldbyp0_fpld,spubyp0_trap,misc_data0[6:0]}),
5014
        .en     (ldbyp0_vld_en),
5015
        .clk    (clk),
5016 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5017 95 fafa1971
        );
5018
 
5019
 
5020 113 albert.wat
dffre_s #(5)  ldbyp0_err_ff (
5021 95 fafa1971
        .din    ({tte_data_perror_unc_w2,atm_ld_w_uerr,
5022
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5023
        .q      ({cam_perr_unc0,pend_atm_ld_ue[0],asi_data_perr0,asi_tag_perr0,
5024
                ifu_unc_err0}),
5025
        .rst    (ldbyp0_vld_rst), .en     (ldbyp0_vld_en & ~spu_trap0 & ~lmq_byp_ldxa_sel0[1]), //bug6525 fix2
5026
        .clk    (clk),
5027 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5028 95 fafa1971
        );
5029
 
5030
 
5031
//assign  ldbyp0_unc_err = ldbyp0_unc_err_q & ifu_lsu_nceen[0] ;
5032
 
5033
// THREAD 1
5034
 
5035
assign ldbyp1_vld_rst =
5036
        (reset | (ld_thrd_byp_sel_e[1])) |
5037
        atm_st_cmplt1 ; // Bug 4048
5038
 
5039
assign   fp_ldst_thrd1_w2 = fp_ldst_w2 & thread1_w2 & ld_inst_vld_w2 ;
5040
 
5041
// thread qualification required.
5042
//assign ldbyp1_vld_en = (lmq_byp_data_en_w2[1] &
5043
//        ~(|lmq_byp_data_sel1[2:1])) | // do not set vld for cas/stdbl
5044
//      | spu_trap1 ;
5045
 
5046
assign ldbyp1_vld_en = lmq_byp_data_raw_sel_d2[1] |
5047
                       lmq_byp_data_sel1[3]       |
5048
                       (atm_ld_w_uerr & lsu_nceen_d1[1] & dfill_thread1) |
5049
                       lmq_byp_data_fmx_sel[1]    |
5050
                       tlb_err_en_w2[1]   |
5051
                       spu_trap1 ;
5052
 
5053
// ld valid
5054
wire    ldbyp1_vld_tmp ;
5055 113 albert.wat
dffre_s #(1)  ldbyp1_vld_ff (
5056 95 fafa1971
        .din    (ldbyp1_vld_en),
5057
        .q      (ldbyp1_vld_tmp),
5058
        .rst    (ldbyp1_vld_rst),        .en     (ldbyp1_vld_en),
5059
        .clk    (clk),
5060 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5061 95 fafa1971
        );
5062
assign  ldbyp1_vld = ldbyp1_vld_tmp & ~pend_atm_ld_ue[1] ;
5063
 
5064
 
5065 113 albert.wat
dffe_s #(9)  ldbyp1_other_ff (
5066 95 fafa1971
        .din    ({fp_ldst_thrd1_w5,spu_trap1,misc_data_in[6:0]}),  //bug6525 fix2
5067
        .q      ({ldbyp1_fpld,spubyp1_trap,misc_data1[6:0]}),
5068
        .en     (ldbyp1_vld_en),
5069
        .clk    (clk),
5070 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5071 95 fafa1971
        );
5072
 
5073
// The tlb rd unc errors are delayed a cycle wrt to ldxa_data
5074
// No reset required
5075 113 albert.wat
dffre_s #(5)  ldbyp1_err_ff (
5076 95 fafa1971
        .din    ({tte_data_perror_unc_w2,atm_ld_w_uerr,
5077
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5078
        .q      ({cam_perr_unc1,pend_atm_ld_ue[1],asi_data_perr1,asi_tag_perr1,
5079
                ifu_unc_err1}),
5080
        .rst    (ldbyp1_vld_rst), .en     (ldbyp1_vld_en & ~spu_trap1 & ~lmq_byp_ldxa_sel1[1]), //bug6525 fix2
5081
        .clk    (clk),
5082 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5083 95 fafa1971
        );
5084
 
5085
//assign  ldbyp1_unc_err = ldbyp1_unc_err_q & ifu_lsu_nceen[1] ;
5086
 
5087
// THREAD 2
5088
 
5089
assign ldbyp2_vld_rst =
5090
        (reset | (ld_thrd_byp_sel_e[2])) |
5091
        atm_st_cmplt2 ; // Bug 4048
5092
 
5093
// thread qualification required.
5094
//assign ldbyp2_vld_en = (lmq_byp_data_en_w2[2] &
5095
//        ~(|lmq_byp_data_sel2[2:1])) | // do not set vld for cas/stdbl
5096
//      spu_trap2 ;
5097
 
5098
assign ldbyp2_vld_en = lmq_byp_data_raw_sel_d2[2] |
5099
                       lmq_byp_data_sel2[3]       |
5100
                       (atm_ld_w_uerr & lsu_nceen_d1[2] & dfill_thread2) |
5101
                       lmq_byp_data_fmx_sel[2]    |
5102
                       tlb_err_en_w2[2]   |
5103
                       spu_trap2 ;
5104
 
5105
assign   fp_ldst_thrd2_w2 = fp_ldst_w2 & thread2_w2 & ld_inst_vld_w2 ;
5106
 
5107
// ld valid
5108
wire    ldbyp2_vld_tmp ;
5109 113 albert.wat
dffre_s #(1)  ldbyp2_vld_ff (
5110 95 fafa1971
        .din    (ldbyp2_vld_en),
5111
        .q      (ldbyp2_vld_tmp),
5112
        .rst    (ldbyp2_vld_rst),        .en     (ldbyp2_vld_en),
5113
        .clk    (clk),
5114 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5115 95 fafa1971
        );
5116
assign  ldbyp2_vld = ldbyp2_vld_tmp & ~pend_atm_ld_ue[2] ;
5117
 
5118 113 albert.wat
dffe_s #(9)  ldbyp2_other_ff (
5119 95 fafa1971
        .din    ({fp_ldst_thrd2_w5,spu_trap2,misc_data_in[6:0]}),  //bug6525 fix2
5120
        .q      ({ldbyp2_fpld,spubyp2_trap,misc_data2[6:0]}),
5121
        .en     (ldbyp2_vld_en),
5122
        .clk    (clk),
5123 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5124 95 fafa1971
        );
5125
 
5126 113 albert.wat
dffre_s #(5)  ldbyp2_err_ff (
5127 95 fafa1971
        .din    ({tte_data_perror_unc_w2, atm_ld_w_uerr,
5128
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5129
        .q      ({cam_perr_unc2,pend_atm_ld_ue[2],asi_data_perr2,asi_tag_perr2,
5130
                ifu_unc_err2}),
5131
        .rst    (ldbyp2_vld_rst), .en     (ldbyp2_vld_en & ~spu_trap2 & ~lmq_byp_ldxa_sel2[1]), //bug6525 fix2
5132
        .clk    (clk),
5133 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5134 95 fafa1971
        );
5135
 
5136
//assign  ldbyp2_unc_err = ldbyp2_unc_err_q & ifu_lsu_nceen[2] ;
5137
 
5138
// THREAD 3
5139
 
5140
assign ldbyp3_vld_rst =
5141
        (reset | (ld_thrd_byp_sel_e[3])) |
5142
        atm_st_cmplt3 ; // Bug 4048
5143
 
5144
// thread qualification required.
5145
//assign ldbyp3_vld_en = (lmq_byp_data_en_w2[3] &
5146
//        ~(|lmq_byp_data_sel3[2:1])) | // do not set vld for cas/stdbl
5147
//      | spu_trap3 ;
5148
 
5149
assign ldbyp3_vld_en = lmq_byp_data_raw_sel_d2[3] |
5150
                       lmq_byp_data_sel3[3]       |
5151
                       (atm_ld_w_uerr & lsu_nceen_d1[3] & dfill_thread3) |
5152
                       lmq_byp_data_fmx_sel[3]    |
5153
                       tlb_err_en_w2[3]   |
5154
                       spu_trap3 ;
5155
 
5156
assign   fp_ldst_thrd3_w2 = fp_ldst_w2 & thread3_w2 & ld_inst_vld_w2 ;
5157
 
5158
// ld valid
5159
wire    ldbyp3_vld_tmp ;
5160 113 albert.wat
dffre_s #(1)  ldbyp3_vld_ff (
5161 95 fafa1971
        .din    (ldbyp3_vld_en),
5162
        .q      (ldbyp3_vld_tmp),
5163
        .rst    (ldbyp3_vld_rst),        .en     (ldbyp3_vld_en),
5164
        .clk    (clk),
5165 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5166 95 fafa1971
        );
5167
assign  ldbyp3_vld = ldbyp3_vld_tmp & ~pend_atm_ld_ue[3] ;
5168
 
5169
 
5170 113 albert.wat
dffe_s #(9)  ldbyp3_other_ff (
5171 95 fafa1971
        .din    ({fp_ldst_thrd3_w5,spu_trap3,misc_data_in[6:0]}),  //bug6525 fix2
5172
        .q      ({ldbyp3_fpld,spubyp3_trap,misc_data3[6:0]}),
5173
        .en     (ldbyp3_vld_en),
5174
        .clk    (clk),
5175 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5176 95 fafa1971
        );
5177
 
5178 113 albert.wat
dffre_s #(5)  ldbyp3_err_ff (
5179 95 fafa1971
        .din    ({tte_data_perror_unc_w2,atm_ld_w_uerr,
5180
                asi_tte_data_perror_w2,asi_tte_tag_perror_w2,ifu_lsu_asi_rd_unc}),
5181
        .q      ({cam_perr_unc3,pend_atm_ld_ue[3],asi_data_perr3,asi_tag_perr3,
5182
                ifu_unc_err3}),
5183
        .rst    (ldbyp3_vld_rst), .en     (ldbyp3_vld_en & ~spu_trap3 & ~lmq_byp_ldxa_sel3[1]), //bug6525 fix2
5184
        .clk    (clk),
5185 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5186 95 fafa1971
        );
5187
 
5188
//assign  ldbyp3_unc_err = ldbyp3_unc_err_q & ifu_lsu_nceen[3] ;
5189
 
5190
//assign  ld_any_byp_data_vld = 
5191
//  ldbyp0_vld | ldbyp1_vld | ldbyp2_vld | ldbyp3_vld ;
5192
 
5193 113 albert.wat
dff_s #(4)   stgm_sqshcmplt (
5194 95 fafa1971
        .din    (squash_byp_cmplt[3:0]),
5195
        .q      (squash_byp_cmplt_m[3:0]),
5196
        .clk    (clk),
5197 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5198 95 fafa1971
        );
5199
 
5200 113 albert.wat
dff_s #(4)  stgg_sqshcmplt (
5201 95 fafa1971
        .din    (squash_byp_cmplt_m[3:0]),
5202
        .q      (squash_byp_cmplt_g[3:0]),
5203
        .clk    (clk),
5204 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5205 95 fafa1971
        );
5206
 
5207
assign  fpld_byp_data_vld =
5208
  (ld_thrd_byp_sel_g[0] & ldbyp0_fpld & ~squash_byp_cmplt_g[0]) | // Bug 4998
5209
  (ld_thrd_byp_sel_g[1] & ldbyp1_fpld & ~squash_byp_cmplt_g[1]) |
5210
  (ld_thrd_byp_sel_g[2] & ldbyp2_fpld & ~squash_byp_cmplt_g[2]) |
5211
  (ld_thrd_byp_sel_g[3] & ldbyp3_fpld & ~squash_byp_cmplt_g[3]) ;
5212
 
5213
//assign  intld_byp_data_vld = |intld_byp_cmplt[3:0] ;
5214
// squash for spu-trap situation.
5215
assign  intld_byp_data_vld_e =
5216
        //(intld_byp_cmplt[0] & ~spubyp0_trap) |
5217
        (intld_byp_cmplt[0]) | // squash now thru squash_byp_cmplt
5218
        (intld_byp_cmplt[1]) |
5219
        (intld_byp_cmplt[2]) |
5220
        (intld_byp_cmplt[3]) ;
5221
 
5222 113 albert.wat
dff_s   stgm_ibvld (
5223 95 fafa1971
        .din    (intld_byp_data_vld_e),
5224
        .q      (intld_byp_data_vld_m),
5225
        .clk    (clk),
5226 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5227 95 fafa1971
        );
5228
 
5229
// to be removed - intld_byp_data_vld in lsu_mon.v
5230
/*
5231 113 albert.wat
dff_s   stgg_ibvld (
5232 95 fafa1971
        .din    (intld_byp_data_vld_m),
5233
        .q      (intld_byp_data_vld),
5234
        .clk    (clk),
5235 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5236 95 fafa1971
        );
5237
*/
5238
assign  spubyp_trap_active_e =
5239
        //(intld_byp_cmplt[0] & spubyp0_trap) | // Bug 4040
5240
        (ld_thrd_byp_sel_e[0] & spubyp0_trap) |
5241
        (ld_thrd_byp_sel_e[1] & spubyp1_trap) |
5242
        (ld_thrd_byp_sel_e[2] & spubyp2_trap) |
5243
        (ld_thrd_byp_sel_e[3] & spubyp3_trap) ;
5244
 
5245 113 albert.wat
dff_s   stgm_strmtrp (
5246 95 fafa1971
        .din    (spubyp_trap_active_e),
5247
        .q      (spubyp_trap_active_m),
5248
        .clk    (clk),
5249 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5250 95 fafa1971
        );
5251
 
5252 113 albert.wat
dff_s   stgg_strmtrp (
5253 95 fafa1971
        .din    (spubyp_trap_active_m),
5254
        .q      (spubyp_trap_active_g),
5255
        .clk    (clk),
5256 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5257 95 fafa1971
        );
5258
 
5259
assign  spubyp0_ttype[6:0] = misc_data0[6:0] ;
5260
assign  spubyp1_ttype[6:0] = misc_data1[6:0] ;
5261
assign  spubyp2_ttype[6:0] = misc_data2[6:0] ;
5262
assign  spubyp3_ttype[6:0] = misc_data3[6:0] ;
5263
 
5264
mux4ds #(7) mux_spubyp_ttype (
5265
        .in0(spubyp0_ttype[6:0]),
5266
        .in1(spubyp1_ttype[6:0]),
5267
        .in2(spubyp2_ttype[6:0]),
5268
        .in3(spubyp3_ttype[6:0]),
5269
        .sel0(ld_thrd_byp_mxsel_m[0]),
5270
        .sel1(ld_thrd_byp_mxsel_m[1]),
5271
        .sel2(ld_thrd_byp_mxsel_m[2]),
5272
        .sel3(ld_thrd_byp_mxsel_m[3]),
5273
        .dout(spubyp_ttype[6:0])
5274
);
5275
 
5276
assign  intld_byp_cmplt[0] = (ld_thrd_byp_sel_e[0] & ~(ldbyp0_fpld | squash_byp_cmplt[0])) ;
5277
assign  intld_byp_cmplt[1] = (ld_thrd_byp_sel_e[1] & ~(ldbyp1_fpld | squash_byp_cmplt[1])) ;
5278
assign  intld_byp_cmplt[2] = (ld_thrd_byp_sel_e[2] & ~(ldbyp2_fpld | squash_byp_cmplt[2])) ;
5279
assign  intld_byp_cmplt[3] = (ld_thrd_byp_sel_e[3] & ~(ldbyp3_fpld | squash_byp_cmplt[3])) ;
5280
 
5281 113 albert.wat
dff_s #(2)  stgm_l2fv (
5282 95 fafa1971
        .din    ({l2fill_vld_e,lsu_l2fill_fpld_e}),
5283
        .q      ({l2fill_vld_m,l2fill_fpld_m}),
5284
        .clk    (clk),
5285 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5286 95 fafa1971
        );
5287
 
5288 113 albert.wat
dff_s #(2) stgg_l2fv (
5289 95 fafa1971
        .din    ({l2fill_vld_m,l2fill_fpld_m}),
5290
        .q      ({l2fill_vld_g,l2fill_fpld_g}),
5291
        .clk    (clk),
5292 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5293 95 fafa1971
        );
5294
 
5295
// write to irf will need to be postphoned by a few cycles. 
5296
// may wish to find more bubbles by counting misses !!!
5297
//assign  lsu_irf_byp_data_src[0]  =      ld_inst_vld_unflushed ;
5298
//assign  lsu_irf_byp_data_src[1]  =    l2fill_vld_g ;
5299
//assign  lsu_irf_byp_data_src[2]  =    
5300
//  ~l2fill_vld_g    &      // no dfq fill
5301
//  ~ld_inst_vld_unflushed ;  // no ld/st in pipe.
5302
 
5303
  //~(ld_inst_vld_unflushed | st_inst_vld_unflushed) ;  // no ld/st in pipe.
5304
   // Timing Change.
5305
   //ld_any_byp_data_vld ;      // full raw bypasses data
5306
 
5307
 
5308
// Store to load full raw bypassing. Plus ldxa data bypassing.
5309
// ldxa-data may be bypassed asap if port available.
5310
// ldxa/stb raw and atomics assumed to be mutually exclusive.
5311
 
5312
wire int_ldxa_vld ;
5313
assign int_ldxa_vld = tlu_lsu_int_ldxa_vld_w2 & ~tlu_lsu_int_ld_ill_va_w2 ;
5314
assign  lmq_byp_data_fmx_sel[0] = int_ldxa_vld & thread0_w2 ;
5315
assign  lmq_byp_data_fmx_sel[1] = int_ldxa_vld & thread1_w2 ;
5316
assign  lmq_byp_data_fmx_sel[2] = int_ldxa_vld & thread2_w2 ;
5317
assign  lmq_byp_data_fmx_sel[3] = int_ldxa_vld & thread3_w2 ;
5318
 
5319
assign lmq_byp_data_en_w2[0] =  (|lmq_byp_data_sel0[3:0]) | lmq_byp_data_fmx_sel[0] ;
5320
assign lmq_byp_data_en_w2[1] =  (|lmq_byp_data_sel1[3:0]) | lmq_byp_data_fmx_sel[1] ;
5321
assign lmq_byp_data_en_w2[2] =  (|lmq_byp_data_sel2[3:0]) | lmq_byp_data_fmx_sel[2] ;
5322
assign lmq_byp_data_en_w2[3] =  (|lmq_byp_data_sel3[3:0]) | lmq_byp_data_fmx_sel[3] ;
5323
 
5324
/*
5325
assign  stq_pkt2_data_en[0] =
5326
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread0_g ;
5327
assign  stq_pkt2_data_en[1] =
5328
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread1_g ;
5329
assign  stq_pkt2_data_en[2] =
5330
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread2_g ;
5331
assign  stq_pkt2_data_en[3] =
5332
  st_inst_vld_g & ldst_dbl_g & quad_asi_g & thread3_g ;
5333
*/
5334
 
5335
// casxa to be decoded as doubleword.
5336
// casa to be decoded as word.
5337
// ldstuba to be decoded as byte.
5338
// casa, casxa and ldstuba needed to be decoded as alternate space insts with optional
5339
// imm_asi use.
5340
// An atomic will switch out a thread.
5341
 
5342
 
5343
wire  ifu_ldxa_vld,  spu_ldxa_vld ;
5344
assign  ifu_ldxa_vld = ifu_lsu_ldxa_data_vld_w2 & ~ifu_lsu_ldxa_illgl_va_w2 ;
5345
//assign  tlu_ldxa_vld = tlu_lsu_ldxa_data_vld_w2 & ~tlu_lsu_ldxa_illgl_va_w2 ;
5346
assign  spu_ldxa_vld = spu_lsu_ldxa_data_vld_w2 & ~spu_lsu_ldxa_illgl_va_w2 ;
5347
 
5348
wire int_ldxa_ivld ;
5349
assign int_ldxa_ivld = tlu_lsu_int_ldxa_vld_w2 & tlu_lsu_int_ld_ill_va_w2 ;
5350
// ldxa data returns need to cmplt thread without writing to register file
5351
assign  ldxa_illgl_va_cmplt[0] =
5352
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread0_w2) |
5353
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread0_w2) |
5354
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread0_w2) |
5355
  (int_ldxa_ivld & thread0_w2) |
5356
  lsu_asi_illgl_va_cmplt_w2[0] ;
5357
assign  ldxa_illgl_va_cmplt[1] =
5358
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread1_w2) |
5359
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread1_w2) |
5360
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread1_w2) |
5361
  (int_ldxa_ivld & thread1_w2) |
5362
  lsu_asi_illgl_va_cmplt_w2[1] ;
5363
assign  ldxa_illgl_va_cmplt[2] =
5364
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread2_w2) |
5365
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread2_w2) |
5366
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread2_w2) |
5367
  (int_ldxa_ivld & thread2_w2) |
5368
  lsu_asi_illgl_va_cmplt_w2[2] ;
5369
assign  ldxa_illgl_va_cmplt[3] =
5370
  ((ifu_lsu_ldxa_data_vld_w2 & ifu_lsu_ldxa_illgl_va_w2) & ifu_ldxa_thread3_w2) |
5371
  //((tlu_lsu_ldxa_data_vld_w2 & tlu_lsu_ldxa_illgl_va_w2) & tlu_ldxa_thread3_w2) |
5372
  ((spu_lsu_ldxa_data_vld_w2 & spu_lsu_ldxa_illgl_va_w2) & spu_ldxa_thread3_w2) |
5373
  (int_ldxa_ivld & thread3_w2) |
5374
  lsu_asi_illgl_va_cmplt_w2[3] ;
5375
 
5376 113 albert.wat
dff_s #(4)  illglva_cmplt_d1 (
5377 95 fafa1971
        .din    (ldxa_illgl_va_cmplt[3:0]),
5378
        .q      (ldxa_illgl_va_cmplt_d1[3:0]),
5379
        .clk    (clk),
5380 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5381 95 fafa1971
        );
5382
 
5383
// Thread0
5384
// Should be able to remove thread qualification for full-raw.
5385
// Could have and e stage store and w2 stage stb rd in same cycle !!! Qualify select3
5386
// with select0 to give the earlier event priority. 
5387
assign  lmq_byp_ldxa_sel0[0] = ifu_ldxa_vld & ifu_ldxa_thread0_w2 ;
5388
//assign  lmq_byp_ldxa_sel0[1] = tlu_ldxa_vld & tlu_ldxa_thread0_w2 ; 
5389
assign  lmq_byp_ldxa_sel0[1] = spu_ldxa_vld & spu_ldxa_thread0_w2 ;
5390
assign  lmq_byp_ldxa_sel0[2] = (lsu_asi_rd_en_w2 & thread0_w2) | ldxa_tlbrd0_w3 ;
5391
 
5392
wire    fraw_annul0,fraw_annul1,fraw_annul2,fraw_annul3 ;
5393
wire    ldst_miss0,ldst_miss1,ldst_miss2,ldst_miss3 ;
5394
 
5395
//RAW read STB at W3 (not W2)
5396
//   E M W        W2 W3                      w4
5397
//LD     cam_hit     RD STB, flop in byp FFs
5398
//inst+1 D        E  
5399
//inst+2          D  E                            <= squash (stxa) rs3_e to write into byp FFs
5400
//  
5401
assign  fraw_annul0 = ld_stb_full_raw_w3 & thread0_w3 & ld_inst_vld_w3;
5402
assign  fraw_annul1 = ld_stb_full_raw_w3 & thread1_w3 & ld_inst_vld_w3;
5403
assign  fraw_annul2 = ld_stb_full_raw_w3 & thread2_w3 & ld_inst_vld_w3;
5404
assign  fraw_annul3 = ld_stb_full_raw_w3 & thread3_w3 & ld_inst_vld_w3;
5405
 
5406
assign  ldst_miss0 = lsu_ldst_miss_w2 & thread0_w2 ;
5407
assign  ldst_miss1 = lsu_ldst_miss_w2 & thread1_w2 ;
5408
assign  ldst_miss2 = lsu_ldst_miss_w2 & thread2_w2 ;
5409
assign  ldst_miss3 = lsu_ldst_miss_w2 & thread3_w2 ;
5410
 
5411
wire    fraw_annul0_d1,fraw_annul1_d1,fraw_annul2_d1,fraw_annul3_d1 ;
5412
wire    ldst_miss0_d1,ldst_miss1_d1,ldst_miss2_d1,ldst_miss3_d1 ;
5413
 
5414 113 albert.wat
dff_s #(4)  fraw_d1 (
5415 95 fafa1971
        .din    ({fraw_annul3,fraw_annul2,fraw_annul1,fraw_annul0}),
5416
        .q      ({fraw_annul3_d1,fraw_annul2_d1,fraw_annul1_d1,fraw_annul0_d1}),
5417
        .clk    (clk),
5418 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5419 95 fafa1971
        );
5420
 
5421 113 albert.wat
dff_s #(4)  ldstm_d1 (
5422 95 fafa1971
        .din    ({ldst_miss3,ldst_miss2,ldst_miss1,ldst_miss0}),
5423
        .q      ({ldst_miss3_d1,ldst_miss2_d1,ldst_miss1_d1,ldst_miss0_d1}),
5424
        .clk    (clk),
5425 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5426 95 fafa1971
        );
5427
 
5428
//wire  memref_d ;
5429
//assign        memref_d = ifu_lsu_memref_d ;
5430
/*wire  mref_vld0,mref_vld1,mref_vld2,mref_vld3;
5431
wire    mref_vld0_d1,mref_vld1_d1,mref_vld2_d1,mref_vld3_d1;
5432
 
5433
// Bug 3053 - prevent overwrite of ldxa data with subsequent st-data
5434
assign  mref_vld0 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread0_w2) ;
5435
assign  mref_vld1 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread1_w2) ;
5436
assign  mref_vld2 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread2_w2) ;
5437
assign  mref_vld3 = (memref_d | memref_e) & ~(lsu_ldst_miss_w2 & thread3_w2) ;
5438
 
5439 113 albert.wat
dff_s #(4)  mrefv_d1 (
5440 95 fafa1971
        .din    ({mref_vld3,mref_vld2,mref_vld1,mref_vld0}),
5441
        .q      ({mref_vld3_d1,mref_vld2_d1,mref_vld1_d1,mref_vld0_d1}),
5442
        .clk    (clk),
5443 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5444 95 fafa1971
        );  */
5445
 
5446
//RAW timing change   
5447
assign  lmq_byp_data_sel0[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3)  & thread0_w3 & ld_inst_vld_w3 ;
5448
//assign  lmq_byp_data_sel0[1] = st_inst_vld_e & thread0_e & ~ifu_lsu_casa_e & ~fraw_annul0 ;
5449
// Timing fix - at most ld will also update the bypass buffer also.
5450
//assign  lmq_byp_data_sel0[1] = memref_e & thread0_e & ~ifu_lsu_casa_e & ~fraw_annul0 ; //bug3009
5451
assign  lmq_byp_data_sel0[1] =  ~lmq_byp_data_sel0[0] & memref_e & thread0_e & ~ifu_lsu_casa_e &
5452
                        ~(fraw_annul0 | fraw_annul0_d1 | ldst_miss0 | ldst_miss0_d1); // Bug 3053,3180
5453
//assign  lmq_byp_data_sel0[1] = mref_vld0_d1 & thread0_e & ~ifu_lsu_casa_e & ~(fraw_annul0 | fraw_annul0_d1); // Bug 3053
5454
//assign  lmq_byp_data_sel0[1] = memref_e & thread0_e & ~ifu_lsu_casa_e & ~(fraw_annul0 | fraw_annul0_d1);
5455
assign  lmq_byp_data_sel0[2] = ~(|lmq_byp_data_sel0[1:0]) & casa_g & thread0_g & lsu_inst_vld_w & ~fraw_annul0_d1 ;
5456
assign  lmq_byp_data_sel0[3] = |lmq_byp_ldxa_sel0[2:0];
5457
//assign  lmq_byp_data_sel0[3] = |lmq_byp_ldxa_sel0[3:0];
5458
 
5459
// Thread1
5460
assign  lmq_byp_ldxa_sel1[0] = ifu_ldxa_vld & ifu_ldxa_thread1_w2 ;
5461
//assign  lmq_byp_ldxa_sel1[1] = tlu_ldxa_vld & tlu_ldxa_thread1_w2 ; 
5462
assign  lmq_byp_ldxa_sel1[1] = spu_ldxa_vld & spu_ldxa_thread1_w2 ;
5463
assign  lmq_byp_ldxa_sel1[2] = (lsu_asi_rd_en_w2 & thread1_w2) | ldxa_tlbrd1_w3 ;
5464
 
5465
assign  lmq_byp_data_sel1[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3) & ld_inst_vld_w3 & thread1_w3 ;
5466
assign  lmq_byp_data_sel1[1] = ~lmq_byp_data_sel1[0] & memref_e & thread1_e & ~ifu_lsu_casa_e &
5467
                        ~(fraw_annul1 | fraw_annul1_d1 | ldst_miss1 | ldst_miss1_d1); // Bug 3053,3180
5468
//assign  lmq_byp_data_sel1[1] = memref_e & thread1_e & ~ifu_lsu_casa_e & ~fraw_annul1; // bug3009
5469
//assign  lmq_byp_data_sel1[1] = mref_vld1_d1 & thread1_e & ~ifu_lsu_casa_e & ~(fraw_annul1 | fraw_annul1_d1);
5470
//assign  lmq_byp_data_sel1[1] = memref_e & thread1_e & ~ifu_lsu_casa_e & ~(fraw_annul1 | fraw_annul1_d1); // Bug 3053
5471
assign  lmq_byp_data_sel1[2] =  ~(|lmq_byp_data_sel1[1:0]) & casa_g & thread1_g & lsu_inst_vld_w & ~fraw_annul1_d1 ;
5472
assign  lmq_byp_data_sel1[3] = |lmq_byp_ldxa_sel1[2:0];
5473
 
5474
// Thread2
5475
assign  lmq_byp_ldxa_sel2[0] = ifu_ldxa_vld & ifu_ldxa_thread2_w2 ;
5476
//assign  lmq_byp_ldxa_sel2[1] = tlu_ldxa_vld & tlu_ldxa_thread2_w2 ; 
5477
assign  lmq_byp_ldxa_sel2[1] = spu_ldxa_vld & spu_ldxa_thread2_w2 ;
5478
assign  lmq_byp_ldxa_sel2[2] = (lsu_asi_rd_en_w2 & thread2_w2) | ldxa_tlbrd2_w3 ;
5479
 
5480
assign  lmq_byp_data_sel2[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3) & ld_inst_vld_w3 & thread2_w3 ;
5481
//assign  lmq_byp_data_sel2[1] = memref_e & thread2_e & ~ifu_lsu_casa_e & ~fraw_annul2; // bug3009
5482
assign  lmq_byp_data_sel2[1] = ~lmq_byp_data_sel2[0] & memref_e & thread2_e & ~ifu_lsu_casa_e &
5483
                        ~(fraw_annul2 | fraw_annul2_d1 | ldst_miss2 | ldst_miss2_d1); // Bug 3053,3180
5484
//assign  lmq_byp_data_sel2[1] = memref_e & thread2_e & ~ifu_lsu_casa_e & ~(fraw_annul2 | fraw_annul2_d1); // Bug 3053
5485
assign  lmq_byp_data_sel2[2] =  ~(|lmq_byp_data_sel2[1:0]) & casa_g & thread2_g & lsu_inst_vld_w & ~fraw_annul2_d1 ;
5486
assign  lmq_byp_data_sel2[3] = |lmq_byp_ldxa_sel2[2:0];
5487
 
5488
// Thread3
5489
assign  lmq_byp_ldxa_sel3[0] = ifu_ldxa_vld & ifu_ldxa_thread3_w2 ;
5490
//assign  lmq_byp_ldxa_sel3[1] = tlu_ldxa_vld & tlu_ldxa_thread3_w2 ; 
5491
assign  lmq_byp_ldxa_sel3[1] = spu_ldxa_vld & spu_ldxa_thread3_w2 ;
5492
assign  lmq_byp_ldxa_sel3[2] =  (lsu_asi_rd_en_w2 & thread3_w2) | ldxa_tlbrd3_w3 ;
5493
 
5494
assign  lmq_byp_data_sel3[0] = ld_stb_full_raw_w3 & ~(ldd_force_l2access_w3 | atomic_w3 | dtlb_perror_en_w3) & ld_inst_vld_w3 & thread3_w3 ;
5495
assign  lmq_byp_data_sel3[1] = ~lmq_byp_data_sel3[0] & memref_e & thread3_e & ~ifu_lsu_casa_e &
5496
                        ~(fraw_annul3 | fraw_annul3_d1 | ldst_miss3 | ldst_miss3_d1); // Bug 3053,3180
5497
//assign  lmq_byp_data_sel3[1] = memref_e & thread3_e & ~ifu_lsu_casa_e & ~(fraw_annul3 | fraw_annul3_d1); // Bug 3053
5498
assign  lmq_byp_data_sel3[2] = ~(|lmq_byp_data_sel3[1:0]) & casa_g & thread3_g & lsu_inst_vld_w & ~fraw_annul3_d1 ;
5499
assign  lmq_byp_data_sel3[3] = |lmq_byp_ldxa_sel3[2:0];
5500
 
5501
 
5502 113 albert.wat
dff_s #(4)  ff_lmq_byp_data_raw_sel_d1 (
5503 95 fafa1971
        .din    ({lmq_byp_data_sel3[0], lmq_byp_data_sel2[0],
5504
                  lmq_byp_data_sel1[0], lmq_byp_data_sel0[0]}),
5505
        .q      (lmq_byp_data_raw_sel_d1[3:0]),
5506
        .clk    (clk),
5507 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5508 95 fafa1971
        );
5509
 
5510 113 albert.wat
dff_s #(4)  ff_lmq_byp_data_raw_sel_d2 (
5511 95 fafa1971
        .din    (lmq_byp_data_raw_sel_d1[3:0]),
5512
        .q      (lmq_byp_data_raw_sel_d2[3:0]),
5513
        .clk    (clk),
5514 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5515 95 fafa1971
        );
5516
 
5517
wire            lsu_irf_raw_byp_e;
5518
// Includes both ldxa and raw bypass. 
5519
assign  lsu_irf_raw_byp_e  =
5520
  ~l2fill_vld_e    &      // no dfq fill
5521
  ~(memref_e) ; // no ld/st in pipe. 
5522
  //~(ld_inst_vld_e | st_inst_vld_e) ; // no ld/st in pipe. 
5523
 
5524
// bug 5379 plus misc (randomize selection to prevent deadlock.
5525
wire [3:0] bypass_sel ;
5526
assign  bypass_sel[0] = lsu_dcache_rand[0] ?
5527
        ldbyp0_vld : (ldbyp0_vld & ~(ldbyp3_vld | ldbyp2_vld | ldbyp1_vld)) ;
5528
assign  bypass_sel[1] = lsu_dcache_rand[0] ?
5529
        (ldbyp1_vld & ~ldbyp0_vld) : (ldbyp1_vld & ~(ldbyp3_vld | ldbyp2_vld)) ;
5530
assign  bypass_sel[2] = lsu_dcache_rand[0] ?
5531
        (ldbyp2_vld & ~(ldbyp0_vld | ldbyp1_vld)) : (ldbyp2_vld & ~ldbyp3_vld) ;
5532
assign  bypass_sel[3] = lsu_dcache_rand[0] ?
5533
        (ldbyp3_vld & ~(ldbyp0_vld | ldbyp1_vld | ldbyp2_vld)) : ldbyp3_vld ;
5534
 
5535
assign ld_thrd_byp_sel_e[0] = bypass_sel[0] & lsu_irf_raw_byp_e ;
5536
assign ld_thrd_byp_sel_e[1] = bypass_sel[1] & lsu_irf_raw_byp_e ;
5537
assign ld_thrd_byp_sel_e[2] = bypass_sel[2] & lsu_irf_raw_byp_e ;
5538
assign ld_thrd_byp_sel_e[3] = bypass_sel[3] & lsu_irf_raw_byp_e ;
5539
 
5540
/*assign ld_thrd_byp_sel_e[0] = ldbyp0_vld & lsu_irf_raw_byp_e ;
5541
assign ld_thrd_byp_sel_e[1] = ldbyp1_vld & lsu_irf_raw_byp_e &
5542
      ~ldbyp0_vld ;
5543
assign ld_thrd_byp_sel_e[2] = ldbyp2_vld & lsu_irf_raw_byp_e &
5544
      ~(ldbyp0_vld | ldbyp1_vld);
5545
assign ld_thrd_byp_sel_e[3] = ldbyp3_vld & lsu_irf_raw_byp_e &
5546
      ~(ldbyp0_vld | ldbyp1_vld | ldbyp2_vld) ; */
5547
 
5548
 
5549
   //assign lsu_ld_thrd_byp_sel_e[2:0] = ld_thrd_byp_sel_e[2:0];
5550
    bw_u1_buf_30x UZsize_lsu_ld_thrd_byp_sel_e_b2 (.a(ld_thrd_byp_sel_e[2]), .z(lsu_ld_thrd_byp_sel_e[2]));
5551
    bw_u1_buf_30x UZsize_lsu_ld_thrd_byp_sel_e_b1 (.a(ld_thrd_byp_sel_e[1]), .z(lsu_ld_thrd_byp_sel_e[1]));
5552
    bw_u1_buf_30x UZsize_lsu_ld_thrd_byp_sel_e_b0 (.a(ld_thrd_byp_sel_e[0]), .z(lsu_ld_thrd_byp_sel_e[0]));
5553
 
5554 113 albert.wat
dff_s #(4)  tbyp_stgd1 (
5555 95 fafa1971
        .din    (ld_thrd_byp_sel_e[3:0]),
5556
        .q      (ld_thrd_byp_sel_m[3:0]),
5557
        .clk    (clk),
5558 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5559 95 fafa1971
        );
5560
 
5561
//assign ld_thrd_byp_mxsel_m[2:0]  =    ld_thrd_byp_sel_m[2:0];
5562
//assign ld_thrd_byp_mxsel_m[3]    =  ~|ld_thrd_byp_sel_m[2:0];
5563
 
5564
assign ld_thrd_byp_mxsel_m[0]  =    ld_thrd_byp_sel_m[0] & ~rst_tri_en;
5565
assign ld_thrd_byp_mxsel_m[1]  =    ld_thrd_byp_sel_m[1] & ~rst_tri_en;
5566
assign ld_thrd_byp_mxsel_m[2]  =    ld_thrd_byp_sel_m[2] & ~rst_tri_en;
5567
assign ld_thrd_byp_mxsel_m[3]  =    (~|ld_thrd_byp_sel_m[2:0]) |  rst_tri_en;
5568
 
5569 113 albert.wat
dff_s #(4)  tbyp_stgd2 (
5570 95 fafa1971
        .din    (ld_thrd_byp_sel_m[3:0]),
5571
        .q      (ld_thrd_byp_sel_g[3:0]),
5572
        .clk    (clk),
5573 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5574 95 fafa1971
        );
5575
 
5576
  //should move to M stage 
5577
 
5578
//assign ld_thrd_byp_mxsel_g[2:0]  =    ld_thrd_byp_sel_g[2:0];
5579
//assign ld_thrd_byp_mxsel_g[3]    =  ~|ld_thrd_byp_sel_g[2:0];
5580
 
5581
assign  lmq_byp_ldxa_mxsel0[1:0] =   lmq_byp_ldxa_sel0[1:0];
5582
assign  lmq_byp_ldxa_mxsel0[2]   = ~|lmq_byp_ldxa_sel0[1:0];
5583
assign  lmq_byp_ldxa_mxsel1[1:0] =   lmq_byp_ldxa_sel1[1:0];
5584
assign  lmq_byp_ldxa_mxsel1[2]   = ~|lmq_byp_ldxa_sel1[1:0];
5585
assign  lmq_byp_ldxa_mxsel2[1:0] =   lmq_byp_ldxa_sel2[1:0];
5586
assign  lmq_byp_ldxa_mxsel2[2]   = ~|lmq_byp_ldxa_sel2[1:0];
5587
assign  lmq_byp_ldxa_mxsel3[1:0] =   lmq_byp_ldxa_sel3[1:0];
5588
assign  lmq_byp_ldxa_mxsel3[2]   = ~|lmq_byp_ldxa_sel3[1:0];
5589
 
5590
assign  lmq_byp_data_mxsel0[0] =   lmq_byp_data_sel0[0] & ~rst_tri_en |  sehold;
5591
assign  lmq_byp_data_mxsel0[1] =   lmq_byp_data_sel0[1] & ~rst_tri_en & ~sehold;
5592
assign  lmq_byp_data_mxsel0[2] =   lmq_byp_data_sel0[2] & ~rst_tri_en & ~sehold;
5593
assign  lmq_byp_data_mxsel0[3]   = (~|lmq_byp_data_sel0[2:0] | rst_tri_en) & ~sehold;
5594
 
5595
assign  lmq_byp_data_mxsel1[0] =   lmq_byp_data_sel1[0] & ~rst_tri_en |  sehold;
5596
assign  lmq_byp_data_mxsel1[1] =   lmq_byp_data_sel1[1] & ~rst_tri_en & ~sehold;
5597
assign  lmq_byp_data_mxsel1[2] =   lmq_byp_data_sel1[2] & ~rst_tri_en & ~sehold;
5598
assign  lmq_byp_data_mxsel1[3]   = (~|lmq_byp_data_sel1[2:0] | rst_tri_en) & ~sehold;
5599
 
5600
assign  lmq_byp_data_mxsel2[0] =   lmq_byp_data_sel2[0] & ~rst_tri_en |  sehold;
5601
assign  lmq_byp_data_mxsel2[1] =   lmq_byp_data_sel2[1] & ~rst_tri_en & ~sehold;
5602
assign  lmq_byp_data_mxsel2[2] =   lmq_byp_data_sel2[2] & ~rst_tri_en & ~sehold;
5603
assign  lmq_byp_data_mxsel2[3]   = (~|lmq_byp_data_sel2[2:0] | rst_tri_en) & ~sehold;
5604
 
5605
assign  lmq_byp_data_mxsel3[0] =   lmq_byp_data_sel3[0] & ~rst_tri_en |  sehold;
5606
assign  lmq_byp_data_mxsel3[1] =   lmq_byp_data_sel3[1] & ~rst_tri_en & ~sehold;
5607
assign  lmq_byp_data_mxsel3[2] =   lmq_byp_data_sel3[2] & ~rst_tri_en & ~sehold;
5608
assign  lmq_byp_data_mxsel3[3]   = (~|lmq_byp_data_sel3[2:0] | rst_tri_en) & ~sehold;
5609
 
5610
//=========================================================================================
5611
//      Error Based Traps/Reporting
5612
//
5613
//=========================================================================================
5614
 
5615
// !!! ORIGINAL ABOVE !!!
5616
// Error Table for Queue
5617
// ** In all cases; squash writes to irf.
5618
//                              | Error Reporting       | Trap ?        | 
5619
// ifu_lsu_asi_rd_unc           | NA;done by ifu        | daccess-error |
5620
// tte_data_perror_unc_w2       | sync;in pipe          | daccess-error |
5621
// tte_data_perror_corr_w2      | sync;in pipe          | dmmu-miss     |
5622
// asi_tte_data_perror_w2       | async;out of Q        | daccess-error |
5623
// asi_tte_tag_perror_w2        | async;out of Q        | daccess-error |
5624
 
5625
assign  squash_byp_cmplt[0] =
5626
        ((cam_perr_unc0  |
5627
        asi_data_perr0 |
5628
        asi_tag_perr0  |
5629
        ifu_unc_err0   ) & lsu_nceen_d1[0]) |
5630
        pend_atm_ld_ue[0] |
5631
        spubyp0_trap ; // Bug 3873. add spu trap squash. (change reverted).
5632
assign  squash_byp_cmplt[1] =
5633
        ((cam_perr_unc1 | asi_data_perr1 | asi_tag_perr1 | ifu_unc_err1) & lsu_nceen_d1[1]) |
5634
        pend_atm_ld_ue[1] | spubyp1_trap ;
5635
assign  squash_byp_cmplt[2] =
5636
        ((cam_perr_unc2 | asi_data_perr2 | asi_tag_perr2 | ifu_unc_err2) & lsu_nceen_d1[2]) |
5637
        pend_atm_ld_ue[2] | spubyp2_trap ;
5638
assign  squash_byp_cmplt[3] =
5639
        ((cam_perr_unc3 | asi_data_perr3 | asi_tag_perr3 | ifu_unc_err3) & lsu_nceen_d1[3]) |
5640
        pend_atm_ld_ue[3] | spubyp3_trap ;
5641
 
5642
assign  cam_perr_unc_e =
5643
  (ld_thrd_byp_sel_e[0] & cam_perr_unc0) |
5644
  (ld_thrd_byp_sel_e[1] & cam_perr_unc1) |
5645
  (ld_thrd_byp_sel_e[2] & cam_perr_unc2) |
5646
  (ld_thrd_byp_sel_e[3] & cam_perr_unc3) ;
5647
assign  asi_data_perr_e =
5648
  (ld_thrd_byp_sel_e[0] & asi_data_perr0) |
5649
  (ld_thrd_byp_sel_e[1] & asi_data_perr1) |
5650
  (ld_thrd_byp_sel_e[2] & asi_data_perr2) |
5651
  (ld_thrd_byp_sel_e[3] & asi_data_perr3) ;
5652
assign  asi_tag_perr_e =
5653
  (ld_thrd_byp_sel_e[0] & asi_tag_perr0) |
5654
  (ld_thrd_byp_sel_e[1] & asi_tag_perr1) |
5655
  (ld_thrd_byp_sel_e[2] & asi_tag_perr2) |
5656
  (ld_thrd_byp_sel_e[3] & asi_tag_perr3) ;
5657
assign  ifu_unc_err_e =
5658
  (ld_thrd_byp_sel_e[0] & ifu_unc_err0) |
5659
  (ld_thrd_byp_sel_e[1] & ifu_unc_err1) |
5660
  (ld_thrd_byp_sel_e[2] & ifu_unc_err2) |
5661
  (ld_thrd_byp_sel_e[3] & ifu_unc_err3) ;
5662
wire atm_st_unc_err_e,atm_st_unc_err_m,atm_st_unc_err_g ;
5663
assign  atm_st_unc_err_e =
5664
(atm_st_cmplt0 & pend_atm_ld_ue[0]) |
5665
(atm_st_cmplt1 & pend_atm_ld_ue[1]) |
5666
(atm_st_cmplt2 & pend_atm_ld_ue[2]) |
5667
(atm_st_cmplt3 & pend_atm_ld_ue[3]) ;
5668
 
5669 113 albert.wat
dff_s #(5)  stgm_tlberr (
5670 95 fafa1971
        .din    ({cam_perr_unc_e,asi_data_perr_e,
5671
                asi_tag_perr_e,ifu_unc_err_e,atm_st_unc_err_e}),
5672
        .q      ({cam_perr_unc_m,asi_data_perr_m,
5673
                asi_tag_perr_m,ifu_unc_err_m,atm_st_unc_err_m}),
5674
        .clk    (clk),
5675 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5676 95 fafa1971
        );
5677
 
5678
 
5679 113 albert.wat
dff_s #(5)  stgg_tlberr (
5680 95 fafa1971
        .din    ({cam_perr_unc_m,asi_data_perr_m,
5681
                asi_tag_perr_m,ifu_unc_err_m,atm_st_unc_err_m}),
5682
        .q      ({cam_perr_unc_g,asi_data_perr_g,
5683
                asi_tag_perr_g,ifu_unc_err_g,atm_st_unc_err_g}),
5684
        .clk    (clk),
5685 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5686 95 fafa1971
        );
5687
 
5688
assign  lsu_tlb_asi_data_perr_g = asi_data_perr_g ;
5689
assign  lsu_tlb_asi_tag_perr_g = asi_tag_perr_g ;
5690
 
5691
// Asynchronous Trap Reporting to TLU (Traps are still precise).
5692
// This version of nceen is meant specifically for trap reporting
5693
// out of the asi queue.
5694
wire nceen_m, nceen_g ;
5695
assign nceen_m =
5696
        (ld_thrd_byp_sel_m[0] & lsu_nceen_d1[0]) |
5697
        (ld_thrd_byp_sel_m[1] & lsu_nceen_d1[1]) |
5698
        (ld_thrd_byp_sel_m[2] & lsu_nceen_d1[2]) |
5699
        (ld_thrd_byp_sel_m[3] & lsu_nceen_d1[3]) ;
5700
 
5701
wire nceen_dfq_m,nceen_dfq_g ;
5702
 
5703
// This version is meant specifically for lds reporting traps
5704
// from the dfq.
5705
assign  nceen_dfq_m =
5706
        ((~dfq_tid_m[1] & ~dfq_tid_m[0]) & lsu_nceen_d1[0]) |
5707
        ((~dfq_tid_m[1] &  dfq_tid_m[0]) & lsu_nceen_d1[1]) |
5708
        (( dfq_tid_m[1] & ~dfq_tid_m[0]) & lsu_nceen_d1[2]) |
5709
        (( dfq_tid_m[1] &  dfq_tid_m[0]) & lsu_nceen_d1[3]) ;
5710
 
5711 113 albert.wat
dff_s #(2)  trpen_stg (
5712 95 fafa1971
        .din    ({nceen_m,nceen_dfq_m}),
5713
        .q      ({nceen_g,nceen_dfq_g}),
5714
        .clk    (clk),
5715 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5716 95 fafa1971
        );
5717
 
5718
 
5719
// l2c/dram
5720
wire    atm_ld_w_uerr_m ;
5721 113 albert.wat
dff_s #(1)  atmldu_stm (
5722 95 fafa1971
        .din    (atm_ld_w_uerr),
5723
        .q      (atm_ld_w_uerr_m),
5724
        .clk    (clk),
5725 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5726 95 fafa1971
        );
5727
 
5728
wire    pmem_unc_error_m,pmem_unc_error_g ;
5729
assign  pmem_unc_error_m =
5730
        l2_unc_error_m &  // bug3666
5731
        ~atm_ld_w_uerr_m ; //bug4048 - squash for atm ld with error.
5732
 
5733
wire    pmem_unc_error_tmp ;
5734 113 albert.wat
dff_s #(1)  pmem_stg (
5735 95 fafa1971
        .din    (pmem_unc_error_m),
5736
        .q      (pmem_unc_error_tmp),
5737
        .clk    (clk),
5738 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5739 95 fafa1971
        );
5740
 
5741
assign  pmem_unc_error_g =
5742
        (pmem_unc_error_tmp | bld_unc_err_pend_g) & ~bld_squash_err_g ;
5743
 
5744
wire    async_ttype_vld_g ;
5745
wire [6:0] async_ttype_g ;
5746
wire [1:0] async_tid_g ;
5747
 
5748
//wire  st_dtlb_perr_en ;
5749
//assign        st_dtlb_perr_en = st_inst_vld_unflushed & tte_data_perror_unc & nceen_pipe_g ;
5750
 
5751
// traps are not to be taken if enables are not set. The asi rds of the tlb must
5752
// thus complete as usual.
5753
assign  async_ttype_vld_g =
5754
        (((cam_perr_unc_g | asi_data_perr_g | asi_tag_perr_g | ifu_unc_err_g) & nceen_g) |
5755
                (pmem_unc_error_g & nceen_dfq_g)) | // Bug 3335,3518
5756
        atm_st_unc_err_g |      // Bug 4048
5757
        //lsu_defr_trp_taken_g |
5758
        //st_dtlb_perr_en |
5759
        //cam_perr_corr_g |
5760
        spubyp_trap_active_g ;
5761
 
5762
wire [6:0]       async_ttype_m ;
5763
assign  async_ttype_m[6:0] =
5764
        spubyp_trap_active_m ? spubyp_ttype[6:0] : 7'h32 ;
5765
 
5766 113 albert.wat
dff_s #(7)  attype_stg (
5767 95 fafa1971
        .din    (async_ttype_m[6:0]),
5768
        .q      (async_ttype_g[6:0]),
5769
        .clk    (clk),
5770 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5771 95 fafa1971
        );
5772
 
5773
wire [1:0]       async_err_tid_e,async_err_tid_m,async_err_tid_g ;
5774
assign  async_err_tid_e[0] = ld_thrd_byp_sel_e[1] | ld_thrd_byp_sel_e[3] ;
5775
assign  async_err_tid_e[1] = ld_thrd_byp_sel_e[3] | ld_thrd_byp_sel_e[2] ;
5776
 
5777 113 albert.wat
dff_s #(2)  ldbyperr_stgm (
5778 95 fafa1971
        .din    (async_err_tid_e[1:0]),
5779
        .q      (async_err_tid_m[1:0]),
5780
        .clk    (clk),
5781 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5782 95 fafa1971
        );
5783
 
5784 113 albert.wat
dff_s #(2)  ldbyperr_stgg (
5785 95 fafa1971
        .din    (async_err_tid_m[1:0]),
5786
        .q      (async_err_tid_g[1:0]),
5787
        .clk    (clk),
5788 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5789 95 fafa1971
        );
5790
 
5791
wire    sel_dfq_tid ;
5792
assign  sel_dfq_tid = pmem_unc_error_g | atm_st_unc_err_g ;
5793
assign  async_tid_g[1:0] =
5794
        //lsu_defr_trp_taken_g ? thrid_g[1:0] : // Bug 4660 - remove.
5795
        sel_dfq_tid ? // Bug 3335,4048
5796
        dfq_tid_g[1:0] : async_err_tid_g[1:0] ;
5797
 
5798
// Delay async_trp interface to TLU by a cycle.
5799
 
5800 113 albert.wat
dff_s #(10)  asynctrp_stgw2 (
5801 95 fafa1971
        .din    ({async_ttype_vld_g,async_tid_g[1:0],async_ttype_g[6:0]}),
5802
        .q      ({lsu_tlu_async_ttype_vld_w2,lsu_tlu_async_tid_w2[1:0],
5803
                lsu_tlu_async_ttype_w2[6:0]}),
5804
        .clk    (clk),
5805 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5806 95 fafa1971
        );
5807
 
5808
// Asynchronous Error Reporting to IFU 
5809
// Partial.
5810
 
5811
wire  sync_error_sel ;
5812
wire    memref_m ,memref_g;
5813
 
5814 113 albert.wat
dff_s #(1) memref_stgg (
5815 95 fafa1971
        .din    (memref_m),
5816
        .q      (memref_g),
5817
        .clk    (clk),
5818 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5819 95 fafa1971
        );
5820
 
5821
//assign  sync_error_sel = tte_data_perror_unc | tte_data_perror_corr ;
5822
 
5823
//for in1 or in2 to be selected, memref_g must be 0.
5824
//in1 is reported thru the bypass/asi queues, in2 thru the dfq.
5825
//So err_addr_sel[0] can be memref_g.
5826
   assign sync_error_sel = memref_g;
5827
 
5828
wire    async_error_sel ;
5829
assign  async_error_sel = asi_data_perr_g | asi_tag_perr_g ;
5830
 
5831
assign  lsu_err_addr_sel[0] =  sync_error_sel & ~rst_tri_en;
5832
assign  lsu_err_addr_sel[1] =  async_error_sel & ~rst_tri_en;
5833
assign  lsu_err_addr_sel[2] = ~(sync_error_sel | async_error_sel) | rst_tri_en;
5834
 
5835
//mux4ds  #(6) async_tlb_index_mx(
5836
//  .in0  (misc_data0[5:0]),
5837
//  .in1  (misc_data1[5:0]),
5838
//  .in2  (misc_data2[5:0]),
5839
//  .in3  (misc_data3[5:0]),
5840
//  .sel0 (ld_thrd_byp_sel_g[0]),
5841
//  .sel1 (ld_thrd_byp_sel_g[1]),
5842
//  .sel2 (ld_thrd_byp_sel_g[2]),
5843
//  .sel3 (ld_thrd_byp_sel_g[3]),
5844
//  .dout (async_tlb_index[5:0])
5845
//   );
5846
 
5847
assign async_tlb_index[5:0] =
5848
  (ld_thrd_byp_sel_g[0] ? misc_data0[5:0] : 6'b0) |
5849
  (ld_thrd_byp_sel_g[1] ? misc_data1[5:0] : 6'b0) |
5850
  (ld_thrd_byp_sel_g[2] ? misc_data2[5:0] : 6'b0) |
5851
  (ld_thrd_byp_sel_g[3] ? misc_data3[5:0] : 6'b0) ;
5852
 
5853
wire    [1:0] err_tid_g ;
5854
//assign  err_tid_g[1:0] =
5855
//  sync_error_sel ? thrid_g[1:0] :
5856
//      async_error_sel ? async_err_tid_g[1:0] : dfill_tid_g[1:0] ;
5857
 
5858
mux3ds #(2) err_tid_mx (
5859
  .in0 (thrid_g[1:0]),
5860
  .in1 (async_err_tid_g[1:0]),
5861
  .in2 (dfill_tid_g[1:0]),
5862
  .sel0(lsu_err_addr_sel[0]),
5863
  .sel1(lsu_err_addr_sel[1]),
5864
  .sel2(lsu_err_addr_sel[2]),
5865
  .dout(err_tid_g[1:0])
5866
                   );
5867
 
5868
// Can shift to m.
5869
//assign  lsu_tlu_derr_tid_g[1:0] = err_tid_g[1:0] ;
5870
 
5871 113 albert.wat
dff_s #(2)  errad_stgg (
5872 95 fafa1971
        .din    (err_tid_g[1:0]),
5873
        .q      (lsu_ifu_error_tid[1:0]),
5874
        .clk    (clk),
5875 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5876 95 fafa1971
        );
5877
 
5878
assign  lsu_ifu_io_error = //l2_unc_error_w2 & lsu_ifu_err_addr_b39 ;
5879
// extend for bld to io space.
5880
(l2_unc_error_w2 | bld_unc_err_pend_w2) & lsu_ifu_err_addr_b39 & ~bld_squash_err_w2 ;
5881
 
5882
 
5883
//=========================================================================================
5884
 
5885
 
5886
wire stxa_internal_cmplt ;
5887
assign  stxa_internal_cmplt =
5888
stxa_internal &
5889
~(intrpt_disp_asi_g | stxa_stall_asi_g | (ifu_nontlb_asi_g & ~ifu_asi42_flush_g) | tlb_lng_ltncy_asi_g) &
5890
                                        lsu_inst_vld_w & ~dctl_early_flush_w ;
5891
                                        //lsu_inst_vld_w & ~dctl_flush_pipe_w ;
5892
 
5893
// Need to add stxa's related to ifu non-tlb asi.
5894 113 albert.wat
dff_s  stxa_int_d1 (
5895 95 fafa1971
        .din    (stxa_internal_cmplt),
5896
        //.din    (stxa_internal & ~(stxa_stall_asi_g | tlb_lng_ltncy_asi_g) & lsu_inst_vld_w),
5897
        .q      (stxa_internal_d1),
5898
        .clk    (clk),
5899 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5900 95 fafa1971
        );
5901
 
5902 113 albert.wat
dff_s  stxa_int_d2 (
5903 95 fafa1971
        .din    (stxa_internal_d1),
5904
        .q      (stxa_internal_d2),
5905
        .clk    (clk),
5906 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5907 95 fafa1971
        );
5908
 
5909
 
5910
//=========================================================================================
5911
//  Replacement Algorithm for Cache
5912
//=========================================================================================
5913
 
5914
 
5915
 
5916
// Increment Condition.
5917
wire    lfsr_incr, lfsr_incr_d1 ;
5918
assign  lfsr_incr =
5919
        ld_inst_vld_g & ~lsu_way_hit_or & ~ldxa_internal &
5920
        ~ncache_pcx_rq_g ; // must be cacheable
5921
 
5922 113 albert.wat
dff_s  lfsrd1_ff (
5923 95 fafa1971
        .din    (lfsr_incr),
5924
        .q      (lfsr_incr_d1),
5925
        .clk    (clk),
5926 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5927 95 fafa1971
        );
5928
 
5929
wire    lfsr_rst ;
5930
assign  lfsr_rst =
5931
                reset           |
5932
                ~gdbginit_l     | // debug init.
5933
                dc_direct_map   ; // direct map mode will reset.
5934
 
5935
// Bug 4027
5936
lsu_dcache_lfsr lfsr(.out (lsu_dcache_rand[1:0]),
5937
                                           .clk  (clk),
5938
                                           .advance (lfsr_incr_d1),
5939
                                           .reset (lfsr_rst),
5940
                                           .se (se),
5941 113 albert.wat
                                           `SIMPLY_RISC_SCANIN,
5942
                                           `SIMPLY_RISC_SCANOUT);
5943 95 fafa1971
 
5944
//assign  lsu_dcache_rand[1:0]  =  dcache_rand[1:0]; 
5945
 
5946
 
5947
/*assign  dcache_rand_new[1:0] = dcache_rand[1:0] + {1'b0, lsu_ld_miss_wb} ;
5948 113 albert.wat
dffre_s #(2) drand (
5949 95 fafa1971
        .din    (dcache_rand_new[1:0]),
5950
        .q      (dcache_rand[1:0]),
5951
        .rst  (reset), .en    (lsu_ld_miss_wb),
5952
        .clk    (clk),
5953 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5954 95 fafa1971
        );
5955
 
5956
assign  lsu_dcache_rand[1:0]  =  dcache_rand[1:0]; */
5957
 
5958
//=========================================================================================
5959
//  Packet Assembly
5960
//=========================================================================================
5961
 
5962
assign lsu_encd_way_hit[0] = cache_way_hit_buf1[1] | cache_way_hit_buf1[3] ;
5963
assign lsu_encd_way_hit[1] = cache_way_hit_buf1[2] | cache_way_hit_buf1[3] ;
5964
 
5965
//assign lsu_way_hit_or  =  |lsu_way_hit[3:0];
5966
assign lsu_way_hit_or  =  |cache_way_hit_buf1[3:0]; // Bug 3940
5967
 
5968
//assign  stb_byp_pkt_vld_e = st_inst_vld_e & ~(ldsta_internal_e & alt_space_e);
5969
assign  ld_pcx_pkt_vld_e = ld_inst_vld_e & ~(ldsta_internal_e & alt_space_e);
5970
 
5971
 
5972 113 albert.wat
dff_s #(5)  pktctl_stgm (
5973 95 fafa1971
        .din    ({ifu_lsu_ldst_dbl_e, ld_pcx_pkt_vld_e,
5974
    ifu_lsu_casa_e,ifu_lsu_ldstub_e,ifu_lsu_swap_e}),
5975
        .q      ({ldst_dbl_m, ld_pcx_pkt_vld_m,
5976
    casa_m,ldstub_m,swap_m}),
5977
        .clk    (clk),
5978 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5979 95 fafa1971
        );
5980
 
5981
assign  atomic_m = casa_m | ldstub_m | swap_m ;
5982
 
5983 113 albert.wat
dff_s #(6) pktctl_stgg (
5984 95 fafa1971
        .din    ({ldst_dbl_m, ld_pcx_pkt_vld_m,
5985
    casa_m,ldstub_m,swap_m,atomic_m}),
5986
        .q      ({ldst_dbl_g, ld_pcx_pkt_vld_g,
5987
    casa_g,ldstub_g,swap_g,atomic_g}),
5988
        .clk    (clk),
5989 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5990 95 fafa1971
        );
5991
 
5992 113 albert.wat
dff_s #(2) pktctl_stgw2 (
5993 95 fafa1971
        .din    ({ldd_force_l2access_g, atomic_g}),
5994
        .q      ({ldd_force_l2access_w2,atomic_w2}),
5995
        .clk    (clk),
5996 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
5997 95 fafa1971
        );
5998
 
5999 113 albert.wat
dff_s #(2) pktctl_stgw3 (
6000 95 fafa1971
        .din    ({ldd_force_l2access_w2, atomic_w2}),
6001
        .q      ({ldd_force_l2access_w3, atomic_w3}),
6002
        .clk    (clk),
6003 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6004 95 fafa1971
        );
6005
 
6006
assign  lsu_ldstub_g = ldstub_g ;
6007
assign  lsu_swap_g = swap_g ;
6008
 
6009
// Choose way for load. If load hits in dcache but sent out to xbar because
6010
// of partial raw then need to use hit way else use random. Similarly, dcache
6011
// parity error will force a miss and fill to same way.
6012
 
6013
// Moved to qctl1
6014
// For direct-map mode, assume that addition set-index bits 12:11 are
6015
// used to file line in set.
6016
//assign  ld_way[1:0] = 
6017
//    (|lsu_way_hit[3:0]) ? 
6018
//        {lsu_encd_way_hit[1],lsu_encd_way_hit[0]} : 
6019
//              lsu_ld_sec_hit_l2access_g ? lsu_ld_sec_hit_wy_g[1:0] :
6020
//                      (dc_direct_map ? ldst_va_g[12:11] : dcache_rand[1:0]) ;
6021
 
6022
// set to 011 for atomic - only cas encoding used for pcx pkt.
6023
assign  ld_rq_type[2:0] =
6024
    atomic_g ? 3'b011 :       // cas pkt 2/ldstub/swap 
6025
//        (ldst_dbl_g & st_inst_vld_g & quad_asi_g) ? 3'b001 : // stquad - label as store.
6026
    3'b000 ;      // normal load
6027
 
6028
 
6029
//assign  lmq_pkt_vld_g = ld_pcx_pkt_vld_g | (ldst_dbl_g & st_inst_vld_unflushed) | pref_inst_g ; 
6030
assign  lmq_pkt_vld_g = ld_pcx_pkt_vld_g | pref_inst_g ;
6031
 
6032
// Moved to qctl1
6033
// 2'b01 encodes ld as st-quad pkt2. 2'b00 needed for cas-pkt2
6034
//assign  lmq_pkt_way_g[1:0] = 
6035
//(ldst_dbl_g & st_inst_vld_unflushed & quad_asi_g) ? 2'b01 :
6036
//        casa_g ? 2'b00 : ld_way[1:0] ;
6037
 
6038
// ld is 128b request.
6039
wire    qword_access_g;
6040
assign  qword_access_g =
6041
(quad_asi_g | blk_asi_g ) & lsu_alt_space_g & ld_inst_vld_unflushed ;
6042
 
6043
assign  lsu_quad_word_access_g = qword_access_g ;
6044
 
6045
wire  fp_ld_inst_g ;
6046
assign  fp_ld_inst_g  = fp_ldst_g & ld_inst_vld_g ;
6047
 
6048
wire  ldst_sz_b0_g ;
6049
assign  ldst_sz_b0_g =
6050
  ldst_sz_g[0] &
6051
  ~(ldst_dbl_g & ~fp_ldst_g &
6052
    (~lsu_alt_space_g | (lsu_alt_space_g & ~quad_asi_g))) ;
6053
                // word for ld-dbl
6054
 
6055
wire    asi_real_iomem_m,asi_real_iomem_g ;
6056
assign  asi_real_iomem_m =
6057
(dtlb_bypass_m & (phy_use_ec_asi_m | phy_byp_ec_asi_m) & lsu_alt_space_m) ;
6058
 
6059 113 albert.wat
dff_s #(1) stgg_asir (
6060 95 fafa1971
        .din    (asi_real_iomem_m),
6061
        .q      (asi_real_iomem_g),
6062
        .clk    (clk),
6063 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6064 95 fafa1971
        );
6065
 
6066
assign  ncache_pcx_rq_g   =
6067
  atomic_g    |   // cas,ldstub,swap  
6068
  asi_real_iomem_g | // real_mem, real_io
6069
  ~dcache_enable_g | // dcache disabled : Bug 5174 (accidental removal)
6070
  ((tlb_pgnum[39] & ~lsu_dtlb_bypass_g & tlb_cam_hit_g) | // IO - tlb not in bypass
6071
   (tlb_pgnum[39] &  lsu_dtlb_bypass_g)) |    // IO - tlb bypass
6072
  (~lsu_tte_data_cp_g & tlb_cam_hit_g) |      // cp bit is clear
6073
  ((quad_asi_g | binit_quad_asi_g | blk_asi_g)  & lsu_alt_space_g & ldst_dbl_g & ld_inst_vld_unflushed) |  // quad-ld
6074
  pref_inst_g ; // pref will not alloc. in L2 dir
6075
 
6076
//wire  dflush_ld_g ;
6077
//assign  dflush_ld_g = dflush_asi_g & lsu_alt_space_g ;
6078
 
6079
// st-quad pkt1 and pkt2 need different addresses !!
6080
// ** should be able to reduce the width, rd2,stquad,lmq_pkt_way ** 
6081
//assign  ld_pcx_pkt_g[`LMQ_WIDTH-1:0] =
6082
 
6083
//bug3601
6084
//dbl_data_return will become lmq_ldd
6085
//it includes quad ld, int ldd, block ld, all these cases need return data twice.    
6086
   wire dbl_data_return;
6087
   assign dbl_data_return = ldst_dbl_g & ~ (fp_ldst_g & ~ (blk_asi_g & lsu_alt_space_g));
6088
 
6089 113 albert.wat
assign  ld_pcx_pkt_g[`LMQ_WIDTH-1:40] =
6090 95 fafa1971
  {lmq_pkt_vld_g,
6091
  1'b0,                  //dflush_ld_g, bug 4580 
6092
  pref_inst_g,
6093
  fp_ld_inst_g,
6094
  l1hit_sign_extend_g,
6095
  //lsu_bendian_access_g,
6096
  bendian_g,    // l2fill_bendian removed.
6097
  ld_rd_g[4:0], // use rd1 only for now.
6098
  dbl_data_return,  //bug 3601
6099
  //ldst_dbl_g & ~fp_ldst_g,  // rd2 used by ld double.
6100
  {ld_rd_g[4:1],~ld_rd_g[0]}, // rd2 to be used with atomics.
6101
  ld_rq_type[2:0],
6102
  ncache_pcx_rq_g,  // NC.
6103
  //lmq_pkt_way_g[1:0], // replacement way
6104
  2'b00,
6105
  ldst_sz_g[1],ldst_sz_b0_g};
6106
  //{tlb_pgnum[39:10], ldst_va_g[9:0]}};
6107
 
6108
//=========================================================================================
6109
//  Byte Masking for writes
6110
//=========================================================================================
6111
 
6112
// Byte-enables will be generated in cycle prior to fill (E-stage)
6113
// Reads and writes are mutex as array is single-ported.
6114
// byte-enables are handled thru read-modify-writes.
6115
 
6116
// Create 16b Write Mask based on size and va ;
6117
// This is to be put in the DFQ once the DFQ is on-line.
6118
 
6119
 
6120
wire [2:0] dc_waddr_m ;
6121 113 albert.wat
dff_s #(4) stgm_addr (
6122 95 fafa1971
        .din    ({memref_e, dcache_wr_addr_e[2:0]}),
6123
        .q      ({memref_m, dc_waddr_m[2:0]}),
6124
        .clk    (clk),
6125 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6126 95 fafa1971
        );
6127
 
6128
assign  lsu_memref_m = memref_m ;
6129
 
6130
//wire [3:0] rwaddr_enc ;
6131
//assign  rwaddr_enc[3:0] = memref_m ? 
6132
//        lsu_ldst_va_b7_b0_m[3:0] : dc_waddr_m[3:0];
6133
 
6134
wire [2:0] rwaddr_enc ;
6135
assign  rwaddr_enc[2:0] = memref_m ?
6136
        lsu_ldst_va_b7_b0_m[2:0] : dc_waddr_m[2:0];
6137
 
6138
 
6139
   wire [1:0] wr_size;
6140
 
6141
   assign wr_size[1:0] = dcache_wr_size_e[1:0];
6142
 
6143
   wire   wr_hword, wr_word, wr_dword;
6144
 
6145
//assign  wr_byte    = ~wr_size[1] & ~wr_size[0] ; // 01
6146
assign  wr_hword   = ~wr_size[1] &  wr_size[0] ; // 01
6147
assign  wr_word    =  wr_size[1] & ~wr_size[0] ; // 10
6148
assign  wr_dword   =  wr_size[1] &  wr_size[0] ; // 11
6149
 
6150
assign  ldst_byte    = ~ldst_sz_e[1] & ~ldst_sz_e[0] ; // 01
6151
assign  ldst_hword   = ~ldst_sz_e[1] &  ldst_sz_e[0] ; // 01
6152
assign  ldst_word    =  ldst_sz_e[1] & ~ldst_sz_e[0] ; // 10
6153
assign  ldst_dword   =  ldst_sz_e[1] &  ldst_sz_e[0] ; // 11
6154
 
6155
// In Bypass mode, endianness is determined by asi.
6156
// Need to complete this equation.
6157
 
6158
// Note : add MMU disable bypass conditions !!!
6159
assign  tlb_invert_endian_g = lsu_tlb_invert_endian_g & ~lsu_dtlb_bypass_g & tlb_cam_hit_g ;
6160
 
6161
// Is qualification with reset needed ?
6162
//assign  l2fill_bendian_g = lsu_l2fill_bendian_g & ~reset;
6163
 
6164
//assign  pstate_cle_m = 
6165
//  thread0_m ? tlu_lsu_pstate_cle[0] :
6166
//    thread1_m ? tlu_lsu_pstate_cle[1] :
6167
//      thread2_m ? tlu_lsu_pstate_cle[2] :
6168
//          tlu_lsu_pstate_cle[3] ;
6169
 
6170
mux4ds  #(1) pstate_cle_e_mux (
6171
        .in0    (tlu_lsu_pstate_cle[0]),
6172
        .in1    (tlu_lsu_pstate_cle[1]),
6173
        .in2    (tlu_lsu_pstate_cle[2]),
6174
        .in3    (tlu_lsu_pstate_cle[3]),
6175
        .sel0   (thread0_e),
6176
        .sel1   (thread1_e),
6177
        .sel2   (thread2_e),
6178
        .sel3   (thread3_e),
6179
        .dout   (pstate_cle_e)
6180
);
6181
 
6182 113 albert.wat
dff_s #(1) stgm_pstatecle (
6183 95 fafa1971
        .din    (pstate_cle_e),
6184
        .q      (pstate_cle_m),
6185
        .clk    (clk),
6186 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6187 95 fafa1971
        );
6188
 
6189 113 albert.wat
dff_s #(1) stgg_pstatecle (
6190 95 fafa1971
        .din    (pstate_cle_m),
6191
        .q      (pstate_cle_g),
6192
        .clk    (clk),
6193 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6194 95 fafa1971
        );
6195
 
6196
//SPARC V9 page 52. pstate.cle should only affect implicit ASI   
6197
assign  l1hit_lendian_g =
6198
    ((non_altspace_ldst_g & (pstate_cle_g ^ tlb_invert_endian_g)) |       // non altspace ldst
6199
     (altspace_ldst_g     & (lendian_asi_g ^ tlb_invert_endian_g)))       // altspace ldst
6200
    & ~(asi_internal_g & lsu_alt_space_g);                                // internal asi is big-endian
6201
 
6202
wire    l1hit_lendian_predict_m ;
6203
// Predict endian-ness in m-stage. Assume tte.IE=0
6204
assign  l1hit_lendian_predict_m =
6205
    ((non_altspace_ldst_m & pstate_cle_m) |        // non altspace ldst
6206
     (altspace_ldst_m     & lendian_asi_m))        // altspace ldst
6207
    & ~asi_internal_m ;                            // internal asi is big-endian
6208
 
6209
// Further, decode of ASI is not factored into endian calculation. 
6210
//assign  lsu_bendian_access_g = (ld_inst_vld_unflushed | st_inst_vld_unflushed) ?
6211
//    ~l1hit_lendian_g : l2fill_bendian_g ;
6212
 
6213
// m stage endian signal is predicted for in-pipe lds only.
6214
wire    bendian_pred_m, bendian_pred_g ;
6215
assign  bendian_pred_m = (ld_inst_vld_m | st_inst_vld_m) ?
6216
    ~l1hit_lendian_predict_m : lsu_l2fill_bendian_m ;
6217
 
6218 113 albert.wat
dff_s #(1) stgg_bendpr(
6219 95 fafa1971
        .din    (bendian_pred_m),
6220
        .q      (bendian_pred_g),
6221
        .clk    (clk),
6222 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6223 95 fafa1971
        );
6224
 
6225
// mispredict applies to only in-pipe lds.
6226
assign  endian_mispred_g =  bendian_pred_g ^ ~l1hit_lendian_g ;
6227
 
6228
// Staging for alignment on read from l1 or fill to l2.
6229 113 albert.wat
dff_s #(4) stgm_sz (
6230 95 fafa1971
        .din    ({ldst_byte,  ldst_hword,  ldst_word,  ldst_dword}),
6231
        .q      ({byte_m,hword_m,word_m,dword_m}),
6232
        .clk    (clk),
6233 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6234 95 fafa1971
        );
6235
 
6236
wire    [7:0]    rwaddr_dcd_part ;
6237
 
6238
assign  rwaddr_dcd_part[0]  = ~rwaddr_enc[2] & ~rwaddr_enc[1] & ~rwaddr_enc[0] ;
6239
assign  rwaddr_dcd_part[1]  = ~rwaddr_enc[2] & ~rwaddr_enc[1] &  rwaddr_enc[0] ;
6240
assign  rwaddr_dcd_part[2]  = ~rwaddr_enc[2] &  rwaddr_enc[1] & ~rwaddr_enc[0] ;
6241
assign  rwaddr_dcd_part[3]  = ~rwaddr_enc[2] &  rwaddr_enc[1] &  rwaddr_enc[0] ;
6242
assign  rwaddr_dcd_part[4]  =  rwaddr_enc[2] & ~rwaddr_enc[1] & ~rwaddr_enc[0] ;
6243
assign  rwaddr_dcd_part[5]  =  rwaddr_enc[2] & ~rwaddr_enc[1] &  rwaddr_enc[0] ;
6244
assign  rwaddr_dcd_part[6]  =  rwaddr_enc[2] &  rwaddr_enc[1] & ~rwaddr_enc[0] ;
6245
assign  rwaddr_dcd_part[7]  =  rwaddr_enc[2] &  rwaddr_enc[1] &  rwaddr_enc[0] ;
6246
 
6247
   assign baddr_m[7:0] = rwaddr_dcd_part[7:0];
6248
/*
6249
assign baddr_m[0]  = ~rwaddr_enc[3] & rwaddr_dcd_part[0] ;
6250
assign baddr_m[1]  = ~rwaddr_enc[3] & rwaddr_dcd_part[1] ;
6251
assign baddr_m[2]  = ~rwaddr_enc[3] & rwaddr_dcd_part[2] ;
6252
assign baddr_m[3]  = ~rwaddr_enc[3] & rwaddr_dcd_part[3] ;
6253
assign baddr_m[4]  = ~rwaddr_enc[3] & rwaddr_dcd_part[4] ;
6254
assign baddr_m[5]  = ~rwaddr_enc[3] & rwaddr_dcd_part[5] ;
6255
assign baddr_m[6]  = ~rwaddr_enc[3] & rwaddr_dcd_part[6] ;
6256
assign baddr_m[7]  = ~rwaddr_enc[3] & rwaddr_dcd_part[7] ;
6257
assign baddr_m[8]  =  rwaddr_enc[3] & rwaddr_dcd_part[0] ;
6258
assign baddr_m[9]  =  rwaddr_enc[3] & rwaddr_dcd_part[1] ;
6259
assign baddr_m[10] =  rwaddr_enc[3] & rwaddr_dcd_part[2] ;
6260
assign baddr_m[11] =  rwaddr_enc[3] & rwaddr_dcd_part[3] ;
6261
assign baddr_m[12] =  rwaddr_enc[3] & rwaddr_dcd_part[4] ;
6262
assign baddr_m[13] =  rwaddr_enc[3] & rwaddr_dcd_part[5] ;
6263
assign baddr_m[14] =  rwaddr_enc[3] & rwaddr_dcd_part[6] ;
6264
assign baddr_m[15] =  rwaddr_enc[3] & rwaddr_dcd_part[7] ;
6265
*/
6266
// Byte Address to start write from. Quantity can be byte/hword/word/dword.
6267
// E-stage decoding for write to cache.
6268
 
6269
wire    [3:0]    waddr_enc ;
6270
wire    [7:0]    waddr_dcd_part ;
6271
wire    [15:0]   waddr_dcd ;
6272
 
6273
assign  waddr_dcd_part[0]  = ~waddr_enc[2] & ~waddr_enc[1] & ~waddr_enc[0] ;
6274
assign  waddr_dcd_part[1]  = ~waddr_enc[2] & ~waddr_enc[1] &  waddr_enc[0] ;
6275
assign  waddr_dcd_part[2]  = ~waddr_enc[2] &  waddr_enc[1] & ~waddr_enc[0] ;
6276
assign  waddr_dcd_part[3]  = ~waddr_enc[2] &  waddr_enc[1] &  waddr_enc[0] ;
6277
assign  waddr_dcd_part[4]  =  waddr_enc[2] & ~waddr_enc[1] & ~waddr_enc[0] ;
6278
assign  waddr_dcd_part[5]  =  waddr_enc[2] & ~waddr_enc[1] &  waddr_enc[0] ;
6279
assign  waddr_dcd_part[6]  =  waddr_enc[2] &  waddr_enc[1] & ~waddr_enc[0] ;
6280
assign  waddr_dcd_part[7]  =  waddr_enc[2] &  waddr_enc[1] &  waddr_enc[0] ;
6281
 
6282
assign  waddr_dcd[0]  = ~waddr_enc[3] & waddr_dcd_part[0] ;
6283
assign  waddr_dcd[1]  = ~waddr_enc[3] & waddr_dcd_part[1] ;
6284
assign  waddr_dcd[2]  = ~waddr_enc[3] & waddr_dcd_part[2] ;
6285
assign  waddr_dcd[3]  = ~waddr_enc[3] & waddr_dcd_part[3] ;
6286
assign  waddr_dcd[4]  = ~waddr_enc[3] & waddr_dcd_part[4] ;
6287
assign  waddr_dcd[5]  = ~waddr_enc[3] & waddr_dcd_part[5] ;
6288
assign  waddr_dcd[6]  = ~waddr_enc[3] & waddr_dcd_part[6] ;
6289
assign  waddr_dcd[7]  = ~waddr_enc[3] & waddr_dcd_part[7] ;
6290
assign  waddr_dcd[8]  =  waddr_enc[3] & waddr_dcd_part[0] ;
6291
assign  waddr_dcd[9]  =  waddr_enc[3] & waddr_dcd_part[1] ;
6292
assign  waddr_dcd[10] =  waddr_enc[3] & waddr_dcd_part[2] ;
6293
assign  waddr_dcd[11] =  waddr_enc[3] & waddr_dcd_part[3] ;
6294
assign  waddr_dcd[12] =  waddr_enc[3] & waddr_dcd_part[4] ;
6295
assign  waddr_dcd[13] =  waddr_enc[3] & waddr_dcd_part[5] ;
6296
assign  waddr_dcd[14] =  waddr_enc[3] & waddr_dcd_part[6] ;
6297
assign  waddr_dcd[15] =  waddr_enc[3] & waddr_dcd_part[7] ;
6298
 
6299
// Byte enables for 16 bytes.
6300
   //bug6216/eco6624
6301
   wire write_16byte_e;
6302
   assign write_16byte_e = l2fill_vld_e | lsu_bist_wvld_e;
6303
 
6304
assign byte_wr_enable[15] =
6305
    write_16byte_e  |   waddr_dcd[0] ;
6306
assign byte_wr_enable[14] =
6307
    write_16byte_e  |   waddr_dcd[1]    |
6308
    (wr_hword & waddr_dcd[0])  |   (wr_word & waddr_dcd[0]) |
6309
    (wr_dword & waddr_dcd[0])  ;
6310
assign byte_wr_enable[13] =
6311
    write_16byte_e  |   waddr_dcd[2]    |
6312
    (wr_word & waddr_dcd[0]) |     (wr_dword & waddr_dcd[0])  ;
6313
assign byte_wr_enable[12] =
6314
    write_16byte_e  |   waddr_dcd[3]    |
6315
    (wr_hword & waddr_dcd[2])  |   (wr_word & waddr_dcd[0]) |
6316
    (wr_dword & waddr_dcd[0])  ;
6317
assign byte_wr_enable[11] =
6318
    write_16byte_e  |   waddr_dcd[4]    |
6319
    (wr_dword & waddr_dcd[0])  ;
6320
assign byte_wr_enable[10] =
6321
    write_16byte_e  |   waddr_dcd[5]    |
6322
    (wr_hword & waddr_dcd[4])  |   (wr_word & waddr_dcd[4]) |
6323
    (wr_dword & waddr_dcd[0])  ;
6324
assign byte_wr_enable[9] =
6325
    write_16byte_e  |   waddr_dcd[6]    |
6326
    (wr_word & waddr_dcd[4]) |     (wr_dword & waddr_dcd[0])  ;
6327
assign byte_wr_enable[8] =
6328
    write_16byte_e  |   waddr_dcd[7]    |
6329
    (wr_hword & waddr_dcd[6])  |   (wr_word & waddr_dcd[4]) |
6330
    (wr_dword & waddr_dcd[0])  ;
6331
assign byte_wr_enable[7] =
6332
    write_16byte_e  |   waddr_dcd[8] ;
6333
assign byte_wr_enable[6] =
6334
    write_16byte_e  |   waddr_dcd[9]    |
6335
    (wr_hword & waddr_dcd[8])  |   (wr_word & waddr_dcd[8]) |
6336
    (wr_dword & waddr_dcd[8])  ;
6337
assign byte_wr_enable[5] =
6338
    write_16byte_e  |   waddr_dcd[10]   |
6339
    (wr_word & waddr_dcd[8]) |     (wr_dword & waddr_dcd[8])  ;
6340
assign byte_wr_enable[4] =
6341
    write_16byte_e  |   waddr_dcd[11]   |
6342
    (wr_hword & waddr_dcd[10]) |   (wr_word & waddr_dcd[8]) |
6343
    (wr_dword & waddr_dcd[8])  ;
6344
assign byte_wr_enable[3] =
6345
    write_16byte_e  |   waddr_dcd[12]   |
6346
    (wr_dword & waddr_dcd[8])  ;
6347
assign byte_wr_enable[2] =
6348
    write_16byte_e  |   waddr_dcd[13]   |
6349
    (wr_hword & waddr_dcd[12]) |   (wr_word & waddr_dcd[12])  |
6350
    (wr_dword & waddr_dcd[8])  ;
6351
assign byte_wr_enable[1] =
6352
    write_16byte_e  |   waddr_dcd[14]   |
6353
    (wr_word & waddr_dcd[12])  |   (wr_dword & waddr_dcd[8])  ;
6354
assign byte_wr_enable[0] =
6355
    write_16byte_e  |   waddr_dcd[15]   |
6356
    (wr_hword & waddr_dcd[14]) |   (wr_word & waddr_dcd[12])  |
6357
    (wr_dword & waddr_dcd[8])  ;
6358
 
6359
assign  dcache_byte_wr_en_e[15:0] = byte_wr_enable[15:0] ;
6360
//assign  lsu_st_byte_addr_g[15:0]  = byp_baddr_g[15:0] ;
6361
 
6362
//=========================================================================================
6363
//  Sign/Zero-Extension
6364
//=========================================================================================
6365
 
6366 113 albert.wat
dff_s #(1) stgm_msb (
6367 95 fafa1971
       .din    ({lsu_l1hit_sign_extend_e}),
6368
       .q      ({l1hit_sign_extend_m}),
6369
       .clk    (clk),
6370 113 albert.wat
       .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6371 95 fafa1971
       );
6372
 
6373 113 albert.wat
dff_s #(1) stgg_msb (
6374 95 fafa1971
       .din    ({l1hit_sign_extend_m}),
6375
       .q      ({l1hit_sign_extend_g}),
6376
       .clk    (clk),
6377 113 albert.wat
       .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6378 95 fafa1971
       );
6379
 
6380
 
6381
//wire [1:0] lsu_byp_misc_sz_g ;   
6382
 
6383
/*dff #(2) ff_lsu_byp_misc_sz_g (
6384
        .din   (lsu_byp_misc_sz_m[1:0]),
6385
        .q     (lsu_byp_misc_sz_g[1:0]),
6386
        .clk    (clk),
6387 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6388 95 fafa1971
        );  */
6389
 
6390
assign  misc_byte_m   = ~lsu_byp_misc_sz_m[1] & ~lsu_byp_misc_sz_m[0] ; // 00
6391
assign  misc_hword_m  = ~lsu_byp_misc_sz_m[1] &  lsu_byp_misc_sz_m[0] ; // 01
6392
assign  misc_word_m   =  lsu_byp_misc_sz_m[1] & ~lsu_byp_misc_sz_m[0] ; // 10
6393
assign  misc_dword_m  =  lsu_byp_misc_sz_m[1] &  lsu_byp_misc_sz_m[0] ; // 11
6394
 
6395
wire    byp_byte_m,byp_hword_m,byp_word_m,byp_dword_m;
6396
assign  byp_byte_m =  (ld_inst_vld_m) ?  byte_m :  misc_byte_m ;
6397
assign  byp_hword_m = (ld_inst_vld_m) ? hword_m :  misc_hword_m ;
6398
assign  byp_word_m =  (ld_inst_vld_m) ?  word_m :  misc_word_m ;
6399
assign  byp_dword_m = (ld_inst_vld_m) ? dword_m :  misc_dword_m ;
6400
 
6401
/*assign  byp_byte_g =  (|lsu_irf_byp_data_src[2:1]) ? misc_byte_g : byte_g ;
6402
assign  byp_hword_g = (|lsu_irf_byp_data_src[2:1]) ? misc_hword_g : hword_g ;
6403
assign  byp_word_g =  (|lsu_irf_byp_data_src[2:1]) ? misc_word_g : word_g ;*/
6404
 
6405 113 albert.wat
dff_s #(1) bypsz_stgg(
6406 95 fafa1971
        .din   ({byp_word_m}),
6407
        .q     ({byp_word_g}),
6408
        .clk    (clk),
6409 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6410 95 fafa1971
        );
6411
 
6412
//wire [3:0]    misc_waddr_m ; 
6413
//assign  misc_waddr_m[3:0] = {lsu_byp_misc_addr_m[3],lsu_byp_misc_addr_m[2]^lsu_byp_ldd_oddrd_m,lsu_byp_misc_addr_m[1:0]} ;
6414
 
6415
wire [2:0]       misc_waddr_m ;
6416
assign  misc_waddr_m[2:0] = {lsu_byp_misc_addr_m[2]^lsu_byp_ldd_oddrd_m,lsu_byp_misc_addr_m[1:0]} ;
6417
 
6418
//wire    [15:0] misc_baddr_m ;
6419
wire    [7:0] misc_baddr_m ;
6420
 
6421
// m-stage decoding
6422
// Might be better to stage encoded waddr, mux and then decode.
6423
/*
6424
assign  misc_baddr_m[0] = ~misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6425
assign  misc_baddr_m[1] = ~misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6426
assign  misc_baddr_m[2] = ~misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6427
assign  misc_baddr_m[3] = ~misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6428
assign  misc_baddr_m[4] = ~misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6429
assign  misc_baddr_m[5] = ~misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6430
assign  misc_baddr_m[6] = ~misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6431
assign  misc_baddr_m[7] = ~misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6432
assign  misc_baddr_m[8] =  misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6433
assign  misc_baddr_m[9] =  misc_waddr_m[3] & ~misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6434
assign  misc_baddr_m[10] =  misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6435
assign  misc_baddr_m[11] =  misc_waddr_m[3] & ~misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6436
assign  misc_baddr_m[12] =  misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6437
assign  misc_baddr_m[13] =  misc_waddr_m[3] &  misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6438
assign  misc_baddr_m[14] =  misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6439
assign  misc_baddr_m[15] =  misc_waddr_m[3] &  misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6440
*/
6441
assign  misc_baddr_m[0] = ~misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6442
assign  misc_baddr_m[1] = ~misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6443
assign  misc_baddr_m[2] = ~misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6444
assign  misc_baddr_m[3] = ~misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6445
assign  misc_baddr_m[4] =  misc_waddr_m[2] & ~misc_waddr_m[1] & ~misc_waddr_m[0] ;
6446
assign  misc_baddr_m[5] =  misc_waddr_m[2] & ~misc_waddr_m[1] &  misc_waddr_m[0] ;
6447
assign  misc_baddr_m[6] =  misc_waddr_m[2] &  misc_waddr_m[1] & ~misc_waddr_m[0] ;
6448
assign  misc_baddr_m[7] =  misc_waddr_m[2] &  misc_waddr_m[1] &  misc_waddr_m[0] ;
6449
 
6450
//wire [15:0] byp_baddr_m ;
6451
//assign  byp_baddr_m[15:0] = (~(ld_inst_vld_m | st_inst_vld_m)) ? misc_baddr_m[15:0] : baddr_m[15:0] ;
6452
wire [7:0] byp_baddr_m ;
6453
assign  byp_baddr_m[7:0] = (~(ld_inst_vld_m | st_inst_vld_m)) ? misc_baddr_m[7:0] : baddr_m[7:0] ;
6454
 
6455
   wire l2fill_sign_extend_m;
6456
 
6457
assign  l2fill_sign_extend_m = lsu_l2fill_sign_extend_m ;
6458
//?? why need st ??
6459
assign  signed_ldst_m = (ld_inst_vld_m | st_inst_vld_m) ?
6460
                         l1hit_sign_extend_m : l2fill_sign_extend_m ;
6461
 
6462
//assign  unsigned_ldst_m = ~signed_ldst_m ;
6463
 
6464
   assign signed_ldst_byte_m = signed_ldst_m & byp_byte_m;
6465
//   assign unsigned_ldst_byte_m = unsigned_ldst_m & byp_byte_m;
6466
 
6467
   assign signed_ldst_hw_m = signed_ldst_m & ( byp_byte_m | byp_hword_m );
6468
//   assign unsigned_ldst_hw_m = unsigned_ldst_m & ( byp_byte_m | byp_hword_m );
6469
 
6470
   assign signed_ldst_w_m = signed_ldst_m & ( byp_byte_m | byp_hword_m | byp_word_m );
6471
//   assign unsigned_ldst_w_m = unsigned_ldst_m & ( byp_byte_m | byp_hword_m | byp_word_m );
6472
 
6473
//C assign  align_bytes_msb[7:0] = (ld_inst_vld_unflushed | st_inst_vld_unflushed) ? lsu_l1hit_bytes_msb_g[7:0] :
6474
//C     (l2fill_vld_g ? l2fill_bytes_msb_g[7:0] : lsu_misc_bytes_msb_g[7:0])  ;
6475
 
6476
//assign  align_bytes_msb[7:0] = (ld_inst_vld_unflushed | st_inst_vld_unflushed) ? lsu_l1hit_bytes_msb_g[7:0] :
6477
//    (lsu_irf_byp_data_src[2] ? lsu_misc_bytes_msb_g[7:0] : l2fill_bytes_msb_g[7:0])  ;
6478
 
6479
 
6480
// For little-endian accesses, the following morphing must occur to the byte addr.
6481
//
6482
// Byte Addr(lower 3b)  
6483
//  000(0)  ->  001(1) (hw)
6484
//    ->  011(3) (w)
6485
//    ->  111(7) (dw)
6486
//  001(1)  ->  not morphed
6487
//  010(2)  ->  011(3) (hw)
6488
//  011(3)  ->  not morphed
6489
//  100(4)  ->  101(5) (hw)
6490
//    ->  111(7) (w)
6491
//  101(5)  ->  not morphed
6492
//  110(6)  ->  111(7) (hw)
6493
//  111(7)  ->  not morphed
6494
 
6495
wire  [7:0] merged_addr_m ;
6496
wire  [7:0] morphed_addr_m ;
6497
 
6498
//wire  bendian ;
6499
 
6500
//assign  merged_addr_m[7:0] = byp_baddr_m[15:8] | byp_baddr_m[7:0] ;
6501
assign  merged_addr_m[7:0] = byp_baddr_m[7:0] ;
6502
 
6503
assign  morphed_addr_m[0]
6504
  =  merged_addr_m[0] & ~(~bendian_pred_m & ~byp_byte_m) ;
6505
assign  morphed_addr_m[1]
6506
  =  merged_addr_m[1] | (merged_addr_m[0] & ~bendian_pred_m & byp_hword_m) ;
6507
assign  morphed_addr_m[2]
6508
  =  merged_addr_m[2] & ~(~bendian_pred_m & byp_hword_m) ;
6509
assign  morphed_addr_m[3]
6510
  =  merged_addr_m[3] | (merged_addr_m[0] & ~bendian_pred_m & byp_word_m) |
6511
  (merged_addr_m[2] & ~bendian_pred_m & byp_hword_m) ;
6512
assign  morphed_addr_m[4]
6513
  =  merged_addr_m[4] & ~(~bendian_pred_m & (byp_hword_m | byp_word_m)) ;
6514
assign  morphed_addr_m[5]
6515
  =  merged_addr_m[5] | (merged_addr_m[4] & ~bendian_pred_m & byp_hword_m) ;
6516
assign  morphed_addr_m[6]
6517
  =  merged_addr_m[6] & ~(~bendian_pred_m & byp_hword_m) ;
6518
assign  morphed_addr_m[7]
6519
  =  merged_addr_m[7] | (merged_addr_m[0] & ~bendian_pred_m & ~(byp_byte_m | byp_hword_m | byp_word_m))  |
6520
  (merged_addr_m[4] & ~bendian_pred_m & byp_word_m) | (merged_addr_m[6] & ~bendian_pred_m & byp_hword_m) ;
6521
 
6522
 
6523
 
6524
 
6525
//=========================================================================================
6526
//  ALIGNMENT CONTROL FOR DCDP 
6527
//=========================================================================================
6528
 
6529
// First generate control for swapping related to endianness.
6530
// byte7-byte0 is source data from cache etc.
6531
// swap7-swap0 is result of endianness swapping.
6532
 
6533
// First logical level - Swapping of bytes. 
6534
// Swap byte 0 
6535
 
6536
wire  swap0_sel_byte0, swap0_sel_byte1, swap0_sel_byte3  ;
6537
wire  swap1_sel_byte0, swap1_sel_byte1, swap1_sel_byte2, swap1_sel_byte6 ;
6538
wire  swap2_sel_byte1, swap2_sel_byte2, swap2_sel_byte3, swap2_sel_byte5 ;
6539
wire  swap3_sel_byte0, swap3_sel_byte2, swap3_sel_byte3, swap3_sel_byte4 ;
6540
wire  swap4_sel_byte3, swap4_sel_byte4, swap4_sel_byte5 ;
6541
wire  swap5_sel_byte2, swap5_sel_byte4, swap5_sel_byte5, swap5_sel_byte6 ;
6542
wire  swap6_sel_byte1, swap6_sel_byte5, swap6_sel_byte6 ;
6543
wire  swap7_sel_byte0, swap7_sel_byte4, swap7_sel_byte6, swap7_sel_byte7 ;
6544
 
6545
//assign  bendian = bendian_pred_m ;
6546
//assign  bendian = lsu_bendian_access_g ;
6547
 
6548
assign  swap0_sel_byte0   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6549
assign  swap0_sel_byte1   = ~bendian_pred_m & byp_hword_m ;
6550
assign  swap0_sel_byte3   = ~bendian_pred_m & byp_word_m ;
6551
// could be substituted with dword encoding.
6552
//assign  swap0_sel_byte7   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6553
 
6554
// Swap byp_byte_m 1 
6555
assign  swap1_sel_byte0   = ~bendian_pred_m & byp_hword_m ;
6556
assign  swap1_sel_byte1   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6557
assign  swap1_sel_byte2   = ~bendian_pred_m & byp_word_m ;
6558
assign  swap1_sel_byte6   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6559
 
6560
// Swap byp_byte_m 2 
6561
assign  swap2_sel_byte1   = ~bendian_pred_m & byp_word_m ;
6562
assign  swap2_sel_byte2   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6563
assign  swap2_sel_byte3   = ~bendian_pred_m & byp_hword_m ;
6564
assign  swap2_sel_byte5   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6565
 
6566
// Swap byp_byte_m 3 
6567
assign  swap3_sel_byte0   = ~bendian_pred_m & byp_word_m ;
6568
assign  swap3_sel_byte2   = ~bendian_pred_m & byp_hword_m ;
6569
assign  swap3_sel_byte3   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6570
assign  swap3_sel_byte4   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6571
 
6572
// Swap byp_byte_m 4 
6573
assign  swap4_sel_byte3   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6574
assign  swap4_sel_byte4   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6575
assign  swap4_sel_byte5   = ~bendian_pred_m & byp_hword_m ;
6576
//assign  swap4_sel_byte7   = ~bendian_pred_m & byp_word_m ;
6577
 
6578
// Swap byp_byte_m 5 
6579
assign  swap5_sel_byte2   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6580
assign  swap5_sel_byte4   = ~bendian_pred_m & byp_hword_m ;
6581
assign  swap5_sel_byte5   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6582
assign  swap5_sel_byte6   = ~bendian_pred_m & byp_word_m ;
6583
 
6584
// Swap byp_byte_m 6 
6585
assign  swap6_sel_byte1   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6586
assign  swap6_sel_byte5   = ~bendian_pred_m & byp_word_m ;
6587
assign  swap6_sel_byte6   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6588
//assign  swap6_sel_byte7   = ~bendian_pred_m & byp_hword_m ;
6589
 
6590
// Swap byp_byte_m 7 
6591
assign  swap7_sel_byte0   = ~bendian_pred_m & ~(byp_word_m | byp_hword_m | byp_byte_m) ;
6592
assign  swap7_sel_byte4   = ~bendian_pred_m & byp_word_m ;
6593
assign  swap7_sel_byte6   = ~bendian_pred_m & byp_hword_m ;
6594
assign  swap7_sel_byte7   = bendian_pred_m | (~bendian_pred_m & byp_byte_m) ;
6595
 
6596
// 2nd logical level - Alignment. 
6597
// rjust7-rjust0 is result of alignment operation.
6598
// sbyte7-sbyte0 is the result of the endian swapping from the 1st logic level.
6599
 
6600
wire  rjust0_sel_sbyte0, rjust0_sel_sbyte1, rjust0_sel_sbyte2, rjust0_sel_sbyte3 ;
6601
wire  rjust0_sel_sbyte4, rjust0_sel_sbyte5, rjust0_sel_sbyte6, rjust0_sel_sbyte7 ;
6602
wire  rjust1_sel_sbyte1, rjust1_sel_sbyte3, rjust1_sel_sbyte5, rjust1_sel_sbyte7 ;
6603
wire  rjust2_sel_sbyte2, rjust2_sel_sbyte6 ;
6604
wire  rjust3_sel_sbyte3, rjust3_sel_sbyte7 ;
6605
 
6606
// Aligned Byte 0
6607
assign  rjust0_sel_sbyte0   =
6608
  ~(rjust0_sel_sbyte1 | rjust0_sel_sbyte2 | rjust0_sel_sbyte3 |
6609
    rjust0_sel_sbyte4 | rjust0_sel_sbyte5 | rjust0_sel_sbyte6 |
6610
    rjust0_sel_sbyte7) ;
6611
assign  rjust0_sel_sbyte1   =
6612
//  ((byp_baddr_m[14] | byp_baddr_m[6]) & byp_byte_m) ;
6613
  ((byp_baddr_m[6]) & byp_byte_m) ;
6614
 
6615
assign  rjust0_sel_sbyte2   =
6616
//  ((byp_baddr_m[12] | byp_baddr_m[4]) & byp_hword_m) | 
6617
  ((byp_baddr_m[4]) & byp_hword_m) |
6618
//  ((byp_baddr_m[13] | byp_baddr_m[5]) & byp_byte_m) ;
6619
  ((byp_baddr_m[5]) & byp_byte_m) ;
6620
assign  rjust0_sel_sbyte3 =
6621
//  (byp_baddr_m[12] | byp_baddr_m[4]) & byp_byte_m ; 
6622
  (byp_baddr_m[4]) & byp_byte_m ;
6623
assign  rjust0_sel_sbyte4 =
6624
//  ((byp_baddr_m[10] | byp_baddr_m[2]) & byp_hword_m) | 
6625
//  ((byp_baddr_m[11] | byp_baddr_m[3]) & byp_byte_m) |
6626
//  ((byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m) ;
6627
  ((byp_baddr_m[2]) & byp_hword_m) |
6628
  ((byp_baddr_m[3]) & byp_byte_m) |
6629
  ((byp_baddr_m[0]) & byp_word_m) ;
6630
assign  rjust0_sel_sbyte5 =
6631
//  ((byp_baddr_m[10] | byp_baddr_m[2]) & byp_byte_m) ; 
6632
  ((byp_baddr_m[2]) & byp_byte_m) ;
6633
assign  rjust0_sel_sbyte6 =
6634
//  ((byp_baddr_m[8] | byp_baddr_m[0]) & byp_hword_m) | 
6635
//  ((byp_baddr_m[9] | byp_baddr_m[1]) & byp_byte_m) ;
6636
  ((byp_baddr_m[0]) & byp_hword_m) |
6637
  ((byp_baddr_m[1]) & byp_byte_m) ;
6638
assign  rjust0_sel_sbyte7 =
6639
//  (byp_baddr_m[8] | byp_baddr_m[0]) & byp_byte_m ;
6640
  (byp_baddr_m[0]) & byp_byte_m ;
6641
 
6642
// Aligned Byte 1
6643
assign  rjust1_sel_sbyte1   =
6644
  ~(rjust1_sel_sbyte3 | rjust1_sel_sbyte5 | rjust1_sel_sbyte7) ;
6645
assign  rjust1_sel_sbyte3   =
6646
//  (byp_baddr_m[12] | byp_baddr_m[4]) & byp_hword_m ;
6647
  (byp_baddr_m[4]) & byp_hword_m ;
6648
assign  rjust1_sel_sbyte5   =
6649
//  ((byp_baddr_m[10] | byp_baddr_m[2]) & byp_hword_m) | 
6650
//  ((byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m) ;
6651
  ((byp_baddr_m[2]) & byp_hword_m) |
6652
  ((byp_baddr_m[0]) & byp_word_m) ;
6653
assign  rjust1_sel_sbyte7   =
6654
//  (byp_baddr_m[8] | byp_baddr_m[0]) & byp_hword_m ;
6655
  (byp_baddr_m[0]) & byp_hword_m ;
6656
 
6657
// Aligned Byte 2
6658
assign  rjust2_sel_sbyte2   = ~rjust2_sel_sbyte6 ;
6659
//assign  rjust2_sel_sbyte6   = (byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m ;
6660
assign  rjust2_sel_sbyte6   = (byp_baddr_m[0]) & byp_word_m ;
6661
 
6662
// Aligned Byte 3
6663
assign  rjust3_sel_sbyte3   = ~rjust3_sel_sbyte7 ;
6664
//assign  rjust3_sel_sbyte7   = (byp_baddr_m[8] | byp_baddr_m[0]) & byp_word_m ;
6665
assign  rjust3_sel_sbyte7   = (byp_baddr_m[0]) & byp_word_m ;
6666
 
6667
// 3rd logical level - Complete alignment. Sign-Extension/Zero-Extension.
6668
// merge7-merge0 corresponds to cumulative swapping and alignment result.
6669
// byte[7]-byte[0] refers to the original pre-swap/alignment data.
6670
 
6671
wire merge7_sel_byte0_m, merge7_sel_byte7_m;
6672
wire merge6_sel_byte1_m, merge6_sel_byte6_m;
6673
wire merge5_sel_byte2_m, merge5_sel_byte5_m;
6674
wire merge4_sel_byte3_m, merge4_sel_byte4_m;
6675
wire merge3_sel_byte0_m, merge3_sel_byte3_m;
6676
wire merge3_sel_byte4_m, merge3_sel_byte7_m,merge3_sel_byte_m;
6677
wire merge2_sel_byte1_m, merge2_sel_byte2_m, merge2_sel_byte5_m;
6678
wire merge2_sel_byte6_m, merge2_sel_byte_m;
6679
wire merge0_sel_byte0_m, merge0_sel_byte1_m;
6680
wire merge0_sel_byte2_m, merge0_sel_byte3_m;
6681
wire merge0_sel_byte4_m, merge0_sel_byte5_m;
6682
wire merge0_sel_byte6_m;
6683
wire merge1_sel_byte0_m, merge1_sel_byte1_m;
6684
wire merge1_sel_byte2_m, merge1_sel_byte3_m;
6685
wire merge1_sel_byte4_m, merge1_sel_byte5_m;
6686
wire merge1_sel_byte6_m, merge1_sel_byte7_m;
6687
wire merge0_sel_byte_1h_m,merge1_sel_byte_1h_m, merge1_sel_byte_2h_m;
6688
 
6689
// Final Merged Byte 0
6690
assign  merge0_sel_byte0_m  =
6691
  (rjust0_sel_sbyte0 & swap0_sel_byte0) |
6692
  (rjust0_sel_sbyte1 & swap1_sel_byte0) |
6693
  (rjust0_sel_sbyte3 & swap3_sel_byte0) |
6694
  (rjust0_sel_sbyte7 & swap7_sel_byte0) ;
6695
 
6696
assign  merge0_sel_byte1_m  =
6697
  (rjust0_sel_sbyte0 & swap0_sel_byte1) |
6698
  (rjust0_sel_sbyte1 & swap1_sel_byte1) |
6699
  (rjust0_sel_sbyte2 & swap2_sel_byte1) |
6700
  (rjust0_sel_sbyte6 & swap6_sel_byte1) ;
6701
 
6702
assign  merge0_sel_byte2_m  =
6703
  (rjust0_sel_sbyte1 & swap1_sel_byte2) |
6704
  (rjust0_sel_sbyte2 & swap2_sel_byte2) |
6705
  (rjust0_sel_sbyte3 & swap3_sel_byte2) |
6706
  (rjust0_sel_sbyte5 & swap5_sel_byte2) ;
6707
 
6708
 
6709
assign  merge0_sel_byte3_m  =
6710
  (rjust0_sel_sbyte0 & swap0_sel_byte3) |
6711
  (rjust0_sel_sbyte2 & swap2_sel_byte3) |
6712
  (rjust0_sel_sbyte3 & swap3_sel_byte3) |
6713
  (rjust0_sel_sbyte4 & swap4_sel_byte3) ;
6714
 
6715
assign merge0_sel_byte3_default_m = ~ (merge0_sel_byte0_m | merge0_sel_byte1_m | merge0_sel_byte2_m);
6716
 
6717
assign  merge0_sel_byte4_m  =
6718
  (rjust0_sel_sbyte3 & swap3_sel_byte4) |
6719
  (rjust0_sel_sbyte4 & swap4_sel_byte4) |
6720
  (rjust0_sel_sbyte5 & swap5_sel_byte4) |
6721
  (rjust0_sel_sbyte7 & swap7_sel_byte4) ;
6722
 
6723
assign  merge0_sel_byte5_m  =
6724
  (rjust0_sel_sbyte2 & swap2_sel_byte5) |
6725
  (rjust0_sel_sbyte4 & swap4_sel_byte5) |
6726
  (rjust0_sel_sbyte5 & swap5_sel_byte5) |
6727
  (rjust0_sel_sbyte6 & swap6_sel_byte5) ;
6728
 
6729
assign  merge0_sel_byte6_m  =
6730
  (rjust0_sel_sbyte1 & swap1_sel_byte6) |
6731
  (rjust0_sel_sbyte5 & swap5_sel_byte6) |
6732
  (rjust0_sel_sbyte6 & swap6_sel_byte6) |
6733
  (rjust0_sel_sbyte7 & swap7_sel_byte6) ;
6734
 
6735
//assign  merge0_sel_byte7_m  = 
6736
//  (rjust0_sel_sbyte0 & swap0_sel_byte7) |
6737
//  (rjust0_sel_sbyte4 & swap4_sel_byte7) |
6738
//  (rjust0_sel_sbyte6 & swap6_sel_byte7) |
6739
//  (rjust0_sel_sbyte7 & swap7_sel_byte7) ;
6740
 
6741
   assign merge0_sel_byte7_default_m = ~(merge0_sel_byte4_m | merge0_sel_byte5_m |  merge0_sel_byte6_m);
6742
 
6743
assign  merge0_sel_byte_1h_m =
6744
  merge0_sel_byte0_m |  merge0_sel_byte1_m | merge0_sel_byte2_m | merge0_sel_byte3_m ;
6745
 
6746
// Final Merged Byte 1
6747
assign  merge1_sel_byte0_m  =
6748
  (rjust1_sel_sbyte1 & swap1_sel_byte0) |
6749
  (rjust1_sel_sbyte3 & swap3_sel_byte0) |
6750
  (rjust1_sel_sbyte7 & swap7_sel_byte0) ;
6751
 
6752
assign  merge1_sel_byte1_m  =
6753
  (rjust1_sel_sbyte1 & swap1_sel_byte1) ;
6754
 
6755
assign  merge1_sel_byte2_m  =
6756
  (rjust1_sel_sbyte1 & swap1_sel_byte2) |
6757
  (rjust1_sel_sbyte3 & swap3_sel_byte2) |
6758
  (rjust1_sel_sbyte5 & swap5_sel_byte2) ;
6759
 
6760
assign  merge1_sel_byte3_m  =
6761
  (rjust1_sel_sbyte3 & swap3_sel_byte3) ;
6762
 
6763
   assign merge1_sel_byte3_default_m = ~( merge1_sel_byte0_m | merge1_sel_byte1_m | merge1_sel_byte2_m);
6764
 
6765
assign  merge1_sel_byte4_m  =
6766
  (rjust1_sel_sbyte3 & swap3_sel_byte4) |
6767
  (rjust1_sel_sbyte5 & swap5_sel_byte4) |
6768
  (rjust1_sel_sbyte7 & swap7_sel_byte4) ;
6769
 
6770
assign  merge1_sel_byte5_m  =
6771
  (rjust1_sel_sbyte5 & swap5_sel_byte5) ;
6772
 
6773
assign  merge1_sel_byte6_m  =
6774
  (rjust1_sel_sbyte1 & swap1_sel_byte6) |
6775
  (rjust1_sel_sbyte5 & swap5_sel_byte6) |
6776
  (rjust1_sel_sbyte7 & swap7_sel_byte6) ;
6777
 
6778
assign  merge1_sel_byte7_m  =
6779
  (rjust1_sel_sbyte7 & swap7_sel_byte7) ;
6780
 
6781
   assign merge1_sel_byte7_default_m = ~( merge1_sel_byte4_m | merge1_sel_byte5_m | merge1_sel_byte6_m);
6782
 
6783
assign  merge1_sel_byte_1h_m = ~byp_byte_m &
6784
  (merge1_sel_byte0_m |  merge1_sel_byte1_m | merge1_sel_byte2_m | merge1_sel_byte3_m) ;
6785
 
6786
assign  merge1_sel_byte_2h_m = ~byp_byte_m &
6787
  (merge1_sel_byte4_m |  merge1_sel_byte5_m | merge1_sel_byte6_m | merge1_sel_byte7_m) ;
6788
 
6789
 
6790
// Final Merged Byte 2
6791
 
6792
assign  merge2_sel_byte1_m  =
6793
  (rjust2_sel_sbyte2 & swap2_sel_byte1) |
6794
  (rjust2_sel_sbyte6 & swap6_sel_byte1) ;
6795
 
6796
assign  merge2_sel_byte2_m  =
6797
  (rjust2_sel_sbyte2 & swap2_sel_byte2) ;
6798
 
6799
assign  merge2_sel_byte5_m  =
6800
  (rjust2_sel_sbyte2 & swap2_sel_byte5) |
6801
  (rjust2_sel_sbyte6 & swap6_sel_byte5) ;
6802
 
6803
assign  merge2_sel_byte6_m  =
6804
  (rjust2_sel_sbyte6 & swap6_sel_byte6) ;
6805
 
6806
   assign merge2_sel_byte6_default_m  = ~(merge2_sel_byte1_m | merge2_sel_byte2_m | merge2_sel_byte5_m);
6807
 
6808
assign merge2_sel_byte_m = ~byp_byte_m & ~byp_hword_m &
6809
(merge2_sel_byte1_m | merge2_sel_byte2_m | merge2_sel_byte5_m | merge2_sel_byte6_m);
6810
 
6811
// Final Merged Byte 3
6812
assign  merge3_sel_byte0_m  =
6813
  (rjust3_sel_sbyte3 & swap3_sel_byte0) |
6814
  (rjust3_sel_sbyte7 & swap7_sel_byte0) ;
6815
 
6816
assign  merge3_sel_byte3_m  =
6817
  (rjust3_sel_sbyte3 & swap3_sel_byte3) ;
6818
 
6819
assign  merge3_sel_byte4_m  =
6820
  (rjust3_sel_sbyte3 & swap3_sel_byte4) |
6821
  (rjust3_sel_sbyte7 & swap7_sel_byte4) ;
6822
 
6823
assign  merge3_sel_byte7_m  =
6824
  (rjust3_sel_sbyte7 & swap7_sel_byte7) ;
6825
 
6826
assign merge3_sel_byte7_default_m  =  ~(merge3_sel_byte0_m | merge3_sel_byte3_m | merge3_sel_byte4_m);
6827
 
6828
assign merge3_sel_byte_m = ~byp_byte_m & ~byp_hword_m &
6829
(merge3_sel_byte0_m | merge3_sel_byte3_m | merge3_sel_byte4_m | merge3_sel_byte7_m);
6830
 
6831
// Final Merged Byte 4
6832
assign  merge4_sel_byte3_m = byp_dword_m & swap4_sel_byte3 ;
6833
assign  merge4_sel_byte4_m = byp_dword_m & swap4_sel_byte4 ;
6834
 
6835
 
6836
// Final Merged Byte 5
6837
assign  merge5_sel_byte2_m = byp_dword_m & swap5_sel_byte2 ;
6838
assign  merge5_sel_byte5_m = byp_dword_m & swap5_sel_byte5 ;
6839
 
6840
// Final Merged Byte 6
6841
assign  merge6_sel_byte1_m = byp_dword_m & swap6_sel_byte1 ;
6842
assign  merge6_sel_byte6_m = byp_dword_m & swap6_sel_byte6 ;
6843
 
6844
// Final Merged Byte 7
6845
assign  merge7_sel_byte0_m = byp_dword_m & swap7_sel_byte0 ;
6846
assign  merge7_sel_byte7_m = byp_dword_m & swap7_sel_byte7 ;
6847
 
6848
 
6849
 
6850
//=========================================================================================
6851
//  STQ/CAS 2ND PKT FORMATTING 
6852
//=========================================================================================
6853
 
6854
// stq and cas write to an extra buffer. stq always uses a full 64bits.
6855
// cas may use either 64b or 32b. stq requires at most endian alignment.
6856
// cas may require both address and endian alignment.
6857
 
6858
// Byte Alignment. Assume 8 bytes, 7-0
6859
//  Case 1 : 7,6,5,4,3,2,1,0 
6860
//  Case 2 : 3,2,1,0,0,1,2,3 
6861
//  Case 3 : 0,1,2,3,4,5,6,7  
6862
 
6863
wire casa_wd_g ;
6864
assign  casa_wd_g = casa_g & byp_word_g ;
6865
wire casa_dwd_g ;
6866
assign  casa_dwd_g = casa_g & ~byp_word_g ;
6867
 
6868
// Change bendian to bendian_g - should not be dependent on fill. 
6869
 
6870
//assign  lsu_atomic_pkt2_bsel_g[2] =   // Case 1
6871
//  (casa_dwd_g &  bendian_g)   |  // bendian stq and dw cas
6872
//  (casa_wd_g &  bendian_g &  ldst_va_g[2]) ;  // bendian_g wd casa addr to uhalf
6873
 
6874
assign lsu_atomic_pkt2_bsel_g[2] = ~| (lsu_atomic_pkt2_bsel_g[1:0]) | rst_tri_en ; //one-hot default
6875
 
6876
assign  lsu_atomic_pkt2_bsel_g[1] =   // Case 2
6877
  ((casa_wd_g &  bendian_g & ~ldst_va_g[2]) |  // bendian_g wd casa addr to lhalf
6878
  (casa_wd_g & ~bendian_g &  ldst_va_g[2])) &  ~rst_tri_en ;  // lendian wd casa addr to uhalf
6879
assign  lsu_atomic_pkt2_bsel_g[0] =   // Case 3 
6880
  ((casa_dwd_g & ~bendian_g) |    // lendian stq and dw cas
6881
  (casa_wd_g & ~bendian_g & ~ldst_va_g[2])) &  ~rst_tri_en ;  // lendian wd cas addr to lhalf
6882
 
6883
// Alignment done in qdp1
6884
 
6885
//=========================================================================================
6886
//  ASI DECODE
6887
//=========================================================================================
6888
 
6889
// Note : tlb_byp_asi same as phy_use/phy_byp asi.
6890
 
6891
 
6892
lsu_asi_decode asi_decode (/*AUTOINST*/
6893
                           // Outputs
6894
                           .asi_internal_d(asi_internal_d),
6895
                           .nucleus_asi_d(nucleus_asi_d),
6896
                           .primary_asi_d(primary_asi_d),
6897
                           .secondary_asi_d(secondary_asi_d),
6898
                           .lendian_asi_d(lendian_asi_d),
6899
                           .nofault_asi_d(nofault_asi_d),
6900
                           .quad_asi_d  (quad_asi_d),
6901
                           .binit_quad_asi_d(binit_quad_asi_d),
6902
                           .dcache_byp_asi_d(dcache_byp_asi_d),
6903
                           .tlb_lng_ltncy_asi_d(tlb_lng_ltncy_asi_d),
6904
                           .tlb_byp_asi_d(tlb_byp_asi_d),
6905
                           .as_if_user_asi_d(as_if_user_asi_d),
6906
                           .atomic_asi_d(atomic_asi_d),
6907
                           .blk_asi_d   (blk_asi_d),
6908
                           .dc_diagnstc_asi_d(dc_diagnstc_asi_d),
6909
                           .dtagv_diagnstc_asi_d(dtagv_diagnstc_asi_d),
6910
                           .wr_only_asi_d(wr_only_asi_d),
6911
                           .rd_only_asi_d(rd_only_asi_d),
6912
                           .unimp_asi_d (unimp_asi_d),
6913
                           .ifu_nontlb_asi_d(ifu_nontlb_asi_d),
6914
                           .recognized_asi_d(recognized_asi_d),
6915
                           .ifill_tlb_asi_d(ifill_tlb_asi_d),
6916
                           .dfill_tlb_asi_d(dfill_tlb_asi_d),
6917
                           .rd_only_ltlb_asi_d(rd_only_ltlb_asi_d),
6918
                           .wr_only_ltlb_asi_d(wr_only_ltlb_asi_d),
6919
                           .phy_use_ec_asi_d(phy_use_ec_asi_d),
6920
                           .phy_byp_ec_asi_d(phy_byp_ec_asi_d),
6921
                           .mmu_rd_only_asi_d(mmu_rd_only_asi_d),
6922
                           .intrpt_disp_asi_d(intrpt_disp_asi_d),
6923
                           .dmmu_asi58_d(dmmu_asi58_d),
6924
                           .immu_asi50_d(immu_asi50_d),
6925
                           // Inputs
6926
                           .asi_d       (asi_d[7:0]));
6927
 
6928 113 albert.wat
dff_s #(31)  asidcd_stge (
6929 95 fafa1971
        .din    ({asi_internal_d,primary_asi_d,secondary_asi_d,nucleus_asi_d,
6930
    lendian_asi_d, tlb_byp_asi_d, dcache_byp_asi_d,nofault_asi_d,
6931
    tlb_lng_ltncy_asi_d,as_if_user_asi_d,atomic_asi_d, blk_asi_d,
6932
    dc_diagnstc_asi_d,dtagv_diagnstc_asi_d,
6933
    wr_only_asi_d, rd_only_asi_d,mmu_rd_only_asi_d,unimp_asi_d,dmmu_asi58_d, immu_asi50_d, quad_asi_d, binit_quad_asi_d,
6934
    ifu_nontlb_asi_d,recognized_asi_d, ifill_tlb_asi_d,
6935
    dfill_tlb_asi_d, rd_only_ltlb_asi_d,wr_only_ltlb_asi_d,phy_use_ec_asi_d, phy_byp_ec_asi_d, intrpt_disp_asi_d}),
6936
        .q      ({asi_internal_e,primary_asi_e,secondary_asi_e,nucleus_asi_e,
6937
    lendian_asi_e, tlb_byp_asi_e, dcache_byp_asi_e,nofault_asi_e,
6938
    tlb_lng_ltncy_asi_e,as_if_user_asi_e,atomic_asi_e, blk_asi_e,
6939
    dc_diagnstc_asi_e,dtagv_diagnstc_asi_e,
6940
    wr_only_asi_e, rd_only_asi_e,mmu_rd_only_asi_e,unimp_asi_e,dmmu_asi58_e, immu_asi50_e, quad_asi_e, binit_quad_asi_e,
6941
    ifu_nontlb_asi_e,recognized_asi_e,ifill_tlb_asi_e,
6942
    dfill_tlb_asi_e,rd_only_ltlb_asi_e,wr_only_ltlb_asi_e,phy_use_ec_asi_e, phy_byp_ec_asi_e, intrpt_disp_asi_e}),
6943
        .clk    (clk),
6944 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6945 95 fafa1971
        );
6946
 
6947
assign  lsu_ffu_blk_asi_e = blk_asi_e & alt_space_e;
6948
assign  lsu_quad_asi_e = quad_asi_e ;
6949
 
6950
wire    unimp_asi_tmp ;
6951 113 albert.wat
dff_s #(23)  asidcd_stgm (
6952 95 fafa1971
        .din    ({asi_internal_e,dcache_byp_asi_e,nofault_asi_e,lendian_asi_e,tlb_lng_ltncy_asi_e,
6953
    as_if_user_asi_e,atomic_asi_e, blk_asi_e,dc_diagnstc_asi_e,dtagv_diagnstc_asi_e,
6954
    wr_only_asi_e, rd_only_asi_e,mmu_rd_only_asi_e,unimp_asi_e,dmmu_asi58_e, immu_asi50_e, quad_asi_e,binit_quad_asi_e,recognized_asi_e,
6955
    ifu_nontlb_asi_e,phy_use_ec_asi_e, phy_byp_ec_asi_e, intrpt_disp_asi_e}),
6956
        .q      ({asi_internal_m,dcache_byp_asi_m,nofault_asi_m,lendian_asi_m,tlb_lng_ltncy_asi_m,
6957
    as_if_user_asi_m,atomic_asi_m, blk_asi_m,dc_diagnstc_asi_m,dtagv_diagnstc_asi_m,
6958
    wr_only_asi_m, rd_only_asi_m,mmu_rd_only_asi_m,unimp_asi_tmp,dmmu_asi58_m, immu_asi50_m, quad_asi_m,binit_quad_asi_m,recognized_asi_tmp,
6959
    ifu_nontlb_asi_m,phy_use_ec_asi_m, phy_byp_ec_asi_m, intrpt_disp_asi_m}),
6960
        .clk    (clk),
6961 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6962 95 fafa1971
        );
6963
 
6964
assign  lsu_blk_asi_m = blk_asi_m ;
6965
 
6966
   wire pa_wtchpt_unimp_m ; // Bug 3408
6967
   wire d_tsb_unimp_m, i_tsb_unimp_m, pctxt_unimp_m, sctxt_unimp_m;
6968
   wire unimp_m;
6969
 
6970
assign  pa_wtchpt_unimp_m  = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h40);
6971
assign  d_tsb_unimp_m = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h28);
6972
assign  pctxt_unimp_m = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h8);
6973
assign  sctxt_unimp_m = dmmu_asi58_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h10);
6974
assign  i_tsb_unimp_m = immu_asi50_m & (lsu_ldst_va_b7_b0_m[7:0] == 8'h28);
6975
assign  unimp_m =  pa_wtchpt_unimp_m |
6976
                   d_tsb_unimp_m | i_tsb_unimp_m |
6977
                   pctxt_unimp_m | sctxt_unimp_m;
6978
 
6979
assign  unimp_asi_m = unimp_asi_tmp | unimp_m ;
6980
assign  recognized_asi_m = recognized_asi_tmp | unimp_m ;
6981
 
6982 113 albert.wat
dff_s #(12)  asidcd_stgg (
6983 95 fafa1971
        .din    ({asi_internal_m,dcache_byp_asi_m, lendian_asi_m,tlb_lng_ltncy_asi_m,
6984
  blk_asi_m,dc_diagnstc_asi_m,dtagv_diagnstc_asi_m,quad_asi_m,
6985
  binit_quad_asi_m,recognized_asi_m,ifu_nontlb_asi_m,  intrpt_disp_asi_m}),
6986
        .q      ({asi_internal_g,dcache_byp_asi_g, lendian_asi_g,tlb_lng_ltncy_asi_g,
6987
  blk_asi_g,dc_diagnstc_asi_g,dtagv_diagnstc_asi_g,quad_asi_g,
6988
  binit_quad_asi_g,recognized_asi_g,ifu_nontlb_asi_g,  intrpt_disp_asi_g}),
6989
        .clk    (clk),
6990 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
6991 95 fafa1971
        );
6992
 
6993
//assign lsu_quad_asi_g = quad_asi_g;
6994
assign  ncache_asild_rq_g   = dcache_byp_asi_g & altspace_ldst_g ;
6995
 
6996
//st data alignment control signals
6997
wire st_sz_hw_g, st_sz_w_g, st_sz_dw_g, stdbl_g;
6998
wire stdbl_m;
6999
 
7000
//assign stdbl_m =  ldst_dbl_m & (~lsu_alt_space_m | (lsu_alt_space_m & ~blk_asi_m)) ;
7001
assign stdbl_m =  ldst_dbl_m ;
7002
 
7003 113 albert.wat
dff_s #(4) ff_st_sz_m (
7004 95 fafa1971
  .din ({hw_size, wd_size, dw_size, stdbl_m }),
7005
  .q   ({st_sz_hw_g, st_sz_w_g, st_sz_dw_g, stdbl_g}),
7006
  .clk (clk),
7007 113 albert.wat
  .se  (se), `SIMPLY_RISC_SCANIN, .so ()
7008 95 fafa1971
);
7009
 
7010
 
7011
//assign        bendian = lsu_bendian_access_g ;        // bendian store
7012
 
7013
wire    swap_sel_default_g, swap_sel_default_byte_7_2_g, st_hw_le_g,st_w_or_dbl_le_g,st_x_le_g;
7014
assign  bendian_g = ~l1hit_lendian_g ;
7015
//assign        swap_sel_default_g = (bendian_g | (~bendian_g & st_sz_b_g)) ;
7016
 
7017
assign swap_sel_default_g = ~ (st_hw_le_g | st_w_or_dbl_le_g | st_x_le_g);
7018
assign swap_sel_default_byte_7_2_g = ~ (st_w_or_dbl_le_g | st_x_le_g);
7019
 
7020
assign  st_hw_le_g = (st_sz_hw_g & ~bendian_g) & (~stdbl_g | fp_ldst_g) & st_inst_vld_unflushed ;  //0-in bug
7021
//bug 3169 
7022
// std(a) on floating point is the same as stx(a)
7023
assign  st_w_or_dbl_le_g = ((st_sz_w_g | (stdbl_g & ~fp_ldst_g)) & ~bendian_g) &  st_inst_vld_unflushed ;
7024
assign  st_x_le_g = (st_sz_dw_g & (~stdbl_g | fp_ldst_g)  & ~bendian_g) &  st_inst_vld_unflushed;
7025
 
7026
wire blkst_m_tmp ;
7027 113 albert.wat
dff_s  stgm_bst (
7028 95 fafa1971
  .din (ffu_lsu_blk_st_e),
7029
  .q   (blkst_m_tmp),
7030
  .clk (clk),
7031 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7032 95 fafa1971
);
7033
 
7034
assign  blkst_m = blkst_m_tmp & ~(st_inst_vld_m  | flsh_inst_m
7035
                | ld_inst_vld_m) ; // Bug 3444
7036
 
7037
assign  lsu_blk_st_m = blkst_m ;
7038
 
7039 113 albert.wat
dff_s  stgg_bst (
7040 95 fafa1971
  .din (blkst_m),
7041
  .q   (blkst_g),
7042
  .clk (clk),
7043 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7044 95 fafa1971
);
7045
 
7046
wire    bst_swap_sel_default_g, bst_swap_sel_default_byte_7_2_g,bst_st_hw_le_g,bst_st_w_or_dbl_le_g,bst_st_x_le_g;
7047
assign  lsu_swap_sel_default_g = (blkst_g ? bst_swap_sel_default_g : swap_sel_default_g) | rst_tri_en ;
7048
assign  lsu_swap_sel_default_byte_7_2_g = (blkst_g ? bst_swap_sel_default_byte_7_2_g : swap_sel_default_byte_7_2_g)
7049
                                         | rst_tri_en ;
7050
 
7051
assign  lsu_st_hw_le_g  = (blkst_g ? bst_st_hw_le_g : st_hw_le_g) & ~rst_tri_en ;
7052
assign  lsu_st_w_or_dbl_le_g = (blkst_g ? bst_st_w_or_dbl_le_g : st_w_or_dbl_le_g) & ~rst_tri_en ;
7053
assign  lsu_st_x_le_g = (blkst_g ? bst_st_x_le_g : st_x_le_g) & ~rst_tri_en ;
7054
 
7055
 
7056
//=========================================================================================
7057
//      BLK STORE
7058
//=========================================================================================
7059
 
7060
// Blk-St Handling : Snap state in g-stage of issue from IFU.
7061
 
7062
wire snap_blk_st_m,snap_blk_st_g ;
7063
assign snap_blk_st_m = st_inst_vld_m & blk_asi_m & lsu_alt_space_m & fp_ldst_m;
7064
 
7065
assign lsu_snap_blk_st_m = snap_blk_st_m ;
7066
 
7067
wire    snap_blk_st_local_m;
7068
assign  snap_blk_st_local_m = snap_blk_st_m & ifu_tlu_inst_vld_m ;
7069
 
7070 113 albert.wat
dff_s  stgg_snap (
7071 95 fafa1971
  .din (snap_blk_st_local_m),
7072
  .q   (snap_blk_st_g),
7073
  .clk (clk),
7074 113 albert.wat
  .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7075 95 fafa1971
);
7076
 
7077
// output to be used in g-stage.
7078 113 albert.wat
dffe_s #(5) bst_state_g (
7079 95 fafa1971
        .din    ({lsu_swap_sel_default_g, lsu_swap_sel_default_byte_7_2_g, lsu_st_hw_le_g,
7080
                lsu_st_w_or_dbl_le_g,lsu_st_x_le_g}),
7081
        .q      ({bst_swap_sel_default_g, bst_swap_sel_default_byte_7_2_g,  bst_st_hw_le_g,
7082
                bst_st_w_or_dbl_le_g,bst_st_x_le_g}),
7083
        .en     (snap_blk_st_g),
7084
        .clk    (clk),
7085 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7086 95 fafa1971
        );
7087
 
7088
 
7089
// snapped in g, used in m
7090
 
7091
   wire [39:10] blkst_pgnum_m;
7092
 
7093 113 albert.wat
dffe_s #(30) bst_pg_g (
7094 95 fafa1971
        .din    (tlb_pgnum[39:10]),
7095
        .q      (blkst_pgnum_m[39:10]),
7096
        .en     (snap_blk_st_g),
7097
        .clk    (clk),
7098 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7099 95 fafa1971
        );
7100
 
7101
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b10 (.a(blkst_pgnum_m[10]), .z(lsu_blkst_pgnum_m[10]));
7102
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b11 (.a(blkst_pgnum_m[11]), .z(lsu_blkst_pgnum_m[11]));
7103
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b12 (.a(blkst_pgnum_m[12]), .z(lsu_blkst_pgnum_m[12]));
7104
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b13 (.a(blkst_pgnum_m[13]), .z(lsu_blkst_pgnum_m[13]));
7105
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b14 (.a(blkst_pgnum_m[14]), .z(lsu_blkst_pgnum_m[14]));
7106
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b15 (.a(blkst_pgnum_m[15]), .z(lsu_blkst_pgnum_m[15]));
7107
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b16 (.a(blkst_pgnum_m[16]), .z(lsu_blkst_pgnum_m[16]));
7108
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b17 (.a(blkst_pgnum_m[17]), .z(lsu_blkst_pgnum_m[17]));
7109
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b18 (.a(blkst_pgnum_m[18]), .z(lsu_blkst_pgnum_m[18]));
7110
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b19 (.a(blkst_pgnum_m[19]), .z(lsu_blkst_pgnum_m[19]));
7111
 
7112
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b20 (.a(blkst_pgnum_m[20]), .z(lsu_blkst_pgnum_m[20]));
7113
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b21 (.a(blkst_pgnum_m[21]), .z(lsu_blkst_pgnum_m[21]));
7114
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b22 (.a(blkst_pgnum_m[22]), .z(lsu_blkst_pgnum_m[22]));
7115
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b23 (.a(blkst_pgnum_m[23]), .z(lsu_blkst_pgnum_m[23]));
7116
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b24 (.a(blkst_pgnum_m[24]), .z(lsu_blkst_pgnum_m[24]));
7117
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b25 (.a(blkst_pgnum_m[25]), .z(lsu_blkst_pgnum_m[25]));
7118
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b26 (.a(blkst_pgnum_m[26]), .z(lsu_blkst_pgnum_m[26]));
7119
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b27 (.a(blkst_pgnum_m[27]), .z(lsu_blkst_pgnum_m[27]));
7120
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b28 (.a(blkst_pgnum_m[28]), .z(lsu_blkst_pgnum_m[28]));
7121
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b29 (.a(blkst_pgnum_m[29]), .z(lsu_blkst_pgnum_m[29]));
7122
 
7123
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b30 (.a(blkst_pgnum_m[30]), .z(lsu_blkst_pgnum_m[30]));
7124
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b31 (.a(blkst_pgnum_m[31]), .z(lsu_blkst_pgnum_m[31]));
7125
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b32 (.a(blkst_pgnum_m[32]), .z(lsu_blkst_pgnum_m[32]));
7126
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b33 (.a(blkst_pgnum_m[33]), .z(lsu_blkst_pgnum_m[33]));
7127
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b34 (.a(blkst_pgnum_m[34]), .z(lsu_blkst_pgnum_m[34]));
7128
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b35 (.a(blkst_pgnum_m[35]), .z(lsu_blkst_pgnum_m[35]));
7129
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b36 (.a(blkst_pgnum_m[36]), .z(lsu_blkst_pgnum_m[36]));
7130
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b37 (.a(blkst_pgnum_m[37]), .z(lsu_blkst_pgnum_m[37]));
7131
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b38 (.a(blkst_pgnum_m[38]), .z(lsu_blkst_pgnum_m[38]));
7132
bw_u1_minbuf_5x UZfix_lsu_blkst_pgnum_m_b39 (.a(blkst_pgnum_m[39]), .z(lsu_blkst_pgnum_m[39]));
7133
 
7134
//=========================================================================================
7135
//  Prefetch Count
7136
//=========================================================================================
7137
 
7138
wire [3:0] lsu_cpx_pref_ack;
7139
wire [3:0] no_spc_pref;
7140
 
7141
wire    [3:0]    pref_ackcnt0,pref_ackcnt1,pref_ackcnt2,pref_ackcnt3 ;
7142
wire    [3:0]    pref_ackcnt0_din,pref_ackcnt1_din,pref_ackcnt2_din,pref_ackcnt3_din ;
7143
 
7144
wire    [3:0]    pref_ackcnt_incr, pref_ackcnt_decr ;
7145
wire    [3:0]    pref_ackcnt_mx_incr, pref_ackcnt_mx_decr ;
7146
 
7147
   wire     lsu_pref_pcx_req_d1;
7148
 
7149 113 albert.wat
dff_s #(1) pref_pcx_req_stg (
7150 95 fafa1971
         .din (lsu_pref_pcx_req),
7151
         .q   (lsu_pref_pcx_req_d1),
7152
         .clk (clk),
7153 113 albert.wat
         .se  (se),       `SIMPLY_RISC_SCANIN,          .so ()
7154 95 fafa1971
);
7155
 
7156
assign   lsu_pcx_pref_issue[0] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[0] & ~lsu_pcx_req_squash_d1;
7157
assign   lsu_pcx_pref_issue[1] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[1] & ~lsu_pcx_req_squash_d1;
7158
assign   lsu_pcx_pref_issue[2] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[2] & ~lsu_pcx_req_squash_d1;
7159
assign   lsu_pcx_pref_issue[3] =  lsu_pref_pcx_req_d1 & lsu_ld_pcx_rq_sel_d2[3] & ~lsu_pcx_req_squash_d1;
7160
 
7161
 
7162
   wire [3:0] pref_acknt_mx_incr_sel;
7163
   assign     pref_acknt_mx_incr_sel[3:0] = lsu_pcx_pref_issue[3:0];
7164
 
7165
assign  pref_ackcnt_mx_incr[3:0] =
7166
  (pref_acknt_mx_incr_sel[0] ? pref_ackcnt0[3:0] : 4'b0) |
7167
  (pref_acknt_mx_incr_sel[1] ? pref_ackcnt1[3:0] : 4'b0) |
7168
  (pref_acknt_mx_incr_sel[2] ? pref_ackcnt2[3:0] : 4'b0) |
7169
  (pref_acknt_mx_incr_sel[3] ? pref_ackcnt3[3:0] : 4'b0) ;
7170
 
7171
 
7172
//====================================================================================
7173
// prefetch ack back from CPX
7174
   wire       dcfill_active_e;
7175
   assign dcfill_active_e = lsu_dfq_ld_vld & ~memref_e ;
7176
 
7177
   wire   dfq_thread0, dfq_thread1, dfq_thread2, dfq_thread3;
7178
 
7179
   assign dfq_thread0 = dfill_thread0;
7180
   assign dfq_thread1 = dfill_thread1;
7181
   assign dfq_thread2 = dfill_thread2;
7182
   assign dfq_thread3 = dfill_thread3;
7183
 
7184
   assign lsu_cpx_pref_ack[0]  = dfq_thread0  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7185
   assign lsu_cpx_pref_ack[1]  = dfq_thread1  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7186
   assign lsu_cpx_pref_ack[2]  = dfq_thread2  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7187
   assign lsu_cpx_pref_ack[3]  = dfq_thread3  & dcfill_active_e & lsu_cpx_pkt_prefetch2;
7188
 
7189
   wire [3:0] pref_acknt_mx_decr_sel;
7190
   assign     pref_acknt_mx_decr_sel[3:0] = lsu_cpx_pref_ack[3:0];
7191
 
7192
assign    pref_ackcnt_mx_decr[3:0] =
7193
  (pref_acknt_mx_decr_sel[0] ? pref_ackcnt0[3:0] : 4'b0) |
7194
  (pref_acknt_mx_decr_sel[1] ? pref_ackcnt1[3:0] : 4'b0) |
7195
  (pref_acknt_mx_decr_sel[2] ? pref_ackcnt2[3:0] : 4'b0) |
7196
  (pref_acknt_mx_decr_sel[3] ? pref_ackcnt3[3:0] : 4'b0) ;
7197
 
7198
 
7199
assign  pref_ackcnt_incr[3:0] = pref_ackcnt_mx_incr[3:0] + 4'b0001 ;
7200
assign  pref_ackcnt_decr[3:0] = pref_ackcnt_mx_decr[3:0] - 4'b0001 ;
7201
 
7202
assign  pref_ackcnt0_din[3:0] = lsu_cpx_pref_ack[0] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7203
assign  pref_ackcnt1_din[3:0] = lsu_cpx_pref_ack[1] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7204
assign  pref_ackcnt2_din[3:0] = lsu_cpx_pref_ack[2] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7205
assign  pref_ackcnt3_din[3:0] = lsu_cpx_pref_ack[3] ? pref_ackcnt_decr[3:0] : pref_ackcnt_incr[3:0] ;
7206
 
7207
wire    [3:0]    pref_ackcnt_en ;
7208
// if both occur in the same cycle then they cancel out.
7209
assign  pref_ackcnt_en[0] = lsu_pcx_pref_issue[0] ^ lsu_cpx_pref_ack[0] ;
7210
assign  pref_ackcnt_en[1] = lsu_pcx_pref_issue[1] ^ lsu_cpx_pref_ack[1] ;
7211
assign  pref_ackcnt_en[2] = lsu_pcx_pref_issue[2] ^ lsu_cpx_pref_ack[2] ;
7212
assign  pref_ackcnt_en[3] = lsu_pcx_pref_issue[3] ^ lsu_cpx_pref_ack[3] ;
7213
 
7214
// Thread0
7215 113 albert.wat
dffre_s #(4)  pref_ackcnt0_ff (
7216 95 fafa1971
        .din    (pref_ackcnt0_din[3:0]),
7217
        .q      (pref_ackcnt0[3:0]),
7218
        .rst    (reset),        .en     (pref_ackcnt_en[0]),
7219
        .clk    (clk),
7220 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7221 95 fafa1971
        );
7222
 
7223
// Thread1
7224 113 albert.wat
dffre_s #(4)  pref_ackcnt1_ff (
7225 95 fafa1971
        .din    (pref_ackcnt1_din[3:0]),
7226
        .q      (pref_ackcnt1[3:0]),
7227
        .rst    (reset),        .en     (pref_ackcnt_en[1]),
7228
        .clk    (clk),
7229 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7230 95 fafa1971
        );
7231
 
7232
// Thread2
7233 113 albert.wat
dffre_s #(4)  pref_ackcnt2_ff (
7234 95 fafa1971
        .din    (pref_ackcnt2_din[3:0]),
7235
        .q      (pref_ackcnt2[3:0]),
7236
        .rst    (reset),        .en     (pref_ackcnt_en[2]),
7237
        .clk    (clk),
7238 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7239 95 fafa1971
        );
7240
 
7241
// Thread3
7242 113 albert.wat
dffre_s #(4)  pref_ackcnt3_ff (
7243 95 fafa1971
        .din    (pref_ackcnt3_din[3:0]),
7244
        .q      (pref_ackcnt3[3:0]),
7245
        .rst    (reset),        .en     (pref_ackcnt_en[3]),
7246
        .clk    (clk),
7247 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7248 95 fafa1971
        );
7249
 
7250
assign  no_spc_pref[0] = pref_ackcnt0[3] ;
7251
assign  no_spc_pref[1] = pref_ackcnt1[3] ;
7252
assign  no_spc_pref[2] = pref_ackcnt2[3] ;
7253
assign  no_spc_pref[3] = pref_ackcnt3[3] ;
7254
 
7255
assign  lsu_no_spc_pref[3:0] = no_spc_pref[3:0];
7256
 
7257
//====================================================================
7258
   wire lsu_bist_e;
7259
 
7260
   assign lsu_bist_e = lsu_bist_wvld_e | lsu_bist_rvld_e;
7261
 
7262
   wire [10:0]      lmq_pcx_pkt_addr_din;
7263
 
7264
   wire [3:0] dfq_byp_thrd_sel;
7265
 
7266
mux4ds #(11) lmq_pcx_pkt_addr_mux (
7267
       .in0 ({lmq0_pcx_pkt_addr[10:0]}),
7268
       .in1 ({lmq1_pcx_pkt_addr[10:0]}),
7269
       .in2 ({lmq2_pcx_pkt_addr[10:0]}),
7270
       .in3 ({lmq3_pcx_pkt_addr[10:0]}),
7271
       .sel0(dfq_byp_thrd_sel[0]),
7272
       .sel1(dfq_byp_thrd_sel[1]),
7273
       .sel2(dfq_byp_thrd_sel[2]),
7274
       .sel3(dfq_byp_thrd_sel[3]),
7275
       .dout({lmq_pcx_pkt_addr_din[10:0]})
7276
);
7277
 
7278 113 albert.wat
dffe_s #(11)  lmq_pcx_pkt_addr_ff (
7279 95 fafa1971
           .din    ({lmq_pcx_pkt_addr_din[10:0]}),
7280
           .q      ({lmq_pcx_pkt_addr[10:0]}),
7281
           .en     (dfq_byp_ff_en),
7282
           .clk    (clk),
7283 113 albert.wat
           .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7284 95 fafa1971
           );
7285
 
7286
 
7287
   wire [10:4] lmq_pcx_pkt_addr_minbf;
7288
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b10 (.a(lmq_pcx_pkt_addr[10]), .z(lmq_pcx_pkt_addr_minbf[10]));
7289
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b9 (.a(lmq_pcx_pkt_addr[9]), .z(lmq_pcx_pkt_addr_minbf[9]));
7290
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b8 (.a(lmq_pcx_pkt_addr[8]), .z(lmq_pcx_pkt_addr_minbf[8]));
7291
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b7 (.a(lmq_pcx_pkt_addr[7]), .z(lmq_pcx_pkt_addr_minbf[7]));
7292
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b6 (.a(lmq_pcx_pkt_addr[6]), .z(lmq_pcx_pkt_addr_minbf[6]));
7293
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b5 (.a(lmq_pcx_pkt_addr[5]), .z(lmq_pcx_pkt_addr_minbf[5]));
7294
   bw_u1_minbuf_5x UZfix_lmq_pcx_pkt_addr_minbf_b4 (.a(lmq_pcx_pkt_addr[4]), .z(lmq_pcx_pkt_addr_minbf[4]));
7295
 
7296
 
7297
assign           lmq_ld_addr_b3 = lmq_pcx_pkt_addr[3];
7298
 
7299
 
7300
assign  dcache_fill_addr_e[10:0] =
7301
{11{lsu_dc_iob_access_e}}               & {dcache_iob_addr_e[7:0],3'b000} |
7302
{11{lsu_bist_wvld_e | lsu_bist_rvld_e}} & {mbist_dcache_index[6:0], mbist_dcache_word, 3'b000} |
7303
{11{lsu_diagnstc_wr_src_sel_e}}         & lsu_diagnstc_wr_addr_e[10:0] |
7304
{11{lsu_dfq_st_vld}}                    & st_dcfill_addr[10:0] |
7305
{11{lsu_dfq_ld_vld}}                    & {lmq_pcx_pkt_addr_minbf[10:4], lmq_pcx_pkt_addr[3:0]};
7306
 
7307
assign lsu_dcache_fill_addr_e[10:3] = dcache_fill_addr_e[10:3];
7308
 
7309
   wire [10:4] dcache_fill_addr_e_tmp;
7310
assign dcache_fill_addr_e_tmp[10:4]    = dcache_fill_addr_e[10:4];
7311
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b10 ( .a(dcache_fill_addr_e_tmp[10]),  .z(lsu_dcache_fill_addr_e_err[10]));
7312
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b9  ( .a(dcache_fill_addr_e_tmp[9]),  .z(lsu_dcache_fill_addr_e_err[9] ));
7313
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b8  ( .a(dcache_fill_addr_e_tmp[8]),  .z(lsu_dcache_fill_addr_e_err[8]));
7314
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b7  ( .a(dcache_fill_addr_e_tmp[7]),  .z(lsu_dcache_fill_addr_e_err[7]));
7315
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b6  ( .a(dcache_fill_addr_e_tmp[6]),  .z(lsu_dcache_fill_addr_e_err[6]));
7316
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b5  ( .a(dcache_fill_addr_e_tmp[5]),  .z(lsu_dcache_fill_addr_e_err[5]));
7317
bw_u1_buf_30x UZfix_lsu_dcache_fill_addr_e_err_b4  ( .a(dcache_fill_addr_e_tmp[4]),  .z(lsu_dcache_fill_addr_e_err[4]));
7318
 
7319
// used as ld bypass 
7320
assign dcache_wr_addr_e[2:0] = dcache_fill_addr_e[2:0];
7321
 
7322
//ldfill doesn't need to create wrt byte msk, always fill one line
7323
assign waddr_enc[3:0] =
7324
{4{lsu_dc_iob_access_e}}               & {dcache_iob_addr_e[0],3'b000} |
7325
{4{lsu_bist_e}}                        & {mbist_dcache_word, 3'b000} |
7326
{4{lsu_diagnstc_wr_src_sel_e}}         & lsu_diagnstc_wr_addr_e[3:0] |
7327
{4{lsu_dfq_st_vld}}                    & st_dcfill_addr[3:0] ;
7328
 
7329
//==============================================================
7330
/*
7331 113 albert.wat
dff_s  #(4) lsu_thread_stgg (
7332 95 fafa1971
        .din    ({thread3_m, thread2_m, thread1_m,thread0_m}),
7333
        .q      (lsu_thread_g[3:0]),
7334
        .clk    (clk),
7335 113 albert.wat
        .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7336 95 fafa1971
        );
7337
*/
7338
   assign lsu_thread_g[3] = thread3_g;
7339
   assign lsu_thread_g[2] = thread2_g;
7340
   assign lsu_thread_g[1] = thread1_g;
7341
   assign lsu_thread_g[0] = thread0_g;
7342
 
7343
//===============================================================
7344
//LMQ thread sel
7345
//===============================================================
7346
//lmq_ldd_vld
7347
   assign     dfq_byp_thrd_sel[0] = ~lsu_dfq_byp_tid[1] & ~lsu_dfq_byp_tid[0];
7348
   assign     dfq_byp_thrd_sel[1] = ~lsu_dfq_byp_tid[1] &  lsu_dfq_byp_tid[0];
7349
   assign     dfq_byp_thrd_sel[2] =  lsu_dfq_byp_tid[1] & ~lsu_dfq_byp_tid[0];
7350
   assign     dfq_byp_thrd_sel[3] =  lsu_dfq_byp_tid[1] &  lsu_dfq_byp_tid[0];
7351
 
7352
   wire       lmq_ldd_vld_din;
7353
 
7354
mux4ds #(1) lmq_ldd_vld_mux (
7355
       .in0 ({lmq0_ldd_vld}),
7356
       .in1 ({lmq1_ldd_vld}),
7357
       .in2 ({lmq2_ldd_vld}),
7358
       .in3 ({lmq3_ldd_vld}),
7359
       .sel0(dfq_byp_thrd_sel[0]),
7360
       .sel1(dfq_byp_thrd_sel[1]),
7361
       .sel2(dfq_byp_thrd_sel[2]),
7362
       .sel3(dfq_byp_thrd_sel[3]),
7363
       .dout({lmq_ldd_vld_din})
7364
);
7365
 
7366 113 albert.wat
dffe_s #(1)  lmq_ldd_vld_ff (
7367 95 fafa1971
           .din    ({lmq_ldd_vld_din}),
7368
           .q      ({lmq_ldd_vld}),
7369
           .en     (dfq_byp_ff_en),
7370
           .clk    (clk),
7371 113 albert.wat
           .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7372 95 fafa1971
           );
7373
 
7374
//bist
7375
wire [1:0] bist_way_enc_e;
7376
wire [3:0] bist_way_e;
7377
 
7378
 
7379
assign bist_way_enc_e[1:0] =  lsu_dc_iob_access_e ?
7380
       lsu_dcache_iob_way_e[1:0] : mbist_dcache_way[1:0] ;
7381
 
7382
assign  bist_way_e[0] = ~bist_way_enc_e[1] & ~bist_way_enc_e[0] ;
7383
assign  bist_way_e[1] = ~bist_way_enc_e[1] &  bist_way_enc_e[0] ;
7384
assign  bist_way_e[2] =  bist_way_enc_e[1] & ~bist_way_enc_e[0] ;
7385
assign  bist_way_e[3] =  bist_way_enc_e[1] &  bist_way_enc_e[0] ;
7386
 
7387
assign lsu_bist_rsel_way_e[3:0] = bist_way_e[3:0];
7388
 
7389
   wire lmq_l2fill_fp_din;
7390
assign    lmq_l2fill_fp_din =
7391
       dfq_byp_thrd_sel[0] & lmq0_l2fill_fpld |
7392
       dfq_byp_thrd_sel[1] & lmq1_l2fill_fpld |
7393
       dfq_byp_thrd_sel[2] & lmq2_l2fill_fpld |
7394
       dfq_byp_thrd_sel[3] & lmq3_l2fill_fpld ;
7395
 
7396 113 albert.wat
dffe_s #(1) lmq_l2fill_fp_ff (
7397 95 fafa1971
           .din (lmq_l2fill_fp_din),
7398
           .q   (lsu_l2fill_fpld_e),
7399
           .en  (dfq_byp_ff_en),
7400
           .clk (clk),
7401 113 albert.wat
           .se  (se),       `SIMPLY_RISC_SCANIN,          .so ()
7402 95 fafa1971
           );
7403
 
7404
   wire lmq_ncache_ld_din;
7405
assign    lmq_ncache_ld_din =
7406
       dfq_byp_thrd_sel[0] & lmq0_ncache_ld |
7407
       dfq_byp_thrd_sel[1] & lmq1_ncache_ld |
7408
       dfq_byp_thrd_sel[2] & lmq2_ncache_ld |
7409
       dfq_byp_thrd_sel[3] & lmq3_ncache_ld ;
7410
 
7411 113 albert.wat
dffe_s #(1) lmq_ncache_ld_ff (
7412 95 fafa1971
           .din (lmq_ncache_ld_din),
7413
           .q   (lsu_ncache_ld_e),
7414
           .en  (dfq_byp_ff_en),
7415
           .clk (clk),
7416 113 albert.wat
           .se  (se),       `SIMPLY_RISC_SCANIN,          .so ()
7417 95 fafa1971
           );
7418
 
7419
//lmq
7420
   wire [1:0]      lmq_ldfill_way_din;
7421
 
7422
mux4ds #(2) lmq_ldfill_way_mux (
7423
       .in0 ({lmq0_pcx_pkt_way[1:0]}),
7424
       .in1 ({lmq1_pcx_pkt_way[1:0]}),
7425
       .in2 ({lmq2_pcx_pkt_way[1:0]}),
7426
       .in3 ({lmq3_pcx_pkt_way[1:0]}),
7427
       .sel0(dfq_byp_thrd_sel[0]),
7428
       .sel1(dfq_byp_thrd_sel[1]),
7429
       .sel2(dfq_byp_thrd_sel[2]),
7430
       .sel3(dfq_byp_thrd_sel[3]),
7431
       .dout({lmq_ldfill_way_din[1:0]})
7432
);
7433
   wire [1:0]      lmq_ldfill_way;
7434
 
7435 113 albert.wat
dffe_s #(2)  lmq_ldfill_way_ff (
7436 95 fafa1971
           .din    ({lmq_ldfill_way_din[1:0]}),
7437
           .q      ({lmq_ldfill_way[1:0]}),
7438
           .en     (dfq_byp_ff_en),
7439
           .clk    (clk),
7440 113 albert.wat
           .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7441 95 fafa1971
           );
7442
 
7443
wire [1:0] dcache_fill_way_enc_e;
7444
 
7445
assign dcache_fill_way_enc_e[1:0] =
7446
{2{lsu_dc_iob_access_e}}               & lsu_dcache_iob_way_e[1:0] |
7447
{2{lsu_bist_e}}                        & bist_way_enc_e[1:0]       |
7448
{2{lsu_diagnstc_wr_src_sel_e}}         & lsu_diagnstc_wr_way_e[1:0]|
7449
{2{lsu_dfq_st_vld}}                    & lsu_st_way_e[1:0]         |
7450
{2{lsu_dfq_ld_vld}}                    & lmq_ldfill_way[1:0];
7451
 
7452
   assign lsu_dcache_fill_way_e[0] =   ~dcache_fill_way_enc_e[1] & ~dcache_fill_way_enc_e[0];
7453
   assign lsu_dcache_fill_way_e[1] =   ~dcache_fill_way_enc_e[1] &  dcache_fill_way_enc_e[0];
7454
   assign lsu_dcache_fill_way_e[2] =    dcache_fill_way_enc_e[1] & ~dcache_fill_way_enc_e[0];
7455
   assign lsu_dcache_fill_way_e[3] =    dcache_fill_way_enc_e[1] &  dcache_fill_way_enc_e[0];
7456
 
7457
//ld_rq_type
7458
 
7459
   wire [2:0]      lmq_ld_rq_type_din;
7460
 
7461
mux4ds #(3) lmq_ld_rq_type_mux (
7462
       .in0 ({lmq0_ld_rq_type[2:0]}),
7463
       .in1 ({lmq1_ld_rq_type[2:0]}),
7464
       .in2 ({lmq2_ld_rq_type[2:0]}),
7465
       .in3 ({lmq3_ld_rq_type[2:0]}),
7466
       .sel0(dfq_byp_thrd_sel[0]),
7467
       .sel1(dfq_byp_thrd_sel[1]),
7468
       .sel2(dfq_byp_thrd_sel[2]),
7469
       .sel3(dfq_byp_thrd_sel[3]),
7470
       .dout({lmq_ld_rq_type_din[2:0]})
7471
);
7472
 
7473 113 albert.wat
dffe_s #(3)  lmq_ld_rq_type_e_ff (
7474 95 fafa1971
           .din    ({lmq_ld_rq_type_din[2:0]}),
7475
           .q      ({lmq_ld_rq_type_e[2:0]}),
7476
           .en     (dfq_byp_ff_en),
7477
           .clk    (clk),
7478 113 albert.wat
           .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7479 95 fafa1971
           );
7480
 
7481
//================================================================
7482
wire    other_flush_pipe_w ;
7483
 
7484
assign  other_flush_pipe_w = tlu_early_flush_pipe2_w | (lsu_ttype_vld_m2 & lsu_inst_vld_w);
7485
assign  dctl_flush_pipe_w = other_flush_pipe_w | ifu_lsu_flush_w ;
7486
// Staged ifu_tlu_flush_m should be used !!
7487
assign  dctl_early_flush_w = (lsu_local_early_flush_g | tlu_early_flush_pipe2_w | ifu_lsu_flush_w) ;
7488
 
7489
//================================================================
7490
// dcfill size
7491
   wire dcfill_size_mx_sel_e;
7492
//bug6216/eco6624 
7493
assign  dcfill_size_mx_sel_e  =  lsu_dc_iob_access_e | lsu_diagnstc_wr_src_sel_e;
7494
 
7495
mux2ds  #(2)  dcache_wr_size_e_mux (
7496
              .in0(2'b11),
7497
              .in1(lsu_st_dcfill_size_e[1:0]),
7498
              .sel0(dcfill_size_mx_sel_e),
7499
              .sel1(~dcfill_size_mx_sel_e),
7500
              .dout(dcache_wr_size_e[1:0])
7501
);
7502
 
7503
 
7504
//assign  lsu_dcfill_data_mx_sel_e  =   (dcache_iob_wr_e | dcache_iob_rd_e | lsu_bist_wvld_e);   
7505
   wire dcfill_data_mx_sel_e_l;
7506
 
7507
bw_u1_nor3_8x  UZsize_dcfill_data_mx_sel_e_l (.a (dcache_iob_wr_e),
7508
                                              .b (dcache_iob_rd_e),
7509
                                              .c (lsu_bist_wvld_e),
7510
                                              .z (dcfill_data_mx_sel_e_l));
7511
 
7512
bw_u1_inv_30x  UZsize_dcfill_data_mx_sel_e   ( .a(dcfill_data_mx_sel_e_l), .z (lsu_dcfill_data_mx_sel_e));
7513
 
7514
//================================================================
7515
   wire [3:0] dfq_thread_e;
7516
   assign     dfq_thread_e[0] = ~lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0];
7517
   assign     dfq_thread_e[1] = ~lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0];
7518
   assign     dfq_thread_e[2] =  lsu_dfill_tid_e[1] & ~lsu_dfill_tid_e[0];
7519
   assign     dfq_thread_e[3] =  lsu_dfill_tid_e[1] &  lsu_dfill_tid_e[0];
7520
 
7521
   wire [3:0] dfq_byp_sel_e;
7522
   assign     dfq_byp_sel_e[0] = dfq_thread_e[0] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
7523
   assign     dfq_byp_sel_e[1] = dfq_thread_e[1] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
7524
   assign     dfq_byp_sel_e[2] = dfq_thread_e[2] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
7525
   assign     dfq_byp_sel_e[3] = dfq_thread_e[3] & dcfill_active_e & ~lsu_cpx_pkt_prefetch2;
7526
 
7527
wire    [3:0] lmq_byp_misc_sel_e ;
7528
 
7529
assign  lmq_byp_misc_sel_e[0] = ld_thrd_byp_sel_e[0]  |        // select for ldxa/raw.
7530
                                dfq_byp_sel_e[0]  ;              // select for dfq.
7531
assign  lmq_byp_misc_sel_e[1] = ld_thrd_byp_sel_e[1]  |        // select for ldxa/raw.
7532
                                dfq_byp_sel_e[1] ;               // select for dfq.
7533
assign  lmq_byp_misc_sel_e[2] = ld_thrd_byp_sel_e[2]  |        // select for ldxa/raw.
7534
                                dfq_byp_sel_e[2] ;               // select for dfq.
7535
assign  lmq_byp_misc_sel_e[3] = ld_thrd_byp_sel_e[3]  |
7536
                                dfq_byp_sel_e[3] ;
7537
 
7538
   wire [2:0] byp_misc_addr_e;
7539
assign byp_misc_addr_e[2:0] = (lmq_byp_misc_sel_e[0] ? lmq0_pcx_pkt_addr[2:0] : 3'b0) |
7540
                              (lmq_byp_misc_sel_e[1] ? lmq1_pcx_pkt_addr[2:0] : 3'b0) |
7541
                              (lmq_byp_misc_sel_e[2] ? lmq2_pcx_pkt_addr[2:0] : 3'b0) |
7542
                              (lmq_byp_misc_sel_e[3] ? lmq3_pcx_pkt_addr[2:0] : 3'b0) ;
7543
 
7544
   wire [1:0] byp_misc_sz_e;
7545
assign byp_misc_sz_e[1:0] = (lmq_byp_misc_sel_e[0] ? lmq0_byp_misc_sz[1:0] : 2'b0) |
7546
                            (lmq_byp_misc_sel_e[1] ? lmq1_byp_misc_sz[1:0] : 2'b0) |
7547
                            (lmq_byp_misc_sel_e[2] ? lmq2_byp_misc_sz[1:0] : 2'b0) |
7548
                            (lmq_byp_misc_sel_e[3] ? lmq3_byp_misc_sz[1:0] : 2'b0) ;
7549
 
7550
 
7551 113 albert.wat
dff_s #(5)  lmq_byp_misc_stgm (
7552 95 fafa1971
           .din    ({byp_misc_addr_e[2:0], byp_misc_sz_e[1:0]}),
7553
           .q      ({lsu_byp_misc_addr_m[2:0], lsu_byp_misc_sz_m[1:0]}),
7554
           .clk    (clk),
7555 113 albert.wat
           .se     (se),       `SIMPLY_RISC_SCANIN,          .so ()
7556 95 fafa1971
           );
7557
 
7558
endmodule
7559
 
7560
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.