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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_ifu_fcl.v] - Blame information for rev 95

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: sparc_ifu_fcl.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
//  Module Name: sparc_ifu_fcl
24
//  Description:
25
//  The FCL is the fetch control logic.  It controls the PC datapath
26
//  and the fetch/next instruction datapath.  It also manages access
27
//  to the icache data, tags, vbits and to the tlb.
28
//  The FCL starts fetching from the reset PC upon reset.  It is up to
29
//  the DTU to specify which thread to fetch from.  Only T0 is set to
30
//  the reset PC.  If the decode unit specifies any other thread, it
31
//  will fetch from an indeterminate address.
32
//  The fetch block automatically stalls the machine when an Imiss is
33
//  detected and there is no thread to switch to.
34
//
35
*/
36
////////////////////////////////////////////////////////////////////////
37
// Global header file includes
38
////////////////////////////////////////////////////////////////////////
39
 
40
/*
41
/* ========== Copyright Header Begin ==========================================
42
*
43
* OpenSPARC T1 Processor File: ifu.h
44
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
45
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
46
*
47
* The above named program is free software; you can redistribute it and/or
48
* modify it under the terms of the GNU General Public
49
* License version 2 as published by the Free Software Foundation.
50
*
51
* The above named program is distributed in the hope that it will be
52
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
53
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
54
* General Public License for more details.
55
*
56
* You should have received a copy of the GNU General Public
57
* License along with this work; if not, write to the Free Software
58
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
59
*
60
* ========== Copyright Header End ============================================
61
*/
62
////////////////////////////////////////////////////////////////////////
63
/*
64
//
65
//  Module Name: ifu.h
66
//  Description:
67
//  All ifu defines
68
*/
69
 
70
//--------------------------------------------
71
// Icache Values in IFU::ICD/ICV/ICT/FDP/IFQDP
72
//--------------------------------------------
73
// Set Values
74
 
75
// IC_IDX_HI = log(icache_size/4ways) - 1
76
 
77
 
78
// !!IMPORTANT!! a change to IC_LINE_SZ will mean a change to the code as
79
//   well.  Unfortunately this has not been properly parametrized.
80
//   Changing the IC_LINE_SZ param alone is *not* enough.
81
 
82
 
83
// !!IMPORTANT!! a change to IC_TAG_HI will mean a change to the code as
84
//   well.  Changing the IC_TAG_HI param alone is *not* enough to
85
//   change the PA range. 
86
// highest bit of PA
87
 
88
 
89
 
90
// Derived Values
91
// 4095
92
 
93
 
94
// number of entries - 1 = 511
95
 
96
 
97
// 12
98
 
99
 
100
// 28
101
 
102
 
103
// 7
104
 
105
 
106
// tags for all 4 ways + parity
107
// 116
108
 
109
 
110
// 115
111
 
112
 
113
 
114
//----------------------------------------------------------------------
115
// For thread scheduler in IFU::DTU::SWL
116
//----------------------------------------------------------------------
117
// thread states:  (thr_state[4:0])
118
 
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
// thread configuration register bit fields
128
 
129
 
130
 
131
 
132
 
133
 
134
 
135
//----------------------------------------------------------------------
136
// For MIL fsm in IFU::IFQ
137
//----------------------------------------------------------------------
138
 
139
 
140
 
141
 
142
 
143
 
144
 
145
 
146
 
147
 
148
 
149
//---------------------------------------------------
150
// Interrupt Block
151
//---------------------------------------------------
152
 
153
 
154
 
155
 
156
 
157
 
158
 
159
//-------------------------------------
160
// IFQ
161
//-------------------------------------
162
// valid bit plus ifill
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 
174
 
175
 
176
//`ifdef SPARC_L2_64B
177
 
178
 
179
//`else
180
//`define BANK_ID_HI 8
181
//`define BANK_ID_LO 7
182
//`endif
183
 
184
//`define CPX_INV_PA_HI  116
185
//`define CPX_INV_PA_LO  112
186
 
187
 
188
 
189
 
190
 
191
 
192
 
193
//----------------------------------------
194
// IFU Traps
195
//----------------------------------------
196
// precise
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
 
206
 
207
 
208
 
209
 
210
 
211
 
212
// disrupting
213
 
214
 
215
 
216
 
217
 
218
 
219
 
220
 
221
 
222
module sparc_ifu_fcl(/*AUTOARG*/
223
   // Outputs
224
   fcl_icd_rdreq_bf, fcl_icv_rdreq_bf, fcl_icd_wrreq_bf,
225
   fcl_ict_wrreq_bf, fcl_icv_wrreq_bf, fcl_icd_index_sel_ifq_bf,
226
   fcl_ifq_grant_bf, fcl_ifq_icmiss_s1, fcl_ifq_rdreq_s1,
227
   fcl_ifq_icache_en_s_l, fcl_ifq_thr_s1, fcl_ifq_canthr,
228
   fcl_itlb_cam_vld_bf, fcl_itlb_cam_bypass_bf, fcl_itlb_addr_mask_l,
229
   fcl_itlb_cam_real_bf, fcl_itlb_cam_pid_bf, fcl_itlb_wr_vld_bf,
230
   fcl_itlb_dmp_vld_bf, fcl_itlb_dmp_all_bf, fcl_itlb_tag_rd_vld_bf,
231
   fcl_itlb_invall_f_l, fcl_itlb_data_rd_vld_bf, fcl_erb_ievld_s1,
232
   fcl_erb_tevld_s1, fcl_erb_immuevld_s1, ifu_lsu_thrid_s,
233
   fcl_erb_asi_tid_f, fcl_erb_clear_iferr, fcl_erb_itlbrd_vld_s,
234
   fcl_erb_itlbrd_data_s, fcl_dec_dslot_s, fcl_dtu_inst_vld_e,
235
   fcl_dtu_intr_vld_e, fcl_dtu_inst_vld_d, fcl_dtu_ely_inst_vld_d,
236
   fcl_dec_intr_vld_d, fcl_erb_inst_issue_d, fcl_erb_inst_vld_d1,
237
   ifu_tlu_inst_vld_m, ifu_exu_inst_vld_e, ifu_exu_inst_vld_w,
238
   ifu_spu_inst_vld_w, ifu_tlu_inst_vld_w, ifu_tlu_flush_w,
239
   ifu_tlu_flush_m, fcl_swl_int_activate_i3, fcl_swl_flush_wake_w,
240
   fcl_swl_flush_w, fcl_dcl_regz_e, ifu_tlu_thrid_e, ifu_tlu_thrid_d,
241
   ifu_tlu_immu_miss_m, ifu_tlu_priv_violtn_m, ifu_tlu_icmiss_e,
242
   ifu_tlu_ttype_vld_m, ifu_exu_ttype_vld_m, ifu_mmu_trap_m,
243
   ifu_tlu_trap_m, ifu_tlu_ttype_m, ifu_tlu_hwint_m,
244
   ifu_tlu_sftint_m, ifu_tlu_rstint_m, fcl_dtu_rst_thr_w,
245
   fcl_dtu_resum_thr_w, ifu_tlu_itlb_done, ifu_spu_trap_ack,
246
   ifu_exu_tid_s2, ifu_exu_ren1_s, ifu_exu_ren2_s, ifu_exu_ren3_s,
247
   ifu_exu_disable_ce_e, fcl_dtu_sync_intr_d, fcl_dtu_tlzero_d,
248
   fcl_dtu_privmode_d, fcl_dtu_hprivmode_d, fcl_dtu_hprivmode_w2,
249
   fcl_dtu_nuke_thr_w, fcl_swl_swout_f, fcl_dtu_stall_bf,
250
   fcl_swl_swcvld_s, fcl_dtu_thr_f, fcl_imd_oddwin_d,
251
   fcl_fdp_oddwin_s, fcl_fdp_pcoor_vec_f, fcl_fdp_pcoor_f,
252
   fcl_fdp_mask32b_f, fcl_fdp_addr_mask_d, fcl_fdp_tctxt_sel_prim,
253
   fcl_fdp_usenir_sel_nir_s1, fcl_fdp_rbinst_sel_inste_s,
254
   fcl_fdp_thrtnpc_sel_tnpc_l, fcl_fdp_thrtnpc_sel_npcw_l,
255
   fcl_fdp_thrtnpc_sel_pcf_l, fcl_fdp_thrtnpc_sel_old_l,
256
   fcl_fdp_thr_s1_l, fcl_fdp_next_thr_bf_l, fcl_fdp_next_ctxt_bf_l,
257
   fcl_fdp_nirthr_s1_l, fcl_fdp_thr_s2_l,
258
   fcl_fdp_tpcbf_sel_pcp4_bf_l, fcl_fdp_tpcbf_sel_brpc_bf_l,
259
   fcl_fdp_tpcbf_sel_trap_bf_l, fcl_fdp_tpcbf_sel_old_bf_l,
260
   fcl_fdp_pcbf_sel_nosw_bf_l, fcl_fdp_pcbf_sel_swpc_bf_l,
261
   fcl_fdp_pcbf_sel_br_bf_l, fcl_fdp_trrbpc_sel_trap_bf_l,
262
   fcl_fdp_trrbpc_sel_rb_bf_l, fcl_fdp_trrbpc_sel_err_bf_l,
263
   fcl_fdp_trrbpc_sel_pcs_bf_l, fcl_fdp_noswpc_sel_tnpc_l_bf,
264
   fcl_fdp_noswpc_sel_old_l_bf, fcl_fdp_noswpc_sel_inc_l_bf,
265
   fcl_fdp_nextpcs_sel_pce_f_l, fcl_fdp_nextpcs_sel_pcd_f_l,
266
   fcl_fdp_nextpcs_sel_pcs_f_l, fcl_fdp_nextpcs_sel_pcf_f_l,
267
   fcl_fdp_inst_sel_curr_s_l, fcl_fdp_inst_sel_switch_s_l,
268
   fcl_fdp_inst_sel_nir_s_l, fcl_fdp_inst_sel_nop_s_l,
269
   fcl_fdp_tinst_sel_curr_s_l, fcl_fdp_tinst_sel_rb_s_l,
270
   fcl_fdp_tinst_sel_old_s_l, fcl_fdp_tinst_sel_ifq_s_l,
271
   fcl_fdp_dmpthr_l, fcl_fdp_ctxt_sel_dmp_bf_l,
272
   fcl_fdp_ctxt_sel_sw_bf_l, fcl_fdp_ctxt_sel_curr_bf_l,
273
   fcl_fdp_rdsr_sel_pc_e_l, fcl_fdp_rdsr_sel_thr_e_l,
274
   fcl_fdp_rdsr_sel_ver_e_l, so, ifu_reset_l,
275
   // Inputs
276
   rclk, grst_l, arst_l, se, sehold, si, rst_tri_en,
277
   tlu_ifu_flush_pipe_w, exu_ifu_va_oor_m, exu_ifu_oddwin_s,
278
   spu_ifu_ttype_tid_w2, spu_ifu_ttype_vld_w2, spu_ifu_ttype_w2,
279
   erb_fcl_spu_uetrap, exu_ifu_regz_e, dcl_fcl_bcregz0_e,
280
   dcl_fcl_bcregz1_e, dtu_fcl_rollback_g, dtu_fcl_retract_d,
281
   dtu_fcl_br_inst_d, dtu_fcl_sir_inst_e, dtu_fcl_privop_e,
282
   dtu_fcl_fpdis_e, dtu_fcl_imask_hit_e, dtu_fcl_illinst_e,
283
   dtu_fcl_thr_active, dec_fcl_rdsr_sel_pc_d, dec_fcl_rdsr_sel_thr_d,
284
   ifq_fcl_wrreq_bf, ifq_fcl_icd_wrreq_bf, ifq_fcl_ictv_wrreq_bf,
285
   ifq_fcl_rdreq_bf, ifq_fcl_asi_tid_bf, ifq_fcl_asird_bf,
286
   ifq_fcl_invreq_bf, erb_fcl_itlb_ce_d1, erb_dtu_ifeterr_d1,
287
   erb_fcl_ifet_uevec_d1, erb_fcl_ue_trapvec, erb_fcl_ce_trapvec,
288
   dtu_fcl_nextthr_bf, dtu_fcl_ntr_s, dtu_fcl_running_s,
289
   dtu_fcl_flush_sonly_e, fdp_fcl_swc_s2, fdp_fcl_va2_bf,
290
   itlb_fcl_tlbmiss_f_l, itlb_fcl_priv_s1, itlb_fcl_cp_s1,
291
   itlb_fcl_imiss_s_l, fdp_fcl_pc_oor_vec_f, fdp_fcl_pc_oor_e,
292
   fdp_fcl_op_s, fdp_fcl_op3_s, fdp_fcl_ibit_s, lsu_ifu_stallreq,
293
   ffu_ifu_stallreq, wbm_spc_stallreq, ifq_fcl_stallreq, dtu_inst_anull_e,
294
   ifq_fcl_fill_thr, ifq_fcl_flush_sonly_e, tlu_ifu_trap_tid_w1,
295
   tlu_ifu_trappc_vld_w1, tlu_ifu_trapnpc_vld_w1,
296
   tlu_lsu_pstate_priv, tlu_lsu_pstate_am, tlu_hpstate_priv,
297
   tlu_lsu_redmode, tlu_hpstate_enb, lsu_ifu_addr_real_l,
298
   lsu_pid_state0, lsu_pid_state1, lsu_pid_state2, lsu_pid_state3,
299
   lsu_ifu_icache_en, lsu_ifu_dc_parity_error_w2, lsu_ifu_t0_tlz,
300
   lsu_ifu_t1_tlz, lsu_ifu_t2_tlz, lsu_ifu_t3_tlz, tlu_ifu_hwint_i3,
301
   tlu_ifu_pstate_ie, tlu_ifu_sftint_vld, tlu_ifu_hintp_vld,
302
   tlu_ifu_rerr_vld, tlu_ifu_rstthr_i2, tlu_ifu_rstint_i2,
303
   tlu_ifu_resumint_i2, tlu_ifu_nukeint_i2, tlu_itlb_wr_vld_g,
304
   tlu_itlb_dmp_vld_g, tlu_itlb_dmp_all_g, tlu_itlb_data_rd_g,
305
   tlu_itlb_tag_rd_g, tlu_itlb_invalidate_all_g, tlu_fcl_dmp_pid_bf,
306
   tlu_fcl_dmp_real_bf, tlu_idtlb_dmp_thrid_g, exu_ifu_ecc_ce_m,
307
   ffu_ifu_fst_ce_w
308
   );
309
 
310
   input  rclk,
311
                grst_l,
312
          arst_l,
313
                se,
314
          sehold,
315
                si;
316
 
317
   input  rst_tri_en;
318
 
319
 
320
   input  tlu_ifu_flush_pipe_w; // flush pipe on a trap
321
   input  exu_ifu_va_oor_m;
322
   input [3:0] exu_ifu_oddwin_s;
323
 
324
   input [1:0] spu_ifu_ttype_tid_w2;
325
   input       spu_ifu_ttype_vld_w2;
326
   input       spu_ifu_ttype_w2;
327
 
328
   input [3:0] erb_fcl_spu_uetrap;  // use m3
329
 
330
//   input       dtu_fcl_brtaken_e;    // branch taken
331
   input       exu_ifu_regz_e;
332
   input       dcl_fcl_bcregz0_e,
333
               dcl_fcl_bcregz1_e;
334
 
335
   input       dtu_fcl_rollback_g;
336
   input       dtu_fcl_retract_d;
337
   input       dtu_fcl_br_inst_d;
338
   input       dtu_fcl_sir_inst_e;
339
   input       dtu_fcl_privop_e,
340
                           dtu_fcl_fpdis_e,
341
               dtu_fcl_imask_hit_e,
342
                           dtu_fcl_illinst_e;
343
   input [3:0] dtu_fcl_thr_active;
344
 
345
   input       dec_fcl_rdsr_sel_pc_d,
346
                           dec_fcl_rdsr_sel_thr_d;
347
 
348
   input       ifq_fcl_wrreq_bf;
349
   input       ifq_fcl_icd_wrreq_bf,
350
                           ifq_fcl_ictv_wrreq_bf,
351
                           ifq_fcl_rdreq_bf;
352
 
353
   input [1:0] ifq_fcl_asi_tid_bf;
354
   input       ifq_fcl_asird_bf;
355
 
356
   input       ifq_fcl_invreq_bf;
357
 
358
   input       erb_fcl_itlb_ce_d1;
359
   input       erb_dtu_ifeterr_d1;
360
   input [3:0] erb_fcl_ifet_uevec_d1,
361
                           erb_fcl_ue_trapvec,
362
                           erb_fcl_ce_trapvec;
363
 
364
   input [3:0] dtu_fcl_nextthr_bf;   // thread to switch to
365
   input       dtu_fcl_ntr_s,        // next thread ready for ex
366
               dtu_fcl_running_s;
367
 
368
   input       dtu_fcl_flush_sonly_e;
369
//               dec_fcl_kill4sta_e;
370
 
371
   input       fdp_fcl_swc_s2,       // instruction switch condition
372
                           fdp_fcl_va2_bf,       // bit 2 of vaddr
373
                           itlb_fcl_tlbmiss_f_l,  // itlb miss
374
                           itlb_fcl_priv_s1,     // privileged access page
375
                           itlb_fcl_cp_s1,       // uncached access page
376
                           itlb_fcl_imiss_s_l;     // icache miss in s1
377
 
378
   input [3:0] fdp_fcl_pc_oor_vec_f;
379
   input       fdp_fcl_pc_oor_e;
380
 
381
   input [1:0] fdp_fcl_op_s;
382
   input [5:2] fdp_fcl_op3_s;
383
   input       fdp_fcl_ibit_s;
384
 
385
   input       lsu_ifu_stallreq,
386
                     ffu_ifu_stallreq, wbm_spc_stallreq,
387
               ifq_fcl_stallreq;
388
 
389
   input       dtu_inst_anull_e;
390
 
391
   input [3:0] ifq_fcl_fill_thr;     // fill inst goes to this
392
                                         // thread instruction register
393
   input       ifq_fcl_flush_sonly_e;
394
 
395
   input [1:0] tlu_ifu_trap_tid_w1;     // thr for which trappc is sent
396
   input       tlu_ifu_trappc_vld_w1,   // ld pc on trap or done/retry
397
                           tlu_ifu_trapnpc_vld_w1;  // ld Npc for a retry
398
 
399
   input [3:0] tlu_lsu_pstate_priv;     // may need to flop these three
400
   input [3:0] tlu_lsu_pstate_am;
401
   input [3:0] tlu_hpstate_priv;
402
   input [3:0] tlu_lsu_redmode;
403
   input [3:0] tlu_hpstate_enb;
404
 
405
   input [3:0] lsu_ifu_addr_real_l;
406
   input [2:0] lsu_pid_state0,
407
               lsu_pid_state1,
408
               lsu_pid_state2,
409
               lsu_pid_state3;
410
   input [3:0] lsu_ifu_icache_en;
411
 
412
   input       lsu_ifu_dc_parity_error_w2;
413
 
414
 
415
//   input       lsu_ifu_flush_ireg;  // not needed any more
416
   input       lsu_ifu_t0_tlz,
417
                           lsu_ifu_t1_tlz,
418
                           lsu_ifu_t2_tlz,
419
                           lsu_ifu_t3_tlz;
420
 
421
   input [3:0] tlu_ifu_hwint_i3,        // normal interrupt
422
                           tlu_ifu_pstate_ie,
423
                           tlu_ifu_sftint_vld,
424
                           tlu_ifu_hintp_vld,
425
                           tlu_ifu_rerr_vld,
426
                           tlu_ifu_rstthr_i2;       // reset or idle interrupt
427
 
428
   input       tlu_ifu_rstint_i2,       // reset to a dead thread
429
                           tlu_ifu_resumint_i2,
430
                           tlu_ifu_nukeint_i2;
431
 
432
   input       tlu_itlb_wr_vld_g,
433
                           tlu_itlb_dmp_vld_g,
434
               tlu_itlb_dmp_all_g,
435
                           tlu_itlb_data_rd_g,
436
                           tlu_itlb_tag_rd_g;
437
   input       tlu_itlb_invalidate_all_g;
438
 
439
   input [2:0] tlu_fcl_dmp_pid_bf;
440
   input       tlu_fcl_dmp_real_bf;
441
   input [1:0] tlu_idtlb_dmp_thrid_g;
442
 
443
   input       exu_ifu_ecc_ce_m;
444
   input       ffu_ifu_fst_ce_w;
445
 
446
   // to icd
447
   output      fcl_icd_rdreq_bf,
448
               fcl_icv_rdreq_bf,
449
                           fcl_icd_wrreq_bf,
450
                           fcl_ict_wrreq_bf,
451
                           fcl_icv_wrreq_bf;
452
 
453
   output      fcl_icd_index_sel_ifq_bf;
454
   output      fcl_ifq_grant_bf;
455
 
456
   // to ifq
457
   output      fcl_ifq_icmiss_s1;  // if icache turned off
458
   output      fcl_ifq_rdreq_s1;
459
   output      fcl_ifq_icache_en_s_l;
460
 
461
   output [1:0] fcl_ifq_thr_s1;
462
   output [3:0] fcl_ifq_canthr;     // cancel ifetch to this thread
463
 
464
   // to itlb
465
   output       fcl_itlb_cam_vld_bf,
466
                fcl_itlb_cam_bypass_bf,
467
                            fcl_itlb_addr_mask_l,
468
                fcl_itlb_cam_real_bf;
469
 
470
   output [2:0] fcl_itlb_cam_pid_bf;
471
 
472
   output       fcl_itlb_wr_vld_bf,
473
                            fcl_itlb_dmp_vld_bf,
474
                fcl_itlb_dmp_all_bf,
475
                            fcl_itlb_tag_rd_vld_bf,
476
                            fcl_itlb_invall_f_l,
477
                            fcl_itlb_data_rd_vld_bf;
478
 
479
   // to erb
480
   output       fcl_erb_ievld_s1,
481
                            fcl_erb_tevld_s1,
482
                            fcl_erb_immuevld_s1;
483
 
484
   output [1:0] ifu_lsu_thrid_s,
485
                            fcl_erb_asi_tid_f;
486
 
487
   output [3:0] fcl_erb_clear_iferr;
488
 
489
 
490
   output       fcl_erb_itlbrd_vld_s,
491
                            fcl_erb_itlbrd_data_s;
492
 
493
   output       fcl_dec_dslot_s;
494
   output       fcl_dtu_inst_vld_e,
495
                fcl_dtu_intr_vld_e,
496
                            fcl_dtu_inst_vld_d,
497
                fcl_dtu_ely_inst_vld_d,
498
                fcl_dec_intr_vld_d,
499
                            fcl_erb_inst_issue_d,
500
                            fcl_erb_inst_vld_d1,
501
                            ifu_tlu_inst_vld_m,
502
//                          ifu_lsu_inst_vld_m,
503
                            ifu_exu_inst_vld_e,
504
                            ifu_exu_inst_vld_w,
505
                            ifu_spu_inst_vld_w,
506
                            ifu_tlu_inst_vld_w;
507
 
508
   output       ifu_tlu_flush_w;
509
   output       ifu_tlu_flush_m;
510
 
511
   output [3:0] fcl_swl_int_activate_i3;
512
   output       fcl_swl_flush_wake_w;
513
   output       fcl_swl_flush_w;
514
 
515
   output       fcl_dcl_regz_e;
516
 
517
   // to tlu
518
   output [1:0] ifu_tlu_thrid_e;
519
   output [1:0] ifu_tlu_thrid_d;
520
 
521
   output       ifu_tlu_immu_miss_m,
522
                            ifu_tlu_priv_violtn_m;
523
 
524
   output       ifu_tlu_icmiss_e;
525
   output       ifu_tlu_ttype_vld_m;
526
   output       ifu_exu_ttype_vld_m;
527
   output       ifu_mmu_trap_m;
528
   output       ifu_tlu_trap_m;
529
   output [8:0] ifu_tlu_ttype_m;
530
 
531
   output       ifu_tlu_hwint_m;
532
   output       ifu_tlu_sftint_m;
533
//   output       ifu_tlu_hintp_m;
534
//   output       ifu_tlu_rerr_m;
535
   output       ifu_tlu_rstint_m;
536
   output       fcl_dtu_rst_thr_w;
537
   output       fcl_dtu_resum_thr_w;
538
 
539
   output       ifu_tlu_itlb_done;
540
 
541
   output       ifu_spu_trap_ack;
542
 
543
   // to exu
544
   output [1:0] ifu_exu_tid_s2;
545
   output       ifu_exu_ren1_s,
546
                            ifu_exu_ren2_s,
547
                            ifu_exu_ren3_s;
548
 
549
   output       ifu_exu_disable_ce_e;  // to exu and ffu
550
 
551
 
552
   // to dtu
553
   output       fcl_dtu_sync_intr_d;
554
   output       fcl_dtu_tlzero_d;
555
   output       fcl_dtu_privmode_d;
556
   output       fcl_dtu_hprivmode_d;
557
   output       fcl_dtu_hprivmode_w2;
558
   output       fcl_dtu_nuke_thr_w;
559
   output       fcl_swl_swout_f;
560
   output       fcl_dtu_stall_bf;
561
//   output       fcl_dtu_switch_s;     // indicates to the DTU that a
562
                                      // switch took place to next_thr
563
   output       fcl_swl_swcvld_s;
564
   output [3:0] fcl_dtu_thr_f;
565
   output       fcl_imd_oddwin_d;
566
 
567
   // to fdp
568
   output       fcl_fdp_oddwin_s;
569
   output [3:0] fcl_fdp_pcoor_vec_f;
570
   output       fcl_fdp_pcoor_f;
571
   output       fcl_fdp_mask32b_f;
572
   output       fcl_fdp_addr_mask_d;
573
 
574
   output [3:0] fcl_fdp_tctxt_sel_prim;
575
 
576
 
577
   // 2:1 mux selects
578
   output       fcl_fdp_usenir_sel_nir_s1;   // same as usenir_d2
579
   output [3:0] fcl_fdp_rbinst_sel_inste_s;
580
 
581
   output [3:0] fcl_fdp_thrtnpc_sel_tnpc_l,  // load npc
582
                            fcl_fdp_thrtnpc_sel_npcw_l,
583
                            fcl_fdp_thrtnpc_sel_pcf_l,
584
                            fcl_fdp_thrtnpc_sel_old_l;
585
 
586
   output [3:0] fcl_fdp_thr_s1_l;            // s1 thr for thrNIR input mux
587
 
588
   // other mux selects   
589
   output [3:0] fcl_fdp_next_thr_bf_l,  // for thrpc output mux
590
                fcl_fdp_next_ctxt_bf_l, // for ctxt output mux
591
                            fcl_fdp_nirthr_s1_l,    // select NIR in s1 stage
592
                            fcl_fdp_thr_s2_l;       // s2 thr for thr_inst_reg
593
 
594
   output [3:0] fcl_fdp_tpcbf_sel_pcp4_bf_l, // selects for thread PC muxes
595
                            fcl_fdp_tpcbf_sel_brpc_bf_l,
596
                            fcl_fdp_tpcbf_sel_trap_bf_l,
597
                            fcl_fdp_tpcbf_sel_old_bf_l;
598
 
599
   output       fcl_fdp_pcbf_sel_nosw_bf_l,      // F stage pc mux selects
600
                            fcl_fdp_pcbf_sel_swpc_bf_l,
601
                            fcl_fdp_pcbf_sel_br_bf_l;
602
 
603
   output [3:0] fcl_fdp_trrbpc_sel_trap_bf_l,
604
                            fcl_fdp_trrbpc_sel_rb_bf_l,
605
                            fcl_fdp_trrbpc_sel_err_bf_l,
606
                            fcl_fdp_trrbpc_sel_pcs_bf_l;
607
 
608
   output       fcl_fdp_noswpc_sel_tnpc_l_bf,    // next pc select,
609
                            fcl_fdp_noswpc_sel_old_l_bf,                 // dont need anymore
610
                            fcl_fdp_noswpc_sel_inc_l_bf;
611
 
612
   output [3:0] fcl_fdp_nextpcs_sel_pce_f_l,
613
                            fcl_fdp_nextpcs_sel_pcd_f_l,
614
                            fcl_fdp_nextpcs_sel_pcs_f_l,
615
                            fcl_fdp_nextpcs_sel_pcf_f_l;
616
 
617
   output       fcl_fdp_inst_sel_curr_s_l,   // selects for inst_s2
618
                            fcl_fdp_inst_sel_switch_s_l,
619
                            fcl_fdp_inst_sel_nir_s_l,
620
                            fcl_fdp_inst_sel_nop_s_l;
621
 
622
   output [3:0] fcl_fdp_tinst_sel_curr_s_l,  // selects for tinst regs
623
                            fcl_fdp_tinst_sel_rb_s_l,
624
                            fcl_fdp_tinst_sel_old_s_l,
625
                            fcl_fdp_tinst_sel_ifq_s_l;
626
 
627
   output [3:0] fcl_fdp_dmpthr_l;
628
 
629
   output       fcl_fdp_ctxt_sel_dmp_bf_l,
630
                            fcl_fdp_ctxt_sel_sw_bf_l,
631
                            fcl_fdp_ctxt_sel_curr_bf_l;
632
 
633
   output       fcl_fdp_rdsr_sel_pc_e_l,
634
                fcl_fdp_rdsr_sel_thr_e_l,
635
                fcl_fdp_rdsr_sel_ver_e_l;
636
 
637
   output       so,
638
                ifu_reset_l;
639
 
640
 
641
   //----------------------------------------------------------------------
642
   // Declarations
643
   //----------------------------------------------------------------------
644
   reg [3:0]    fcl_fdp_tpcbf_sel_old_bf_l,
645
                            fcl_fdp_tpcbf_sel_pcp4_bf_l,
646
                            fcl_fdp_tpcbf_sel_trap_bf_l,
647
                            fcl_fdp_tpcbf_sel_brpc_bf_l;
648
 
649
   wire         fcl_fdp_inst_sel_nop_s_l,
650
                fcl_fdp_inst_sel_nir_s_l,
651
                            fcl_fdp_inst_sel_curr_s_l,
652
                            fcl_fdp_inst_sel_switch_s_l;
653
 
654
 
655
   // local signals
656
   wire         //sw_itlb_on,
657
                sw_itlb_real,
658
                            sw_itlb_am,
659
                            //this_itlb_on,
660
                this_itlb_real,
661
                            itlb_on;
662
 
663
   wire [3:0]   xlate_en,
664
                xlate_en_d1;
665
 
666
   wire [2:0]   sw_pid_bf,
667
                curr_pid_bf;
668
 
669
   wire         pid_sel_sw,
670
                pid_sel_curr,
671
                pid_sel_dmp;
672
 
673
   wire         itlb_access_gnt,
674
                            itlb_access_en,
675
                itlb_write_en,
676
                ctxt_sel_dmp,
677
                            itlb_access_done,
678
                itlb_write_done,
679
                            itlb_rd_access_done,
680
                            itlb_rd_access_done_d1,
681
                            itlb_rd_access_done_d2,
682
                            itlb_rd_req_bf,
683
                            itlb_rd_req_f,
684
                            itlb_data_rd_f,
685
                itlb_data_rd_s;
686
 
687
   wire [1:0]   asi_tid_bf;
688
   wire [1:0]   spu_tid_w2;
689
 
690
   wire         fetch_bf,       // fetch an instruction next cycle
691
                allow_ifq_access_icd_bf,
692
                inst_access_bf,
693
                ia1_bf,
694
                ia0_bf,
695
                no_instacc_bf;
696
 
697
   wire         cam_vld_bf,
698
                tlb_invall_bf,
699
                tlb_invall_f,
700
//                tlb_invall_req_bf,
701
                inst_vld_bf;
702
 
703
   wire         rdreq_bf,     // read from I$ next cycle
704
                            rdreq_f;
705
 
706
   wire         ic_wrreq_bf;
707
 
708
   wire         running_s2,
709
                valid_s,
710
                            running_s1,
711
                ely_running_s1,
712
                            running_d,
713
                            running_e,
714
                            running_m,
715
                        inst_vld_f,
716
                            inst_vld_s,
717
                inst_vld_s_crit,
718
                            inst_vld_s1,
719
                            inst_vld_s2,    // valid bit of S stage
720
                                            // instruction.  If this is 0,
721
                                            // convert inst to no-op
722
                            inst_vld_d,
723
                inst_vld_d_crit,
724
                            inst_vld_d1,
725
                            inst_vld_e,
726
                            inst_vld_qual_e,
727
                            inst_vld_m,
728
                            inst_vld_w;
729
 
730
   wire         inst_vld_w_crit;
731
 
732
   wire         no_iftrap_m,
733
                no_iftrap_w;
734
 
735
   wire         stall_f,
736
                            stall_s1,
737
                            stall_s1_nxt,
738
                ely_stall_thisthr_f,
739
                part_stall_thisthr_f,
740
                            stall_thisthr_f;
741
   wire         rdreq_s1;
742
 
743
   wire         usenir_bf,
744
                            usenir_f,
745
                            usenir_s1;
746
 
747
   wire [3:0]   tinst_vld_s,    // valid bit of thr instr register
748
                                            // in s stage
749
                            tinst_vld_nxt;
750
 
751
   wire [3:0]   val_thr_s1,
752
                            val_thr_f,
753
                thr_e_v2,
754
                            val_thr_e;
755
 
756
   wire         flush_sonly_qual_e,
757
                flush_sonly_all_m,
758
                flush_sonly_qual_m,
759
                ims_flush_sonly_m,
760
                ims_flush_sonly_w,
761
                ims_flush_coll_m,
762
                ims_flush_coll_w,
763
                flush_sonly_m;
764
 
765
   wire         flush_pipe_w;
766
 
767
   wire         kill_thread_d,
768
//                          kill_thread_e,
769
                            kill_thread_m,
770
                kill_local_m,
771
                ely_kill_thread_s2,
772
                ely_kill_thread_m,
773
                            kill_thread_s2;
774
 
775
   wire [3:0]   clear_s_d1,
776
                flush_thr_w,
777
                late_flush_w2;
778
 
779
   wire         utrap_flush_w,
780
                utrap_flush_m,
781
                flush_pipe_w2;
782
 
783
   wire         kill_curr_f,
784
                kill_curr_d,
785
                kill_curr_e,
786
                kill_curr_m;
787
 
788
   wire [3:0]   canthr_f,
789
                canthr_s_early,
790
                            canthr_s;
791
   wire         canthr_sw;
792
   wire         canthr_sm,
793
                canthr_sd;
794
 
795
   wire         forcemiss_f,   // force an icache miss (if icache is off)
796
                            forcemiss_s1,
797
                icmiss_for_perf,
798
//                ic_miss_sw_s1,
799
                            ic_miss_s1;    // icache miss (forced or not)
800
 
801
   wire [3:0]   icache_en_d1;
802
 
803
   wire         icache_on_bf,
804
                            icache_on_f,
805
                            icache_on_s1,
806
                uncached_page_s1;
807
//                          sw_icache_on,
808
//                          this_icache_on;
809
 
810
   wire         imsto_thisthr_s1,
811
                iferrto_thisthr_d1,
812
                retract_iferr_d1,
813
                retract_iferr_qual_d1,
814
                retract_inst_d,
815
                retract_iferr_e;
816
//   wire         intrto_thisthr_d;
817
//   wire         imsto_nextthr_s1;
818
 
819
   wire         mark4rb_w,
820
                mark4rb_m,
821
                mark4rb_e,
822
                mark4rb_d,
823
                mark4rb_s;
824
 
825
   wire [3:0]   tlbmiss_s2,
826
                            tlbmiss_d,
827
                            nir_tlbmiss_vec,
828
                            nir_tlbmiss_next;
829
 
830
   wire [3:0]   delay_slot_vec,
831
                delay_slot_vec_nxt;
832
 
833
   wire         tlb_cam_miss_f,
834
                tlb_cam_miss_s1,
835
                nir_tlbmiss_s1,
836
                            tlbmiss_s1_crit,
837
                            tlbmiss_s1;
838
 
839
   wire         cam_vld_f,
840
                            cam_vld_s1;
841
 
842
   wire         immu_fault_f,
843
                            immu_miss_d,
844
                            immu_miss_crit_d,
845
                            immu_miss_qual_d,
846
                            immu_miss_e,
847
//                immu_miss_qual_e,
848
                immu_miss_m,
849
                addr_real_e;
850
   wire [3:0]   itlb_addr_real_l,
851
                itlb_addr_real;
852
   wire [3:0]   pstate_am_d1;
853
 
854
   wire         pc_oor_s1,
855
                pc_oor_s2,
856
                pc_oor_s,
857
                            pc_oor_f;
858
   wire         set_oor_m;
859
   wire         addr_mask_32b_m;
860
 
861
   wire         priv_mode_s1,
862
                priv_mode_f,
863
                hpriv_mode_s1,
864
                hpriv_mode_w,
865
                hpriv_mode_w2,
866
                hpriv_mode_f;
867
 
868
   wire         inst_acc_exc_s1,
869
                            inst_acc_exc_d,
870
                            inst_acc_exc_e;
871
   wire [3:0]   inst_acc_vec_s2,
872
                            inst_acc_vec_d;
873
 
874
   wire         priv_violtn_e,
875
                priv_violtn_m;
876
 
877
   wire         trap_e,
878
                            trap_m;
879
 
880
   wire         ttype_sel_spuma_e,
881
                            ttype_sel_spuenc_e,
882
                            ttype_sel_corr_err_e,
883
                            ttype_sel_unc_err_e,
884
                            ttype_sel_res_err_e,
885
                            ttype_sel_hstk_cmp_e,
886
                            ttype_sel_pcoor_e,
887
                            ttype_sel_immu_miss_e,
888
                            ttype_sel_real_trans_e,
889
                            ttype_sel_icache_err_e,
890
                            ttype_sel_priv_viol_e,
891
                            ttype_sel_privop_e,
892
                            ttype_sel_illinst_e,
893
                            ttype_sel_ibe_e,
894
                            ttype_sel_sir_e,
895
                            ttype_sel_fpdis_e;
896
 
897
   wire [8:0]   ttype_e;
898
 
899
   wire [3:0]   next_nir_privvec,
900
                            nir_privvec;
901
   wire         nir_priv_s1,
902
                            priv_inst_s1;
903
 
904
   wire         tlzero_s2;
905
   wire [3:0]   tlzero_vec_d1;
906
 
907
   wire         nuke_thr_w,
908
                resum_thr_w,
909
                rst_thr_w;
910
 
911
   wire [3:0]   spu_thr;
912
//   wire [3:0]   rst_thr_bf;
913
 
914
   wire [3:0]   async_rst_i3,
915
                async_rst_i4,
916
                            next_rst_i2,
917
                            rstint_i2,
918
                            rstint_i3,
919
                            resumint_i2,
920
                            resumint_i3,
921
                next_resum_i2,
922
                            nuke_thr_i2,
923
                            next_nuke_i2,
924
                            nuke_thr_i3,
925
                            next_sftint_i2,
926
                next_hintp_i2,
927
                next_rerr_i2,
928
                            next_hwint_i3,
929
                            sftint_i3,
930
                hintp_i3,
931
                rerr_i3,
932
                            hwint_i4,
933
                            next_ceint_i2,
934
                            ceint_i3,
935
                            next_ueint_i2,
936
                            ueint_i3,
937
                            next_spuint0_i2,
938
                            spuint0_i3,
939
                            next_spuint1_i2,
940
                            spuint1_i3;
941
 
942
   wire [3:0]   intr_in_pipe;
943
 
944
   wire [3:0]   hypv_int_en,
945
                hypv_int_en_d1;
946
   wire [3:0]   supv_int_en,
947
                supv_int_en_d1;
948
 
949
   wire [3:0]   ifet_ue_vec_d1,
950
                            ifet_ue_vec_e;
951
   wire         ifet_ue_e;
952
 
953
   wire [3:0]   any_intr_vec_f,
954
                any_intr_vec_s,
955
                intr_pending_nxt,
956
                intr_pending_s,
957
                supv_masked_intr_s,
958
                hypv_masked_intr_s;
959
 
960
   wire         spuint0_m,
961
                spuint0_trap_m,
962
//                spuint0_qual_m,
963
                            spuint0_e,
964
                            spuint0_qual_e,
965
                spuint0_w,
966
                spuint0_trap_w,
967
                            spuint1_m,
968
                spuint1_trap_m,
969
//                spuint1_qual_m,
970
                            spuint1_e,
971
                            spuint1_qual_e,
972
                spuint1_w,
973
                spuint1_trap_w,
974
                hwint_m,
975
                hwint_e,
976
                rstint_m,
977
//                rstint_qual_m,
978
                resumint_m,
979
                resumint_qual_m,
980
                sftint_m,
981
                sftint_e,
982
                sftint_qual_e,
983
                hintp_e,
984
                hintp_qual_e,
985
                hintp_m,
986
                rerr_e,
987
                rerr_qual_e,
988
                rerr_m,
989
                nuke_thr_m,
990
                nuke_thr_qual_m,
991
                            ceint_m,
992
                ceint_trap_m,
993
                ceint_trap_w,
994
//                ceint_qual_m,
995
                ceint_qual_w,
996
                            ceint_e,
997
                            ceint_qual_e,
998
                            ueint_m,
999
                ueint_trap_m,
1000
                ueint_trap_w,
1001
//                ueint_qual_m,
1002
                ueint_qual_w,
1003
                ueint_qual_e,
1004
                            ueint_e;
1005
 
1006
   wire         disr_trap_m,
1007
                rb_intr_m,
1008
                rb_intr_w,
1009
                any_intr_m;
1010
 
1011
   wire         force_intr_s;
1012
   wire         intr_vld_s,
1013
                            intr_vld_d,
1014
                            intr_vld_e,
1015
                            intr_vld_m,
1016
                            intr_vld_w,
1017
                intr_vld_qual_s,
1018
                            intr_vld_qual_d,
1019
                            intr_vld_qual_e,
1020
                            intr_vld_qual_m;
1021
 
1022
   wire         kill_intr_f,
1023
                            kill_intr_d,
1024
                            kill_intr_e;
1025
 
1026
//       wire         kill_intr_m;
1027
 
1028
   wire         rst_stallreq,
1029
                rst_stallreq_l,
1030
                all_stallreq,
1031
                rst_itlb_stv_l,
1032
                arst_vld_f,
1033
                arst_vld_f_l,
1034
                arst_vld_s,
1035
                arst_vld_s_l,
1036
                async_intr_vld_s,
1037
                itlb_starv_alert,
1038
                rst_sw_bf,
1039
                rst_sw_bf_l,
1040
                sw_for_real_rst_bf,
1041
                rst_stallreq_d0,
1042
                            rst_stallreq_d1,
1043
                            rst_stallreq_d2;
1044
 
1045
   wire         lsu_stallreq_d1,
1046
                ffu_stallreq_d1;
1047
 
1048
   wire [3:0]   rstint_penc;
1049
 
1050
   wire         usep_bf,
1051
                set_usen_bf,
1052
                usen_iso_bf,
1053
                            usen_bf;
1054
   wire         va2_f;
1055
   wire         ntpc_thisthr;
1056
 
1057
   wire [3:0]   thr_usen_nxt,
1058
                            thr_usen_bf;
1059
 
1060
   wire         brto_nxtthr_bf_l,  // intermediate signal for icadr sel
1061
//                brto_nxtthr_bf,
1062
//                thr_match_ne_norst,
1063
                sw_match_ne_norst,
1064
                brtaken_buf_e,
1065
                brtaken_unq_e,
1066
                brtaken_e,
1067
                brtaken_m;
1068
 
1069
   wire         switch_bf,   // switch in next cycle unless stall
1070
                switch_qual_bf,
1071
                            switch_s2;  // switch in this cycle
1072
 
1073
   wire         rstt,       // set thr_f to the reset pkt thread
1074
                            swt,        // switch to nextthr_bf
1075
                            samet;      // don't change thread
1076
 
1077
   wire [3:0]   thr_f_crit,
1078
                thr_f_dec,
1079
                thr_f_flop;
1080
 
1081
   wire [3:0]   thr_f,      // = thr_s2
1082
                            thr_bf,
1083
                            thr_s1,     // = thr_d
1084
                            thr_s1_next,
1085
                dec_thr_s1_l,
1086
                            thr_d,
1087
                            thr_e,
1088
                            thr_m,
1089
                            thr_w2,
1090
                            thr_w;
1091
 
1092
   wire         tm_fd_l;
1093
 
1094
   wire         thr_match_fw,
1095
                            thr_match_fw2,
1096
                            thr_match_dw,
1097
                            thr_match_dw2,
1098
                            thr_match_em,
1099
                            thr_match_ew,
1100
                            thr_match_ew2,
1101
                            same_thr_mw2,
1102
                            thr_match_mw,
1103
                            thr_match_fm,
1104
                            thr_match_de,
1105
                            thr_match_dm,
1106
                            thr_match_fe,
1107
                            thr_match_fd,
1108
                            thr_match_fs1,
1109
                            thr_match_nw,
1110
                            thr_match_nd,
1111
                            thr_match_ne;
1112
//                          thr_match_ft;
1113
 
1114
   wire         rb2_inst_d,
1115
                            rb2_inst_e,
1116
                            rb1_inst_s,
1117
                            rb1_inst_d,
1118
                            rb0_inst_bf,
1119
                            rb0_inst_s,
1120
                            rt2_inst_e,
1121
                            rt1_inst_s,
1122
                            rt1_inst_d,
1123
                            rt0_inst_bf,
1124
                            rt0_inst_s;
1125
 
1126
   wire [3:0]   rb_w2,
1127
                rb_for_iferr_e,
1128
                            rb_froms,
1129
                            rb_frome,
1130
                            rb_fromd;
1131
 
1132
   wire         rb_stg_s,
1133
                            rb_stg_d,
1134
                rb_stg_d_crit,
1135
                            rb_stg_e;
1136
 
1137
   wire         icadr_selbr_l,
1138
//                          icadr_selsw,
1139
//                icadr_selbr,
1140
                icadr_selsw_l;
1141
 
1142
   wire         sw_or_async_stall;
1143
 
1144
   wire [3:0]   trap_thr;
1145
 
1146
   wire [3:0]   load_tpc,     // thread pc reg input select
1147
                            load_bpc,     // these should be exclusive in normal mode
1148
                            load_pcp4;    // but not during scan shift or reset
1149
 
1150
   wire         irf_ce_w,
1151
                            irf_ce_m,
1152
                any_ce_w,
1153
                            rb_stg_w;
1154
 
1155
   wire [3:0]   ce_cnt0,
1156
                ce_cnt0_nxt,
1157
                ce_cnt1,
1158
                ce_cnt1_nxt,
1159
                ce_cnt_rst;
1160
 
1161
   wire         ce_val0_d,
1162
                ce_val1_d,
1163
                disable_ce_e,
1164
                disable_ce_d;
1165
 
1166
   wire [3:0]   ntpc_vld,     // use thr_nextpc_f
1167
                            ntpc_vld_nxt;
1168
 
1169
   wire [1:0]   sas_thrid_w;
1170
 
1171
   wire         rdsr_sel_pc_e,
1172
                                    rdsr_sel_thr_e;
1173
 
1174
   wire [1:0]   trap_tid_w2;
1175
   wire         trappc_vld_w2,
1176
                trapnpc_vld_w2;
1177
 
1178
   wire         fcl_reset,
1179
                fcl_reset_l;
1180
 
1181
   // some monitor is looking for this signal
1182
//   wire         fcl_swl_flush_wait_w=1'b0;
1183
   wire         clk;
1184
 
1185
   wire [3:0]   nextthr_bf_buf,
1186
                nextthr_final_bf;
1187
 
1188
 
1189
//
1190
// Code start here 
1191
//
1192
   assign       clk = rclk;
1193
 
1194
//----------------------------------------------------------------------
1195
// Fetch Unit Controls
1196
//----------------------------------------------------------------------
1197
 
1198
   // reset buffer
1199
   dffrl_async rstff(.din (grst_l),
1200
                     .q   (fcl_reset_l),
1201
                     .clk (clk), .se(se), .si(), .so(),
1202
                     .rst_l (arst_l));
1203
 
1204
   assign   fcl_reset = ~fcl_reset_l;
1205
   assign   ifu_reset_l = fcl_reset_l;
1206
 
1207
 
1208
//-----------------------------------
1209
// TLB Operations
1210
//-----------------------------------
1211
 
1212
   dff #(4) real_reg(.din (lsu_ifu_addr_real_l),
1213
                     .q   (itlb_addr_real_l),
1214
                     .clk (clk), .se(se), .si(), .so());
1215
   assign   itlb_addr_real = ~itlb_addr_real_l;
1216
 
1217
   // ITLB on signal
1218
 
1219
//`ifdef SPARC_HPV_EN   
1220
   assign   xlate_en = (~tlu_hpstate_enb & lsu_ifu_addr_real_l |
1221
                        tlu_hpstate_enb & ~tlu_hpstate_priv) &
1222
                         ~tlu_lsu_redmode;
1223
 
1224
//`else
1225
//   assign   xlate_en = lsu_ifu_addr_real_l;
1226
//`endif
1227
 
1228
   dff #(4) xlate_reg(.din (xlate_en),
1229
                      .q   (xlate_en_d1),
1230
                      .clk (clk), .se(se), .si(), .so());
1231
 
1232
//   assign sw_itlb_on = ((nextthr_bf_buf & xlate_en_d1) == 4'b0) ?
1233
//                                   1'b0 : 1'b1;
1234
//   assign this_itlb_on = ((thr_f & xlate_en_d1) == 4'b0) ?
1235
//                                           1'b0 : 1'b1;
1236
//   assign itlb_on = switch_bf ? sw_itlb_on : this_itlb_on;
1237
   assign itlb_on = (nextthr_final_bf[0] & xlate_en_d1[0] |
1238
                     nextthr_final_bf[1] & xlate_en_d1[1] |
1239
                     nextthr_final_bf[2] & xlate_en_d1[2] |
1240
                     nextthr_final_bf[3] & xlate_en_d1[3]);
1241
 
1242
 
1243
   // flop xlate_en (done) addr_real and icache_en if timing is 
1244
   // not cutting it
1245
 
1246
   // Hypervisor signals
1247
   assign sw_itlb_real = ((nextthr_bf_buf & itlb_addr_real) == 4'b0) ?
1248
                                     1'b0 : 1'b1;
1249
   assign this_itlb_real = ((thr_f & itlb_addr_real) == 4'b0) ?
1250
                                             1'b0 : 1'b1;
1251
 
1252
//   assign fcl_itlb_cam_real_bf = switch_bf ? sw_itlb_real : this_itlb_real;
1253
 
1254
   mux3ds  creal_mx(.dout (fcl_itlb_cam_real_bf),
1255
                    .in0  (sw_itlb_real),
1256
                    .in1  (this_itlb_real),
1257
                    .in2  (tlu_fcl_dmp_real_bf),
1258
                    .sel0 (pid_sel_sw),
1259
                    .sel1 (pid_sel_curr),
1260
                    .sel2 (pid_sel_dmp));
1261
 
1262
   // Partition ID
1263
   mux4ds #(3) swpid_mux (.dout (sw_pid_bf[2:0]),
1264
                          .in0  (lsu_pid_state0[2:0]),
1265
                          .in1  (lsu_pid_state1[2:0]),
1266
                          .in2  (lsu_pid_state2[2:0]),
1267
                          .in3  (lsu_pid_state3[2:0]),
1268
                          .sel0 (nextthr_bf_buf[0]),
1269
                          .sel1 (nextthr_bf_buf[1]),
1270
                          .sel2 (nextthr_bf_buf[2]),
1271
                          .sel3 (nextthr_bf_buf[3]));
1272
 
1273
   mux4ds #(3) currpid_mux (.dout (curr_pid_bf[2:0]),
1274
                            .in0  (lsu_pid_state0[2:0]),
1275
                            .in1  (lsu_pid_state1[2:0]),
1276
                            .in2  (lsu_pid_state2[2:0]),
1277
                            .in3  (lsu_pid_state3[2:0]),
1278
                            .sel0 (thr_f[0]),
1279
                            .sel1 (thr_f[1]),
1280
                            .sel2 (thr_f[2]),
1281
                            .sel3 (thr_f[3]));
1282
 
1283
//   assign fcl_itlb_cam_pid_bf[2:0] = switch_bf ?  
1284
//                                       sw_pid_bf[2:0] : 
1285
//                                       curr_pid_bf[2:0];
1286
 
1287
//   assign pid_sel_dmp = tlu_itlb_dmp_actxt_g & ctxt_sel_dmp;
1288
   assign pid_sel_dmp = ctxt_sel_dmp;
1289
   assign pid_sel_curr = ~pid_sel_dmp & ~switch_bf;
1290
   assign pid_sel_sw = ~pid_sel_dmp & switch_bf;
1291
   mux3ds #(3) ipid_mx(.dout (fcl_itlb_cam_pid_bf[2:0]),
1292
                       .in0  (sw_pid_bf[2:0]),
1293
                       .in1  (curr_pid_bf[2:0]),
1294
                       .in2  (tlu_fcl_dmp_pid_bf[2:0]),
1295
                       .sel0 (pid_sel_sw),
1296
                       .sel1 (pid_sel_curr),
1297
                       .sel2 (pid_sel_dmp));
1298
 
1299
   // ITLB address mask
1300
   dff #(4) am_reg(.din (tlu_lsu_pstate_am),
1301
                   .q   (pstate_am_d1),
1302
                   .clk (clk), .se(se), .si(), .so());
1303
 
1304
   assign sw_itlb_am = ((nextthr_bf_buf & pstate_am_d1) == 4'b0) ?
1305
                                     1'b0 : 1'b1;
1306
   assign fcl_itlb_addr_mask_l = switch_bf ?
1307
                                 ~sw_itlb_am : ~fcl_fdp_mask32b_f;
1308
 
1309
   dff #(4) tlz_reg(.din ({lsu_ifu_t3_tlz,
1310
                           lsu_ifu_t2_tlz,
1311
                           lsu_ifu_t1_tlz,
1312
                           lsu_ifu_t0_tlz}),
1313
                    .q   (tlzero_vec_d1[3:0]),
1314
                    .clk (clk), .se (se), .si(), .so());
1315
 
1316
 
1317
   // TLB context select
1318
   assign fcl_fdp_tctxt_sel_prim = tlzero_vec_d1 & itlb_addr_real_l;
1319
//   assign fcl_fdp_tctxt_sel_prim[1] = lsu_ifu_t1_tlz & itlb_addr_real_l[1];
1320
//   assign fcl_fdp_tctxt_sel_prim[2] = lsu_ifu_t2_tlz & itlb_addr_real_l[2];
1321
//   assign fcl_fdp_tctxt_sel_prim[3] = lsu_ifu_t3_tlz & itlb_addr_real_l[3];
1322
 
1323
 
1324
   // Access to TLB
1325
   // ITLB may be accessed even when icache is off
1326
   assign cam_vld_bf = itlb_on & inst_access_bf;
1327
 
1328
   assign fcl_itlb_cam_vld_bf = cam_vld_bf;
1329
   assign fcl_itlb_cam_bypass_bf = ~cam_vld_bf;
1330
 
1331
   dff #(1) itlb_onf_ff(.din (cam_vld_bf),
1332
                                    .q   (cam_vld_f),
1333
                                    .clk (clk),
1334
                                    .se  (se), .si(), .so());
1335
 
1336
   dff #(1) itlb_ons1_ff(.din (cam_vld_f),
1337
                                     .q   (cam_vld_s1),
1338
                                     .clk (clk),
1339
                                     .se  (se), .si(), .so());
1340
 
1341
   // allow rd/wr/demap access to tlb
1342
   // itlb access is granted only every other cycle
1343
   // (not enough time to turn the request from mmu around)
1344
//   assign itlb_access_en = ~cam_vld_bf & ~ifq_fcl_asird_bf & 
1345
//                           ~itlb_access_done;
1346
//
1347
//   assign itlb_write_en = ~cam_vld_bf & ~ifq_fcl_asird_bf & 
1348
//                           ~itlb_write_done & 
1349
//                           (~tlu_itlb_dmp_vld_g | itlb_access_done);
1350
 
1351
// Save some timing   
1352
//   assign itlb_write_en = (~itlb_on | no_instacc_bf) & ~ifq_fcl_asird_bf &
1353
//                          ~itlb_write_done & 
1354
//                          (~tlu_itlb_dmp_vld_g | itlb_access_done);
1355
 
1356
   assign itlb_write_en = no_instacc_bf & ~ifq_fcl_asird_bf &
1357
                          ~itlb_write_done &
1358
                          (~tlu_itlb_dmp_vld_g | itlb_access_done);
1359
   assign itlb_access_en = no_instacc_bf & ~ifq_fcl_asird_bf &
1360
                           ~itlb_access_done;
1361
 
1362
   // reset tlb
1363
//   dff #(1) itlbrst_ff(.din (tlu_itlb_invalidate_all_g),
1364
//                                 .q   (tlb_invall_req_bf),
1365
//                                 .clk (clk), .se(se), .si(), .so());
1366
//   assign tlb_invall_bf = tlb_invall_req_bf & ~itlb_access_done;
1367
   assign tlb_invall_bf = sehold ? tlb_invall_f :
1368
                           (tlu_itlb_invalidate_all_g & itlb_access_en);
1369
   dff #(1) itlbrstf_ff(.din (tlb_invall_bf),
1370
                                    .q   (tlb_invall_f),
1371
                                    .clk (clk), .se(se), .si(), .so());
1372
 
1373
   assign fcl_itlb_wr_vld_bf = tlu_itlb_wr_vld_g & itlb_write_en;
1374
   assign fcl_itlb_dmp_vld_bf = tlu_itlb_dmp_vld_g & itlb_access_en;
1375
   assign fcl_itlb_dmp_all_bf = tlu_itlb_dmp_all_g & tlu_itlb_dmp_vld_g &
1376
                                itlb_access_en;
1377
 
1378
//   assign fcl_itlb_invall_bf = tlb_invall_bf & itlb_access_en | fcl_reset;
1379
   assign fcl_itlb_invall_f_l = ~tlb_invall_f;
1380
 
1381
   assign fcl_itlb_data_rd_vld_bf = tlu_itlb_data_rd_g & itlb_access_en &
1382
                                          ~itlb_rd_access_done_d2 &
1383
                                    ~itlb_rd_access_done_d1;
1384
 
1385
   assign fcl_itlb_tag_rd_vld_bf = tlu_itlb_tag_rd_g & itlb_access_en &
1386
                                         ~itlb_rd_access_done_d2 &
1387
                                   ~itlb_rd_access_done_d1;
1388
 
1389
   assign rst_itlb_stv_l = ((tlu_itlb_invalidate_all_g |
1390
                             tlu_itlb_dmp_vld_g |
1391
                             tlu_itlb_data_rd_g |
1392
                             tlu_itlb_tag_rd_g) & ~itlb_access_done |
1393
                            tlu_itlb_wr_vld_g & ~itlb_write_done) &
1394
                             ~fcl_reset;
1395
 
1396
   sparc_ifu_ctr5 starv_ctr(
1397
                                              // Outputs
1398
                                              .limit    (itlb_starv_alert),
1399
                                              .so       (so),
1400
                                              // Inputs
1401
                                              .clk      (clk),
1402
                                              .se       (se),
1403
                                              .si       (si),
1404
                                              .rst_ctr_l (rst_itlb_stv_l));
1405
 
1406
   assign itlb_rd_req_bf = fcl_itlb_data_rd_vld_bf | fcl_itlb_tag_rd_vld_bf;
1407
 
1408
   // tlb access request
1409
   assign itlb_access_gnt = (fcl_itlb_data_rd_vld_bf |
1410
                                               fcl_itlb_tag_rd_vld_bf  |
1411
//                             tlb_invall_bf & itlb_access_en |
1412
                             tlb_invall_bf |
1413
                             fcl_itlb_dmp_vld_bf);
1414
 
1415
   dff #(1) tlb_gnt1_ff(.din (itlb_access_gnt),
1416
                                  .q   (itlb_access_done),
1417
                                  .clk (clk), .se  (se), .si(), .so());
1418
 
1419
   dff #(1) tlb_rd_ff(.din (itlb_rd_req_bf),
1420
                                .q   (itlb_rd_req_f),
1421
                                .clk (clk), .se  (se), .si(), .so());
1422
 
1423
   dff #(1) tlb_wrt1_ff(.din (fcl_itlb_wr_vld_bf),
1424
                                    .q   (itlb_write_done),
1425
                                    .clk (clk), .se  (se), .si(), .so());
1426
 
1427
 
1428
   // TBD:
1429
   // reads need to wait one more cycle.  Others can ack without this
1430
   // second delay.
1431
   assign itlb_rd_access_done = itlb_rd_req_f & itlb_access_done;
1432
 
1433
   dff #(1) tlb_rd1_ff(.din (itlb_rd_access_done),
1434
                                  .q   (itlb_rd_access_done_d1),
1435
                                  .clk (clk), .se  (se), .si(), .so());
1436
   dff #(1) tlb_rd2_ff(.din (itlb_rd_access_done_d1),
1437
                                   .q   (itlb_rd_access_done_d2),
1438
                                  .clk (clk), .se  (se), .si(), .so());
1439
   assign ifu_tlu_itlb_done = ~itlb_rd_req_f & itlb_access_done |
1440
                               itlb_write_done |
1441
                                     itlb_rd_access_done_d2;
1442
 
1443
   assign fcl_erb_itlbrd_vld_s = itlb_rd_access_done_d1;
1444
 
1445
   assign asi_tid_bf = ifq_fcl_asird_bf ? ifq_fcl_asi_tid_bf :
1446
                                                tlu_idtlb_dmp_thrid_g;
1447
 
1448
   dff #(2) asi_tid_reg(.din (asi_tid_bf),
1449
                                  .q   (fcl_erb_asi_tid_f),
1450
                                  .clk (clk), .se(se), .si(), .so());
1451
 
1452
 
1453
   // Remember if we read tag or data
1454
   dff #(1) tlb_rddf_ff(.din (fcl_itlb_data_rd_vld_bf),
1455
                                  .q   (itlb_data_rd_f),
1456
                                  .clk (clk), .se  (se), .si(), .so());
1457
 
1458
   dff #(1) tlb_rdds_ff(.din (itlb_data_rd_f),
1459
                                  .q   (itlb_data_rd_s),
1460
                                  .clk (clk), .se  (se), .si(), .so());
1461
 
1462
   // pick itlb ldxa data
1463
   assign fcl_erb_itlbrd_data_s =  itlb_data_rd_s;
1464
 
1465
   // Demap thread
1466
   assign fcl_fdp_dmpthr_l[0] = ~(~tlu_idtlb_dmp_thrid_g[1] & ~tlu_idtlb_dmp_thrid_g[0]);
1467
   assign fcl_fdp_dmpthr_l[1] = ~(~tlu_idtlb_dmp_thrid_g[1] & tlu_idtlb_dmp_thrid_g[0]);
1468
   assign fcl_fdp_dmpthr_l[2] = ~(tlu_idtlb_dmp_thrid_g[1] & ~tlu_idtlb_dmp_thrid_g[0]);
1469
   assign fcl_fdp_dmpthr_l[3] = ~(tlu_idtlb_dmp_thrid_g[1] & tlu_idtlb_dmp_thrid_g[0]);
1470
 
1471
   // Select appropriate context for TLB
1472
   // ctxt_sel_dmp is itlb_access_en without the asird signal
1473
   assign ctxt_sel_dmp = no_instacc_bf & ~itlb_access_done;
1474
   assign fcl_fdp_ctxt_sel_dmp_bf_l = ~ctxt_sel_dmp;
1475
   assign fcl_fdp_ctxt_sel_sw_bf_l = ctxt_sel_dmp | ~switch_bf;
1476
   assign fcl_fdp_ctxt_sel_curr_bf_l = ctxt_sel_dmp | switch_bf;
1477
 
1478
 
1479
//--------------------------
1480
// Fetch Request and Stall
1481
//--------------------------
1482
 
1483
   // Determine if we need can continue fetching next cycle
1484
//   assign fetch_bf = (~all_stallreq & ~fcl_reset & ~rst_stallreq) &
1485
//                   (switch_bf |
1486
//                    ~(part_stall_thisthr_f | fdp_fcl_swc_s2));
1487
//                    ~(stall_thisthr_f | fdp_fcl_swc_s2 | immu_fault_f));
1488
 
1489
   assign fetch_bf = (~all_stallreq & ~fcl_reset & ~rst_stallreq) &
1490
                       (switch_bf |  // replace with ntr_s?
1491
                        ~(part_stall_thisthr_f
1492
                          | fdp_fcl_swc_s2
1493
                          )
1494
                        );
1495
 
1496
   // dtu_fcl_running_s should be a part of this eqn, since it is assumed
1497
   // by the ifill completion prediction logic in the swl
1498
//   assign inst_access_bf = (~all_stallreq & ~fcl_reset & ~rst_stallreq & 
1499
//                            (switch_bf & ~usen_iso_bf |
1500
//                             ~switch_bf & ~ely_stall_thisthr_f &
1501
//                             dtu_fcl_running_s & 
1502
//                             ~ely_kill_thread_s2 &
1503
//                             //~fdp_fcl_swc_s2 & // take out for tim reasons
1504
//                             ~usep_bf));
1505
 
1506
   assign ia0_bf = (~all_stallreq & ~fcl_reset & ~rst_stallreq &
1507
                    (switch_bf |
1508
                     ~ely_stall_thisthr_f &
1509
                     dtu_fcl_running_s &
1510
                     ~ely_kill_thread_s2 &
1511
                     ~usep_bf));
1512
 
1513
   assign ia1_bf = (~all_stallreq & ~fcl_reset & ~rst_stallreq &
1514
                    (~switch_bf & ~ely_stall_thisthr_f &
1515
                     dtu_fcl_running_s &
1516
                     ~ely_kill_thread_s2 &
1517
                     ~usep_bf));
1518
 
1519
 
1520
   assign inst_access_bf = usen_iso_bf ? ia1_bf : ia0_bf;
1521
   // needs to work even if usen_iso_bf is X - not nec. 11/06/03
1522
//   dp_mux2es #(1) ia_mx(.dout (inst_access_bf),
1523
//                        .in0  (ia0_bf),
1524
//                        .in1  (ia1_bf),
1525
//                        .sel  (usen_iso_bf));
1526
 
1527
 
1528
 
1529
//   assign allow_ifq_access_icd_bf = (all_stallreq | rs
1530
//                                     ~switch_bf & 
1531
//                                     (usep_bf | stall_f) |
1532
//                                     switch_bf & usen_bf);
1533
   assign allow_ifq_access_icd_bf = ~inst_access_bf;
1534
 
1535
   // earlier version for critical stuff
1536
   assign no_instacc_bf = all_stallreq | fcl_reset | rst_stallreq |
1537
                          ~dtu_fcl_ntr_s & (ely_stall_thisthr_f | usep_bf);
1538
 
1539
   // check if icache is on
1540
   dff #(4) ic_en_reg(.din (lsu_ifu_icache_en),
1541
                      .q   (icache_en_d1),
1542
                      .clk (clk), .se(se), .si(), .so());
1543
 
1544
//   assign sw_icache_on = (nextthr_bf_buf[0] & icache_en_d1[0] |
1545
//                          nextthr_bf_buf[1] & icache_en_d1[1] |
1546
//                          nextthr_bf_buf[2] & icache_en_d1[2] |
1547
//                          nextthr_bf_buf[3] & icache_en_d1[3]);
1548
//   assign this_icache_on = (thr_f[0] & icache_en_d1[0] |
1549
//                            thr_f[1] & icache_en_d1[1] |
1550
//                            thr_f[2] & icache_en_d1[2] |
1551
//                            thr_f[3] & icache_en_d1[3]);
1552
//   assign icache_on_bf = switch_bf ? sw_icache_on : this_icache_on;
1553
 
1554
   assign icache_on_bf = (nextthr_final_bf[0] & icache_en_d1[0] |
1555
                          nextthr_final_bf[1] & icache_en_d1[1] |
1556
                          nextthr_final_bf[2] & icache_en_d1[2] |
1557
                          nextthr_final_bf[3] & icache_en_d1[3]);
1558
 
1559
   // remember if icache was turned on
1560
   dff #(1) icef_ff(.din (icache_on_bf),
1561
                              .q   (icache_on_f),
1562
                              .clk (clk), .se(se), .si(), .so());
1563
   dff #(1) ices_ff(.din (icache_on_f),
1564
                              .q   (icache_on_s1),
1565
                              .clk (clk), .se(se), .si(), .so());
1566
 
1567
   // check if cp is set
1568
   assign uncached_page_s1 = ~itlb_fcl_cp_s1 & cam_vld_s1;
1569
   assign fcl_ifq_icache_en_s_l = ~icache_on_s1 | uncached_page_s1;
1570
 
1571
   // Read from the icache only if 
1572
   //   we need to fetch AND 
1573
   //   the icache is on AND 
1574
   //   we are not using the NIR 
1575
   assign rdreq_bf = icache_on_bf & inst_access_bf;
1576
 
1577
   assign fcl_icd_rdreq_bf = rdreq_bf | ifq_fcl_rdreq_bf;
1578
 
1579
   // split off driver to icv to reduce load
1580
   assign fcl_icv_rdreq_bf = rdreq_bf | ifq_fcl_rdreq_bf;
1581
 
1582
   // Read req pipe
1583
   dffr #(1)  rdreq_ff(.din  (rdreq_bf),
1584
                                 .clk  (clk),
1585
                                 .rst  (fcl_reset),
1586
                                 .q    (rdreq_f),
1587
                                 .se   (se), .si(), .so());
1588
   // Remember if we fetched in the last cycle
1589
   dff #(1)  rdreqs1_ff (.din  (rdreq_f),
1590
                                   .clk  (clk),
1591
                                   .q    (rdreq_s1),
1592
                                   .se   (se), .si(), .so());
1593
   assign fcl_ifq_rdreq_s1 = ~stall_s1;
1594
 
1595
   // Use NIR pipe
1596
   assign usenir_bf = switch_bf ? usen_bf : usep_bf;
1597
 
1598
   dffr #(1)  unf_ff(.din  (usenir_bf),
1599
                                 .clk  (clk),
1600
                                 .rst  (fcl_reset),
1601
                                 .q    (usenir_f),
1602
                                 .se   (se), .si(), .so());
1603
   // Remember if we fetched in the last cycle
1604
   dff #(1)  uns1_ff (.din  (usenir_f),
1605
                                  .clk  (clk),
1606
                                  .q    (usenir_s1),
1607
                                  .se   (se), .si(), .so());
1608
 
1609
 
1610
   // Write signal to icache if no access from pipe
1611
   assign ic_wrreq_bf = allow_ifq_access_icd_bf & ifq_fcl_wrreq_bf;
1612
 
1613
   assign fcl_icd_wrreq_bf = ic_wrreq_bf | ifq_fcl_icd_wrreq_bf;
1614
   assign fcl_ict_wrreq_bf = ic_wrreq_bf | ifq_fcl_ictv_wrreq_bf;
1615
   assign fcl_icv_wrreq_bf = ic_wrreq_bf | ifq_fcl_ictv_wrreq_bf |
1616
                             ifq_fcl_invreq_bf;
1617
 
1618
   // synopsys translate_off
1619
   always @ (posedge clk)
1620
   begin
1621
            if (fcl_icd_rdreq_bf & fcl_icd_wrreq_bf)
1622
              begin
1623
                 // 0in <fire -message "ERROR: sparc_ifu_fcl: rd and wr req to I$ at the same time"
1624
 
1625
 
1626
 
1627
 
1628
 
1629
                 $display("CACHE_CONTENTION", "ERROR: sparc_ifu_fcl: rd and wr req to I$ at the same time");
1630
 
1631
 
1632
              end
1633
   end
1634
   // synopsys translate_on
1635
 
1636
 
1637
   //-------------------------
1638
   // Valid Instruction Pipe
1639
   //-------------------------
1640
   // F stage
1641
   assign inst_vld_bf = fetch_bf;
1642
   dff #(1) inst_vld_ff(.din (inst_vld_bf),
1643
                                  .clk (clk),
1644
                                  .q   (inst_vld_f),
1645
                                  .se  (se), .si(), .so());
1646
 
1647
   assign stall_f = ~inst_vld_f | kill_curr_f;
1648
   assign stall_thisthr_f = stall_f | imsto_thisthr_s1 | // intrto_thisthr_d |
1649
                                  kill_thread_s2 | rb_stg_s | ~dtu_fcl_running_s |
1650
                            iferrto_thisthr_d1;
1651
 
1652
   assign part_stall_thisthr_f = stall_f |
1653
                                 imsto_thisthr_s1 |
1654
                                 ~dtu_fcl_running_s |
1655
                                 ely_kill_thread_s2 |
1656
                                       rb_stg_s;
1657
 
1658
   assign ely_stall_thisthr_f = stall_f | rb_stg_s;
1659
 
1660
//   assign stall_s1_nxt = stall_thisthr_f | intr_vld_s | tmsto_thisthr_f;
1661
   assign stall_s1_nxt = stall_thisthr_f; //| intr_vld_s;
1662
 
1663
   // S1 stage
1664
   dff #(1) stalld_ff(.din (stall_s1_nxt),
1665
                                  .clk (clk),
1666
                                  .q   (stall_s1),
1667
                                  .se  (se), .si(), .so());
1668
 
1669
   assign inst_vld_s1 = ~stall_s1 & ~ic_miss_s1 & ~kill_curr_d;
1670
   assign val_thr_s1 = thr_s1 & {4{inst_vld_s1}}; // 4b
1671
 
1672
   // S2 stage
1673
   assign val_thr_f = thr_f & {4{~stall_f & ~rb_stg_s & dtu_fcl_running_s}};
1674
 
1675
   // Tag the S stage thr inst register as containing a valid inst or not
1676
   assign tinst_vld_nxt = (ifq_fcl_fill_thr |
1677
                           (rb_w2 & ~rb_for_iferr_e) | // set
1678
                                             val_thr_s1 & ~val_thr_f |
1679
                           //                      val_thr_s1 |
1680
                                             tinst_vld_s & ~val_thr_f) &
1681
                                              ~(clear_s_d1 |
1682
                              {4{erb_dtu_ifeterr_d1 & inst_vld_d1 &
1683
                                 ~rb_stg_e}} & thr_e);   // reset
1684
 
1685
   dffr #(4) tinst_reg(.din  (tinst_vld_nxt),
1686
                                 .clk  (clk),
1687
                                 .rst  (fcl_reset),
1688
                                 .q    (tinst_vld_s),
1689
                                 .se   (se), .si(), .so());
1690
 
1691
   // Does current thread have valid inst in s2
1692
   assign inst_vld_s2 = ((thr_f_crit & tinst_vld_s) == 4'b0000) ?
1693
                                            {1'b0} :  {1'b1};
1694
 
1695
   assign inst_vld_s = ~switch_s2 & inst_vld_s1 |
1696
                              switch_s2 & inst_vld_s2;
1697
   assign inst_vld_s_crit = ~switch_s2 & ~stall_s1 & ~kill_curr_d |
1698
                              switch_s2 & inst_vld_s2;
1699
 
1700
   assign valid_s = inst_vld_s & ~stall_f &  // f and s2 have same thread
1701
                       dtu_fcl_running_s &
1702
                             ~(ely_kill_thread_s2 | rb_stg_s);
1703
 
1704
   assign running_s2 = inst_vld_s & ~stall_thisthr_f;// f and s2 have 
1705
                                                     // same thread
1706
   // D stage
1707
   dff #(1) rund_ff(.din (running_s2),
1708
                              .clk (clk),
1709
                              .q   (inst_vld_d),
1710
                              .se  (se), .si(), .so());
1711
   dff #(1) eivd_ff(.din (running_s2),
1712
                                .clk (clk),
1713
                                .q   (inst_vld_d_crit),
1714
                                .se  (se), .si(), .so());
1715
   assign fcl_erb_inst_issue_d = inst_vld_d & ~intr_vld_d;
1716
   assign running_d = inst_vld_d & ~kill_thread_d & ~rb_stg_d &
1717
                            ~intr_vld_d;
1718
 
1719
   // E stage
1720
   dff #(1) rune_ff(.din (running_d),
1721
                              .clk (clk),
1722
                              .q   (inst_vld_e),
1723
                              .se  (se), .si(), .so());
1724
 
1725
   assign running_e = inst_vld_e & ~dtu_inst_anull_e &
1726
                            ~kill_curr_e & ~rb_stg_e &
1727
                      ~(thr_match_em & ifu_tlu_flush_m);
1728
   assign inst_vld_qual_e = inst_vld_e & ~rb_stg_e;
1729
   assign val_thr_e = thr_e_v2 & {4{inst_vld_qual_e}} & ~late_flush_w2 &
1730
                      ~(thr_w & {4{utrap_flush_w}});
1731
 
1732
 
1733
   // M stage
1734
   dff #(1) runm_ff(.din (running_e),
1735
                              .clk (clk),
1736
                              .q   (inst_vld_m),
1737
                              .se  (se), .si(), .so());
1738
   assign running_m = (inst_vld_m | intr_vld_m) & ~kill_thread_m;
1739
 
1740
   assign ifu_tlu_inst_vld_m = (inst_vld_m | intr_vld_m) & ~kill_curr_m;
1741
   // less critical
1742
   // assign ifu_lsu_inst_vld_m = ifu_tlu_inst_vld_m;
1743
 
1744
   // W stage
1745
   dff #(1) runw_ff(.din (running_m),
1746
                              .q   (inst_vld_w),
1747
                              .clk (clk), .se  (se), .si(), .so());
1748
 
1749
   dff #(1) iw_ff(.din (running_m),
1750
                              .q   (inst_vld_w_crit),
1751
                              .clk (clk), .se  (se), .si(), .so());
1752
 
1753
   // synopsys translate_off
1754
//   wire         sas_m,
1755
//                          inst_done_w_for_sas;
1756
 
1757
//   assign sas_m = inst_vld_m & ~kill_thread_m & 
1758
//                      ~(exu_ifu_ecc_ce_m & inst_vld_m & ~trap_m);
1759
 
1760
//   dff #(1) sasw_ff(.din (sas_m),
1761
//                            .clk (clk),
1762
//                            .q   (inst_done_w_for_sas),
1763
//                            .se  (se), .si(), .so());   
1764
   // synopsys translate_on
1765
 
1766
   // need to kill branch by E stage, so qual with rb_stg_X
1767
   assign fcl_dtu_inst_vld_e = inst_vld_e & ~rb_stg_e & ~kill_curr_e;
1768
   assign fcl_dtu_intr_vld_e = intr_vld_e & ~rb_stg_e & ~kill_curr_e;
1769
   assign fcl_dtu_inst_vld_d = inst_vld_d & ~kill_curr_d &
1770
                                     ~rb_stg_d_crit & ~immu_miss_crit_d;
1771
   assign fcl_dtu_ely_inst_vld_d = inst_vld_d_crit;
1772
   assign ifu_tlu_inst_vld_w = inst_vld_w;
1773
   assign ifu_exu_inst_vld_w = inst_vld_w_crit;
1774
   assign ifu_spu_inst_vld_w = inst_vld_w;
1775
   assign ifu_exu_inst_vld_e = fcl_dtu_inst_vld_e;
1776
 
1777
   assign flush_sonly_qual_e = dtu_fcl_flush_sonly_e & inst_vld_e &
1778
//                               ~dec_fcl_kill4sta_e &
1779
                               ~rb_stg_e & ~dtu_inst_anull_e & ~kill_curr_e;
1780
 
1781
 
1782
   dff #(1) flshm_ff(.din (flush_sonly_qual_e),
1783
                     .q   (flush_sonly_m),
1784
                     .clk (clk),
1785
                     .se  (se), .si(), .so());
1786
 
1787
   dff #(1) imflshm_ff(.din (ifq_fcl_flush_sonly_e),
1788
                       .q   (ims_flush_sonly_m),
1789
                       .clk (clk),
1790
                       .se  (se), .si(), .so());
1791
   // detect collision between two different types of retractions
1792
   assign ims_flush_coll_m = ims_flush_sonly_m & ~canthr_sm &
1793
                             retract_iferr_e;
1794
   dff #(1) imflshw_ff(.din (ims_flush_coll_m),
1795
                       .q   (ims_flush_sonly_w),
1796
                       .clk (clk),
1797
                       .se  (se), .si(), .so());
1798
   assign ims_flush_coll_w = ims_flush_sonly_w & ~canthr_sw;
1799
   assign flush_sonly_qual_m = (ims_flush_sonly_m & ~canthr_sm &
1800
                                ~retract_iferr_e |
1801
                                flush_sonly_m & inst_vld_m & ~kill_local_m &
1802
                                ~kill_curr_m);
1803
   assign flush_sonly_all_m = (ims_flush_sonly_m & ~canthr_sm |
1804
                               flush_sonly_m & inst_vld_m);
1805
 
1806
//   assign flush_sonly_qual_m = flush_sonly_m & ~canthr_sm;
1807
//   assign qtrap_flush_e = dtu_fcl_qtrap_e & inst_vld_e & ~dtu_inst_anull_e & 
1808
//                        ~rb_stg_e;
1809
 
1810
//------------------------------   
1811
// Instruction Kill Logic
1812
//------------------------------
1813
 
1814
   // kill_s2 is the same as kill_f
1815
   assign kill_thread_s2 = thr_match_fw & rb_stg_w |
1816
//                               thr_match_ft & trappc_vld_w2 |
1817
                                 thr_match_fm & (flush_sonly_all_m) |
1818
                           kill_curr_f;
1819
 
1820
   assign ely_kill_thread_s2 = thr_match_fw & utrap_flush_w |
1821
//                                   thr_match_ft & trappc_vld_w2 |
1822
                                     thr_match_fm & (flush_sonly_all_m) |
1823
                               kill_curr_f;
1824
 
1825
   assign kill_thread_d = thr_match_dw & rb_stg_w |
1826
                                thr_match_dm & (flush_sonly_all_m) |
1827
                          kill_curr_d;
1828
 
1829
   // M and E still need full qualification with flush pipe   
1830
//   assign kill_thread_e = thr_match_ew & utrap_flush_w | 
1831
//                          thr_match_ew & tlu_ifu_flush_pipe_w | 
1832
//                          kill_curr_e ;
1833
   assign ely_kill_thread_m = thr_match_mw & utrap_flush_w |
1834
//                              mark4rb_m |
1835
                              kill_curr_m;
1836
   assign kill_thread_m = ely_kill_thread_m |
1837
                          thr_match_mw & tlu_ifu_flush_pipe_w;
1838
 
1839
   assign kill_local_m = thr_match_mw & (utrap_flush_w | intr_vld_w);
1840
 
1841
   assign flush_pipe_w = rb_stg_w | tlu_ifu_flush_pipe_w;
1842
//   assign part_flush_w = ifu_tlu_flush_w | tlu_ifu_flush_pipe_w;
1843
//   assign kill_nextthr_w = thr_match_nw & flush_pipe_w;
1844
   assign flush_thr_w = thr_w & {4{flush_pipe_w}};
1845
   dff #(1) fp_ff(.din (flush_pipe_w),
1846
                  .q   (flush_pipe_w2),
1847
                  .clk (clk), .se(se), .si(), .so());
1848
 
1849
//   assign clear_s_stage =  thr_e & {4{flush_sonly_qual_e}};
1850
//   assign clear_s_stage =  trap_thr & {4{trappc_vld_w2}} |
1851
//                               {4{dummy_flush_ireg}} | 
1852
//                               thr_e & {4{flush_sonly_qual_e}};
1853
                           //  | flush_thr_w 
1854
 
1855
   assign canthr_f = thr_e & {4{flush_sonly_qual_e}} |
1856
                     (rb_w2 & ~rb_for_iferr_e) | rb_froms;
1857
 
1858
//   dff #(4) cls_reg(.din (clear_s_stage),
1859
//                              .q   (clear_s_early),
1860
//                              .clk (clk), .se(se), .si(), .so());
1861
 
1862
   // ***NOTE***
1863
   // Don't use clear_s_d1 to generate fcl_ifq_canthr, since clear_s_d1 
1864
   // includes ifeterr!
1865
   // first term could be just flush_sonly_m & inst_vld_m & thr_m
1866
   assign clear_s_d1 = thr_m & {4{flush_sonly_all_m}} |
1867
                       late_flush_w2 |
1868
                       trap_thr & {4{trappc_vld_w2}};
1869
 
1870
   assign fcl_erb_clear_iferr = thr_m & {4{ims_flush_sonly_m |
1871
                                           flush_sonly_m}} |
1872
                                late_flush_w2 |
1873
                                trap_thr & {4{trappc_vld_w2}};
1874
 
1875
 
1876
   dff #(4) cm_reg(.din (canthr_f),
1877
                               .q   (canthr_s_early),
1878
                               .clk (clk),
1879
                               .se  (se), .si(), .so());
1880
 
1881
   assign canthr_s = canthr_s_early | late_flush_w2 |
1882
                     trap_thr & {4{trappc_vld_w2}};
1883
 
1884
//   assign fcl_ifq_canthr = clear_s_stage | rb_w2 | rb_froms | 
1885
//                               canthr_s;
1886
   assign fcl_ifq_canthr = canthr_s;
1887
 
1888
   assign canthr_sm = (canthr_s[0] & thr_m[0] |
1889
                       canthr_s[1] & thr_m[1] |
1890
                       canthr_s[2] & thr_m[2] |
1891
                       canthr_s[3] & thr_m[3]);
1892
 
1893
   assign canthr_sw = (canthr_s[0] & thr_w[0] |
1894
                       canthr_s[1] & thr_w[1] |
1895
                       canthr_s[2] & thr_w[2] |
1896
                       canthr_s[3] & thr_w[3]);
1897
 
1898
   assign canthr_sd = (canthr_s[0] & thr_d[0] |
1899
                       canthr_s[1] & thr_d[1] |
1900
                       canthr_s[2] & thr_d[2] |
1901
                       canthr_s[3] & thr_d[3]) |
1902
                        thr_match_dw & utrap_flush_w;
1903
 
1904
   dff #(4) fpw2_reg(.din (flush_thr_w),
1905
                     .q   (late_flush_w2),
1906
                     .clk (clk), .se(se), .si(), .so());
1907
 
1908
//   assign late_flush_w2 = thr_w2 & {4{flush_pipe_w2}};
1909
 
1910
   assign kill_curr_f = (thr_f_crit[0] & late_flush_w2[0] |
1911
                         thr_f_crit[1] & late_flush_w2[1] |
1912
                         thr_f_crit[2] & late_flush_w2[2] |
1913
                         thr_f_crit[3] & late_flush_w2[3]);
1914
   assign kill_curr_d = (thr_d[0] & late_flush_w2[0] |
1915
                         thr_d[1] & late_flush_w2[1] |
1916
                         thr_d[2] & late_flush_w2[2] |
1917
                         thr_d[3] & late_flush_w2[3]);
1918
   assign kill_curr_e = (thr_e_v2[0] & late_flush_w2[0] |
1919
                         thr_e_v2[1] & late_flush_w2[1] |
1920
                         thr_e_v2[2] & late_flush_w2[2] |
1921
                         thr_e_v2[3] & late_flush_w2[3]) |
1922
                          thr_match_ew & utrap_flush_w;
1923
 
1924
//   assign kill_curr_m = (thr_m[0] & late_flush_w2[0] |
1925
//                         thr_m[1] & late_flush_w2[1] |
1926
//                         thr_m[2] & late_flush_w2[2] |
1927
//                         thr_m[3] & late_flush_w2[3]);
1928
   assign kill_curr_m = same_thr_mw2 & flush_pipe_w2;
1929
 
1930
   //------------------------------
1931
   // track I$ misses
1932
   //------------------------------
1933
 
1934
   // force a miss if a fetch and icache is off
1935
   // forcemiss triggers a fill vld_grequest to L2, so set to zero by default
1936
   assign forcemiss_f = inst_vld_f & ~icache_on_f;
1937
   dffr #(1)  miss_ff(.din (forcemiss_f),
1938
                                  .clk (clk),
1939
                                  .rst (fcl_reset),
1940
                                  .q   (forcemiss_s1),
1941
                                  .se  (se), .si(), .so());
1942
 
1943
   //ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
1944
   // removed imiss_s_l from this signal for timing fix  
1945
   // Perf Hit: 0.2% TPCC, 0.4% JBB
1946
//   assign ic_miss_sw_s1 = (~itlb_fcl_imiss_s_l & rdreq_s1 |
1947
//                             tlb_cam_miss_s1 | 
1948
//                             forcemiss_s1);
1949
//   assign ic_miss_sw_s1 =   tlb_cam_miss_s1 | 
1950
//                            forcemiss_s1;
1951
   //ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
1952
 
1953
   assign ic_miss_s1 =  (~itlb_fcl_imiss_s_l & rdreq_s1 |
1954
                                           forcemiss_s1) &
1955
                        ~stall_s1 & ~tlbmiss_s1_crit & ~pc_oor_s1 &
1956
                        ~rb_stg_d_crit & ~canthr_sd;
1957
 
1958
   assign icmiss_for_perf =  (~itlb_fcl_imiss_s_l & rdreq_s1) &
1959
                        ~stall_s1 & ~tlbmiss_s1_crit & ~pc_oor_s1 &
1960
                        ~rb_stg_d & ~canthr_sd;
1961
 
1962
//   assign fcl_ifq_icmiss_s1 = ic_miss_s1 & ~ely_kill_thread_d;  // use buffer
1963
   assign fcl_ifq_icmiss_s1 = ic_miss_s1;  // use buffer   
1964
 
1965
   // for perf counters (d1=e)
1966
   dff #(1) icmd1_ff(.din (icmiss_for_perf),
1967
                     .q   (ifu_tlu_icmiss_e),
1968
                     .clk (clk), .se(se), .si(), .so());
1969
 
1970
   // I$ miss is always to thr_s1.  Below we check to see if this is
1971
   // the same as thr_f (=thr_s2) which is the "current thread"
1972
//   assign imsto_thisthr_s1 = thr_match_fd & ic_miss_s1;
1973
//   assign imsto_nextthr_s1 = thr_match_nd & (ic_miss_s1 | tlbmiss_s1);
1974
 
1975
   assign imsto_thisthr_s1 = thr_match_fd & ic_miss_s1;
1976
//   assign imsto_nextthr_s1 = thr_match_nd & (ic_miss_sw_s1);
1977
//   assign intrto_thisthr_d = thr_match_fd & fcl_dtu_sync_intr_d;
1978
 
1979
   assign iferrto_thisthr_d1 = thr_match_fe & erb_dtu_ifeterr_d1 &
1980
                               inst_vld_d1;
1981
 
1982
 
1983
//------------------------------
1984
// track itlb misses
1985
//------------------------------
1986
 
1987
   // default to hit when camming is turned off
1988
   assign tlb_cam_miss_f = ~itlb_fcl_tlbmiss_f_l & cam_vld_f;
1989
   dff #(1) tlbmsf_ff(.din (tlb_cam_miss_f),
1990
                                  .clk (clk),
1991
                                  .q   (tlb_cam_miss_s1),
1992
                                  .se  (se), .si(), .so());
1993
 
1994
   // tlb miss logic
1995
   // va hole has higher priority than immu miss
1996
   assign tlbmiss_s2 = (({4{tlbmiss_s1 & ~pc_oor_s1 & ~rb_stg_d}} & thr_s1) |
1997
                                          ({4{erb_fcl_itlb_ce_d1 & inst_vld_d1 &
1998
                            ~rb_stg_e}} & thr_e &
1999
                                           (~thr_d | {4{~inst_vld_d | ~thr_match_de}})) |
2000
                                          ({4{immu_miss_e}} & rb_frome) |
2001
                                          ({4{immu_miss_d}} & rb_fromd & ~rb_frome) |  // set
2002
                                          tlbmiss_d & (~thr_d | {4{~inst_vld_d}}) & ~rb_w2) &
2003
                                         ~(clear_s_d1); // reset
2004
 
2005
//   assign tlbmiss_s2 = (({4{tlbmiss_s1 & ~pc_oor_s1 & ~rb_stg_d}} & thr_s1) |
2006
//                      ({4{erb_fcl_itlb_ce_d1 & inst_vld_qual_d1}} & thr_e |
2007
//                       tlbmiss_d & (~thr_e | {4{~inst_vld_qual_e}}) & 
2008
//                       ~rb_w2) & ~(clear_s_stage); // reset
2009
 
2010
   dffr #(4) tlbmiss_reg(.din (tlbmiss_s2),
2011
                                     .q   (tlbmiss_d),
2012
                                     .clk (clk),
2013
                                     .rst (fcl_reset),
2014
                                     .se  (se), .si(), .so());
2015
 
2016
   assign immu_fault_f = (thr_f_crit[0] & (tlbmiss_d[0] | inst_acc_vec_d[0]) |
2017
                                            thr_f_crit[1] & (tlbmiss_d[1] | inst_acc_vec_d[1]) |
2018
                                            thr_f_crit[2] & (tlbmiss_d[2] | inst_acc_vec_d[2]) |
2019
                                            thr_f_crit[3] & (tlbmiss_d[3] | inst_acc_vec_d[3])) &
2020
                           switch_s2|
2021
                                             // D stage miss
2022
                                             (tlbmiss_s1 | pc_oor_s1) & thr_match_fs1;
2023
                                 // S stage miss
2024
 
2025
   assign immu_miss_crit_d = (thr_d[0] & tlbmiss_d[0] |
2026
                                                thr_d[1] & tlbmiss_d[1] |
2027
                                                thr_d[2] & tlbmiss_d[2] |
2028
                                                thr_d[3] & tlbmiss_d[3]);
2029
 
2030
   // TBD: move this to the E stage, post RB
2031
   assign immu_miss_d = immu_miss_crit_d & inst_vld_d |
2032
                                          thr_match_de & erb_fcl_itlb_ce_d1 & inst_vld_d1;
2033
 
2034
   // don't need to do this, once everyone switches to immu_miss_m
2035
   assign immu_miss_qual_d = immu_miss_d & ~kill_thread_d &
2036
                                    ~(immu_miss_e & thr_match_de &
2037
                                inst_vld_e & ~dtu_inst_anull_e & ~rb_stg_e &
2038
                                ~kill_curr_e);
2039
 
2040
   dff immu_misse_ff(.din (immu_miss_qual_d),
2041
                                 .clk (clk),
2042
                                 .q   (immu_miss_e),
2043
                                 .se  (se), .si(), .so());
2044
 
2045
 
2046
   // flop this and send in M
2047
//   assign ifu_tlu_immu_miss_e = immu_miss_e & ~addr_real_e & 
2048
//                                inst_vld_e & ~dtu_inst_anull_e & ~rb_stg_e;
2049
//   assign ifu_tlu_immu_miss_e = 1'b0;
2050
 
2051
//   assign immu_miss_qual_e = immu_miss_e & //~addr_real_e & 
2052
// //                             ~(immu_miss_m & thr_match_em) &
2053
//                             inst_vld_e & ~dtu_inst_anull_e & ~rb_stg_e;
2054
 
2055
//   dff #(1) immu_msm_ff(.din (immu_miss_qual_e),
2056
   dff #(1) immu_msm_ff(.din (immu_miss_e),
2057
                        .q   (immu_miss_m),
2058
                        .clk (clk), .se(se), .si(), .so());
2059
 
2060
   assign ifu_tlu_immu_miss_m = immu_miss_m & inst_vld_m & ~kill_curr_m;
2061
 
2062
   assign addr_real_e = (itlb_addr_real[0] & thr_e[0] |
2063
                         itlb_addr_real[1] & thr_e[1] |
2064
                         itlb_addr_real[2] & thr_e[2] |
2065
                         itlb_addr_real[3] & thr_e[3]);
2066
 
2067
   // store tlbmiss state for NIR
2068
   assign nir_tlbmiss_next = ({4{tlb_cam_miss_s1 & ~stall_s1}} & thr_s1 |
2069
                                                nir_tlbmiss_vec & (~thr_s1 | {4{stall_s1}}));
2070
 
2071
   dffr #(4) nirtlbm_reg(.din (nir_tlbmiss_next),
2072
                                   .clk (clk),
2073
                                   .q   (nir_tlbmiss_vec),
2074
                                   .rst (fcl_reset),
2075
                                   .se  (se), .si(), .so());
2076
 
2077
   assign nir_tlbmiss_s1 = (nir_tlbmiss_vec[0] & thr_s1[0] |
2078
                                              nir_tlbmiss_vec[1] & thr_s1[1] |
2079
                                              nir_tlbmiss_vec[2] & thr_s1[2] |
2080
                                              nir_tlbmiss_vec[3] & thr_s1[3]);
2081
 
2082
   assign tlbmiss_s1_crit = ~usenir_s1 ? tlb_cam_miss_s1 :
2083
                                               nir_tlbmiss_s1;
2084
 
2085
   assign tlbmiss_s1 = tlbmiss_s1_crit & ~stall_s1;
2086
 
2087
//---------------------------------
2088
//  Privilege Mode and VA Hole
2089
//---------------------------------
2090
   assign addr_mask_32b_m = (thr_m[0] & pstate_am_d1[0] |
2091
                                               thr_m[1] & pstate_am_d1[1] |
2092
                                               thr_m[2] & pstate_am_d1[2] |
2093
                                               thr_m[3] & pstate_am_d1[3]);
2094
 
2095
   assign fcl_fdp_mask32b_f = (thr_f[0] & pstate_am_d1[0] |
2096
                                                 thr_f[1] & pstate_am_d1[1] |
2097
                                                 thr_f[2] & pstate_am_d1[2] |
2098
                                                 thr_f[3] & pstate_am_d1[3]);
2099
 
2100
   dff #(1) amd_ff(.din (fcl_fdp_mask32b_f),
2101
                               .q   (fcl_fdp_addr_mask_d),
2102
                               .clk (clk), .se(se), .si(), .so());
2103
 
2104
   // keep track of whether pc is outside va hole
2105
   assign set_oor_m = exu_ifu_va_oor_m & brtaken_m & ~addr_mask_32b_m;
2106
   assign fcl_fdp_pcoor_vec_f = fdp_fcl_pc_oor_vec_f | {4{set_oor_m}} & thr_m;
2107
 
2108
   assign fcl_fdp_pcoor_f =  (thr_f[0] & fcl_fdp_pcoor_vec_f[0] |
2109
                                                thr_f[1] & fcl_fdp_pcoor_vec_f[1] |
2110
                                                thr_f[2] & fcl_fdp_pcoor_vec_f[2] |
2111
                                                thr_f[3] & fcl_fdp_pcoor_vec_f[3]);
2112
 
2113
   assign pc_oor_f = fcl_fdp_pcoor_f  & ~part_stall_thisthr_f;
2114
   dff oors1_ff(.din (pc_oor_f),
2115
                            .q   (pc_oor_s1),
2116
                            .clk (clk), .se(se), .si(), .so());
2117
 
2118
   // track privilege mode of current page
2119
   assign priv_mode_f = (thr_f[0] & tlu_lsu_pstate_priv[0] |
2120
                                           thr_f[1] & tlu_lsu_pstate_priv[1] |
2121
                                           thr_f[2] & tlu_lsu_pstate_priv[2] |
2122
                                           thr_f[3] & tlu_lsu_pstate_priv[3]);
2123
 
2124
   dff #(1) priv_ff(.din (priv_mode_f),
2125
                    .q   (priv_mode_s1),
2126
                    .clk (clk), .se(se), .si(), .so());
2127
 
2128
   // s1 and d are the same thread
2129
   assign fcl_dtu_privmode_d = priv_mode_s1;
2130
 
2131
   // hyper privilege
2132
   assign hpriv_mode_f = (thr_f[0] & tlu_hpstate_priv[0] |
2133
                                            thr_f[1] & tlu_hpstate_priv[1] |
2134
                                            thr_f[2] & tlu_hpstate_priv[2] |
2135
                                            thr_f[3] & tlu_hpstate_priv[3]);
2136
 
2137
   assign hpriv_mode_w = (thr_w[0] & tlu_hpstate_priv[0] |
2138
                                            thr_w[1] & tlu_hpstate_priv[1] |
2139
                                            thr_w[2] & tlu_hpstate_priv[2] |
2140
                                            thr_w[3] & tlu_hpstate_priv[3]);
2141
 
2142
   dff #(1) hprivd_ff(.din (hpriv_mode_f),
2143
                     .q   (hpriv_mode_s1),
2144
                     .clk (clk), .se(se), .si(), .so());
2145
 
2146
   assign fcl_dtu_hprivmode_d = hpriv_mode_s1;
2147
 
2148
   dff #(1) hprivw2_ff(.din (hpriv_mode_w),
2149
                     .q   (hpriv_mode_w2),
2150
                     .clk (clk), .se(se), .si(), .so());
2151
   assign fcl_dtu_hprivmode_w2 = hpriv_mode_w2;
2152
 
2153
   // determine if priv page has been accessed in non priv mode
2154
   // or if we have fallen into the VA hole
2155
   assign inst_acc_exc_s1 = (priv_inst_s1 & ~(priv_mode_s1 | hpriv_mode_s1) &
2156
                                               ~tlbmiss_s1_crit & cam_vld_s1 |
2157
                                               pc_oor_s1) & ~stall_s1 & ~rb_stg_d;
2158
   assign pc_oor_s2 = (thr_f[0] & inst_acc_vec_d[0] |
2159
                       thr_f[1] & inst_acc_vec_d[1] |
2160
                       thr_f[2] & inst_acc_vec_d[2] |
2161
                       thr_f[3] & inst_acc_vec_d[3]);
2162
   assign pc_oor_s = (tm_fd_l) ? pc_oor_s2 : pc_oor_s1;
2163
 
2164
   assign inst_acc_vec_s2 = (({4{inst_acc_exc_s1}} & thr_s1) |
2165
                                               ({4{inst_acc_exc_e}} & rb_frome) |
2166
                                               ({4{inst_acc_exc_d}} & rb_fromd & ~rb_frome) |
2167
                                   inst_acc_vec_d & (~thr_d | {4{~inst_vld_d}}) &
2168
                                               ~rb_w2) &
2169
                                                ~(clear_s_d1);
2170
 
2171
   dffr #(4) instaccd_reg(.din (inst_acc_vec_s2),
2172
                                          .q   (inst_acc_vec_d),
2173
                                          .rst (fcl_reset),
2174
                                          .clk (clk), .se (se), .si(), .so());
2175
 
2176
   assign inst_acc_exc_d = (thr_d[0] & inst_acc_vec_d[0] |
2177
                                              thr_d[1] & inst_acc_vec_d[1] |
2178
                                              thr_d[2] & inst_acc_vec_d[2] |
2179
                                              thr_d[3] & inst_acc_vec_d[3]);
2180
 
2181
   dff #(1) instacce_ff(.din (inst_acc_exc_d),
2182
                                  .q   (inst_acc_exc_e),
2183
                                  .clk (clk), .se(se), .si(), .so());
2184
 
2185
   // TLU needs to know if this is a priv violtn
2186
   assign priv_violtn_e = inst_acc_exc_e & ~fdp_fcl_pc_oor_e;
2187
   dff #(1) privm_ff(.din (priv_violtn_e),
2188
                               .q   (priv_violtn_m),
2189
                               .clk (clk),  .se  (se), .si(), .so());
2190
 
2191
   assign ifu_tlu_priv_violtn_m = priv_violtn_m & inst_vld_m & ~kill_curr_m;
2192
 
2193
   // NIR privilege bit
2194
   assign next_nir_privvec = {4{itlb_fcl_priv_s1 & ~stall_s1 &
2195
                                cam_vld_s1}} & thr_s1 |
2196
                                   nir_privvec & (~thr_s1 | {4{stall_s1}});
2197
 
2198
   dffr #(4) nir_priv_reg(.din (next_nir_privvec),
2199
                                          .q   (nir_privvec),
2200
                                          .rst (fcl_reset),
2201
                                          .clk (clk), .se(se), .si(), .so());
2202
 
2203
   assign nir_priv_s1 = (nir_privvec[0] & thr_s1[0] |
2204
                                           nir_privvec[1] & thr_s1[1] |
2205
                                           nir_privvec[2] & thr_s1[2] |
2206
                                           nir_privvec[3] & thr_s1[3]);
2207
 
2208
   assign priv_inst_s1 = ~usenir_s1 ? (itlb_fcl_priv_s1 & cam_vld_s1) :
2209
                                        nir_priv_s1;
2210
 
2211
//-------------------------
2212
// Errors
2213
//-------------------------
2214
 
2215
   // decide when the errors are valid
2216
   assign running_s1 = ~stall_s1 & ~kill_thread_d & ~rb_stg_d & ~pc_oor_s1 &
2217
                             ~tlb_cam_miss_s1 & ~retract_inst_d;
2218
//   assign ely_running_s1 = ~stall_s1 & ~rb_stg_d & ~pc_oor_s1 & 
2219
//                           ~tlb_cam_miss_s1 & ~retract_inst_d & ~kill_curr_d;
2220
   assign ely_running_s1 = ~stall_s1 & ~rb_stg_d_crit & ~pc_oor_s1 &
2221
                           ~tlb_cam_miss_s1 & ~kill_curr_d;
2222
   assign fcl_erb_ievld_s1 = ely_running_s1 & rdreq_s1 & itlb_fcl_imiss_s_l;
2223
   assign fcl_erb_tevld_s1 = ely_running_s1 & rdreq_s1;
2224
 
2225
   assign fcl_erb_immuevld_s1 = ely_running_s1 & cam_vld_s1;
2226
 
2227
//   assign fcl_erb_ttevld_s1 = asird_s & rdtag_s;
2228
//   assign fcl_erb_tdevld_s1 = asird_s & ~rdtag_s;
2229
 
2230
   dff #(1) d1vld_ff(.din (running_s1),
2231
                                 .q   (inst_vld_d1),
2232
                                 .clk (clk), .se(se), .si(), .so());
2233
//   assign inst_vld_qual_d1 = inst_vld_d1 & ~kill_thread_e & 
2234
//                                 ~flush_sonly_qual_e & ~rb_stg_e;
2235
   assign fcl_erb_inst_vld_d1 = inst_vld_d1;
2236
 
2237
 
2238
   // ifetch unc. error
2239
   assign ifet_ue_vec_d1 = (erb_fcl_ifet_uevec_d1 |
2240
                                  ifet_ue_vec_e & ~val_thr_e) &   // reset
2241
                                               ~(clear_s_d1);                 // wins
2242
 
2243
   dffr #(4) ifuerr_reg(.din (ifet_ue_vec_d1),
2244
                                  .q   (ifet_ue_vec_e),
2245
                                  .rst (fcl_reset),
2246
                                  .clk (clk), .se(se), .si(), .so());
2247
 
2248
   assign ifet_ue_e = (ifet_ue_vec_e[0] & thr_e[0] |
2249
                                   ifet_ue_vec_e[1] & thr_e[1] |
2250
                                   ifet_ue_vec_e[2] & thr_e[2] |
2251
                                   ifet_ue_vec_e[3] & thr_e[3]);
2252
 
2253
 
2254
//----------------------
2255
// Other I side traps
2256
//----------------------
2257
   // Determine if we are in Trap Level 0
2258
   assign tlzero_s2 = (thr_f[0] & tlzero_vec_d1[0] |
2259
                                   thr_f[1] & tlzero_vec_d1[1] |
2260
                                   thr_f[2] & tlzero_vec_d1[2] |
2261
                                   thr_f[3] & tlzero_vec_d1[3]);
2262
   dff #(1) tlzd_ff(.din (tlzero_s2),
2263
                              .q   (fcl_dtu_tlzero_d),
2264
                              .clk (clk), .se(se), .si(), .so());
2265
 
2266
   // Collect all IFU traps
2267
   assign trap_e = (immu_miss_e | inst_acc_exc_e | dtu_fcl_illinst_e |
2268
                                dtu_fcl_fpdis_e | dtu_fcl_privop_e | ifet_ue_e |
2269
                                dtu_fcl_imask_hit_e | dtu_fcl_sir_inst_e) &
2270
                     inst_vld_e;
2271
 
2272
   dff trapm_ff(.din (trap_e),
2273
                            .q   (trap_m),
2274
                            .clk (clk),
2275
                            .se  (se), .si(), .so());
2276
 
2277
   assign no_iftrap_m = ~ifu_tlu_ttype_vld_m;
2278
   dff trapw_ff(.din (no_iftrap_m),
2279
                            .q   (no_iftrap_w),
2280
                            .clk (clk),
2281
                            .se  (se), .si(), .so());
2282
 
2283
   // south is very critical
2284
   assign ifu_tlu_ttype_vld_m = (trap_m & inst_vld_m |
2285
                                 disr_trap_m) & ~kill_curr_m & ~kill_local_m;
2286
   // less critical going east
2287
   assign ifu_exu_ttype_vld_m = trap_m & inst_vld_m;
2288
 
2289
   // less critical going southwest
2290
   assign ifu_mmu_trap_m = trap_m;
2291
 
2292
   // less critical going south   
2293
   assign ifu_tlu_trap_m = trap_m;
2294
 
2295
   // trap type priority encode
2296
   // Decreasing priority is
2297
   //   pc out of range           i_acc_exc
2298
   //   immu parity error         i_acc_err
2299
   //   immu miss                 i_acc_mmu_ms
2300
   //   icache/tag parity error   i_acc_err
2301
   //   privilege page            i_acc_exc
2302
   //   privilege opcode          priv_opc
2303
   //   illegal non-fp inst       ill_inst
2304
   //   soft reset                sir
2305
   //   fp disabled               fp_disabled
2306
   //   illegal fp instruction    ill_inst
2307
 
2308
   // Clean this up!!
2309
   assign ttype_sel_spuma_e = spuint1_qual_e;
2310
   assign ttype_sel_spuenc_e = spuint0_qual_e;
2311
   assign ttype_sel_corr_err_e = ceint_qual_e;
2312
   assign ttype_sel_unc_err_e = ueint_qual_e;
2313
   assign ttype_sel_res_err_e = rerr_qual_e;
2314
   assign ttype_sel_hstk_cmp_e = hintp_qual_e;
2315
 
2316
   assign ttype_sel_pcoor_e = fdp_fcl_pc_oor_e & inst_acc_exc_e;
2317
   assign ttype_sel_icache_err_e = ifet_ue_e;
2318
   assign ttype_sel_immu_miss_e = ~fdp_fcl_pc_oor_e & immu_miss_e &
2319
                                  ~addr_real_e;
2320
   assign ttype_sel_real_trans_e = ~fdp_fcl_pc_oor_e & immu_miss_e &
2321
                                   addr_real_e;
2322
   assign ttype_sel_priv_viol_e = ~fdp_fcl_pc_oor_e & ~immu_miss_e &
2323
                                   inst_acc_exc_e;
2324
   assign ttype_sel_ibe_e = ~fdp_fcl_pc_oor_e & ~immu_miss_e &
2325
                                ~inst_acc_exc_e & dtu_fcl_imask_hit_e;
2326
   assign ttype_sel_privop_e = ~fdp_fcl_pc_oor_e & ~immu_miss_e &
2327
                               ~inst_acc_exc_e & dtu_fcl_privop_e;
2328
   assign ttype_sel_illinst_e = ~fdp_fcl_pc_oor_e & ~immu_miss_e &
2329
                                ~inst_acc_exc_e & dtu_fcl_illinst_e;
2330
   assign ttype_sel_sir_e = ~fdp_fcl_pc_oor_e & ~immu_miss_e &
2331
                            ~inst_acc_exc_e & ~dtu_fcl_illinst_e &
2332
                             dtu_fcl_sir_inst_e;
2333
 
2334
   assign ttype_sel_fpdis_e = ~fdp_fcl_pc_oor_e & ~immu_miss_e &
2335
                              ~inst_acc_exc_e & ~dtu_fcl_illinst_e &
2336
                               dtu_fcl_fpdis_e;
2337
 
2338
   // mux in the trap type
2339
   assign ttype_e[8:0] = ttype_sel_unc_err_e    ? 9'h078  :
2340
                   ttype_sel_hstk_cmp_e   ? 9'h05e    :
2341
                         ttype_sel_spuma_e      ? 9'h074     :
2342
                         ttype_sel_spuenc_e     ? 9'h070    :
2343
                         ttype_sel_corr_err_e   ? 9'h063  :
2344
                   ttype_sel_res_err_e    ? 9'h07e :
2345
 
2346
                         ttype_sel_pcoor_e      ? 9'h008  :
2347
                         ttype_sel_immu_miss_e  ? 9'h064   :
2348
                         ttype_sel_real_trans_e ? 9'h03e :
2349
                         ttype_sel_icache_err_e ? 9'h00a  :
2350
                         ttype_sel_priv_viol_e  ? 9'h008  :
2351
                         ttype_sel_ibe_e        ? 9'h076   :
2352
                         ttype_sel_privop_e     ? 9'h011 :
2353
                         ttype_sel_illinst_e    ? 9'h010 :
2354
                         ttype_sel_sir_e        ? 9'h004      :
2355
                         ttype_sel_fpdis_e      ? 9'h020 :
2356
                                                   9'h1ff;
2357
 
2358
   dff #(9) ttype_reg(.din (ttype_e[8:0]),
2359
                                .q   (ifu_tlu_ttype_m[8:0]),
2360
                                .clk (clk), .se(se), .si(), .so());
2361
 
2362
//------------------------------
2363
// Interrupts and Resets
2364
//------------------------------
2365
   // Process resets to see if they are sync or async
2366
   assign intr_in_pipe = ({4{intr_vld_d}} & thr_d |
2367
                          {4{intr_vld_e}} & thr_e |
2368
                          {4{intr_vld_m}} & thr_m |
2369
                          {4{intr_vld_w}} & thr_w);
2370
 
2371
//   assign async_rst_i2 = tlu_ifu_rstthr_i2  & {4{tlu_ifu_rstint_i2}} &
2372
   assign async_rst_i3 = (rstint_i3 | nuke_thr_i3 | resumint_i3) &
2373
                           ~dtu_fcl_thr_active & ~intr_in_pipe;
2374
 
2375
   dff #(4) asyrst4_reg(.din (async_rst_i3),
2376
                        .q   (async_rst_i4),
2377
                        .clk (clk), .se(se), .si(), .so());
2378
 
2379
   // stall pipe before switching in rst thread
2380
   assign rst_stallreq_d0 = (|async_rst_i4[3:0]);
2381
   assign rst_stallreq = rst_stallreq_d0 | rst_stallreq_d1 | rst_stallreq_d2;
2382
 
2383
   dff #(2) stlreq_reg(.din ({lsu_ifu_stallreq,
2384
                              ffu_ifu_stallreq}),
2385
                       .q   ({lsu_stallreq_d1,
2386
                              ffu_stallreq_d1}),
2387
                       .clk (clk), .se(se), .si(), .so());
2388
 
2389
   assign all_stallreq = ifq_fcl_stallreq | wbm_spc_stallreq | lsu_stallreq_d1 |
2390
                         ffu_stallreq_d1 | itlb_starv_alert;
2391
 
2392
   // leave out stall from ifq which goes directly to swl
2393
   assign fcl_dtu_stall_bf = lsu_stallreq_d1 | ffu_stallreq_d1 |
2394
                             itlb_starv_alert | rst_stallreq;
2395
 
2396
   // priority encode rst interrupts
2397
   // this could lead to obvious starvation of thr3, the assumption is that
2398
   // idle/resume/reset interrupts do not occur very frequently
2399
   assign rstint_penc[0] = async_rst_i4[0];
2400
   assign rstint_penc[1] = ~async_rst_i4[0] & async_rst_i4[1];
2401
   assign rstint_penc[2] = ~async_rst_i4[0] & ~async_rst_i4[1]  &
2402
                                  async_rst_i4[2];
2403
   assign rstint_penc[3] = ~async_rst_i4[0] & ~async_rst_i4[1]  &
2404
                                 ~async_rst_i4[2];
2405
 
2406
   // BF - switch in rst thread
2407
   dff #(1) asyncr1_ff(.din (rst_stallreq_d0),
2408
                                   .q   (rst_stallreq_d1),
2409
                                   .clk (clk), .se(se), .si(), .so());
2410
   assign arst_vld_f_l = ~arst_vld_f;
2411
   assign arst_vld_s_l = ~arst_vld_s;
2412
   bw_u1_nand3_4x UZsize_rstsw_n3(.z (rst_sw_bf_l),
2413
                                  .a (arst_vld_f_l),
2414
                                  .b (arst_vld_s_l),
2415
                                  .c (rst_stallreq_d1));
2416
   assign rst_sw_bf = ~rst_sw_bf_l;
2417
 
2418
   // double check if asyn intrs are still valid
2419
   assign sw_for_real_rst_bf = rst_sw_bf & rst_stallreq_d0;
2420
 
2421
   // F
2422
   dff #(1) asyncr2_ff(.din (sw_for_real_rst_bf),
2423
                                   .q   (rst_stallreq_d2),
2424
                                   .clk (clk), .se(se), .si(), .so());
2425
//   assign arst_vld_f = rst_stallreq_d2 & any_rstnuke_f;
2426
   assign arst_vld_f = rst_stallreq_d2;
2427
 
2428
   // hold thread till reset of curr thread is processed
2429
//   assign rst_thr_bf = arst_vld_f ? thr_f : rstint_penc;
2430
 
2431
   // S issue to pipe
2432
   dff #(1) rstvlds_ff(.din (arst_vld_f),
2433
                                   .q   (arst_vld_s),
2434
                                   .clk (clk), .se(se), .si(), .so());
2435
   assign async_intr_vld_s = arst_vld_s & ~kill_intr_f; // & any_rstnuke_f 
2436
 
2437
 
2438
   //
2439
   // thread wise interrupts
2440
   //
2441
   assign rstint_i2 = {4{tlu_ifu_rstint_i2}} & tlu_ifu_rstthr_i2;
2442
   assign resumint_i2 = {4{tlu_ifu_resumint_i2}} & tlu_ifu_rstthr_i2;
2443
   assign nuke_thr_i2 =  {4{tlu_ifu_nukeint_i2}} & tlu_ifu_rstthr_i2;
2444
 
2445
   assign next_rst_i2 = rstint_i2 |
2446
                              rstint_i3 & (~(thr_w & {4{fcl_dtu_rst_thr_w}}));
2447
   assign next_resum_i2 = resumint_i2 |
2448
                                resumint_i3 & (~(thr_w & {4{fcl_dtu_resum_thr_w}}))
2449
                          & ~rstint_i2;
2450
 
2451
   assign next_nuke_i2  = (nuke_thr_i2 | nuke_thr_i3) &
2452
                            (~(thr_w & {4{fcl_dtu_nuke_thr_w}})) &
2453
                               ~(rstint_i2 | resumint_i2);
2454
 
2455
   assign next_sftint_i2 = tlu_ifu_sftint_vld;
2456
   assign next_hwint_i3 = tlu_ifu_hwint_i3;
2457
   assign next_hintp_i2 = tlu_ifu_hintp_vld;
2458
   assign next_rerr_i2 = tlu_ifu_rerr_vld;
2459
 
2460
   assign next_ceint_i2 = erb_fcl_ce_trapvec |
2461
                                ceint_i3 & (~(thr_w & {4{ceint_qual_w}}));
2462
 
2463
   assign next_ueint_i2 = erb_fcl_ue_trapvec |
2464
                                ueint_i3 & (~(thr_w & {4{ueint_qual_w}}));
2465
 
2466
   // From Farnad: tid is ready several cycles before everything else
2467
   // I will assume 1 cycle before in the ifu
2468
   dff #(2) sptid_reg(.din (spu_ifu_ttype_tid_w2),
2469
                      .q   (spu_tid_w2),
2470
                      .clk (clk), .se(se), .so(), .si());
2471
 
2472
   assign spu_thr[0] = ~spu_tid_w2[1] & ~spu_tid_w2[0];
2473
   assign spu_thr[1] = ~spu_tid_w2[1] &  spu_tid_w2[0];
2474
   assign spu_thr[2] =  spu_tid_w2[1] & ~spu_tid_w2[0];
2475
   assign spu_thr[3] =  spu_tid_w2[1] &  spu_tid_w2[0];
2476
 
2477
   assign next_spuint1_i2 = {4{spu_ifu_ttype_vld_w2 & spu_ifu_ttype_w2}} &
2478
                                  spu_thr & ~erb_fcl_spu_uetrap |
2479
                                  spuint1_i3 & ~({4{spuint1_w}} & thr_w);
2480
 
2481
   assign next_spuint0_i2 = {4{spu_ifu_ttype_vld_w2 & ~spu_ifu_ttype_w2}} &
2482
                                  spu_thr & ~erb_fcl_spu_uetrap |
2483
                                  spuint0_i3 & ~({4{spuint0_w}} & thr_w);
2484
 
2485
 
2486
   dffr #(4) rst_reg(.din  (next_rst_i2),
2487
                                 .q    (rstint_i3),
2488
                                 .clk  (clk),
2489
                                 .rst  (fcl_reset),
2490
                                 .se   (se), .si(), .so());
2491
 
2492
   dffr #(4) resum_reg(.din  (next_resum_i2),
2493
                                   .q    (resumint_i3),
2494
                                   .clk  (clk),
2495
                                   .rst  (fcl_reset),
2496
                                   .se   (se), .si(), .so());
2497
 
2498
   dffr #(4) nuke_reg(.din  (next_nuke_i2),
2499
                                  .q    (nuke_thr_i3),
2500
                                  .rst  (fcl_reset),
2501
                                  .clk  (clk),
2502
                                  .se   (se), .si(), .so());
2503
 
2504
   dffr #(4) sfti_reg(.din  (next_sftint_i2),
2505
                                  .q    (sftint_i3),
2506
                                  .rst  (fcl_reset),
2507
                                  .clk  (clk), .se   (se), .si(), .so());
2508
   dffr #(4) hstki_reg(.din  (next_hintp_i2),
2509
                                  .q    (hintp_i3),
2510
                                  .rst  (fcl_reset),
2511
                                  .clk  (clk), .se   (se), .si(), .so());
2512
   dffr #(4) reri_reg(.din  (next_rerr_i2),
2513
                                  .q    (rerr_i3),
2514
                                  .rst  (fcl_reset),
2515
                                  .clk  (clk), .se   (se), .si(), .so());
2516
   dffr #(4) hwi_reg(.din  (next_hwint_i3),
2517
                                 .q    (hwint_i4),
2518
                                 .rst  (fcl_reset),
2519
                                 .clk  (clk), .se   (se), .si(), .so());
2520
 
2521
   dffr #(4) spui0_reg(.din  (next_spuint0_i2),
2522
                                   .q    (spuint0_i3),
2523
                                   .rst  (fcl_reset),
2524
                                   .clk  (clk), .se   (se), .si(), .so());
2525
 
2526
   dffr #(4) spui1_reg(.din  (next_spuint1_i2),
2527
                                   .q    (spuint1_i3),
2528
                                   .rst  (fcl_reset),
2529
                                   .clk  (clk), .se   (se), .si(), .so());
2530
 
2531
   dffr #(4) cei_reg(.din  (next_ceint_i2),
2532
                                 .q    (ceint_i3),
2533
                                 .rst  (fcl_reset),
2534
                                 .clk  (clk), .se   (se), .si(), .so());
2535
 
2536
   dffr #(4) uei_reg(.din  (next_ueint_i2),
2537
                                 .q    (ueint_i3),
2538
                                 .rst  (fcl_reset),
2539
                                 .clk  (clk), .se   (se), .si(), .so());
2540
 
2541
   assign supv_int_en = (~tlu_hpstate_priv | ~tlu_hpstate_enb) &
2542
                         tlu_ifu_pstate_ie & dtu_fcl_thr_active;
2543
   assign hypv_int_en = ~tlu_hpstate_priv & tlu_hpstate_enb |
2544
                        tlu_ifu_pstate_ie & dtu_fcl_thr_active;
2545
 
2546
   dff #(4) spvie_ff(.din (supv_int_en),
2547
                     .q   (supv_int_en_d1),
2548
                     .clk (clk), .se(se), .si(), .so());
2549
   dff #(4) hpvie_ff(.din (hypv_int_en),
2550
                     .q   (hypv_int_en_d1),
2551
                     .clk (clk), .se(se), .si(), .so());
2552
 
2553
   // force an interrupt by putting nop on pipe
2554
   // use this signal instead of hw_int_s to help with crit path
2555
   assign supv_masked_intr_s = (sftint_i3        |
2556
                                                  rerr_i3);
2557
   assign hypv_masked_intr_s = (hwint_i4         |
2558
                                                  hintp_i3         |
2559
                                                  ceint_i3         |
2560
                                                  ueint_i3         |
2561
                                                  spuint0_i3       |
2562
                                                  spuint1_i3);
2563
 
2564
   assign fcl_swl_int_activate_i3 = hypv_masked_intr_s |
2565
                                    supv_masked_intr_s;
2566
 
2567
    // keep track of rolled back interrupts
2568
   assign intr_pending_nxt =  (({4{intr_vld_e}} & rb_frome) |
2569
                               ({4{intr_vld_d}} & rb_fromd & ~rb_frome) |
2570
                                intr_pending_s) & ~clear_s_d1;
2571
 
2572
   dffr #(4) ipend_reg(.din (intr_pending_nxt),
2573
                       .q   (intr_pending_s),
2574
                       .rst (fcl_reset),
2575
                       .clk (clk), .se(se), .si(), .so());
2576
 
2577
   assign any_intr_vec_f = (supv_masked_intr_s & supv_int_en_d1 |
2578
                            hypv_masked_intr_s & hypv_int_en_d1 |
2579
                            intr_pending_s    |
2580
                                              rstint_i3         |
2581
                            resumint_i3       |
2582
                                              nuke_thr_i3);
2583
 
2584
   dff #(4) anyints_reg(.din (any_intr_vec_f),
2585
                        .q   (any_intr_vec_s),
2586
                        .clk (clk), .se(se), .si(), .so());
2587
 
2588
   assign force_intr_s = (thr_f_crit[0] & any_intr_vec_s[0] |
2589
                          thr_f_crit[1] & any_intr_vec_s[1] |
2590
                          thr_f_crit[2] & any_intr_vec_s[2] |
2591
                          thr_f_crit[3] & any_intr_vec_s[3]) &
2592
                                 ~kill_intr_f;
2593
 
2594
   // interrupt and reset signal pipe
2595
   // VA hole trap has higher priority than interrupt
2596
   //   - since the VA hole marker is lost once the intr is taken
2597
   assign intr_vld_s = force_intr_s & (valid_s & ~pc_oor_s |
2598
                                       async_intr_vld_s);
2599
 
2600
   assign intr_vld_qual_s = intr_vld_s & ~iferrto_thisthr_d1;
2601
   dff #(1) any_intrd_ff(.din (intr_vld_qual_s),
2602
                                     .q   (intr_vld_d),
2603
                                     .clk (clk),
2604
                                     .se  (se), .so(), .si());
2605
   assign fcl_dec_intr_vld_d = intr_vld_d;
2606
   assign intr_vld_qual_d = intr_vld_d & ~kill_intr_d & ~kill_thread_d &
2607
                                   ~rb_stg_d;
2608
 
2609
   dff #(1) intr_vlde_ff(.din (intr_vld_qual_d),
2610
                                   .q   (intr_vld_e),
2611
                                   .clk (clk), .se  (se), .so(), .si());
2612
 
2613
   assign intr_vld_qual_e = intr_vld_e & ~kill_curr_e & ~rb_stg_e &
2614
                            ~kill_intr_e & ~dtu_inst_anull_e &
2615
                      ~(thr_match_em & ifu_tlu_flush_m);
2616
 
2617
   dff #(1) intr_vldm_ff(.din (intr_vld_qual_e),
2618
                                   .q   (intr_vld_m),
2619
                                   .clk (clk), .se  (se), .so(), .si());
2620
 
2621
   assign intr_vld_qual_m = intr_vld_m & ~kill_thread_m & ~mark4rb_m;
2622
 
2623
   dff #(1) intr_vldw_ff(.din (intr_vld_qual_m),
2624
                                   .q   (intr_vld_w),
2625
                                   .clk (clk), .se  (se), .so(), .si());
2626
 
2627
   // Reset and Idle are prioritized in M.  All others in E
2628
   // reset interrupt
2629
   assign rstint_m = (rstint_i3[0] & thr_m[0] |
2630
                                        rstint_i3[1] & thr_m[1] |
2631
                                        rstint_i3[2] & thr_m[2] |
2632
                                        rstint_i3[3] & thr_m[3]);
2633
 
2634
   assign ifu_tlu_rstint_m = rstint_m & intr_vld_m & ~kill_local_m &
2635
                             ~kill_curr_m;
2636
//   assign rstint_qual_m = rstint_m & ~ely_kill_thread_m & intr_vld_m;
2637
   dff #(1) rstw_ff(.din (rstint_m),
2638
                    .q   (rst_thr_w),
2639
                    .clk (clk), .se(se), .si(), .so());
2640
   assign fcl_dtu_rst_thr_w = rst_thr_w & intr_vld_w;
2641
 
2642
   // resume interrupt
2643
   assign resumint_m = (resumint_i3[0] & thr_m[0] |
2644
                                          resumint_i3[1] & thr_m[1] |
2645
                                          resumint_i3[2] & thr_m[2] |
2646
                                          resumint_i3[3] & thr_m[3]);
2647
   assign resumint_qual_m = resumint_m & ~rstint_m;
2648
 
2649
   dff #(1) resumw_ff(.din (resumint_qual_m),
2650
                      .q   (resum_thr_w),
2651
                      .clk (clk), .se(se), .si(), .so());
2652
   assign fcl_dtu_resum_thr_w = resum_thr_w & intr_vld_w;
2653
 
2654
   // idle interrupt
2655
   assign nuke_thr_m = (nuke_thr_i3[0] & thr_m[0] |
2656
                                                nuke_thr_i3[1] & thr_m[1] |
2657
                                                nuke_thr_i3[2] & thr_m[2] |
2658
                                                nuke_thr_i3[3] & thr_m[3]);
2659
 
2660
   assign nuke_thr_qual_m = nuke_thr_m & ~rstint_m & ~resumint_m;
2661
 
2662
   dff #(1) nukw_ff(.din (nuke_thr_qual_m),
2663
                    .q   (nuke_thr_w),
2664
                    .clk (clk),
2665
                    .se  (se), .si(), .so());
2666
   assign fcl_dtu_nuke_thr_w = nuke_thr_w & intr_vld_w;
2667
 
2668
   // uncorrected ecc
2669
   assign ueint_e = (ueint_i3[0] & thr_e[0] & hypv_int_en_d1[0] |
2670
                                 ueint_i3[1] & thr_e[1] & hypv_int_en_d1[1] |
2671
                                 ueint_i3[2] & thr_e[2] & hypv_int_en_d1[2] |
2672
                                 ueint_i3[3] & thr_e[3] & hypv_int_en_d1[3]);
2673
   assign ueint_qual_e = ueint_e & intr_vld_e;
2674
 
2675
   dff #(1) uem_ff (.din (ueint_qual_e),
2676
                    .q   (ueint_m),
2677
                    .clk (clk), .se (se), .si(), .so());
2678
 
2679
//   assign ueint_m = (ueint_i3[0] & thr_m[0] |
2680
//                               ueint_i3[1] & thr_m[1] |
2681
//                               ueint_i3[2] & thr_m[2] |
2682
//                               ueint_i3[3] & thr_m[3]);
2683
 
2684
   assign ueint_trap_m = ueint_m & intr_vld_m &
2685
                         ~(rstint_m | resumint_m | nuke_thr_m);
2686
 
2687
//   assign ueint_qual_m = ueint_trap_m & ~ely_kill_thread_m;
2688
   dff #(1) ueintw_ff(.din (ueint_trap_m),
2689
                      .q   (ueint_trap_w),
2690
                      .clk (clk), .se(se), .si(), .so());
2691
   assign ueint_qual_w = ueint_trap_w & intr_vld_w;
2692
 
2693
   // hstk match interrupt
2694
   assign hintp_e = (hintp_i3[0] & thr_e[0] & hypv_int_en_d1[0] |
2695
                                       hintp_i3[1] & thr_e[1] & hypv_int_en_d1[1] |
2696
                                       hintp_i3[2] & thr_e[2] & hypv_int_en_d1[2] |
2697
                                       hintp_i3[3] & thr_e[3] & hypv_int_en_d1[3]);
2698
   assign hintp_qual_e = hintp_e & intr_vld_e & ~ueint_e;
2699
 
2700
   dff #(1) hintpm_ff (.din (hintp_qual_e),
2701
                       .q   (hintp_m),
2702
                       .clk (clk), .se (se), .si(), .so());
2703
 
2704
//   assign ifu_tlu_hintp_m = hintp_m & ~kill_local_m & intr_vld_m & 
2705
//                          ~(rstint_m | nuke_thr_m | ueint_m);
2706
 
2707
   // hw int
2708
   assign hwint_e = (hwint_i4[0] & thr_e[0] & hypv_int_en_d1[0] |
2709
                                       hwint_i4[1] & thr_e[1] & hypv_int_en_d1[1] |
2710
                                       hwint_i4[2] & thr_e[2] & hypv_int_en_d1[2] |
2711
                                       hwint_i4[3] & thr_e[3] & hypv_int_en_d1[3]);
2712
   dff #(1) hwe_ff(.din (hwint_e),
2713
                   .q   (hwint_m),
2714
                   .clk (clk), .se(se), .si(), .so());
2715
 
2716
   assign ifu_tlu_hwint_m = hwint_m & intr_vld_m & ~kill_local_m &
2717
                     ~kill_curr_m &
2718
                           ~(rstint_m | resumint_m | nuke_thr_m | ueint_m | hintp_m);
2719
 
2720
 
2721
   // spu interrupt
2722
   assign spuint1_e = (spuint1_i3[0] & thr_e[0] & hypv_int_en_d1[0] |
2723
                                   spuint1_i3[1] & thr_e[1] & hypv_int_en_d1[1] |
2724
                                   spuint1_i3[2] & thr_e[2] & hypv_int_en_d1[2] |
2725
                                   spuint1_i3[3] & thr_e[3] & hypv_int_en_d1[3]);
2726
   assign spuint1_qual_e = spuint1_e & intr_vld_e & ~ueint_e & ~hintp_e;
2727
 
2728
//   assign spuint1_m = (spuint1_i3[0] & thr_m[0] |
2729
//                                 spuint1_i3[1] & thr_m[1] |
2730
//                                 spuint1_i3[2] & thr_m[2] |
2731
//                                 spuint1_i3[3] & thr_m[3]);
2732
 
2733
   dff #(1) spu1m_ff(.din (spuint1_qual_e),
2734
                     .q   (spuint1_m),
2735
                     .clk (clk), .se(se), .si(), .so());
2736
 
2737
   assign spuint1_trap_m = spuint1_m & intr_vld_m &
2738
                            ~(rstint_m | resumint_m | nuke_thr_m | hwint_m);
2739
 
2740
//   assign spuint1_qual_m = spuint1_trap_m & ~ely_kill_thread_m;
2741
 
2742
   dff #(1) spiw1_ff(.din (spuint1_trap_m),
2743
                                 .q   (spuint1_trap_w),
2744
                                 .clk (clk), .se(se), .si(), .so());
2745
   assign spuint1_w = spuint1_trap_w & intr_vld_w;
2746
 
2747
   assign spuint0_e = (spuint0_i3[0] & thr_e[0] & hypv_int_en_d1[0] |
2748
                                   spuint0_i3[1] & thr_e[1] & hypv_int_en_d1[1] |
2749
                                   spuint0_i3[2] & thr_e[2] & hypv_int_en_d1[2] |
2750
                                   spuint0_i3[3] & thr_e[3] & hypv_int_en_d1[3]);
2751
 
2752
   assign spuint0_qual_e = spuint0_e & intr_vld_e & ~ueint_e &
2753
                                             ~spuint1_e & ~hintp_e;
2754
 
2755
//   assign spuint0_m = (spuint0_i3[0] & thr_m[0] |
2756
//                                 spuint0_i3[1] & thr_m[1] |
2757
//                                 spuint0_i3[2] & thr_m[2] |
2758
//                                 spuint0_i3[3] & thr_m[3]);
2759
   dff #(1) spu0m_ff(.din (spuint0_qual_e),
2760
                     .q   (spuint0_m),
2761
                     .clk (clk), .se(se), .si(), .so());
2762
 
2763
   assign spuint0_trap_m = spuint0_m & intr_vld_m &
2764
                        ~(rstint_m | nuke_thr_m | resumint_m |
2765
                                    hwint_m);
2766
 
2767
//   assign spuint0_qual_m = spuint0_trap_m & ~kill_thread_m;
2768
 
2769
   dff #(1) spiw0_ff(.din (spuint0_trap_m),
2770
                                 .q   (spuint0_trap_w),
2771
                                 .clk (clk), .se(se), .si(), .so());
2772
   assign spuint0_w = spuint0_trap_w & intr_vld_w;
2773
 
2774
//   assign ifu_spu_trap_ack = {spuint1_w, spuint0_w};
2775
   assign ifu_spu_trap_ack = spuint1_w;
2776
 
2777
 
2778
   // software interrupts
2779
   assign sftint_e = (sftint_i3[0] & thr_e[0] & supv_int_en_d1[0] |
2780
                                        sftint_i3[1] & thr_e[1] & supv_int_en_d1[1] |
2781
                                        sftint_i3[2] & thr_e[2] & supv_int_en_d1[2] |
2782
                                        sftint_i3[3] & thr_e[3] & supv_int_en_d1[3]);
2783
 
2784
   assign sftint_qual_e = sftint_e & ~spuint0_e & intr_vld_e &
2785
                          ~ueint_e & ~spuint1_e & ~hintp_e;
2786
 
2787
   dff #(1) swm_ff(.din (sftint_qual_e),
2788
                   .q   (sftint_m),
2789
                   .clk (clk), .se(se), .si(), .so());
2790
 
2791
   // if nothing else, signal sftint!
2792
//   assign ifu_tlu_sftint_m = (sftint_m & 
2793
//                                  ~(rstint_m | nuke_thr_m | hintp_m | resumint_m |
2794
//                                                      hwint_m | spuint1_m | spuint0_m | ueint_m) |
2795
//                              ~(ceint_m | rerr_m)) & 
2796
//                               ~kill_local_m & intr_vld_m;
2797
 
2798
   assign ifu_tlu_sftint_m = (sftint_m &
2799
                                    ~(rstint_m | nuke_thr_m | hintp_m | resumint_m |
2800
                                                        hwint_m | spuint1_m | spuint0_m | ueint_m)) &
2801
                               ~kill_local_m & ~kill_curr_m & intr_vld_m;
2802
 
2803
 
2804
   // corrected ecc interrupt
2805
   assign ceint_e = (ceint_i3[0] & thr_e[0] & hypv_int_en_d1[0] |
2806
                                 ceint_i3[1] & thr_e[1] & hypv_int_en_d1[1] |
2807
                                 ceint_i3[2] & thr_e[2] & hypv_int_en_d1[2] |
2808
                                 ceint_i3[3] & thr_e[3] & hypv_int_en_d1[3]);
2809
   assign ceint_qual_e = ceint_e & intr_vld_e & ~ueint_e &
2810
                          ~spuint1_e & ~spuint0_e & ~hintp_e;
2811
 
2812
//   assign ceint_m = (ceint_i3[0] & thr_m[0] |
2813
//                               ceint_i3[1] & thr_m[1] |
2814
//                               ceint_i3[2] & thr_m[2] |
2815
//                               ceint_i3[3] & thr_m[3]);
2816
   dff #(1) cem_ff(.din (ceint_qual_e),
2817
                   .q   (ceint_m),
2818
                   .clk (clk), .se(se), .si(), .so());
2819
 
2820
   assign ceint_trap_m = ceint_m & intr_vld_m &
2821
                         ~(rstint_m | nuke_thr_m | resumint_m |
2822
                                 sftint_m | hwint_m);
2823
 
2824
//   assign ceint_qual_m = ceint_trap_m & ~ely_kill_thread_m;
2825
   dff #(1) ceintw_ff(.din (ceint_trap_m),
2826
                      .q   (ceint_trap_w),
2827
                      .clk (clk), .se(se), .si(), .so());
2828
   assign ceint_qual_w = ceint_trap_w & intr_vld_w;
2829
 
2830
   // resumable error interrupt
2831
   assign rerr_e = (rerr_i3[0] & thr_e[0] & supv_int_en_d1[0] |
2832
                                 rerr_i3[1] & thr_e[1] & supv_int_en_d1[1] |
2833
                                 rerr_i3[2] & thr_e[2] & supv_int_en_d1[2] |
2834
                                 rerr_i3[3] & thr_e[3] & supv_int_en_d1[3]);
2835
   assign rerr_qual_e = rerr_e & intr_vld_e & ~ueint_e & ~ceint_e &
2836
                        ~spuint1_e & ~spuint0_e & ~hintp_e;
2837
 
2838
   dff #(1) rem_ff(.din (rerr_qual_e),
2839
                   .q   (rerr_m),
2840
                   .clk (clk), .se(se), .si(), .so());
2841
 
2842
//   assign rerr_m = (rerr_i3[0] & thr_m[0] |
2843
//                                    rerr_i3[1] & thr_m[1] |
2844
//                                    rerr_i3[2] & thr_m[2] |
2845
//                                    rerr_i3[3] & thr_m[3]);
2846
 
2847
//   assign ifu_tlu_rerr_m = rerr_m & ~kill_local_m & intr_vld_m & 
2848
//                          ~(rstint_m | nuke_thr_m | ueint_m | ceint_m);
2849
 
2850
   assign disr_trap_m = (ueint_m | hintp_m | spuint0_m | spuint1_m |
2851
                         ceint_m | rerr_m) & ~rstint_m & ~nuke_thr_m &
2852
                          ~resumint_m & intr_vld_m;
2853
 
2854
   // check if a scheduled interrupt evaporated...
2855
   assign any_intr_m = (ueint_m | ceint_m | spuint0_m | spuint1_m |
2856
                        hintp_m | rerr_m | sftint_m | hwint_m |
2857
                        rstint_m | nuke_thr_m | resumint_m);
2858
 
2859
   // ..and rollback if that is the case
2860
   assign rb_intr_m = ~any_intr_m & intr_vld_m;
2861
   dff #(1) rbint_ff(.din (rb_intr_m),
2862
                     .q   (rb_intr_w),
2863
                     .clk (clk), .se(se), .si(), .so());
2864
 
2865
   // use synchronous interrupt signal to switch out thread in swl
2866
//   assign fcl_dtu_sync_intr_d = (intr_vld_d | immu_miss_crit_d) & ~rb_stg_d;
2867
   assign fcl_dtu_sync_intr_d = (intr_vld_d) & ~rb_stg_d_crit;
2868
 
2869
   // kill the next three interrupts.  After that you are on your own.
2870
//   assign kill_intr_m = ((thr_m & thr_w) == 4'b0) ?
2871
//                                          1'b0 : (intr_vld_w);
2872
   assign kill_intr_e = ((thr_e & thr_w) == 4'b0) ?
2873
                                            1'b0 : (intr_vld_w);
2874
   assign kill_intr_d = ((thr_d & thr_w) == 4'b0) ?
2875
                                            1'b0 : (intr_vld_w);
2876
   assign kill_intr_f = ((thr_f & thr_w) == 4'b0) ?
2877
                                            1'b0 : (intr_vld_w);
2878
 
2879
//--------------------------------
2880
// check if we are in a delay slot
2881
//--------------------------------
2882
   // remember if the current instruction is a delay slot
2883
   assign delay_slot_vec_nxt = ({4{dtu_fcl_br_inst_d & inst_vld_d &
2884
                                   ~rb_stg_d}} & thr_d | // set
2885
                                delay_slot_vec &
2886
                                ~(thr_d & {4{inst_vld_d &
2887
                                             ~rb_stg_d &
2888
                                             ~intr_vld_d}})) &
2889
                                 ~(trap_thr & {4{trappc_vld_w2}});
2890
                                // & ~late_flush_w2;
2891
   // Need to be a little pessimitic: can't clear the delay slot vec
2892
   // after a utrap, since we may still be in the delay slot when we
2893
   // re-execute
2894
 
2895
   dffr #(4) ds_reg(.din (delay_slot_vec_nxt),
2896
                    .q   (delay_slot_vec),
2897
                    .rst (fcl_reset),
2898
                    .clk (clk), .se(se), .si(), .so());
2899
   assign fcl_dec_dslot_s = (delay_slot_vec[0] & thr_f[0] |
2900
                             delay_slot_vec[1] & thr_f[1] |
2901
                             delay_slot_vec[2] & thr_f[2] |
2902
                             delay_slot_vec[3] & thr_f[3]);
2903
 
2904
 
2905
//------------------------------
2906
// NIR control
2907
//------------------------------
2908
   // use nir if va[2] of previous fetch is a zero (i.e lower word)
2909
   dff #(1) va2_ff(.din (fdp_fcl_va2_bf),
2910
                               .clk (clk),
2911
                               .q   (va2_f),
2912
                               .se  (se), .si(), .so());
2913
 
2914
   assign usep_bf = rdreq_f & ~va2_f & ~ntpc_thisthr & ~stall_f;
2915
   assign set_usen_bf = usep_bf & ~ely_stall_thisthr_f & dtu_fcl_running_s;
2916
 
2917
   // need to kill usen if trap or interrupt or flush
2918
   assign thr_usen_nxt = ({4{set_usen_bf}} &  thr_f  |    // set usen
2919
                                            thr_usen_bf  & ~val_thr_f) &    // keep old value
2920
                                             ~((thr_d & {4{dtu_fcl_br_inst_d}})  |
2921
                                         (thr_s1 & {4{ic_miss_s1}})  |
2922
                             (thr_e & {4{erb_dtu_ifeterr_d1 & inst_vld_d1}}) |
2923
                                               (clear_s_d1) |
2924
                                               (ntpc_vld)  |
2925
                                               (rb_w2 | rb_froms));     // reset usen (wins)
2926
                         // & ~dtu_fcl_flush_nir
2927
 
2928
   dffr #(4) thr_usen_reg(.din  (thr_usen_nxt),
2929
                                          .clk  (clk),
2930
                                          .q    (thr_usen_bf),
2931
                                          .rst  (fcl_reset),
2932
                                          .se   (se), .si(), .so());
2933
 
2934
   /*
2935
   // Use hand instantiated mux
2936
   bw_u1_ao2222_4x UZsize_usn_mx(.z   (usen_iso_bf)
2937
                                            .a2  (thr_usen_bf[0]),
2938
                                            .b2  (thr_usen_bf[1]),
2939
                                            .c2  (thr_usen_bf[2]),
2940
                                            .d2  (thr_usen_bf[3]),
2941
                                            .a1  (nextthr_bf_buf[0]),
2942
                                            .b1  (nextthr_bf_buf[1]),
2943
                                            .c1  (nextthr_bf_buf[2]),
2944
                                            .d1  (nextthr_bf_buf[3]));
2945
 
2946
    // isolate from critical path
2947
    bw_u1_buf_5x  UZsize_usn_iso(.z(usen_bf), .a(usen_iso_bf));
2948
    */
2949
 
2950
   assign usen_iso_bf = (thr_usen_bf[0] & nextthr_bf_buf[0] |
2951
                         thr_usen_bf[1] & nextthr_bf_buf[1] |
2952
                         thr_usen_bf[2] & nextthr_bf_buf[2] |
2953
                         thr_usen_bf[3] & nextthr_bf_buf[3]);
2954
   assign usen_bf = usen_iso_bf;
2955
 
2956
 
2957
 
2958
//------------------------------
2959
// Switch Control
2960
//------------------------------   
2961
   // Switch IF
2962
   //   1. Another thread is ready OR
2963
   //   2. We hit a switch condition or Imiss and another thread is
2964
   //      speculatively ready
2965
   //   3. No thread is running and another thread is speculatively ready
2966
   //   4. The DTU calls for a thread switch and another thread is ready
2967
   //   (NOTE: if we hit a switch condition or Imiss and no thread is
2968
   //    speculatively or otherwise ready we stall the pipe).
2969
   //
2970
   //   New plan:  switch if another thread is ready or spec ready.
2971
   //
2972
 
2973
//   assign switch_bf = dtu_fcl_ntr_s;
2974
   bw_u1_buf_20x UZsize_swbuf(.a (dtu_fcl_ntr_s),
2975
                              .z (switch_bf));
2976
 
2977
//   assign switch_bf = dtu_fcl_ntr_s & ~imsto_nextthr_s1;
2978
//   assign switch_bf = dtu_fcl_ntr_s & ~(imsto_nextthr_s1 | kill_nextthr_w | 
2979
//                                        intrto_nextthr_d);   
2980
 
2981
//   assign fcl_dtu_switch_s = switch_bf & ~all_stallreq & ~rst_stallreq;
2982
//   assign fcl_dtu_switch_s = switch_bf & ~kill_nextthr_w;
2983
 
2984
   // TBD: No need to send this anymore, since switch_bf = ntr_s
2985
//   assign fcl_dtu_switch_s = switch_bf;  // sw out curr and sw in next
2986
 
2987
   assign fcl_swl_swout_f = stall_f;     // sw out curr but don't sw in next
2988
   // Note: need fcl_swl_swout_f and dtu_fcl_running_s to sync swl and
2989
   // fcl at all times.  
2990
 
2991
   assign switch_qual_bf = switch_bf & ~rst_stallreq;
2992
   dff #(1) sw_ff (.din  (switch_qual_bf),
2993
                               .clk  (clk),
2994
                               .q    (switch_s2),
2995
                               .se   (se), .si(), .so());
2996
 
2997
   dff #(1) tmfn_ff (.din  (switch_bf),
2998
                                 .clk  (clk),
2999
                                 .q    (tm_fd_l),
3000
                                 .se   (se), .si(), .so());
3001
 
3002
   // need to qual with immu_fault to avoid X's
3003
//   assign fcl_dtu_swc_s = fdp_fcl_swc_s2 & inst_vld_s_crit & 
3004
//                          ~immu_fault_f & ~part_stall_thisthr_f;
3005
//   assign fcl_dtu_swc_s = fdp_fcl_swc_s2 & inst_vld_s_crit & 
3006
//                          ~immu_fault_f & ~imsto_thisthr_s1 & ~rb_stg_s;
3007
   assign fcl_swl_swcvld_s = inst_vld_s_crit & ~immu_fault_f &
3008
                             ~imsto_thisthr_s1 & ~rb_stg_s;
3009
 
3010
 
3011
//------------------------------   
3012
// Thread pipe
3013
//------------------------------
3014
 
3015
//`ifdef VERPLEX
3016
//   $constraint nthr_1h4 ($one_hot(dtu_fcl_nextthr_bf[3:0]));
3017
//   $constraint thrf_1h4 ($one_hot(thr_f[3:0]));
3018
//`endif
3019
 
3020
   // Keep track the thread in each pipe stage
3021
   assign rstt = (~fcl_reset & (rst_stallreq_d1 & ~arst_vld_f)) | rst_tri_en;
3022
   assign swt =  (~rst_stallreq_d1 & ~arst_vld_f & switch_bf | fcl_reset) &
3023
                   ~rst_tri_en;
3024
   assign samet = (~rst_stallreq_d1 & ~switch_bf | arst_vld_f) &
3025
                    ~fcl_reset & ~rst_tri_en;
3026
 
3027
   mux3ds #(4)  nxttthr_mux(.dout  (thr_bf[3:0]),
3028
                                              .in0   (thr_f[3:0]),
3029
                                              .in1   (nextthr_bf_buf[3:0]),
3030
                                              .in2   (rstint_penc[3:0]),
3031
                                              .sel0  (samet),
3032
                                              .sel1  (swt),
3033
                                              .sel2  (rstt));
3034
 
3035
   assign thr_match_nw = (thr_w[0] & nextthr_bf_buf[0] |
3036
                                            thr_w[1] & nextthr_bf_buf[1] |
3037
                                            thr_w[2] & nextthr_bf_buf[2] |
3038
                                            thr_w[3] & nextthr_bf_buf[3]);
3039
 
3040
   assign thr_match_nd = (thr_d[0] & nextthr_bf_buf[0] |
3041
                                            thr_d[1] & nextthr_bf_buf[1] |
3042
                                            thr_d[2] & nextthr_bf_buf[2] |
3043
                                            thr_d[3] & nextthr_bf_buf[3]);
3044
 
3045
//   assign thr_match_ne = (thr_e[0] & dtu_fcl_nextthr_bf[0] | 
3046
//                                          thr_e[1] & dtu_fcl_nextthr_bf[1] | 
3047
//                                          thr_e[2] & dtu_fcl_nextthr_bf[2] | 
3048
//                                          thr_e[3] & dtu_fcl_nextthr_bf[3]);
3049
   // qualify inst_vld_e in fcl itself
3050
 
3051
//   bw_u1_ao2222_4x UZsize_tmne(.z  (thr_match_ne),
3052
//                               .a1 (val_thr_e[0]),
3053
//                               .b1 (val_thr_e[1]),
3054
//                               .c1 (val_thr_e[2]),
3055
//                               .d1 (val_thr_e[3]),
3056
//                               .a2 (dtu_fcl_nextthr_bf[0]),
3057
//                               .b2 (dtu_fcl_nextthr_bf[1]),
3058
//                               .c2 (dtu_fcl_nextthr_bf[2]),
3059
//                               .d2 (dtu_fcl_nextthr_bf[3]));
3060
 
3061
   wire   tmne_10,
3062
          tmne_32;
3063
   bw_u1_aoi22_2x UZsize_tmne10(.z (tmne_10),
3064
                                .a1 (dtu_fcl_nextthr_bf[0]),
3065
                                .b1 (dtu_fcl_nextthr_bf[1]),
3066
                                .a2 (val_thr_e[0]),
3067
                                .b2 (val_thr_e[1]));
3068
   bw_u1_aoi22_2x UZsize_tmne32(.z (tmne_32),
3069
                                .a1 (dtu_fcl_nextthr_bf[2]),
3070
                                .b1 (dtu_fcl_nextthr_bf[3]),
3071
                                .a2 (val_thr_e[2]),
3072
                                .b2 (val_thr_e[3]));
3073
   bw_u1_nand2_4x UZsize_tmne30(.z (thr_match_ne),
3074
                                .a (tmne_10),
3075
                                .b (tmne_32));
3076
 
3077
 
3078
   dff #(4) thrf_reg(.din   (thr_bf),     // thr_f may be 4'b0000 but it has 
3079
                                 .clk   (clk),        // to reset to 4'b0001
3080
                                 .q     (thr_f_flop),
3081
                                 .se    (se),  .si(), .so());
3082
 
3083
   bw_u1_buf_10x UZsize_tfcrit0(.a (thr_f_flop[0]), .z(thr_f_crit[0]));
3084
   bw_u1_buf_10x UZsize_tfcrit1(.a (thr_f_flop[1]), .z(thr_f_crit[1]));
3085
   bw_u1_buf_10x UZsize_tfcrit2(.a (thr_f_flop[2]), .z(thr_f_crit[2]));
3086
   bw_u1_buf_10x UZsize_tfcrit3(.a (thr_f_flop[3]), .z(thr_f_crit[3]));
3087
 
3088
   bw_u1_buf_10x UZsize_tfncr0(.a (thr_f_flop[0]), .z(thr_f[0]));
3089
   bw_u1_buf_10x UZsize_tfncr1(.a (thr_f_flop[1]), .z(thr_f[1]));
3090
   bw_u1_buf_10x UZsize_tfncr2(.a (thr_f_flop[2]), .z(thr_f[2]));
3091
   bw_u1_buf_10x UZsize_tfncr3(.a (thr_f_flop[3]), .z(thr_f[3]));
3092
 
3093
   assign     ifu_exu_tid_s2[1] = thr_f[3] | thr_f[2];
3094
   assign     ifu_exu_tid_s2[0] = thr_f[3] | thr_f[1];
3095
   assign     ifu_lsu_thrid_s = ifu_exu_tid_s2;
3096
   assign     fcl_dtu_thr_f = thr_f;
3097
 
3098
//   assign thr_s1_next = inst_vld_f ? thr_f : thr_s1;
3099
   assign     thr_s1_next[0] = thr_f[0];
3100
   assign     thr_s1_next[1] = ~thr_f[0] & thr_f[1];
3101
   assign     thr_s1_next[2] = ~thr_f[0] & ~thr_f[1] & thr_f[2];
3102
   assign     thr_s1_next[3] = ~thr_f[0] & ~thr_f[1] & ~thr_f[2];
3103
 
3104
//`ifdef VERPLEX
3105
//   $constraint thr_s1_1h4 ($one_hot(thr_s1_next[3:0]));
3106
//`endif
3107
 
3108
   dff #(4) thrs1_reg(.din   (thr_s1_next),
3109
                    .clk   (clk),
3110
                    .q     (thr_s1),
3111
                    .se    (se), .si(), .so());
3112
 
3113
   dff #(4) thrd_reg(.din    (thr_s1_next),
3114
                     .clk   (clk),
3115
                     .q     (thr_d),
3116
                     .se    (se), .si(), .so());
3117
 
3118
   assign fcl_ifq_thr_s1[0] = thr_s1[3] | thr_s1[1];
3119
   assign fcl_ifq_thr_s1[1] = thr_s1[3] | thr_s1[2];
3120
 
3121
   assign ifu_tlu_thrid_d[1] = thr_d[3] | thr_d[2];
3122
   assign ifu_tlu_thrid_d[0] = thr_d[3] | thr_d[1];
3123
 
3124
   assign thr_match_fs1 = (thr_d[0] & thr_f_crit[0] |
3125
                                             thr_d[1] & thr_f_crit[1] |
3126
                                             thr_d[2] & thr_f_crit[2] |
3127
                                             thr_d[3] & thr_f_crit[3]);
3128
   assign thr_match_fd = thr_match_fs1;
3129
   assign thr_match_fe = (thr_e[0] & thr_f[0] |
3130
                                            thr_e[1] & thr_f[1] |
3131
                                            thr_e[2] & thr_f[2] |
3132
                                            thr_e[3] & thr_f[3]);
3133
   assign thr_match_fm = (thr_m[0] & thr_f[0] |
3134
                                            thr_m[1] & thr_f[1] |
3135
                                            thr_m[2] & thr_f[2] |
3136
                                            thr_m[3] & thr_f[3]);
3137
//   assign thr_match_ft = (trap_thr[0] & thr_f[0] | 
3138
//                        trap_thr[1] & thr_f[1] | 
3139
//                        trap_thr[2] & thr_f[2] | 
3140
//                        trap_thr[3] & thr_f[3]);
3141
 
3142
   dffr #(4) thre_reg(.din   (thr_d),
3143
                    .clk   (clk),
3144
                    .rst   (fcl_reset),
3145
                    .q     (thr_e),
3146
                    .se    (se), .si(), .so());
3147
 
3148
   dffr #(4) thre2_reg(.din   (thr_d),
3149
                    .clk   (clk),
3150
                    .rst   (fcl_reset),
3151
                    .q     (thr_e_v2),
3152
                    .se    (se), .si(), .so());
3153
 
3154
   assign     ifu_tlu_thrid_e[1] = thr_e[3] | thr_e[2];
3155
   assign     ifu_tlu_thrid_e[0] = thr_e[3] | thr_e[1];
3156
 
3157
   assign thr_match_de = (thr_d[0] & thr_e[0] |
3158
                                            thr_d[1] & thr_e[1] |
3159
                                            thr_d[2] & thr_e[2] |
3160
                                            thr_d[3] & thr_e[3]);
3161
 
3162
   assign thr_match_dm = (thr_d[0] & thr_m[0] |
3163
                                            thr_d[1] & thr_m[1] |
3164
                                            thr_d[2] & thr_m[2] |
3165
                                            thr_d[3] & thr_m[3]);
3166
 
3167
   dff #(4) thrm_reg(.din   (thr_e),
3168
                   .clk   (clk),
3169
                   .q     (thr_m),
3170
                   .se    (se), .si(), .so());
3171
 
3172
   dff #(4) thrw_reg(.din   (thr_m),
3173
                   .clk   (clk),
3174
                   .q     (thr_w),
3175
                   .se    (se), .si(), .so());
3176
 
3177
   assign sas_thrid_w[1] = thr_w[3] | thr_w[2];
3178
   assign sas_thrid_w[0] = thr_w[3] | thr_w[1];
3179
 
3180
   assign thr_match_fw = (thr_f[0] & thr_w[0] |
3181
                                            thr_f[1] & thr_w[1] |
3182
                                            thr_f[2] & thr_w[2] |
3183
                                            thr_f[3] & thr_w[3]);
3184
 
3185
   assign thr_match_fw2 = (thr_f[0] & thr_w2[0] |
3186
                                             thr_f[1] & thr_w2[1] |
3187
                                             thr_f[2] & thr_w2[2] |
3188
                                             thr_f[3] & thr_w2[3]);
3189
 
3190
   assign thr_match_dw = (thr_d[0] & thr_w[0] |
3191
                                            thr_d[1] & thr_w[1] |
3192
                                            thr_d[2] & thr_w[2] |
3193
                                            thr_d[3] & thr_w[3]);
3194
 
3195
   assign thr_match_dw2 = (thr_d[0] & thr_w2[0] |
3196
                                             thr_d[1] & thr_w2[1] |
3197
                                             thr_d[2] & thr_w2[2] |
3198
                                             thr_d[3] & thr_w2[3]);
3199
 
3200
   assign thr_match_em = (thr_e[0] & thr_m[0] |
3201
                                            thr_e[1] & thr_m[1] |
3202
                                            thr_e[2] & thr_m[2] |
3203
                                            thr_e[3] & thr_m[3]);
3204
 
3205
   assign thr_match_ew = (thr_e_v2[0] & thr_w[0] |
3206
                                            thr_e_v2[1] & thr_w[1] |
3207
                                            thr_e_v2[2] & thr_w[2] |
3208
                                            thr_e_v2[3] & thr_w[3]);
3209
 
3210
   dff #(1) stmw2_ff(.din (thr_match_ew),
3211
                     .q   (same_thr_mw2),
3212
                     .clk (clk), .se (se), .si(), .so());
3213
 
3214
   assign thr_match_ew2 = (thr_e[0] & thr_w2[0] |
3215
                                             thr_e[1] & thr_w2[1] |
3216
                                             thr_e[2] & thr_w2[2] |
3217
                                             thr_e[3] & thr_w2[3]);
3218
 
3219
   assign thr_match_mw = (thr_m[0] & thr_w[0] |
3220
                                            thr_m[1] & thr_w[1] |
3221
                                            thr_m[2] & thr_w[2] |
3222
                                            thr_m[3] & thr_w[3]);
3223
 
3224
   dff #(4) thrw2_reg(.din   (thr_w),
3225
                    .clk   (clk),
3226
                    .q     (thr_w2),
3227
                    .se    (se), .si(), .so());
3228
 
3229
 
3230
//-------------------------
3231
// Rollback
3232
//-------------------------
3233
 
3234
   // 04/05/02
3235
   // Looks like we made a mistake with rollback.  Should never
3236
   // rollback to S.  In the event of a dmiss or mul contention, just
3237
   // kill all the instructions and rollback to F.  This adds one
3238
   // cycle to the dmiss penalty and to the mul latency if we have to
3239
   // wait, both not a very high price to pay.  This would have saved
3240
   // lots of hours of design and verif time.
3241
   //    
3242
   assign rb2_inst_d = thr_match_dw & inst_vld_d & dtu_fcl_rollback_g;
3243
   assign rb1_inst_s = thr_match_fw & inst_vld_s & dtu_fcl_rollback_g;
3244
   assign rb0_inst_bf = thr_match_nw & switch_bf & dtu_fcl_rollback_g;
3245
 
3246
//   assign rt1_inst_s = thr_match_fd & inst_vld_s & retract_inst_d;
3247
//   assign rt0_inst_bf = thr_match_nd & dtu_fcl_ntr_s & retract_inst_d;
3248
 
3249
//   assign retract_iferr_d = thr_match_de & erb_dtu_ifeterr_d1 & inst_vld_d1 &
3250
//                            ~kill_curr_e & fcl_dtu_inst_vld_d;
3251
   assign retract_iferr_d1 = erb_dtu_ifeterr_d1 & inst_vld_d1;
3252
 
3253
   assign retract_inst_d = retract_iferr_d1 & thr_match_de &
3254
                           fcl_dtu_inst_vld_d |
3255
                           mark4rb_d |
3256
                           dtu_fcl_retract_d;
3257
 
3258
   assign rt1_inst_s = thr_match_fd & inst_vld_s & dtu_fcl_retract_d |
3259
                       mark4rb_s;
3260
//                     | thr_match_fe & inst_vld_s & retract_iferr_d1;
3261
 
3262
   // TBD:  This is not necessary since the thread will switch out and
3263
   // stall whatever makes its way to the S stage.
3264
   // NOTE: rb0_inst *is needed* however.
3265
   assign rt0_inst_bf = thr_match_nd & switch_bf & dtu_fcl_retract_d;
3266
//                      | thr_match_ne & dtu_fcl_ntr_s & retract_iferr_d1;
3267
 
3268
   assign retract_iferr_qual_d1 = retract_iferr_d1 & thr_match_de &
3269
                                  fcl_dtu_inst_vld_d &
3270
                                  ~(dtu_fcl_rollback_g & thr_match_ew);
3271
 
3272
   dff rbe_ff(.din (rb2_inst_d),
3273
              .q   (rb2_inst_e),
3274
              .clk (clk),
3275
              .se  (se), .si(), .so());
3276
 
3277
   dff rte_ff(.din (retract_inst_d),
3278
              .q   (rt2_inst_e),
3279
              .clk (clk),
3280
              .se  (se), .si(), .so());
3281
 
3282
   dff rbd_ff(.din (rb1_inst_s),
3283
              .q   (rb1_inst_d),
3284
              .clk (clk),
3285
              .se  (se), .si(), .so());
3286
 
3287
   dff rtd_ff(.din (rt1_inst_s),
3288
              .q   (rt1_inst_d),
3289
              .clk (clk),
3290
              .se  (se), .si(), .so());
3291
 
3292
   dff rbs_ff(.din (rb0_inst_bf),
3293
              .q   (rb0_inst_s),
3294
              .clk (clk),
3295
              .se  (se), .si(), .so());
3296
 
3297
   // TBD: is this necessary?
3298
   dff rts_ff(.din (rt0_inst_bf),
3299
              .q   (rt0_inst_s),
3300
              .clk (clk),
3301
              .se  (se), .si(), .so());
3302
 
3303
   dff rtiferr_ff(.din (retract_iferr_qual_d1),
3304
                  .q   (retract_iferr_e),
3305
                  .clk (clk),
3306
                  .se  (se), .si(), .so());
3307
 
3308
   assign rb_stg_s = (rb0_inst_s | rt0_inst_s) & tm_fd_l |
3309
                           (rb1_inst_d | rt1_inst_d) & ~tm_fd_l;
3310
   assign rb_stg_d_crit = rb1_inst_d | rt1_inst_d;
3311
   assign rb_stg_e = rb2_inst_e | rt2_inst_e;
3312
 
3313
   bw_u1_buf_5x UZsize_rbd_buf(.a (rb_stg_d_crit),
3314
                               .z (rb_stg_d));
3315
 
3316
   // determine rollback amount
3317
   assign rb_frome = {4{(rb2_inst_e | rt2_inst_e) &
3318
                        (inst_vld_e | intr_vld_e)}} & thr_e;
3319
   assign rb_fromd = {4{(rb1_inst_d | rt1_inst_d) &
3320
                        (inst_vld_d | intr_vld_d)}} & thr_d;
3321
   assign rb_froms = {4{rb_stg_s & inst_vld_s_crit}} & thr_f;
3322
   assign rb_w2 = rb_frome | rb_fromd;
3323
   assign rb_for_iferr_e = {4{retract_iferr_e}} & thr_e;
3324
 
3325
//------------------------------   
3326
// Branch Control
3327
//------------------------------
3328
   // final portion of branch evaluation
3329
   wire brtaken_e_l;
3330
   bw_u1_buf_20x UZsize_bcbf(.z(fcl_dcl_regz_e),
3331
                             .a(exu_ifu_regz_e));
3332
 
3333
   bw_u1_muxi21_6x UZsize_bcmux(.z(brtaken_e_l),
3334
                                .d0(dcl_fcl_bcregz0_e),
3335
                                .d1(dcl_fcl_bcregz1_e),
3336
                                .s(exu_ifu_regz_e));
3337
 
3338
   bw_u1_inv_15x UZsize_bcinv(.z(brtaken_e),
3339
                              .a(brtaken_e_l));
3340
 
3341
   // Branch is taken in the E stage to thr_e.  Below we check to see
3342
   // if this is the same as the next thread we will switch to
3343
 
3344
   // isolate non critical section
3345
   bw_u1_buf_5x UZsize_btbuf(.z (brtaken_unq_e),
3346
                             .a (brtaken_e));
3347
   assign brtaken_buf_e = brtaken_unq_e & inst_vld_qual_e & ~kill_curr_e;
3348
 
3349
//   assign thr_match_ne_norst = thr_match_ne & ~rst_sw_bf;
3350
//   assign brto_nxtthr_bf  = thr_match_ne & brtaken_e;
3351
   bw_u1_nand2_4x UZsize_btkn_ntl(.a (brtaken_e),
3352
                                  .b (thr_match_ne),
3353
                                  .z (brto_nxtthr_bf_l));
3354
 
3355
//   bw_u1_inv_8x UZsize_btkn_bf(.a (brto_nxtthr_bf_l),
3356
//                               .z (brto_nxtthr_bf));
3357
 
3358
   dff #(1) br_ff(.din (brtaken_buf_e),
3359
                              .q   (brtaken_m),
3360
                              .clk (clk),
3361
                              .se  (se), .si(), .so());
3362
 
3363
 
3364
//----------------------------------------------------------------------
3365
// PC related control
3366
//----------------------------------------------------------------------
3367
 
3368
   // Choose next IC address
3369
   // IC address is chosen from
3370
   //    1. Next PC assuming no switch 
3371
   //    2. Branch PC if E stage branch is to next thread
3372
   //    3. Saved F stage Thread PC if we switch threads
3373
 
3374
   assign fcl_icd_index_sel_ifq_bf = allow_ifq_access_icd_bf;
3375
   assign fcl_ifq_grant_bf = allow_ifq_access_icd_bf;
3376
 
3377
   // Select branch PC
3378
//   assign fcl_fdp_icaddr_sel_br_bf_l = ~(~all_stallreq &
3379
//                                                                     brto_nxtthr_bf    &
3380
//                                                                     switch_bf);
3381
//
3382
//   // Select the switch PC from thread PC register
3383
//   assign fcl_fdp_icaddr_sel_swpc_bf_l = ~(~all_stallreq &
3384
//                                                                       ~usen_bf &
3385
//                                                                       ~brto_nxtthr_bf &
3386
//                                                                       switch_bf);
3387
//
3388
//   // Select current thread's next PC or IC write addr (PC/PC+4/I$ wraddr)
3389
//   assign fcl_fdp_icaddr_sel_curr_bf_l = ~(~all_stallreq &
3390
//                                                                       ~(stall_f | usep_bf) & 
3391
//                                                                       ~switch_bf);
3392
//   
3393
//   assign fcl_fdp_icaddr_sel_ifq_bf_l = ~(all_stallreq |
3394
//                                                                      (stall_f | usep_bf) & ~switch_bf |
3395
//                                                                      ~brto_nxtthr_bf & usen_bf &
3396
//                                                                      (switch_bf | stall_f | usep_bf));
3397
 
3398
 
3399
 
3400
//   assign sw_or_async_stall = (switch_bf & ~rst_stallreq | rst_sw_bf);
3401
   wire   sw_or_async_stall_l;
3402
   assign rst_stallreq_l = ~rst_stallreq;
3403
   bw_u1_aoi21_4x UZsize_swstl_aoi(.z  (sw_or_async_stall_l),
3404
                                   .a  (rst_sw_bf),
3405
                                   .b1 (switch_bf),
3406
                                   .b2 (rst_stallreq_l));
3407
   assign sw_or_async_stall = ~sw_or_async_stall_l;
3408
 
3409
//   assign icadr_selbr = sw_or_async_stall & brto_nxtthr_bf;
3410
   assign sw_match_ne_norst = sw_or_async_stall & thr_match_ne;
3411
   bw_u1_nand2_10x UZfix_icad_br(.a (brtaken_e),
3412
                                 .b (sw_match_ne_norst),
3413
                                 .z (icadr_selbr_l));
3414
 
3415
//   assign icadr_selsw = sw_or_async_stall & ~brto_nxtthr_bf;
3416
   bw_u1_nand2_15x UZfix_icad_sw(.a (brto_nxtthr_bf_l),
3417
                                 .b (sw_or_async_stall),
3418
                                 .z (icadr_selsw_l));
3419
 
3420
 
3421
   // select next PC
3422
   assign fcl_fdp_pcbf_sel_br_bf_l = icadr_selbr_l;
3423
   assign fcl_fdp_pcbf_sel_swpc_bf_l = icadr_selsw_l ;
3424
   assign fcl_fdp_pcbf_sel_nosw_bf_l = ~sw_or_async_stall_l;
3425
 
3426
   // Select PC to switch to in the event of a switch
3427
   // No need to protect during scan
3428
   // NOTE: SWL guarantees nextthr_bf is one hot
3429
//   assign fcl_fdp_next_thr_bf_l = rst_stallreq_d1 ? ~rstint_penc :
3430
//                                                    ~dtu_fcl_nextthr_bf;
3431
 
3432
   wire [3:0] next_thr_bf_l;
3433
   wire       nt_sel_rst;
3434
   assign     nt_sel_rst = rst_stallreq_d1 | rst_tri_en;
3435
 
3436
   bw_u1_muxi21_2x UZfix_nthr_mx0(.z (next_thr_bf_l[0]),
3437
                                  .d0 (dtu_fcl_nextthr_bf[0]),
3438
                                  .d1 (rstint_penc[0]),
3439
                                  .s  (nt_sel_rst));
3440
   bw_u1_muxi21_2x UZfix_nthr_mx1(.z (next_thr_bf_l[1]),
3441
                                  .d0 (dtu_fcl_nextthr_bf[1]),
3442
                                  .d1 (rstint_penc[1]),
3443
                                  .s  (nt_sel_rst));
3444
   bw_u1_muxi21_2x UZfix_nthr_mx2(.z (next_thr_bf_l[2]),
3445
                                  .d0 (dtu_fcl_nextthr_bf[2]),
3446
                                  .d1 (rstint_penc[2]),
3447
                                  .s  (nt_sel_rst));
3448
   bw_u1_muxi21_2x UZfix_nthr_mx3(.z (next_thr_bf_l[3]),
3449
                                  .d0 (dtu_fcl_nextthr_bf[3]),
3450
                                  .d1 (rstint_penc[3]),
3451
                                  .s  (nt_sel_rst));
3452
   assign     fcl_fdp_next_thr_bf_l = next_thr_bf_l;
3453
 
3454
 
3455
//   assign nextthr_bf_buf = dtu_fcl_nextthr_bf;
3456
   bw_u1_buf_20x UZsize_ntbf0(.a (dtu_fcl_nextthr_bf[0]),
3457
                              .z (nextthr_bf_buf[0]));
3458
   bw_u1_buf_20x UZsize_ntbf1(.a (dtu_fcl_nextthr_bf[1]),
3459
                              .z (nextthr_bf_buf[1]));
3460
   bw_u1_buf_20x UZsize_ntbf2(.a (dtu_fcl_nextthr_bf[2]),
3461
                              .z (nextthr_bf_buf[2]));
3462
   bw_u1_buf_20x UZsize_ntbf3(.a (dtu_fcl_nextthr_bf[3]),
3463
                              .z (nextthr_bf_buf[3]));
3464
   // use 6x
3465
   assign fcl_fdp_next_ctxt_bf_l[2:0] = ~nextthr_bf_buf[2:0] | {3{rst_tri_en}};
3466
   assign fcl_fdp_next_ctxt_bf_l[3] = ~nextthr_bf_buf[3] & ~rst_tri_en;
3467
 
3468
//   assign nextthr_final_bf = switch_bf ? dtu_fcl_nextthr_bf : thr_f;
3469
   wire [3:0] nextthr_final_bf_l;
3470
   bw_u1_muxi21_2x UZfix_ntfmux0(.z  (nextthr_final_bf_l[0]),
3471
                                .d0 (thr_f[0]),
3472
                                .d1 (dtu_fcl_nextthr_bf[0]),
3473
                                .s  (switch_bf));
3474
   bw_u1_inv_8x UZsize_ntfin_buf0(.z (nextthr_final_bf[0]),
3475
                                 .a (nextthr_final_bf_l[0]));
3476
 
3477
   bw_u1_muxi21_2x UZfix_ntfmux1(.z  (nextthr_final_bf_l[1]),
3478
                                .d0 (thr_f[1]),
3479
                                .d1 (dtu_fcl_nextthr_bf[1]),
3480
                                .s  (switch_bf));
3481
   bw_u1_inv_8x UZsize_ntfin_buf1(.z (nextthr_final_bf[1]),
3482
                                 .a (nextthr_final_bf_l[1]));
3483
 
3484
   bw_u1_muxi21_2x UZfix_ntfmux2(.z  (nextthr_final_bf_l[2]),
3485
                                .d0 (thr_f[2]),
3486
                                .d1 (dtu_fcl_nextthr_bf[2]),
3487
                                .s  (switch_bf));
3488
   bw_u1_inv_8x UZsize_ntfin_buf2(.z (nextthr_final_bf[2]),
3489
                                 .a (nextthr_final_bf_l[2]));
3490
 
3491
   bw_u1_muxi21_2x UZfix_ntfmux3(.z  (nextthr_final_bf_l[3]),
3492
                                .d0 (thr_f[3]),
3493
                                .d1 (dtu_fcl_nextthr_bf[3]),
3494
                                .s  (switch_bf));
3495
   bw_u1_inv_8x UZsize_ntfin_buf3(.z (nextthr_final_bf[3]),
3496
                                 .a (nextthr_final_bf_l[3]));
3497
 
3498
 
3499
   // decode trap thread
3500
   dff #(2) ld_trp_reg(.din ({tlu_ifu_trappc_vld_w1,
3501
                              tlu_ifu_trapnpc_vld_w1}),
3502
                       .q   ({trappc_vld_w2,
3503
                              trapnpc_vld_w2}),
3504
                       .clk (clk), .se(se), .si(), .so());
3505
 
3506
   dff #(2) trp_tid_reg(.din (tlu_ifu_trap_tid_w1[1:0]),
3507
                        .q   (trap_tid_w2[1:0]),
3508
                        .clk (clk), .se(se), .si(), .so());
3509
 
3510
   assign trap_thr[0] = ~trap_tid_w2[1] & ~trap_tid_w2[0];
3511
   assign trap_thr[1] = ~trap_tid_w2[1] &  trap_tid_w2[0];
3512
   assign trap_thr[2] =  trap_tid_w2[1] & ~trap_tid_w2[0];
3513
   assign trap_thr[3] =  trap_tid_w2[1] &  trap_tid_w2[0];
3514
 
3515
   assign load_tpc[3:0] = {4{trappc_vld_w2}} & trap_thr |
3516
                           rb_w2 |
3517
                           {4{rb_stg_w | ims_flush_coll_w}} & thr_w |
3518
//                     {4{dec_fcl_kill4sta_e}} & thr_e |
3519
                           {4{flush_sonly_qual_m}} & thr_m;
3520
 
3521
   assign load_bpc[3:0] = {4{brtaken_buf_e}} & thr_e;
3522
   assign load_pcp4[3:0] = {4{~part_stall_thisthr_f &
3523
                              ~iferrto_thisthr_d1 |
3524
                              arst_vld_f |
3525
                              async_intr_vld_s}}     & thr_f;
3526
 
3527
   always @ (/*AUTOSENSE*/load_bpc or load_pcp4 or load_tpc)
3528
     begin
3529
//            if (fcl_reset)
3530
//              begin // RESET PC is loaded to T0
3531
//                 fcl_fdp_tpcbf_sel_old_bf_l = 4'b0001;
3532
//                 fcl_fdp_tpcbf_sel_pcp4_bf_l = 4'b1110;
3533
//                 fcl_fdp_tpcbf_sel_trap_bf_l = 4'b1111;
3534
//                 fcl_fdp_tpcbf_sel_brpc_bf_l = 4'b1111;
3535
//              end // if (reset)
3536
//            else 
3537
//              begin
3538
              fcl_fdp_tpcbf_sel_old_bf_l = (load_bpc | load_tpc | load_pcp4);
3539
              fcl_fdp_tpcbf_sel_brpc_bf_l = ~load_bpc | load_tpc | load_pcp4;
3540
              fcl_fdp_tpcbf_sel_pcp4_bf_l = ~load_pcp4 | load_tpc;
3541
              fcl_fdp_tpcbf_sel_trap_bf_l = ~load_tpc;
3542
     end // always @ (...
3543
 
3544
   // Track correctible errors
3545
   assign irf_ce_m = exu_ifu_ecc_ce_m & ~trap_m & inst_vld_m & ~kill_curr_m;
3546
   dff #(1) irfcew_ff(.din (irf_ce_m),
3547
                                .q   (irf_ce_w),
3548
                                .clk (clk), .se(se), .si(), .so());
3549
 
3550
   // track if ldhit was actually a miss
3551
   // D and S stage are rolled back through the normal D stage retract
3552
   // process.  
3553
   assign mark4rb_d = lsu_ifu_dc_parity_error_w2 & thr_match_dw2 &
3554
                      (inst_vld_d | intr_vld_d);
3555
   assign mark4rb_s = lsu_ifu_dc_parity_error_w2 & thr_match_fw2 &
3556
                      (inst_vld_s | intr_vld_s);
3557
 
3558
   assign mark4rb_e = lsu_ifu_dc_parity_error_w2 & thr_match_ew2 &
3559
                      (inst_vld_e | intr_vld_e) &
3560
                        ~dtu_inst_anull_e & ~kill_curr_e;
3561
 
3562
   dff #(2) markrb_reg(.din ({mark4rb_m,
3563
                              mark4rb_e}),
3564
                       .q   ({mark4rb_w,
3565
                              mark4rb_m}),
3566
                       .clk (clk),
3567
                       .se  (se), .si(), .so());
3568
 
3569
   // Rollback from W on irf/frf ce and on a dcache parity error
3570
   assign rb_stg_w = irf_ce_w & inst_vld_w & no_iftrap_w |
3571
                           ffu_ifu_fst_ce_w & inst_vld_w & no_iftrap_w |
3572
                     rb_intr_w & intr_vld_w |
3573
                     mark4rb_w |
3574
                     fcl_dtu_resum_thr_w |
3575
                                 fcl_dtu_nuke_thr_w;
3576
 
3577
   // flush after hardware micro trap
3578
//   assign ifu_tlu_flush_w = irf_ce_w | fcl_dtu_nuke_thr_w | mark4rb_w |
3579
//                            fcl_dtu_resum_thr_w;
3580
   // very critical
3581
   assign ifu_tlu_flush_m = (exu_ifu_ecc_ce_m & inst_vld_m & ~trap_m |
3582
                             (resumint_m | nuke_thr_m) &
3583
                             intr_vld_m & ~rstint_m |
3584
                             rb_intr_m |
3585
                             mark4rb_m);
3586
   assign utrap_flush_m =  ifu_tlu_flush_m & ~kill_local_m;
3587
   dff #(1) flw_ff(.din (utrap_flush_m),
3588
                   .q   (utrap_flush_w),
3589
                   .clk (clk), .se(se), .si(), .so());
3590
   assign ifu_tlu_flush_w = utrap_flush_w;
3591
   assign fcl_swl_flush_w =  (irf_ce_w & inst_vld_w & no_iftrap_w |
3592
                              rb_intr_w & intr_vld_w |
3593
                              mark4rb_w |
3594
                              fcl_dtu_resum_thr_w |
3595
                                          fcl_dtu_nuke_thr_w);
3596
 
3597
   // tells swl to flush and then wake up
3598
   assign fcl_swl_flush_wake_w = fcl_swl_flush_w & ~mark4rb_w;
3599
 
3600
   // if the same instruction keeps hitting ce's disable ce detection
3601
   // count how many ce's occur to a given thread
3602
   assign any_ce_w = ffu_ifu_fst_ce_w | irf_ce_w;
3603
 
3604
   assign ce_cnt1_nxt = (({4{any_ce_w & inst_vld_w}} & thr_w &
3605
                          ce_cnt0) ^ ce_cnt1) & ~ce_cnt_rst;
3606
   assign ce_cnt0_nxt = (({4{any_ce_w & inst_vld_w}} & thr_w) ^
3607
                         ce_cnt0) & ~ce_cnt_rst;
3608
 
3609
   assign ce_cnt_rst = thr_w & {4{inst_vld_w & ~any_ce_w}} | {4{fcl_reset}};
3610
 
3611
   dff #(8) cecnt_reg(.din ({ce_cnt1_nxt, ce_cnt0_nxt}),
3612
                      .q   ({ce_cnt1, ce_cnt0}),
3613
                      .clk (clk),
3614
                      .se(se), .si(), .so());
3615
 
3616
   // find the count for the current d stage thread
3617
   assign ce_val1_d = (thr_d[0] & ce_cnt1[0] |
3618
                       thr_d[1] & ce_cnt1[1] |
3619
                       thr_d[2] & ce_cnt1[2] |
3620
                       thr_d[3] & ce_cnt1[3]);
3621
 
3622
   assign ce_val0_d = (thr_d[0] & ce_cnt0[0] |
3623
                       thr_d[1] & ce_cnt0[1] |
3624
                       thr_d[2] & ce_cnt0[2] |
3625
                       thr_d[3] & ce_cnt0[3]);
3626
 
3627
   // if count hits 3 disable ce's
3628
   assign disable_ce_d = ce_val1_d & ce_val0_d;
3629
 
3630
   dff #(1) disce_ff(.din (disable_ce_d),
3631
                     .q   (disable_ce_e),
3632
                     .clk (clk), .se(se), .si(), .so());
3633
   assign ifu_exu_disable_ce_e = disable_ce_e;
3634
 
3635
   // select error/trap/utrap rollback PC
3636
   assign fcl_fdp_trrbpc_sel_trap_bf_l =
3637
                                ~({4{trappc_vld_w2}} & trap_thr);
3638
 
3639
   assign fcl_fdp_trrbpc_sel_err_bf_l =
3640
                  ({4{trappc_vld_w2}} & trap_thr) |
3641
                         ~({4{rb_stg_w}} & thr_w);
3642
 
3643
   assign fcl_fdp_trrbpc_sel_rb_bf_l =
3644
                  ({4{trappc_vld_w2}} & trap_thr) |
3645
                               ({4{rb_stg_w}} & thr_w) |
3646
                        ~(rb_frome & rb_fromd);
3647
 
3648
   assign fcl_fdp_trrbpc_sel_pcs_bf_l =
3649
                 ({4{trappc_vld_w2}} & trap_thr) |
3650
                               ({4{rb_stg_w}} & thr_w) |
3651
                         (rb_frome & rb_fromd);
3652
 
3653
   // select next S stage Thr PC
3654
   assign fcl_fdp_nextpcs_sel_pce_f_l = ~rb_frome;
3655
   assign fcl_fdp_nextpcs_sel_pcd_f_l = rb_frome | ~rb_fromd;
3656
   assign fcl_fdp_nextpcs_sel_pcf_f_l = rb_frome | rb_fromd |
3657
                                        ~(thr_f & {4{~part_stall_thisthr_f &
3658
                                               ~iferrto_thisthr_d1 |
3659
                                               arst_vld_f |
3660
                                               async_intr_vld_s}});
3661
   assign fcl_fdp_nextpcs_sel_pcs_f_l = rb_frome | rb_fromd |
3662
                                        (thr_f & {4{~part_stall_thisthr_f &
3663
                                              ~iferrto_thisthr_d1 |
3664
                                              arst_vld_f |
3665
                                              async_intr_vld_s}});
3666
 
3667
   // next S2 stage pc and npc select
3668
   assign thr_f_dec[3:1] = thr_f_crit[3:1] & {3{~rst_tri_en}};
3669
   assign thr_f_dec[0] = thr_f_crit[0] | rst_tri_en;
3670
   assign fcl_fdp_thr_s2_l = ~thr_f_dec;     // thr_f = thr_s2
3671
 
3672
 
3673
   // Select NextPC from
3674
   //    1. Trap NextPC (if the tnpc is valid)
3675
   //    2. reset PC
3676
   //    3. incremented PC (PC+4)
3677
   //    4. old PC (in the event of a stall)
3678
 
3679
   // Load the trap PC to the BF stage NPC.  (The BF stage NPC is used
3680
   // only for storing the next PC from the TLU
3681
   assign fcl_fdp_thrtnpc_sel_tnpc_l = ~({4{trapnpc_vld_w2}} & trap_thr);
3682
 
3683
   assign fcl_fdp_thrtnpc_sel_npcw_l = ({4{trapnpc_vld_w2}} & trap_thr) |
3684
                                               ~({4{rb_stg_w}} & thr_w);
3685
 
3686
   assign fcl_fdp_thrtnpc_sel_pcf_l = ({4{trapnpc_vld_w2}} & trap_thr) |
3687
                                              ({4{rb_stg_w}} & thr_w) |
3688
                                                (~({4{ims_flush_coll_w}} & thr_w) &
3689
                                           ~({4{flush_sonly_qual_m}} & thr_m));
3690
                                       //   {4{dec_fcl_kill4sta_e}} & thr_e);
3691
 
3692
   assign fcl_fdp_thrtnpc_sel_old_l = ({4{trapnpc_vld_w2}} & trap_thr) |
3693
                                              ({4{rb_stg_w}} & thr_w) |
3694
                                              ({4{ims_flush_coll_w}} & thr_w) |
3695
                                        ({4{flush_sonly_qual_m}} & thr_m);
3696
                                         // {4{dec_fcl_kill4sta_e}} & thr_e);
3697
 
3698
   assign ntpc_vld_nxt = fcl_fdp_thrtnpc_sel_old_l |
3699
                               ntpc_vld & ({4{(part_stall_thisthr_f |
3700
                                         iferrto_thisthr_d1) &
3701
                                        ~arst_vld_f &
3702
                                        ~async_intr_vld_s}} | ~thr_f) &
3703
                                  ~({4{trappc_vld_w2}} & trap_thr);
3704
 
3705
   dffr #(4) ntpcv_reg(.din  (ntpc_vld_nxt),
3706
                     .clk  (clk),
3707
                     .q    (ntpc_vld),
3708
                     .rst  (fcl_reset),
3709
                     .se   (se), .si(), .so());
3710
 
3711
   assign ntpc_thisthr = (thr_f[0] & ntpc_vld[0] |
3712
                                            thr_f[1] & ntpc_vld[1] |
3713
                                            thr_f[2] & ntpc_vld[2] |
3714
                                            thr_f[3] & ntpc_vld[3]);
3715
 
3716
//   assign fcl_fdp_noswpc_sel_rst_l_bf = 1'b1; 
3717
   assign fcl_fdp_noswpc_sel_tnpc_l_bf = ~ntpc_thisthr;
3718
   assign fcl_fdp_noswpc_sel_old_l_bf = ntpc_thisthr | inst_vld_f | arst_vld_f;
3719
   assign fcl_fdp_noswpc_sel_inc_l_bf = ntpc_thisthr | ~inst_vld_f & ~arst_vld_f;
3720
 
3721
 
3722
   // Don't need noswpc_sel_old anymore (this is always 1)
3723
//   always @(/*AUTOSENSE*/ntpc_vld or reset or thr_f)
3724
//     begin
3725
//            if (reset)
3726
//              begin
3727
//                 fcl_fdp_noswpc_sel_tnpc_l_bf = 1'b1;
3728
//                 fcl_fdp_noswpc_sel_rst_l_bf = 1'b0;  
3729
//                 fcl_fdp_noswpc_sel_inc_l_bf = 1'b1;
3730
//                 fcl_fdp_noswpc_sel_old_l_bf = 1'b1;
3731
//              end
3732
//            else if ((ntpc_vld & thr_f) != 4'b0000)
3733
//              begin
3734
//                 fcl_fdp_noswpc_sel_tnpc_l_bf = 1'b0;
3735
//                 fcl_fdp_noswpc_sel_rst_l_bf = 1'b1;  
3736
//                 fcl_fdp_noswpc_sel_inc_l_bf = 1'b1;
3737
//                 fcl_fdp_noswpc_sel_old_l_bf = 1'b1;  
3738
//              end // if ((ntpc_vld & thr_f) != 4'b0000)
3739
////    else if (ely_stall_thisthr_f)
3740
////      begin
3741
////         fcl_fdp_noswpc_sel_tnpc_l_bf = 1'b1;
3742
////         fcl_fdp_noswpc_sel_rst_l_bf = 1'b1;        
3743
////         fcl_fdp_noswpc_sel_inc_l_bf = 1'b1;
3744
////         fcl_fdp_noswpc_sel_old_l_bf = 1'b0;             
3745
////      end // if (ely_stall_thisthr_f)
3746
//            else 
3747
//              begin
3748
//                 fcl_fdp_noswpc_sel_tnpc_l_bf = 1'b1;
3749
//                 fcl_fdp_noswpc_sel_rst_l_bf = 1'b1;  
3750
//                 fcl_fdp_noswpc_sel_inc_l_bf = 1'b0;
3751
//                 fcl_fdp_noswpc_sel_old_l_bf = 1'b1;  
3752
//              end // else: 
3753
//            
3754
//     end // always @ (...
3755
 
3756
   // NOTE: direct branch vs indirect branch select goes from dtu to fdp
3757
 
3758
//----------------------------------------------------------------------
3759
// Instruction Register Related Control
3760
//----------------------------------------------------------------------
3761
 
3762
   // use NIR if no read previously
3763
   assign fcl_fdp_usenir_sel_nir_s1 = usenir_s1;
3764
 
3765
 
3766
   assign  fcl_fdp_inst_sel_nop_s_l = ~(ely_stall_thisthr_f |
3767
                                        ~inst_vld_s_crit |
3768
                                        force_intr_s |
3769
                                        immu_fault_f);
3770
 
3771
   assign  fcl_fdp_inst_sel_switch_s_l = ~switch_s2 |
3772
                                        (ely_stall_thisthr_f |
3773
                                         ~inst_vld_s_crit |
3774
                                         force_intr_s |
3775
                                         immu_fault_f);
3776
 
3777
   assign  fcl_fdp_inst_sel_nir_s_l = ~usenir_s1 |
3778
                                        (switch_s2 |
3779
                                         ely_stall_thisthr_f |
3780
                                         ~inst_vld_s_crit |
3781
                                         force_intr_s |
3782
                                         immu_fault_f);
3783
 
3784
   assign  fcl_fdp_inst_sel_curr_s_l = (usenir_s1 |
3785
                                        switch_s2 |
3786
                                        ely_stall_thisthr_f |
3787
                                        ~inst_vld_s_crit |
3788
                                        force_intr_s |
3789
                                        immu_fault_f);
3790
 
3791
 
3792
   // Instruction Output Mux
3793
//   always @ (/*AUTOSENSE*/ely_stall_thisthr_f or force_intr_s
3794
//             or immu_fault_f or inst_vld_s_crit or switch_s2
3795
//             or usenir_s1)
3796
//     begin
3797
//            if (ely_stall_thisthr_f | ~inst_vld_s_crit | force_intr_s | 
3798
//            immu_fault_f) 
3799
//              begin // stalled or imiss
3800
//                 fcl_fdp_inst_sel_nop_s_l = 1'b0;
3801
//                 fcl_fdp_inst_sel_switch_s_l = 1'b1;
3802
//                 fcl_fdp_inst_sel_nir_s_l = 1'b1;
3803
//                 fcl_fdp_inst_sel_curr_s_l = 1'b1;
3804
//              end
3805
//            else if (switch_s2) 
3806
//              begin
3807
//                 fcl_fdp_inst_sel_nop_s_l = 1'b1;
3808
//                 fcl_fdp_inst_sel_switch_s_l = 1'b0;
3809
//                 fcl_fdp_inst_sel_nir_s_l = 1'b1;
3810
//                 fcl_fdp_inst_sel_curr_s_l = 1'b1;
3811
//              end
3812
//            else if (usenir_s1) 
3813
//              begin
3814
//                 fcl_fdp_inst_sel_nop_s_l = 1'b1;
3815
//                 fcl_fdp_inst_sel_switch_s_l = 1'b1;
3816
//                 fcl_fdp_inst_sel_nir_s_l = 1'b0;
3817
//                 fcl_fdp_inst_sel_curr_s_l = 1'b1;
3818
//              end
3819
//            else
3820
//              begin
3821
//                 fcl_fdp_inst_sel_nop_s_l = 1'b1;
3822
//                 fcl_fdp_inst_sel_switch_s_l = 1'b1;
3823
//                 fcl_fdp_inst_sel_nir_s_l = 1'b1;
3824
//                 fcl_fdp_inst_sel_curr_s_l = 1'b0;
3825
//              end // else: !if(switch_s2 | stall_s1)
3826
//     end // always @ (...
3827
 
3828
   // thread IR input muxes
3829
   assign fcl_fdp_tinst_sel_rb_s_l   = ~rb_w2;
3830
   assign fcl_fdp_tinst_sel_ifq_s_l  = rb_w2 | ~ifq_fcl_fill_thr;
3831
   assign fcl_fdp_tinst_sel_curr_s_l = ~val_thr_s1 | rb_w2 | ifq_fcl_fill_thr;
3832
   assign fcl_fdp_tinst_sel_old_s_l  = val_thr_s1 | rb_w2 | ifq_fcl_fill_thr;
3833
 
3834
   // Select rollback instruction
3835
   assign fcl_fdp_rbinst_sel_inste_s = {4{rb2_inst_e | rt2_inst_e}} &
3836
                                       thr_e;
3837
 
3838
   // thread NIR input muxes  (2:1 no need to protect)
3839
   assign fcl_fdp_thr_s1_l = ~thr_s1 | {4{stall_s1}};
3840
 
3841
   // select appropriate NIR
3842
   assign dec_thr_s1_l[0] = ~(thr_s1[0] | rst_tri_en);
3843
   assign dec_thr_s1_l[3:1] = ~(thr_s1[3:1] & {3{~rst_tri_en}});
3844
 
3845
   assign fcl_fdp_nirthr_s1_l = dec_thr_s1_l;
3846
 
3847
 
3848
//--------------------
3849
// rdsr data to exu
3850
//--------------------   
3851
 
3852
   dff #(1) pcrsr_ff(.din  (dec_fcl_rdsr_sel_pc_d),
3853
                               .clk  (clk),
3854
                               .q    (rdsr_sel_pc_e),
3855
                               .se   (se), .si(), .so());
3856
   dff #(1) thrrsr_ff(.din  (dec_fcl_rdsr_sel_thr_d),
3857
                                .clk  (clk),
3858
                                .q    (rdsr_sel_thr_e),
3859
                                .se   (se), .si(), .so());
3860
   // make sure they are exclusive
3861
   assign fcl_fdp_rdsr_sel_pc_e_l = ~rdsr_sel_pc_e;
3862
   assign fcl_fdp_rdsr_sel_thr_e_l = ~(~rdsr_sel_pc_e & rdsr_sel_thr_e);
3863
   assign fcl_fdp_rdsr_sel_ver_e_l = ~(~rdsr_sel_pc_e & ~rdsr_sel_thr_e);
3864
 
3865
//--------------------------------------------------------------
3866
// Reg file control
3867
//--------------------------------------------------------------
3868
 
3869
// Some decode is done here since these signals are in the crit path
3870
 
3871
   // Regfile enables are only power saving features.  So they don't
3872
   // have to be exact, as long as they are on, a super set of when
3873
   // they need to be on.
3874
 
3875
   // Enable rs3 if store or atomic or mov
3876
   assign ifu_exu_ren3_s =  inst_vld_f & fdp_fcl_op_s[1] & fdp_fcl_op3_s[2] &
3877
                            (fdp_fcl_op_s[0] | fdp_fcl_op3_s[5]);
3878
 
3879
   // enable rs2 if i=0 and !branch or CAS
3880
   // cas not fully decoded;  i=inst[13];
3881
   assign ifu_exu_ren2_s = inst_vld_f & fdp_fcl_op_s[1] &
3882
                            (~fdp_fcl_ibit_s |
3883
                             fdp_fcl_op_s[0] & fdp_fcl_op3_s[5]);
3884
 
3885
   // rs1 is read if this is not (a branch on cc or no-op/sethi)
3886
   assign ifu_exu_ren1_s = inst_vld_f & (fdp_fcl_op_s[1] |     // not br/call
3887
                           fdp_fcl_op3_s[4] & fdp_fcl_op3_s[3]);  // BPR
3888
 
3889
   //-------------------------------------
3890
   // Generate oddwin signal for rs and rd
3891
   //-------------------------------------
3892
   assign fcl_fdp_oddwin_s = (exu_ifu_oddwin_s[0] & thr_f[0] |
3893
                              exu_ifu_oddwin_s[1] & thr_f[1] |
3894
                              exu_ifu_oddwin_s[2] & thr_f[2] |
3895
                              exu_ifu_oddwin_s[3] & thr_f[3]);
3896
 
3897
   dff #(1) oddwin_ff(.din (fcl_fdp_oddwin_s),
3898
                                  .clk (clk),
3899
                                  .q   (fcl_imd_oddwin_d),
3900
                                  .se  (se), .si(), .so());
3901
 
3902
 
3903
   sink #(2) s0(.in (sas_thrid_w));
3904
endmodule // sparc_ifu_fcl

powered by: WebSVN 2.1.0

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