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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [tlu_mmu_ctl.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: tlu_mmu_ctl.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
`else
24
`define SIMPLY_RISC_SCANIN .si()
25
`endif
26 95 fafa1971
///////////////////////////////////////////////////////////////////////
27
/*
28
//      Description:    MMU Control - I & D.
29
*/
30
////////////////////////////////////////////////////////////////////////
31
// Global header file includes
32
////////////////////////////////////////////////////////////////////////
33 113 albert.wat
`include        "sys.h" // system level definition file which contains the 
34 95 fafa1971
                                        // time scale definition
35
 
36
////////////////////////////////////////////////////////////////////////
37
// Local header file includes / local defines
38
////////////////////////////////////////////////////////////////////////
39
 
40
module tlu_mmu_ctl ( /*AUTOARG*/
41
   // Outputs
42
   dmmu_any_sfsr_wr, dmmu_sfsr_wr_en_l, dmmu_sfar_wr_en_l,
43
   immu_any_sfsr_wr, immu_sfsr_wr_en_l, immu_tsb_rd_en, tlu_tte_tag_g,
44
   tlu_dtlb_rw_index_vld_g,  tlu_dtlb_rw_index_g,
45
   tlu_dtlb_data_rd_g, tlu_dtlb_tag_rd_g, tlu_itlb_rw_index_vld_g,
46
   tlu_itlb_wr_vld_g, itlb_wr_vld_g, tlu_itlb_rw_index_g,
47
   tlu_itlb_data_rd_g, tlu_itlb_tag_rd_g, tlu_idtsb_8k_ptr,
48
   tlu_dtlb_invalidate_all_g, tlu_itlb_invalidate_all_g, tlu_slxa_thrd_sel,
49
   tlu_lsu_ldxa_tid_w2, tlu_itlb_dmp_vld_g,
50
   tlu_itlb_dmp_all_g, tlu_itlb_dmp_pctxt_g, tlu_itlb_dmp_actxt_g,
51
   tlu_itlb_dmp_nctxt_g, tlu_dtlb_dmp_vld_g, tlu_dtlb_dmp_all_g,
52
   tlu_dtlb_dmp_pctxt_g, tlu_dtlb_dmp_sctxt_g, tlu_dtlb_dmp_nctxt_g,
53
   tlu_dtlb_dmp_actxt_g, tlu_idtlb_dmp_thrid_g, tlu_dmp_key_vld_g,
54
   tlu_int_asi_load, tlu_int_asi_store, tlu_int_asi_thrid,
55
   tlu_int_asi_vld, tlb_access_rst_l,
56
   tlu_lsu_stxa_ack, tlu_lsu_stxa_ack_tid, mra_wr_ptr, mra_rd_ptr,
57
   mra_wr_vld, mra_rd_vld, tag_access_wdata_sel,
58
   tlu_admp_key_sel, mra_byte_wen,
59
   tlu_tte_wr_pid_g, tlu_lsu_ldxa_async_data_vld, tlu_tte_real_g,
60
   tlu_ldxa_l1mx1_sel, tlu_ldxa_l1mx2_sel, tlu_ldxa_l2mx1_sel,
61
   lsu_ifu_inj_ack, tlu_tlb_tag_invrt_parity,  tlu_tlb_data_invrt_parity,
62
   tlu_sun4r_tte_g, so, lsu_exu_ldxa_m, tlu_lng_ltncy_en_l,
63
   tlu_tag_access_ctxt_sel_m, tlu_tsb_rd_ps0_sel, tlu_tlb_access_en_l_d1,
64
   // Inputs
65
   ifu_lsu_ld_inst_e, ifu_lsu_st_inst_e, spu_tlu_rsrv_illgl_m,
66
   lsu_tlu_dmmu_miss_g,
67
   tlu_dtsb_split_w2, tlu_dtsb_size_w2, tlu_dtag_access_w2, tlu_itsb_split_w2,
68
   tlu_itsb_size_w2, tlu_ctxt_cfg_w2, lsu_tlu_st_rs3_data_g,
69
   lsu_tlu_st_rs3_data_b48_g, lsu_tlu_st_rs3_data_b12t0_g,
70
   ifu_tlu_immu_miss_m, ifu_lsu_thrid_s,
71
   ifu_lsu_alt_space_e, lsu_tlu_dtlb_done,
72
   ifu_tlu_itlb_done, lsu_tlu_tlb_asi_state_m, lsu_tlu_tlb_ldst_va_m,
73
   lsu_tlu_tlb_ld_inst_m, lsu_tlu_tlb_st_inst_m,
74
   lsu_tlu_tlb_access_tid_m, dmmu_sfsr_trp_wr,
75
   immu_sfsr_trp_wr, lsu_tlu_daccess_excptn_g,
76
   lsu_tlu_daccess_prot_g,
77
   lsu_pid_state0, lsu_pid_state1, lsu_pid_state2, lsu_pid_state3,
78
   lsu_tlu_nucleus_ctxt_m, lsu_tlu_tte_pg_sz_g, ifu_lsu_error_inj,
79
   ifu_tlu_alt_space_d, ifu_lsu_imm_asi_d,
80
   ifu_lsu_memref_d, lsu_asi_reg0, lsu_asi_reg1, lsu_asi_reg2,
81
   lsu_asi_reg3, exu_mmu_early_va_e, rclk, arst_l, grst_l,
82
   si,se,ifu_tlu_flush_m,tlu_mmu_early_flush_pipe_w,lsu_mmu_early_flush_w,
83
   tlu_tag_access_ctxt_g, tlu_lsu_tl_zero,
84
   exu_tlu_va_oor_jl_ret_m, exu_tlu_va_oor_m, tlu_lsu_pstate_am, tlu_tsb_base_w2_d1,
85
   lsu_mmu_flush_pipe_w, ifu_tlu_inst_vld_m, ifu_mmu_trap_m, ffu_tlu_ill_inst_m,
86
   exu_lsu_priority_trap_m, sehold, rst_tri_en, tlu_itag_acc_sel_g, lsu_mmu_defr_trp_taken_g,
87
   ifu_tlu_priv_violtn_m
88
   ) ;
89
 
90
 
91
/*AUTOINPUT*/
92
// Beginning of automatic inputs (from unused autoinst inputs)
93
// End of automatics
94
 
95
input                   ifu_lsu_ld_inst_e;      // inst_is_load (src-decode)
96
input                   ifu_lsu_st_inst_e;      // inst is store (src-decode)
97
input                   lsu_tlu_dmmu_miss_g ;   // ld/st misses in dtlb.
98
input                   spu_tlu_rsrv_illgl_m ;
99
 
100
input                   tlu_itag_acc_sel_g ;
101
input                   lsu_mmu_defr_trp_taken_g ;
102
 
103
// The timing on these signals can be changed to any earlier stage.
104
// For both SPARC_HPV_EN and non-SPARC_HPV_EN - tsb,tag-access 
105
// dtsb maps to ps0. itsb maps to ps1.
106
input  [47:13]          tlu_tsb_base_w2_d1 ;
107
//input  [47:13]                tlu_dtsb_base_w2 ;
108
input                   tlu_dtsb_split_w2 ;
109
input  [3:0]             tlu_dtsb_size_w2 ;
110
input  [47:13]          tlu_dtag_access_w2 ;    // used to represent both i/d.
111
//input  [47:13]                tlu_itsb_base_w2 ;
112
input                   tlu_itsb_split_w2 ;
113
input  [3:0]             tlu_itsb_size_w2 ;
114
 
115
// For SPARC_HPV_EN - BEGIN
116
input  [5:0]             tlu_ctxt_cfg_w2 ;       // i/d context zero/non-zero config.
117
//input                         tlu_tag_access_nctxt_g ;// tag-access contains nucleus context.
118
// For SPARC_HPV_EN - END
119
 
120
input   [62:61]         lsu_tlu_st_rs3_data_g ;     // Page Size (1,0) bits of TTE
121
input                   lsu_tlu_st_rs3_data_b48_g ; // Page Size (2)   bits of TTE
122
//input   [2:0]           lsu_tlu_st_rs3_data_b10t8_g ; // ps1 of ctxt-cfg
123
input   [12:0]          lsu_tlu_st_rs3_data_b12t0_g ;
124
//input   [2:0]           lsu_tlu_st_rs3_data_b2t0_g ; // sun4v tte size
125
input                   ifu_tlu_immu_miss_m ;
126
input   [1:0]           ifu_lsu_thrid_s ;        // Thread id.
127
input                   ifu_lsu_alt_space_e ;   // alt-space access
128
input                   lsu_tlu_dtlb_done ; // dtlb rd/wr/dmp complete
129
input                   ifu_tlu_itlb_done ; // itlb rd/wr/dmp complete
130
//input                 int_tlu_asi_data_vld ;  // asi return vld for int blk
131
//input                 int_tlu_ldxa_illgl_va ; // int asi has illgl va
132
input  [7:0]             lsu_tlu_tlb_asi_state_m ;
133
input  [10:0]           lsu_tlu_tlb_ldst_va_m ;
134
input                   lsu_tlu_tlb_ld_inst_m ;
135
input                   lsu_tlu_tlb_st_inst_m ;
136
input  [1:0]             lsu_tlu_tlb_access_tid_m ;
137
input                   ifu_tlu_flush_m ;
138
input                   tlu_mmu_early_flush_pipe_w ;
139
input                   lsu_mmu_early_flush_w ;
140
input   [3:0]    dmmu_sfsr_trp_wr ;
141
input   [3:0]    immu_sfsr_trp_wr ;
142
//input                         tlu_inst_vld_m ;        // qualified inst vld
143
input                   lsu_tlu_daccess_excptn_g ; // data access exception 
144
input                   lsu_tlu_daccess_prot_g ;// data access protection
145
                                                // obsolete with SPARC_HPV_EN !!!
146
//input                 lsu_tlu_asi_rd_unc ;    // uncorrectable error for tlb rd
147
input   [2:0]    lsu_pid_state0 ;        // pid thread0 ; global use
148
input   [2:0]    lsu_pid_state1 ;        // pid thread1 ; global use
149
input   [2:0]    lsu_pid_state2 ;        // pid thread2 ; global use
150
input   [2:0]    lsu_pid_state3 ;        // pid thread3 ; global use
151
 
152
input                   lsu_tlu_nucleus_ctxt_m ;// access is nucleus context
153
input   [2:0]            lsu_tlu_tte_pg_sz_g ;   // page-size of tte 
154
 
155
input   [3:0]           ifu_lsu_error_inj ;     // inject parity error into tlb
156
 
157
// BEGIN - MMU_ASI_RD_CHANGE
158
// !! early va required.
159
input                   ifu_tlu_alt_space_d ;   // alt space access - new;_e exists
160
//input                 ifu_lsu_imm_asi_vld_d ; // imm asi is vld - current
161
input   [8:0]            ifu_lsu_imm_asi_d ;     // imm asi - current
162
input                   ifu_lsu_memref_d;       // ld/st - prefer ld_inst_e;
163
input   [7:0]    lsu_asi_reg0 ;          // asi state - thread0
164
input   [7:0]    lsu_asi_reg1 ;          // asi state - thread1
165
input   [7:0]    lsu_asi_reg2 ;          // asi state - thread2
166
input   [7:0]    lsu_asi_reg3 ;          // asi state - thread3
167
//input [1:0]           ifu_tlu_thrid_d ;       // thread id
168
input   [7:0]            exu_mmu_early_va_e;     // early va from exu
169
// END - MMU_ASI_RD_CHANGE
170
 
171
input [12:0]          tlu_tag_access_ctxt_g ;
172
 
173
input [3:0] tlu_lsu_tl_zero;   // trap level is zero.
174
//input           exu_tlu_ttype_vld_m;    // exu src ttype vld
175
input           exu_tlu_va_oor_jl_ret_m;
176
input           exu_tlu_va_oor_m;
177
input [3:0] tlu_lsu_pstate_am;
178
 
179
input           lsu_mmu_flush_pipe_w ;
180
input           ifu_tlu_inst_vld_m ;
181
input           ifu_mmu_trap_m ;
182
input           ffu_tlu_ill_inst_m ;
183
input           exu_lsu_priority_trap_m ; // fill/ue
184
input           ifu_tlu_priv_violtn_m ;
185
 
186
input           rclk ;
187
input           arst_l, grst_l;
188
input           si,se;
189
input           sehold ;
190
input           rst_tri_en ;
191
 
192
/*AUTOOUTPUT*/
193
// Beginning of automatic outputs (from unused autoinst outputs)
194
// End of automatics
195
 
196
output                  dmmu_any_sfsr_wr ;
197
output  [3:0]            dmmu_sfsr_wr_en_l ;
198
output  [3:0]            dmmu_sfar_wr_en_l ;
199
//output        [3:0]           dmmu_tsb_wr_en ;
200
//output        [3:0]           dmmu_tsb_rd_en ;
201
//output        [3:0]           dmmu_tag_access_wr_en ;
202
//output        [3:0]           dmmu_tag_access_rd_en ;
203
//output                        dmmu_tag_read_en ; 
204
 
205
output                  immu_any_sfsr_wr ;
206
output  [3:0]            immu_sfsr_wr_en_l ;
207
//output        [3:0]           immu_tsb_wr_en ;
208
output  [3:0]            immu_tsb_rd_en ;
209
//output        [3:0]           immu_tag_access_wr_en ;
210
//output        [3:0]           immu_tag_access_rd_en ;
211
//output                        immu_tag_read_en ; 
212
 
213
// tlb/itlb related control can potentially be
214
// made g-stage.
215
output  [2:0]            tlu_tte_tag_g ;
216
output                  tlu_dtlb_rw_index_vld_g ;
217
output  [5:0]            tlu_dtlb_rw_index_g ;
218
output                  tlu_dtlb_data_rd_g ;
219
output                  tlu_dtlb_tag_rd_g ;
220
output                  tlu_itlb_rw_index_vld_g ;
221
output                  tlu_itlb_wr_vld_g ;
222
output                  itlb_wr_vld_g ;
223
output  [5:0]            tlu_itlb_rw_index_g ;
224
output                  tlu_itlb_data_rd_g ;
225
output                  tlu_itlb_tag_rd_g ;
226
output  [47:0]           tlu_idtsb_8k_ptr ;      // maps to ps0/ps1 ptr. require only 1.
227
 
228
output                  tlu_dtlb_invalidate_all_g ;
229
output                  tlu_itlb_invalidate_all_g ;
230
 
231
output  [3:0]           tlu_slxa_thrd_sel ;
232
 
233
output  [1:0]            tlu_lsu_ldxa_tid_w2 ;
234
 
235
output                  tlu_itlb_dmp_vld_g ;
236
output                  tlu_itlb_dmp_all_g ;
237
output                  tlu_itlb_dmp_pctxt_g ;
238
output                  tlu_itlb_dmp_actxt_g ;
239
output                  tlu_itlb_dmp_nctxt_g ;
240
output                  tlu_dtlb_dmp_vld_g ;
241
output                  tlu_dtlb_dmp_all_g ;
242
output                  tlu_dtlb_dmp_pctxt_g ;
243
output                  tlu_dtlb_dmp_sctxt_g ;
244
output                  tlu_dtlb_dmp_nctxt_g ;
245
output                  tlu_dtlb_dmp_actxt_g ;
246
output  [1:0]            tlu_idtlb_dmp_thrid_g ;
247
output  [4:0]           tlu_dmp_key_vld_g ;
248
output                  tlu_int_asi_load;
249
output                  tlu_int_asi_store;
250
output  [1:0]            tlu_int_asi_thrid;
251
output                  tlu_int_asi_vld;
252
//output                        tlb_access_en_l ;
253
output                  tlb_access_rst_l ;
254
output                  tlu_lsu_stxa_ack ;         // write to tlb is complete.
255
output   [1:0]           tlu_lsu_stxa_ack_tid ;
256
output   [3:0]          mra_wr_ptr ;    // wr ptr for mra
257
output   [3:0]          mra_rd_ptr ;    // thrd id for rd.
258
output                  mra_wr_vld ;    // write pointer vld
259
output                  mra_rd_vld ;    // read vld
260
output   [19:0]          mra_byte_wen ;
261
output   [2:0]           tag_access_wdata_sel ;
262
output                  tlu_admp_key_sel ;
263
//output                        tlu_mmu_sync_data_excp_g ;      // sync asi related data excp
264
//output                        tlu_lsu_dtlb_rd_unc ;           // unc error for tlb rd
265
 
266
//output   [3:0]          tlu_dldxa_mx2_sel ;           // obsolete for SPARC_HPV_EN
267
//output   [2:0]          tlu_dldxa_mx3_sel ;           // obsolete for SPARC_HPV_EN
268
//output   [2:0]          tlu_dldxa_fmx_sel ;           // obsolete for SPARC_HPV_EN
269
//output   [3:0]          tlu_ildxa_mx1_sel ;           // obsolete for SPARC_HPV_EN
270
//output   [2:0]          tlu_ildxa_fmx_sel ;           // obsolete for SPARC_HPV_EN
271
 
272
output   [2:0]           tlu_tte_wr_pid_g ;      // thread selected pid
273
output                  tlu_lsu_ldxa_async_data_vld ;   // tlu_lsu_ldxa_data_vld is for async op.
274
 
275
output                  tlu_tte_real_g ;                // tte is real
276
 
277
output  [3:0]    tlu_ldxa_l1mx1_sel ;    // mmu ldxa level1 mx1 sel
278
output  [3:0]    tlu_ldxa_l1mx2_sel ;    // mmu ldxa level1 mx2 sel
279
output  [2:0]    tlu_ldxa_l2mx1_sel ;    // mmu ldxa level2 mx1 sel
280
 
281
output  [3:0]           lsu_ifu_inj_ack ;       // ack for tlb error injection.
282
output                  tlu_tlb_tag_invrt_parity ;      // invert parity on write tag.
283
output                  tlu_tlb_data_invrt_parity ;     // invert parity on write data.
284
 
285
output                  tlu_sun4r_tte_g ;       // sun4r vs. sun4v tte.
286
 
287
output                  lsu_exu_ldxa_m ;
288
 
289
output                  tlu_lng_ltncy_en_l ;
290
 
291
output  [2:0]            tlu_tag_access_ctxt_sel_m ;
292
 
293
output                  tlu_tsb_rd_ps0_sel ;
294
 
295
output                  tlu_tlb_access_en_l_d1 ;
296
 
297
output                  so ;
298
 
299
/*AUTOWIRE*/
300
// Beginning of automatic wires (for undeclared instantiated-module outputs)
301 113 albert.wat
`ifdef SIMPLY_RISC_TWEAKS
302
wire alt_space_e;
303
`endif
304 95 fafa1971
// End of automatics
305
 
306
reg                     dmmu_invalidate_all_en_m ;
307
reg                     immu_invalidate_all_en_m ;
308
reg     dmmu_decode_asi58_e ;
309
reg     immu_decode_asi50_e ;
310
reg     dmmu_8k_ptr_e,dmmu_64k_ptr_e,dmmu_direct_ptr_e ;
311
reg     immu_8k_ptr_e,immu_64k_ptr_e;
312
reg     dmmu_zctxt_ps0_tsb_e, dmmu_zctxt_ps1_tsb_e ;
313
reg     dmmu_nzctxt_ps0_tsb_e, dmmu_nzctxt_ps1_tsb_e ;
314
reg     dmmu_zctxt_cfg_e, dmmu_nzctxt_cfg_e ;
315
reg     immu_zctxt_ps0_tsb_e, immu_zctxt_ps1_tsb_e ;
316
reg     immu_nzctxt_ps0_tsb_e, immu_nzctxt_ps1_tsb_e ;
317
reg     immu_zctxt_cfg_e, immu_nzctxt_cfg_e ;
318
 
319
reg                     dmmu_data_in_en_m,dmmu_data_access_en_m;
320
reg                     dmmu_tag_read_en_m,dmmu_demap_en_m;
321
 
322
wire                    sehold_d1 ;
323
wire                    tlb_access_en_l ;
324
wire                    dmmu_sync_illgl_va_g ;
325
wire                    dmmu_async_supported_asi,dmmu_async_illgl_va_g ;
326
wire                    immu_sync_illgl_va_g ;
327
wire                    immu_async_supported_asi,immu_async_illgl_va_g ;
328
wire                    ld_inst_m,st_inst_m ;
329
wire                    ld_inst_g,st_inst_g ;
330
wire [3:0]               tsb_size ;
331
wire                    tsb_split ;
332
//wire [47:13]          tsb_base ;
333
wire [47:13]            tag_access ;
334
/*wire  tsb_sz_8k_b0_mx1_out,tsb_sz_8k_b1_mx1_out,tsb_sz_8k_b2_mx1_out,tsb_sz_8k_b3_mx1_out;
335
wire    tsb_sz_8k_b4_mx1_out,tsb_sz_8k_b5_mx1_out,tsb_sz_8k_b6_mx1_out,tsb_sz_8k_b7_mx1_out;
336
wire    tsb_sz_8k_b0_mx2_out,tsb_sz_8k_b1_mx2_out,tsb_sz_8k_b2_mx2_out,tsb_sz_8k_b3_mx2_out;
337
wire    tsb_sz_8k_b4_mx2_out,tsb_sz_8k_b5_mx2_out,tsb_sz_8k_b6_mx2_out,tsb_sz_8k_b7_mx2_out;
338
wire    tsb_sz_8k_b0_mx3_out,tsb_sz_8k_b1_mx3_out,tsb_sz_8k_b2_mx3_out,tsb_sz_8k_b3_mx3_out;
339
wire    tsb_sz_8k_b4_mx3_out,tsb_sz_8k_b5_mx3_out,tsb_sz_8k_b6_mx3_out,tsb_sz_8k_b7_mx3_out;
340
wire    tsb_sz_64k_b0_mx1_out,tsb_sz_64k_b1_mx1_out,tsb_sz_64k_b2_mx1_out,tsb_sz_64k_b3_mx1_out;
341
wire    tsb_sz_64k_b4_mx1_out,tsb_sz_64k_b5_mx1_out,tsb_sz_64k_b6_mx1_out,tsb_sz_64k_b7_mx1_out;
342
wire    tsb_sz_64k_b0_mx2_out,tsb_sz_64k_b1_mx2_out,tsb_sz_64k_b2_mx2_out,tsb_sz_64k_b3_mx2_out;
343
wire    tsb_sz_64k_b4_mx2_out,tsb_sz_64k_b5_mx2_out,tsb_sz_64k_b6_mx2_out ;
344
wire    tsb_sz_64k_b0_mx3_out,tsb_sz_64k_b1_mx3_out,tsb_sz_64k_b2_mx3_out,tsb_sz_64k_b3_mx3_out;
345
wire    tsb_sz_64k_b4_mx3_out ;*/
346
wire    dtlb_rw_index_vld_g,dtlb_wr_vld_g ;
347
wire            dmmu_data_in_wr_en, dmmu_data_access_wr_en ;
348
wire            dmmu_tag_read_rd_en, dmmu_data_access_rd_en ;
349
wire            immu_data_in_wr_en, immu_data_access_wr_en ;
350
wire            immu_data_access_rd_en, immu_tag_read_rd_en ;
351
wire            itlb_rw_index_vld_g,itlb_wr_vld_g;
352
wire            tlu_ldxa_data_vld ;
353
wire    tlu_dldxa_data_vld ;
354
wire    [1:0]    thrid_d,thrid_e,thrid_m,thrid_g ;
355
wire            thread0_sel_g, thread1_sel_g ;
356
wire            thread2_sel_g, thread3_sel_g ;
357
wire            alt_space_m, alt_space_g ;
358
wire            immu_miss_g;
359
wire            ddemap_by_page,ddemap_by_ctxt,ddemap_all;
360
wire            idemap_by_page,idemap_by_ctxt,idemap_all;
361
wire            demap_pctxt,demap_sctxt,demap_nctxt ;
362
//wire          lsu_tlu_page_ebit_g ;
363
wire            ddemap_vld, idemap_vld ;
364
wire    [2:0]   tlu_tte_tag_g ;
365
wire            demap_resrv ;
366
wire    itlb_wr_pend,itlb_data_rd_pend,itlb_tag_rd_pend ;
367
wire    dtlb_wr_pend,dtlb_data_rd_pend,dtlb_tag_rd_pend ;
368
wire    tlb_access_en ;
369
wire    tlb_access_rst ;
370
wire    dmra_wr_g, imra_wr_g ;
371
wire                    dmmu_data_in_en, dmmu_data_access_en, dmmu_tag_read_en, dmmu_demap_en ;
372
wire                    immu_data_in_en, immu_data_access_en, immu_tag_read_en, immu_demap_en ;
373
wire    immu_invalidate_all_en,dmmu_invalidate_all_en ;
374
wire    tlb_wr_vld_g ;
375
wire    tlb_admp_en, tlb_admp_rst, tlb_wr_rst ;
376
wire    tlb_admp_mode,tlb_write_mode ;
377
wire    tlb_ldst_inst_m ;
378
wire    tlb_admp_mode_d1 ;
379
wire    itlb_wr_vld_unmsked,dtlb_wr_vld_unmsked;
380
wire    idemap_pend, ddemap_pend ;
381
wire    itlb_tag_rd_en, dtlb_tag_rd_en ;
382
wire    [3:0]    dsfsr_asi_wr_en ;
383
wire    [3:0]    isfsr_asi_wr_en ;
384
wire    [10:3]  tlb_ldst_va_g ;
385
wire            tlb_ld_inst_g,tlb_st_inst_g ;
386
wire            tlb_ld_inst_unflushed,tlb_st_inst_unflushed ;
387
wire    [1:0]    tlb_access_tid_g ;
388
wire            inst_vld_g ;
389
wire    st_inst_unflushed, ld_inst_unflushed ;
390
wire    imra_lng_lat_rd,dmra_lng_lat_rd ;
391
wire    iside_mra_access_rd, iside_mra_access_wr ;
392
wire    [1:0]    mra_raccess_tid ;
393
//wire  dmmu_sync_rd_only_asi_g ;
394
//wire  immu_sync_rd_only_asi_g ;
395
wire    dptr0_pg64k_en,dptr1_pg64k_en,dptr2_pg64k_en,dptr3_pg64k_en;
396
wire    dptr0_pg64k_vld,dptr1_pg64k_vld,dptr2_pg64k_vld,dptr3_pg64k_vld;
397
//wire  dmmu_direct_ptr_rd_en ;
398
wire    tlu_dtlb_rd_done ;
399
wire    dmmu_ctxt_cfg_en, immu_ctxt_cfg_en ;
400
//wire  dmmu_ctxt_cfg_rd_en ;
401
wire    dacc_prot_ps1_match ;
402
wire    tacc_nctxt, itacc_nctxt, dtacc_nctxt ;  // for in-pipe access
403
wire    tacc_anctxt, itacc_anctxt, dtacc_anctxt ;// for async access
404
wire    thread0_async_g,thread1_async_g,thread2_async_g ;
405
wire    sun4r_tte_g ;
406
wire    dmmu_decode_asi58_m, immu_decode_asi50_m ;
407
wire    dmmu_zctxt_ps0_tsb_m, dmmu_zctxt_ps1_tsb_m,
408
        dmmu_nzctxt_ps0_tsb_m, dmmu_nzctxt_ps1_tsb_m,
409
        dmmu_zctxt_cfg_m, dmmu_nzctxt_cfg_m,
410
        immu_zctxt_ps0_tsb_m, immu_zctxt_ps1_tsb_m,
411
        immu_nzctxt_ps0_tsb_m, immu_nzctxt_ps1_tsb_m,
412
        immu_zctxt_cfg_m, immu_nzctxt_cfg_m ;
413
wire    dmmu_sync_fsr_en, dmmu_sync_far_en,
414
        dmmu_zctxt_ps0_tsb_en, dmmu_zctxt_ps1_tsb_en,
415
        dmmu_nzctxt_ps0_tsb_en, dmmu_nzctxt_ps1_tsb_en,
416
        dmmu_zctxt_cfg_en, dmmu_nzctxt_cfg_en,
417
        immu_sync_fsr_en,
418
        immu_zctxt_ps0_tsb_en, immu_zctxt_ps1_tsb_en,
419
        immu_nzctxt_ps0_tsb_en, immu_nzctxt_ps1_tsb_en,
420
        immu_zctxt_cfg_en, immu_nzctxt_cfg_en ;
421
wire    dmmu_tag_target_en_m,dmmu_tag_access_en_m;
422
wire    immu_tag_target_en_m,immu_tag_access_en_m;
423
wire    dmmu_tag_access_en;
424
wire    immu_tag_access_en;
425
wire    dmmu_8k_ptr_en_m,dmmu_64k_ptr_en_m,dmmu_direct_ptr_en_m ;
426
wire    immu_8k_ptr_en_m,immu_64k_ptr_en_m ;
427
wire    dmmu_sync_fsr_en_m, dmmu_sync_far_en_m,
428
        dmmu_zctxt_ps0_tsb_en_m, dmmu_zctxt_ps1_tsb_en_m,
429
        dmmu_nzctxt_ps0_tsb_en_m, dmmu_nzctxt_ps1_tsb_en_m,
430
        dmmu_zctxt_cfg_en_m, dmmu_nzctxt_cfg_en_m,
431
        immu_sync_fsr_en_m,
432
        immu_zctxt_ps0_tsb_en_m, immu_zctxt_ps1_tsb_en_m,
433
        immu_nzctxt_ps0_tsb_en_m, immu_nzctxt_ps1_tsb_en_m,
434
        immu_zctxt_cfg_en_m, immu_nzctxt_cfg_en_m ;
435
wire    thread0_d,thread1_d,thread2_d,thread3_d;
436
wire    thread0_e, thread1_e, thread2_e, thread3_e ;
437
wire [7:0]       asi_state_d, asi_state_e ;
438
wire    memref_e,memref_m ;
439
wire [7:0] early_va_m ;
440
wire    idmra_rd_d ;
441
wire idmra_nzctxt_rd_d ;
442
wire idmra_fault_rd_d ;
443
wire    dmmu_tsb_en_m, dmmu_ctxt_cfg_en_m ;
444
wire    immu_tsb_en_m, immu_ctxt_cfg_en_m ;
445
wire    tlu_ildxa_data_vld ;
446
wire    dmmu_direct_8kptr_sel_g ;       // direct ptr should select 8k ptr
447
 
448
        wire    dmmu_tsb_en ;
449
        wire    immu_tsb_en ;
450
 
451
wire    mra_field1_en, mra_field2_en ;
452
wire    mra_field3_en, mra_field4_en ;
453
 
454
//=========================================================================================
455
//      RESET/CLK
456
//=========================================================================================
457
 
458
    wire       clk;
459
    assign     clk = rclk;
460
 
461
    wire       rst_l;
462
 
463
    dffrl_async rstff(.din (grst_l),
464
                      .q   (rst_l),
465 113 albert.wat
                      .clk (clk), .se(se), `SIMPLY_RISC_SCANIN, .so(),
466 95 fafa1971
                      .rst_l (arst_l));
467
 
468
 
469
//=========================================================================================
470
//      Early Flush Generation
471
//=========================================================================================
472
 
473
 
474
 
475
 
476
wire    ifu_tlu_flush_w ;
477 113 albert.wat
dff_s  #(1) stg_w (
478 95 fafa1971
        .din    (ifu_tlu_flush_m),
479
        .q      (ifu_tlu_flush_w),
480
        .clk    (clk),
481 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
482 95 fafa1971
) ;
483
 
484
wire    local_flush_w ;
485
 
486
assign  local_flush_w =
487
        ifu_tlu_flush_w                 |       // ifu flush 
488
        lsu_mmu_defr_trp_taken_g        |       // defr trp 
489
        tlu_mmu_early_flush_pipe_w      |       // tlu flush
490
        lsu_mmu_early_flush_w           ;       // lsu early flush
491
 
492
wire    flush_w_inst_vld_m ;
493
assign  flush_w_inst_vld_m =
494
        ifu_tlu_inst_vld_m &
495
        ~(lsu_mmu_flush_pipe_w & (thrid_m[1:0] == thrid_g[1:0])) ; // really lsu_flush_pipe_w
496
 
497 113 albert.wat
dff_s  stgw_ivld (
498 95 fafa1971
        .din    (flush_w_inst_vld_m),
499
        .q      (inst_vld_g),
500
        .clk    (clk),
501 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
502 95 fafa1971
        );
503
 
504
// Bug 4183
505
wire    priority_squash_m, priority_squash_g ;
506
assign  priority_squash_m =
507
ifu_mmu_trap_m | ffu_tlu_ill_inst_m | exu_lsu_priority_trap_m |  spu_tlu_rsrv_illgl_m ;
508
 
509
wire    trp_vld_m,trp_vld_g ;
510
assign  trp_vld_m = flush_w_inst_vld_m & ~priority_squash_m ;
511
 
512 113 albert.wat
dff_s  #(2) sqshstgw (
513 95 fafa1971
        .din    ({priority_squash_m,trp_vld_m}),
514
        .q      ({priority_squash_g,trp_vld_g}),
515
        .clk    (clk),
516 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
517 95 fafa1971
) ;
518
 
519
//=========================================================================================
520
//      Staging
521
//=========================================================================================
522
 
523 113 albert.wat
dff_s  #(2) stg_d (
524 95 fafa1971
        .din    (ifu_lsu_thrid_s[1:0]),
525
        .q      (thrid_d[1:0]),
526
        .clk    (clk),
527 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
528 95 fafa1971
        );
529
 
530 113 albert.wat
dff_s  #(2) stg_e (
531 95 fafa1971
        .din    (thrid_d[1:0]),
532
        .q      (thrid_e[1:0]),
533
        .clk    (clk),
534 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
535 95 fafa1971
        );
536
 
537 113 albert.wat
dff_s  #(5) stg_m (
538 95 fafa1971
        .din    ({ifu_lsu_ld_inst_e,ifu_lsu_st_inst_e,
539
                thrid_e[1:0],ifu_lsu_alt_space_e}),
540
        .q      ({ld_inst_m,st_inst_m,thrid_m[1:0],alt_space_m}),
541
        .clk    (clk),
542 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
543 95 fafa1971
        );
544
 
545 113 albert.wat
dff_s  #(6) stg_g (
546 95 fafa1971
        .din    ({ld_inst_m,st_inst_m,thrid_m[1:0],alt_space_m,ifu_tlu_immu_miss_m}),
547
        .q      ({ld_inst_unflushed,st_inst_unflushed,thrid_g[1:0],alt_space_g,immu_miss_g}),
548
        .clk    (clk),
549 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
550 95 fafa1971
        );
551
 
552
// reads are terminated for illegal va case.
553
assign  ld_inst_g = ld_inst_unflushed & inst_vld_g & ~local_flush_w ;
554
//assign        ld_inst_g = ld_inst_unflushed & inst_vld_g & ~(dmmu_sync_illgl_va_g | immu_sync_illgl_va_g) & ;
555
// writes are terminated for illegal va case.
556
assign  st_inst_g = st_inst_unflushed & inst_vld_g & ~local_flush_w &
557
                        ~(dmmu_sync_illgl_va_g | immu_sync_illgl_va_g) ;
558
//assign        st_inst_g = st_inst_unflushed & inst_vld_g & ~(dmmu_sync_illgl_va_g | immu_sync_illgl_va_g);
559
 
560
assign  thread0_sel_g =  ~thrid_g[1] & ~thrid_g[0] ;
561
assign  thread1_sel_g =  ~thrid_g[1] &  thrid_g[0] ;
562
assign  thread2_sel_g =   thrid_g[1] & ~thrid_g[0] ;
563
assign  thread3_sel_g =   thrid_g[1] &  thrid_g[0] ;
564
 
565
assign tlu_slxa_thrd_sel[0] = ~thrid_m[1] & ~thrid_m[0] ;
566
assign tlu_slxa_thrd_sel[1] = ~thrid_m[1] &  thrid_m[0] ;
567
assign tlu_slxa_thrd_sel[2] =  thrid_m[1] & ~thrid_m[0] ;
568
assign tlu_slxa_thrd_sel[3] =  thrid_m[1] &  thrid_m[0] ;
569
 
570
/*dff stgivld_g (
571
        .din    (tlu_inst_vld_m),
572
        .q      (inst_vld_g),
573
        .clk    (clk),
574 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
575 95 fafa1971
        ); */
576
 
577
//=========================================================================================
578
//      ASI RD DP MUX SELECT
579
//=========================================================================================
580
 
581
// qualification with vld not required as this dp is used by synchronous ops only
582
// Need to be made non zero-hot in functional mode
583
 
584
// Decode of bits va[5:4] to distinguish reads.  
585
wire va_54_eq_0,va_54_eq_1,va_54_eq_2,va_54_eq_3 ;
586
wire    [2:0]    ldxa_l1mx1_sel_d1 ;
587
assign va_54_eq_0 = (~early_va_m[5] & ~early_va_m[4]) ;
588
assign va_54_eq_1 = (~early_va_m[5] &  early_va_m[4]) ;
589
assign va_54_eq_2 = ( early_va_m[5] & ~early_va_m[4]) ;
590
assign va_54_eq_3 = ( early_va_m[5] &  early_va_m[4]) ;
591
 
592
// i/d tag-target
593
// Extend for MacroTest Control.
594
assign  tlu_ldxa_l1mx1_sel[0] =
595
((((dmmu_decode_asi58_m | immu_decode_asi50_m) & va_54_eq_0) & ~sehold_d1) | rst_tri_en) |
596
(ldxa_l1mx1_sel_d1[0] & sehold_d1) ;
597
assign  tlu_ldxa_l1mx1_sel[1] =
598
((dmmu_zctxt_ps0_tsb_e | dmmu_nzctxt_ps0_tsb_e |
599
immu_zctxt_ps0_tsb_e | immu_nzctxt_ps0_tsb_e) & ~sehold_d1 & ~rst_tri_en) |
600
(ldxa_l1mx1_sel_d1[1] & sehold_d1) ;
601
assign  tlu_ldxa_l1mx1_sel[2] =
602
((dmmu_zctxt_ps1_tsb_e | dmmu_nzctxt_ps1_tsb_e |
603
immu_zctxt_ps1_tsb_e | immu_nzctxt_ps1_tsb_e) & ~sehold_d1 & ~rst_tri_en) |
604
(ldxa_l1mx1_sel_d1[2] & sehold_d1) ;
605
 
606
 
607
 
608
// Extend flops to hold selects for MacroTest of MRA.
609
wire [2:0] ldxa_l1mx1_sel_out ;
610 113 albert.wat
dff_s #(3)   l1mx1s_stgd1(
611 95 fafa1971
        .din    (tlu_ldxa_l1mx1_sel[2:0]),
612
        .q      (ldxa_l1mx1_sel_out[2:0]),
613
        .clk    (clk),
614 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
615 95 fafa1971
        );
616
 
617
// scan protection.
618
assign  ldxa_l1mx1_sel_d1[0] = ldxa_l1mx1_sel_out[0] ;
619
assign  ldxa_l1mx1_sel_d1[1] = ldxa_l1mx1_sel_out[1] & ~rst_tri_en ;
620
assign  ldxa_l1mx1_sel_d1[2] = ldxa_l1mx1_sel_out[2] & ~rst_tri_en ;
621
 
622
wire    sehold_out ;
623 113 albert.wat
dff_s #(1)   seh_d1 (
624 95 fafa1971
        .din    (sehold),
625
        .q      (sehold_out),
626
        .clk    (clk),
627 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
628 95 fafa1971
        );
629
 
630
assign  sehold_d1 = sehold_out & ~rst_tri_en ;
631
 
632
// i/d tag-access
633
assign  tlu_ldxa_l1mx1_sel[3] =  ~|tlu_ldxa_l1mx1_sel[2:1];
634
wire    ldxa_l1mx1_sel3;
635
// * read timing change.
636
assign  ldxa_l1mx1_sel3 =
637
(dmmu_decode_asi58_m | immu_decode_asi50_m) & va_54_eq_3 & ~rst_tri_en ;
638
 
639
// d sync-fsr
640
// * read timing change.
641
wire    dmmu_sync_fsr_m_sel,dmmu_sync_far_m_sel,immu_sync_fsr_m_sel;
642
assign  dmmu_sync_fsr_m_sel     = (dmmu_decode_asi58_m & va_54_eq_1) | rst_tri_en ;
643
assign  dmmu_sync_far_m_sel     = (dmmu_decode_asi58_m & va_54_eq_2) & ~rst_tri_en ;
644
assign  immu_sync_fsr_m_sel     = (immu_decode_asi50_m & va_54_eq_1) & ~rst_tri_en ;
645
assign  tlu_ldxa_l1mx2_sel[0] = dmmu_sync_fsr_m_sel ;
646
// d sync-far
647
// * read timing change.
648
assign  tlu_ldxa_l1mx2_sel[1] = dmmu_sync_far_m_sel ;
649
// i sync-fsr
650
assign  tlu_ldxa_l1mx2_sel[2] = immu_sync_fsr_m_sel ;
651
assign  tlu_ldxa_l1mx2_sel[3] = ~|tlu_ldxa_l1mx2_sel[2:0];
652
wire    ldxa_l1mx2_sel3;
653
assign  ldxa_l1mx2_sel3 = (dmmu_zctxt_cfg_m | dmmu_nzctxt_cfg_m |
654
                          immu_zctxt_cfg_m | immu_nzctxt_cfg_m) & ~rst_tri_en ;
655
 
656
assign  tlu_ldxa_l2mx1_sel[0] =
657
|{ldxa_l1mx1_sel3,ldxa_l1mx1_sel_d1[2:1],(tlu_ldxa_l1mx1_sel[0] & ~rst_tri_en)} ;
658
assign  tlu_ldxa_l2mx1_sel[1] = |{ldxa_l1mx2_sel3,tlu_ldxa_l1mx2_sel[2:0]} ;
659
assign  tlu_ldxa_l2mx1_sel[2] = ~|tlu_ldxa_l2mx1_sel[1:0];
660
 
661
//=========================================================================================
662
//      MRA RD/WRITE
663
//=========================================================================================
664
 
665
wire    [3:0]    isfsr_trp_wr ;
666
wire    flush_mmuasi_wr ;
667
assign  flush_mmuasi_wr = ifu_tlu_flush_w | lsu_mmu_defr_trp_taken_g ; // Bug 5196
668
assign  isfsr_trp_wr[0] = immu_sfsr_trp_wr[0] & ~flush_mmuasi_wr ;
669
assign  isfsr_trp_wr[1] = immu_sfsr_trp_wr[1] & ~flush_mmuasi_wr ;
670
assign  isfsr_trp_wr[2] = immu_sfsr_trp_wr[2] & ~flush_mmuasi_wr ;
671
assign  isfsr_trp_wr[3] = immu_sfsr_trp_wr[3] & ~flush_mmuasi_wr ;
672
 
673
wire  tag_access_nctxt_g ;
674
 
675
wire immu_miss_vld_g ;
676
assign immu_miss_vld_g = immu_miss_g & inst_vld_g ;
677
 
678
// fast-asi read takes precedence over long-latency rd. Can long-latency read get
679
// starved out ?? Assume memref_d is never x.
680
assign  dmra_lng_lat_rd = ((dmmu_data_in_en | dmmu_data_access_en) & tlb_st_inst_g & ~ifu_lsu_memref_d) ;
681
assign  imra_lng_lat_rd = ((immu_data_in_en | immu_data_access_en) & tlb_st_inst_g & ~ifu_lsu_memref_d) ;
682
//assign        dmra_lng_lat_rd = ((dmmu_data_in_en | dmmu_data_access_en) & tlb_st_inst_g) ;
683
//assign        imra_lng_lat_rd = ((immu_data_in_en | immu_data_access_en) & tlb_st_inst_g) ;
684
 
685
wire  dmra_ldst,imra_ldst ;
686
assign        dmra_ldst = dmmu_tag_access_en | dmmu_tsb_en | dmmu_ctxt_cfg_en ;
687
assign        imra_ldst = immu_tag_access_en | immu_tsb_en | immu_ctxt_cfg_en ;
688
 
689
// sync_far_en no longer written/read
690
assign  dmra_wr_g =
691
        (dmra_ldst & st_inst_g) |
692
        (lsu_tlu_dmmu_miss_g | lsu_tlu_daccess_excptn_g | lsu_tlu_daccess_prot_g)
693
        & trp_vld_g & ~flush_mmuasi_wr ;
694
        //(lsu_tlu_dmmu_miss_g | lsu_tlu_daccess_excptn_g | lsu_tlu_daccess_prot_g) & inst_vld_g ;
695
        // Bug 4183
696
wire    isfsr_trap ;
697
assign  isfsr_trap = |isfsr_trp_wr[3:0] ;
698
assign  imra_wr_g =
699
        (imra_ldst & st_inst_g) |
700
        //((immu_tag_access_en | immu_tsb_en | immu_ctxt_cfg_en) & st_inst_g) | 
701
        (immu_miss_vld_g & ~flush_mmuasi_wr) | isfsr_trap ;
702
 
703
wire    dmra_rw_d ;
704
assign  iside_mra_access_rd = ((~dmra_rw_d) & ~(imra_lng_lat_rd | dmra_lng_lat_rd))  | imra_lng_lat_rd ;
705
assign  iside_mra_access_wr = imra_wr_g ;
706
 
707
assign  mra_raccess_tid[1:0] = (dmra_lng_lat_rd | imra_lng_lat_rd) ? tlb_access_tid_g[1:0] : thrid_d[1:0] ;
708
 
709
wire idside_nzctxt_accwr_early_m,idside_nzctxt_accwr_early_g  ;
710
assign  idside_nzctxt_accwr_early_m =
711
        ((dmmu_nzctxt_cfg_en_m   | immu_nzctxt_cfg_en_m     |
712
        dmmu_nzctxt_ps0_tsb_en_m | immu_nzctxt_ps0_tsb_en_m |
713
        dmmu_nzctxt_ps1_tsb_en_m | immu_nzctxt_ps1_tsb_en_m) & st_inst_m) ; // tsb/cfg asi wr
714
 
715 113 albert.wat
dff_s ctacc_stgg (
716 95 fafa1971
        .din    (idside_nzctxt_accwr_early_m),
717
        .q      (idside_nzctxt_accwr_early_g),
718
        .clk    (clk),
719 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
720 95 fafa1971
        );
721
 
722
//wire  idside_nzctxt_access ;
723
wire    idside_nzctxt_access_rd,idside_nzctxt_access_wr ;
724
wire    st_wr_g ;
725
 
726
assign  idside_nzctxt_access_wr =
727
        ((dmmu_tag_access_en    | immu_tag_access_en)   // tag-access asi write
728
                & st_inst_unflushed & ~tag_access_nctxt_g)       |
729
        ((lsu_tlu_daccess_excptn_g | lsu_tlu_daccess_prot_g | lsu_tlu_dmmu_miss_g |
730
        immu_miss_g | (isfsr_trap))             // tag-access exception write 
731
                & inst_vld_g & ~tag_access_nctxt_g)      |
732
        (idside_nzctxt_accwr_early_g & st_wr_g) ; // Bug 4828
733
        //((dmmu_nzctxt_cfg_en  | immu_nzctxt_cfg_en     |
734
        //dmmu_nzctxt_ps0_tsb_en        | immu_nzctxt_ps0_tsb_en |
735
        //dmmu_nzctxt_ps1_tsb_en        | immu_nzctxt_ps1_tsb_en) & st_inst_unflushed) ; // tsb/cfg asi wr
736
assign  idside_nzctxt_access_rd =
737
        (idmra_nzctxt_rd_d)              |  // => nzctxt rd with decode
738
        (idmra_fault_rd_d & ~tacc_nctxt) |  // => fault-based rd
739
        ((dmra_lng_lat_rd | imra_lng_lat_rd) & ~tacc_anctxt) ;
740
// access non zero context levels
741
 
742
assign  mra_wr_ptr[3:0]  = {thrid_g[1:0],idside_nzctxt_access_wr,iside_mra_access_wr};
743
assign  mra_rd_ptr[3:0]  = {mra_raccess_tid[1:0],idside_nzctxt_access_rd,iside_mra_access_rd};
744
 
745
assign  mra_wr_vld = dmra_wr_g | imra_wr_g ;
746
assign  mra_rd_vld = idmra_rd_d | dmra_lng_lat_rd | imra_lng_lat_rd ;
747
 
748
assign  dmmu_ctxt_cfg_en = dmmu_zctxt_cfg_en | dmmu_nzctxt_cfg_en ;
749
assign  immu_ctxt_cfg_en = immu_zctxt_cfg_en | immu_nzctxt_cfg_en ;
750
//assign        dmmu_ctxt_cfg_rd_en = (dmmu_zctxt_cfg_en | dmmu_nzctxt_cfg_en) & ld_inst_g ;
751
//assign        immu_ctxt_cfg_rd_en = (immu_zctxt_cfg_en | immu_nzctxt_cfg_en) & ld_inst_g ;
752
 
753
// Change - with 8 tsbs per thread, tsb can be in any of the 3 fields
754
// of a line in the mra.
755
wire    mra_itag_acc_en,mra_dtag_acc_en ;
756
// Be careful about loading on trap conditions.
757
assign st_wr_g = st_inst_unflushed & ~local_flush_w ;
758
assign  mra_itag_acc_en =
759
        (immu_tag_access_en & st_wr_g) | immu_miss_g | (isfsr_trap) ;
760
assign  mra_dtag_acc_en =
761
        (dmmu_tag_access_en & st_wr_g) | lsu_tlu_dmmu_miss_g | lsu_tlu_daccess_excptn_g |
762
        lsu_tlu_daccess_prot_g ;
763
assign  mra_field1_en   = (dmmu_zctxt_ps0_tsb_en  | immu_zctxt_ps0_tsb_en |
764
                          dmmu_nzctxt_ps0_tsb_en | immu_nzctxt_ps0_tsb_en) & st_wr_g ;
765
                          // dmmu_nzctxt_ps0_tsb_en | immu_nzctxt_ps0_tsb_en) & st_inst_unflushed ; Bug 3378
766
assign  mra_field2_en   = (dmmu_zctxt_ps1_tsb_en  | immu_zctxt_ps1_tsb_en |
767
                          dmmu_nzctxt_ps1_tsb_en | immu_nzctxt_ps1_tsb_en) & st_wr_g ;
768
assign  mra_field3_en   = mra_itag_acc_en | mra_dtag_acc_en ;
769
assign  mra_field4_en   = (dmmu_ctxt_cfg_en | immu_ctxt_cfg_en) & st_wr_g ;
770
 
771
// for use of rf16x160
772
assign  mra_byte_wen[19:14] = {6{mra_field1_en}} ;
773
assign  mra_byte_wen[13:8]  = {6{mra_field2_en}} ;
774
assign  mra_byte_wen[7:2]  =  {6{mra_field3_en}} ;
775
assign  mra_byte_wen[1:0]  =  {2{mra_field4_en}} ;
776
 
777
// active-low selects
778
// Need to add inst_access_excp to the sel !!!
779
// Prioritized between the two sels.
780
assign        tag_access_wdata_sel[0] =
781
      ~(tag_access_wdata_sel[1] | tag_access_wdata_sel[2]) | rst_tri_en ;
782
//assign        tag_access_wdata_sel[1] = (immu_miss_g | isfsr_trap) & ~rst_tri_en ; // Timing
783
assign        tag_access_wdata_sel[1] = tlu_itag_acc_sel_g & ~rst_tri_en ;
784
assign        tag_access_wdata_sel[2] = (dmra_ldst | imra_ldst) & st_wr_g & ~rst_tri_en ;
785
                                        // Bug 4728
786
 
787
wire  [12:0]  tag_access_wdata_ctxt ;
788
assign        tag_access_wdata_ctxt[12:0] =
789
       tag_access_wdata_sel[2] ? lsu_tlu_st_rs3_data_b12t0_g[12:0] : tlu_tag_access_ctxt_g[12:0] ;
790
 
791
assign  tag_access_nctxt_g = (tag_access_wdata_ctxt[12:0] == 13'd0) ;
792
 
793
//=========================================================================================
794
//      Tag-Access Context Per thread
795
//=========================================================================================
796
 
797
// Mark ctxt field in tag-access register as being nucleus or non-nucleus.
798
// State will not be ~rst_l as use is expected to be preceeded by write.
799
 
800
wire    [3:0]    itacc_ctxt_en, dtacc_ctxt_en ;
801
wire            itacc_nctxt0,itacc_nctxt1,itacc_nctxt2,itacc_nctxt3;
802
wire            dtacc_nctxt0,dtacc_nctxt1,dtacc_nctxt2,dtacc_nctxt3;
803
assign  itacc_ctxt_en[0] = thread0_sel_g & mra_itag_acc_en & mra_wr_vld ;
804
assign  itacc_ctxt_en[1] = thread1_sel_g & mra_itag_acc_en & mra_wr_vld ;
805
assign  itacc_ctxt_en[2] = thread2_sel_g & mra_itag_acc_en & mra_wr_vld ;
806
assign  itacc_ctxt_en[3] = thread3_sel_g & mra_itag_acc_en & mra_wr_vld ;
807
assign  dtacc_ctxt_en[0] = thread0_sel_g & mra_dtag_acc_en & mra_wr_vld ;
808
assign  dtacc_ctxt_en[1] = thread1_sel_g & mra_dtag_acc_en & mra_wr_vld ;
809
assign  dtacc_ctxt_en[2] = thread2_sel_g & mra_dtag_acc_en & mra_wr_vld ;
810
assign  dtacc_ctxt_en[3] = thread3_sel_g & mra_dtag_acc_en & mra_wr_vld ;
811
 
812
// Thread0
813 113 albert.wat
dffe_s   itacc_ctxt0 (
814 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (itacc_nctxt0),
815
        .en     (itacc_ctxt_en[0]),      .clk (clk),
816 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
817 95 fafa1971
        );
818
 
819 113 albert.wat
dffe_s   dtacc_ctxt0 (
820 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (dtacc_nctxt0),
821
        .en     (dtacc_ctxt_en[0]),      .clk (clk),
822 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
823 95 fafa1971
        );
824
 
825
// Thread1
826 113 albert.wat
dffe_s   itacc_ctxt1 (
827 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (itacc_nctxt1),
828
        .en     (itacc_ctxt_en[1]),     .clk (clk),
829 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
830 95 fafa1971
        );
831
 
832 113 albert.wat
dffe_s   dtacc_ctxt1 (
833 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (dtacc_nctxt1),
834
        .en     (dtacc_ctxt_en[1]),     .clk (clk),
835 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
836 95 fafa1971
        );
837
 
838
// Thread2
839 113 albert.wat
dffe_s   itacc_ctxt2 (
840 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (itacc_nctxt2),
841
        .en     (itacc_ctxt_en[2]),     .clk (clk),
842 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
843 95 fafa1971
        );
844
 
845 113 albert.wat
dffe_s   dtacc_ctxt2 (
846 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (dtacc_nctxt2),
847
        .en     (dtacc_ctxt_en[2]),     .clk (clk),
848 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
849 95 fafa1971
        );
850
 
851
// Thread3
852 113 albert.wat
dffe_s   itacc_ctxt3 (
853 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (itacc_nctxt3),
854
        .en     (itacc_ctxt_en[3]),     .clk (clk),
855 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
856 95 fafa1971
        );
857
 
858 113 albert.wat
dffe_s   dtacc_ctxt3 (
859 95 fafa1971
        .din    (tag_access_nctxt_g), .q  (dtacc_nctxt3),
860
        .en     (dtacc_ctxt_en[3]),     .clk (clk),
861 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
862 95 fafa1971
        );
863
 
864
// In-pipe Access
865
assign  itacc_nctxt =
866
        thread0_d ? itacc_nctxt0 :
867
                thread1_d ? itacc_nctxt1 :
868
                        thread2_d ? itacc_nctxt2 : itacc_nctxt3 ;
869
assign  dtacc_nctxt =
870
        thread0_d ? dtacc_nctxt0 :
871
                thread1_d ? dtacc_nctxt1 :
872
                        thread2_d ? dtacc_nctxt2 : dtacc_nctxt3 ;
873
assign  tacc_nctxt =
874
        iside_mra_access_rd ? itacc_nctxt : dtacc_nctxt ;
875
 
876
// Asynchronous Access
877
assign  itacc_anctxt =
878
        thread0_async_g ? itacc_nctxt0 :
879
                thread1_async_g ? itacc_nctxt1 :
880
                        thread2_async_g ? itacc_nctxt2 : itacc_nctxt3 ;
881
assign  dtacc_anctxt =
882
        thread0_async_g ? dtacc_nctxt0 :
883
                thread1_async_g ? dtacc_nctxt1 :
884
                        thread2_async_g ? dtacc_nctxt2 : dtacc_nctxt3 ;
885
 
886
assign  tacc_anctxt =
887
        imra_lng_lat_rd ? itacc_anctxt : dtacc_anctxt ;
888
 
889
//=========================================================================================
890
//      Interrupt Control
891
//=========================================================================================
892
 
893
assign  tlu_int_asi_load =  ld_inst_g & alt_space_g ;
894
assign  tlu_int_asi_store =  st_inst_g & alt_space_g ;
895
assign  tlu_int_asi_thrid[1:0] = thrid_g[1:0] ;
896
assign  tlu_int_asi_vld = alt_space_g ;
897
 
898
//=========================================================================================
899
//      ASI Error Condition
900
//=========================================================================================
901
 
902
// Supported asi but illegal_va. ldxa must signal this occurrence when returning data
903
// to LSU.
904
// The decode can be shared with the statement below (grape)
905
// SPARC_HPV_EN - Needs to change once asi assignments are available !!!
906
// Bug 2201 : pid and va_wtchpt decoded in lsu (asi 58)
907
/*wire lsu_asi58_g ;
908
assign lsu_asi58_g =
909
        ((tlu_ldst_va_g[8:0] == 9'h080) |       // pid
910
        (tlu_ldst_va_g[8:0] == 9'h038)) ;       // va-wtchpt
911
assign  dmmu_sync_supported_asi =
912
        (((lsu_asi_state[7:0] == 8'h58) & ~lsu_asi58_g) |
913
        (lsu_asi_state[7:0] == 8'h59) |
914
        (lsu_asi_state[7:0] == 8'h5A) |
915
        (lsu_asi_state[7:0] == 8'h5B)) & alt_space_g  ;*/
916
 
917
 
918
wire    dmmu_inv_all_asi ;
919
assign dmmu_inv_all_asi =
920
({lsu_tlu_tlb_asi_state_m[7:0],lsu_tlu_tlb_ldst_va_m[7:0]} == {8'h60,8'h08}) ;
921
 
922
wire    dmmu_async_supported_asi_m ;
923
assign  dmmu_async_supported_asi_m =
924
        ((lsu_tlu_tlb_asi_state_m[7:0] == 8'h5C) |
925
        //dmmu_inv_all_asi |
926
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h60) | // Bug 4901
927
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h5D) |
928
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h5E) |
929
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h5F)) & tlb_ldst_inst_m ;
930
 
931 113 albert.wat
dff_s stgg_dasi (
932 95 fafa1971
        .din    (dmmu_async_supported_asi_m),
933
        .q      (dmmu_async_supported_asi),
934
        .clk    (clk),
935 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
936 95 fafa1971
        );
937
 
938
assign  dmmu_async_illgl_va_g =
939
        dmmu_async_supported_asi &
940
        ~(dmmu_data_in_en |
941
        dmmu_invalidate_all_en | immu_invalidate_all_en | // Bug 4901
942
        dmmu_data_access_en |
943
        dmmu_tag_read_en | dmmu_demap_en) ;
944
 
945
/*assign        immu_sync_supported_asi =
946
        ((lsu_asi_state[7:0] == 8'h50) |
947
        (lsu_asi_state[7:0] == 8'h51) |
948
        (lsu_asi_state[7:0] == 8'h52)) & alt_space_g ;
949
 
950
assign  immu_sync_illgl_va_g =
951
        immu_sync_supported_asi & ~(immu_tag_target_en | immu_sync_fsr_en | immu_tsb_en |
952
        immu_tag_access_en | immu_8k_ptr_en | immu_64k_ptr_en | immu_ctxt_cfg_en) ;*/
953
 
954
wire    immu_inv_all_asi ;
955
assign immu_inv_all_asi =
956
({lsu_tlu_tlb_asi_state_m[7:0],lsu_tlu_tlb_ldst_va_m[7:0]} == {8'h60,8'h00}) ;
957
 
958
wire    immu_async_supported_asi_m ;
959
assign  immu_async_supported_asi_m =
960
        ((lsu_tlu_tlb_asi_state_m[7:0] == 8'h54) |
961
        //immu_inv_all_asi |
962
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h60) | // Bug 4901
963
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h55) |
964
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h56) |
965
        (lsu_tlu_tlb_asi_state_m[7:0] == 8'h57)) & tlb_ldst_inst_m  ;
966
 
967 113 albert.wat
dff_s stgg_iasi (
968 95 fafa1971
        .din    (immu_async_supported_asi_m),
969
        .q      (immu_async_supported_asi),
970
        .clk    (clk),
971 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
972 95 fafa1971
        );
973
 
974
assign  immu_async_illgl_va_g =
975
        immu_async_supported_asi &
976
        ~(immu_data_in_en |
977
        immu_data_access_en | immu_tag_read_en | immu_demap_en |
978
        immu_invalidate_all_en | dmmu_invalidate_all_en) ; // Bug 4901
979
 
980
//=========================================================================================
981
//      IN-PIPE ASI RD SUPPORT
982
//=========================================================================================
983
 
984
 
985
assign  thread0_d = ~thrid_d[1] & ~thrid_d[0] ;
986
assign  thread1_d = ~thrid_d[1] &  thrid_d[0] ;
987
assign  thread2_d =  thrid_d[1] & ~thrid_d[0] ;
988
assign  thread3_d =  thrid_d[1] &  thrid_d[0] ;
989
 
990
wire    [7:0]   asi_reg0_d1 ;
991 113 albert.wat
dff_s #(8) stgd1_asi0 (
992 95 fafa1971
        .din    (lsu_asi_reg0[7:0]),
993
        .q      (asi_reg0_d1[7:0]),
994
        .clk    (clk),
995 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
996 95 fafa1971
        );
997
 
998
wire    [7:0]   asi_reg1_d1 ;
999 113 albert.wat
dff_s #(8) stgd1_asi1 (
1000 95 fafa1971
        .din    (lsu_asi_reg1[7:0]),
1001
        .q      (asi_reg1_d1[7:0]),
1002
        .clk    (clk),
1003 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1004 95 fafa1971
        );
1005
 
1006
wire    [7:0]   asi_reg2_d1 ;
1007 113 albert.wat
dff_s #(8) stgd1_asi2 (
1008 95 fafa1971
        .din    (lsu_asi_reg2[7:0]),
1009
        .q      (asi_reg2_d1[7:0]),
1010
        .clk    (clk),
1011 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1012 95 fafa1971
        );
1013
 
1014
wire    [7:0]   asi_reg3_d1 ;
1015 113 albert.wat
dff_s #(8) stgd1_asi3 (
1016 95 fafa1971
        .din    (lsu_asi_reg3[7:0]),
1017
        .q      (asi_reg3_d1[7:0]),
1018
        .clk    (clk),
1019 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1020 95 fafa1971
        );
1021
 
1022
wire    [7:0]   asi_reg_state ;
1023
assign  asi_reg_state[7:0] =
1024
        (thread0_d ? asi_reg0_d1[7:0] :
1025
          (thread1_d ? asi_reg1_d1[7:0] :
1026
            (thread2_d ? asi_reg2_d1[7:0] :
1027
              asi_reg3_d1[7:0]))) ;
1028
 
1029
wire    imm_asi_vld_d ;
1030
assign  imm_asi_vld_d = ~ifu_lsu_imm_asi_d[8] ;
1031
 
1032
// Use of asi delayed by a cycle.
1033
assign  asi_state_d[7:0] = imm_asi_vld_d ?
1034
      ifu_lsu_imm_asi_d[7:0] : asi_reg_state[7:0] ;
1035
 
1036 113 albert.wat
dff_s #(8) stgd1_asi (
1037 95 fafa1971
        .din    (asi_state_d[7:0]),
1038
        .q      (asi_state_e[7:0]),
1039
        .clk    (clk),
1040 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1041 95 fafa1971
        );
1042
 
1043
// bit8 is unused.
1044 113 albert.wat
dff_s #(8) stgd1_eva (
1045 95 fafa1971
        .din    (exu_mmu_early_va_e[7:0]),
1046
        .q      (early_va_m[7:0]),
1047
        .clk    (clk),
1048 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1049 95 fafa1971
        );
1050
 
1051 113 albert.wat
dff_s #(6) stgd1_mref (
1052 95 fafa1971
        .din    ({ifu_lsu_memref_d,thread0_d,thread1_d,thread2_d,thread3_d,ifu_tlu_alt_space_d}),
1053
        .q      ({memref_e,thread0_e, thread1_e, thread2_e, thread3_e,alt_space_e}),
1054
        .clk    (clk),
1055 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1056 95 fafa1971
        );
1057
 
1058 113 albert.wat
dff_s #(1) stgm_mref (
1059 95 fafa1971
        .din    (memref_e),
1060
        .q      (memref_m),
1061
        .clk    (clk),
1062 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1063 95 fafa1971
        );
1064
 
1065
 
1066
// qualification with memref_d to cut down on number of speculative reads
1067
// decode can be shared with corresponding enables
1068
// gates can be shared.
1069
 
1070
// Establish that mra *could* be read by sync events. full decode would
1071
// cause critical path.
1072
assign  idmra_rd_d =
1073
        //((asi_state_d[6:4] == 3'h6)  | // specifically tag-access.
1074
        ((asi_state_d[6:4] == 3'h5)  |
1075
         (asi_state_d[6:4] == 3'h3)) & ifu_tlu_alt_space_d & ifu_lsu_memref_d ;
1076
 
1077
// need to decode 58,59,5a,5B,31,32,39,3A,33,3B
1078
// use lower hex. need to distinguish 1 & 2 between both accesses.
1079
assign  dmra_rw_d =
1080
        (asi_state_d[3:0] == 4'b1000)   | // 8   
1081
        (((asi_state_d[3:0] == 4'b0001)  | // 1  
1082
        (asi_state_d[3:0] == 4'b0010)) & asi_state_d[5])  | // 2 ;1 & 2 need distinction between I&D     
1083
        (asi_state_d[3:0] == 4'b1001)   | // 9   
1084
        (asi_state_d[3:0] == 4'b1010)   | // A   
1085
        (asi_state_d[2:0] == 3'b011)   ; // partial B    
1086
 
1087
 
1088
// Read requires that ctxt of access be chosen.
1089
// ctxt_cfg,ps0_tsb,ps1_tsb require decode for ctxt.
1090
// tag_access,ps0-ptr,ps1-ptr,direct-ptr,tag-target require lookup of logged ctxt. 
1091
// ** Solution here is to exclude zctxt asi rds from equation.
1092
 
1093
assign idmra_nzctxt_rd_d =
1094
        (asi_state_d[7:4] == 4'h3) &    // common
1095
                ((asi_state_d[3:0] == 4'h9) |    // dmmu_nzctxt_ps0_tsb
1096
                (asi_state_d[3:0] == 4'hA) |     // dmmu_nzctxt_ps1_tsb
1097
                (asi_state_d[3:0] == 4'hB) |     // dmmu_nzctxt_cfg
1098
                (asi_state_d[3:0] == 4'hD) |     // immu_nzctxt_ps0_tsb
1099
                (asi_state_d[3:0] == 4'hE) |     // immu_nzctxt_ps1_tsb
1100
                (asi_state_d[3:0] == 4'hF)) &    // immu_nzctxt_cfg
1101
                ifu_tlu_alt_space_d & ifu_lsu_memref_d ;
1102
 
1103
// Fault based reads
1104
assign  idmra_fault_rd_d =
1105
        (asi_state_d[7:4] == 4'h5) &    // common
1106
                ((asi_state_d[3:0] == 4'h8) |    // dmmu_tag_access/target; va ignored
1107
                (asi_state_d[3:0] == 4'h9) |     // dmmu_ps0_ptr
1108
                (asi_state_d[3:0] == 4'hA) |     // dmmu_ps1_ptr
1109
                (asi_state_d[3:0] == 4'hB) |     // direct_ptr
1110
                (asi_state_d[3:0] == 4'h0) |     // immu_tag_access/target ; va ignored
1111
                (asi_state_d[3:0] == 4'h1) |     // immu_ps0_ptr
1112
                (asi_state_d[3:0] == 4'h2)) &    // immu_ps1_ptr
1113
                ifu_tlu_alt_space_d & ifu_lsu_memref_d ;
1114
 
1115
 
1116
// Note - tag_access needs to be included.
1117
always  @ (/*AUTOSENSE*/alt_space_e or asi_state_e or memref_e)
1118
        begin
1119
                // DMMU
1120
                dmmu_decode_asi58_e =
1121
                 ({asi_state_e[7:0]} == {8'h58}) & alt_space_e & memref_e ;
1122
                dmmu_8k_ptr_e =
1123
                 ({asi_state_e[7:0]} == {8'h59}) & alt_space_e & memref_e ;
1124
                dmmu_64k_ptr_e =
1125
                 ({asi_state_e[7:0]} == {8'h5A}) & alt_space_e & memref_e ;
1126
                dmmu_direct_ptr_e =
1127
                 ({asi_state_e[7:0]} == {8'h5B}) & alt_space_e & memref_e ;
1128
                dmmu_zctxt_ps0_tsb_e =
1129
                 ({asi_state_e[7:0]} == {8'h31}) & alt_space_e & memref_e ;
1130
                dmmu_zctxt_ps1_tsb_e =
1131
                 ({asi_state_e[7:0]} == {8'h32}) & alt_space_e & memref_e ;
1132
                dmmu_nzctxt_ps0_tsb_e =
1133
                 ({asi_state_e[7:0]} == {8'h39}) & alt_space_e & memref_e ;
1134
                dmmu_nzctxt_ps1_tsb_e =
1135
                 ({asi_state_e[7:0]} == {8'h3A}) & alt_space_e & memref_e ;
1136
                dmmu_zctxt_cfg_e =
1137
                 ({asi_state_e[7:0]} == {8'h33}) & alt_space_e & memref_e ;
1138
                dmmu_nzctxt_cfg_e =
1139
                 ({asi_state_e[7:0]} == {8'h3B}) & alt_space_e & memref_e ;
1140
                // IMMU
1141
                immu_decode_asi50_e =
1142
                 ({asi_state_e[7:0]} == {8'h50}) & alt_space_e & memref_e ;
1143
                immu_8k_ptr_e =
1144
                 ({asi_state_e[7:0]} == {8'h51}) & alt_space_e & memref_e ;
1145
                immu_64k_ptr_e =
1146
                 ({asi_state_e[7:0]} == {8'h52}) & alt_space_e & memref_e ;
1147
                immu_zctxt_ps0_tsb_e =
1148
                 ({asi_state_e[7:0]} == {8'h35}) & alt_space_e & memref_e ;
1149
                immu_zctxt_ps1_tsb_e =
1150
                 ({asi_state_e[7:0]} == {8'h36}) & alt_space_e & memref_e ;
1151
                immu_nzctxt_ps0_tsb_e =
1152
                 ({asi_state_e[7:0]} == {8'h3D}) & alt_space_e & memref_e ;
1153
                immu_nzctxt_ps1_tsb_e =
1154
                 ({asi_state_e[7:0]} == {8'h3E}) & alt_space_e & memref_e ;
1155
                immu_zctxt_cfg_e =
1156
                 ({asi_state_e[7:0]} == {8'h37}) & alt_space_e & memref_e ;
1157
                immu_nzctxt_cfg_e =
1158
                 ({asi_state_e[7:0]} == {8'h3F}) & alt_space_e & memref_e ;
1159
        end
1160
 
1161
wire immu_64k_ptr_m,immu_8k_ptr_m,dmmu_direct_ptr_m,dmmu_64k_ptr_m,
1162
dmmu_8k_ptr_m ;
1163 113 albert.wat
dff_s  #(19) fastasi_m (
1164 95 fafa1971
        .din    ({dmmu_8k_ptr_e,dmmu_64k_ptr_e,dmmu_direct_ptr_e,
1165
                dmmu_decode_asi58_e, immu_decode_asi50_e,
1166
                dmmu_zctxt_ps0_tsb_e, dmmu_zctxt_ps1_tsb_e,
1167
                dmmu_nzctxt_ps0_tsb_e, dmmu_nzctxt_ps1_tsb_e,
1168
                dmmu_zctxt_cfg_e, dmmu_nzctxt_cfg_e,
1169
                immu_zctxt_ps0_tsb_e, immu_zctxt_ps1_tsb_e,
1170
                immu_nzctxt_ps0_tsb_e, immu_nzctxt_ps1_tsb_e,
1171
                immu_zctxt_cfg_e, immu_nzctxt_cfg_e,
1172
                immu_8k_ptr_e,immu_64k_ptr_e}),
1173
        .q      ({dmmu_8k_ptr_m,dmmu_64k_ptr_m,dmmu_direct_ptr_m,
1174
                dmmu_decode_asi58_m, immu_decode_asi50_m,
1175
                dmmu_zctxt_ps0_tsb_m, dmmu_zctxt_ps1_tsb_m,
1176
                dmmu_nzctxt_ps0_tsb_m, dmmu_nzctxt_ps1_tsb_m,
1177
                dmmu_zctxt_cfg_m, dmmu_nzctxt_cfg_m,
1178
                immu_zctxt_ps0_tsb_m, immu_zctxt_ps1_tsb_m,
1179
                immu_nzctxt_ps0_tsb_m, immu_nzctxt_ps1_tsb_m,
1180
                immu_zctxt_cfg_m, immu_nzctxt_cfg_m,
1181
                immu_8k_ptr_m,immu_64k_ptr_m}),
1182
        .clk    (clk),
1183 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1184 95 fafa1971
        );
1185
 
1186
assign  dmmu_tag_target_en_m = dmmu_decode_asi58_m & (early_va_m[7:0] == 8'h00) ;
1187
assign  dmmu_tag_access_en_m = dmmu_decode_asi58_m & (early_va_m[7:0] == 8'h30) ;
1188
assign  dmmu_sync_fsr_en_m = dmmu_decode_asi58_m & (early_va_m[7:0] == 8'h18) ;
1189
assign  dmmu_sync_far_en_m = dmmu_decode_asi58_m & (early_va_m[7:0] == 8'h20) ;
1190
assign  dmmu_zctxt_ps0_tsb_en_m = dmmu_zctxt_ps0_tsb_m & (early_va_m[7:0] == 8'h00) ;
1191
assign  dmmu_zctxt_ps1_tsb_en_m = dmmu_zctxt_ps1_tsb_m & (early_va_m[7:0] == 8'h00) ;
1192
assign  dmmu_nzctxt_ps0_tsb_en_m = dmmu_nzctxt_ps0_tsb_m & (early_va_m[7:0] == 8'h00) ;
1193
assign  dmmu_nzctxt_ps1_tsb_en_m = dmmu_nzctxt_ps1_tsb_m & (early_va_m[7:0] == 8'h00) ;
1194
assign  dmmu_zctxt_cfg_en_m = dmmu_zctxt_cfg_m & (early_va_m[7:0] == 8'h00) ;
1195
assign  dmmu_nzctxt_cfg_en_m = dmmu_nzctxt_cfg_m & (early_va_m[7:0] == 8'h00) ;
1196
assign  dmmu_8k_ptr_en_m = dmmu_8k_ptr_m & (early_va_m[7:0] == 8'h00) ;
1197
assign  dmmu_64k_ptr_en_m = dmmu_64k_ptr_m & (early_va_m[7:0] == 8'h00) ;
1198
assign  dmmu_direct_ptr_en_m = dmmu_direct_ptr_m & (early_va_m[7:0] == 8'h00) ;
1199
 
1200
// Calculation of dmmu illgl-va
1201
 
1202
wire    dmmu_sync_supported_asi_e ;
1203
wire    dmmu_sync_supported_asi_m ;
1204
assign  dmmu_sync_supported_asi_e =
1205
        (dmmu_decode_asi58_e | dmmu_zctxt_ps0_tsb_e | dmmu_zctxt_ps1_tsb_e |
1206
        dmmu_nzctxt_ps0_tsb_e | dmmu_nzctxt_ps1_tsb_e | dmmu_zctxt_cfg_e |
1207
        dmmu_nzctxt_cfg_e | dmmu_8k_ptr_e | dmmu_64k_ptr_e | dmmu_direct_ptr_e);
1208
 
1209 113 albert.wat
dff_s stgm_dsynca (
1210 95 fafa1971
        .din    (dmmu_sync_supported_asi_e),
1211
        .q      (dmmu_sync_supported_asi_m),
1212
        .clk    (clk),
1213 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1214 95 fafa1971
        );
1215
 
1216
wire    dmmu_sync_illgl_va_m ;
1217
assign  dmmu_sync_illgl_va_m = dmmu_sync_supported_asi_m & ~(dmmu_tag_target_en_m |
1218
        dmmu_tag_access_en_m | dmmu_sync_fsr_en_m | dmmu_sync_far_en_m | dmmu_tsb_en_m |
1219
        dmmu_ctxt_cfg_en_m | dmmu_8k_ptr_en_m | dmmu_64k_ptr_en_m | dmmu_direct_ptr_en_m);
1220
 
1221
assign  dmmu_tsb_en_m =
1222
        dmmu_zctxt_ps0_tsb_en_m  | dmmu_zctxt_ps1_tsb_en_m |
1223
        dmmu_nzctxt_ps0_tsb_en_m | dmmu_nzctxt_ps1_tsb_en_m ;
1224
assign  dmmu_ctxt_cfg_en_m = dmmu_zctxt_cfg_en_m | dmmu_nzctxt_cfg_en_m ;
1225
 
1226
assign  immu_tag_target_en_m = immu_decode_asi50_m & (early_va_m[7:0] == 8'h00) ;
1227
assign  immu_tag_access_en_m = immu_decode_asi50_m & (early_va_m[7:0] == 8'h30) ;
1228
assign  immu_sync_fsr_en_m = immu_decode_asi50_m & (early_va_m[7:0] == 8'h18) ;
1229
assign  immu_zctxt_ps0_tsb_en_m = immu_zctxt_ps0_tsb_m & (early_va_m[7:0] == 8'h00) ;
1230
assign  immu_zctxt_ps1_tsb_en_m = immu_zctxt_ps1_tsb_m & (early_va_m[7:0] == 8'h00) ;
1231
assign  immu_nzctxt_ps0_tsb_en_m = immu_nzctxt_ps0_tsb_m & (early_va_m[7:0] == 8'h00) ;
1232
assign  immu_nzctxt_ps1_tsb_en_m = immu_nzctxt_ps1_tsb_m & (early_va_m[7:0] == 8'h00) ;
1233
assign  immu_zctxt_cfg_en_m = immu_zctxt_cfg_m & (early_va_m[7:0] == 8'h00) ;
1234
assign  immu_nzctxt_cfg_en_m = immu_nzctxt_cfg_m & (early_va_m[7:0] == 8'h00) ;
1235
assign  immu_8k_ptr_en_m = immu_8k_ptr_m & (early_va_m[7:0] == 8'h00) ;
1236
assign  immu_64k_ptr_en_m = immu_64k_ptr_m & (early_va_m[7:0] == 8'h00) ;
1237
 
1238
assign  immu_tsb_en_m =
1239
        immu_zctxt_ps0_tsb_en_m  | immu_zctxt_ps1_tsb_en_m |
1240
        immu_nzctxt_ps0_tsb_en_m | immu_nzctxt_ps1_tsb_en_m ;
1241
assign  immu_ctxt_cfg_en_m = immu_zctxt_cfg_en_m | immu_nzctxt_cfg_en_m ;
1242
 
1243
 
1244
// Calculation of immu illgl-va
1245
 
1246
wire    immu_sync_supported_asi_e ;
1247
wire    immu_sync_supported_asi_m ;
1248
assign  immu_sync_supported_asi_e =
1249
        (immu_decode_asi50_e | immu_zctxt_ps0_tsb_e | immu_zctxt_ps1_tsb_e |
1250
        immu_nzctxt_ps0_tsb_e | immu_nzctxt_ps1_tsb_e | immu_zctxt_cfg_e |
1251
        immu_nzctxt_cfg_e | immu_8k_ptr_e | immu_64k_ptr_e);
1252
 
1253 113 albert.wat
dff_s stgm_isynca (
1254 95 fafa1971
        .din    (immu_sync_supported_asi_e),
1255
        .q      (immu_sync_supported_asi_m),
1256
        .clk    (clk),
1257 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1258 95 fafa1971
        );
1259
 
1260
wire    immu_sync_illgl_va_m ;
1261
assign  immu_sync_illgl_va_m = immu_sync_supported_asi_m & ~(immu_tag_target_en_m |
1262
        immu_tag_access_en_m | immu_sync_fsr_en_m | immu_tsb_en_m | immu_ctxt_cfg_en_m |
1263
        immu_8k_ptr_en_m | immu_64k_ptr_en_m);
1264
 
1265 113 albert.wat
dff_s #(2) stgg_illgl (
1266 95 fafa1971
        .din    ({immu_sync_illgl_va_m,dmmu_sync_illgl_va_m}),
1267
        .q      ({immu_sync_illgl_va_g,dmmu_sync_illgl_va_g}),
1268
        .clk    (clk),
1269 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1270 95 fafa1971
        );
1271
 
1272
// Staged to g for writes
1273 113 albert.wat
dff_s  #(17) fastasi_g (
1274 95 fafa1971
        .din    ({dmmu_tag_access_en_m,
1275
                dmmu_sync_fsr_en_m, dmmu_sync_far_en_m,
1276
                dmmu_zctxt_ps0_tsb_en_m, dmmu_zctxt_ps1_tsb_en_m,
1277
                dmmu_nzctxt_ps0_tsb_en_m, dmmu_nzctxt_ps1_tsb_en_m,
1278
                dmmu_zctxt_cfg_en_m, dmmu_nzctxt_cfg_en_m,
1279
                immu_tag_access_en_m,
1280
                immu_sync_fsr_en_m,
1281
                immu_zctxt_ps0_tsb_en_m, immu_zctxt_ps1_tsb_en_m,
1282
                immu_nzctxt_ps0_tsb_en_m, immu_nzctxt_ps1_tsb_en_m,
1283
                immu_zctxt_cfg_en_m, immu_nzctxt_cfg_en_m}),
1284
        .q      ({dmmu_tag_access_en,
1285
                dmmu_sync_fsr_en, dmmu_sync_far_en,
1286
                dmmu_zctxt_ps0_tsb_en, dmmu_zctxt_ps1_tsb_en,
1287
                dmmu_nzctxt_ps0_tsb_en, dmmu_nzctxt_ps1_tsb_en,
1288
                dmmu_zctxt_cfg_en, dmmu_nzctxt_cfg_en,
1289
                immu_tag_access_en,
1290
                immu_sync_fsr_en,
1291
                immu_zctxt_ps0_tsb_en, immu_zctxt_ps1_tsb_en,
1292
                immu_nzctxt_ps0_tsb_en, immu_nzctxt_ps1_tsb_en,
1293
                immu_zctxt_cfg_en, immu_nzctxt_cfg_en}),
1294
        .clk    (clk),
1295 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1296 95 fafa1971
        );
1297
 
1298
//=========================================================================================
1299
//      MMU ASI Decode - D-Side
1300
//=========================================================================================
1301
 
1302
 
1303
// Assumption is that only 9 bits of VA are required.
1304
// Comparison for asi-state and va is to be done uniformly in w2.
1305
 
1306
// This will have to change because of tsb mapping to mra.
1307
        assign  dmmu_tsb_en =
1308
                        dmmu_zctxt_ps0_tsb_en  | dmmu_zctxt_ps1_tsb_en |
1309
                        dmmu_nzctxt_ps0_tsb_en | dmmu_nzctxt_ps1_tsb_en ;
1310
 
1311
assign  tlb_ldst_inst_m = lsu_tlu_tlb_ld_inst_m | lsu_tlu_tlb_st_inst_m ;
1312
 
1313
// M-stage decoding for long-latency tlb accesses
1314
always  @ (/*AUTOSENSE*/dmmu_inv_all_asi or lsu_tlu_tlb_asi_state_m
1315
           or lsu_tlu_tlb_ldst_va_m[7:0] or tlb_ldst_inst_m)
1316
        begin
1317
                dmmu_data_in_en_m =
1318
                 ({lsu_tlu_tlb_asi_state_m[7:0],lsu_tlu_tlb_ldst_va_m[7:0]} == {8'h5C,8'h00}) & tlb_ldst_inst_m ;
1319
                dmmu_invalidate_all_en_m =
1320
                 dmmu_inv_all_asi & tlb_ldst_inst_m ;
1321
                 //({lsu_tlu_tlb_asi_state_m[7:0],lsu_tlu_tlb_ldst_va_m[7:0]} == {8'h60,8'h08}) & tlb_ldst_inst_m ;
1322
                // Address specifies tlb entry.
1323
                dmmu_data_access_en_m =
1324
                 ({lsu_tlu_tlb_asi_state_m[7:0]} == {8'h5D}) &   tlb_ldst_inst_m ;
1325
                // Address specifies tlb entry.
1326
                dmmu_tag_read_en_m =
1327
                 ({lsu_tlu_tlb_asi_state_m[7:0]} == {8'h5E}) &   tlb_ldst_inst_m ;
1328
                dmmu_demap_en_m =
1329
                 ({lsu_tlu_tlb_asi_state_m[7:0]} == {8'h5F}) &  tlb_ldst_inst_m ;
1330
        end
1331
 
1332
// Stage to g.
1333
// Make dff->dffre. This required to avoid conflict between fast-asi and lng-latency
1334
// rds of mra. Specifically, data-in/data_access need to be staged, along with
1335
// support information.
1336
 
1337
wire lng_ltncy_en_d1 ;
1338
assign  tlu_lng_ltncy_en_l = ~lng_ltncy_en_d1 | sehold ;
1339
wire    lng_ltncy_en ;
1340 113 albert.wat
dff_s stgd1_lltncyen (
1341 95 fafa1971
        .din    (lng_ltncy_en),
1342
        .q      (lng_ltncy_en_d1),
1343
        .clk    (clk),
1344 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1345 95 fafa1971
        );
1346
 
1347
assign  lng_ltncy_en = (lsu_tlu_tlb_st_inst_m | lsu_tlu_tlb_ld_inst_m) ;
1348
wire    lng_ltncy_rst ;
1349
assign  lng_ltncy_rst =
1350
        tlb_ld_inst_unflushed |         // all reads processed immediately
1351
        (tlb_st_inst_unflushed &        // all writes not requiring mra processed immediately
1352
                ~(dmmu_data_in_en | dmmu_data_access_en | immu_data_in_en | immu_data_access_en)) |
1353
        dmra_lng_lat_rd | imra_lng_lat_rd | // lng-ltncy rds - delay until bubble available.
1354
        ((tlb_ld_inst_unflushed | tlb_st_inst_unflushed) &  // rst w/o use if illgl-va
1355
                        (dmmu_async_illgl_va_g | immu_async_illgl_va_g)) |
1356
        ~rst_l ;
1357
 
1358 113 albert.wat
dffe_s  #(10) dtlbacc_stgg (
1359 95 fafa1971
        .din    ({lsu_tlu_tlb_ldst_va_m[10:3], lsu_tlu_tlb_access_tid_m[1:0]}),
1360
        .q      ({tlb_ldst_va_g[10:3],tlb_access_tid_g[1:0]}),
1361
        .clk    (clk),
1362
        .en     (lng_ltncy_en),
1363 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1364 95 fafa1971
        );
1365
 
1366 113 albert.wat
dffre_s  #(7) dtlbaccr_stgg (
1367 95 fafa1971
        .din    ({dmmu_data_in_en_m,dmmu_data_access_en_m,dmmu_tag_read_en_m,
1368
                dmmu_demap_en_m,dmmu_invalidate_all_en_m,
1369
                lsu_tlu_tlb_ld_inst_m,lsu_tlu_tlb_st_inst_m}),
1370
        .q      ({dmmu_data_in_en,dmmu_data_access_en,dmmu_tag_read_en,
1371
                dmmu_demap_en,dmmu_invalidate_all_en,
1372
                tlb_ld_inst_unflushed,tlb_st_inst_unflushed}),
1373
        .clk    (clk),
1374
        .rst    (lng_ltncy_rst),        .en     (lng_ltncy_en),
1375 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1376 95 fafa1971
        );
1377
 
1378
 
1379
assign  tlb_st_inst_g = tlb_st_inst_unflushed & ~(dmmu_async_illgl_va_g | immu_async_illgl_va_g) ;
1380
assign  tlb_ld_inst_g = tlb_ld_inst_unflushed & ~(dmmu_async_illgl_va_g | immu_async_illgl_va_g) ;
1381
 
1382
assign  dsfsr_asi_wr_en[0] = dmmu_sync_fsr_en & st_inst_g & thread0_sel_g ;
1383
assign  dsfsr_asi_wr_en[1] = dmmu_sync_fsr_en & st_inst_g & thread1_sel_g ;
1384
assign  dsfsr_asi_wr_en[2] = dmmu_sync_fsr_en & st_inst_g & thread2_sel_g ;
1385
assign  dsfsr_asi_wr_en[3] = dmmu_sync_fsr_en & st_inst_g & thread3_sel_g ;
1386
 
1387
assign  dmmu_any_sfsr_wr = dmmu_sync_fsr_en & st_inst_g ; //|(dsfsr_asi_wr_en[3:0]);
1388
 
1389
assign  dmmu_sfsr_wr_en_l[3:0] =
1390
~(dsfsr_asi_wr_en[3:0] | (dmmu_sfsr_trp_wr[3:0] & {4{~priority_squash_g}})) ; // Bug 4183
1391
 
1392
assign  dmmu_sfar_wr_en_l[0] =
1393
~((dmmu_sync_far_en & st_inst_g & thread0_sel_g) |
1394
(dmmu_sfsr_trp_wr[0] & ~priority_squash_g)) ; // Bug 4183
1395
assign  dmmu_sfar_wr_en_l[1] =
1396
~((dmmu_sync_far_en & st_inst_g & thread1_sel_g) |
1397
(dmmu_sfsr_trp_wr[1] & ~priority_squash_g)) ;
1398
assign  dmmu_sfar_wr_en_l[2] =
1399
~((dmmu_sync_far_en & st_inst_g & thread2_sel_g) |
1400
(dmmu_sfsr_trp_wr[2] & ~priority_squash_g)) ;
1401
assign  dmmu_sfar_wr_en_l[3] =
1402
~((dmmu_sync_far_en & st_inst_g & thread3_sel_g) |
1403
(dmmu_sfsr_trp_wr[3] & ~priority_squash_g)) ;
1404
 
1405
 
1406
assign  dmmu_data_in_wr_en = dmmu_data_in_en & tlb_st_inst_g ;  // Write-Only.
1407
assign  dmmu_data_access_wr_en = dmmu_data_access_en & tlb_st_inst_g ;
1408
// non-threaded as shared resource
1409
assign  dmmu_data_access_rd_en = dmmu_data_access_en & tlb_ld_inst_g ;
1410
 
1411
// take exception for write case.
1412
assign  dmmu_tag_read_rd_en = dmmu_tag_read_en & tlb_ld_inst_g ;
1413
 
1414
 
1415
assign  dtlb_rw_index_vld_g = dmmu_data_access_rd_en | dmmu_data_access_wr_en | dmmu_tag_read_rd_en ;
1416
// terminate write if tlb full and signal exception.
1417
assign  dtlb_wr_vld_g = (dmmu_data_in_wr_en | dmmu_data_access_wr_en) & ~ifu_lsu_memref_d ;
1418
 
1419
wire            dtlb_rw_index_vld_pend ;
1420
wire [5:0]       dtlb_rw_index_pend ;
1421
 
1422 113 albert.wat
dffre_s  #(1) stgw2_dtlbctl (
1423 95 fafa1971
        .din    (dtlb_rw_index_vld_g),
1424
        .q      (dtlb_rw_index_vld_pend),
1425
        .rst    (tlb_access_rst),       .en     (tlb_access_en),
1426
        .clk    (clk),
1427 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1428 95 fafa1971
        );
1429
 
1430 113 albert.wat
dffre_s  #(6) stgw2_dtlbidx (
1431 95 fafa1971
        .din    (tlb_ldst_va_g[8:3]),
1432
        .q      (dtlb_rw_index_pend[5:0]),
1433
        .rst    (tlb_access_rst),       .en     (tlb_access_en),
1434
        .clk    (clk),
1435 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1436 95 fafa1971
        );
1437
 
1438
wire    tlb_rd_mode, tlb_rd_mode_d1 ;
1439
assign  tlb_rd_mode =
1440
                tlu_itlb_tag_rd_g | tlu_itlb_data_rd_g |        // i-side read
1441
                tlu_dtlb_tag_rd_g | tlu_dtlb_data_rd_g ;        // d-side read
1442
 
1443 113 albert.wat
dff_s stgd1_rmode (
1444 95 fafa1971
        .din    (tlb_rd_mode),
1445
        .q      (tlb_rd_mode_d1),
1446
        .clk    (clk),
1447 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1448 95 fafa1971
        );
1449
 
1450
wire    dtlb_done_d1 ;
1451 113 albert.wat
dff_s stgd1_ddone (
1452 95 fafa1971
        .din    (lsu_tlu_dtlb_done),
1453
        .q      (dtlb_done_d1),
1454
        .clk    (clk),
1455 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1456 95 fafa1971
        );
1457
 
1458
wire    itlb_done_d1 ;
1459 113 albert.wat
dff_s stgd1_idone (
1460 95 fafa1971
        .din    (ifu_tlu_itlb_done),
1461
        .q      (itlb_done_d1),
1462
        .clk    (clk),
1463 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1464 95 fafa1971
        );
1465
 
1466
// Advanced by a cycle.
1467
assign  tlu_dtlb_rw_index_vld_g  = dtlb_rw_index_vld_g | dtlb_rw_index_vld_pend ;
1468
//assign        tlu_dtlb_rw_index_vld_g  = dtlb_rw_index_vld_g | (dtlb_rw_index_vld_pend & ~dtlb_done_d1) ; //Bug3974
1469
//assign        tlu_dtlb_rw_index_vld_g  = dtlb_rw_index_vld_g | (dtlb_rw_index_vld_pend & ~lsu_tlu_dtlb_done) ;
1470
assign  tlu_dtlb_rw_index_g[5:0] = (tlb_ldst_va_g[8:3] & {6{~(tlb_admp_mode | tlb_write_mode | tlb_rd_mode_d1)}})  |
1471
                                        dtlb_rw_index_pend[5:0]  ;
1472
 
1473
// Exception on reserved field.
1474
assign  demap_pctxt = ~tlb_ldst_va_g[5] & ~tlb_ldst_va_g[4] ;
1475
assign  demap_sctxt = ~tlb_ldst_va_g[5] &  tlb_ldst_va_g[4] ;
1476
assign  demap_nctxt =  tlb_ldst_va_g[5] & ~tlb_ldst_va_g[4] ;
1477
// reserved ctxt causes demap to be ignored.
1478
// reserved dmp type causes demap to be ignored.
1479
assign  demap_resrv =   (tlb_ldst_va_g[5] &  tlb_ldst_va_g[4])          // ctxt
1480
                        | (tlb_ldst_va_g[7] &  tlb_ldst_va_g[6]) ;      // type
1481
 
1482
assign  ddemap_by_page  = dmmu_demap_en & ~tlb_ldst_va_g[7] & ~tlb_ldst_va_g[6] ;
1483
assign  ddemap_by_ctxt  = dmmu_demap_en & ~tlb_ldst_va_g[7] &  tlb_ldst_va_g[6] ;
1484
assign  ddemap_all      = dmmu_demap_en &  tlb_ldst_va_g[7] & ~tlb_ldst_va_g[6] ;
1485
 
1486
// assumption is that demap_all is unaffected by presence of reserved ctxt as it
1487
// does not use ctxt.
1488
assign  ddemap_vld      = ((ddemap_by_page | ddemap_by_ctxt) & ~demap_resrv) |
1489
                                ddemap_all ;
1490
 
1491
//wire          dtlb_dmp_by_ctxt_pend ;
1492
wire            dtlb_dmp_all_pend ;
1493
wire            dtlb_dmp_pctxt_pend ;
1494
wire            dtlb_dmp_sctxt_pend ;
1495
wire            dtlb_dmp_nctxt_pend ;
1496
wire    [1:0]    idtlb_dmp_thrid_pend ;
1497
wire    [1:0]    ldst_asi_tid ;
1498
wire            dmmu_inv_all_g, dmmu_inv_all_pend ;
1499
 
1500
assign  dmmu_inv_all_g = dmmu_invalidate_all_en & tlb_st_inst_g ;
1501
 
1502
// Demap/Invalidate
1503 113 albert.wat
dffre_s  #(5) stgw2_dtlbdmp (
1504 95 fafa1971
        .din    ({ddemap_all,demap_pctxt,demap_sctxt,demap_nctxt,dmmu_inv_all_g}),
1505
        .q      ({dtlb_dmp_all_pend,dtlb_dmp_pctxt_pend,dtlb_dmp_sctxt_pend,
1506
                dtlb_dmp_nctxt_pend,dmmu_inv_all_pend }),
1507
        .rst    (tlb_access_rst),       .en     (tlb_access_en),
1508
        .clk    (clk),
1509 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1510 95 fafa1971
        );
1511
 
1512
// Bug 3905 - rm from above flop.
1513
assign  idtlb_dmp_thrid_pend[1:0] = tlb_access_tid_g[1:0] ;
1514
 
1515
assign  ldst_asi_tid[1:0] =
1516
        (lsu_tlu_dtlb_done | dmmu_async_illgl_va_g | immu_async_illgl_va_g)  ?
1517
        idtlb_dmp_thrid_pend[1:0] : thrid_g[1:0] ;
1518
 
1519
// Thread for tlb
1520 113 albert.wat
dff_s  #(4) stg_w2 (
1521 95 fafa1971
        .din    ({ldst_asi_tid[1:0],idtlb_dmp_thrid_pend[1:0]}),
1522
        .q      ({tlu_lsu_ldxa_tid_w2[1:0],tlu_lsu_stxa_ack_tid[1:0]}),
1523
        .clk    (clk),
1524 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1525 95 fafa1971
        );
1526
 
1527
assign  tlu_dtlb_invalidate_all_g = dmmu_inv_all_g | (dmmu_inv_all_pend & ~dtlb_done_d1) ;
1528
//assign        tlu_dtlb_invalidate_all_g = dmmu_inv_all_g | (dmmu_inv_all_pend & ~lsu_tlu_dtlb_done) ;
1529
 
1530
// Timing Change : Delay by a cycle to match vlds.
1531
wire  pre_dtlb_dmp_all, pre_dtlb_dmp_pctxt ;
1532
wire pre_dtlb_dmp_sctxt, pre_dtlb_dmp_nctxt, pre_dtlb_dmp_actxt ;
1533
//assign        pre_dtlb_dmp_by_ctxt = (ddemap_by_ctxt | dtlb_dmp_by_ctxt_pend) & ~tlu_admp_key_sel  ;
1534
assign  pre_dtlb_dmp_all = (ddemap_all | dtlb_dmp_all_pend) & ~tlu_admp_key_sel ;
1535
assign  pre_dtlb_dmp_pctxt = (dtlb_dmp_pctxt_pend) & ~tlu_admp_key_sel ;
1536
assign  pre_dtlb_dmp_sctxt = (dtlb_dmp_sctxt_pend) & ~tlu_admp_key_sel ;
1537
assign  pre_dtlb_dmp_nctxt = (dtlb_dmp_nctxt_pend) & ~tlu_admp_key_sel ;
1538
assign  pre_dtlb_dmp_actxt = tlu_admp_key_sel ;
1539
 
1540 113 albert.wat
dff_s  #(5) dmp_stgd1 (
1541 95 fafa1971
        .din    ({pre_dtlb_dmp_all, pre_dtlb_dmp_pctxt,
1542
                pre_dtlb_dmp_sctxt, pre_dtlb_dmp_nctxt, pre_dtlb_dmp_actxt}),
1543
        .q      ({tlu_dtlb_dmp_all_g,tlu_dtlb_dmp_pctxt_g,
1544
                tlu_dtlb_dmp_sctxt_g,tlu_dtlb_dmp_nctxt_g,tlu_dtlb_dmp_actxt_g}),
1545
        .clk    (clk),
1546 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1547 95 fafa1971
        );
1548
 
1549
assign  tlu_idtlb_dmp_thrid_g = tlb_access_tid_g[1:0] | idtlb_dmp_thrid_pend[1:0] ;
1550
 
1551
 
1552
//=========================================================================================
1553
//      MMU ASI Decode - I-Side
1554
//=========================================================================================
1555
 
1556
// Assumption is that only 9 bits of VA are required.
1557
// Comparison for asi-state and va is to be done uniformly in w2.
1558
 
1559
        assign  immu_tsb_en =
1560
                        immu_zctxt_ps0_tsb_en  | immu_zctxt_ps1_tsb_en |
1561
                        immu_nzctxt_ps0_tsb_en | immu_nzctxt_ps1_tsb_en ;
1562
 
1563
reg     immu_data_in_en_m,immu_data_access_en_m,immu_tag_read_en_m,immu_demap_en_m;
1564
 
1565
// M-stage decoding for long-latency tlb accesses
1566
always  @ (/*AUTOSENSE*/immu_inv_all_asi or lsu_tlu_tlb_asi_state_m
1567
           or lsu_tlu_tlb_ldst_va_m[7:0] or tlb_ldst_inst_m)
1568
        begin
1569
                immu_data_in_en_m =
1570
                 ({lsu_tlu_tlb_asi_state_m[7:0],lsu_tlu_tlb_ldst_va_m[7:0]} == {8'h54,8'h00}) & tlb_ldst_inst_m ;
1571
                // Address specifies tlb entry.
1572
                immu_invalidate_all_en_m =
1573
                 immu_inv_all_asi & tlb_ldst_inst_m ;
1574
                 //({lsu_tlu_tlb_asi_state_m[7:0],lsu_tlu_tlb_ldst_va_m[7:0]} == {8'h60,8'h00}) & tlb_ldst_inst_m ;
1575
                immu_data_access_en_m =
1576
                 ({lsu_tlu_tlb_asi_state_m[7:0]} == {8'h55}) & tlb_ldst_inst_m ;
1577
                // Address specifies tlb entry.
1578
                immu_tag_read_en_m =
1579
                 ({lsu_tlu_tlb_asi_state_m[7:0]} == {8'h56}) & tlb_ldst_inst_m ;
1580
                immu_demap_en_m =
1581
                 ({lsu_tlu_tlb_asi_state_m[7:0]} == {8'h57}) & tlb_ldst_inst_m ;
1582
        end
1583
 
1584
// Stage to g.
1585
// Convert to dffre to resolve conflict between fast-asi and lng-ltncy reads.
1586 113 albert.wat
dffre_s #(5) itlbacc_stgg (
1587 95 fafa1971
        .din    ({immu_data_in_en_m,immu_data_access_en_m,immu_tag_read_en_m,immu_demap_en_m,immu_invalidate_all_en_m}),
1588
        .q      ({immu_data_in_en,immu_data_access_en,immu_tag_read_en,immu_demap_en,immu_invalidate_all_en}),
1589
        .clk    (clk),
1590
        .rst    (lng_ltncy_rst),        .en     (lng_ltncy_en),
1591 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1592 95 fafa1971
        );
1593
 
1594
 
1595
assign  isfsr_asi_wr_en[0] = immu_sync_fsr_en & st_inst_g & thread0_sel_g ;
1596
assign  isfsr_asi_wr_en[1] = immu_sync_fsr_en & st_inst_g & thread1_sel_g ;
1597
assign  isfsr_asi_wr_en[2] = immu_sync_fsr_en & st_inst_g & thread2_sel_g ;
1598
assign  isfsr_asi_wr_en[3] = immu_sync_fsr_en & st_inst_g & thread3_sel_g ;
1599
 
1600
assign  immu_any_sfsr_wr = immu_sync_fsr_en & st_inst_g ; //|(isfsr_asi_wr_en[3:0]);
1601
 
1602
assign  immu_sfsr_wr_en_l[3:0] = ~(isfsr_trp_wr[3:0] | isfsr_asi_wr_en[3:0]) ;
1603
 
1604
assign  immu_tsb_rd_en[0] = immu_tsb_en & ld_inst_g & thread0_sel_g ;
1605
assign  immu_tsb_rd_en[1] = immu_tsb_en & ld_inst_g & thread1_sel_g ;
1606
assign  immu_tsb_rd_en[2] = immu_tsb_en & ld_inst_g & thread2_sel_g ;
1607
assign  immu_tsb_rd_en[3] = immu_tsb_en & ld_inst_g & thread3_sel_g ;
1608
 
1609
assign  immu_data_in_wr_en = immu_data_in_en & tlb_st_inst_g ;  // Write-Only.
1610
assign  immu_data_access_wr_en = immu_data_access_en & tlb_st_inst_g ;
1611
assign  immu_data_access_rd_en = immu_data_access_en & tlb_ld_inst_g ;
1612
 
1613
assign  immu_tag_read_rd_en = immu_tag_read_en & tlb_ld_inst_g ;
1614
 
1615
assign  itlb_rw_index_vld_g = immu_data_access_rd_en | immu_data_access_wr_en | immu_tag_read_rd_en ;
1616
// terminate write if tlb full and signal exception.
1617
assign  itlb_wr_vld_g = (immu_data_in_wr_en | immu_data_access_wr_en) & ~ifu_lsu_memref_d ;
1618
 
1619
wire    itlb_rw_index_vld_pend ;
1620
 
1621 113 albert.wat
dffre_s #(1)  stgw2_itlbctl (
1622 95 fafa1971
        .din    (itlb_rw_index_vld_g),
1623
        .q      (itlb_rw_index_vld_pend),
1624
        .rst    (tlb_access_rst),       .en     (tlb_access_en),
1625
        .clk    (clk),
1626 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1627 95 fafa1971
        );
1628
 
1629
assign  tlu_itlb_rw_index_vld_g  = itlb_rw_index_vld_g | (itlb_rw_index_vld_pend & ~itlb_done_d1) ;
1630
assign  tlu_itlb_rw_index_g[5:0] = tlu_dtlb_rw_index_g[5:0] ;
1631
 
1632
assign  idemap_by_page  = immu_demap_en & ~tlb_ldst_va_g[7] & ~tlb_ldst_va_g[6] ;
1633
assign  idemap_by_ctxt  = immu_demap_en & ~tlb_ldst_va_g[7] &  tlb_ldst_va_g[6] ;
1634
assign  idemap_all      = immu_demap_en &  tlb_ldst_va_g[7] & ~tlb_ldst_va_g[6] ;
1635
 
1636
// assumption is that demap_all is unaffected by presence of reserved ctxt as it
1637
// does not use ctxt.
1638
assign  idemap_vld      = ((idemap_by_page | idemap_by_ctxt) & ~(demap_resrv | demap_sctxt)) |
1639
                                idemap_all ;
1640
 
1641
wire    itlb_dmp_by_ctxt_pend ;
1642
wire    itlb_dmp_all_pend ;
1643
wire    immu_inv_all_g, immu_inv_all_pend ;
1644
 
1645
assign  immu_inv_all_g = immu_invalidate_all_en & tlb_st_inst_g ;
1646
 
1647
// Demap
1648 113 albert.wat
dffre_s  #(3) stgw2_itlbdmp (
1649 95 fafa1971
        .din    ({idemap_by_ctxt,idemap_all,immu_inv_all_g}),
1650
        .q      ({itlb_dmp_by_ctxt_pend, itlb_dmp_all_pend,immu_inv_all_pend}),
1651
        .rst    (tlb_access_rst),       .en     (tlb_access_en),
1652
        .clk    (clk),
1653 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1654 95 fafa1971
        );
1655
 
1656
wire    tlu_itlb_dmp_all_g = (idemap_all | itlb_dmp_all_pend) & ~tlu_admp_key_sel ;
1657
 
1658
assign  tlu_itlb_invalidate_all_g = immu_inv_all_g | (immu_inv_all_pend & ~itlb_done_d1) ;
1659
assign  tlu_itlb_dmp_pctxt_g = tlu_dtlb_dmp_pctxt_g ;
1660
 
1661
// Timing Change - delay by 1-cycle to match vld.
1662
wire    pre_itlb_dmp_actxt ;
1663
assign  pre_itlb_dmp_actxt = tlu_admp_key_sel ;
1664 113 albert.wat
dff_s  #(1) preidmp_d1 (
1665 95 fafa1971
        .din    (pre_itlb_dmp_actxt),
1666
        .q      (tlu_itlb_dmp_actxt_g),
1667
        .clk    (clk),
1668 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1669 95 fafa1971
        );
1670
 
1671
assign  tlu_itlb_dmp_nctxt_g = tlu_dtlb_dmp_nctxt_g ;
1672
 
1673
 
1674
// Adapt key vlds to autodemap.
1675
// Note that sense of global bit has changed. Otherwise vlds remain same.
1676
assign  tlu_dmp_key_vld_g[4:0] =
1677
        (ddemap_by_ctxt | idemap_by_ctxt) ? 5'b00000 :                  // demap-ctxt - include only ctxt 
1678
                        (ddemap_all | idemap_all) ? 5'b00001 :          // demap-all - do not include va or ctxt
1679
                        // Bug 3129             5'b11110 ;              // else include both va and ctxt
1680
                                tlb_ldst_va_g[9] ? 5'b11111 :           // include va and NO ctxt;dmp-pg-real
1681
                                                       5'b11110 ;       // include both va and ctxt; dmp-pg
1682
 
1683
// real tte for demap and write. both are indicated in bit 9 of va.
1684
// demap_by_ctxt will not effect real translations.
1685
assign  tlu_tte_real_g = tlb_ldst_va_g[9] & ~(ddemap_by_ctxt | idemap_by_ctxt) ;
1686
 
1687
//=========================================================================================
1688
//      EXCEPTIONS
1689
//=========================================================================================
1690
 
1691
// Now generated in LSU.
1692
 
1693
// These are all related to asi use.
1694
/*assign        tlu_mmu_sync_data_excp_g =
1695
        (immu_sync_rd_only_asi_g | dmmu_sync_rd_only_asi_g) & st_inst_unflushed & inst_vld_g  ;*/
1696
 
1697
//=========================================================================================
1698
//      TAG/DATA RD/WR/DMP HANDSHAKE
1699
//=========================================================================================
1700
 
1701
// RD/WR HANDSHAKE
1702
// Need to add autodemap capability.
1703
 
1704
// Assume mutually exclusive by construction.
1705
assign  tlb_access_en = itlb_wr_vld_g | immu_data_access_rd_en | immu_tag_read_rd_en |
1706
                        dtlb_wr_vld_g | dmmu_data_access_rd_en | dmmu_tag_read_rd_en |
1707
                        idemap_vld    | ddemap_vld | immu_inv_all_g | dmmu_inv_all_g ;
1708
assign  tlb_access_en_l = ~tlb_access_en ;
1709
assign  tlb_access_rst = ~rst_l | ((lsu_tlu_dtlb_done | ifu_tlu_itlb_done) & ~(tlb_admp_mode | tlb_admp_mode_d1)) ;
1710
assign  tlb_access_rst_l = ~tlb_access_rst ;
1711
 
1712
wire    tlb_access_en_l_d1 ;
1713 113 albert.wat
dff_s  #(1) stgd1_tlbacc (
1714 95 fafa1971
        .din    (tlb_access_en_l),
1715
        .q      (tlb_access_en_l_d1),
1716
        .clk    (clk),
1717 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1718 95 fafa1971
        );
1719
 
1720
assign  tlu_tlb_access_en_l_d1 = tlb_access_en_l_d1 | sehold ;
1721
 
1722
assign  itlb_tag_rd_en = immu_tag_read_rd_en | immu_data_access_rd_en ;
1723
assign  dtlb_tag_rd_en = dmmu_tag_read_rd_en | dmmu_data_access_rd_en ;
1724
 
1725 113 albert.wat
dffre_s #(8)  tlb_access (
1726 95 fafa1971
        .din    ({itlb_wr_vld_g,immu_data_access_rd_en,itlb_tag_rd_en,
1727
                dtlb_wr_vld_g,dmmu_data_access_rd_en,dtlb_tag_rd_en,
1728
                idemap_vld, ddemap_vld}),
1729
        .q      ({itlb_wr_pend,itlb_data_rd_pend,itlb_tag_rd_pend,
1730
                dtlb_wr_pend,dtlb_data_rd_pend,dtlb_tag_rd_pend,
1731
                idemap_pend, ddemap_pend}),
1732
        .rst    (tlb_access_rst),       .en     (tlb_access_en),
1733
        .clk    (clk),
1734 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1735 95 fafa1971
        );
1736
assign  tlu_dtlb_rd_done  = lsu_tlu_dtlb_done & (dtlb_data_rd_pend | dtlb_tag_rd_pend) ;
1737
//assign  itlb_rd_done  = ifu_tlu_itlb_done & (itlb_data_rd_pend | itlb_tag_rd_pend) ;
1738
 
1739
 
1740
// w2 should be renamed to g at some time !!!
1741
// Write may take one extra cycle to get initiated !!!
1742
assign  itlb_wr_vld_unmsked = (itlb_wr_vld_g | (itlb_wr_pend & ~itlb_done_d1)) ;
1743
wire    pre_itlb_wr_vld_g ;
1744
assign pre_itlb_wr_vld_g = (itlb_wr_pend & ~itlb_done_d1) & tlb_write_mode ;
1745
//assign pre_itlb_wr_vld_g = itlb_wr_vld_unmsked & tlb_write_mode ;
1746
// name kept as _g for now to avoid interface change.
1747
 
1748
assign  tlu_itlb_wr_vld_g = pre_itlb_wr_vld_g ;
1749
/*dff  #(1) iwvld_d1 (
1750
        .din    (pre_itlb_wr_vld_g),
1751
        .q      (tlu_itlb_wr_vld_g),
1752
        .clk    (clk),
1753 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1754 95 fafa1971
        ); */
1755
assign  tlu_itlb_data_rd_g = immu_data_access_rd_en | (itlb_data_rd_pend & ~itlb_done_d1) ;
1756
assign  tlu_itlb_tag_rd_g = (immu_tag_read_rd_en | immu_data_access_rd_en) | (itlb_tag_rd_pend & ~itlb_done_d1) ;
1757
 
1758
assign  dtlb_wr_vld_unmsked = (dtlb_wr_vld_g | (dtlb_wr_pend & ~dtlb_done_d1)) ;
1759
wire    pre_dtlb_wr_vld_g ;
1760
assign pre_dtlb_wr_vld_g = (dtlb_wr_pend & ~dtlb_done_d1) & tlb_write_mode ;
1761
// name kept as _g for now to avoid interface change.
1762
 
1763
//assign        tlu_dtlb_wr_vld_g = pre_dtlb_wr_vld_g ;
1764
assign  tlu_dtlb_data_rd_g = dmmu_data_access_rd_en | (dtlb_data_rd_pend & ~dtlb_done_d1) ;
1765
assign  tlu_dtlb_tag_rd_g = (dmmu_tag_read_rd_en | dmmu_data_access_rd_en) | (dtlb_tag_rd_pend & ~dtlb_done_d1) ;
1766
 
1767
// Delay by a cycle - rd for long-latency matches fast-asi.
1768
// Both occur on a posedge.
1769
 
1770
wire    dtlb_dmp_vld_g,itlb_dmp_vld_g;
1771
assign  dtlb_dmp_vld_g =
1772
                // qual with dtlb-done may not be needed. Taken into account in ddemap_pend.
1773
                (ddemap_pend & ~dtlb_done_d1) |
1774
                (dtlb_wr_vld_unmsked & tlb_admp_mode) ;
1775
assign  itlb_dmp_vld_g =
1776
                (idemap_pend & ~itlb_done_d1) |
1777
                (itlb_wr_vld_unmsked & tlb_admp_mode) ;
1778
// dmp_vld should be w2. kept as _g for now to avoid
1779
// interface change.
1780
wire    dtlb_dmp_vld_d1,itlb_dmp_vld_d1 ;
1781 113 albert.wat
dff_s  #(2) dmpvld_d1 (
1782 95 fafa1971
        .din    ({dtlb_dmp_vld_g,itlb_dmp_vld_g}),
1783
        .q      ({dtlb_dmp_vld_d1,itlb_dmp_vld_d1}),
1784
        .clk    (clk),
1785 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1786 95 fafa1971
        );
1787
assign  tlu_dtlb_dmp_vld_g = dtlb_dmp_vld_d1 & ~dtlb_done_d1 ;
1788
assign  tlu_itlb_dmp_vld_g = itlb_dmp_vld_d1 & ~itlb_done_d1 ;
1789
 
1790
wire    stxa_ack ;
1791
 
1792
// Assume mutually exclusive.
1793
// Third term is meant to complete demap with reserved ctxt.
1794
assign  stxa_ack =
1795
        (((itlb_wr_pend | dtlb_wr_pend) & ~(tlb_admp_mode | tlb_admp_mode_d1))  |
1796
        idemap_pend | ddemap_pend | immu_inv_all_pend | dmmu_inv_all_pend) & (lsu_tlu_dtlb_done | ifu_tlu_itlb_done)    |
1797
        (demap_resrv & tlb_st_inst_g &
1798
                ((immu_demap_en & ~idemap_all)  | (dmmu_demap_en & ~ddemap_all))) | //5053
1799
        (demap_sctxt & tlb_st_inst_g & (immu_demap_en & ~idemap_all)) | // Bug5053                                
1800
                                                // iside should not use sctxt
1801
        // lng-latency store needs to signal cmplt to lsu even with illegal va
1802
        (tlb_st_inst_unflushed & (dmmu_async_illgl_va_g | immu_async_illgl_va_g)) ;
1803
 
1804 113 albert.wat
dff_s  #(1) stack_d1 (
1805 95 fafa1971
        .din    (stxa_ack),
1806
        .q      (tlu_lsu_stxa_ack),
1807
        .clk    (clk),
1808 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1809 95 fafa1971
        );
1810
 
1811
//=========================================================================================
1812
//      AUTODEMAP
1813
//=========================================================================================
1814
 
1815
 
1816
assign  tlb_wr_vld_g = itlb_wr_vld_unmsked | dtlb_wr_vld_unmsked ;
1817
 
1818
assign  tlb_admp_en   = tlb_wr_vld_g & ~tlb_admp_mode & ~tlb_write_mode ;
1819
assign  tlb_admp_rst  = ~rst_l |
1820
        (((itlb_wr_pend | dtlb_wr_pend) & (lsu_tlu_dtlb_done | ifu_tlu_itlb_done)) & tlb_admp_mode) ;
1821
assign  tlb_wr_rst  = ~rst_l |
1822
        (((itlb_wr_pend | dtlb_wr_pend) & (lsu_tlu_dtlb_done | ifu_tlu_itlb_done))
1823
                        & tlb_write_mode & ~tlb_admp_mode_d1) ;
1824
 
1825
assign  tlu_admp_key_sel = (dtlb_wr_vld_g | itlb_wr_vld_g) | tlb_admp_mode ;
1826
 
1827
// 1st Phase - Autodemap
1828 113 albert.wat
dffre_s  #(1) dmp1_ff (
1829 95 fafa1971
        .din    (tlb_wr_vld_g),
1830
        .q      (tlb_admp_mode),
1831
        .rst    (tlb_admp_rst), .en     (tlb_admp_en),
1832
        .clk    (clk),
1833 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1834 95 fafa1971
        );
1835
 
1836
 
1837
// this is temporary - IFU is spuriously sourcing extra done signal.
1838 113 albert.wat
dff_s  #(1) admp_d1 (
1839 95 fafa1971
        .din    (tlb_admp_mode),
1840
        .q      (tlb_admp_mode_d1),
1841
        .clk    (clk),
1842 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1843 95 fafa1971
        );
1844
 
1845
// 2nd Phase - Follow-up with Write
1846 113 albert.wat
dffre_s  #(1) dmp2_ff (
1847 95 fafa1971
        .din    (tlb_admp_rst),
1848
        .q      (tlb_write_mode),
1849
        .rst    (tlb_wr_rst),   .en     (tlb_admp_rst),
1850
        .clk    (clk),
1851 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1852 95 fafa1971
        );
1853
 
1854
//=========================================================================================
1855
 
1856
wire    tlu_ldxa_async_data_vld ;
1857
assign  tlu_ldxa_async_data_vld =
1858
        tlu_dtlb_rd_done                |
1859
        (tlb_ld_inst_unflushed & (dmmu_async_illgl_va_g | immu_async_illgl_va_g)) ;
1860
 
1861
assign  tlu_dldxa_data_vld =
1862
// ** need to qualify with inst_vld in LSU
1863
        ((dmmu_tag_target_en_m  |
1864
         dmmu_8k_ptr_en_m       |
1865
         dmmu_64k_ptr_en_m      |
1866
         dmmu_direct_ptr_en_m   |
1867
         dmmu_tsb_en_m          |
1868
         dmmu_tag_access_en_m   |
1869
         dmmu_sync_fsr_en_m     |
1870
         dmmu_sync_far_en_m     |
1871
         dmmu_ctxt_cfg_en_m) & ld_inst_m) ;
1872
        //tlu_dtlb_rd_done              | // complete thru lsu
1873
        // for sync/async lng-latency ldxa with illegal va
1874
        // MMU_ASI
1875
        //(ld_inst_g & dmmu_sync_illgl_va_g) |
1876
        //(tlb_ld_inst_unflushed & dmmu_async_illgl_va_g) ;
1877
 
1878
assign  tlu_ildxa_data_vld =
1879
// ** need to qualify with inst_vld in LSU
1880
        ((immu_tag_target_en_m          |
1881
         immu_8k_ptr_en_m               |
1882
         immu_64k_ptr_en_m              |
1883
         immu_tsb_en_m                  |
1884
         immu_tag_access_en_m           |
1885
         immu_sync_fsr_en_m             |
1886
         immu_ctxt_cfg_en_m) & ld_inst_m)  ;
1887
        // for sync/async lng-latency ldxa with illegal va
1888
        // MMU_ASI
1889
        //(ld_inst_g & immu_sync_illgl_va_g) |
1890
        //(tlb_ld_inst_unflushed & immu_async_illgl_va_g) ;
1891
 
1892
assign  tlu_ldxa_data_vld = tlu_ildxa_data_vld | tlu_dldxa_data_vld ;
1893
 
1894
        // Flush needs to be removed.
1895
        assign  lsu_exu_ldxa_m = tlu_ldxa_data_vld & ~(dmmu_sync_illgl_va_m | immu_sync_illgl_va_m);
1896
 
1897 113 albert.wat
dff_s #(1) stg_asyncdvld (
1898 95 fafa1971
        .din    (tlu_ldxa_async_data_vld),
1899
        .q      (tlu_lsu_ldxa_async_data_vld),
1900
        .clk    (clk),
1901 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1902 95 fafa1971
        );
1903
 
1904
//=========================================================================================
1905
//      SFSR/SFAR Control
1906
//=========================================================================================
1907
 
1908
// In tcl
1909
 
1910
//=========================================================================================
1911
//      PS0 and PS1 Ptr Registers (NEW !!!!)
1912
//=========================================================================================
1913
 
1914
// If N=TSB_Size, P=Page_Size, then
1915
// Ptr = TSB_Base<63:13+N> | VA<21+N+3xP:13+3xP> | 0000 if TSB not split
1916
// Ptr = TSB_Base<63:14+N> | 0 | VA<21+N+3xP:13+3xP> | 0000 if TSB split
1917
// Assume P=0(8K),1(64K),3(4M),5(256M).
1918
// Note that Nmax=11 even though N=0..15, for 256M page. This is because VA cannot exceed 47 for ms bit.
1919
// Otherwise entire range of N can be covered by all 3 remaining page-size.
1920
 
1921
// Timing :
1922
//
1923
//      |   D-stage  |  E-stage | M-stage | W-stage    |        
1924
//      | Read setup | Read +   | Logic + | Latched in |
1925
//      | to mra     | Logic    | xmit    | LSU. Select|        
1926
//      |            |          |         | for wr-back|        
1927
//
1928
 
1929
// TSB Size Logic - Form 8 bits for 8k and 64k Ptr regs respectively.
1930
 
1931
// Macrotest support for logic in shadow of mra scan collar.
1932
// Scan only. Scan value valid in 2nd cycle of macrotest.
1933
wire    mtest_rdps0_sel ;
1934 113 albert.wat
dff_s  #(1) rps0d_d1 (
1935 95 fafa1971
        .din    (1'b0),
1936
        .q      (mtest_rdps0_sel),
1937
        .clk    (clk),
1938 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
1939 95 fafa1971
) ;
1940
 
1941
wire    tsb_rd_ps0_sel ;
1942
assign  tlu_tsb_rd_ps0_sel = tsb_rd_ps0_sel ;
1943
assign  tsb_rd_ps0_sel =
1944
                        ((dmmu_8k_ptr_e | immu_8k_ptr_e |
1945
                        // really _m stage.
1946
                        dmmu_direct_8kptr_sel_g) & ~sehold_d1) | // direct-ptr selects ps0
1947
                        (mtest_rdps0_sel & sehold_d1) ;
1948
 
1949
// Choose between zero and non-zero context
1950
assign  tsb_size[3:0]    =
1951
        tsb_rd_ps0_sel ? tlu_dtsb_size_w2[3:0] : tlu_itsb_size_w2[3:0] ;
1952
assign  tsb_split       =
1953
        tsb_rd_ps0_sel ? tlu_dtsb_split_w2 : tlu_itsb_split_w2 ;
1954
// Mux'ed and staged in mmu_dp.
1955
assign  tag_access[47:13] = tlu_dtag_access_w2[47:13] ;
1956
wire    [2:0]    page_size,tsb_page_size_g ;
1957
assign  page_size[2:0] = tsb_page_size_g[2:0] ;
1958
 
1959
// Currently, all the logic is done in one stage. This will have to
1960
// be rearranged once the read of the mra is advanced. 
1961
 
1962
wire    pg8k,pg64k,pg4M;
1963
assign  pg8k    = ~page_size[2] & ~page_size[1] & ~page_size[0] ; // 000
1964
assign  pg64k   = ~page_size[2] & ~page_size[1] &  page_size[0] ; // 001
1965
assign  pg4M    = ~page_size[2] &  page_size[1] &  page_size[0] ; // 011
1966
//assign        pg256M  =  page_size[2] & ~page_size[1] &  page_size[0] ; // 101
1967
 
1968
// Mux tag-access <36:13>,<39:13>,<45:22>,<51:28> based on page-size.
1969
// Notebook contains greater detail of mapping of base,tag-access to ptr.
1970
wire    [23:0]   va ;
1971
assign  va[23:0] = pg8k ? tag_access[36:13] :
1972
                        pg64k ? tag_access[39:16] :
1973
                                pg4M ? tag_access[45:22] :
1974
                                                {{5{tag_access[47]}},tag_access[46:28]} ;// 256M        
1975
                                                //{4'b0000,tag_access[47:28]} ; // 256M // Bug3727
1976
 
1977
// The ptr address is broken up into 3 regions :
1978
// ptr<3:0>=4'b0000,                 : constant
1979
// ptr<12:4>=va<8:0>                 : va from tag-access only  
1980
// ptr<27:13>=va<23:9>/base<27:13>/0/1 : va from tag-access OR tsb base address OR '0/1' (split).
1981
// ptr<28>=base<28>/0/1              : tsb base address OR '0' (split).
1982
// ptr<47:29>=base<47:29>            : tsb base address. 
1983
 
1984
// Assuming N=0..15. Could be reduced to N=11.
1985
// Need to take exception for unused page size and value of N not compatible with selected page-size.
1986
 
1987
wire [28:13] ptr ;
1988
wire    ps1;
1989
assign ps1 = ~tsb_rd_ps0_sel ;
1990
 
1991
// This is an obvious flop boundary break. 
1992
 
1993
wire    [3:0] tsb_size_d1 ;
1994
wire    tsb_split_d1 ;
1995
wire    [47:13] tsb_base_d1 ;
1996
wire    ps1_d1 ;
1997
wire    [23:0]   va_d1 ;
1998
 
1999 113 albert.wat
dff_s  #(4) tsbsize_stgd1 (
2000 95 fafa1971
        .din    (tsb_size[3:0]),
2001
        .q      (tsb_size_d1[3:0]),
2002
        .clk    (clk),
2003 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2004 95 fafa1971
) ;
2005
 
2006 113 albert.wat
dff_s  #(1) tsbsplit_stgd1 (
2007 95 fafa1971
        .din    (tsb_split),
2008
        .q      (tsb_split_d1),
2009
        .clk    (clk),
2010 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2011 95 fafa1971
) ;
2012
 
2013
assign  tsb_base_d1[47:13] = tlu_tsb_base_w2_d1[47:13] ;
2014
 
2015 113 albert.wat
dff_s  #(1) ps1_stgd1 (
2016 95 fafa1971
        .din    (ps1),
2017
        .q      (ps1_d1),
2018
        .clk    (clk),
2019 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2020 95 fafa1971
) ;
2021
 
2022 113 albert.wat
dff_s  #(24) va_stgd1 (
2023 95 fafa1971
        .din    (va[23:0]),
2024
        .q      (va_d1[23:0]),
2025
        .clk    (clk),
2026 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2027 95 fafa1971
) ;
2028
 
2029
// These equations have to be optimized.
2030
assign  ptr[28] = ((tsb_size_d1==4'd15) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[28] ;
2031
assign  ptr[27] = (tsb_size_d1==4'd15) ? va_d1[23] : ((tsb_size_d1==4'd14) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[27] ;
2032
assign  ptr[26] = (tsb_size_d1>=4'd14) ? va_d1[22] : ((tsb_size_d1==4'd13) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[26] ;
2033
assign  ptr[25] = (tsb_size_d1>=4'd13) ? va_d1[21] : ((tsb_size_d1==4'd12) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[25] ;
2034
assign  ptr[24] = (tsb_size_d1>=4'd12) ? va_d1[20] : ((tsb_size_d1==4'd11) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[24] ;
2035
assign  ptr[23] = (tsb_size_d1>=4'd11) ? va_d1[19] : ((tsb_size_d1==4'd10) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[23] ;
2036
assign  ptr[22] = (tsb_size_d1>=4'd10) ? va_d1[18] : ((tsb_size_d1==4'd9) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[22] ;
2037
assign  ptr[21] = (tsb_size_d1>=4'd9) ? va_d1[17] : ((tsb_size_d1==4'd8) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[21] ;
2038
assign  ptr[20] = (tsb_size_d1>=4'd8) ? va_d1[16] : ((tsb_size_d1==4'd7) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[20] ;
2039
assign  ptr[19] = (tsb_size_d1>=4'd7) ? va_d1[15] : ((tsb_size_d1==4'd6) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[19] ;
2040
assign  ptr[18] = (tsb_size_d1>=4'd6) ? va_d1[14] : ((tsb_size_d1==4'd5) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[18] ;
2041
assign  ptr[17] = (tsb_size_d1>=4'd5) ? va_d1[13] : ((tsb_size_d1==4'd4) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[17] ;
2042
assign  ptr[16] = (tsb_size_d1>=4'd4) ? va_d1[12] : ((tsb_size_d1==4'd3) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[16] ;
2043
assign  ptr[15] = (tsb_size_d1>=4'd3) ? va_d1[11] : ((tsb_size_d1==4'd2) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[15] ;
2044
assign  ptr[14] = (tsb_size_d1>=4'd2) ? va_d1[10] : ((tsb_size_d1==4'd1) & tsb_split_d1) ? ps1_d1 : tsb_base_d1[14] ;
2045
assign  ptr[13] = (tsb_size_d1>=4'd1) ? va_d1[9] :  tsb_split_d1 ? ps1_d1 : tsb_base_d1[13] ;
2046
 
2047
// TSB 8K Ptr. This maps to tsb ps0 ptr !!!
2048
// This is mapped to either PS0 or PS1 ptr. Do not need to send
2049
// 8k and 64K ptrs to mmu_dp.
2050
// Direct ptr needs to be accounted for.
2051
assign  tlu_idtsb_8k_ptr[47:0] =
2052
        {tsb_base_d1[47:29],
2053
        ptr[28:13],
2054
        va_d1[8:0],
2055
        4'b0000};
2056
 
2057
//=========================================================================================
2058
//      Establishing Context for Ptr Read
2059
//=========================================================================================
2060
 
2061
// Context of Ptr Read determined by context within d/i tag-access register. 
2062
// Markers per thread will be maintained to determine whether any subsequent 
2063
// ptr access is made in nucleus or non-nucleus context.
2064
// Note i and d tag-access can be merged within tlu_mmu_dp.v
2065
 
2066
// write of tag-access ctxt needs to be setup in M for subsequent read of MRA in M.
2067
 
2068
assign  tsb_page_size_g[2:0] = tsb_rd_ps0_sel ? tlu_ctxt_cfg_w2[2:0] : tlu_ctxt_cfg_w2[5:3] ;
2069
 
2070
// Listening Flops for Macrotest of mra.
2071 113 albert.wat
dff_s #(6) ctxtcfg_listen (
2072 95 fafa1971
        .din    (tlu_ctxt_cfg_w2[5:0]),
2073
        .q      (),
2074
        .clk    (clk),
2075 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2076 95 fafa1971
        );
2077
 
2078
 
2079
 
2080
//=========================================================================================
2081
//      Direct Ptr State
2082
//=========================================================================================
2083
 
2084
// For new ptr support, if page-size of tte matches that of ps1 then
2085
// direct-ptr maps to ps1-ptr else ps0-ptr.
2086
 
2087
wire    daccess_prot_qual ;
2088
assign  daccess_prot_qual =
2089
lsu_tlu_daccess_prot_g & ~lsu_tlu_daccess_excptn_g &
2090
inst_vld_g & ~(priority_squash_g | flush_mmuasi_wr) ;
2091
 
2092
// For SPARC_HPV_EN, 64k represents ps1 ptr.
2093
assign  dptr0_pg64k_en = daccess_prot_qual & thread0_sel_g ;
2094
assign  dptr1_pg64k_en = daccess_prot_qual & thread1_sel_g ;
2095
assign  dptr2_pg64k_en = daccess_prot_qual & thread2_sel_g ;
2096
assign  dptr3_pg64k_en = daccess_prot_qual & thread3_sel_g ;
2097
 
2098
// For SPARC_HPV_EN this means ps0 sel. This should be an internal
2099
// wire with SPARC_HPV_EN
2100
assign  dmmu_direct_8kptr_sel_g  =
2101
        dmmu_direct_ptr_e & ((thread0_e & ~dptr0_pg64k_vld) |
2102
                                (thread1_e & ~dptr1_pg64k_vld) |
2103
                                (thread2_e & ~dptr2_pg64k_vld) |
2104
                                (thread3_e & ~dptr3_pg64k_vld));
2105
wire    dptr_state_din ;
2106
        assign dptr_state_din = dacc_prot_ps1_match ;
2107
 
2108 113 albert.wat
dffre_s  #(1) dptrstate_0 (
2109 95 fafa1971
        .din    (dptr_state_din),
2110
        .q      (dptr0_pg64k_vld),
2111
        .rst    (~rst_l),       .en     (dptr0_pg64k_en),
2112
        .clk    (clk),
2113 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2114 95 fafa1971
        );
2115
 
2116 113 albert.wat
dffre_s  #(1) dptrstate_1 (
2117 95 fafa1971
        .din    (dptr_state_din),
2118
        .q      (dptr1_pg64k_vld),
2119
        .rst    (~rst_l),       .en     (dptr1_pg64k_en),
2120
        .clk    (clk),
2121 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2122 95 fafa1971
        );
2123
 
2124 113 albert.wat
dffre_s  #(1) dptrstate_2 (
2125 95 fafa1971
        .din    (dptr_state_din),
2126
        .q      (dptr2_pg64k_vld),
2127
        .rst    (~rst_l),       .en     (dptr2_pg64k_en),
2128
        .clk    (clk),
2129 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2130 95 fafa1971
        );
2131
 
2132 113 albert.wat
dffre_s  #(1) dptrstate_3 (
2133 95 fafa1971
        .din    (dptr_state_din),
2134
        .q      (dptr3_pg64k_vld),
2135
        .rst    (~rst_l),       .en     (dptr3_pg64k_en),
2136
        .clk    (clk),
2137 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2138 95 fafa1971
        );
2139
 
2140
//=========================================================================================
2141
//      PS1 PAGE SIZE FOR DMMU
2142
//=========================================================================================
2143
 
2144
// Maintain ps1 page-size for dmmu zero/non-zero ctxt. This is required to compare
2145
// against the page-size of the tte on a data-access-protection to set-up the
2146
// direct-pointer. Note that the real copy is in the mra.
2147
 
2148
wire [2:0] zctxt_cfg0_ps1,zctxt_cfg1_ps1,zctxt_cfg2_ps1,zctxt_cfg3_ps1;
2149
wire [2:0] nzctxt_cfg0_ps1,nzctxt_cfg1_ps1,nzctxt_cfg2_ps1,nzctxt_cfg3_ps1;
2150
wire [3:0] dzctxt_cfg_wr_en ;
2151
wire [3:0] dnzctxt_cfg_wr_en ;
2152
 
2153
assign  dzctxt_cfg_wr_en[3] = dmmu_zctxt_cfg_en & st_inst_g & thread3_sel_g ;
2154
assign  dzctxt_cfg_wr_en[2] = dmmu_zctxt_cfg_en & st_inst_g & thread2_sel_g ;
2155
assign  dzctxt_cfg_wr_en[1] = dmmu_zctxt_cfg_en & st_inst_g & thread1_sel_g ;
2156
assign  dzctxt_cfg_wr_en[0] = dmmu_zctxt_cfg_en & st_inst_g & thread0_sel_g ;
2157
 
2158
assign  dnzctxt_cfg_wr_en[3] = dmmu_nzctxt_cfg_en & st_inst_g & thread3_sel_g ;
2159
assign  dnzctxt_cfg_wr_en[2] = dmmu_nzctxt_cfg_en & st_inst_g & thread2_sel_g ;
2160
assign  dnzctxt_cfg_wr_en[1] = dmmu_nzctxt_cfg_en & st_inst_g & thread1_sel_g ;
2161
assign  dnzctxt_cfg_wr_en[0] = dmmu_nzctxt_cfg_en & st_inst_g & thread0_sel_g ;
2162
 
2163
// Thread0
2164
// Zero-Ctxt Cfg PS1
2165 113 albert.wat
dffe_s #(3)   zctxtps1_0 (
2166 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2167
        .q      (zctxt_cfg0_ps1[2:0]),
2168
        .en     (dzctxt_cfg_wr_en[0]),   .clk (clk),
2169 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2170 95 fafa1971
        );
2171
 
2172
// Non-Zero-Ctxt Cfg PS1
2173 113 albert.wat
dffe_s #(3)   nzctxtps1_0 (
2174 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2175
        .q      (nzctxt_cfg0_ps1[2:0]),
2176
        .en     (dnzctxt_cfg_wr_en[0]),  .clk (clk),
2177 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2178 95 fafa1971
        );
2179
 
2180
// Thread1
2181
// Zero-Ctxt Cfg PS1
2182 113 albert.wat
dffe_s #(3)   zctxtps1_1 (
2183 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2184
        .q      (zctxt_cfg1_ps1[2:0]),
2185
        .en     (dzctxt_cfg_wr_en[1]),  .clk (clk),
2186 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2187 95 fafa1971
        );
2188
 
2189
// Non-Zero-Ctxt Cfg PS1
2190 113 albert.wat
dffe_s #(3)   nzctxtps1_1 (
2191 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2192
        .q      (nzctxt_cfg1_ps1[2:0]),
2193
        .en     (dnzctxt_cfg_wr_en[1]),         .clk (clk),
2194 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2195 95 fafa1971
        );
2196
 
2197
// Thread2
2198
// Zero-Ctxt Cfg PS1
2199 113 albert.wat
dffe_s #(3)   zctxtps1_2 (
2200 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2201
        .q      (zctxt_cfg2_ps1[2:0]),
2202
        .en     (dzctxt_cfg_wr_en[2]),  .clk (clk),
2203 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2204 95 fafa1971
        );
2205
 
2206
// Non-Zero-Ctxt Cfg PS1
2207 113 albert.wat
dffe_s #(3)   nzctxtps1_2 (
2208 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2209
        .q      (nzctxt_cfg2_ps1[2:0]),
2210
        .en     (dnzctxt_cfg_wr_en[2]),         .clk (clk),
2211 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2212 95 fafa1971
        );
2213
 
2214
// Thread3
2215
// Zero-Ctxt Cfg PS1
2216 113 albert.wat
dffe_s #(3)   zctxtps1_3 (
2217 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2218
        .q      (zctxt_cfg3_ps1[2:0]),
2219
        .en     (dzctxt_cfg_wr_en[3]),  .clk (clk),
2220 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2221 95 fafa1971
        );
2222
 
2223
// Non-Zero-Ctxt Cfg PS1
2224 113 albert.wat
dffe_s #(3)   nzctxtps1_3 (
2225 95 fafa1971
        .din    (lsu_tlu_st_rs3_data_b12t0_g[10:8]),
2226
        .q      (nzctxt_cfg3_ps1[2:0]),
2227
        .en     (dnzctxt_cfg_wr_en[3]),         .clk (clk),
2228 113 albert.wat
        .se     (1'b0),         `SIMPLY_RISC_SCANIN,          .so ()
2229 95 fafa1971
        );
2230
 
2231
 
2232
wire [2:0] zctxt_cfg_ps1,nzctxt_cfg_ps1 ;
2233
 
2234
assign  zctxt_cfg_ps1[2:0] =
2235
        thread0_sel_g ? zctxt_cfg0_ps1[2:0] :
2236
                thread1_sel_g ? zctxt_cfg1_ps1[2:0] :
2237
                        thread2_sel_g ? zctxt_cfg2_ps1[2:0] :
2238
                                                zctxt_cfg3_ps1[2:0] ;
2239
 
2240
assign  nzctxt_cfg_ps1[2:0] =
2241
        thread0_sel_g ? nzctxt_cfg0_ps1[2:0] :
2242
                thread1_sel_g ? nzctxt_cfg1_ps1[2:0] :
2243
                        thread2_sel_g ? nzctxt_cfg2_ps1[2:0] :
2244
                                                nzctxt_cfg3_ps1[2:0] ;
2245
wire    nucleus_ctxt_g ;
2246 113 albert.wat
dff_s nctxt_stgg(
2247 95 fafa1971
        .din    (lsu_tlu_nucleus_ctxt_m),
2248
        .q      (nucleus_ctxt_g),
2249
        .clk    (clk),
2250 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2251 95 fafa1971
        );
2252
 
2253
wire    [2:0]    ctxt_cfg_ps1 ;
2254
assign  ctxt_cfg_ps1[2:0] =
2255
        nucleus_ctxt_g ? zctxt_cfg_ps1[2:0] : nzctxt_cfg_ps1[2:0] ;
2256
 
2257
assign  dacc_prot_ps1_match
2258
        = (lsu_tlu_tte_pg_sz_g[2:0] == ctxt_cfg_ps1[2:0]) ;
2259
 
2260
//=========================================================================================
2261
//      CTXT SEL
2262
//=========================================================================================
2263
 
2264
wire    thread_tl_zero_e,thread_tl_zero_m ;
2265
assign thread_tl_zero_e =
2266
        thread0_e ? tlu_lsu_tl_zero[0] :
2267
                thread1_e ? tlu_lsu_tl_zero[1] :
2268
                        thread2_e ? tlu_lsu_tl_zero[2] : tlu_lsu_tl_zero[3];
2269
 
2270 113 albert.wat
dff_s tlz_stgm(
2271 95 fafa1971
        .din    (thread_tl_zero_e),
2272
        .q      (thread_tl_zero_m),
2273
        .clk    (clk),
2274 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2275 95 fafa1971
        );
2276
 
2277
// Generate selects for ctxt to be written to tag_access
2278
// iside trap meant to cover immu_miss and inst_access_excp
2279
// modified for hypervisor support
2280
// assign       iside_trap = exu_tlu_ttype_vld_m | immu_va_oor_brnchetc_m | exu_tlu_va_oor_jl_ret_m;
2281
 
2282
wire    pstate_am_e,pstate_am_m;
2283
assign  pstate_am_e =
2284
        (thread0_e & tlu_lsu_pstate_am[0]) |
2285
        (thread1_e & tlu_lsu_pstate_am[1]) |
2286
        (thread2_e & tlu_lsu_pstate_am[2]) |
2287
        (thread3_e & tlu_lsu_pstate_am[3]);
2288
 
2289 113 albert.wat
dff_s pam_stgm(
2290 95 fafa1971
        .din    (pstate_am_e),
2291
        .q      (pstate_am_m),
2292
        .clk    (clk),
2293 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2294 95 fafa1971
        );
2295
 
2296
wire    immu_va_oor_brnchetc_m ;
2297
assign  immu_va_oor_brnchetc_m
2298
        = exu_tlu_va_oor_m & ~pstate_am_m & ~memref_m;
2299
 
2300
wire iside_trap ;
2301
assign  iside_trap =
2302
            ifu_tlu_immu_miss_m | // exu_tlu_ttype_vld_m : Rm along with Bug 5346
2303
            immu_va_oor_brnchetc_m | exu_tlu_va_oor_jl_ret_m |
2304
            ifu_tlu_priv_violtn_m ; // Bug 5346.
2305
assign  tlu_tag_access_ctxt_sel_m[0] = iside_trap &  thread_tl_zero_m;
2306
assign  tlu_tag_access_ctxt_sel_m[1] = iside_trap & ~thread_tl_zero_m;
2307
assign  tlu_tag_access_ctxt_sel_m[2] = ~iside_trap;
2308
 
2309
 
2310
//=========================================================================================
2311
//      TLB Write Data
2312
//=========================================================================================
2313
 
2314
wire    [2:0]    pg_size ;
2315
wire            page_8k, page_64k, page_4m ;
2316
wire            va_15_13_vld, va_21_16_vld, va_27_22_vld ;
2317
 
2318
assign sun4r_tte_g = ~tlb_ldst_va_g[10] ;
2319
 
2320
assign tlu_sun4r_tte_g = sun4r_tte_g ;
2321
 
2322
assign  pg_size[2:0]     =
2323
        sun4r_tte_g ? {lsu_tlu_st_rs3_data_b48_g,lsu_tlu_st_rs3_data_g[62:61]} :
2324
                        {lsu_tlu_st_rs3_data_b12t0_g[2:0]} ;
2325
 
2326
assign  page_8k         = ~pg_size[2] & ~pg_size[1] & ~pg_size[0] ;
2327
assign  page_64k        = ~pg_size[2] & ~pg_size[1] &  pg_size[0] ;
2328
assign  page_4m         = ~pg_size[2] &  pg_size[1] &  pg_size[0] ;
2329
//assign        page_256m       =  pg_size[2] & ~pg_size[1] &  pg_size[0] ;     
2330
 
2331
assign  va_15_13_vld    = page_8k ;
2332
assign  va_21_16_vld    = page_8k | page_64k  ;
2333
assign  va_27_22_vld    = page_8k | page_64k | page_4m ;
2334
 
2335
assign  tlu_tte_tag_g[2:0] = {va_27_22_vld,va_21_16_vld,va_15_13_vld} ;
2336
 
2337
assign  thread0_async_g = ~tlb_access_tid_g[1] & ~tlb_access_tid_g[0] ;
2338
assign  thread1_async_g = ~tlb_access_tid_g[1] &  tlb_access_tid_g[0] ;
2339
assign  thread2_async_g =  tlb_access_tid_g[1] & ~tlb_access_tid_g[0] ;
2340
//assign        thread3_async_g =  tlb_access_tid_g[1] &  tlb_access_tid_g[0] ; // to be used in instanced mux
2341
 
2342
assign  tlu_tte_wr_pid_g[2:0] =
2343
        thread0_async_g ? lsu_pid_state0[2:0] :
2344
                thread1_async_g ? lsu_pid_state1[2:0] :
2345
                        thread2_async_g ? lsu_pid_state2[2:0] : lsu_pid_state3[2:0] ;
2346
 
2347
// Error Injection :
2348
// Error injection is one-shot. It will occur for either dmmu or immu. The ifu
2349
// is informed once the error injection is accomplished.
2350
 
2351
wire    i_tag_invrt_par,d_tag_invrt_par ;
2352
wire    i_data_invrt_par,d_data_invrt_par ;
2353
assign tlu_tlb_tag_invrt_parity = i_tag_invrt_par | d_tag_invrt_par ;
2354
assign i_tag_invrt_par = (ifu_lsu_error_inj[2] & (immu_data_in_en | immu_data_access_en)) ;
2355
assign d_tag_invrt_par = (ifu_lsu_error_inj[0] & (dmmu_data_in_en | dmmu_data_access_en)) ;
2356
assign tlu_tlb_data_invrt_parity = i_data_invrt_par | d_data_invrt_par ;
2357
assign i_data_invrt_par = (ifu_lsu_error_inj[3] & (immu_data_in_en | immu_data_access_en)) ;
2358
assign d_data_invrt_par = (ifu_lsu_error_inj[1] & (dmmu_data_in_en | dmmu_data_access_en)) ;
2359
 
2360
wire tlb_wr_vld ;
2361
assign tlb_wr_vld = dtlb_wr_vld_g | itlb_wr_vld_g ;
2362
wire [3:0] err_inj_ack ;
2363
assign  err_inj_ack[0] = tlb_wr_vld & d_tag_invrt_par ;
2364
assign  err_inj_ack[1] = tlb_wr_vld & d_data_invrt_par ;
2365
assign  err_inj_ack[2] = tlb_wr_vld & i_tag_invrt_par ;
2366
assign  err_inj_ack[3] = tlb_wr_vld & i_data_invrt_par ;
2367
 
2368 113 albert.wat
dff_s #(4) err_inj (
2369 95 fafa1971
        .din    (err_inj_ack[3:0]),
2370
        .q      (lsu_ifu_inj_ack[3:0]),
2371
        .clk    (clk),
2372 113 albert.wat
        .se     (1'b0),       `SIMPLY_RISC_SCANIN,          .so ()
2373 95 fafa1971
        );
2374
 
2375
endmodule

powered by: WebSVN 2.1.0

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