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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_ifu_fdp.v] - Blame information for rev 105

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_fdp.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_fdp
24
//  Description:
25
//    The fdp contains the pc's for all four threads and the PC and
26
//    nPC for all pipestages register.  The fetcher also contains two
27
//    adders for doing PC + br_offset and PC + 4.
28
//    The fdp also holds the last fetched icache data for each thread
29
//    and the next instruction register, which has the top half of the
30
//    double instruction bundle which is fetched from the icache.
31
*/
32
////////////////////////////////////////////////////////////////////////
33
// Local header file includes / local defines
34
////////////////////////////////////////////////////////////////////////
35
/*
36
/* ========== Copyright Header Begin ==========================================
37
*
38
* OpenSPARC T1 Processor File: ifu.h
39
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
40
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
41
*
42
* The above named program is free software; you can redistribute it and/or
43
* modify it under the terms of the GNU General Public
44
* License version 2 as published by the Free Software Foundation.
45
*
46
* The above named program is distributed in the hope that it will be
47
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
48
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
49
* General Public License for more details.
50
*
51
* You should have received a copy of the GNU General Public
52
* License along with this work; if not, write to the Free Software
53
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
54
*
55
* ========== Copyright Header End ============================================
56
*/
57
////////////////////////////////////////////////////////////////////////
58
/*
59
//
60
//  Module Name: ifu.h
61
//  Description:
62
//  All ifu defines
63
*/
64
 
65
//--------------------------------------------
66
// Icache Values in IFU::ICD/ICV/ICT/FDP/IFQDP
67
//--------------------------------------------
68
// Set Values
69
 
70
// IC_IDX_HI = log(icache_size/4ways) - 1
71
 
72
 
73
// !!IMPORTANT!! a change to IC_LINE_SZ will mean a change to the code as
74
//   well.  Unfortunately this has not been properly parametrized.
75
//   Changing the IC_LINE_SZ param alone is *not* enough.
76
 
77
 
78
// !!IMPORTANT!! a change to IC_TAG_HI will mean a change to the code as
79
//   well.  Changing the IC_TAG_HI param alone is *not* enough to
80
//   change the PA range. 
81
// highest bit of PA
82
 
83
 
84
 
85
// Derived Values
86
// 4095
87
 
88
 
89
// number of entries - 1 = 511
90
 
91
 
92
// 12
93
 
94
 
95
// 28
96
 
97
 
98
// 7
99
 
100
 
101
// tags for all 4 ways + parity
102
// 116
103
 
104
 
105
// 115
106
 
107
 
108
 
109
//----------------------------------------------------------------------
110
// For thread scheduler in IFU::DTU::SWL
111
//----------------------------------------------------------------------
112
// thread states:  (thr_state[4:0])
113
 
114
 
115
 
116
 
117
 
118
 
119
 
120
 
121
 
122
// thread configuration register bit fields
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
//----------------------------------------------------------------------
131
// For MIL fsm in IFU::IFQ
132
//----------------------------------------------------------------------
133
 
134
 
135
 
136
 
137
 
138
 
139
 
140
 
141
 
142
 
143
 
144
//---------------------------------------------------
145
// Interrupt Block
146
//---------------------------------------------------
147
 
148
 
149
 
150
 
151
 
152
 
153
 
154
//-------------------------------------
155
// IFQ
156
//-------------------------------------
157
// valid bit plus ifill
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
//`ifdef SPARC_L2_64B
172
 
173
 
174
//`else
175
//`define BANK_ID_HI 8
176
//`define BANK_ID_LO 7
177
//`endif
178
 
179
//`define CPX_INV_PA_HI  116
180
//`define CPX_INV_PA_LO  112
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
//----------------------------------------
189
// IFU Traps
190
//----------------------------------------
191
// precise
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
 
206
 
207
// disrupting
208
 
209
 
210
 
211
 
212
 
213
 
214
 
215
 
216
 
217
 
218
 
219
 
220
 
221
 
222
 
223
 
224
//`define VER_MAXTL      {5'b0, fcl_fdp_hprivmode_e, 2'b10}
225
//`define VER_IMPL_MASK  24'h002301
226
 
227
//`define VERSION_REG_HPV  {`VER_MANUF, `VER_IMPL_MASK, `VER_MAXGL, 5'b0, fcl_fdp_hprivmode_e, 2'b10, `VER_MAXWIN}
228
 
229
//`define VERSION_REG      {`VER_MANUF, `VER_IMPL_MASK, `VER_MAXGL, 8'h06, `VER_MAXWIN}
230
 
231
//FPGA_SYN enables all FPGA related modifications
232
 
233
 
234
 
235
 
236
 
237
module sparc_ifu_fdp(/*AUTOARG*/
238
   // Outputs
239
   so, fdp_itlb_ctxt_bf, fdp_icd_vaddr_bf, fdp_icv_index_bf,
240
   fdp_erb_pc_f, fdp_dtu_inst_s, ifu_exu_pc_d, ifu_exu_rs1_s,
241
   ifu_exu_rs2_s, ifu_exu_rs3_s, ifu_tlu_pc_m, ifu_tlu_npc_m,
242
   ifu_tlu_pc_oor_e, ifu_exu_pcver_e, fdp_fcl_swc_s2,
243
   fdp_fcl_pc_oor_vec_f, fdp_fcl_pc_oor_e, fdp_fcl_op_s,
244
   fdp_fcl_op3_s, fdp_fcl_ibit_s,
245
   // Inputs
246
   rclk, se, si, const_maskid, lsu_t0_pctxt_state,
247
   lsu_t1_pctxt_state, lsu_t2_pctxt_state, lsu_t3_pctxt_state,
248
   exu_ifu_brpc_e, tlu_ifu_trappc_w2, tlu_ifu_trapnpc_w2,
249
   tlu_itlb_dmp_nctxt_g, tlu_itlb_dmp_actxt_g, tlu_itlb_tte_tag_w2,
250
   dtu_fdp_thrconf_e, icd_fdp_fetdata_s1, icd_fdp_topdata_s1,
251
   ifq_fdp_fill_inst, fcl_fdp_oddwin_s, fcl_fdp_pcoor_vec_f,
252
   fcl_fdp_pcoor_f, fcl_fdp_mask32b_f, fcl_fdp_addr_mask_d,
253
   fcl_fdp_tctxt_sel_prim, fcl_fdp_usenir_sel_nir_s1,
254
   fcl_fdp_rbinst_sel_inste_s, fcl_fdp_thrtnpc_sel_tnpc_l,
255
   fcl_fdp_thrtnpc_sel_npcw_l, fcl_fdp_thrtnpc_sel_pcf_l,
256
   fcl_fdp_thrtnpc_sel_old_l, fcl_fdp_thr_s1_l,
257
   fcl_fdp_next_thr_bf_l, fcl_fdp_next_ctxt_bf_l, fcl_fdp_thr_s2_l,
258
   fcl_fdp_nirthr_s1_l, fcl_fdp_tpcbf_sel_pcp4_bf_l,
259
   fcl_fdp_tpcbf_sel_brpc_bf_l, fcl_fdp_tpcbf_sel_trap_bf_l,
260
   fcl_fdp_tpcbf_sel_old_bf_l, fcl_fdp_pcbf_sel_swpc_bf_l,
261
   fcl_fdp_pcbf_sel_nosw_bf_l, fcl_fdp_pcbf_sel_br_bf_l,
262
   fcl_fdp_trrbpc_sel_trap_bf_l, fcl_fdp_trrbpc_sel_rb_bf_l,
263
   fcl_fdp_trrbpc_sel_err_bf_l, fcl_fdp_trrbpc_sel_pcs_bf_l,
264
   fcl_fdp_noswpc_sel_tnpc_l_bf, fcl_fdp_noswpc_sel_old_l_bf,
265
   fcl_fdp_noswpc_sel_inc_l_bf, fcl_fdp_nextpcs_sel_pce_f_l,
266
   fcl_fdp_nextpcs_sel_pcd_f_l, fcl_fdp_nextpcs_sel_pcs_f_l,
267
   fcl_fdp_nextpcs_sel_pcf_f_l, fcl_fdp_rdsr_sel_pc_e_l,
268
   fcl_fdp_rdsr_sel_ver_e_l, fcl_fdp_rdsr_sel_thr_e_l,
269
   fcl_fdp_inst_sel_curr_s_l, fcl_fdp_inst_sel_switch_s_l,
270
   fcl_fdp_inst_sel_nir_s_l, fcl_fdp_inst_sel_nop_s_l,
271
   fcl_fdp_tinst_sel_curr_s_l, fcl_fdp_tinst_sel_rb_s_l,
272
   fcl_fdp_tinst_sel_old_s_l, fcl_fdp_tinst_sel_ifq_s_l,
273
   fcl_fdp_dmpthr_l, fcl_fdp_ctxt_sel_dmp_bf_l,
274
   fcl_fdp_ctxt_sel_sw_bf_l, fcl_fdp_ctxt_sel_curr_bf_l
275
   );
276
 
277
   input       rclk,
278
                     se,
279
                     si;
280
 
281
   input [7:0] const_maskid;
282
 
283
   input [12:0] lsu_t0_pctxt_state,   // primary context
284
                            lsu_t1_pctxt_state,
285
                            lsu_t2_pctxt_state,
286
                            lsu_t3_pctxt_state;
287
 
288
   //   input    exu_ifu_va_oor_e;
289
   input [47:0] exu_ifu_brpc_e;        // br address for dir branch
290
 
291
   input [48:0] tlu_ifu_trappc_w2,     // trap/exception PC
292
                            tlu_ifu_trapnpc_w2;    // next trap PC
293
 
294
   input        tlu_itlb_dmp_nctxt_g,
295
                            tlu_itlb_dmp_actxt_g;
296
 
297
   input [12:0] tlu_itlb_tte_tag_w2;
298
 
299
//   input [`IC_IDX_HI:4] ifq_fdp_icindex_bf;   // index + 1 bit for 16B write
300
 
301
   input [40:0]         dtu_fdp_thrconf_e;
302
 
303
   input [32:0]         icd_fdp_fetdata_s1,    // 4 inst + 4 sw bits
304
                                    icd_fdp_topdata_s1;    // next instruction
305
 
306
   input [32:0]         ifq_fdp_fill_inst;    // icache miss return
307
 
308
   input                fcl_fdp_oddwin_s;
309
   input [3:0]          fcl_fdp_pcoor_vec_f;
310
   input                fcl_fdp_pcoor_f;
311
   input                fcl_fdp_mask32b_f;
312
   input                fcl_fdp_addr_mask_d;
313
   input [3:0]          fcl_fdp_tctxt_sel_prim;
314
 
315
   // 2:1 mux selects
316
   input                fcl_fdp_usenir_sel_nir_s1;   // same as usenir_d2
317
   input [3:0]          fcl_fdp_rbinst_sel_inste_s;  // rollback 1 or 2 
318
 
319
   input [3:0]          fcl_fdp_thrtnpc_sel_tnpc_l,  // load npc
320
                              fcl_fdp_thrtnpc_sel_npcw_l,
321
                                    fcl_fdp_thrtnpc_sel_pcf_l,
322
                              fcl_fdp_thrtnpc_sel_old_l;
323
 
324
   input [3:0]          fcl_fdp_thr_s1_l;            // s2 thr (64*5 muxes)
325
 
326
   // other mux selects
327
   input [3:0]          fcl_fdp_next_thr_bf_l;  // for thrpc output mux
328
   input [3:0]          fcl_fdp_next_ctxt_bf_l; // for ctxt output mux
329
 
330
   input [3:0]          fcl_fdp_thr_s2_l;       // s2 thr (64*5 muxes)
331
   input [3:0]          fcl_fdp_nirthr_s1_l;        // same as thr_s1, but protected
332
 
333
   input [3:0]          fcl_fdp_tpcbf_sel_pcp4_bf_l, // selects for thread PC muxes
334
                              fcl_fdp_tpcbf_sel_brpc_bf_l,
335
                              fcl_fdp_tpcbf_sel_trap_bf_l,
336
                              fcl_fdp_tpcbf_sel_old_bf_l;
337
 
338
   input                fcl_fdp_pcbf_sel_swpc_bf_l,
339
                              fcl_fdp_pcbf_sel_nosw_bf_l,
340
                              fcl_fdp_pcbf_sel_br_bf_l;
341
 
342
   input [3:0]          fcl_fdp_trrbpc_sel_trap_bf_l,
343
                              fcl_fdp_trrbpc_sel_rb_bf_l,
344
                              fcl_fdp_trrbpc_sel_err_bf_l,
345
                              fcl_fdp_trrbpc_sel_pcs_bf_l;
346
 
347
   input                fcl_fdp_noswpc_sel_tnpc_l_bf,    // next pc select from trap,
348
                              fcl_fdp_noswpc_sel_old_l_bf,
349
                              fcl_fdp_noswpc_sel_inc_l_bf;
350
 
351
   input [3:0]          fcl_fdp_nextpcs_sel_pce_f_l,
352
                              fcl_fdp_nextpcs_sel_pcd_f_l,
353
                              fcl_fdp_nextpcs_sel_pcs_f_l,
354
                              fcl_fdp_nextpcs_sel_pcf_f_l;
355
 
356
   input                fcl_fdp_rdsr_sel_pc_e_l,
357
                              fcl_fdp_rdsr_sel_ver_e_l,
358
                              fcl_fdp_rdsr_sel_thr_e_l;
359
 
360
   input                fcl_fdp_inst_sel_curr_s_l,       // selects for inst_s2
361
                              fcl_fdp_inst_sel_switch_s_l,
362
                              fcl_fdp_inst_sel_nir_s_l,
363
                              fcl_fdp_inst_sel_nop_s_l;
364
 
365
   input [3:0]          fcl_fdp_tinst_sel_curr_s_l, // selects for tinst regs
366
                              fcl_fdp_tinst_sel_rb_s_l,
367
                              fcl_fdp_tinst_sel_old_s_l,
368
                              fcl_fdp_tinst_sel_ifq_s_l;
369
 
370
   input [3:0]          fcl_fdp_dmpthr_l;
371
 
372
   input                fcl_fdp_ctxt_sel_dmp_bf_l,
373
                              fcl_fdp_ctxt_sel_sw_bf_l,
374
                              fcl_fdp_ctxt_sel_curr_bf_l;
375
 
376
 
377
   output               so;
378
   output [12:0]        fdp_itlb_ctxt_bf;
379
   output [47:2]        fdp_icd_vaddr_bf;   // 11:2 is index to ic
380
   output [11:5]        fdp_icv_index_bf;
381
   output [47:0]        fdp_erb_pc_f;
382
   output [31:0]        fdp_dtu_inst_s;     // 32b inst + switch bit 
383
 
384
   output [47:0]        ifu_exu_pc_d;       // PC for rel branch
385
   output [4:0]         ifu_exu_rs1_s,      // reg file read address
386
                                    ifu_exu_rs2_s,
387
                                    ifu_exu_rs3_s;
388
 
389
   output [48:0]        ifu_tlu_pc_m,
390
                                    ifu_tlu_npc_m;
391
 
392
   output               ifu_tlu_pc_oor_e;
393
 
394
   output [63:0]        ifu_exu_pcver_e;    // PCs to different dests.
395
 
396
   output               fdp_fcl_swc_s2;       // tells whether to switch or not
397
   output [3:0]         fdp_fcl_pc_oor_vec_f; // PC va hole check
398
   output               fdp_fcl_pc_oor_e;
399
 
400
   output [1:0]         fdp_fcl_op_s;
401
   output [5:2]         fdp_fcl_op3_s;
402
   output               fdp_fcl_ibit_s;
403
 
404
 
405
 
406
 
407
//----------------------------------------------------------------------
408
// Declarations
409
//----------------------------------------------------------------------
410
 
411
   // local signals
412
 
413
   // Contexts
414
   wire [12:0]   curr_ctxt,
415
                            sw_ctxt,
416
                            dmp_ctxt,
417
                            dmp_ctxt_unq,
418
                            dmp_ctxt1,
419
                            dmp_ctxt2,
420
                            t0_ctxt_bf,
421
                            t1_ctxt_bf,
422
                            t2_ctxt_bf,
423
                            t3_ctxt_bf;
424
 
425
   // PCs
426
   wire [48:0]  t0pc_f, t1pc_f, t2pc_f, t3pc_f,         // F stage thread PC
427
                            t0pc_s, t1pc_s, t2pc_s, t3pc_s,         // S stage thr pc
428
                            t0_next_pcs_f, t1_next_pcs_f, t2_next_pcs_f, t3_next_pcs_f,
429
                            t0npc_bf, t1npc_bf, t2npc_bf, t3npc_bf, // Next PC in
430
                                                                                                  // BF stage
431
                            pc_s, pc_d, pc_e, pc_m, pc_w,
432
                            npc_s, npc_d, npc_e, npc_m, npc_w,
433
                            pc_d_adj, npc_d_adj;
434
 
435
   wire [47:0]  pc_bf,
436
                            swpc_bf,                // PC of next thread if not branch
437
                pc_f;
438
 
439
   wire [48:0]  nextpc_nosw_bf,         // next pc if no switch
440
                            am_mask;
441
 
442
   // trap PCs and rollback PCs
443
   wire [48:0]  t0_trap_rb_pc_bf,
444
                            t1_trap_rb_pc_bf,
445
                            t2_trap_rb_pc_bf,
446
                            t3_trap_rb_pc_bf;
447
 
448
   wire [48:0]  thr_trappc_bf,
449
                            t0_trapnpc_f,
450
                            t1_trapnpc_f,
451
                            t2_trapnpc_f,
452
                            t3_trapnpc_f,
453
                            trapnpc0_bf,
454
                            trapnpc1_bf,
455
                            trapnpc2_bf,
456
                            trapnpc3_bf;
457
 
458
   // Branch PCs
459
   wire [48:0]  pcinc_f;                // incr output
460
 
461
   // Instruction Words
462
   wire [32:0]  inst_s2,                // instruction to switch to in S
463
                            fdp_inst_s,             // instruction to be sent to D
464
                            t0inst_s1,              // input to thr inst reg in S
465
                            t1inst_s1,
466
                            t2inst_s1,
467
                            t3inst_s1,
468
                            t0inst_s2,              // thr inst reg output
469
                            t1inst_s2,
470
                            t2inst_s2,
471
                            t3inst_s2;
472
 
473
   wire [32:0]  inst_s1;                // fetched instruction in S
474
   wire [32:0]  inst_s1_bf1;            // buf version of inst_s1
475
 
476
   wire [32:0]  rb_inst0_s,             // instruction to rollback to
477
                            rb_inst1_s,             // instruction to rollback to
478
                            rb_inst2_s,             // instruction to rollback to
479
                            rb_inst3_s,             // instruction to rollback to
480
                            inst_d,                 //   rollback 1
481
                            inst_e;                 //   rollback 2
482
 
483
   // Next instruction word
484
   wire [32:0]  nirdata_s1,             // next inst reg contents
485
                            t0nir,                  // thread NIR reg output
486
                            t1nir,
487
                            t2nir,
488
                            t3nir;
489
 
490
   wire         clk;
491
 
492
 
493
   //
494
   // Code start here 
495
   //
496
   assign       clk = rclk;
497
 
498
//----------------------------------------------------------------------
499
// Context Reg
500
//----------------------------------------------------------------------
501
   assign t0_ctxt_bf = lsu_t0_pctxt_state & {13{fcl_fdp_tctxt_sel_prim[0]}};
502
 
503
 
504
 
505
 
506
 
507
 
508
 
509
 
510
 
511
   assign t1_ctxt_bf = lsu_t1_pctxt_state & {13{fcl_fdp_tctxt_sel_prim[1]}};
512
   assign t2_ctxt_bf = lsu_t2_pctxt_state & {13{fcl_fdp_tctxt_sel_prim[2]}};
513
   assign t3_ctxt_bf = lsu_t3_pctxt_state & {13{fcl_fdp_tctxt_sel_prim[3]}};
514
 
515
   dp_mux4ds #(13) sw_ctxt_mux(.dout (sw_ctxt),
516
                               .in0  (t0_ctxt_bf),
517
                               .in1  (t1_ctxt_bf),
518
                               .in2  (t2_ctxt_bf),
519
                               .in3  (t3_ctxt_bf),
520
                               .sel0_l (fcl_fdp_next_ctxt_bf_l[0]),
521
                               .sel1_l (fcl_fdp_next_ctxt_bf_l[1]),
522
                               .sel2_l (fcl_fdp_next_ctxt_bf_l[2]),
523
                               .sel3_l (fcl_fdp_next_ctxt_bf_l[3]));
524
 
525
   dp_mux4ds #(13) curr_ctxt_mux(.dout (curr_ctxt),
526
                             .in0  (t0_ctxt_bf),
527
                             .in1  (t1_ctxt_bf),
528
                             .in2  (t2_ctxt_bf),
529
                             .in3  (t3_ctxt_bf),
530
                             .sel0_l (fcl_fdp_thr_s2_l[0]),
531
                             .sel1_l (fcl_fdp_thr_s2_l[1]),
532
                             .sel2_l (fcl_fdp_thr_s2_l[2]),
533
                             .sel3_l (fcl_fdp_thr_s2_l[3]));
534
 
535
   dp_mux4ds #(13) dmp_ctxt_mux(.dout (dmp_ctxt_unq),
536
                              .in0  (lsu_t0_pctxt_state),
537
                              .in1  (lsu_t1_pctxt_state),
538
                              .in2  (lsu_t2_pctxt_state),
539
                              .in3  (lsu_t3_pctxt_state),
540
                              .sel0_l (fcl_fdp_dmpthr_l[0]),
541
                              .sel1_l (fcl_fdp_dmpthr_l[1]),
542
                              .sel2_l (fcl_fdp_dmpthr_l[2]),
543
                              .sel3_l (fcl_fdp_dmpthr_l[3]));
544
 // !`ifdef FPGA_SYN_1THREAD
545
 
546
   assign dmp_ctxt1 = dmp_ctxt_unq & {13{~(tlu_itlb_dmp_nctxt_g |
547
                                                                         tlu_itlb_dmp_actxt_g)}};
548
//`ifdef SPARC_HPV_EN   
549
   assign dmp_ctxt2 = {tlu_itlb_tte_tag_w2[12:7],tlu_itlb_tte_tag_w2[6:0]} &
550
                            {13{tlu_itlb_dmp_actxt_g}};
551
//`else
552
//  assign dmp_ctxt2 = {tlu_itlb_tte_tag_w2[13:8],tlu_itlb_tte_tag_w2[6:0]} & 
553
//                          {13{tlu_itlb_dmp_actxt_g}};
554
//`endif   
555
 
556
   assign dmp_ctxt = dmp_ctxt1 | dmp_ctxt2;
557
 
558
   dp_mux3ds #(13) ctxt_mux (.dout (fdp_itlb_ctxt_bf),
559
                                             .in0  (curr_ctxt),
560
                                             .in1  (sw_ctxt),
561
                                             .in2  (dmp_ctxt),
562
                                             .sel0_l  (fcl_fdp_ctxt_sel_curr_bf_l),
563
                                             .sel1_l  (fcl_fdp_ctxt_sel_sw_bf_l),
564
                                             .sel2_l  (fcl_fdp_ctxt_sel_dmp_bf_l));
565
 
566
 
567
// ----------------------------------------------------------------------
568
// PC datapath    
569
// ----------------------------------------------------------------------
570
 
571
   // pc/thr to exu for rdsr instruction
572
   // this is the only 64 bit cell in the IFU
573
   dp_mux3ds #(64) ver_mux(.dout (ifu_exu_pcver_e[63:0]),
574
                                           .in0  ({{16{pc_e[47]}}, pc_e[47:0]}),
575
                                           .in1  ({16'h003e,
576
                                 16'h0023,
577
                                 const_maskid[7:0],
578
                                 8'h03,
579
                                 8'h06,
580
                                 8'h07}),
581
                                           .in2  ({12'b0,
582
                                 dtu_fdp_thrconf_e[40:29],
583
                                 4'b0,
584
                                 dtu_fdp_thrconf_e[28:9],
585
                                 2'b0,
586
                                 dtu_fdp_thrconf_e[8:3],
587
                                 5'b0,
588
                                 dtu_fdp_thrconf_e[2:0]}),
589
                                           .sel0_l  (fcl_fdp_rdsr_sel_pc_e_l),
590
                                           .sel1_l  (fcl_fdp_rdsr_sel_ver_e_l),
591
                                           .sel2_l  (fcl_fdp_rdsr_sel_thr_e_l));
592
 
593
   // Select the next thread pc (for F stage)
594
   dp_mux4ds #(49) t0_pcbf_mux(.dout (t0npc_bf),
595
                                               .in0 ({fcl_fdp_pcoor_vec_f[0], t0pc_f[47:0]}),
596
                                               .in1 (nextpc_nosw_bf),
597
                                               .in2 (t0_trap_rb_pc_bf),
598
                                               .in3 ({1'b0, exu_ifu_brpc_e}),
599
                                               .sel0_l (fcl_fdp_tpcbf_sel_old_bf_l[0]),
600
                                               .sel1_l (fcl_fdp_tpcbf_sel_pcp4_bf_l[0]),
601
                                               .sel2_l (fcl_fdp_tpcbf_sel_trap_bf_l[0]),
602
                                               .sel3_l (fcl_fdp_tpcbf_sel_brpc_bf_l[0]));
603
 
604
 
605
 
606
   dp_mux4ds #(49) t1_pcbf_mux(.dout (t1npc_bf),
607
                                               .in0 ({fcl_fdp_pcoor_vec_f[1], t1pc_f[47:0]}),
608
                                               .in1 (nextpc_nosw_bf),
609
                                               .in2 (t1_trap_rb_pc_bf),
610
                                               .in3 ({1'b0, exu_ifu_brpc_e}),
611
                                               .sel0_l (fcl_fdp_tpcbf_sel_old_bf_l[1]),
612
                                               .sel1_l (fcl_fdp_tpcbf_sel_pcp4_bf_l[1]),
613
                                               .sel2_l (fcl_fdp_tpcbf_sel_trap_bf_l[1]),
614
                                               .sel3_l (fcl_fdp_tpcbf_sel_brpc_bf_l[1]));
615
 
616
   dp_mux4ds #(49) t2_pcbf_mux(.dout (t2npc_bf),
617
                                               .in0 ({fcl_fdp_pcoor_vec_f[2], t2pc_f[47:0]}),
618
                                               .in1 (nextpc_nosw_bf),
619
                                               .in2 (t2_trap_rb_pc_bf),
620
                                               .in3 ({1'b0, exu_ifu_brpc_e}),
621
                                               .sel0_l (fcl_fdp_tpcbf_sel_old_bf_l[2]),
622
                                               .sel1_l (fcl_fdp_tpcbf_sel_pcp4_bf_l[2]),
623
                                               .sel2_l (fcl_fdp_tpcbf_sel_trap_bf_l[2]),
624
                                               .sel3_l (fcl_fdp_tpcbf_sel_brpc_bf_l[2]));
625
 
626
   dp_mux4ds #(49) t3_pcbf_mux(.dout (t3npc_bf),
627
                                               .in0 ({fcl_fdp_pcoor_vec_f[3], t3pc_f[47:0]}),
628
                                               .in1 (nextpc_nosw_bf),
629
                                               .in2 (t3_trap_rb_pc_bf),
630
                                               .in3 ({1'b0, exu_ifu_brpc_e}),
631
                                               .sel0_l (fcl_fdp_tpcbf_sel_old_bf_l[3]),
632
                                               .sel1_l (fcl_fdp_tpcbf_sel_pcp4_bf_l[3]),
633
                                               .sel2_l (fcl_fdp_tpcbf_sel_trap_bf_l[3]),
634
                                               .sel3_l (fcl_fdp_tpcbf_sel_brpc_bf_l[3]));
635
 
636
 
637
   // F stage thread PC regs;  use low power thr flop
638
   dff  #(49)  t0_pcf_reg(.din (t0npc_bf),
639
                                          .clk (clk),
640
                                          .q   (t0pc_f),
641
                                          .se  (se), .si(), .so());
642
 
643
 
644
 
645
 
646
   dff  #(49)  t1_pcf_reg(.din (t1npc_bf),
647
                                          .clk (clk),
648
                                          .q   (t1pc_f),
649
                                          .se  (se), .si(), .so());
650
   dff  #(49)  t2_pcf_reg(.din (t2npc_bf),
651
                                          .clk (clk),
652
                                          .q   (t2pc_f),
653
                                          .se  (se), .si(), .so());
654
   dff  #(49)  t3_pcf_reg(.din (t3npc_bf),
655
                                          .clk (clk),
656
                                          .q   (t3pc_f),
657
                                          .se  (se), .si(), .so());
658
 
659
   assign fdp_fcl_pc_oor_vec_f = {t3pc_f[48], t2pc_f[48],
660
                                                          t1pc_f[48], t0pc_f[48]};
661
 
662
 
663
   // select the pc to be used on a switch -- need to protect
664
   dp_mux4ds #(48) swpc_mux(.dout (swpc_bf),
665
                                            .in0 (t0pc_f[47:0]),
666
                                            .in1 (t1pc_f[47:0]),
667
                                            .in2 (t2pc_f[47:0]),
668
                                            .in3 (t3pc_f[47:0]),
669
                                            .sel0_l (fcl_fdp_next_thr_bf_l[0]),
670
                                            .sel1_l (fcl_fdp_next_thr_bf_l[1]),
671
                                            .sel2_l (fcl_fdp_next_thr_bf_l[2]),
672
                                            .sel3_l (fcl_fdp_next_thr_bf_l[3]));
673
 
674
 
675
   // choose between I$ write address and read address
676
   // need mux only for lower 11 bits (2+3 + ICINDEX_SIZE)
677
//   dp_mux2es #(48) ifqfdp_mux(.dout (icaddr_nosw_bf[47:0]),
678
//           .in0  (nextpc_nosw_bf[47:0]), 
679
//           .in1  ({{37{1'b0}}, ifq_fdp_icindex_bf, 4'b0}),
680
//           .sel  (fcl_fdp_ifqfdp_sel_ifq_bf));  // 1=ifq
681
 
682
   // implements switch and branch
683
   // can we cut this down to 11 bits? No! tlb needs all 48
684
 
685
//   dp_mux4ds #(48) nxt_icaddr_mux(.dout  (icaddr_bf),
686
//                                                      .in0   (swpc_bf[47:0]), 
687
//                                                      .in1   (nextpc_nosw_bf[47:0]),
688
//                                                      .in2   ({8'b0, {`IC_TAG_SZ{1'b0}}, 
689
//                                         ifq_fdp_icindex_bf, 4'b0}),
690
//                                                      .in3   (exu_ifu_brpc_e[47:0]), 
691
//                                                      .sel0_l (fcl_fdp_icaddr_sel_swpc_bf_l),
692
//                                                      .sel1_l (fcl_fdp_icaddr_sel_curr_bf_l),
693
//                                                      .sel2_l (fcl_fdp_icaddr_sel_ifq_bf_l),
694
//                                                      .sel3_l (fcl_fdp_icaddr_sel_br_bf_l));
695
 
696
//   assign fdp_icd_vaddr_bf = icaddr_bf[47:0];
697
   // this goes to the itlb, icd and ict on top of fdp
698
   // this is !!very critical!!
699
   assign fdp_icd_vaddr_bf = pc_bf[47:2];
700
 
701
   // create separate output for the icv to the left
702
   assign fdp_icv_index_bf = pc_bf[11:5];
703
 
704
   // Place this mux as close to the top (itlb) as possible
705
   dp_mux3ds #(48) pcbf_mux(.dout  (pc_bf[47:0]),
706
                          .in0   (swpc_bf[47:0]),
707
                          .in1   (nextpc_nosw_bf[47:0]),
708
                          .in2   (exu_ifu_brpc_e[47:0]),
709
                          .sel0_l (fcl_fdp_pcbf_sel_swpc_bf_l),
710
                          .sel1_l (fcl_fdp_pcbf_sel_nosw_bf_l),
711
                          .sel2_l (fcl_fdp_pcbf_sel_br_bf_l));
712
 
713
   dff #(48)  pcf_reg(.din  (pc_bf),
714
                    .clk  (clk),
715
                    .q    (pc_f),
716
                    .se   (se), .si(), .so());
717
 
718
   assign fdp_erb_pc_f = pc_f[47:0];
719
 
720
    // trappc mux (choose trap pc vs rollback/uTrap pc)
721
   dp_mux4ds #(49) trap_pc0_mux(.dout (t0_trap_rb_pc_bf),
722
                              .in0  (tlu_ifu_trappc_w2),
723
                              .in1  (pc_d_adj),
724
                              .in2  (t0pc_s),
725
                              .in3  (pc_w),
726
                              .sel0_l  (fcl_fdp_trrbpc_sel_trap_bf_l[0]),
727
                              .sel1_l  (fcl_fdp_trrbpc_sel_rb_bf_l[0]),
728
                              .sel2_l  (fcl_fdp_trrbpc_sel_pcs_bf_l[0]),
729
                              .sel3_l  (fcl_fdp_trrbpc_sel_err_bf_l[0]));
730
 
731
 
732
 
733
   dp_mux4ds #(49) trap_pc1_mux(.dout (t1_trap_rb_pc_bf),
734
                              .in0  (tlu_ifu_trappc_w2),
735
                              .in1  (pc_d_adj),
736
                              .in2  (t1pc_s),
737
                              .in3  (pc_w),
738
                              .sel0_l  (fcl_fdp_trrbpc_sel_trap_bf_l[1]),
739
                              .sel1_l  (fcl_fdp_trrbpc_sel_rb_bf_l[1]),
740
                              .sel2_l  (fcl_fdp_trrbpc_sel_pcs_bf_l[1]),
741
                              .sel3_l  (fcl_fdp_trrbpc_sel_err_bf_l[1]));
742
 
743
   dp_mux4ds #(49) trap_pc2_mux(.dout (t2_trap_rb_pc_bf),
744
                              .in0  (tlu_ifu_trappc_w2),
745
                              .in1  (pc_d_adj),
746
                              .in2  (t2pc_s),
747
                              .in3  (pc_w),
748
                              .sel0_l  (fcl_fdp_trrbpc_sel_trap_bf_l[2]),
749
                              .sel1_l  (fcl_fdp_trrbpc_sel_rb_bf_l[2]),
750
                              .sel2_l  (fcl_fdp_trrbpc_sel_pcs_bf_l[2]),
751
                              .sel3_l  (fcl_fdp_trrbpc_sel_err_bf_l[2]));
752
 
753
   dp_mux4ds #(49) trap_pc3_mux(.dout (t3_trap_rb_pc_bf),
754
                              .in0  (tlu_ifu_trappc_w2),
755
                              .in1  (pc_d_adj),
756
                              .in2  (t3pc_s),
757
                              .in3  (pc_w),
758
                              .sel0_l  (fcl_fdp_trrbpc_sel_trap_bf_l[3]),
759
                              .sel1_l  (fcl_fdp_trrbpc_sel_rb_bf_l[3]),
760
                              .sel2_l  (fcl_fdp_trrbpc_sel_pcs_bf_l[3]),
761
                              .sel3_l  (fcl_fdp_trrbpc_sel_err_bf_l[3]));
762
 
763
 
764
 
765
   // can reduce this to a 2:1 mux since reset pc is not used any more and
766
   // pc_f is not needed.
767
   dp_mux3ds #(49) pcp4_mux(.dout  (nextpc_nosw_bf),
768
                          .in0   (pcinc_f),
769
                          .in1   (thr_trappc_bf),
770
                          .in2   ({fcl_fdp_pcoor_f, pc_f[47:0]}),
771
                          .sel0_l (fcl_fdp_noswpc_sel_inc_l_bf),
772
                          .sel1_l (fcl_fdp_noswpc_sel_tnpc_l_bf),
773
                          .sel2_l (fcl_fdp_noswpc_sel_old_l_bf));
774
 
775
 
776
   // next S stage thread pc mux per thread
777
   // Use advtpcs signal which works for stall (Aug '01)
778
   // Merged pc_e/pc_d into the eqn to allow for rollback
779
   dp_mux4ds #(49) t0pcf_mux(.dout (t0_next_pcs_f),
780
                           .in0  (t0pc_s),
781
                           .in1  ({fcl_fdp_pcoor_vec_f[0], t0pc_f[47:0]}),
782
                           .in2  (pc_d_adj),
783
                           .in3  (pc_e),
784
                           .sel0_l (fcl_fdp_nextpcs_sel_pcs_f_l[0]),
785
                           .sel1_l (fcl_fdp_nextpcs_sel_pcf_f_l[0]),
786
                           .sel2_l (fcl_fdp_nextpcs_sel_pcd_f_l[0]),
787
                           .sel3_l (fcl_fdp_nextpcs_sel_pce_f_l[0]));
788
 
789
 
790
 
791
   dp_mux4ds #(49) t1pcf_mux(.dout (t1_next_pcs_f),
792
                           .in0  (t1pc_s),
793
                           .in1  ({fcl_fdp_pcoor_vec_f[1], t1pc_f[47:0]}),
794
                           .in2  (pc_d_adj),
795
                           .in3  (pc_e),
796
                           .sel0_l (fcl_fdp_nextpcs_sel_pcs_f_l[1]),
797
                           .sel1_l (fcl_fdp_nextpcs_sel_pcf_f_l[1]),
798
                           .sel2_l (fcl_fdp_nextpcs_sel_pcd_f_l[1]),
799
                           .sel3_l (fcl_fdp_nextpcs_sel_pce_f_l[1]));
800
 
801
   dp_mux4ds #(49) t2pcf_mux(.dout (t2_next_pcs_f),
802
                           .in0  (t2pc_s),
803
                           .in1  ({fcl_fdp_pcoor_vec_f[2], t2pc_f[47:0]}),
804
//                         .in1  ({fcl_fdp_pcoor_f, pc_f[47:0]}),
805
                           .in2  (pc_d_adj),
806
                           .in3  (pc_e),
807
                           .sel0_l (fcl_fdp_nextpcs_sel_pcs_f_l[2]),
808
                           .sel1_l (fcl_fdp_nextpcs_sel_pcf_f_l[2]),
809
                           .sel2_l (fcl_fdp_nextpcs_sel_pcd_f_l[2]),
810
                           .sel3_l (fcl_fdp_nextpcs_sel_pce_f_l[2]));
811
 
812
   dp_mux4ds #(49) t3pcf_mux(.dout (t3_next_pcs_f),
813
                           .in0  (t3pc_s),
814
                           .in1  ({fcl_fdp_pcoor_vec_f[3], t3pc_f[47:0]}),
815
//                         .in1  ({fcl_fdp_pcoor_f, pc_f[47:0]}),
816
                           .in2  (pc_d_adj),
817
                           .in3  (pc_e),
818
                           .sel0_l (fcl_fdp_nextpcs_sel_pcs_f_l[3]),
819
                           .sel1_l (fcl_fdp_nextpcs_sel_pcf_f_l[3]),
820
                           .sel2_l (fcl_fdp_nextpcs_sel_pcd_f_l[3]),
821
                           .sel3_l (fcl_fdp_nextpcs_sel_pce_f_l[3]));
822
 
823
 
824
 
825
   // S stage thread PC regs;  use low power thr flop
826
   dff  #(49)  t0pcs_reg(.din  (t0_next_pcs_f),
827
                                   .q    (t0pc_s),
828
                                   .clk  (clk),  .se(se), .si(), .so());
829
 
830
 
831
 
832
 
833
   dff  #(49)  t1pcs_reg(.din  (t1_next_pcs_f),
834
                                   .q    (t1pc_s),
835
                                   .clk  (clk),  .se(se), .si(), .so());
836
   dff  #(49)  t2pcs_reg(.din  (t2_next_pcs_f),
837
                                   .q    (t2pc_s),
838
                                   .clk  (clk),  .se(se), .si(), .so());
839
   dff  #(49)  t3pcs_reg(.din  (t3_next_pcs_f),
840
                                   .q    (t3pc_s),
841
                                   .clk  (clk),  .se(se), .si(), .so());
842
 
843
   // S stage PC mux -- need to protect
844
   dp_mux4ds #(49) pcs_mux(.dout (pc_s),
845
                         .in0  (t0pc_s),
846
                         .in1  (t1pc_s),
847
                         .in2  (t2pc_s),
848
                         .in3  (t3pc_s),
849
                         .sel0_l (fcl_fdp_thr_s2_l[0]),
850
                         .sel1_l (fcl_fdp_thr_s2_l[1]),
851
                         .sel2_l (fcl_fdp_thr_s2_l[2]),
852
                         .sel3_l (fcl_fdp_thr_s2_l[3]));
853
 
854
   // S stage next PC mux -- need to protect
855
   dp_mux4ds #(49) npcs_mux(.dout (npc_s),
856
                          .in0  (t0_next_pcs_f),
857
                          .in1  (t1_next_pcs_f),
858
                          .in2  (t2_next_pcs_f),
859
                          .in3  (t3_next_pcs_f),
860
                          .sel0_l (fcl_fdp_thr_s2_l[0]),
861
                          .sel1_l (fcl_fdp_thr_s2_l[1]),
862
                          .sel2_l (fcl_fdp_thr_s2_l[2]),
863
                          .sel3_l (fcl_fdp_thr_s2_l[3]));
864
 
865
 
866
   // D stage PC and nPC
867
   dff  #(49)  pcd_reg(.din (pc_s),
868
                                 .q   (pc_d),
869
                                 .clk (clk),  .se(se), .si(), .so());
870
   dff  #(49)  npcd_reg(.din  (npc_s),
871
                                  .q    (npc_d),
872
                                  .clk  (clk), .se(se), .si(), .so());
873
 
874
   assign am_mask = {{17{~fcl_fdp_addr_mask_d}}, 32'hffffffff};
875
 
876
   // nand2
877
   assign pc_d_adj = pc_d & am_mask;
878
   assign npc_d_adj = npc_d & am_mask;
879
 
880
   assign ifu_exu_pc_d = pc_d_adj[47:0];
881
 
882
   // E stage PC and nPC
883
   dff  #(49)  pce_reg(.din (pc_d_adj),
884
                                 .q   (pc_e),
885
                                 .clk (clk), .se(se), .si(), .so());
886
   dff  #(49)  npce_reg(.din  (npc_d_adj),
887
                                  .q    (npc_e),
888
                                  .clk (clk), .se(se), .si(), .so());
889
 
890
   assign fdp_fcl_pc_oor_e = pc_e[48];
891
   assign ifu_tlu_pc_oor_e = pc_e[48];
892
 
893
   // M stage PC and nPC
894
   dff  #(49)  pcm_reg(.din  (pc_e),
895
                                 .q    (pc_m),
896
                                 .clk  (clk),  .se(se), .si(), .so());
897
   dff  #(49)  npcm_reg(.din (npc_e),
898
                                  .q   (npc_m),
899
                                  .clk (clk), .se(se), .si(), .so());
900
   assign ifu_tlu_pc_m = pc_m[48:0];
901
   assign ifu_tlu_npc_m = npc_m[48:0];
902
 
903
   // W stage PC and nPC
904
   dff  #(49)  pcw_reg(.din  (pc_m),
905
                                 .q    (pc_w),
906
                                 .clk  (clk),  .se(se), .si(), .so());
907
   dff  #(49)  npcw_reg(.din (npc_m),
908
                                  .q   (npc_w),
909
                                  .clk (clk), .se(se), .si(), .so());
910
 
911
//   assign ifu_tlu_pc_w = pc_w;
912
//   assign ifu_tlu_npc_w = npc_w;
913
 
914
   // PC incrementer
915
   // can we fit the ofl logic on the side of the incrementer?
916
   assign pcinc_f[1:0] = pc_f[1:0];
917
   sparc_ifu_incr46 pc_inc(.a     (pc_f[47:2]),
918
                                             .a_inc (pcinc_f[47:2]),
919
                                             .ofl   ());   // ofl output not needed
920
 
921
//   assign pcinc_f[48] = inc_ofl & ~fcl_fdp_mask32b_f | fcl_fdp_pcoor_f;
922
   assign pcinc_f[48] = ~pc_f[47] & pcinc_f[47] & ~fcl_fdp_mask32b_f |
923
                        fcl_fdp_pcoor_f;
924
 
925
   // Enable for thr trapnpc reg
926
   dp_mux4ds #(49) t0tnpc_mux(.dout (trapnpc0_bf),
927
                                                .in0  (tlu_ifu_trapnpc_w2),
928
                                                .in1  (npc_w),
929
                              .in2  (t0pc_f),
930
                                                .in3  (t0_trapnpc_f),
931
                                                .sel0_l  (fcl_fdp_thrtnpc_sel_tnpc_l[0]),
932
                                                .sel1_l  (fcl_fdp_thrtnpc_sel_npcw_l[0]),
933
                                                .sel2_l  (fcl_fdp_thrtnpc_sel_pcf_l[0]),
934
                                                .sel3_l  (fcl_fdp_thrtnpc_sel_old_l[0]));
935
 
936
 
937
 
938
   dp_mux4ds #(49) t1tnpc_mux(.dout (trapnpc1_bf),
939
                            .in0  (tlu_ifu_trapnpc_w2),
940
                            .in1  (npc_w),
941
          .in2  (t1pc_f),
942
                            .in3  (t1_trapnpc_f),
943
                            .sel0_l  (fcl_fdp_thrtnpc_sel_tnpc_l[1]),
944
                            .sel1_l  (fcl_fdp_thrtnpc_sel_npcw_l[1]),
945
          .sel2_l  (fcl_fdp_thrtnpc_sel_pcf_l[1]),
946
                            .sel3_l  (fcl_fdp_thrtnpc_sel_old_l[1]));
947
 
948
   dp_mux4ds #(49) t2tnpc_mux(.dout (trapnpc2_bf),
949
                            .in0  (tlu_ifu_trapnpc_w2),
950
                            .in1  (npc_w),
951
          .in2  (t2pc_f),
952
                            .in3  (t2_trapnpc_f),
953
                            .sel0_l  (fcl_fdp_thrtnpc_sel_tnpc_l[2]),
954
                            .sel1_l  (fcl_fdp_thrtnpc_sel_npcw_l[2]),
955
          .sel2_l  (fcl_fdp_thrtnpc_sel_pcf_l[2]),
956
                            .sel3_l  (fcl_fdp_thrtnpc_sel_old_l[2]));
957
 
958
   dp_mux4ds #(49) t3tnpc_mux(.dout (trapnpc3_bf),
959
                            .in0  (tlu_ifu_trapnpc_w2),
960
                            .in1  (npc_w),
961
          .in2  (t3pc_f),
962
                            .in3  (t3_trapnpc_f),
963
                            .sel0_l  (fcl_fdp_thrtnpc_sel_tnpc_l[3]),
964
                            .sel1_l  (fcl_fdp_thrtnpc_sel_npcw_l[3]),
965
          .sel2_l  (fcl_fdp_thrtnpc_sel_pcf_l[3]),
966
                            .sel3_l  (fcl_fdp_thrtnpc_sel_old_l[3]));
967
 
968
 
969
   // thread next trap pc reg
970
   dff #(49) t0tnpcf_reg(.din  (trapnpc0_bf),
971
                                   .q    (t0_trapnpc_f),
972
                                   .clk  (clk),  .se(se), .si(), .so());
973
 
974
 
975
 
976
   dff #(49) t1tnpcf_reg(.din  (trapnpc1_bf),
977
                                   .q    (t1_trapnpc_f),
978
                                   .clk  (clk),  .se(se), .si(), .so());
979
   dff #(49) t2tnpcf_reg(.din  (trapnpc2_bf),
980
                                   .q    (t2_trapnpc_f),
981
                                   .clk  (clk),  .se(se), .si(), .so());
982
   dff #(49) t3tnpcf_reg(.din  (trapnpc3_bf),
983
                                   .q    (t3_trapnpc_f),
984
                                   .clk  (clk),  .se(se), .si(), .so());
985
 
986
   dp_mux4ds #(49) nxttpc_mux(.dout (thr_trappc_bf),
987
                            .in0  (t0_trapnpc_f),
988
                            .in1  (t1_trapnpc_f),
989
                            .in2  (t2_trapnpc_f),
990
                            .in3  (t3_trapnpc_f),
991
                            .sel0_l (fcl_fdp_thr_s2_l[0]), // thr_s2 = thr_f
992
                            .sel1_l (fcl_fdp_thr_s2_l[1]),
993
                            .sel2_l (fcl_fdp_thr_s2_l[2]),
994
                            .sel3_l (fcl_fdp_thr_s2_l[3]));
995
 
996
 
997
   // During rst nextpc_nosw_bf = PO_RESET_PC.  All thread PC_f registers,
998
   // the icaddr_f register and the nextpc register should be loaded
999
   // with nextpc_nosw_bf during reset.
1000
   // Eventually, we will load the reset_pc from the trap logic unit,
1001
   // which will arrive on the trap_pc bus.
1002
 
1003
 
1004
   // TBD in PC datapath:
1005
   // 1.  Add useNIR bit to PCs  -- DONE
1006
   // 2.  Add support for ifq request grant -- DONE
1007
   // 3.  Generate icache read signal (from fcl?) -- DONE
1008
   // 4.  Rollback functionality -- DONE
1009
   // 5.  PC range checks -- DONE
1010
   // 6.  Change PC to 48 bit value -- DONE
1011
 
1012
 
1013
//----------------------------------------------------------------------
1014
// Fetched Instruction Datapath
1015
//----------------------------------------------------------------------
1016
 
1017
// This is logically 33 bits wide.  The NIR and IR datapaths are laid
1018
// side by side, making this a 66bit datapath.  The NIR path is
1019
// potentially a little longer.
1020
 
1021
   // choose between NIR data and fetched data
1022
   dp_mux2es #(33)  usenir_mux(.dout (inst_s1),
1023
                                               .in0  (icd_fdp_fetdata_s1[32:0]),
1024
                                               .in1  (nirdata_s1),
1025
                                               .sel  (fcl_fdp_usenir_sel_nir_s1));  // 1=nir
1026
 
1027
   // Instruction Output Mux
1028
   // CHANGE: now 4:1
1029
   dp_mux4ds  #(33)  instout_mux(.dout (fdp_inst_s),
1030
                                                 .in0 (icd_fdp_fetdata_s1[32:0]),
1031
                                                 .in1 (inst_s2),
1032
                                                 .in2 ({32'h01000000, 1'b0}),
1033
                                                 .in3 (nirdata_s1[32:0]),
1034
                                                 .sel0_l (fcl_fdp_inst_sel_curr_s_l),
1035
                                                 .sel1_l (fcl_fdp_inst_sel_switch_s_l),
1036
                                                 .sel2_l (fcl_fdp_inst_sel_nop_s_l),
1037
                                                 .sel3_l (fcl_fdp_inst_sel_nir_s_l));
1038
 
1039
   assign fdp_fcl_swc_s2 = fdp_inst_s[0];
1040
 
1041
   assign fdp_fcl_op_s = fdp_inst_s[32:31];
1042
   assign fdp_fcl_op3_s = fdp_inst_s[25:22];
1043
   assign fdp_fcl_ibit_s = fdp_inst_s[14];
1044
 
1045
   assign fdp_dtu_inst_s = fdp_inst_s[32:1];
1046
 
1047
   // CHANGE: Random logic to fix timing paths
1048
   // output pin on RHS, as close to IRF as possible
1049
   // 16x drivers
1050
   // nand2-xor-invert
1051
   assign ifu_exu_rs1_s[4] = fdp_inst_s[19] ^
1052
                                               (fdp_inst_s[18] & fcl_fdp_oddwin_s);
1053
   assign ifu_exu_rs1_s[3:0] = fdp_inst_s[18:15];
1054
 
1055
   assign ifu_exu_rs2_s[4] = (fdp_inst_s[5] ^
1056
                                                (fdp_inst_s[4] & fcl_fdp_oddwin_s));
1057
   assign ifu_exu_rs2_s[3:0] = fdp_inst_s[4:1];
1058
 
1059
   assign ifu_exu_rs3_s[4] = (fdp_inst_s[30] ^
1060
                                                (fdp_inst_s[29] & fcl_fdp_oddwin_s));
1061
   assign ifu_exu_rs3_s[3:0] = fdp_inst_s[29:26];
1062
 
1063
 
1064
   dp_buffer #(33) insts1_buf(inst_s1_bf1, inst_s1[32:0]);
1065
 
1066
   // Thread instruction muxes
1067
   dp_mux4ds #(33)  t0inst_mux(.dout (t0inst_s1),
1068
                             .in0 (ifq_fdp_fill_inst),
1069
                             .in1 (inst_s1_bf1),
1070
                             .in2 (t0inst_s2),
1071
                             .in3 (rb_inst0_s),
1072
                             .sel0_l (fcl_fdp_tinst_sel_ifq_s_l[0]),
1073
                             .sel1_l (fcl_fdp_tinst_sel_curr_s_l[0]),
1074
                             .sel2_l (fcl_fdp_tinst_sel_old_s_l[0]),
1075
                             .sel3_l (fcl_fdp_tinst_sel_rb_s_l[0]));
1076
 
1077
 
1078
 
1079
   dp_mux4ds #(33)  t1inst_mux(.dout (t1inst_s1),
1080
                             .in0 (ifq_fdp_fill_inst),
1081
                             .in1 (inst_s1_bf1),
1082
                             .in2 (t1inst_s2),
1083
                             .in3 (rb_inst1_s),
1084
                             .sel0_l (fcl_fdp_tinst_sel_ifq_s_l[1]),
1085
                             .sel1_l (fcl_fdp_tinst_sel_curr_s_l[1]),
1086
                             .sel2_l (fcl_fdp_tinst_sel_old_s_l[1]),
1087
                             .sel3_l (fcl_fdp_tinst_sel_rb_s_l[1]));
1088
 
1089
   dp_mux4ds #(33)  t2inst_mux(.dout (t2inst_s1),
1090
                             .in0 (ifq_fdp_fill_inst),
1091
                             .in1 (inst_s1_bf1),
1092
                             .in2 (t2inst_s2),
1093
                             .in3 (rb_inst2_s),
1094
                             .sel0_l (fcl_fdp_tinst_sel_ifq_s_l[2]),
1095
                             .sel1_l (fcl_fdp_tinst_sel_curr_s_l[2]),
1096
                             .sel2_l (fcl_fdp_tinst_sel_old_s_l[2]),
1097
                             .sel3_l (fcl_fdp_tinst_sel_rb_s_l[2]));
1098
 
1099
   dp_mux4ds #(33)  t3inst_mux(.dout (t3inst_s1),
1100
                             .in0 (ifq_fdp_fill_inst),
1101
                             .in1 (inst_s1_bf1),
1102
                             .in2 (t3inst_s2),
1103
                             .in3 (rb_inst3_s),
1104
                             .sel0_l (fcl_fdp_tinst_sel_ifq_s_l[3]),
1105
                             .sel1_l (fcl_fdp_tinst_sel_curr_s_l[3]),
1106
                             .sel2_l (fcl_fdp_tinst_sel_old_s_l[3]),
1107
                             .sel3_l (fcl_fdp_tinst_sel_rb_s_l[3]));
1108
 
1109
 
1110
   // Thread Instruction Register
1111
   dff #(33) t0_inst_reg(.din  (t0inst_s1),
1112
                                   .q    (t0inst_s2),
1113
                                   .clk  (clk),  .se(se), .si(), .so());
1114
 
1115
 
1116
 
1117
   dff #(33) t1_inst_reg(.din  (t1inst_s1),
1118
                                   .q    (t1inst_s2),
1119
                                   .clk  (clk),  .se(se), .si(), .so());
1120
   dff #(33) t2_inst_reg(.din  (t2inst_s1),
1121
                                   .q    (t2inst_s2),
1122
                                   .clk  (clk),  .se(se), .si(), .so());
1123
   dff #(33) t3_inst_reg(.din  (t3inst_s1),
1124
                                   .q    (t3inst_s2),
1125
                                   .clk  (clk),  .se(se), .si(), .so());
1126
 
1127
   // switch instruction mux -- choose the instruction to switch to
1128
   // fcl keep track of which t*inst_s2 is valid
1129
   dp_mux4ds  #(33) swinst_mux(.dout (inst_s2),
1130
                             .in0  (t0inst_s2),
1131
                             .in1  (t1inst_s2),
1132
                             .in2  (t2inst_s2),
1133
                             .in3  (t3inst_s2),
1134
                             .sel0_l (fcl_fdp_thr_s2_l[0]),
1135
                             .sel1_l (fcl_fdp_thr_s2_l[1]),
1136
                             .sel2_l (fcl_fdp_thr_s2_l[2]),
1137
                             .sel3_l (fcl_fdp_thr_s2_l[3]));
1138
 
1139
 
1140
   // Rollback instruction
1141
   dff #(33) rbinst_d_reg(.din (fdp_inst_s[32:0]),
1142
                                          .q   (inst_d),
1143
                                          .clk (clk),
1144
                                          .se  (se), .si(), .so());
1145
 
1146
   dff #(33) rbinst_e_reg(.din (inst_d),
1147
                                          .q   (inst_e),
1148
                                          .clk (clk),
1149
                                          .se  (se), .si(), .so());
1150
 
1151
   dp_mux2es #(33) rbinst0_mux(.dout (rb_inst0_s),
1152
                                               .in0  (inst_d),
1153
                                               .in1  (inst_e),
1154
                                               .sel  (fcl_fdp_rbinst_sel_inste_s[0]));
1155
 
1156
 
1157
 
1158
   dp_mux2es #(33) rbinst1_mux(.dout (rb_inst1_s),
1159
                                               .in0  (inst_d),
1160
                                               .in1  (inst_e),
1161
                                               .sel  (fcl_fdp_rbinst_sel_inste_s[1]));
1162
 
1163
   dp_mux2es #(33) rbinst2_mux(.dout (rb_inst2_s),
1164
                                               .in0  (inst_d),
1165
                                               .in1  (inst_e),
1166
                                               .sel  (fcl_fdp_rbinst_sel_inste_s[2]));
1167
 
1168
   dp_mux2es #(33) rbinst3_mux(.dout (rb_inst3_s),
1169
                                               .in0  (inst_d),
1170
                                               .in1  (inst_e),
1171
                                               .sel  (fcl_fdp_rbinst_sel_inste_s[3]));
1172
 
1173
 
1174
//----------------------------------------------------------------------
1175
// Next Instruction Datapath
1176
//----------------------------------------------------------------------
1177
 
1178
   // Thread next instruction muxes
1179
//   dp_mux2es #(33) t0nir_mux(.dout (t0nir_in),
1180
//                                           .in0 (icd_fdp_topdata_s1[32:0]), 
1181
//                                           .in1 (t0nir), 
1182
//                                           .sel (fcl_fdp_thr_s1_l[0]));  // 0=new
1183
//   dp_mux2es #(33) t1nir_mux(.dout (t1nir_in),
1184
//                                           .in0 (icd_fdp_topdata_s1[32:0]), 
1185
//                                           .in1 (t1nir), 
1186
//                                           .sel (fcl_fdp_thr_s1_l[1])); 
1187
//   dp_mux2es #(33) t2nir_mux(.dout (t2nir_in),
1188
//                                           .in0 (icd_fdp_topdata_s1[32:0]), 
1189
//                                           .in1 (t2nir), 
1190
//                                           .sel (fcl_fdp_thr_s1_l[2])); 
1191
//   dp_mux2es #(33) t3nir_mux(.dout (t3nir_in),
1192
//                                           .in0 (icd_fdp_topdata_s1[32:0]), 
1193
//                                           .in1 (t3nir), 
1194
//                                           .sel (fcl_fdp_thr_s1_l[3])); 
1195
 
1196
   // Thread Next Instruction Register
1197
   wire   clk_nir0;
1198
 
1199
 
1200
 
1201
 
1202
 
1203
 
1204
 
1205
 
1206
 
1207
   dffe #(33) t0nir_reg(.din (icd_fdp_topdata_s1[32:0]),
1208
                                   .q    (t0nir),
1209
                                   .en  (~(fcl_fdp_thr_s1_l[0])), .clk(rclk), .se(se), .si(), .so());
1210
 
1211
 
1212
 
1213
 
1214
 
1215
 
1216
 
1217
 
1218
 
1219
 
1220
   wire   clk_nir1;
1221
 
1222
 
1223
 
1224
 
1225
 
1226
 
1227
 
1228
 
1229
 
1230
   dffe #(33)  t1nir_reg(.din  (icd_fdp_topdata_s1[32:0]),
1231
                                   .q    (t1nir),
1232
                                   .en (~(fcl_fdp_thr_s1_l[1])), .clk  (rclk), .se(se), .si(), .so());
1233
 
1234
 
1235
 
1236
 
1237
 
1238
 
1239
   wire   clk_nir2;
1240
 
1241
 
1242
 
1243
 
1244
 
1245
 
1246
 
1247
 
1248
 
1249
   dffe #(33) t2nir_reg(.din  (icd_fdp_topdata_s1[32:0]),
1250
                                   .q    (t2nir),
1251
                                   .en (~(fcl_fdp_thr_s1_l[2])), .clk  (rclk), .se(se), .si(), .so());
1252
 
1253
 
1254
 
1255
 
1256
 
1257
   wire   clk_nir3;
1258
 
1259
 
1260
 
1261
 
1262
 
1263
 
1264
 
1265
 
1266
 
1267
   dffe #(33) t3nir_reg(.din  (icd_fdp_topdata_s1[32:0]),
1268
                                   .q    (t3nir),
1269
                                   .en (~(fcl_fdp_thr_s1_l[3])), .clk  (rclk), .se(se), .si(), .so());
1270
 
1271
 
1272
 
1273
 
1274
 
1275
 
1276
 
1277
   // Next thread NIR mux  (nir output mux)
1278
   dp_mux4ds  #(33) nextnir_mux(.dout (nirdata_s1),
1279
                                          .in0 (t0nir),
1280
                              .in1 (t1nir),
1281
                              .in2 (t2nir),
1282
                              .in3 (t3nir),
1283
                                          .sel0_l (fcl_fdp_nirthr_s1_l[0]),
1284
                                          .sel1_l (fcl_fdp_nirthr_s1_l[1]),
1285
                                          .sel2_l (fcl_fdp_nirthr_s1_l[2]),
1286
                                          .sel3_l (fcl_fdp_nirthr_s1_l[3]));
1287
 
1288
 
1289
   // TBD in fetched instruction DP:
1290
   // 1. Rollback -- DONE
1291
   // 2. Icache parity check (increase fet data and top data to 34 bits)
1292
 
1293
endmodule // sparc_ifu_fdp
1294
 

powered by: WebSVN 2.1.0

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