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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_exu_eclccr.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_exu_eclccr.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_exu_eclccr
29
//      Description: 4 bit condition code registers with forwarding.  Takes
30
//      the e_stage result and writes on the w stage.
31
*/
32
 
33
module sparc_exu_eclccr (/*AUTOARG*/
34
   // Outputs
35
   exu_ifu_cc_d, exu_tlu_ccr0_w, exu_tlu_ccr1_w, exu_tlu_ccr2_w,
36
   exu_tlu_ccr3_w,
37
   // Inputs
38
   clk, se, alu_xcc_e, alu_icc_e, tid_d, thrdec_d, thr_match_dm,
39
   thr_match_de, tid_w, thr_w, ifu_exu_kill_e, ifu_exu_setcc_d,
40
   byp_ecl_wrccr_data_w, wb_ccr_wrccr_w, wb_ccr_setcc_g,
41
   divcntl_ccr_cc_w2, wb_ccr_thr_g, tlu_exu_cwpccr_update_m,
42
   tlu_exu_ccr_m, ifu_exu_inst_vld_w, ifu_tlu_flush_w, early_flush_w
43
   ) ;
44
   input clk;
45
   input se;
46
   input [3:0] alu_xcc_e;    // condition codes from the alu
47
   input [3:0] alu_icc_e;
48
   input [1:0] tid_d;   // thread for each stage
49
   input [3:0] thrdec_d;   // decoded tid_d for mux select
50
   input       thr_match_dm;
51
   input       thr_match_de;
52
   input [1:0] tid_w;
53
   input [3:0] thr_w;        // decoded tid_w
54
   input       ifu_exu_kill_e;
55
   input       ifu_exu_setcc_d;
56
   input [7:0] byp_ecl_wrccr_data_w;// for the WRCCR operation (LSBs of
57
   input       wb_ccr_wrccr_w; // ALU result) + wen signal
58
   input       wb_ccr_setcc_g;
59
   input [7:0] divcntl_ccr_cc_w2;
60
   input [1:0] wb_ccr_thr_g;
61
   input       tlu_exu_cwpccr_update_m;
62
   input [7:0] tlu_exu_ccr_m;
63
   input       ifu_exu_inst_vld_w;
64
   input       ifu_tlu_flush_w;
65
   input       early_flush_w;
66
 
67
   output [7:0] exu_ifu_cc_d;   // condition codes for current thread
68
   output [7:0] exu_tlu_ccr0_w;
69
   output [7:0] exu_tlu_ccr1_w;
70
   output [7:0] exu_tlu_ccr2_w;
71
   output [7:0] exu_tlu_ccr3_w;
72
 
73
   wire [7:0]   partial_cc_d;   // partial bypassed ccr
74
   wire [7:0]   alu_cc_e;   // alu combined condition codes
75
   wire [7:0]   alu_cc_m;   // m stage alu ccs
76
   wire [7:0]   alu_cc_w;
77
   wire [7:0]   exu_ifu_cc_w;   // writeback data
78
   wire         setcc_e;        // from previous stage
79
   wire         setcc_m;
80
   wire         setcc_w;
81
   wire         valid_setcc_e;  // after comparing with kill
82
   wire         valid_setcc_m;
83
   wire         valid_setcc_w;
84
   wire         setcc_w2;
85
   wire [7:0]   ccrin_thr0;
86
   wire [7:0]   ccrin_thr1;
87
   wire [7:0]   ccrin_thr2;
88
   wire [7:0]   ccrin_thr3;
89
   wire [7:0]   ccr_d;
90
   wire [7:0]   ccr_thr0;
91
   wire [7:0]   ccr_thr1;
92
   wire [7:0]   ccr_thr2;
93
   wire [7:0]   ccr_thr3;
94
   wire         use_alu_cc;
95
   wire         use_ccr;
96
   wire         use_cc_e;
97
   wire         use_cc_m;
98
   wire         use_cc_w;
99
   wire  [1:0]   tid_dxorw;
100
   wire         thr_match_de;
101
   wire         thrmatch_w;
102
   wire [1:0]   thr_w2;
103
   wire          thr0_w2;
104
   wire          thr1_w2;
105
   wire          thr2_w2;
106
   wire          thr3_w2;
107
   wire          wen_thr0_w;    // write enable for each input/thread
108
   wire          wen_thr0_w2;
109
   wire          wen_thr1_w;
110
   wire          wen_thr1_w2;
111
   wire          wen_thr2_w;
112
   wire          wen_thr2_w2;
113
   wire          wen_thr3_w;
114
   wire          wen_thr3_w2;
115
   wire          wen_thr0_l;      // overall write enable for each thread
116
   wire          wen_thr1_l;
117
   wire          wen_thr2_l;
118
   wire          wen_thr3_l;
119
   wire          bypass_cc_w;
120
 
121
   wire [7:0]    ccr_m;
122
 
123
 
124
   // D2E flops
125 113 albert.wat
   dff_s dff_setcc_d2e(.din(ifu_exu_setcc_d), .clk(clk), .q(setcc_e),
126
                     .se(se), `SIMPLY_RISC_SCANIN, .so());
127 95 fafa1971
 
128
   // E stage
129
   assign       alu_cc_e = {alu_xcc_e, alu_icc_e};
130
   assign       valid_setcc_e = setcc_e & ~ifu_exu_kill_e;
131
 
132 113 albert.wat
   dff_s #(8) dff_cc_e2m(.din(alu_cc_e[7:0]), .clk(clk), .q(alu_cc_m[7:0]),
133
                  .se(se), `SIMPLY_RISC_SCANIN, .so());
134
   dff_s dff_setcc_e2m(.din(valid_setcc_e), .clk(clk), .q(setcc_m),
135
                     .se(se), `SIMPLY_RISC_SCANIN, .so());
136 95 fafa1971
 
137
   // M stage
138
   assign       valid_setcc_m = setcc_m | tlu_exu_cwpccr_update_m;
139
   mux2ds #(8) mux_ccr_m(.dout(ccr_m[7:0]),
140
                            .in0(alu_cc_m[7:0]),
141
                            .in1(tlu_exu_ccr_m[7:0]),
142
                            .sel0(~tlu_exu_cwpccr_update_m),
143
                            .sel1(tlu_exu_cwpccr_update_m));
144
 
145 113 albert.wat
   dff_s #(8) dff_cc_m2w(.din(ccr_m[7:0]), .clk(clk), .q(alu_cc_w[7:0]),
146
                  .se(se), `SIMPLY_RISC_SCANIN, .so());
147
   dff_s dff_setcc_m2w(.din(valid_setcc_m), .clk(clk), .q(setcc_w),
148
                     .se(se), `SIMPLY_RISC_SCANIN, .so());
149 95 fafa1971
 
150
   // W stage
151
   assign bypass_cc_w = ifu_exu_inst_vld_w & setcc_w;
152
   assign valid_setcc_w = ~ifu_tlu_flush_w & ~early_flush_w & ifu_exu_inst_vld_w & (setcc_w | wb_ccr_wrccr_w);
153
 
154
   // mux with wrccr
155
   assign        use_alu_cc = ~(wb_ccr_wrccr_w);
156
   mux2ds #(8) mux_ccrin_cc(.dout(exu_ifu_cc_w[7:0]), .sel0(wb_ccr_wrccr_w),
157
                          .sel1(use_alu_cc),
158
                          .in0(byp_ecl_wrccr_data_w[7:0]),
159
                          .in1(alu_cc_w[7:0]));
160
 
161 113 albert.wat
   dff_s #(3) setcc_g2w2 (.din({wb_ccr_setcc_g, wb_ccr_thr_g[1:0]}), .clk(clk),
162 95 fafa1971
                        .q({setcc_w2, thr_w2[1:0]}),
163 113 albert.wat
                        .se(se), `SIMPLY_RISC_SCANIN, .so());
164 95 fafa1971
 
165
 
166
   /////////////////////////
167
   // Storage of ccr
168
   /////////////////////////
169 113 albert.wat
`ifdef FPGA_SYN_1THREAD
170
 
171
   assign          thr0_w2 = ~thr_w2[1] & ~thr_w2[0];
172
   assign          wen_thr0_w = (thr_w[0] & valid_setcc_w & ~wen_thr0_w2);
173
   assign          wen_thr0_w2 = thr0_w2 & setcc_w2;
174
   assign          wen_thr0_l = ~(wen_thr0_w | wen_thr0_w2);
175
   // mux between cc_w, cc_w2, old value, tlu value
176
   mux3ds #(8) mux_ccrin0(.dout(ccrin_thr0[7:0]), .sel0(wen_thr0_w),
177
                          .sel1(wen_thr0_w2), .sel2(wen_thr0_l),
178
                          .in0(exu_ifu_cc_w[7:0]),
179
                          .in1(divcntl_ccr_cc_w2[7:0]), .in2(ccr_thr0[7:0]));
180
   // store new value
181
   dff_s #(8) dff_ccr_thr0(.din(ccrin_thr0[7:0]), .clk(clk), .q(ccr_thr0[7:0]),
182
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
183
   assign          ccr_d[7:0] = ccr_thr0[7:0];
184 95 fafa1971
 
185 113 albert.wat
`else // !`ifdef FPGA_SYN_1THREAD
186
 
187 95 fafa1971
   // decode thr_w2 for mux select
188
   assign        thr0_w2 = ~thr_w2[1] & ~thr_w2[0];
189
   assign        thr1_w2 = ~thr_w2[1] & thr_w2[0];
190
   assign        thr2_w2 = thr_w2[1] & ~thr_w2[0];
191
   assign        thr3_w2 = thr_w2[1] & thr_w2[0];
192
   // enable input for each thread
193
   assign        wen_thr0_w = (thr_w[0] & valid_setcc_w & ~wen_thr0_w2);
194
   assign        wen_thr0_w2 = thr0_w2 & setcc_w2;
195
   assign        wen_thr0_l = ~(wen_thr0_w | wen_thr0_w2);
196
   assign        wen_thr1_w = (thr_w[1] & valid_setcc_w & ~wen_thr1_w2);
197
   assign        wen_thr1_w2 = (thr1_w2 & setcc_w2);
198
   assign        wen_thr1_l = ~(wen_thr1_w | wen_thr1_w2);
199
   assign        wen_thr2_w = (thr_w[2] & valid_setcc_w & ~wen_thr2_w2);
200
   assign        wen_thr2_w2 = (thr2_w2 & setcc_w2);
201
   assign        wen_thr2_l = ~(wen_thr2_w | wen_thr2_w2);
202
   assign        wen_thr3_w = (thr_w[3] & valid_setcc_w & ~wen_thr3_w2);
203
   assign        wen_thr3_w2 = (thr3_w2 & setcc_w2);
204
   assign        wen_thr3_l = ~(wen_thr3_w | wen_thr3_w2);
205
 
206
   // mux between cc_w, cc_w2, old value, tlu value
207
   mux3ds #(8) mux_ccrin0(.dout(ccrin_thr0[7:0]), .sel0(wen_thr0_w),
208
                          .sel1(wen_thr0_w2), .sel2(wen_thr0_l),
209
                          .in0(exu_ifu_cc_w[7:0]),
210
                          .in1(divcntl_ccr_cc_w2[7:0]), .in2(ccr_thr0[7:0]));
211
   mux3ds #(8) mux_ccrin1(.dout(ccrin_thr1[7:0]), .sel0(wen_thr1_w),
212
                          .sel1(wen_thr1_w2), .sel2(wen_thr1_l),
213
                          .in0(exu_ifu_cc_w[7:0]),
214
                          .in1(divcntl_ccr_cc_w2[7:0]), .in2(ccr_thr1[7:0]));
215
   mux3ds #(8) mux_ccrin2(.dout(ccrin_thr2[7:0]), .sel0(wen_thr2_w),
216
                          .sel1(wen_thr2_w2), .sel2(wen_thr2_l),
217
                          .in0(exu_ifu_cc_w[7:0]),
218
                          .in1(divcntl_ccr_cc_w2[7:0]), .in2(ccr_thr2[7:0]));
219
   mux3ds #(8) mux_ccrin3(.dout(ccrin_thr3[7:0]), .sel0(wen_thr3_w),
220
                          .sel1(wen_thr3_w2), .sel2(wen_thr3_l),
221
                          .in0(exu_ifu_cc_w[7:0]),
222
                          .in1(divcntl_ccr_cc_w2[7:0]), .in2(ccr_thr3[7:0]));
223
 
224
   // store new value
225 113 albert.wat
   dff_s #(8) dff_ccr_thr0(.din(ccrin_thr0[7:0]), .clk(clk), .q(ccr_thr0[7:0]),
226
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
227
   dff_s #(8) dff_ccr_thr1(.din(ccrin_thr1[7:0]), .clk(clk), .q(ccr_thr1[7:0]),
228
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
229
   dff_s #(8) dff_ccr_thr2(.din(ccrin_thr2[7:0]), .clk(clk), .q(ccr_thr2[7:0]),
230
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
231
   dff_s #(8) dff_ccr_thr3(.din(ccrin_thr3[7:0]), .clk(clk), .q(ccr_thr3[7:0]),
232
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
233 95 fafa1971
 
234
 
235
   // mux between the 4 sets of ccrs
236
   mux4ds #(8) mux_ccr_out(.dout(ccr_d[7:0]), .sel0(thrdec_d[0]),
237
                         .sel1(thrdec_d[1]), .sel2(thrdec_d[2]),
238
                         .sel3(thrdec_d[3]), .in0(ccr_thr0[7:0]),
239
                         .in1(ccr_thr1[7:0]), .in2(ccr_thr2[7:0]),
240
                         .in3(ccr_thr3[7:0]));
241 113 albert.wat
`endif // !`ifdef FPGA_SYN_1THREAD
242 95 fafa1971
 
243
   // bypass the ccs to the output.  Only alu result needs to be bypassed
244
   assign        exu_ifu_cc_d[7:0] = (use_cc_e)? alu_cc_e[7:0]: partial_cc_d[7:0];
245
   mux3ds #(8) mux_ccr_bypass1(.dout(partial_cc_d[7:0]),
246
                               .sel0(use_ccr),
247
                               .sel1(use_cc_m),
248
                               .sel2(use_cc_w),
249
                               .in0(ccr_d[7:0]),
250
                               .in1(alu_cc_m[7:0]),
251
                               .in2(alu_cc_w[7:0]));
252
 
253
   assign        use_cc_e = valid_setcc_e & thr_match_de;
254
   assign        use_cc_m = setcc_m & thr_match_dm;
255
   assign        use_cc_w = bypass_cc_w & thrmatch_w & ~use_cc_m;
256
   assign        use_ccr = ~(use_cc_m | use_cc_w);
257
 
258
   assign        tid_dxorw = tid_w ^ tid_d;
259
 
260
   assign        thrmatch_w = ~(tid_dxorw[1] | tid_dxorw[0]);
261
 
262
   // generate ccr_w for the tlu
263
   assign        exu_tlu_ccr0_w[7:0] = ccr_thr0[7:0];
264
   assign        exu_tlu_ccr1_w[7:0] = ccr_thr1[7:0];
265
   assign        exu_tlu_ccr2_w[7:0] = ccr_thr2[7:0];
266
   assign        exu_tlu_ccr3_w[7:0] = ccr_thr3[7:0];
267
 
268
 
269
endmodule // sparc_exu_eclccr

powered by: WebSVN 2.1.0

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