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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_exu_ecl_mdqctl.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_ecl_mdqctl.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_ecl_mdqctl
29
//      Description:  This block is the control logic for the multiply/divide
30
//      input buffer.  It generates the select lines for both the output
31
//      to mul and div, as well as for moving the data within the buffer.
32
//      There are 4 slots in the buffer, which is a modified FIFO.
33
//      It will output 1 MUL and 1 DIV every cycle, as well as whether those
34
//      outputs are valid.  If none of the slots contain a valid entry, it
35
//      will pass through the input to the output.  If a kill comes through
36
//      and invalidates an entry, it will show up on the valid bit coming out
37
//      of the mdq, but may cause a lost cycle as the kill won't affect the logic
38
//      which chooses the output until the next cycle.  The block also
39
//      stores the thr, rd, setcc and other control bits for each entry.
40
*/
41
 
42 113 albert.wat
`define MULS 10
43
`define IS64 9
44
`define SIGNED 8
45
`define SET_CC 7
46 95 fafa1971
 
47
module sparc_exu_ecl_mdqctl (/*AUTOARG*/
48
   // Outputs
49
   mdqctl_divcntl_input_vld, mdqctl_divcntl_reset_div,
50
   mdqctl_divcntl_muldone, ecl_div_div64, ecl_div_signed_div,
51
   ecl_div_muls, mdqctl_wb_divthr_g, mdqctl_wb_divrd_g,
52
   mdqctl_wb_multhr_g, mdqctl_wb_mulrd_g, mdqctl_wb_divsetcc_g,
53
   mdqctl_wb_mulsetcc_g, mdqctl_wb_yreg_shift_g, exu_mul_input_vld,
54
   mdqctl_wb_yreg_wen_g, ecl_div_mul_sext_rs1_e,
55
   ecl_div_mul_sext_rs2_e, ecl_div_mul_get_new_data,
56
   ecl_div_mul_keep_data, ecl_div_mul_get_32bit_data,
57
   ecl_div_mul_wen, div_zero_m,
58
   // Inputs
59
   clk, se, reset, ifu_exu_muldivop_d, tid_d, ifu_exu_rd_d, tid_w1,
60
   flush_w1, ifu_exu_inst_vld_w, wb_divcntl_ack_g, divcntl_wb_req_g,
61
   byp_alu_rs1_data_31_e, byp_alu_rs2_data_31_e, mul_exu_ack,
62
   ecl_div_sel_div, ifu_exu_muls_d, div_ecl_detect_zero_high,
63
   div_ecl_detect_zero_low, ifu_tlu_flush_w, early_flush_w
64
   ) ;
65
   input clk;
66
   input se;
67
   input reset;
68
   input [4:0] ifu_exu_muldivop_d;
69
   input [1:0] tid_d;
70
   input [4:0] ifu_exu_rd_d;
71
   input [1:0] tid_w1;
72
   input       flush_w1;
73
   input       ifu_exu_inst_vld_w;
74
   input       wb_divcntl_ack_g;
75
   input       divcntl_wb_req_g;
76
   input       byp_alu_rs1_data_31_e;
77
   input       byp_alu_rs2_data_31_e;
78
   input       mul_exu_ack;
79
   input       ecl_div_sel_div;
80
   input       ifu_exu_muls_d;
81
   input       div_ecl_detect_zero_high;
82
   input       div_ecl_detect_zero_low;
83
   input       ifu_tlu_flush_w;
84
   input       early_flush_w;
85
 
86
 
87
   output      mdqctl_divcntl_input_vld;
88
   output      mdqctl_divcntl_reset_div;
89
   output      mdqctl_divcntl_muldone;
90
   output      ecl_div_div64;
91
   output      ecl_div_signed_div;
92
   output      ecl_div_muls;
93
   output [1:0] mdqctl_wb_divthr_g;
94
   output [4:0] mdqctl_wb_divrd_g;
95
   output [1:0] mdqctl_wb_multhr_g;
96
   output [4:0] mdqctl_wb_mulrd_g;
97
   output       mdqctl_wb_divsetcc_g;
98
   output       mdqctl_wb_mulsetcc_g;
99
   output       mdqctl_wb_yreg_shift_g;
100
 
101
 
102
   output       exu_mul_input_vld;
103
   output       mdqctl_wb_yreg_wen_g;
104
   output       ecl_div_mul_sext_rs1_e;
105
   output       ecl_div_mul_sext_rs2_e;
106
   output       ecl_div_mul_get_new_data;
107
   output       ecl_div_mul_keep_data;
108
   output       ecl_div_mul_get_32bit_data;
109
   output       ecl_div_mul_wen;
110
   output   div_zero_m;
111
 
112
   wire [11:0] div_data_next;
113
   wire [11:0] div_data;
114
   wire        new_div_vld;
115
   wire        curr_div_vld;
116
   wire [11:0] div_input_data_d;
117
   wire [9:0] mul_input_data_d;
118
   wire [9:0] mul_data;
119
   wire [9:0] mul_data_next;
120
   wire        new_mul_d;
121
   wire        kill_thr_mul;
122
   wire        mul_kill;
123
   wire        invalid_mul_w;
124
   wire        div_kill;
125
   wire        kill_thr_div;
126
 
127
   wire        mul_ready_next;
128
   wire        mul_ready;
129
   wire        mul_done_valid_c0;
130
   wire        mul_done_valid_c1;
131
   wire        mul_done_ack;
132
   wire        mul_done_c0;
133
   wire        mul_done_c1;
134
   wire        mul_done_c2;
135
   wire        mul_done_c3;
136
 
137
   wire        isdiv_e_valid;
138
   wire        isdiv_m_valid;
139
   wire        ismul_e_valid;
140
   wire        ismul_m_valid;
141
   wire        isdiv_e;
142
   wire        isdiv_m;
143
   wire        isdiv_w;
144
   wire        ismul_e;
145
   wire        ismul_m;
146
   wire        ismul_w;
147
 
148
   wire        div_used;
149
   wire        invalid_div_w;
150
   wire        div_zero_e;
151
 
152
   // Mul result state wires
153
   wire        go_mul_done;
154
   wire        stay_mul_done;
155
   wire        mul_done;
156
   wire        next_mul_done;
157
 
158
 
159
   ////////////////////////
160
   // Divide  output DATAPATH
161
   ////////////////////////
162
   // store control signals
163
   assign div_used = divcntl_wb_req_g & wb_divcntl_ack_g & ecl_div_sel_div;
164
 
165
   assign new_div_vld = ifu_exu_muls_d | ifu_exu_muldivop_d[3];
166
 
167
   assign div_input_data_d[11:0] = {1'b1, // isdiv
168
                                    ifu_exu_muls_d,
169
                                    ifu_exu_muldivop_d[2], // 64bit
170
                                    ifu_exu_muldivop_d[1], // signed
171
                                    ifu_exu_muldivop_d[0], // setcc
172
                                    ifu_exu_rd_d[4:0],
173
                                    tid_d[1:0]};
174
   mux2ds #(12) div_data_mux(.dout(div_data_next[11:0]),
175
                                .in0({curr_div_vld, div_data[10:0]}),
176
                                .in1(div_input_data_d[11:0]),
177
                                .sel0(~new_div_vld),
178
                                .sel1(new_div_vld));
179
 
180 113 albert.wat
   dffr_s #(12) div_data_dff(.din(div_data_next[11:0]), .clk(clk), .q(div_data[11:0]),
181
                          .se(se), `SIMPLY_RISC_SCANIN, .so(), .rst(reset));
182 95 fafa1971
 
183
   //div  kill logic (kills on div by zero exception or if there isn't an outstanding div)
184 113 albert.wat
   assign div_zero_e = isdiv_e & div_ecl_detect_zero_high & div_ecl_detect_zero_low & ~div_data[`MULS];
185 95 fafa1971
   assign invalid_div_w = isdiv_w & (~ifu_exu_inst_vld_w | ifu_tlu_flush_w | early_flush_w);
186
   assign kill_thr_div = ~(div_data[1] ^ tid_w1[1]) & ~(div_data[0] ^ tid_w1[0]);
187
   assign div_kill = (flush_w1 & kill_thr_div) | invalid_div_w | new_div_vld;
188
   assign curr_div_vld = div_data[11] & ~div_zero_m & ~div_kill & ~div_used;
189
 
190
   wire   div_zero_unqual_m;
191
   assign div_zero_m = div_zero_unqual_m & isdiv_m;
192 113 albert.wat
   dff_s div_zero_e2m(.din(div_zero_e), .clk(clk), .q(div_zero_unqual_m), .se(se), `SIMPLY_RISC_SCANIN, .so());
193 95 fafa1971
 
194
   // pipeling for divide valid signal (for inst_vld checking)
195 113 albert.wat
   dff_s isdiv_d2e(.din(new_div_vld), .clk(clk), .q(isdiv_e),
196
                 .se(se), `SIMPLY_RISC_SCANIN, .so());
197
   dff_s isdiv_e2m(.din(isdiv_e_valid), .clk(clk), .q(isdiv_m),
198
                 .se(se), `SIMPLY_RISC_SCANIN, .so());
199
   dff_s isdiv_m2w(.din(isdiv_m_valid), .clk(clk), .q(isdiv_w),
200
                 .se(se), `SIMPLY_RISC_SCANIN, .so());
201 95 fafa1971
   assign        isdiv_e_valid = isdiv_e & ~div_kill;
202
   assign        isdiv_m_valid = isdiv_m & ~div_kill;
203
 
204
   // control for div state machine
205
   assign mdqctl_divcntl_reset_div = (~div_data[11] | div_kill);
206
   assign mdqctl_divcntl_input_vld = isdiv_e;
207
 
208
   // control signals for div
209 113 albert.wat
   assign ecl_div_div64 = div_data[`IS64];
210
   assign ecl_div_signed_div = div_data[`SIGNED];
211
   assign ecl_div_muls = div_data[`MULS];
212 95 fafa1971
 
213
   // control for writeback on completion
214
   assign mdqctl_wb_divrd_g[4:0] = div_data[6:2];
215
   assign mdqctl_wb_divthr_g[1:0] = div_data[1:0];
216 113 albert.wat
   assign mdqctl_wb_divsetcc_g = div_data[`SET_CC] | div_data[`MULS];
217
   assign mdqctl_wb_yreg_shift_g = div_used & div_data[`MULS];
218 95 fafa1971
 
219
 
220
   ////////////////////////////////////////////////////////////////////////////
221
   // Multiply control
222
   //----------------------
223
   // The multiply will drop the current operation if a new request is issued.
224
   // This requires addition checking to make sure that the kills are for the
225
   // proper operation.
226
   ////////////////////////////////////////////////////////////////////////////
227 113 albert.wat
   dff_s ismul_d2e(.din(ifu_exu_muldivop_d[4]), .clk(clk), .q(ismul_e),
228
                 .se(se), `SIMPLY_RISC_SCANIN, .so());
229
   dff_s ismul_e2m(.din(ismul_e_valid), .clk(clk), .q(ismul_m),
230
                 .se(se), `SIMPLY_RISC_SCANIN, .so());
231
   dff_s ismul_m2w(.din(ismul_m_valid), .clk(clk), .q(ismul_w),
232
                 .se(se), `SIMPLY_RISC_SCANIN, .so());
233 95 fafa1971
   assign ismul_e_valid = ismul_e & ~mul_kill;
234
   assign        ismul_m_valid = ismul_m & ~mul_kill & ~ismul_e;
235
 
236
   // store control signals
237
  //   assign mul_used = divcntl_wb_req_g & wb_divcntl_ack_g & ~ecl_div_sel_div;
238
   assign new_mul_d = ifu_exu_muldivop_d[4];
239
 
240
   assign mul_input_data_d[9:0] = {ifu_exu_muldivop_d[2], // 64bit
241
                                    ifu_exu_muldivop_d[1], // signed
242
                                    ifu_exu_muldivop_d[0], // setcc
243
                                    ifu_exu_rd_d[4:0],
244
                                    tid_d[1:0]};
245
   assign mul_data_next[9:0] = (new_mul_d)? mul_input_data_d[9:0]: mul_data[9:0];
246
 
247 113 albert.wat
   dff_s #(10) mul_data_dff(.din(mul_data_next[9:0]), .clk(clk), .q(mul_data[9:0]),
248
                          .se(se), `SIMPLY_RISC_SCANIN, .so());
249 95 fafa1971
 
250
   // mul kill logic
251
   assign kill_thr_mul = ~(mul_data[1] ^ tid_w1[1]) & ~(mul_data[0] ^ tid_w1[0]);
252
   assign mul_kill = (flush_w1 & kill_thr_mul) | reset;
253
   assign invalid_mul_w = ismul_w & ~ifu_exu_inst_vld_w;
254
 
255
   // control signals for mul data in div unit
256
   assign      ecl_div_mul_keep_data = ~ismul_e;
257 113 albert.wat
   assign      ecl_div_mul_get_new_data = ismul_e & mul_data[`IS64];
258
   assign      ecl_div_mul_get_32bit_data = ismul_e & ~mul_data[`IS64];
259
   assign      ecl_div_mul_sext_rs1_e = byp_alu_rs1_data_31_e & mul_data[`SIGNED];
260
   assign      ecl_div_mul_sext_rs2_e = byp_alu_rs2_data_31_e & mul_data[`SIGNED];
261 95 fafa1971
 
262
   // control for writeback on completion
263 113 albert.wat
   assign      mdqctl_wb_yreg_wen_g = ~mul_data[`IS64] & ecl_div_mul_wen;
264 95 fafa1971
   assign      mdqctl_wb_multhr_g[1:0] = mul_data[1:0];
265 113 albert.wat
   assign      mdqctl_wb_mulsetcc_g = mul_data[`SET_CC];
266 95 fafa1971
   assign      mdqctl_wb_mulrd_g[4:0] = mul_data[6:2];
267
 
268
   // interface with mul and state of pending mul
269
   assign      mul_ready_next = ismul_e_valid | (mul_ready & ~mul_exu_ack & ~mul_kill & ~ismul_e & ~invalid_mul_w);
270 113 albert.wat
   dff_s mul_ready_dff(.din(mul_ready_next), .clk(clk), .q(mul_ready), .se(se), `SIMPLY_RISC_SCANIN, .so());
271 95 fafa1971
 
272
   assign      exu_mul_input_vld = mul_ready;
273
 
274
   // If there was a valid request and an ack then start passing down pipe
275
   assign      mul_done_ack = mul_ready & ~mul_kill & ~ismul_e & mul_exu_ack & ~invalid_mul_w;
276 113 albert.wat
   dff_s dff_done_ack2c0(.din(mul_done_ack), .clk(clk), .q(mul_done_c0),
277
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
278 95 fafa1971
   // need to check here cause this could be w
279
   assign        mul_done_valid_c0 = mul_done_c0 & ~mul_kill & ~invalid_mul_w & ~ismul_e;
280 113 albert.wat
   dff_s dff_done_c02c1(.din(mul_done_valid_c0), .clk(clk), .q(mul_done_c1),
281
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
282 95 fafa1971
   // need to check here cause this could be w1
283
   assign        mul_done_valid_c1 = mul_done_c1 & ~mul_kill & ~ismul_e;
284 113 albert.wat
   dff_s dff_done_c1c2(.din(mul_done_valid_c1), .clk(clk), .q(mul_done_c2),
285
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
286
   dff_s dff_done_c22c3(.din(mul_done_c2), .clk(clk), .q(mul_done_c3),
287
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
288
   dff_s dff_done_c32c4(.din(mul_done_c3), .clk(clk), .q(ecl_div_mul_wen),
289
                       .se(se), `SIMPLY_RISC_SCANIN, .so());
290 95 fafa1971
 
291
   // Mul result state machine
292
   assign        go_mul_done = ~mul_done & ecl_div_mul_wen;
293
   assign        stay_mul_done = mul_done & (~wb_divcntl_ack_g | ecl_div_sel_div);
294
   assign        next_mul_done = ~reset & (go_mul_done | stay_mul_done);
295
 
296
   assign        mdqctl_divcntl_muldone = mul_done;
297
 
298
   // mul state flop
299 113 albert.wat
   dff_s  mulstate_dff(.din(next_mul_done), .clk(clk), .q(mul_done), .se(se), `SIMPLY_RISC_SCANIN,
300 95 fafa1971
                     .so());
301
 
302
   /////////////////////////////////////////
303
   // Pipeline registers for control signals
304
   /////////////////////////////////////////
305
 
306
 
307
endmodule // sparc_exu_ecl_mdqctl

powered by: WebSVN 2.1.0

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