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

Subversion Repositories sparc64soc

[/] [sparc64soc/] [trunk/] [T1-CPU/] [lsu/] [lsu_dctldp.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dmitryr
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: lsu_dctldp.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21
/////////////////////////////////////////////////////////////////
22
 
23
//FPGA_SYN enables all FPGA related modifications
24
`ifdef FPGA_SYN
25
`define FPGA_SYN_CLK_EN
26
`define FPGA_SYN_CLK_DFF
27
`endif
28
 
29
module lsu_dctldp (/*AUTOARG*/
30
   // Outputs
31
   so, asi_d, lsu_excpctl_asi_state_m, lsu_dctl_asi_state_m,
32
   lsu_spu_asi_state_e, lsu_tlu_rsr_data_e, lsu_asi_state,
33
   lsu_asi_reg0, lsu_asi_reg1, lsu_asi_reg2, lsu_asi_reg3,
34
   lsu_t0_pctxt_state, lsu_t1_pctxt_state, lsu_t2_pctxt_state,
35
   lsu_t3_pctxt_state, lsu_tlu_dside_ctxt_m, lsu_tlu_pctxt_m,
36
   tlb_ctxt, lsu_pid_state0, lsu_pid_state1, lsu_pid_state2,
37
   lsu_pid_state3, lsu_dtlb_cam_pid_e, bist_ctl_reg_in,
38
   lsu_ifu_direct_map_l1, dc_direct_map, lsu_iobrdge_rd_data,
39
   lsu_ictag_mrgn, lsu_dctag_mrgn, lsu_mamem_mrgn, lsu_dtlb_mrgn,
40
   lsu_itlb_mrgn, lsu_local_ldxa_data_g, lsu_ldst_va_m,
41
   lsu_ldst_va_m_buf, lsu_tlu_ldst_va_m, lsu_tlu_tlb_asi_state_m,
42
   lsu_ifu_asi_state, lsu_tlu_tlb_ldst_va_m, lsu_tlu_tlb_dmp_va_m,
43
   lsu_ifu_asi_addr, lsu_diagnstc_wr_addr_e,
44
   lsu_diagnstc_dc_prty_invrt_e, lsu_ifu_err_addr,
45
   va_wtchpt_msk_match_m, lsu_ldst_va_g, lsu_dp_ctl_reg0,
46
   lsu_dp_ctl_reg1, lsu_dp_ctl_reg2, lsu_dp_ctl_reg3,
47
   lsu_diagnstc_wr_way_e, lsu_diag_va_prty_invrt,
48
   // Inputs
49
   rclk, rst_l, si, se, async_tlb_index, lsu_dtlb_dmp_vld_e,
50
   tlu_lsu_asi_m, exu_tlu_wsr_data_m, tlu_lsu_asi_update_g,
51
   asi_state_wr_thrd, ifu_lsu_imm_asi_d, thread0_d, thread1_d,
52
   thread2_d, thread3_d, ifu_lsu_imm_asi_vld_d, lsu_err_addr_sel,
53
   pctxt_state_wr_thrd, sctxt_state_wr_thrd, st_rs3_data_g,
54
   thread0_ctxt, thread1_ctxt, thread2_ctxt, thread3_ctxt,
55
   thread_pctxt, thread_sctxt, thread_actxt, thread_default,
56
   tlu_dtlb_tte_tag_w2, tlu_dtlb_tte_tag_b58t56, thread0_g,
57
   thread1_g, thread2_g, thread3_g, pid_state_wr_en, thread0_e,
58
   thread1_e, thread2_e, thread3_e, thread0_m, thread1_m, thread2_m,
59
   thread3_m, lsu_iobrdge_wr_data, dfture_tap_wr_mx_sel, lctl_rst,
60
   lsu_ctl_state_wr_en, lsuctl_ctlbits_wr_en, dfture_tap_rd_en,
61
   bist_tap_wr_en, bist_ctl_reg_out, mrgn_tap_wr_en, ldiagctl_wr_en,
62
   misc_ctl_sel_din, lsu_asi_sel_fmx1, lsu_asi_sel_fmx2,
63
   exu_lsu_ldst_va_e, tlb_access_en0_g, tlb_access_en1_g,
64
   tlb_access_en2_g, tlb_access_en3_g, tlb_access_sel_thrd0,
65
   tlb_access_sel_thrd1, tlb_access_sel_thrd2,
66
   tlb_access_sel_default, mrgnctl_wr_en, lsu_dcfill_addr_e,
67
   lsu_error_pa_m, stb_ldst_byte_msk, lsu_diagnstc_va_sel,
68
   rst_tri_en
69
   );
70
 
71
   input rclk;
72
   input rst_l;
73
   input si;
74
   input se;
75
//   input tmb_l ;
76
 
77
   output so;
78
 
79
//   input      async_error_sel ;
80
   input [5:0]   async_tlb_index ;
81
 
82
   input        lsu_dtlb_dmp_vld_e ;
83
 
84
   input [7:0] tlu_lsu_asi_m;
85
   input [7:0] exu_tlu_wsr_data_m;
86
   input       tlu_lsu_asi_update_g;
87
   input [3:0] asi_state_wr_thrd;
88
   input [7:0] ifu_lsu_imm_asi_d;
89
   input       thread0_d;
90
   input       thread1_d;
91
   input       thread2_d;
92
   input       thread3_d;
93
   input       ifu_lsu_imm_asi_vld_d;
94
 
95
   input [2:0]   lsu_err_addr_sel ;
96
 
97
   output [7:0] asi_d;
98
   output [7:0] lsu_excpctl_asi_state_m;
99
   output [7:0] lsu_dctl_asi_state_m;
100
 
101
   output [7:0] lsu_spu_asi_state_e;
102
   output [7:0] lsu_tlu_rsr_data_e;
103
 
104
   output  [7:0]   lsu_asi_state ;   // ASI State + imm asi
105
   output  [7:0]   lsu_asi_reg0 ;    // ASI State Register.
106
   output  [7:0]   lsu_asi_reg1 ;    // ASI State Register.
107
   output  [7:0]   lsu_asi_reg2 ;    // ASI State Register.
108
   output  [7:0]   lsu_asi_reg3 ;    // ASI State Register.
109
 
110
input  [3:0] pctxt_state_wr_thrd ;
111
input  [3:0] sctxt_state_wr_thrd ;
112
//input [63:0] st_rs3_data_g;
113
//input [59:56] st_rs3_data_g_59_56;
114
//input [51:48] st_rs3_data_g_51_48;
115
//input [43:40] st_rs3_data_g_43_40;
116
input [32:0]  st_rs3_data_g;
117
 
118
   input     thread0_ctxt;  //should be one hot, force default
119
   input     thread1_ctxt;
120
   input     thread2_ctxt;
121
   input     thread3_ctxt;
122
 
123
   input     thread_pctxt;
124
   input     thread_sctxt;
125
//   input     thread_nctxt;    
126
   input     thread_actxt;
127
   input     thread_default;
128
 
129
input [12:0]  tlu_dtlb_tte_tag_w2 ;
130
input [2:0]      tlu_dtlb_tte_tag_b58t56 ;
131
 
132
   input       thread0_g;
133
   input       thread1_g;
134
   input       thread2_g;
135
   input       thread3_g;
136
 
137
output  [12:0]    lsu_t0_pctxt_state ;  // primary ctxt - thread0
138
output  [12:0]    lsu_t1_pctxt_state ;  // primary ctxt - thread1
139
output  [12:0]    lsu_t2_pctxt_state ;  // primary ctxt - thread2
140
output  [12:0]    lsu_t3_pctxt_state ;  // primary ctxt - thread3
141
 
142
output  [12:0]    lsu_tlu_dside_ctxt_m ;
143
output  [12:0]    lsu_tlu_pctxt_m ;
144
output  [12:0]    tlb_ctxt ;    // ctxt for xslate or demap.
145
 
146
   input [3:0]    pid_state_wr_en;
147
   input          thread0_e;
148
   input          thread1_e;
149
   input          thread2_e;
150
   input          thread3_e;
151
 
152
   input          thread0_m;
153
   input          thread1_m;
154
   input          thread2_m;
155
   input          thread3_m;
156
 
157
output  [2:0]    lsu_pid_state0 ;        // pid thread0 ; global use
158
output  [2:0]    lsu_pid_state1 ;        // pid thread1 ; global use
159
output  [2:0]    lsu_pid_state2 ;        // pid thread2 ; global use
160
output  [2:0]    lsu_pid_state3 ;        // pid thread3 ; global use
161
output  [2:0] lsu_dtlb_cam_pid_e ;
162
 
163
input [27:0]  lsu_iobrdge_wr_data ;
164
   input      dfture_tap_wr_mx_sel;
165
   input [3:0] lctl_rst;
166
   input [3:0] lsu_ctl_state_wr_en;
167
   input [3:0] lsuctl_ctlbits_wr_en;
168
   input [3:0] dfture_tap_rd_en;
169
 
170
   input      bist_tap_wr_en;
171
//  input      bistctl_wr_en;
172
   output [6:0] bist_ctl_reg_in;
173
 
174
   input [10:0] bist_ctl_reg_out;
175
 
176
   input      mrgn_tap_wr_en;
177
 
178
   output               lsu_ifu_direct_map_l1 ; // l1 icache set to direct map.
179
   output   dc_direct_map;
180
   input    ldiagctl_wr_en;
181
 
182
   output [43:0] lsu_iobrdge_rd_data ;
183
 
184
   input [3:0]  misc_ctl_sel_din ;  //should force default
185
 
186
output  [3:0]    lsu_ictag_mrgn ;        // icache tag self-timed margin control
187
output  [3:0]    lsu_dctag_mrgn ;        // dcache tag self-timed margin control
188
 
189
output  [3:0]    lsu_mamem_mrgn ;        // mamem self-timed margin control
190
output  [7:0]    lsu_dtlb_mrgn ;   // dtlb self-timed margin control
191
output  [7:0]    lsu_itlb_mrgn ;   // itlb self-timed margin control
192
 
193
output  [47:0]    lsu_local_ldxa_data_g ;  // local ldxa data
194
 
195
//   input          misc_asi_rd_en;
196
//input [47:3]  lsu_va_wtchpt_addr ;
197
   input [2:0] lsu_asi_sel_fmx1;
198
   input [2:0] lsu_asi_sel_fmx2;
199
 
200
input  [47:0]  exu_lsu_ldst_va_e;      // sub VA for mem-ref (src-execute)
201
 
202
output [12:0]  lsu_ldst_va_m;
203
output [47:0]  lsu_ldst_va_m_buf;
204
output [9:0]  lsu_tlu_ldst_va_m;
205
 
206
   input       tlb_access_en0_g;
207
   input       tlb_access_en1_g;
208
   input       tlb_access_en2_g;
209
   input       tlb_access_en3_g;
210
 
211
output  [7:0]   lsu_tlu_tlb_asi_state_m ;
212
output  [7:0]   lsu_ifu_asi_state;
213
 
214
   input tlb_access_sel_thrd0;
215
   input tlb_access_sel_thrd1;
216
   input tlb_access_sel_thrd2;
217
   input tlb_access_sel_default;
218
 
219
output  [10:0]   lsu_tlu_tlb_ldst_va_m ;
220
output  [47:13]         lsu_tlu_tlb_dmp_va_m ;
221
output  [17:0]    lsu_ifu_asi_addr ;
222
 
223
   output [10:0]  lsu_diagnstc_wr_addr_e ;
224
   output [7:0]   lsu_diagnstc_dc_prty_invrt_e ;
225
 
226
///  output [13:11] lsu_lngltncy_ldst_va;
227
 
228
   input mrgnctl_wr_en;
229
input [10:4]  lsu_dcfill_addr_e ;         // data cache fill addr
230
input [28:0]  lsu_error_pa_m ;            // error phy addr
231
//   input      sync_error_sel;
232
   output  [47:4]    lsu_ifu_err_addr ;    // error address
233
 
234
input [7:0]   stb_ldst_byte_msk ;
235
   output va_wtchpt_msk_match_m;
236
 
237
   output [7:0]  lsu_ldst_va_g;
238
 
239
   output [5:0] lsu_dp_ctl_reg0;
240
   output [5:0] lsu_dp_ctl_reg1;
241
   output [5:0] lsu_dp_ctl_reg2;
242
   output [5:0] lsu_dp_ctl_reg3;
243
 
244
   input   [3:0] lsu_diagnstc_va_sel ;
245
   output  [1:0] lsu_diagnstc_wr_way_e ;
246
   output        lsu_diag_va_prty_invrt ;
247
   input   rst_tri_en;
248
 
249
wire  [12:0]  pctxt_state;
250
wire  [12:0]  sctxt_state;
251
wire  [2:0]   pid_state;
252
 
253
wire   [13:0] lsu_ctl_reg0;
254
wire   [13:0] lsu_ctl_reg1;
255
wire   [13:0] lsu_ctl_reg2;
256
wire   [13:0] lsu_ctl_reg3;
257
 
258
wire   [13:0] lsu_ctl_reg;
259
 
260
   wire       clk;
261
   assign     clk = rclk;
262
 
263
/********************* ASI state ***********************/
264
   wire [7:0]  tlu_lsu_asi_g;
265
 
266
dff_s #(8) asi_stgw (
267
        .din    (tlu_lsu_asi_m[7:0]),
268
        .q      (tlu_lsu_asi_g[7:0]),
269
        .clk    (clk),
270
        .se     (se),       .si (),          .so ()
271
        );
272
 
273
   wire [7:0]  exu_tlu_wsr_data_w;
274
 
275
dff_s #(8) ff_wsr_data_w (
276
        .din    (exu_tlu_wsr_data_m[7:0]),
277
        .q      (exu_tlu_wsr_data_w[7:0]),
278
        .clk    (clk),
279
        .se     (se),       .si (),          .so ()
280
        );
281
 
282
   wire [7:0]  asi_wr_din;
283
 
284
assign  asi_wr_din[7:0] = tlu_lsu_asi_update_g ? tlu_lsu_asi_g[7:0] : exu_tlu_wsr_data_w[7:0] ;
285
 
286
// ASI - Thread0
287
   wire [7:0] asi_state0;
288
   wire [7:0] lsu_asi_reg0;
289
 
290
   wire       asi0_state_clk;
291
 
292
`ifdef FPGA_SYN_CLK_EN
293
`else
294
clken_buf asi0_state_clkbuf (
295
                .rclk   (clk),
296
                .enb_l  (~asi_state_wr_thrd[0]),
297
                .tmb_l  (~se),
298
                .clk    (asi0_state_clk)
299
                ) ;
300
`endif
301
 
302
`ifdef FPGA_SYN_CLK_DFF
303
dffe_s #(8) asi0_state_ff (
304
        .din    (asi_wr_din[7:0]),
305
        .q      (asi_state0[7:0]),
306
        .en (~(~asi_state_wr_thrd[0])), .clk(clk),
307
        .se     (se),       .si (),          .so ()
308
        );
309
`else
310
dff_s #(8) asi0_state_ff (
311
        .din    (asi_wr_din[7:0]),
312
        .q      (asi_state0[7:0]),
313
        .clk    (asi0_state_clk),
314
        .se     (se),       .si (),          .so ()
315
        );
316
`endif
317
 
318
assign  lsu_asi_reg0[7:0] = asi_state0[7:0] ;
319
 
320
// ASI - Thread1
321
   wire [7:0] asi_state1;
322
   wire [7:0] lsu_asi_reg1;
323
 
324
   wire       asi1_state_clk;
325
 
326
`ifdef FPGA_SYN_CLK_EN
327
`else
328
clken_buf asi1_state_clkbuf (
329
                .rclk   (clk),
330
                .enb_l  (~asi_state_wr_thrd[1]),
331
                .tmb_l  (~se),
332
                .clk    (asi1_state_clk)
333
                ) ;
334
`endif
335
 
336
`ifdef FPGA_SYN_CLK_DFF
337
dffe_s #(8) asi1_state_ff (
338
        .din    (asi_wr_din[7:0]),
339
        .q      (asi_state1[7:0]),
340
        .en (~(~asi_state_wr_thrd[1])), .clk(clk),
341
        .se     (se),       .si (),          .so ()
342
        );
343
`else
344
dff_s #(8) asi1_state_ff (
345
        .din    (asi_wr_din[7:0]),
346
        .q      (asi_state1[7:0]),
347
        .clk    (asi1_state_clk),
348
        .se     (se),       .si (),          .so ()
349
        );
350
`endif
351
 
352
assign  lsu_asi_reg1[7:0] = asi_state1[7:0] ;
353
 
354
// ASI - Thread2
355
   wire [7:0] asi_state2;
356
   wire [7:0] lsu_asi_reg2;
357
 
358
   wire       asi2_state_clk;
359
 
360
`ifdef FPGA_SYN_CLK_EN
361
`else
362
clken_buf asi2_state_clkbuf (
363
                .rclk   (clk),
364
                .enb_l  (~asi_state_wr_thrd[2]),
365
                .tmb_l  (~se),
366
                .clk    (asi2_state_clk)
367
                ) ;
368
`endif
369
 
370
`ifdef FPGA_SYN_CLK_DFF
371
dffe_s #(8) asi2_state_ff (
372
        .din    (asi_wr_din[7:0]),
373
        .q      (asi_state2[7:0]),
374
        .en (~(~asi_state_wr_thrd[2])), .clk(clk),
375
        .se     (se),       .si (),          .so ()
376
        );
377
`else
378
dff_s #(8) asi2_state_ff (
379
        .din    (asi_wr_din[7:0]),
380
        .q      (asi_state2[7:0]),
381
        .clk    (asi2_state_clk),
382
        .se     (se),       .si (),          .so ()
383
        );
384
`endif
385
 
386
assign  lsu_asi_reg2[7:0] = asi_state2[7:0] ;
387
 
388
// ASI - Thread3
389
   wire [7:0] asi_state3;
390
   wire [7:0] lsu_asi_reg3;
391
 
392
   wire       asi3_state_clk;
393
 
394
`ifdef FPGA_SYN_CLK_EN
395
`else
396
clken_buf asi3_state_clkbuf (
397
                .rclk   (clk),
398
                .enb_l  (~asi_state_wr_thrd[3]),
399
                .tmb_l  (~se),
400
                .clk    (asi3_state_clk)
401
                ) ;
402
`endif
403
 
404
`ifdef FPGA_SYN_CLK_DFF
405
dffe_s #(8) asi3_state_ff (
406
        .din    (asi_wr_din[7:0]),
407
        .q      (asi_state3[7:0]),
408
        .en (~(~asi_state_wr_thrd[3])), .clk(clk),
409
        .se     (se),       .si (),          .so ()
410
        );
411
`else
412
dff_s #(8) asi3_state_ff (
413
        .din    (asi_wr_din[7:0]),
414
        .q      (asi_state3[7:0]),
415
        .clk    (asi3_state_clk),
416
        .se     (se),       .si (),          .so ()
417
        );
418
`endif
419
 
420
assign  lsu_asi_reg3[7:0] = asi_state3[7:0] ;
421
 
422
   wire [7:0] asi_state;
423
 
424
mux4ds #(8) lsu_asi_mux_d (
425
   .in0 (asi_state0[7:0]),
426
   .in1 (asi_state1[7:0]),
427
   .in2 (asi_state2[7:0]),
428
   .in3 (asi_state3[7:0]),
429
   .sel0(thread0_d),
430
   .sel1(thread1_d),
431
   .sel2(thread2_d),
432
   .sel3(thread3_d),
433
   .dout(asi_state[7:0])
434
   );
435
 
436
assign  asi_d[7:0] = ifu_lsu_imm_asi_vld_d ?
437
                     ifu_lsu_imm_asi_d[7:0] : asi_state[7:0];
438
 
439
wire  [7:0] asi_state_e, asi_state_m ;
440
 
441
dff_s #(8) asistate_stge (
442
        .din    (asi_d[7:0]),
443
        .q      (asi_state_e[7:0]),
444
        .clk    (clk),
445
        .se     (se),       .si (),          .so ()
446
        );
447
 
448
// Make rsr_data independent of imm_asi.
449
dff_s #(8) rdasi_stge (
450
        .din    (asi_state[7:0]),
451
        .q      (lsu_tlu_rsr_data_e[7:0]),
452
        .clk    (clk),
453
        .se     (se),       .si (),          .so ()
454
        );
455
 
456
//assign lsu_tlu_rsr_data_e[7:0] =  asi_state_e[7:0] ;
457
 
458
assign  lsu_spu_asi_state_e[7:0] = asi_state_e[7:0] ;
459
 
460
dff_s #(8) asistate_stgm (
461
        .din    (asi_state_e[7:0]),
462
        .q      (asi_state_m[7:0]),
463
        .clk    (clk),
464
        .se     (se),       .si (),          .so ()
465
        );
466
 
467
assign  lsu_excpctl_asi_state_m[7:0] = asi_state_m[7:0] ;
468
assign  lsu_dctl_asi_state_m[7:0]    = asi_state_m[7:0] ;
469
 
470
   wire [7:0] lsu_asi_state;
471
dff_s #(8) asistate_stgg (
472
        .din    (asi_state_m[7:0]),
473
        .q      (lsu_asi_state[7:0]),
474
        .clk    (clk),
475
        .se     (se),       .si (),          .so ()
476
        );
477
 
478
 
479
/*********************context************************/
480
wire  [12:0]  pctxt_state0,pctxt_state1;
481
wire  [12:0]  pctxt_state2,pctxt_state3;
482
wire  [12:0]  sctxt_state0,sctxt_state1;
483
wire  [12:0]  sctxt_state2,sctxt_state3;
484
 
485
// PRIMARY CONTEXT - Thread0
486
   wire       pctxt0_state_clk;
487
 
488
`ifdef FPGA_SYN_CLK_EN
489
`else
490
clken_buf pctxt0_state_clkbuf (
491
                .rclk   (clk),
492
                .enb_l  (~pctxt_state_wr_thrd[0]),
493
                .tmb_l  (~se),
494
                .clk    (pctxt0_state_clk)
495
                ) ;
496
`endif
497
 
498
`ifdef FPGA_SYN_CLK_DFF
499
dffe_s #(13) pctxt_state0_ff (
500
        .din    (st_rs3_data_g[12:0]),
501
        .q      (pctxt_state0[12:0]),
502
        .en (~(~pctxt_state_wr_thrd[0])), .clk(clk),
503
        .se     (se),       .si (),          .so ()
504
        );
505
`else
506
dff_s #(13) pctxt_state0_ff (
507
        .din    (st_rs3_data_g[12:0]),
508
        .q      (pctxt_state0[12:0]),
509
        .clk    (pctxt0_state_clk),
510
        .se     (se),       .si (),          .so ()
511
        );
512
`endif
513
 
514
assign  lsu_t0_pctxt_state[12:0] = pctxt_state0[12:0] ;
515
 
516
// PRIMARY CONTEXT - Thread1
517
   wire       pctxt1_state_clk;
518
 
519
`ifdef FPGA_SYN_CLK_EN
520
`else
521
clken_buf pctxt1_state_clkbuf (
522
                .rclk   (clk),
523
                .enb_l  (~pctxt_state_wr_thrd[1]),
524
                .tmb_l  (~se),
525
                .clk    (pctxt1_state_clk)
526
                ) ;
527
`endif
528
 
529
`ifdef FPGA_SYN_CLK_DFF
530
dffe_s #(13) pctxt_state1_ff (
531
        .din    (st_rs3_data_g[12:0]),
532
        .q      (pctxt_state1[12:0]),
533
        .en (~(~pctxt_state_wr_thrd[1])), .clk(clk),
534
        .se     (se),       .si (),          .so ()
535
        );
536
`else
537
dff_s #(13) pctxt_state1_ff (
538
        .din    (st_rs3_data_g[12:0]),
539
        .q      (pctxt_state1[12:0]),
540
        .clk    (pctxt1_state_clk),
541
        .se     (se),       .si (),          .so ()
542
        );
543
`endif
544
 
545
assign  lsu_t1_pctxt_state[12:0] = pctxt_state1[12:0] ;
546
 
547
// PRIMARY CONTEXT - Thread2
548
   wire       pctxt2_state_clk;
549
 
550
`ifdef FPGA_SYN_CLK_EN
551
`else
552
clken_buf pctxt2_state_clkbuf (
553
                .rclk   (clk),
554
                .enb_l  (~pctxt_state_wr_thrd[2]),
555
                .tmb_l  (~se),
556
                .clk    (pctxt2_state_clk)
557
                ) ;
558
`endif
559
 
560
`ifdef FPGA_SYN_CLK_DFF
561
dffe_s #(13) pctxt_state2_ff (
562
        .din    (st_rs3_data_g[12:0]),
563
        .q      (pctxt_state2[12:0]),
564
        .en (~(~pctxt_state_wr_thrd[2])), .clk(clk),
565
        .se     (se),       .si (),          .so ()
566
        );
567
`else
568
dff_s #(13) pctxt_state2_ff (
569
        .din    (st_rs3_data_g[12:0]),
570
        .q      (pctxt_state2[12:0]),
571
        .clk    (pctxt2_state_clk),
572
        .se     (se),       .si (),          .so ()
573
        );
574
`endif
575
 
576
assign  lsu_t2_pctxt_state[12:0] = pctxt_state2[12:0] ;
577
 
578
// PRIMARY CONTEXT - Thread3
579
   wire       pctxt3_state_clk;
580
 
581
`ifdef FPGA_SYN_CLK_EN
582
`else
583
clken_buf pctxt3_state_clkbuf (
584
                .rclk   (clk),
585
                .enb_l  (~pctxt_state_wr_thrd[3]),
586
                .tmb_l  (~se),
587
                .clk    (pctxt3_state_clk)
588
                ) ;
589
`endif
590
 
591
`ifdef FPGA_SYN_CLK_DFF
592
dffe_s #(13) pctxt_state3_ff (
593
        .din    (st_rs3_data_g[12:0]),
594
        .q      (pctxt_state3[12:0]),
595
        .en (~(~pctxt_state_wr_thrd[3])), .clk(clk),
596
        .se     (se),       .si (),          .so ()
597
        );
598
`else
599
dff_s #(13) pctxt_state3_ff (
600
        .din    (st_rs3_data_g[12:0]),
601
        .q      (pctxt_state3[12:0]),
602
        .clk    (pctxt3_state_clk),
603
        .se     (se),       .si (),          .so ()
604
        );
605
`endif
606
 
607
assign  lsu_t3_pctxt_state[12:0] = pctxt_state3[12:0] ;
608
 
609
// SECONDARY CONTEXT - Thread0
610
   wire       sctxt0_state_clk;
611
 
612
`ifdef FPGA_SYN_CLK_EN
613
`else
614
clken_buf sctxt0_state_clkbuf (
615
                .rclk   (clk),
616
                .enb_l  (~sctxt_state_wr_thrd[0]),
617
                .tmb_l  (~se),
618
                .clk    (sctxt0_state_clk)
619
                ) ;
620
`endif
621
 
622
`ifdef FPGA_SYN_CLK_DFF
623
dffe_s #(13) sctxt_state0_ff (
624
        .din    (st_rs3_data_g[12:0]),
625
        .q      (sctxt_state0[12:0]),
626
        .en (~(~sctxt_state_wr_thrd[0])), .clk(clk),
627
        .se     (se),       .si (),          .so ()
628
        );
629
`else
630
dff_s #(13) sctxt_state0_ff (
631
        .din    (st_rs3_data_g[12:0]),
632
        .q      (sctxt_state0[12:0]),
633
        .clk    (sctxt0_state_clk),
634
        .se     (se),       .si (),          .so ()
635
        );
636
`endif
637
 
638
// SECONDARY CONTEXT - Thread1
639
   wire       sctxt1_state_clk;
640
 
641
`ifdef FPGA_SYN_CLK_EN
642
`else
643
clken_buf sctxt1_state_clkbuf (
644
                .rclk   (clk),
645
                .enb_l  (~sctxt_state_wr_thrd[1]),
646
                .tmb_l  (~se),
647
                .clk    (sctxt1_state_clk)
648
                ) ;
649
`endif
650
 
651
`ifdef FPGA_SYN_CLK_DFF
652
dffe_s #(13) sctxt_state1_ff (
653
        .din    (st_rs3_data_g[12:0]),
654
        .q      (sctxt_state1[12:0]),
655
        .en (~(~sctxt_state_wr_thrd[1])), .clk(clk),
656
        .se     (se),       .si (),          .so ()
657
        );
658
`else
659
dff_s #(13) sctxt_state1_ff (
660
        .din    (st_rs3_data_g[12:0]),
661
        .q      (sctxt_state1[12:0]),
662
        .clk    (sctxt1_state_clk),
663
        .se     (se),       .si (),          .so ()
664
        );
665
`endif
666
 
667
// SECONDARY CONTEXT - Thread2
668
   wire       sctxt2_state_clk;
669
 
670
`ifdef FPGA_SYN_CLK_EN
671
`else
672
clken_buf sctxt2_state_clkbuf (
673
                .rclk   (clk),
674
                .enb_l  (~sctxt_state_wr_thrd[2]),
675
                .tmb_l  (~se),
676
                .clk    (sctxt2_state_clk)
677
                ) ;
678
`endif
679
 
680
`ifdef FPGA_SYN_CLK_DFF
681
dffe_s #(13) sctxt_state2_ff (
682
        .din    (st_rs3_data_g[12:0]),
683
        .q      (sctxt_state2[12:0]),
684
        .en (~(~sctxt_state_wr_thrd[2])), .clk(clk),
685
        .se     (se),       .si (),          .so ()
686
        );
687
`else
688
dff_s #(13) sctxt_state2_ff (
689
        .din    (st_rs3_data_g[12:0]),
690
        .q      (sctxt_state2[12:0]),
691
        .clk    (sctxt2_state_clk),
692
        .se     (se),       .si (),          .so ()
693
        );
694
`endif
695
 
696
// SECONDARY CONTEXT - Thread3
697
   wire       sctxt3_state_clk;
698
 
699
`ifdef FPGA_SYN_CLK_EN
700
`else
701
clken_buf sctxt3_state_clkbuf (
702
                .rclk   (clk),
703
                .enb_l  (~sctxt_state_wr_thrd[3]),
704
                .tmb_l  (~se),
705
                .clk    (sctxt3_state_clk)
706
                ) ;
707
`endif
708
 
709
`ifdef FPGA_SYN_CLK_DFF
710
dffe_s #(13) sctxt_state3_ff (
711
        .din    (st_rs3_data_g[12:0]),
712
        .q      (sctxt_state3[12:0]),
713
        .en (~(~sctxt_state_wr_thrd[3])), .clk(clk),
714
        .se     (se),       .si (),          .so ()
715
        );
716
`else
717
dff_s #(13) sctxt_state3_ff (
718
        .din    (st_rs3_data_g[12:0]),
719
        .q      (sctxt_state3[12:0]),
720
        .clk    (sctxt3_state_clk),
721
        .se     (se),       .si (),          .so ()
722
        );
723
`endif
724
 
725
wire  [12:0]  current_pctxt_e,current_sctxt_e ;
726
wire  [12:0]  current_pctxt_m ;
727
 
728
wire  [12:0]  current_ctxt_e,current_ctxt_m ;
729
 
730
mux4ds #(13) current_pctxt_e_mux (
731
   .in0 (pctxt_state0[12:0]),
732
   .in1 (pctxt_state1[12:0]),
733
   .in2 (pctxt_state2[12:0]),
734
   .in3 (pctxt_state3[12:0]),
735
   .sel0(thread0_ctxt),
736
   .sel1(thread1_ctxt),
737
   .sel2(thread2_ctxt),
738
   .sel3(thread3_ctxt),
739
   .dout(current_pctxt_e[12:0])
740
   );
741
 
742
mux4ds #(13) current_sctxt_e_mux (
743
   .in0 (sctxt_state0[12:0]),
744
   .in1 (sctxt_state1[12:0]),
745
   .in2 (sctxt_state2[12:0]),
746
   .in3 (sctxt_state3[12:0]),
747
   .sel0(thread0_ctxt),
748
   .sel1(thread1_ctxt),
749
   .sel2(thread2_ctxt),
750
   .sel3(thread3_ctxt),
751
   .dout(current_sctxt_e[12:0])
752
   );
753
 
754
   wire [12:0] tlb_actxt;
755
 
756
assign tlb_actxt[12:0] =
757
       {tlu_dtlb_tte_tag_w2[12:0]} ;
758
 
759
   wire [3:0] thread_sel;
760
   assign     thread_sel[0]= thread_pctxt   & ~rst_tri_en;
761
   assign     thread_sel[1]= thread_sctxt   & ~rst_tri_en;
762
   assign     thread_sel[2]= thread_actxt   & ~rst_tri_en;
763
   assign     thread_sel[3]= thread_default |  rst_tri_en;
764
 
765
// change buffer to nand /nor
766
 
767
mux4ds #(13) tlb_ctxt_mux (
768
   .in0 (current_pctxt_e[12:0]),
769
   .in1 (current_sctxt_e[12:0]),
770
   .in2 (tlb_actxt[12:0]),
771
   .in3 ({13'b0}),
772
   .sel0(thread_sel[0]),
773
   .sel1(thread_sel[1]),
774
   .sel2(thread_sel[2]),
775
   .sel3(thread_sel[3]),
776
   .dout(tlb_ctxt[12:0])
777
   );
778
 
779
assign  current_ctxt_e[12:0] = tlb_ctxt[12:0] ;
780
 
781
//Bug 3094
782
wire    [12:0]   itrap_pctxt_e ;
783
mux4ds #(13) itrap_pctxt_e_mux (
784
   .in0 (pctxt_state0[12:0]),
785
   .in1 (pctxt_state1[12:0]),
786
   .in2 (pctxt_state2[12:0]),
787
   .in3 (pctxt_state3[12:0]),
788
   .sel0(thread0_e),
789
   .sel1(thread1_e),
790
   .sel2(thread2_e),
791
   .sel3(thread3_e),
792
   .dout(itrap_pctxt_e[12:0])
793
   );
794
 
795
// Create current ctxt for tlu purpose.
796
dff_s #(26) cctxt_stgm (
797
        .din    ({current_ctxt_e[12:0],itrap_pctxt_e[12:0]}),
798
        .q      ({current_ctxt_m[12:0],current_pctxt_m[12:0]}),
799
        .clk    (clk),
800
        .se     (se),       .si (),          .so ()
801
        );
802
 
803
assign  lsu_tlu_dside_ctxt_m[12:0] = current_ctxt_m[12:0] ;
804
assign  lsu_tlu_pctxt_m[12:0] = current_pctxt_m[12:0] ;
805
 
806
   // Primary Context 
807
mux4ds #(13)     pctxt_mx (
808
        .in0    (pctxt_state0[12:0]),
809
        .in1    (pctxt_state1[12:0]),
810
        .in2    (pctxt_state2[12:0]),
811
        .in3    (pctxt_state3[12:0]),
812
        .sel0   (thread0_g),
813
        .sel1   (thread1_g),
814
        .sel2   (thread2_g),
815
        .sel3   (thread3_g),
816
        .dout   (pctxt_state[12:0])
817
        );
818
 
819
// Secondary Context 
820
mux4ds #(13)     sctxt_mx (
821
        .in0    (sctxt_state0[12:0]),
822
        .in1    (sctxt_state1[12:0]),
823
        .in2    (sctxt_state2[12:0]),
824
        .in3    (sctxt_state3[12:0]),
825
        .sel0   (thread0_g),
826
        .sel1   (thread1_g),
827
        .sel2   (thread2_g),
828
        .sel3   (thread3_g),
829
        .dout   (sctxt_state[12:0])
830
        );
831
 
832
/********************partition id********************/
833
 // ** Reset put in temporarily to ensure pid is correctly initialized **
834
// ** Env/diags should be set-up to initialize pid correctly **
835
wire    [2:0]    pid_state0, pid_state1, pid_state2, pid_state3;
836
 
837
// Thread0
838
   wire [2:0] pid_state_din;
839
   assign     pid_state_din[2:0] = {3{rst_l}} & st_rs3_data_g[2:0];
840
 
841
   wire       pid_state0_clk;
842
 
843
`ifdef FPGA_SYN_CLK_EN
844
`else
845
clken_buf pid_state0_clkbuf (
846
                .rclk   (clk),
847
                .enb_l  (~pid_state_wr_en[0]),
848
                .tmb_l  (~se),
849
                .clk    (pid_state0_clk)
850
                ) ;
851
`endif
852
 
853
`ifdef FPGA_SYN_CLK_DFF
854
dffe_s #(3) pid0_state (
855
        .din    (pid_state_din[2:0]),
856
        .q      (pid_state0[2:0]),
857
        .en (~(~pid_state_wr_en[0])), .clk(clk),
858
        .se     (se),       .si (),          .so ()
859
        );
860
`else
861
dff_s #(3) pid0_state (
862
        .din    (pid_state_din[2:0]),
863
        .q      (pid_state0[2:0]),
864
        .clk    (pid_state0_clk),
865
        .se     (se),       .si (),          .so ()
866
        );
867
`endif
868
 
869
assign  lsu_pid_state0[2:0] = pid_state0[2:0] ;
870
 
871
// Thread1
872
   wire       pid_state1_clk;
873
 
874
`ifdef FPGA_SYN_CLK_EN
875
`else
876
clken_buf pid_state1_clkbuf (
877
                .rclk   (clk),
878
                .enb_l  (~pid_state_wr_en[1]),
879
                .tmb_l  (~se),
880
                .clk    (pid_state1_clk)
881
                ) ;
882
`endif
883
 
884
`ifdef FPGA_SYN_CLK_DFF
885
dffe_s #(3) pid1_state (
886
        .din    (pid_state_din[2:0]),
887
        .q      (pid_state1[2:0]),
888
        .en (~(~pid_state_wr_en[1])), .clk(clk),
889
        .se     (se),       .si (),          .so ()
890
        );
891
`else
892
dff_s #(3) pid1_state (
893
        .din    (pid_state_din[2:0]),
894
        .q      (pid_state1[2:0]),
895
        .clk    (pid_state1_clk),
896
        .se     (se),       .si (),          .so ()
897
        );
898
`endif
899
 
900
assign  lsu_pid_state1[2:0] = pid_state1[2:0] ;
901
 
902
// Thread2
903
   wire       pid_state2_clk;
904
 
905
`ifdef FPGA_SYN_CLK_EN
906
`else
907
clken_buf pid_state2_clkbuf (
908
                .rclk   (clk),
909
                .enb_l  (~pid_state_wr_en[2]),
910
                .tmb_l  (~se),
911
                .clk    (pid_state2_clk)
912
                ) ;
913
`endif
914
 
915
`ifdef FPGA_SYN_CLK_DFF
916
dffe_s #(3) pid2_state (
917
        .din    (pid_state_din[2:0]),
918
        .q      (pid_state2[2:0]),
919
        .en (~(~pid_state_wr_en[2])), .clk(clk),
920
        .se     (se),       .si (),          .so ()
921
        );
922
`else
923
dff_s #(3) pid2_state (
924
        .din    (pid_state_din[2:0]),
925
        .q      (pid_state2[2:0]),
926
        .clk    (pid_state2_clk),
927
        .se     (se),       .si (),          .so ()
928
        );
929
`endif
930
 
931
assign  lsu_pid_state2[2:0] = pid_state2[2:0] ;
932
 
933
// Thread3
934
   wire       pid_state3_clk;
935
 
936
`ifdef FPGA_SYN_CLK_EN
937
`else
938
clken_buf pid_state3_clkbuf (
939
                .rclk   (clk),
940
                .enb_l  (~pid_state_wr_en[3]),
941
                .tmb_l  (~se),
942
                .clk    (pid_state3_clk)
943
                ) ;
944
`endif
945
 
946
`ifdef FPGA_SYN_CLK_DFF
947
dffe_s #(3) pid3_state (
948
        .din    (pid_state_din[2:0]),
949
        .q      (pid_state3[2:0]),
950
        .en (~(~pid_state_wr_en[3])), .clk(clk),
951
        .se     (se),       .si (),          .so ()
952
        );
953
`else
954
dff_s #(3) pid3_state (
955
        .din    (pid_state_din[2:0]),
956
        .q      (pid_state3[2:0]),
957
        .clk    (pid_state3_clk),
958
        .se     (se),       .si (),          .so ()
959
        );
960
`endif
961
 
962
assign  lsu_pid_state3[2:0] = pid_state3[2:0] ;
963
 
964
wire [2:0] cam_pid_e ;
965
// Hypervisor related cam inputs
966
mux4ds #(3)     cam_pid_mx (
967
        .in0    (pid_state0[2:0]),
968
        .in1    (pid_state1[2:0]),
969
        .in2    (pid_state2[2:0]),
970
        .in3    (pid_state3[2:0]),
971
        .sel0   (thread0_e),
972
        .sel1   (thread1_e),
973
        .sel2   (thread2_e),
974
        .sel3   (thread3_e),
975
        .dout   (cam_pid_e[2:0])
976
        );
977
 
978
assign  lsu_dtlb_cam_pid_e[2:0] =
979
  lsu_dtlb_dmp_vld_e ? tlu_dtlb_tte_tag_b58t56[2:0] : cam_pid_e[2:0] ;
980
  //thread_actxt ? tlu_dtlb_tte_tag_b58t56[2:0] : cam_pid_e[2:0] ;
981
 
982
mux4ds #(3)     pid_mx (
983
        .in0    (pid_state0[2:0]),
984
        .in1    (pid_state1[2:0]),
985
        .in2    (pid_state2[2:0]),
986
        .in3    (pid_state3[2:0]),
987
        .sel0   (thread0_g),
988
        .sel1   (thread1_g),
989
        .sel2   (thread2_g),
990
        .sel3   (thread3_g),
991
        .dout   (pid_state[2:0])
992
        );
993
 
994
 
995
/***********************lsu ctl reg********************/
996
// Contents of lsu_ctl_reg
997
/*
998
  IC. I-Cache Enable. b0           b0
999
  DC. D-Cache Enable. b1           b1
1000
  IM. I-MMU Enable.   b2           b2
1001
  DM. D-MMU Enable.   b3           b3
1002
  FM. Parity Mask.(delete) b4-19   --
1003
  Reserved    b20                  --
1004
  VW. VA Wtchpt Wr  b21            b4
1005
  VR. VA Wtchpt Rd  b22            b5
1006
  PW. PA Wtchpt Wr  b23            --
1007
  PR. PA Wtchpt Rd  b24            --
1008
  VM. VA Wtchpt BMask   b25-32     b6-13
1009
  PM. PA Wtchpt BMask   b33-40     --
1010
*/
1011
 
1012
   assign lsu_dp_ctl_reg0[5:0] = lsu_ctl_reg0[5:0];
1013
   assign lsu_dp_ctl_reg1[5:0] = lsu_ctl_reg1[5:0];
1014
   assign lsu_dp_ctl_reg2[5:0] = lsu_ctl_reg2[5:0];
1015
   assign lsu_dp_ctl_reg3[5:0] = lsu_ctl_reg3[5:0];
1016
 
1017
wire  [9:0]  lsu_ctl_reg_din ;
1018
 
1019
//assign  lsu_ctl_reg_din[19:0] = st_rs3_data_g[40:21] ;
1020
   wire   lsu_ctl_reg_vw_din, lsu_ctl_reg_vr_din;
1021
   wire [7:0] lsu_ctl_reg_vm_din;
1022
 
1023
assign  lsu_ctl_reg_vw_din = st_rs3_data_g[21] ;
1024
assign  lsu_ctl_reg_vr_din = st_rs3_data_g[22] ;
1025
assign  lsu_ctl_reg_vm_din[7:0] = st_rs3_data_g[32:25];
1026
 
1027
assign lsu_ctl_reg_din[9:0] = {lsu_ctl_reg_vm_din[7:0],
1028
                               lsu_ctl_reg_vr_din,
1029
                               lsu_ctl_reg_vw_din};
1030
 
1031
 
1032
wire [3:0]  lsuctl_ctlbits_wr_data ;
1033
 
1034
assign  lsuctl_ctlbits_wr_data[3:0] =
1035
          dfture_tap_wr_mx_sel ? lsu_iobrdge_wr_data[3:0] : st_rs3_data_g[3:0] ;
1036
 
1037
// Thread0
1038
   wire [9:0] lsu_ctl_reg0_din;
1039
   assign      lsu_ctl_reg0_din[9:0] = {10{~lctl_rst[0]}} & lsu_ctl_reg_din[9:0];
1040
 
1041
   wire        lsu_ctl_state0_clk;
1042
 
1043
`ifdef FPGA_SYN_CLK_EN
1044
`else
1045
clken_buf lsu_ctl_state0_clkbuf (
1046
                .rclk   (clk),
1047
                .enb_l  (~lsu_ctl_state_wr_en[0]),
1048
                .tmb_l  (~se),
1049
                .clk    (lsu_ctl_state0_clk)
1050
                ) ;
1051
`endif
1052
 
1053
`ifdef FPGA_SYN_CLK_DFF
1054
dffe_s #(10) lsu_ctl_reg0_ff2 (
1055
        .din    (lsu_ctl_reg0_din[9:0]),
1056
        .q      (lsu_ctl_reg0[13:4]),
1057
        .en (~(~lsu_ctl_state_wr_en[0])), .clk(clk),
1058
        .se     (se),       .si (),          .so ()
1059
        );
1060
`else
1061
dff_s #(10) lsu_ctl_reg0_ff2 (
1062
        .din    (lsu_ctl_reg0_din[9:0]),
1063
        .q      (lsu_ctl_reg0[13:4]),
1064
        .clk    (lsu_ctl_state0_clk),
1065
        .se     (se),       .si (),          .so ()
1066
        );
1067
`endif
1068
 
1069
   wire [3:0]  lsuctl_ctlbits0_wr_data_din;
1070
   assign      lsuctl_ctlbits0_wr_data_din[3:0] = {4{~lctl_rst[0]}} & lsuctl_ctlbits_wr_data[3:0];
1071
 
1072
   wire        lsuctl_ctlbits0_clk;
1073
 
1074
`ifdef FPGA_SYN_CLK_EN
1075
`else
1076
clken_buf lsuctl_ctlbits0_clkbuf (
1077
                .rclk   (clk),
1078
                .enb_l  (~lsuctl_ctlbits_wr_en[0]),
1079
                .tmb_l  (~se),
1080
                .clk    (lsuctl_ctlbits0_clk)
1081
                ) ;
1082
`endif
1083
 
1084
`ifdef FPGA_SYN_CLK_DFF
1085
dffe_s #(4) lsu_ctl_reg0_ff1 (
1086
        .din    (lsuctl_ctlbits0_wr_data_din[3:0]),
1087
        .q      (lsu_ctl_reg0[3:0]),
1088
        .en (~(~lsuctl_ctlbits_wr_en[0])), .clk(clk),
1089
        .se     (se),       .si (),          .so ()
1090
        );
1091
`else
1092
dff_s #(4) lsu_ctl_reg0_ff1 (
1093
        .din    (lsuctl_ctlbits0_wr_data_din[3:0]),
1094
        .q      (lsu_ctl_reg0[3:0]),
1095
        .clk    (lsuctl_ctlbits0_clk),
1096
        .se     (se),       .si (),          .so ()
1097
        );
1098
`endif
1099
 
1100
// Thread1
1101
   wire [9:0] lsu_ctl_reg1_din;
1102
   assign      lsu_ctl_reg1_din[9:0] = {10{~lctl_rst[1]}} & lsu_ctl_reg_din[9:0];
1103
 
1104
   wire        lsu_ctl_state1_clk;
1105
 
1106
`ifdef FPGA_SYN_CLK_EN
1107
`else
1108
clken_buf lsu_ctl_state1_clkbuf (
1109
                .rclk   (clk),
1110
                .enb_l  (~lsu_ctl_state_wr_en[1]),
1111
                .tmb_l  (~se),
1112
                .clk    (lsu_ctl_state1_clk)
1113
                ) ;
1114
`endif
1115
 
1116
`ifdef FPGA_SYN_CLK_DFF
1117
dffe_s #(10) lsu_ctl_reg1_ff2 (
1118
        .din    (lsu_ctl_reg1_din[9:0]),
1119
        .q      (lsu_ctl_reg1[13:4]),
1120
        .en (~(~lsu_ctl_state_wr_en[1])), .clk(clk),
1121
        .se     (se),       .si (),          .so ()
1122
        );
1123
`else
1124
dff_s #(10) lsu_ctl_reg1_ff2 (
1125
        .din    (lsu_ctl_reg1_din[9:0]),
1126
        .q      (lsu_ctl_reg1[13:4]),
1127
        .clk    (lsu_ctl_state1_clk),
1128
        .se     (se),       .si (),          .so ()
1129
        );
1130
`endif
1131
 
1132
   wire [3:0]  lsuctl_ctlbits1_wr_data_din;
1133
   assign      lsuctl_ctlbits1_wr_data_din[3:0] = {4{~lctl_rst[1]}} & lsuctl_ctlbits_wr_data[3:0];
1134
 
1135
   wire        lsuctl_ctlbits1_clk;
1136
 
1137
`ifdef FPGA_SYN_CLK_EN
1138
`else
1139
clken_buf lsuctl_ctlbits1_clkbuf (
1140
                .rclk   (clk),
1141
                .enb_l  (~lsuctl_ctlbits_wr_en[1]),
1142
                .tmb_l  (~se),
1143
                .clk    (lsuctl_ctlbits1_clk)
1144
                ) ;
1145
`endif
1146
 
1147
`ifdef FPGA_SYN_CLK_DFF
1148
dffe_s #(4) lsu_ctl_reg1_ff1 (
1149
        .din    (lsuctl_ctlbits1_wr_data_din[3:0]),
1150
        .q      (lsu_ctl_reg1[3:0]),
1151
        .en (~(~lsuctl_ctlbits_wr_en[1])), .clk(clk),
1152
        .se     (se),       .si (),          .so ()
1153
        );
1154
`else
1155
dff_s #(4) lsu_ctl_reg1_ff1 (
1156
        .din    (lsuctl_ctlbits1_wr_data_din[3:0]),
1157
        .q      (lsu_ctl_reg1[3:0]),
1158
        .clk    (lsuctl_ctlbits1_clk),
1159
        .se     (se),       .si (),          .so ()
1160
        );
1161
`endif
1162
 
1163
// Thread2
1164
   wire [9:0] lsu_ctl_reg2_din;
1165
   assign      lsu_ctl_reg2_din[9:0] = {10{~lctl_rst[2]}} & lsu_ctl_reg_din[9:0];
1166
 
1167
   wire        lsu_ctl_state2_clk;
1168
 
1169
`ifdef FPGA_SYN_CLK_EN
1170
`else
1171
clken_buf lsu_ctl_state2_clkbuf (
1172
                .rclk   (clk),
1173
                .enb_l  (~lsu_ctl_state_wr_en[2]),
1174
                .tmb_l  (~se),
1175
                .clk    (lsu_ctl_state2_clk)
1176
                ) ;
1177
`endif
1178
 
1179
`ifdef FPGA_SYN_CLK_DFF
1180
dffe_s #(10) lsu_ctl_reg2_ff2 (
1181
        .din    (lsu_ctl_reg2_din[9:0]),
1182
        .q      (lsu_ctl_reg2[13:4]),
1183
        .en (~(~lsu_ctl_state_wr_en[2])), .clk(clk),
1184
        .se     (se),       .si (),          .so ()
1185
        );
1186
`else
1187
dff_s #(10) lsu_ctl_reg2_ff2 (
1188
        .din    (lsu_ctl_reg2_din[9:0]),
1189
        .q      (lsu_ctl_reg2[13:4]),
1190
        .clk    (lsu_ctl_state2_clk),
1191
        .se     (se),       .si (),          .so ()
1192
        );
1193
`endif
1194
 
1195
   wire [3:0]  lsuctl_ctlbits2_wr_data_din;
1196
   assign      lsuctl_ctlbits2_wr_data_din[3:0] = {4{~lctl_rst[2]}} & lsuctl_ctlbits_wr_data[3:0];
1197
 
1198
   wire        lsuctl_ctlbits2_clk;
1199
 
1200
`ifdef FPGA_SYN_CLK_EN
1201
`else
1202
clken_buf lsuctl_ctlbits2_clkbuf (
1203
                .rclk   (clk),
1204
                .enb_l  (~lsuctl_ctlbits_wr_en[2]),
1205
                .tmb_l  (~se),
1206
                .clk    (lsuctl_ctlbits2_clk)
1207
                ) ;
1208
`endif
1209
 
1210
`ifdef FPGA_SYN_CLK_DFF
1211
dffe_s #(4) lsu_ctl_reg2_ff1 (
1212
        .din    (lsuctl_ctlbits2_wr_data_din[3:0]),
1213
        .q      (lsu_ctl_reg2[3:0]),
1214
        .en (~(~lsuctl_ctlbits_wr_en[2])), .clk(clk),
1215
        .se     (se),       .si (),          .so ()
1216
        );
1217
`else
1218
dff_s #(4) lsu_ctl_reg2_ff1 (
1219
        .din    (lsuctl_ctlbits2_wr_data_din[3:0]),
1220
        .q      (lsu_ctl_reg2[3:0]),
1221
        .clk    (lsuctl_ctlbits2_clk),
1222
        .se     (se),       .si (),          .so ()
1223
        );
1224
`endif
1225
 
1226
// Thread3
1227
   wire [9:0] lsu_ctl_reg3_din;
1228
   assign      lsu_ctl_reg3_din[9:0] = {10{~lctl_rst[3]}} & lsu_ctl_reg_din[9:0];
1229
 
1230
   wire        lsu_ctl_state3_clk;
1231
 
1232
`ifdef FPGA_SYN_CLK_EN
1233
`else
1234
clken_buf lsu_ctl_state3_clkbuf (
1235
                .rclk   (clk),
1236
                .enb_l  (~lsu_ctl_state_wr_en[3]),
1237
                .tmb_l  (~se),
1238
                .clk    (lsu_ctl_state3_clk)
1239
                ) ;
1240
`endif
1241
 
1242
`ifdef FPGA_SYN_CLK_DFF
1243
dffe_s #(10) lsu_ctl_reg3_ff2 (
1244
        .din    (lsu_ctl_reg3_din[9:0]),
1245
        .q      (lsu_ctl_reg3[13:4]),
1246
        .en (~(~lsu_ctl_state_wr_en[3])), .clk(clk),
1247
        .se     (se),       .si (),          .so ()
1248
        );
1249
`else
1250
dff_s #(10) lsu_ctl_reg3_ff2 (
1251
        .din    (lsu_ctl_reg3_din[9:0]),
1252
        .q      (lsu_ctl_reg3[13:4]),
1253
        .clk    (lsu_ctl_state3_clk),
1254
        .se     (se),       .si (),          .so ()
1255
        );
1256
`endif
1257
 
1258
   wire [3:0]  lsuctl_ctlbits3_wr_data_din;
1259
   assign      lsuctl_ctlbits3_wr_data_din[3:0] = {4{~lctl_rst[3]}} & lsuctl_ctlbits_wr_data[3:0];
1260
 
1261
   wire        lsuctl_ctlbits3_clk;
1262
 
1263
`ifdef FPGA_SYN_CLK_EN
1264
`else
1265
clken_buf lsuctl_ctlbits3_clkbuf (
1266
                .rclk   (clk),
1267
                .enb_l  (~lsuctl_ctlbits_wr_en[3]),
1268
                .tmb_l  (~se),
1269
                .clk    (lsuctl_ctlbits3_clk)
1270
                ) ;
1271
`endif
1272
 
1273
`ifdef FPGA_SYN_CLK_DFF
1274
dffe_s #(4) lsu_ctl_reg3_ff1 (
1275
        .din    (lsuctl_ctlbits3_wr_data_din[3:0]),
1276
        .q      (lsu_ctl_reg3[3:0]),
1277
        .en (~(~lsuctl_ctlbits_wr_en[3])), .clk(clk),
1278
        .se     (se),       .si (),          .so ()
1279
        );
1280
`else
1281
dff_s #(4) lsu_ctl_reg3_ff1 (
1282
        .din    (lsuctl_ctlbits3_wr_data_din[3:0]),
1283
        .q      (lsu_ctl_reg3[3:0]),
1284
        .clk    (lsuctl_ctlbits3_clk),
1285
        .se     (se),       .si (),          .so ()
1286
        );
1287
`endif
1288
 
1289
// LSU Ctl Reg
1290
mux4ds #(14)     lctlrg_mx (
1291
        .in0    (lsu_ctl_reg0[13:0]),
1292
        .in1    (lsu_ctl_reg1[13:0]),
1293
        .in2    (lsu_ctl_reg2[13:0]),
1294
        .in3    (lsu_ctl_reg3[13:0]),
1295
        .sel0   (thread0_g),
1296
        .sel1   (thread1_g),
1297
        .sel2   (thread2_g),
1298
        .sel3   (thread3_g),
1299
        .dout   (lsu_ctl_reg[13:0])
1300
        );
1301
 
1302
   wire [3:0] dfture_tap_rd_data;
1303
 
1304
mux4ds #(4)     dfture_tap_rd_data_mx (
1305
        .in0    (lsu_ctl_reg0[3:0]),
1306
        .in1    (lsu_ctl_reg1[3:0]),
1307
        .in2    (lsu_ctl_reg2[3:0]),
1308
        .in3    (lsu_ctl_reg3[3:0]),
1309
        .sel0   (dfture_tap_rd_en[0]),
1310
        .sel1   (dfture_tap_rd_en[1]),
1311
        .sel2   (dfture_tap_rd_en[2]),
1312
        .sel3   (dfture_tap_rd_en[3]),
1313
        .dout   (dfture_tap_rd_data[3:0])
1314
        );
1315
 
1316
   wire [7:0] va_wtchpt_mask;
1317
 
1318
mux4ds #(8)     va_wtchpt_mask_mx (
1319
        .in0    (lsu_ctl_reg0[13:6]),
1320
        .in1    (lsu_ctl_reg1[13:6]),
1321
        .in2    (lsu_ctl_reg2[13:6]),
1322
        .in3    (lsu_ctl_reg3[13:6]),
1323
        .sel0   (thread0_m),
1324
        .sel1   (thread1_m),
1325
        .sel2   (thread2_m),
1326
        .sel3   (thread3_m),
1327
        .dout   (va_wtchpt_mask[7:0])
1328
        );
1329
 
1330
// Bug 1671 fix
1331
//assign va_wtchpt_msk_match_m  =   (stb_ldst_byte_msk[7:0] == va_wtchpt_mask[7:0]);
1332
//assign va_wtchpt_msk_match_m  =   |(stb_ldst_byte_msk[7:0] & va_wtchpt_mask[7:0]);
1333
 
1334
assign va_wtchpt_msk_match_m  =
1335
       stb_ldst_byte_msk[0] & va_wtchpt_mask[7] |
1336
       stb_ldst_byte_msk[1] & va_wtchpt_mask[6] |
1337
       stb_ldst_byte_msk[2] & va_wtchpt_mask[5] |
1338
       stb_ldst_byte_msk[3] & va_wtchpt_mask[4] |
1339
       stb_ldst_byte_msk[4] & va_wtchpt_mask[3] |
1340
       stb_ldst_byte_msk[5] & va_wtchpt_mask[2] |
1341
       stb_ldst_byte_msk[6] & va_wtchpt_mask[1] |
1342
       stb_ldst_byte_msk[7] & va_wtchpt_mask[0] ;
1343
 
1344
 
1345
 
1346
/***********************ldxa****************************/
1347
// BIST_Controller ASI
1348
// tap wr takes precedence
1349
//wire  [10:0]  bistctl_data_in;
1350
//wire  [10:0]  bist_ctl_reg ;
1351
 
1352
//assign  bistctl_data_in[13:0] =
1353
//  bist_tap_wr_en ? lsu_iobrdge_wr_data[13:0] : st_rs3_data_g[13:0] ;
1354
 
1355
//assign  bistctl_data_in[10:7] = lsu_iobrdge_wr_data[10:7];
1356
//assign  bistctl_data_in[6:0] =
1357
//  bist_tap_wr_en ? lsu_iobrdge_wr_data[6:0] : st_rs3_data_g[6:0] ;
1358
 
1359
assign  bist_ctl_reg_in[6:0] =
1360
bist_tap_wr_en ? lsu_iobrdge_wr_data[6:0] : st_rs3_data_g[6:0];
1361
 
1362
/*   wire bistctl_clk;
1363
 
1364
`ifdef FPGA_SYN_CLK_EN
1365
`else
1366
clken_buf bistctl_clkbuf (
1367
                .rclk   (clk),
1368
                .enb_l  (~bistctl_wr_en),
1369
                .tmb_l  (tmb_l),
1370
                .clk    (bistctl_clk)
1371
                ) ;
1372
`endif
1373
 
1374
`ifdef FPGA_SYN_CLK_DFF
1375
dffe_s #(11) bistctl_ff (
1376
        .din    (bistctl_data_in[10:0]),
1377
        .q      (bist_ctl_reg[10:0]),
1378
        .en (~(~bistctl_wr_en)), .clk(clk),
1379
        .se     (se),       .si (),          .so ()
1380
        );
1381
`else
1382
dff_s #(11) bistctl_ff (
1383
        .din    (bistctl_data_in[10:0]),
1384
        .q      (bist_ctl_reg[10:0]),
1385
        .clk    (bistctl_clk),
1386
        .se     (se),       .si (),          .so ()
1387
        );
1388
`endif
1389
*/
1390
 
1391
// Self-Timed Margin Control ASI
1392
// tap wr takes precedence
1393
wire  [27:0]  mrgnctl_data_in;
1394
wire  [27:0]  spc_mrgnctl_data_in;
1395
 
1396
wire  [27:0]  mrgn_ctl_reg ;
1397
 
1398
//itlb         [27:20]
1399
//dtlb         [19:12]
1400
//idct (i)     [11: 8]
1401
//idct (d)     [ 7: 4]
1402
//idct (mamem) [ 3: 0]
1403
 
1404
assign mrgnctl_data_in[27:0] =
1405
mrgn_tap_wr_en ? lsu_iobrdge_wr_data[27:0] :
1406
                 spc_mrgnctl_data_in[27:0];
1407
 
1408
assign spc_mrgnctl_data_in[27:0] =
1409
(~rst_l) ?  {8'b01011011, 8'b01011011, 4'b0101,4'b0101,4'b0101} :
1410
             st_rs3_data_g[27:0];
1411
 
1412
   wire mrgnctl_clk;
1413
 
1414
`ifdef FPGA_SYN_CLK_EN
1415
`else
1416
clken_buf mrgnctl_clkbuf (
1417
                .rclk   (clk),
1418
                .enb_l  (~mrgnctl_wr_en),
1419
                .tmb_l  (~se),
1420
                .clk    (mrgnctl_clk)
1421
                ) ;
1422
`endif
1423
 
1424
`ifdef FPGA_SYN_CLK_DFF
1425
dffe_s #(28) mrgnctl_ff (
1426
        .din    (mrgnctl_data_in[27:0]),
1427
        .q      (mrgn_ctl_reg[27:0]),
1428
        .en (~(~mrgnctl_wr_en)), .clk(clk),
1429
        .se     (se),       .si (),          .so ()
1430
        );
1431
`else
1432
dff_s #(28) mrgnctl_ff (
1433
        .din    (mrgnctl_data_in[27:0]),
1434
        .q      (mrgn_ctl_reg[27:0]),
1435
        .clk    (mrgnctl_clk),
1436
        .se     (se),       .si (),          .so ()
1437
        );
1438
`endif
1439
 
1440
assign  lsu_itlb_mrgn[7:0] = mrgn_ctl_reg[27:20] ;
1441
assign  lsu_dtlb_mrgn[7:0] = mrgn_ctl_reg[19:12] ;
1442
assign  lsu_ictag_mrgn[3:0] = mrgn_ctl_reg[11:8] ;
1443
assign  lsu_dctag_mrgn[3:0] = mrgn_ctl_reg[7:4] ;
1444
assign  lsu_mamem_mrgn[3:0] = mrgn_ctl_reg[3:0] ;
1445
 
1446
// LSU Diag Reg ASI
1447
wire  [1:0] ldiagctl_data_in ;
1448
 
1449
wire  [1:0] ldiag_ctl_reg ;
1450
 
1451
assign  ldiagctl_data_in[1:0] = {2{rst_l}} & st_rs3_data_g[1:0] ;
1452
 
1453
   wire ldiagctl_clk;
1454
 
1455
`ifdef FPGA_SYN_CLK_EN
1456
`else
1457
clken_buf ldiagctl_clkbuf (
1458
                .rclk   (clk),
1459
                .enb_l  (~ldiagctl_wr_en),
1460
                .tmb_l  (~se),
1461
                .clk    (ldiagctl_clk)
1462
                ) ;
1463
`endif
1464
 
1465
`ifdef FPGA_SYN_CLK_DFF
1466
dffe_s #(2) ldiagctl_ff (
1467
        .din    (ldiagctl_data_in[1:0]),
1468
        .q      (ldiag_ctl_reg[1:0]),
1469
        .en (~(~ldiagctl_wr_en)), .clk(clk),
1470
        .se     (se),       .si (),          .so ()
1471
        );
1472
`else
1473
dff_s #(2) ldiagctl_ff (
1474
        .din    (ldiagctl_data_in[1:0]),
1475
        .q      (ldiag_ctl_reg[1:0]),
1476
        .clk    (ldiagctl_clk),
1477
        .se     (se),       .si (),          .so ()
1478
        );
1479
`endif
1480
 
1481
assign  lsu_ifu_direct_map_l1 = ldiag_ctl_reg[0] ;
1482
assign  dc_direct_map = ldiag_ctl_reg[1] ;
1483
 
1484
   wire [43:0] misc_ctl_reg;
1485
 
1486
   wire [3:0] misc_ctl_sel_q;
1487
 
1488
dff_s #(4) misc_ctl_sel_stgg (
1489
    .din ( misc_ctl_sel_din[3:0] ),
1490
    .q   ( misc_ctl_sel_q[3:0]   ),
1491
    .clk (clk),
1492
    .se  (se),       .si (),          .so ()
1493
);
1494
   wire [3:0] misc_ctl_sel;
1495
 
1496
   assign     misc_ctl_sel[0] =  misc_ctl_sel_q [0] & ~rst_tri_en;
1497
   assign     misc_ctl_sel[1] =  misc_ctl_sel_q [1] & ~rst_tri_en;
1498
   assign     misc_ctl_sel[2] =  misc_ctl_sel_q [2] |  rst_tri_en;
1499
   assign     misc_ctl_sel[3] =  misc_ctl_sel_q [3] & ~rst_tri_en;
1500
 
1501
// Misc Ctl Registers
1502
mux4ds #(44)     miscrg_mx (
1503
        .in0    ({33'b0,bist_ctl_reg_out[10:0]}),
1504
        .in1    ({16'b0,mrgn_ctl_reg[27:0]}),
1505
        .in2    ({42'd0,ldiag_ctl_reg[1:0]}),
1506
        .in3    ({40'd0,dfture_tap_rd_data[3:0]}),
1507
        .sel0   (misc_ctl_sel[0]),
1508
        .sel1   (misc_ctl_sel[1]),
1509
        .sel2   (misc_ctl_sel[2]),
1510
        .sel3   (misc_ctl_sel[3]),
1511
        .dout   (misc_ctl_reg[43:0])
1512
        );
1513
 
1514
assign  lsu_iobrdge_rd_data[43:0] = misc_ctl_reg[43:0] ;
1515
 
1516
wire    [12:0]   ldxa_data_fmx1 ;
1517
 
1518
mux3ds #(13)     lsuasi_fmx1 (
1519
        .in0    (pctxt_state[12:0]),
1520
        .in1    (sctxt_state[12:0]),
1521
        .in2    ({10'd0,pid_state[2:0]}),
1522
        .sel0   (lsu_asi_sel_fmx1[0]),
1523
        .sel1   (lsu_asi_sel_fmx1[1]),
1524
        .sel2   (lsu_asi_sel_fmx1[2]),
1525
        .dout   (ldxa_data_fmx1[12:0])
1526
        );
1527
 
1528
wire  [47:0]  final_ldxa_data_g ;
1529
 
1530
//mux3ds #(48)     lsuasi_fmx2 (
1531
//        .in0    ({35'd0,ldxa_data_fmx1[12:0]}),
1532
//        .in1    ({15'd0,lsu_ctl_reg[15:8],2'b00,lsu_ctl_reg[5:4],17'd0,lsu_ctl_reg[3:0]}),
1533
//        .in2    ({lsu_va_wtchpt_addr[47:3],3'b000}),
1534
//        .sel0   (lsu_asi_sel_fmx2[0]),
1535
//        .sel1   (lsu_asi_sel_fmx2[1]),
1536
//        .sel2   (lsu_asi_sel_fmx2[2]),
1537
//        .dout   (local_ldxa_data_g[47:0])
1538
//        );
1539
 
1540
//mux2ds #(48)     lsuasi_final (
1541
//        .in0    (local_ldxa_data_g[47:0]),
1542
//        .in1    ({4'd0,misc_ctl_reg[43:0]}),
1543
//        .sel0   (~misc_asi_rd_en),
1544
//        .sel1   (misc_asi_rd_en),
1545
//        .dout   (final_ldxa_data_g[47:0])
1546
//        );
1547
 
1548
mux3ds #(48)     lsuasi_fmx2 (
1549
        .in0    ({35'd0,ldxa_data_fmx1[12:0]}),
1550
        .in1    ({15'd0,lsu_ctl_reg[13:6],2'b00,lsu_ctl_reg[5:4],17'd0,lsu_ctl_reg[3:0]}),
1551
        .in2    ({4'd0,misc_ctl_reg[43:0]}),
1552
        .sel0   (lsu_asi_sel_fmx2[0]),
1553
        .sel1   (lsu_asi_sel_fmx2[1]),
1554
        .sel2   (lsu_asi_sel_fmx2[2]),
1555
        .dout   (final_ldxa_data_g[47:0])
1556
        );
1557
 
1558
assign        lsu_local_ldxa_data_g[47:0] =  final_ldxa_data_g[47:0];
1559
 
1560
 
1561
/****************va staging*******************/
1562
 wire [47:0] ldst_va_m;
1563
dff_s  #(48) va_stgm (
1564
        .din    (exu_lsu_ldst_va_e[47:0]),
1565
        .q      (ldst_va_m[47:0]),
1566
        .clk    (clk),
1567
        .se     (se),       .si (),          .so ()
1568
        );
1569
 
1570
assign lsu_ldst_va_m[12:0] = ldst_va_m[12:0];
1571
 
1572
assign lsu_ldst_va_m_buf[47:0] = ldst_va_m[47:0];
1573
 
1574
 
1575
assign lsu_tlu_ldst_va_m[9:0] = ldst_va_m[9:0];
1576
 
1577
wire [47:0] ldst_va_g;
1578
dff_s  #(48) va_stgg (
1579
        .din    (ldst_va_m[47:0]),
1580
        .q      (ldst_va_g[47:0]),
1581
        .clk    (clk),
1582
        .se     (se),       .si (),          .so ()
1583
        );
1584
 
1585
assign  lsu_ldst_va_g[7:0] = ldst_va_g[7:0] ;
1586
 
1587
 
1588
wire  [7:0] asi_state_g ;
1589
assign  asi_state_g[7:0] = lsu_asi_state[7:0] ;
1590
 
1591
wire  [7:0] tlb_asi_state0,tlb_asi_state1,tlb_asi_state2,tlb_asi_state3 ;
1592
wire  [47:13] lngltncy_dmp_va ;
1593
 
1594
// Thread 0
1595
   wire [47:0] ldst_va0;
1596
 
1597
   wire        tlb_access0_clk;
1598
 
1599
`ifdef FPGA_SYN_CLK_EN
1600
`else
1601
clken_buf tlb_access0_clkbuf (
1602
                .rclk   (clk),
1603
                .enb_l  (~tlb_access_en0_g),
1604
                .tmb_l  (~se),
1605
                .clk    (tlb_access0_clk)
1606
                ) ;
1607
`endif
1608
 
1609
`ifdef FPGA_SYN_CLK_DFF
1610
dffe_s #(56)  asi_thrd0 (
1611
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1612
        .q      ({tlb_asi_state0[7:0],ldst_va0[47:0]}),
1613
        .en (~(~tlb_access_en0_g)), .clk(clk),
1614
        .se     (se),       .si (),          .so ()
1615
        );
1616
`else
1617
dff_s #(56)  asi_thrd0 (
1618
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1619
        .q      ({tlb_asi_state0[7:0],ldst_va0[47:0]}),
1620
        .clk    (tlb_access0_clk),
1621
        .se     (se),       .si (),          .so ()
1622
        );
1623
`endif
1624
 
1625
// Thread 1
1626
   wire [47:0] ldst_va1;
1627
 
1628
   wire        tlb_access1_clk;
1629
 
1630
`ifdef FPGA_SYN_CLK_EN
1631
`else
1632
clken_buf tlb_access1_clkbuf (
1633
                .rclk   (clk),
1634
                .enb_l  (~tlb_access_en1_g),
1635
                .tmb_l  (~se),
1636
                .clk    (tlb_access1_clk)
1637
                ) ;
1638
`endif
1639
 
1640
`ifdef FPGA_SYN_CLK_DFF
1641
dffe_s #(56)  asi_thrd1 (
1642
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1643
        .q      ({tlb_asi_state1[7:0],ldst_va1[47:0]}),
1644
        .en (~(~tlb_access_en1_g)), .clk(clk),
1645
        .se     (se),       .si (),          .so ()
1646
        );
1647
`else
1648
dff_s #(56)  asi_thrd1 (
1649
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1650
        .q      ({tlb_asi_state1[7:0],ldst_va1[47:0]}),
1651
        .clk    (tlb_access1_clk),
1652
        .se     (se),       .si (),          .so ()
1653
        );
1654
`endif
1655
 
1656
// Thread 2
1657
   wire [47:0] ldst_va2;
1658
 
1659
   wire        tlb_access2_clk;
1660
 
1661
`ifdef FPGA_SYN_CLK_EN
1662
`else
1663
clken_buf tlb_access2_clkbuf (
1664
                .rclk   (clk),
1665
                .enb_l  (~tlb_access_en2_g),
1666
                .tmb_l  (~se),
1667
                .clk    (tlb_access2_clk)
1668
                ) ;
1669
`endif
1670
 
1671
`ifdef FPGA_SYN_CLK_DFF
1672
dffe_s #(56)  asi_thrd2 (
1673
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1674
        .q      ({tlb_asi_state2[7:0],ldst_va2[47:0]}),
1675
        .en (~(~tlb_access_en2_g)), .clk(clk),
1676
        .se     (se),       .si (),          .so ()
1677
        );
1678
`else
1679
dff_s #(56)  asi_thrd2 (
1680
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1681
        .q      ({tlb_asi_state2[7:0],ldst_va2[47:0]}),
1682
        .clk    (tlb_access2_clk),
1683
        .se     (se),       .si (),          .so ()
1684
        );
1685
`endif
1686
 
1687
// Thread 3
1688
   wire [47:0] ldst_va3;
1689
 
1690
   wire        tlb_access3_clk;
1691
 
1692
`ifdef FPGA_SYN_CLK_EN
1693
`else
1694
clken_buf tlb_access3_clkbuf (
1695
                .rclk   (clk),
1696
                .enb_l  (~tlb_access_en3_g),
1697
                .tmb_l  (~se),
1698
                .clk    (tlb_access3_clk)
1699
                ) ;
1700
`endif
1701
 
1702
`ifdef FPGA_SYN_CLK_DFF
1703
dffe_s #(56)  asi_thrd3 (
1704
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1705
        .q      ({tlb_asi_state3[7:0],ldst_va3[47:0]}),
1706
        .en (~(~tlb_access_en3_g)), .clk(clk),
1707
        .se     (se),       .si (),          .so ()
1708
        );
1709
`else
1710
dff_s #(56)  asi_thrd3 (
1711
        .din    ({asi_state_g[7:0],   ldst_va_g[47:0]}),
1712
        .q      ({tlb_asi_state3[7:0],ldst_va3[47:0]}),
1713
        .clk    (tlb_access3_clk),
1714
        .se     (se),       .si (),          .so ()
1715
        );
1716
`endif
1717
 
1718
   wire [47:0] ldst_va_dout;
1719
 
1720
mux4ds #(56)     ldst_va_mx (
1721
        .in0    ({tlb_asi_state0[7:0],ldst_va0[47:0]}),
1722
        .in1    ({tlb_asi_state1[7:0],ldst_va1[47:0]}),
1723
        .in2    ({tlb_asi_state2[7:0],ldst_va2[47:0]}),
1724
        .in3    ({tlb_asi_state3[7:0],ldst_va3[47:0]}),
1725
        .sel0   (tlb_access_sel_thrd0),
1726
        .sel1   (tlb_access_sel_thrd1),
1727
        .sel2   (tlb_access_sel_thrd2),
1728
        .sel3   (tlb_access_sel_default),
1729
        .dout   ({lsu_tlu_tlb_asi_state_m[7:0], ldst_va_dout[47:0]})
1730
        );
1731
 
1732
assign  lsu_ifu_asi_state[7:0] = lsu_tlu_tlb_asi_state_m[7:0] ;
1733
 
1734
wire [17:0] lngltncy_ldst_va ;
1735
 
1736
assign  lngltncy_ldst_va[17:0] = ldst_va_dout[17:0];
1737
assign  lngltncy_dmp_va[47:13] = ldst_va_dout[47:13];
1738
assign  lsu_tlu_tlb_ldst_va_m[10:0] = lngltncy_ldst_va[10:0] ;
1739
assign  lsu_tlu_tlb_dmp_va_m[47:13] = lngltncy_dmp_va[47:13] ;
1740
assign  lsu_ifu_asi_addr[17:0] = lngltncy_ldst_va[17:0] ;
1741
 
1742
// Diagnostics
1743
 
1744
//wire  [3:0]   lsu_diag_access_sel_d1 ;
1745
 
1746
//dff #(4)  diagsel_stgd1 (
1747
//        .din    (lsu_diag_access_sel[3:0]),
1748
//        .q      (lsu_diag_access_sel_d1[3:0]),
1749
//        .clk    (clk),
1750
//        .se     (se),       .si (),          .so ()
1751
//        ); 
1752
  wire [3:0] diagnstc_va_sel;
1753
//change buffer to nand / nor 
1754
assign     diagnstc_va_sel[0] =   lsu_diagnstc_va_sel[0] & ~rst_tri_en;
1755
assign     diagnstc_va_sel[1] =   lsu_diagnstc_va_sel[1] & ~rst_tri_en;
1756
assign     diagnstc_va_sel[2] =   lsu_diagnstc_va_sel[2] & ~rst_tri_en;
1757
assign     diagnstc_va_sel[3] =   lsu_diagnstc_va_sel[3] |  rst_tri_en;
1758
 
1759
wire    [20:0] diag_va ;
1760
mux4ds #(21)     diag_va_mx (
1761
        .in0    (ldst_va0[20:0]),
1762
        .in1    (ldst_va1[20:0]),
1763
        .in2    (ldst_va2[20:0]),
1764
        .in3    (ldst_va3[20:0]),
1765
        .sel0   (diagnstc_va_sel[0]),
1766
        .sel1   (diagnstc_va_sel[1]),
1767
        .sel2   (diagnstc_va_sel[2]),
1768
        .sel3   (diagnstc_va_sel[3]),
1769
        .dout   (diag_va[20:0])
1770
        );
1771
 
1772
assign  lsu_diagnstc_wr_addr_e[10:0] = diag_va[10:0] ;
1773
assign  lsu_diagnstc_dc_prty_invrt_e[7:0] = diag_va[20:13] ;
1774
 
1775
//assign  lsu_lngltncy_ldst_va[13:11]= lngltncy_ldst_va[13:11] ;
1776
 
1777
//assign  lsu_diagnstc_wr_way_e[0] = ~diag_va[12] & ~diag_va[11] ;
1778
//assign  lsu_diagnstc_wr_way_e[1] = ~diag_va[12] &  diag_va[11] ;
1779
//assign  lsu_diagnstc_wr_way_e[2] =  diag_va[12] & ~diag_va[11] ;
1780
//assign  lsu_diagnstc_wr_way_e[3] =  diag_va[12] &  diag_va[11] ;
1781
 
1782
assign  lsu_diagnstc_wr_way_e[1:0] =  {diag_va[12],  diag_va[11]};
1783
 
1784
 
1785
assign  lsu_diag_va_prty_invrt = diag_va[13] ;
1786
 
1787
/***************error addr***************/
1788
wire  [10:4] dcfill_addr_m,dcfill_addr_g ;
1789
 
1790
dff_s #(7)  filla_stgm (
1791
        .din    (lsu_dcfill_addr_e[10:4]),
1792
        .q      (dcfill_addr_m[10:4]),
1793
        .clk    (clk),
1794
        .se     (se),       .si (),          .so ()
1795
        );
1796
 
1797
dff_s #(7)  filla_stgg (
1798
        .din    (dcfill_addr_m[10:4]),
1799
        .q      (dcfill_addr_g[10:4]),
1800
        .clk    (clk),
1801
        .se     (se),       .si (),          .so ()
1802
        );
1803
 
1804
wire  [28:0]  error_pa_g ;
1805
dff_s #(29)  epa_stgg (
1806
        .din    (lsu_error_pa_m[28:0]),
1807
        .q      (error_pa_g[28:0]),
1808
        .clk    (clk),
1809
        .se     (se),       .si (),          .so ()
1810
        );
1811
 
1812
wire  [47:4]  err_addr_g ;
1813
 
1814
mux3ds #(44)     erra_mx (
1815
        .in0    (ldst_va_g[47:4]),
1816
        .in1    ({38'd0,async_tlb_index[5:0]}),
1817
        .in2    ({8'd0,error_pa_g[28:0],dcfill_addr_g[10:4]}),
1818
        .sel0   (lsu_err_addr_sel[0]),
1819
        .sel1   (lsu_err_addr_sel[1]),
1820
        .sel2   (lsu_err_addr_sel[2]),
1821
        .dout   (err_addr_g[47:4])
1822
        );
1823
 
1824
/*assign  err_addr_g[47:4] =
1825
  sync_error_sel ?  ldst_va_g[47:4] :
1826
        async_error_sel ? {38'd0,async_tlb_index[5:0]} :
1827
                        {8'd0,error_pa_g[28:0],dcfill_addr_g[10:4]} ;*/
1828
 
1829
dff_s #(44)  errad_stgg (
1830
        .din    (err_addr_g[47:4]),
1831
        .q      (lsu_ifu_err_addr[47:4]),
1832
        .clk    (clk),
1833
        .se     (se),       .si (),          .so ()
1834
        );
1835
 
1836
endmodule // lsu_dctldp

powered by: WebSVN 2.1.0

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