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

Subversion Repositories s1_core

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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