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 113

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

powered by: WebSVN 2.1.0

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