1 |
43 |
robfinch |
//
|
2 |
|
|
// COPYRIGHT 2000 by Bruce L. Jacob
|
3 |
|
|
// (contact info: http://www.ece.umd.edu/~blj/)
|
4 |
|
|
//
|
5 |
|
|
// You are welcome to use, modify, copy, and/or redistribute this implementation, provided:
|
6 |
|
|
// 1. you share with the author (Bruce Jacob) any changes you make;
|
7 |
|
|
// 2. you properly credit the author (Bruce Jacob) if used within a larger work; and
|
8 |
|
|
// 3. you do not modify, delete, or in any way obscure the implementation's copyright
|
9 |
|
|
// notice or following comments (i.e. the first 3-4 dozen lines of this file).
|
10 |
|
|
//
|
11 |
|
|
// RiSC-16
|
12 |
|
|
//
|
13 |
|
|
// This is an out-of-order implementation of the RiSC-16, a teaching instruction-set used by
|
14 |
|
|
// the author at the University of Maryland, and which is a blatant (but sanctioned) rip-off
|
15 |
|
|
// of the Little Computer (LC-896) developed by Peter Chen at the University of Michigan.
|
16 |
|
|
// The primary differences include the following:
|
17 |
|
|
// 1. a move from 17-bit to 16-bit instructions; and
|
18 |
|
|
// 2. the replacement of the NOP and HALT opcodes by ADDI and LUI ... HALT and NOP are
|
19 |
|
|
// now simply special instances of other instructions: NOP is a do-nothing ADD, and
|
20 |
|
|
// HALT is a subset of JALR.
|
21 |
|
|
//
|
22 |
|
|
// RiSC stands for Ridiculously Simple Computer, which makes sense in the context in which
|
23 |
|
|
// the instruction-set is normally used -- to teach simple organization and architecture to
|
24 |
|
|
// undergraduates who do not yet know how computers work. This implementation was targetted
|
25 |
|
|
// towards more advanced undergraduates doing design & implementation and was intended to
|
26 |
|
|
// demonstrate some high-performance concepts on a small scale -- an 8-entry reorder buffer,
|
27 |
|
|
// eight opcodes, two ALUs, two-way issue, two-way commit, etc. However, the out-of-order
|
28 |
|
|
// core is much more complex than I anticipated, and I hope that its complexity does not
|
29 |
|
|
// obscure its underlying structure. We'll see how well it flies in class ...
|
30 |
|
|
//
|
31 |
|
|
// CAVEAT FREELOADER: This Verilog implementation was developed and debugged in a (somewhat
|
32 |
|
|
// frantic) 2-week period before the start of the Fall 2000 semester. Not surprisingly, it
|
33 |
|
|
// still contains many bugs and some horrible, horrible logic. The logic is also written so
|
34 |
|
|
// as to be debuggable and/or explain its function, rather than to be efficient -- e.g. in
|
35 |
|
|
// several places, signals are over-constrained so that they are easy to read in the debug
|
36 |
|
|
// output ... also, you will see statements like
|
37 |
|
|
//
|
38 |
|
|
// if (xyz[`INSTRUCTION_OP] == `BEQ || xyz[`INSTRUCTION_OP] == `SW)
|
39 |
|
|
//
|
40 |
|
|
// instead of and/nand combinations of bits ... sorry; can't be helped. Use at your own risk.
|
41 |
|
|
//
|
42 |
|
|
// DOCUMENTATION: Documents describing the RiSC-16 in all its forms (sequential, pipelined,
|
43 |
|
|
// as well as out-of-order) can be found on the author's website at the following URL:
|
44 |
|
|
//
|
45 |
|
|
// http://www.ece.umd.edu/~blj/RiSC/
|
46 |
|
|
//
|
47 |
|
|
// If you do not find what you are looking for, please feel free to email me with suggestions
|
48 |
|
|
// for more/different/modified documents. Same goes for bug fixes.
|
49 |
|
|
//
|
50 |
|
|
//
|
51 |
|
|
// KNOWN PROBLEMS (i.e., bugs I haven't got around to fixing yet)
|
52 |
|
|
//
|
53 |
|
|
// - If the target of a backwards branch is a backwards branch, the fetchbuf steering logic
|
54 |
|
|
// will get confused. This can be fixed by having a separate did_branchback status register
|
55 |
|
|
// for each of the fetch buffers.
|
56 |
|
|
//
|
57 |
|
|
// ============================================================================
|
58 |
|
|
// __
|
59 |
|
|
// \\__/ o\ (C) 2017-2018 Robert Finch, Waterloo
|
60 |
|
|
// \ __ / All rights reserved.
|
61 |
|
|
// \/_// robfinch<remove>@finitron.ca
|
62 |
|
|
// ||
|
63 |
|
|
//
|
64 |
|
|
// FT64.v
|
65 |
|
|
// Modification to RiSC-16 include:
|
66 |
|
|
// - move to 32 bit instructions
|
67 |
|
|
// - additional instructions added
|
68 |
|
|
// - vector instruction set,
|
69 |
|
|
// - SIMD instructions
|
70 |
|
|
// - extension of data width to 64 bits
|
71 |
|
|
// - 32 general purpose registers
|
72 |
|
|
// - 32 floating point registers
|
73 |
|
|
// - 32 vector registers, length 63
|
74 |
|
|
// - addition of more powerful branch prediction
|
75 |
|
|
// - branch target buffer (BTB)
|
76 |
|
|
// - return address predictor (RSB)
|
77 |
|
|
// - bus interface unit
|
78 |
|
|
// - instruction and data caches
|
79 |
|
|
// - asynchronous logic loops for issue and branch miss
|
80 |
|
|
// re-written for synchronous operation, not as elegant
|
81 |
|
|
// but required for operation in an FPGA
|
82 |
|
|
// - fine-grained simultaneous multi-threading (SMT)
|
83 |
|
|
//
|
84 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
85 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
86 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
87 |
|
|
// (at your option) any later version.
|
88 |
|
|
//
|
89 |
|
|
// This source file is distributed in the hope that it will be useful,
|
90 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
91 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
92 |
|
|
// GNU General Public License for more details.
|
93 |
|
|
//
|
94 |
|
|
// You should have received a copy of the GNU General Public License
|
95 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
96 |
|
|
//
|
97 |
|
|
// Approx. 100,000 LUTs. 160,000 LC's.
|
98 |
|
|
// ============================================================================
|
99 |
|
|
//
|
100 |
|
|
`include "FT64_defines.vh"
|
101 |
|
|
`define SUPPORT_SMT 1'b1
|
102 |
|
|
//`define SUPPORT_DBG 1'b1
|
103 |
|
|
`define FULL_ISSUE_LOGIC 1'b1
|
104 |
|
|
`define QBITS 2:0
|
105 |
|
|
`define QENTRIES 8
|
106 |
|
|
|
107 |
|
|
module FT64(hartid, rst, clk, clk4x, irq_i, vec_i, bte_o, cti_o, cyc_o, stb_o, ack_i, err_i, we_o, sel_o, adr_o, dat_o, dat_i,
|
108 |
|
|
ol_o, pcr_o, pcr2_o, exv_i, rdv_i, wrv_i, icl_o, sr_o, cr_o, rbi_i, signal_i);
|
109 |
|
|
input [63:0] hartid;
|
110 |
|
|
input rst;
|
111 |
|
|
input clk;
|
112 |
|
|
input clk4x;
|
113 |
|
|
input [2:0] irq_i;
|
114 |
|
|
input [8:0] vec_i;
|
115 |
|
|
output reg [1:0] bte_o;
|
116 |
|
|
output reg [2:0] cti_o;
|
117 |
|
|
output reg cyc_o;
|
118 |
|
|
output reg stb_o;
|
119 |
|
|
input ack_i;
|
120 |
|
|
input err_i;
|
121 |
|
|
output reg we_o;
|
122 |
|
|
output reg [7:0] sel_o;
|
123 |
|
|
output reg [31:0] adr_o;
|
124 |
|
|
output reg [63:0] dat_o;
|
125 |
|
|
input [63:0] dat_i;
|
126 |
|
|
output [2:0] ol_o;
|
127 |
|
|
output [31:0] pcr_o;
|
128 |
|
|
output [63:0] pcr2_o;
|
129 |
|
|
input exv_i;
|
130 |
|
|
input rdv_i;
|
131 |
|
|
input wrv_i;
|
132 |
|
|
output reg icl_o;
|
133 |
|
|
output reg cr_o;
|
134 |
|
|
output reg sr_o;
|
135 |
|
|
input rbi_i;
|
136 |
|
|
input [31:0] signal_i;
|
137 |
|
|
|
138 |
|
|
parameter QENTRIES = `QENTRIES;
|
139 |
|
|
parameter RSTPC = 32'hFFFC0100;
|
140 |
|
|
parameter BRKPC = 32'hFFFC0000;
|
141 |
|
|
`ifdef SUPPORT_SMT
|
142 |
|
|
parameter PREGS = 256; // number of physical registers - 1
|
143 |
|
|
parameter AREGS = 256; // number of architectural registers
|
144 |
|
|
`else
|
145 |
|
|
parameter PREGS = 128;
|
146 |
|
|
parameter AREGS = 128;
|
147 |
|
|
`endif
|
148 |
|
|
parameter RBIT = 11;
|
149 |
|
|
parameter DEBUG = 1'b0;
|
150 |
|
|
parameter NMAP = QENTRIES;
|
151 |
|
|
parameter BRANCH_PRED = 1'b0;
|
152 |
|
|
parameter SUP_TXE = 1'b0;
|
153 |
|
|
parameter SUP_VECTOR = 1;
|
154 |
|
|
parameter DBW = 64;
|
155 |
|
|
parameter ABW = 32;
|
156 |
|
|
parameter AMSB = ABW-1;
|
157 |
|
|
parameter NTHREAD = 1;
|
158 |
|
|
reg [3:0] i;
|
159 |
|
|
integer n;
|
160 |
|
|
integer j;
|
161 |
|
|
genvar g;
|
162 |
|
|
parameter TRUE = 1'b1;
|
163 |
|
|
parameter FALSE = 1'b0;
|
164 |
|
|
// Memory access sizes
|
165 |
|
|
parameter byt = 3'd0;
|
166 |
|
|
parameter wyde = 3'd1;
|
167 |
|
|
parameter tetra = 3'd2;
|
168 |
|
|
parameter octa = 3'd3;
|
169 |
|
|
|
170 |
|
|
wire [RBIT:0] Ra0, Ra1;
|
171 |
|
|
wire [RBIT:0] Rb0, Rb1;
|
172 |
|
|
wire [RBIT:0] Rc0, Rc1;
|
173 |
|
|
wire [RBIT:0] Rt0, Rt1;
|
174 |
|
|
wire [63:0] rfoa0,rfob0,rfoc0,rfoc0a;
|
175 |
|
|
wire [63:0] rfoa1,rfob1,rfoc1,rfoc1a;
|
176 |
|
|
`ifdef SUPPORT_SMT
|
177 |
|
|
wire [7:0] Ra0s = {Ra0[7:0]};
|
178 |
|
|
wire [7:0] Ra1s = {Ra1[7:0]};
|
179 |
|
|
wire [7:0] Rb0s = {Rb0[7:0]};
|
180 |
|
|
wire [7:0] Rb1s = {Rb1[7:0]};
|
181 |
|
|
wire [7:0] Rc0s = {Rc0[7:0]};
|
182 |
|
|
wire [7:0] Rc1s = {Rc1[7:0]};
|
183 |
|
|
wire [7:0] Rt0s = {Rt0[7:0]};
|
184 |
|
|
wire [7:0] Rt1s = {Rt1[7:0]};
|
185 |
|
|
`else
|
186 |
|
|
wire [6:0] Ra0s = {Ra0[7],Ra0[5:0]};
|
187 |
|
|
wire [6:0] Ra1s = {Ra1[7],Ra1[5:0]};
|
188 |
|
|
wire [6:0] Rb0s = {Rb0[7],Rb0[5:0]};
|
189 |
|
|
wire [6:0] Rb1s = {Rb1[7],Rb1[5:0]};
|
190 |
|
|
wire [6:0] Rc0s = {Rc0[7],Rc0[5:0]};
|
191 |
|
|
wire [6:0] Rc1s = {Rc1[7],Rc1[5:0]};
|
192 |
|
|
wire [6:0] Rt0s = {Rt0[7],Rt0[5:0]};
|
193 |
|
|
wire [6:0] Rt1s = {Rt1[7],Rt1[5:0]};
|
194 |
|
|
/*
|
195 |
|
|
wire [5:0] Ra0s = {Ra0[5:0]};
|
196 |
|
|
wire [5:0] Ra1s = {Ra1[5:0]};
|
197 |
|
|
wire [5:0] Rb0s = {Rb0[5:0]};
|
198 |
|
|
wire [5:0] Rb1s = {Rb1[5:0]};
|
199 |
|
|
wire [5:0] Rc0s = {Rc0[5:0]};
|
200 |
|
|
wire [5:0] Rc1s = {Rc1[5:0]};
|
201 |
|
|
wire [5:0] Rt0s = {Rt0[5:0]};
|
202 |
|
|
wire [5:0] Rt1s = {Rt1[5:0]};
|
203 |
|
|
*/
|
204 |
|
|
`endif
|
205 |
|
|
|
206 |
|
|
reg [PREGS-1:0] rf_v;
|
207 |
|
|
reg [4:0] rf_source[0:AREGS-1];
|
208 |
|
|
initial begin
|
209 |
|
|
for (n = 0; n < AREGS; n = n + 1)
|
210 |
|
|
rf_source[n] = 5'd0;
|
211 |
|
|
end
|
212 |
|
|
wire [31:0] pc0;
|
213 |
|
|
wire [31:0] pc1;
|
214 |
|
|
|
215 |
|
|
reg excmiss;
|
216 |
|
|
reg [31:0] excmisspc;
|
217 |
|
|
reg excthrd;
|
218 |
|
|
reg exception_set;
|
219 |
|
|
reg rdvq; // accumulated read violation
|
220 |
|
|
reg errq; // accumulated err_i input status
|
221 |
|
|
reg exvq;
|
222 |
|
|
|
223 |
|
|
// Vector
|
224 |
|
|
reg [5:0] vqe0, vqe1; // vector element being queued
|
225 |
|
|
reg [5:0] vqet0, vqet1;
|
226 |
|
|
reg [7:0] vl; // vector length
|
227 |
|
|
reg [63:0] vm [0:7]; // vector mask registers
|
228 |
|
|
reg [1:0] m2;
|
229 |
|
|
|
230 |
|
|
// CSR's
|
231 |
|
|
reg [63:0] cr0;
|
232 |
|
|
wire snr = cr0[17]; // sequence number reset
|
233 |
|
|
wire dce = cr0[30]; // data cache enable
|
234 |
|
|
wire bpe = cr0[32]; // branch predictor enable
|
235 |
|
|
wire ctgtxe = cr0[33];
|
236 |
|
|
// Simply setting this flag to zero should strip out almost all the logic
|
237 |
|
|
// associated SMT.
|
238 |
|
|
`ifdef SUPPORT_SMT
|
239 |
|
|
wire thread_en = cr0[16];
|
240 |
|
|
`else
|
241 |
|
|
wire thread_en = 1'b0;
|
242 |
|
|
`endif
|
243 |
|
|
wire vechain = cr0[18];
|
244 |
|
|
reg [7:0] fcu_timeout;
|
245 |
|
|
reg [63:0] tick;
|
246 |
|
|
reg [31:0] pcr;
|
247 |
|
|
reg [63:0] pcr2;
|
248 |
|
|
assign pcr_o = pcr;
|
249 |
|
|
assign pcr2_o = pcr2;
|
250 |
|
|
reg [63:0] aec;
|
251 |
|
|
reg [15:0] cause[0:15];
|
252 |
|
|
reg [31:0] epc [0:NTHREAD];
|
253 |
|
|
reg [31:0] epc0 [0:NTHREAD];
|
254 |
|
|
reg [31:0] epc1 [0:NTHREAD];
|
255 |
|
|
reg [31:0] epc2 [0:NTHREAD];
|
256 |
|
|
reg [31:0] epc3 [0:NTHREAD];
|
257 |
|
|
reg [31:0] epc4 [0:NTHREAD];
|
258 |
|
|
reg [31:0] epc5 [0:NTHREAD];
|
259 |
|
|
reg [31:0] epc6 [0:NTHREAD];
|
260 |
|
|
reg [31:0] epc7 [0:NTHREAD];
|
261 |
|
|
reg [31:0] epc8 [0:NTHREAD]; // exception pc and stack
|
262 |
|
|
reg [63:0] mstatus [0:NTHREAD]; // machine status
|
263 |
|
|
wire [2:0] im = mstatus[0][2:0];
|
264 |
|
|
wire [2:0] ol [0:NTHREAD];
|
265 |
|
|
assign ol[0] = mstatus[0][5:3]; // operating level
|
266 |
|
|
wire [7:0] cpl [0:NTHREAD];
|
267 |
|
|
assign cpl[0] = mstatus[0][13:6]; // current privilege level
|
268 |
|
|
wire [5:0] rgs [0:NTHREAD];
|
269 |
|
|
assign rgs[0] = mstatus[0][19:14];
|
270 |
|
|
`ifdef SUPPORT_SMT
|
271 |
|
|
assign ol[1] = mstatus[1][5:3]; // operating level
|
272 |
|
|
assign cpl[1] = mstatus[1][13:6]; // current privilege level
|
273 |
|
|
assign rgs[1] = mstatus[1][19:14];
|
274 |
|
|
`endif
|
275 |
|
|
reg [23:0] ol_stack [0:NTHREAD];
|
276 |
|
|
reg [23:0] im_stack [0:NTHREAD];
|
277 |
|
|
reg [63:0] pl_stack [0:NTHREAD];
|
278 |
|
|
reg [63:0] rs_stack [0:NTHREAD];
|
279 |
|
|
reg [63:0] fr_stack [0:NTHREAD];
|
280 |
|
|
wire mprv = mstatus[0][55];
|
281 |
|
|
wire [5:0] fprgs = mstatus[0][25:20];
|
282 |
|
|
assign ol_o = mprv ? ol_stack[0][2:0] : ol[0];
|
283 |
|
|
wire vca = mstatus[0][32]; // vector chaining active
|
284 |
|
|
reg [31:0] badaddr[0:15];
|
285 |
|
|
reg [31:0] tvec[0:7];
|
286 |
|
|
reg [63:0] sema;
|
287 |
|
|
reg [63:0] cas; // compare and swap
|
288 |
|
|
reg [63:0] ve_hold;
|
289 |
|
|
reg isCAS, isAMO;
|
290 |
|
|
reg [`QBITS] casid;
|
291 |
|
|
reg [31:0] sbl, sbu;
|
292 |
|
|
reg [4:0] regLR = 5'd29;
|
293 |
|
|
|
294 |
|
|
reg [2:0] fp_rm;
|
295 |
|
|
reg fp_inexe;
|
296 |
|
|
reg fp_dbzxe;
|
297 |
|
|
reg fp_underxe;
|
298 |
|
|
reg fp_overxe;
|
299 |
|
|
reg fp_invopxe;
|
300 |
|
|
reg fp_giopxe;
|
301 |
|
|
reg fp_nsfp = 1'b0;
|
302 |
|
|
reg fp_fractie;
|
303 |
|
|
reg fp_raz;
|
304 |
|
|
|
305 |
|
|
reg fp_neg;
|
306 |
|
|
reg fp_pos;
|
307 |
|
|
reg fp_zero;
|
308 |
|
|
reg fp_inf;
|
309 |
|
|
|
310 |
|
|
reg fp_inex; // inexact exception
|
311 |
|
|
reg fp_dbzx; // divide by zero exception
|
312 |
|
|
reg fp_underx; // underflow exception
|
313 |
|
|
reg fp_overx; // overflow exception
|
314 |
|
|
reg fp_giopx; // global invalid operation exception
|
315 |
|
|
reg fp_sx; // summary exception
|
316 |
|
|
reg fp_swtx; // software triggered exception
|
317 |
|
|
reg fp_gx;
|
318 |
|
|
reg fp_invopx;
|
319 |
|
|
|
320 |
|
|
reg fp_infzerox;
|
321 |
|
|
reg fp_zerozerox;
|
322 |
|
|
reg fp_subinfx;
|
323 |
|
|
reg fp_infdivx;
|
324 |
|
|
reg fp_NaNCmpx;
|
325 |
|
|
reg fp_cvtx;
|
326 |
|
|
reg fp_sqrtx;
|
327 |
|
|
reg fp_snanx;
|
328 |
|
|
|
329 |
|
|
wire [31:0] fp_status = {
|
330 |
|
|
fp_rm,
|
331 |
|
|
fp_inexe,
|
332 |
|
|
fp_dbzxe,
|
333 |
|
|
fp_underxe,
|
334 |
|
|
fp_overxe,
|
335 |
|
|
fp_invopxe,
|
336 |
|
|
fp_nsfp,
|
337 |
|
|
|
338 |
|
|
fp_fractie,
|
339 |
|
|
fp_raz,
|
340 |
|
|
1'b0,
|
341 |
|
|
fp_neg,
|
342 |
|
|
fp_pos,
|
343 |
|
|
fp_zero,
|
344 |
|
|
fp_inf,
|
345 |
|
|
|
346 |
|
|
fp_swtx,
|
347 |
|
|
fp_inex,
|
348 |
|
|
fp_dbzx,
|
349 |
|
|
fp_underx,
|
350 |
|
|
fp_overx,
|
351 |
|
|
fp_giopx,
|
352 |
|
|
fp_gx,
|
353 |
|
|
fp_sx,
|
354 |
|
|
|
355 |
|
|
fp_cvtx,
|
356 |
|
|
fp_sqrtx,
|
357 |
|
|
fp_NaNCmpx,
|
358 |
|
|
fp_infzerox,
|
359 |
|
|
fp_zerozerox,
|
360 |
|
|
fp_infdivx,
|
361 |
|
|
fp_subinfx,
|
362 |
|
|
fp_snanx
|
363 |
|
|
};
|
364 |
|
|
|
365 |
|
|
reg [63:0] fpu_csr;
|
366 |
|
|
|
367 |
|
|
//reg [25:0] m[0:8191];
|
368 |
|
|
reg [3:0] panic; // indexes the message structure
|
369 |
|
|
reg [128:0] message [0:15]; // indexed by panic
|
370 |
|
|
|
371 |
|
|
wire int_commit;
|
372 |
|
|
reg StatusHWI;
|
373 |
|
|
reg [31:0] insn0, insn1;
|
374 |
|
|
wire [31:0] insn0a, insn1a;
|
375 |
|
|
reg tgtq;
|
376 |
|
|
// Only need enough bits in the seqnence number to cover the instructions in
|
377 |
|
|
// the queue plus an extra count for skipping on branch misses. In this case
|
378 |
|
|
// that would be four bits minimum (count 0 to 8).
|
379 |
|
|
reg [31:0] seq_num;
|
380 |
|
|
reg [31:0] seq_num1;
|
381 |
|
|
wire [63:0] rdat0,rdat1,rdat2;
|
382 |
|
|
reg [63:0] xdati;
|
383 |
|
|
|
384 |
|
|
reg canq1, canq2;
|
385 |
|
|
reg queued1;
|
386 |
|
|
reg queued2;
|
387 |
|
|
reg queuedNop;
|
388 |
|
|
|
389 |
|
|
reg [31:0] codebuf[0:63];
|
390 |
|
|
reg [7:0] setpred;
|
391 |
|
|
|
392 |
|
|
// instruction queue (ROB)
|
393 |
|
|
reg [31:0] iqentry_sn [0:QENTRIES-1]; // instruction sequence number
|
394 |
|
|
reg [QENTRIES-1:0] iqentry_v; // entry valid? -- this should be the first bit
|
395 |
|
|
reg iqentry_out [0:QENTRIES-1]; // instruction has been issued to an ALU ...
|
396 |
|
|
reg iqentry_done [0:QENTRIES-1]; // instruction result valid
|
397 |
|
|
reg iqentry_cmt [0:QENTRIES-1];
|
398 |
|
|
reg [QENTRIES-1:0] iqentry_thrd; // which thread the instruction is in
|
399 |
|
|
reg iqentry_pred [0:QENTRIES-1]; // predicate bit
|
400 |
|
|
reg iqentry_bt [0:QENTRIES-1]; // branch-taken (used only for branches)
|
401 |
|
|
reg iqentry_agen [0:QENTRIES-1]; // address-generate ... signifies that address is ready (only for LW/SW)
|
402 |
|
|
reg iqentry_alu [0:QENTRIES-1]; // alu type instruction
|
403 |
|
|
reg [QENTRIES-1:0] iqentry_alu0; // only valid on alu #0
|
404 |
|
|
reg iqentry_fpu [0:QENTRIES-1]; // floating point instruction
|
405 |
|
|
reg iqentry_fc [0:QENTRIES-1]; // flow control instruction
|
406 |
|
|
reg iqentry_canex[0:QENTRIES-1]; // true if it's an instruction that can exception
|
407 |
|
|
reg iqentry_load [0:QENTRIES-1]; // is a memory load instruction
|
408 |
|
|
reg iqentry_mem [0:QENTRIES-1]; // touches memory: 1 if LW/SW
|
409 |
|
|
reg iqentry_memndx [0:QENTRIES-1]; // indexed memory operation
|
410 |
|
|
reg iqentry_memdb [0:QENTRIES-1];
|
411 |
|
|
reg iqentry_memsb [0:QENTRIES-1];
|
412 |
|
|
reg iqentry_aq [0:QENTRIES-1]; // memory aquire
|
413 |
|
|
reg iqentry_rl [0:QENTRIES-1]; // memory release
|
414 |
|
|
reg iqentry_jmp [0:QENTRIES-1]; // changes control flow: 1 if BEQ/JALR
|
415 |
|
|
reg iqentry_br [0:QENTRIES-1]; // Bcc (for predictor)
|
416 |
|
|
reg iqentry_sync [0:QENTRIES-1]; // sync instruction
|
417 |
|
|
reg iqentry_fsync[0:QENTRIES-1];
|
418 |
|
|
reg iqentry_rfw [0:QENTRIES-1]; // writes to register file
|
419 |
|
|
reg [7:0] iqentry_we [0:QENTRIES-1]; // enable strobe
|
420 |
|
|
reg [63:0] iqentry_res [0:QENTRIES-1]; // instruction result
|
421 |
|
|
reg [31:0] iqentry_instr[0:QENTRIES-1]; // instruction opcode
|
422 |
|
|
reg [3:0] iqentry_exc [0:QENTRIES-1]; // only for branches ... indicates a HALT instruction
|
423 |
|
|
reg [RBIT:0] iqentry_tgt [0:QENTRIES-1]; // Rt field or ZERO -- this is the instruction's target (if any)
|
424 |
|
|
reg [5:0] iqentry_ven [0:QENTRIES-1]; // vector element number
|
425 |
|
|
reg [63:0] iqentry_a0 [0:QENTRIES-1]; // argument 0 (immediate)
|
426 |
|
|
reg [63:0] iqentry_a1 [0:QENTRIES-1]; // argument 1
|
427 |
|
|
reg iqentry_a1_v [0:QENTRIES-1]; // arg1 valid
|
428 |
|
|
reg [4:0] iqentry_a1_s [0:QENTRIES-1]; // arg1 source (iq entry # with top bit representing ALU/DRAM bus)
|
429 |
|
|
reg [63:0] iqentry_a2 [0:QENTRIES-1]; // argument 2
|
430 |
|
|
reg iqentry_a2_v [0:QENTRIES-1]; // arg2 valid
|
431 |
|
|
reg [4:0] iqentry_a2_s [0:QENTRIES-1]; // arg2 source (iq entry # with top bit representing ALU/DRAM bus)
|
432 |
|
|
reg [63:0] iqentry_a3 [0:QENTRIES-1]; // argument 3
|
433 |
|
|
reg iqentry_a3_v [0:QENTRIES-1]; // arg3 valid
|
434 |
|
|
reg [4:0] iqentry_a3_s [0:QENTRIES-1]; // arg3 source (iq entry # with top bit representing ALU/DRAM bus)
|
435 |
|
|
reg [31:0] iqentry_pc [0:QENTRIES-1]; // program counter for this instruction
|
436 |
|
|
reg [RBIT:0] iqentry_Ra [0:QENTRIES-1];
|
437 |
|
|
reg [RBIT:0] iqentry_Rb [0:QENTRIES-1];
|
438 |
|
|
reg [RBIT:0] iqentry_Rc [0:QENTRIES-1];
|
439 |
|
|
// debugging
|
440 |
|
|
//reg [4:0] iqentry_ra [0:7]; // Ra
|
441 |
|
|
initial begin
|
442 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
443 |
|
|
iqentry_a1_s[n] = 5'd0;
|
444 |
|
|
iqentry_a2_s[n] = 5'd0;
|
445 |
|
|
iqentry_a3_s[n] = 5'd0;
|
446 |
|
|
end
|
447 |
|
|
|
448 |
|
|
wire [QENTRIES-1:0] iqentry_source;
|
449 |
|
|
reg [QENTRIES-1:0] iqentry_imm;
|
450 |
|
|
wire [QENTRIES-1:0] iqentry_memready;
|
451 |
|
|
wire [QENTRIES-1:0] iqentry_memopsvalid;
|
452 |
|
|
|
453 |
|
|
reg [QENTRIES-1:0] memissue;
|
454 |
|
|
reg [1:0] missued;
|
455 |
|
|
integer last_issue;
|
456 |
|
|
reg [QENTRIES-1:0] iqentry_memissue;
|
457 |
|
|
wire [QENTRIES-1:0] iqentry_stomp;
|
458 |
|
|
reg [3:0] stompedOnRets;
|
459 |
|
|
reg [QENTRIES-1:0] iqentry_issue;
|
460 |
|
|
reg [1:0] iqentry_islot [0:QENTRIES-1];
|
461 |
|
|
reg [1:0] iqentry_mem_islot [0:QENTRIES-1];
|
462 |
|
|
reg [1:0] iqentry_fpu_islot [0:QENTRIES-1];
|
463 |
|
|
reg [QENTRIES-1:0] iqentry_fcu_issue;
|
464 |
|
|
reg [QENTRIES-1:0] iqentry_fpu_issue;
|
465 |
|
|
|
466 |
|
|
wire [PREGS-1:1] livetarget;
|
467 |
|
|
wire [PREGS-1:1] iqentry_0_livetarget;
|
468 |
|
|
wire [PREGS-1:1] iqentry_1_livetarget;
|
469 |
|
|
wire [PREGS-1:1] iqentry_2_livetarget;
|
470 |
|
|
wire [PREGS-1:1] iqentry_3_livetarget;
|
471 |
|
|
wire [PREGS-1:1] iqentry_4_livetarget;
|
472 |
|
|
wire [PREGS-1:1] iqentry_5_livetarget;
|
473 |
|
|
wire [PREGS-1:1] iqentry_6_livetarget;
|
474 |
|
|
wire [PREGS-1:1] iqentry_7_livetarget;
|
475 |
|
|
wire [PREGS-1:1] iqentry_0_latestID;
|
476 |
|
|
wire [PREGS-1:1] iqentry_1_latestID;
|
477 |
|
|
wire [PREGS-1:1] iqentry_2_latestID;
|
478 |
|
|
wire [PREGS-1:1] iqentry_3_latestID;
|
479 |
|
|
wire [PREGS-1:1] iqentry_4_latestID;
|
480 |
|
|
wire [PREGS-1:1] iqentry_5_latestID;
|
481 |
|
|
wire [PREGS-1:1] iqentry_6_latestID;
|
482 |
|
|
wire [PREGS-1:1] iqentry_7_latestID;
|
483 |
|
|
wire [PREGS-1:1] iqentry_0_cumulative;
|
484 |
|
|
wire [PREGS-1:1] iqentry_1_cumulative;
|
485 |
|
|
wire [PREGS-1:1] iqentry_2_cumulative;
|
486 |
|
|
wire [PREGS-1:1] iqentry_3_cumulative;
|
487 |
|
|
wire [PREGS-1:1] iqentry_4_cumulative;
|
488 |
|
|
wire [PREGS-1:1] iqentry_5_cumulative;
|
489 |
|
|
wire [PREGS-1:1] iqentry_6_cumulative;
|
490 |
|
|
wire [PREGS-1:1] iqentry_7_cumulative;
|
491 |
|
|
wire [PREGS-1:1] iq0_out;
|
492 |
|
|
wire [PREGS-1:1] iq1_out;
|
493 |
|
|
wire [PREGS-1:1] iq2_out;
|
494 |
|
|
wire [PREGS-1:1] iq3_out;
|
495 |
|
|
wire [PREGS-1:1] iq4_out;
|
496 |
|
|
wire [PREGS-1:1] iq5_out;
|
497 |
|
|
wire [PREGS-1:1] iq6_out;
|
498 |
|
|
wire [PREGS-1:1] iq7_out;
|
499 |
|
|
|
500 |
|
|
reg [`QBITS] tail0;
|
501 |
|
|
reg [`QBITS] tail1;
|
502 |
|
|
reg [`QBITS] head0;
|
503 |
|
|
reg [`QBITS] head1;
|
504 |
|
|
reg [`QBITS] head2; // used only to determine memory-access ordering
|
505 |
|
|
reg [`QBITS] head3; // used only to determine memory-access ordering
|
506 |
|
|
reg [`QBITS] head4; // used only to determine memory-access ordering
|
507 |
|
|
reg [`QBITS] head5; // used only to determine memory-access ordering
|
508 |
|
|
reg [`QBITS] head6; // used only to determine memory-access ordering
|
509 |
|
|
reg [`QBITS] head7; // used only to determine memory-access ordering
|
510 |
|
|
|
511 |
|
|
wire [`QBITS] missid;
|
512 |
|
|
wire take_branch0;
|
513 |
|
|
wire take_branch1;
|
514 |
|
|
|
515 |
|
|
reg [3:0] nop_fetchbuf;
|
516 |
|
|
wire fetchbuf; // determines which pair to read from & write to
|
517 |
|
|
|
518 |
|
|
wire [31:0] fetchbuf0_instr;
|
519 |
|
|
wire [31:0] fetchbuf0_pc;
|
520 |
|
|
wire fetchbuf0_v;
|
521 |
|
|
wire fetchbuf0_thrd;
|
522 |
|
|
wire fetchbuf0_mem;
|
523 |
|
|
wire fetchbuf0_memld;
|
524 |
|
|
wire fetchbuf0_jmp;
|
525 |
|
|
wire fetchbuf0_rfw;
|
526 |
|
|
wire [31:0] fetchbuf1_instr;
|
527 |
|
|
wire [31:0] fetchbuf1_pc;
|
528 |
|
|
wire fetchbuf1_v;
|
529 |
|
|
wire fetchbuf1_thrd;
|
530 |
|
|
wire fetchbuf1_mem;
|
531 |
|
|
wire fetchbuf1_memld;
|
532 |
|
|
wire fetchbuf1_jmp;
|
533 |
|
|
wire fetchbuf1_rfw;
|
534 |
|
|
|
535 |
|
|
wire [31:0] fetchbufA_instr;
|
536 |
|
|
wire [31:0] fetchbufA_pc;
|
537 |
|
|
wire fetchbufA_v;
|
538 |
|
|
wire [31:0] fetchbufB_instr;
|
539 |
|
|
wire [31:0] fetchbufB_pc;
|
540 |
|
|
wire fetchbufB_v;
|
541 |
|
|
wire [31:0] fetchbufC_instr;
|
542 |
|
|
wire [31:0] fetchbufC_pc;
|
543 |
|
|
wire fetchbufC_v;
|
544 |
|
|
wire [31:0] fetchbufD_instr;
|
545 |
|
|
wire [31:0] fetchbufD_pc;
|
546 |
|
|
wire fetchbufD_v;
|
547 |
|
|
|
548 |
|
|
//reg did_branchback0;
|
549 |
|
|
//reg did_branchback1;
|
550 |
|
|
|
551 |
|
|
reg alu0_ld;
|
552 |
|
|
reg alu0_available;
|
553 |
|
|
reg alu0_dataready;
|
554 |
|
|
wire alu0_done;
|
555 |
|
|
reg alu0_pred;
|
556 |
|
|
wire alu0_idle;
|
557 |
|
|
reg [3:0] alu0_sourceid;
|
558 |
|
|
reg [31:0] alu0_instr;
|
559 |
|
|
reg alu0_bt;
|
560 |
|
|
reg [63:0] alu0_argA;
|
561 |
|
|
reg [63:0] alu0_argB;
|
562 |
|
|
reg [63:0] alu0_argC;
|
563 |
|
|
reg [63:0] alu0_argI; // only used by BEQ
|
564 |
|
|
reg [RBIT:0] alu0_tgt;
|
565 |
|
|
reg [5:0] alu0_ven;
|
566 |
|
|
reg alu0_thrd;
|
567 |
|
|
reg [31:0] alu0_pc;
|
568 |
|
|
wire [63:0] alu0_bus;
|
569 |
|
|
wire [63:0] alu0b_bus;
|
570 |
|
|
wire [3:0] alu0_id;
|
571 |
|
|
wire [8:0] alu0_exc;
|
572 |
|
|
wire alu0_v;
|
573 |
|
|
wire alu0_branchmiss;
|
574 |
|
|
wire [31:0] alu0_misspc;
|
575 |
|
|
|
576 |
|
|
reg alu1_ld;
|
577 |
|
|
reg alu1_available;
|
578 |
|
|
reg alu1_dataready;
|
579 |
|
|
wire alu1_done;
|
580 |
|
|
reg alu1_pred;
|
581 |
|
|
wire alu1_idle;
|
582 |
|
|
reg [3:0] alu1_sourceid;
|
583 |
|
|
reg [31:0] alu1_instr;
|
584 |
|
|
reg alu1_bt;
|
585 |
|
|
reg [63:0] alu1_argA;
|
586 |
|
|
reg [63:0] alu1_argB;
|
587 |
|
|
reg [63:0] alu1_argC;
|
588 |
|
|
reg [63:0] alu1_argI; // only used by BEQ
|
589 |
|
|
reg [RBIT:0] alu1_tgt;
|
590 |
|
|
reg [5:0] alu1_ven;
|
591 |
|
|
reg [31:0] alu1_pc;
|
592 |
|
|
wire [63:0] alu1_bus;
|
593 |
|
|
wire [63:0] alu1b_bus;
|
594 |
|
|
wire [3:0] alu1_id;
|
595 |
|
|
wire [8:0] alu1_exc;
|
596 |
|
|
wire alu1_v;
|
597 |
|
|
wire alu1_branchmiss;
|
598 |
|
|
wire [31:0] alu1_misspc;
|
599 |
|
|
|
600 |
|
|
reg fpu_ld;
|
601 |
|
|
reg fpu_available;
|
602 |
|
|
reg fpu_dataready;
|
603 |
|
|
wire fpu_done;
|
604 |
|
|
reg fpu_pred;
|
605 |
|
|
wire fpu_idle;
|
606 |
|
|
reg [3:0] fpu_sourceid;
|
607 |
|
|
reg [31:0] fpu_instr;
|
608 |
|
|
reg [63:0] fpu_argA;
|
609 |
|
|
reg [63:0] fpu_argB;
|
610 |
|
|
reg [63:0] fpu_argC;
|
611 |
|
|
reg [63:0] fpu_argI; // only used by BEQ
|
612 |
|
|
reg [RBIT:0] fpu_tgt;
|
613 |
|
|
reg [31:0] fpu_pc;
|
614 |
|
|
wire [63:0] fpu_bus;
|
615 |
|
|
wire [3:0] fpu_id;
|
616 |
|
|
wire [8:0] fpu_exc;
|
617 |
|
|
wire fpu_v;
|
618 |
|
|
wire [31:0] fpu_status;
|
619 |
|
|
|
620 |
|
|
reg [63:0] waitctr;
|
621 |
|
|
reg fcu_ld;
|
622 |
|
|
reg fcu_dataready;
|
623 |
|
|
reg fcu_done;
|
624 |
|
|
reg fcu_pred;
|
625 |
|
|
reg fcu_idle = 1'b1;
|
626 |
|
|
reg [3:0] fcu_sourceid;
|
627 |
|
|
reg [31:0] fcu_instr;
|
628 |
|
|
reg fcu_call;
|
629 |
|
|
reg fcu_bt;
|
630 |
|
|
reg [63:0] fcu_argA;
|
631 |
|
|
reg [63:0] fcu_argB;
|
632 |
|
|
reg [63:0] fcu_argC;
|
633 |
|
|
reg [63:0] fcu_argI; // only used by BEQ
|
634 |
|
|
reg [63:0] fcu_argT;
|
635 |
|
|
reg [63:0] fcu_argT2;
|
636 |
|
|
reg [31:0] fcu_retadr;
|
637 |
|
|
reg fcu_retadr_v;
|
638 |
|
|
reg [31:0] fcu_pc;
|
639 |
|
|
wire [63:0] fcu_bus;
|
640 |
|
|
wire [3:0] fcu_id;
|
641 |
|
|
reg [8:0] fcu_exc;
|
642 |
|
|
wire fcu_v;
|
643 |
|
|
reg fcu_thrd;
|
644 |
|
|
reg fcu_branchmiss;
|
645 |
|
|
wire [31:0] fcu_misspc;
|
646 |
|
|
|
647 |
|
|
reg [63:0] amo_argA;
|
648 |
|
|
reg [63:0] amo_argB;
|
649 |
|
|
wire [63:0] amo_res;
|
650 |
|
|
reg [31:0] amo_instr;
|
651 |
|
|
|
652 |
|
|
wire branchmiss;
|
653 |
|
|
wire branchmiss_thrd;
|
654 |
|
|
wire [31:0] misspc;
|
655 |
|
|
wire take_branch;
|
656 |
|
|
wire take_branchA;
|
657 |
|
|
wire take_branchB;
|
658 |
|
|
wire take_branchC;
|
659 |
|
|
wire take_branchD;
|
660 |
|
|
|
661 |
|
|
wire dram_avail;
|
662 |
|
|
reg [2:0] dram0; // state of the DRAM request (latency = 4; can have three in pipeline)
|
663 |
|
|
reg [2:0] dram1; // state of the DRAM request (latency = 4; can have three in pipeline)
|
664 |
|
|
reg [2:0] dram2; // state of the DRAM request (latency = 4; can have three in pipeline)
|
665 |
|
|
reg [63:0] dram0_data;
|
666 |
|
|
reg [31:0] dram0_addr;
|
667 |
|
|
reg [31:0] dram0_instr;
|
668 |
|
|
reg [RBIT:0] dram0_tgt;
|
669 |
|
|
reg [3:0] dram0_id;
|
670 |
|
|
reg [8:0] dram0_exc;
|
671 |
|
|
reg dram0_unc;
|
672 |
|
|
reg [2:0] dram0_memsize;
|
673 |
|
|
reg dram0_load; // is a load operation
|
674 |
|
|
reg [63:0] dram1_data;
|
675 |
|
|
reg [31:0] dram1_addr;
|
676 |
|
|
reg [31:0] dram1_instr;
|
677 |
|
|
reg [RBIT:0] dram1_tgt;
|
678 |
|
|
reg [3:0] dram1_id;
|
679 |
|
|
reg [8:0] dram1_exc;
|
680 |
|
|
reg dram1_unc;
|
681 |
|
|
reg [2:0] dram1_memsize;
|
682 |
|
|
reg dram1_load;
|
683 |
|
|
reg [63:0] dram2_data;
|
684 |
|
|
reg [31:0] dram2_addr;
|
685 |
|
|
reg [31:0] dram2_instr;
|
686 |
|
|
reg [RBIT:0] dram2_tgt;
|
687 |
|
|
reg [3:0] dram2_id;
|
688 |
|
|
reg [8:0] dram2_exc;
|
689 |
|
|
reg dram2_unc;
|
690 |
|
|
reg [2:0] dram2_memsize;
|
691 |
|
|
reg dram2_load;
|
692 |
|
|
|
693 |
|
|
reg dramA_v;
|
694 |
|
|
reg [3:0] dramA_id;
|
695 |
|
|
reg [63:0] dramA_bus;
|
696 |
|
|
reg [8:0] dramA_exc;
|
697 |
|
|
reg dramB_v;
|
698 |
|
|
reg [3:0] dramB_id;
|
699 |
|
|
reg [63:0] dramB_bus;
|
700 |
|
|
reg [8:0] dramB_exc;
|
701 |
|
|
reg dramC_v;
|
702 |
|
|
reg [3:0] dramC_id;
|
703 |
|
|
reg [63:0] dramC_bus;
|
704 |
|
|
reg [8:0] dramC_exc;
|
705 |
|
|
|
706 |
|
|
wire outstanding_stores;
|
707 |
|
|
reg [63:0] I; // instruction count
|
708 |
|
|
|
709 |
|
|
reg commit0_v;
|
710 |
|
|
reg [4:0] commit0_id;
|
711 |
|
|
reg [RBIT:0] commit0_tgt;
|
712 |
|
|
reg [7:0] commit0_we;
|
713 |
|
|
reg [63:0] commit0_bus;
|
714 |
|
|
reg commit1_v;
|
715 |
|
|
reg [4:0] commit1_id;
|
716 |
|
|
reg [RBIT:0] commit1_tgt;
|
717 |
|
|
reg [7:0] commit1_we;
|
718 |
|
|
reg [63:0] commit1_bus;
|
719 |
|
|
|
720 |
|
|
reg [4:0] bstate;
|
721 |
|
|
parameter BIDLE = 5'd0;
|
722 |
|
|
parameter B1 = 5'd1;
|
723 |
|
|
parameter B2 = 5'd2;
|
724 |
|
|
parameter B3 = 5'd3;
|
725 |
|
|
parameter B4 = 5'd4;
|
726 |
|
|
parameter B5 = 5'd5;
|
727 |
|
|
parameter B6 = 5'd6;
|
728 |
|
|
parameter B7 = 5'd7;
|
729 |
|
|
parameter B8 = 5'd8;
|
730 |
|
|
parameter B9 = 5'd9;
|
731 |
|
|
parameter B10 = 5'd10;
|
732 |
|
|
parameter B11 = 5'd11;
|
733 |
|
|
parameter B12 = 5'd12;
|
734 |
|
|
parameter B13 = 5'd13;
|
735 |
|
|
parameter B14 = 5'd14;
|
736 |
|
|
parameter B15 = 5'd15;
|
737 |
|
|
parameter B16 = 5'd16;
|
738 |
|
|
parameter B17 = 5'd17;
|
739 |
|
|
parameter B18 = 5'd18;
|
740 |
|
|
parameter B19 = 5'd19;
|
741 |
|
|
parameter B2a = 5'd20;
|
742 |
|
|
parameter B2b = 5'd21;
|
743 |
|
|
parameter B2c = 5'd22;
|
744 |
|
|
parameter B2d = 5'd23;
|
745 |
|
|
parameter B20 = 5'd24;
|
746 |
|
|
reg [1:0] bwhich;
|
747 |
|
|
reg [3:0] icstate,picstate;
|
748 |
|
|
parameter IDLE = 4'd0;
|
749 |
|
|
parameter IC1 = 4'd1;
|
750 |
|
|
parameter IC2 = 4'd2;
|
751 |
|
|
parameter IC3 = 4'd3;
|
752 |
|
|
parameter IC4 = 4'd4;
|
753 |
|
|
parameter IC5 = 4'd5;
|
754 |
|
|
parameter IC6 = 4'd6;
|
755 |
|
|
parameter IC7 = 4'd7;
|
756 |
|
|
parameter IC8 = 4'd8;
|
757 |
|
|
parameter IC9 = 4'd9;
|
758 |
|
|
parameter IC10 = 4'd10;
|
759 |
|
|
parameter IC3a = 4'd11;
|
760 |
|
|
reg invic, invdc;
|
761 |
|
|
reg icwhich,icnxt,L2_nxt;
|
762 |
|
|
wire ihit0,ihit1,ihit2;
|
763 |
|
|
wire ihit = ihit0&ihit1;
|
764 |
|
|
reg phit;
|
765 |
|
|
wire threadx;
|
766 |
|
|
always @*
|
767 |
|
|
phit <= ihit&&icstate==IDLE;
|
768 |
|
|
reg [1:0] iccnt;
|
769 |
|
|
reg L1_wr0,L1_wr1;
|
770 |
|
|
reg L1_invline;
|
771 |
|
|
reg [7:0] L1_en;
|
772 |
|
|
reg [37:0] L1_adr, L2_adr;
|
773 |
|
|
reg [255:0] L2_rdat;
|
774 |
|
|
wire [255:0] L2_dato;
|
775 |
|
|
|
776 |
|
|
FT64_regfile2w6r_oc #(.RBIT(RBIT)) urf1
|
777 |
|
|
(
|
778 |
|
|
.clk(clk),
|
779 |
|
|
.clk4x(clk4x),
|
780 |
|
|
.wr0(commit0_v),
|
781 |
|
|
.wr1(commit1_v),
|
782 |
|
|
.we0(commit0_we),
|
783 |
|
|
.we1(commit1_we),
|
784 |
|
|
.wa0(commit0_tgt),
|
785 |
|
|
.wa1(commit1_tgt),
|
786 |
|
|
.i0(commit0_bus),
|
787 |
|
|
.i1(commit1_bus),
|
788 |
|
|
.rclk(~clk),
|
789 |
|
|
.ra0(Ra0),
|
790 |
|
|
.ra1(Rb0),
|
791 |
|
|
.ra2(Rc0),
|
792 |
|
|
.ra3(Ra1),
|
793 |
|
|
.ra4(Rb1),
|
794 |
|
|
.ra5(Rc1),
|
795 |
|
|
.o0(rfoa0),
|
796 |
|
|
.o1(rfob0),
|
797 |
|
|
.o2(rfoc0a),
|
798 |
|
|
.o3(rfoa1),
|
799 |
|
|
.o4(rfob1),
|
800 |
|
|
.o5(rfoc1a)
|
801 |
|
|
);
|
802 |
|
|
assign rfoc0 = Rc0[11:6]==6'h3F ? vm[Rc0[2:0]] : rfoc0a;
|
803 |
|
|
assign rfoc1 = Rc1[11:6]==6'h3F ? vm[Rc1[2:0]] : rfoc1a;
|
804 |
|
|
|
805 |
|
|
FT64_L1_icache uic0
|
806 |
|
|
(
|
807 |
|
|
.rst(rst),
|
808 |
|
|
.clk(clk),
|
809 |
|
|
.nxt(icnxt),
|
810 |
|
|
.wr(L1_wr0),
|
811 |
|
|
.en(L1_en),
|
812 |
|
|
.adr(icstate==IDLE||icstate==IC8 ? {pcr[5:0],pc0} : L1_adr),
|
813 |
|
|
.wadr(L1_adr),
|
814 |
|
|
.i(L2_rdat),
|
815 |
|
|
.o(insn0a),
|
816 |
|
|
.hit(ihit0),
|
817 |
|
|
.invall(invic),
|
818 |
|
|
.invline(L1_invline)
|
819 |
|
|
);
|
820 |
|
|
FT64_L1_icache uic1
|
821 |
|
|
(
|
822 |
|
|
.rst(rst),
|
823 |
|
|
.clk(clk),
|
824 |
|
|
.nxt(icnxt),
|
825 |
|
|
.wr(L1_wr1),
|
826 |
|
|
.en(L1_en),
|
827 |
|
|
.adr(icstate==IDLE||icstate==IC8 ? {pcr[5:0],pc1} : L1_adr),
|
828 |
|
|
.wadr(L1_adr),
|
829 |
|
|
.i(L2_rdat),
|
830 |
|
|
.o(insn1a),
|
831 |
|
|
.hit(ihit1),
|
832 |
|
|
.invall(invic),
|
833 |
|
|
.invline(L1_invline)
|
834 |
|
|
);
|
835 |
|
|
FT64_L2_icache uic2
|
836 |
|
|
(
|
837 |
|
|
.rst(rst),
|
838 |
|
|
.clk(clk),
|
839 |
|
|
.nxt(L2_nxt),
|
840 |
|
|
.wr(bstate==B7 && ack_i),
|
841 |
|
|
.adr(L2_adr),
|
842 |
|
|
.cnt(iccnt),
|
843 |
|
|
.exv_i(exvq),
|
844 |
|
|
.i(dat_i),
|
845 |
|
|
.err_i(errq),
|
846 |
|
|
.o(L2_dato),
|
847 |
|
|
.hit(ihit2),
|
848 |
|
|
.invall(invic),
|
849 |
|
|
.invline()
|
850 |
|
|
);
|
851 |
|
|
|
852 |
|
|
wire predict_taken;
|
853 |
|
|
wire predict_taken0;
|
854 |
|
|
wire predict_taken1;
|
855 |
|
|
wire predict_takenA;
|
856 |
|
|
wire predict_takenB;
|
857 |
|
|
wire predict_takenC;
|
858 |
|
|
wire predict_takenD;
|
859 |
|
|
wire predict_takenA1;
|
860 |
|
|
wire predict_takenB1;
|
861 |
|
|
wire predict_takenC1;
|
862 |
|
|
wire predict_takenD1;
|
863 |
|
|
wire P0 = iqentry_instr[head0][`INSTRUCTION_OP]==`CHK ? 1'b1 : iqentry_instr[head0][`INSTRUCTION_OP]==`BccR ? iqentry_instr[head0][27] : iqentry_instr[head0][22];
|
864 |
|
|
wire P1 = iqentry_instr[head1][`INSTRUCTION_OP]==`CHK ? 1'b1 : iqentry_instr[head1][`INSTRUCTION_OP]==`BccR ? iqentry_instr[head1][27] : iqentry_instr[head1][22];
|
865 |
|
|
wire BA = fetchbufA_instr[`INSTRUCTION_OP]==`CHK ? 1'b0 : fetchbufA_instr[`INSTRUCTION_OP]==`BccR ? fetchbufA_instr[26] : fetchbufA_instr[21];
|
866 |
|
|
wire BB = fetchbufB_instr[`INSTRUCTION_OP]==`CHK ? 1'b0 : fetchbufB_instr[`INSTRUCTION_OP]==`BccR ? fetchbufB_instr[26] : fetchbufB_instr[21];
|
867 |
|
|
wire BC = fetchbufC_instr[`INSTRUCTION_OP]==`CHK ? 1'b0 : fetchbufC_instr[`INSTRUCTION_OP]==`BccR ? fetchbufC_instr[26] : fetchbufC_instr[21];
|
868 |
|
|
wire BD = fetchbufD_instr[`INSTRUCTION_OP]==`CHK ? 1'b0 : fetchbufD_instr[`INSTRUCTION_OP]==`BccR ? fetchbufD_instr[26] : fetchbufD_instr[21];
|
869 |
|
|
wire SPA = fetchbufA_instr[`INSTRUCTION_OP]==`CHK ? 1'b1 : fetchbufA_instr[`INSTRUCTION_OP]==`BccR ? fetchbufA_instr[27] : fetchbufA_instr[22];
|
870 |
|
|
wire SPB = fetchbufB_instr[`INSTRUCTION_OP]==`CHK ? 1'b1 : fetchbufB_instr[`INSTRUCTION_OP]==`BccR ? fetchbufB_instr[27] : fetchbufB_instr[22];
|
871 |
|
|
wire SPC = fetchbufC_instr[`INSTRUCTION_OP]==`CHK ? 1'b1 : fetchbufC_instr[`INSTRUCTION_OP]==`BccR ? fetchbufC_instr[27] : fetchbufC_instr[22];
|
872 |
|
|
wire SPD = fetchbufD_instr[`INSTRUCTION_OP]==`CHK ? 1'b1 : fetchbufD_instr[`INSTRUCTION_OP]==`BccR ? fetchbufD_instr[27] : fetchbufD_instr[22];
|
873 |
|
|
|
874 |
|
|
wire [31:0] btgtA, btgtB, btgtC, btgtD;
|
875 |
|
|
wire btbwr0 = iqentry_v[head0] && iqentry_done[head0] &&
|
876 |
|
|
(
|
877 |
|
|
iqentry_instr[head0][`INSTRUCTION_OP]==`JAL ||
|
878 |
|
|
iqentry_instr[head0][`INSTRUCTION_OP]==`BRK ||
|
879 |
|
|
IsRTI(iqentry_instr[head0]) ||
|
880 |
|
|
iqentry_instr[head0][`INSTRUCTION_OP]==`BccR);
|
881 |
|
|
wire btbwr1 = iqentry_v[head1] && iqentry_done[head1] &&
|
882 |
|
|
(
|
883 |
|
|
iqentry_instr[head1][`INSTRUCTION_OP]==`JAL ||
|
884 |
|
|
iqentry_instr[head1][`INSTRUCTION_OP]==`BRK ||
|
885 |
|
|
IsRTI(iqentry_instr[head1]) ||
|
886 |
|
|
iqentry_instr[head1][`INSTRUCTION_OP]==`BccR);
|
887 |
|
|
|
888 |
|
|
FT64_BTB ubtb1
|
889 |
|
|
(
|
890 |
|
|
.rst(rst),
|
891 |
|
|
.wclk(clk),
|
892 |
|
|
.wr(btbwr0 | btbwr1),
|
893 |
|
|
.wadr(btbwr0 ? iqentry_pc[head0] : iqentry_pc[head1]),
|
894 |
|
|
.wdat(btbwr0 ? iqentry_a0[head0] : iqentry_a0[head1]),
|
895 |
|
|
.valid(btbwr0 ? iqentry_bt[head0] & iqentry_v[head0] : iqentry_bt[head1] & iqentry_v[head1]),
|
896 |
|
|
.rclk(~clk),
|
897 |
|
|
.pcA(fetchbufA_pc),
|
898 |
|
|
.btgtA(btgtA),
|
899 |
|
|
.pcB(fetchbufB_pc),
|
900 |
|
|
.btgtB(btgtB),
|
901 |
|
|
.pcC(fetchbufC_pc),
|
902 |
|
|
.btgtC(btgtC),
|
903 |
|
|
.pcD(fetchbufD_pc),
|
904 |
|
|
.btgtD(btgtD),
|
905 |
|
|
.npcA(BRKPC),
|
906 |
|
|
.npcB(BRKPC),
|
907 |
|
|
.npcC(BRKPC),
|
908 |
|
|
.npcD(BRKPC)
|
909 |
|
|
);
|
910 |
|
|
|
911 |
|
|
FT64_BranchPredictor ubp1
|
912 |
|
|
(
|
913 |
|
|
.rst(rst),
|
914 |
|
|
.clk(clk),
|
915 |
|
|
.en(bpe),
|
916 |
|
|
.xisBranch0(iqentry_br[head0] & !P0 & commit0_v),
|
917 |
|
|
.xisBranch1(iqentry_br[head1] & !P1 & commit1_v),
|
918 |
|
|
.pcA(fetchbufA_pc),
|
919 |
|
|
.pcB(fetchbufB_pc),
|
920 |
|
|
.pcC(fetchbufC_pc),
|
921 |
|
|
.pcD(fetchbufD_pc),
|
922 |
|
|
.xpc0(iqentry_pc[head0]),
|
923 |
|
|
.xpc1(iqentry_pc[head1]),
|
924 |
|
|
.takb0(commit0_v & iqentry_res[head0][0]),
|
925 |
|
|
.takb1(commit1_v & iqentry_res[head1][0]),
|
926 |
|
|
.predict_takenA(predict_takenA1),
|
927 |
|
|
.predict_takenB(predict_takenB1),
|
928 |
|
|
.predict_takenC(predict_takenC1),
|
929 |
|
|
.predict_takenD(predict_takenD1)
|
930 |
|
|
);
|
931 |
|
|
// Static branch predictions
|
932 |
|
|
assign predict_takenA = SPA ? BA : predict_takenA1;
|
933 |
|
|
assign predict_takenB = SPB ? BB : predict_takenB1;
|
934 |
|
|
assign predict_takenC = SPC ? BC : predict_takenC1;
|
935 |
|
|
assign predict_takenD = SPD ? BD : predict_takenD1;
|
936 |
|
|
|
937 |
|
|
//-----------------------------------------------------------------------------
|
938 |
|
|
// Debug
|
939 |
|
|
//-----------------------------------------------------------------------------
|
940 |
|
|
`ifdef SUPPORT_DBG
|
941 |
|
|
|
942 |
|
|
wire [DBW-1:0] dbg_stat1x;
|
943 |
|
|
reg [DBW-1:0] dbg_stat;
|
944 |
|
|
reg [DBW-1:0] dbg_ctrl;
|
945 |
|
|
reg [ABW-1:0] dbg_adr0;
|
946 |
|
|
reg [ABW-1:0] dbg_adr1;
|
947 |
|
|
reg [ABW-1:0] dbg_adr2;
|
948 |
|
|
reg [ABW-1:0] dbg_adr3;
|
949 |
|
|
reg dbg_imatchA0,dbg_imatchA1,dbg_imatchA2,dbg_imatchA3,dbg_imatchA;
|
950 |
|
|
reg dbg_imatchB0,dbg_imatchB1,dbg_imatchB2,dbg_imatchB3,dbg_imatchB;
|
951 |
|
|
|
952 |
|
|
wire dbg_lmatch00 =
|
953 |
|
|
dbg_ctrl[0] && dbg_ctrl[17:16]==2'b11 && dram0_addr[AMSB:3]==dbg_adr0[AMSB:3] &&
|
954 |
|
|
((dbg_ctrl[19:18]==2'b00 && dram0_addr[2:0]==dbg_adr0[2:0]) ||
|
955 |
|
|
(dbg_ctrl[19:18]==2'b01 && dram0_addr[2:1]==dbg_adr0[2:1]) ||
|
956 |
|
|
(dbg_ctrl[19:18]==2'b10 && dram0_addr[2]==dbg_adr0[2]) ||
|
957 |
|
|
dbg_ctrl[19:18]==2'b11)
|
958 |
|
|
;
|
959 |
|
|
wire dbg_lmatch01 =
|
960 |
|
|
dbg_ctrl[0] && dbg_ctrl[17:16]==2'b11 && dram1_addr[AMSB:3]==dbg_adr0[AMSB:3] &&
|
961 |
|
|
((dbg_ctrl[19:18]==2'b00 && dram1_addr[2:0]==dbg_adr0[2:0]) ||
|
962 |
|
|
(dbg_ctrl[19:18]==2'b01 && dram1_addr[2:1]==dbg_adr0[2:1]) ||
|
963 |
|
|
(dbg_ctrl[19:18]==2'b10 && dram1_addr[2]==dbg_adr0[2]) ||
|
964 |
|
|
dbg_ctrl[19:18]==2'b11)
|
965 |
|
|
;
|
966 |
|
|
wire dbg_lmatch02 =
|
967 |
|
|
dbg_ctrl[0] && dbg_ctrl[17:16]==2'b11 && dram2_addr[AMSB:3]==dbg_adr0[AMSB:3] &&
|
968 |
|
|
((dbg_ctrl[19:18]==2'b00 && dram2_addr[2:0]==dbg_adr0[2:0]) ||
|
969 |
|
|
(dbg_ctrl[19:18]==2'b01 && dram2_addr[2:1]==dbg_adr0[2:1]) ||
|
970 |
|
|
(dbg_ctrl[19:18]==2'b10 && dram2_addr[2]==dbg_adr0[2]) ||
|
971 |
|
|
dbg_ctrl[19:18]==2'b11)
|
972 |
|
|
;
|
973 |
|
|
wire dbg_lmatch10 =
|
974 |
|
|
dbg_ctrl[1] && dbg_ctrl[21:20]==2'b11 && dram0_addr[AMSB:3]==dbg_adr1[AMSB:3] &&
|
975 |
|
|
((dbg_ctrl[23:22]==2'b00 && dram0_addr[2:0]==dbg_adr1[2:0]) ||
|
976 |
|
|
(dbg_ctrl[23:22]==2'b01 && dram0_addr[2:1]==dbg_adr1[2:1]) ||
|
977 |
|
|
(dbg_ctrl[23:22]==2'b10 && dram0_addr[2]==dbg_adr1[2]) ||
|
978 |
|
|
dbg_ctrl[23:22]==2'b11)
|
979 |
|
|
;
|
980 |
|
|
wire dbg_lmatch11 =
|
981 |
|
|
dbg_ctrl[1] && dbg_ctrl[21:20]==2'b11 && dram1_addr[AMSB:3]==dbg_adr1[AMSB:3] &&
|
982 |
|
|
((dbg_ctrl[23:22]==2'b00 && dram1_addr[2:0]==dbg_adr1[2:0]) ||
|
983 |
|
|
(dbg_ctrl[23:22]==2'b01 && dram1_addr[2:1]==dbg_adr1[2:1]) ||
|
984 |
|
|
(dbg_ctrl[23:22]==2'b10 && dram1_addr[2]==dbg_adr1[2]) ||
|
985 |
|
|
dbg_ctrl[23:22]==2'b11)
|
986 |
|
|
;
|
987 |
|
|
wire dbg_lmatch12 =
|
988 |
|
|
dbg_ctrl[1] && dbg_ctrl[21:20]==2'b11 && dram2_addr[AMSB:3]==dbg_adr1[AMSB:3] &&
|
989 |
|
|
((dbg_ctrl[23:22]==2'b00 && dram2_addr[2:0]==dbg_adr1[2:0]) ||
|
990 |
|
|
(dbg_ctrl[23:22]==2'b01 && dram2_addr[2:1]==dbg_adr1[2:1]) ||
|
991 |
|
|
(dbg_ctrl[23:22]==2'b10 && dram2_addr[2]==dbg_adr1[2]) ||
|
992 |
|
|
dbg_ctrl[23:22]==2'b11)
|
993 |
|
|
;
|
994 |
|
|
wire dbg_lmatch20 =
|
995 |
|
|
dbg_ctrl[2] && dbg_ctrl[25:24]==2'b11 && dram0_addr[AMSB:3]==dbg_adr2[AMSB:3] &&
|
996 |
|
|
((dbg_ctrl[27:26]==2'b00 && dram0_addr[2:0]==dbg_adr2[2:0]) ||
|
997 |
|
|
(dbg_ctrl[27:26]==2'b01 && dram0_addr[2:1]==dbg_adr2[2:1]) ||
|
998 |
|
|
(dbg_ctrl[27:26]==2'b10 && dram0_addr[2]==dbg_adr2[2]) ||
|
999 |
|
|
dbg_ctrl[27:26]==2'b11)
|
1000 |
|
|
;
|
1001 |
|
|
wire dbg_lmatch21 =
|
1002 |
|
|
dbg_ctrl[2] && dbg_ctrl[25:24]==2'b11 && dram1_addr[AMSB:3]==dbg_adr2[AMSB:3] &&
|
1003 |
|
|
((dbg_ctrl[27:26]==2'b00 && dram1_addr[2:0]==dbg_adr2[2:0]) ||
|
1004 |
|
|
(dbg_ctrl[27:26]==2'b01 && dram1_addr[2:1]==dbg_adr2[2:1]) ||
|
1005 |
|
|
(dbg_ctrl[27:26]==2'b10 && dram1_addr[2]==dbg_adr2[2]) ||
|
1006 |
|
|
dbg_ctrl[27:26]==2'b11)
|
1007 |
|
|
;
|
1008 |
|
|
wire dbg_lmatch22 =
|
1009 |
|
|
dbg_ctrl[2] && dbg_ctrl[25:24]==2'b11 && dram2_addr[AMSB:3]==dbg_adr2[AMSB:3] &&
|
1010 |
|
|
((dbg_ctrl[27:26]==2'b00 && dram2_addr[2:0]==dbg_adr2[2:0]) ||
|
1011 |
|
|
(dbg_ctrl[27:26]==2'b01 && dram2_addr[2:1]==dbg_adr2[2:1]) ||
|
1012 |
|
|
(dbg_ctrl[27:26]==2'b10 && dram2_addr[2]==dbg_adr2[2]) ||
|
1013 |
|
|
dbg_ctrl[27:26]==2'b11)
|
1014 |
|
|
;
|
1015 |
|
|
wire dbg_lmatch30 =
|
1016 |
|
|
dbg_ctrl[3] && dbg_ctrl[29:28]==2'b11 && dram0_addr[AMSB:3]==dbg_adr3[AMSB:3] &&
|
1017 |
|
|
((dbg_ctrl[31:30]==2'b00 && dram0_addr[2:0]==dbg_adr3[2:0]) ||
|
1018 |
|
|
(dbg_ctrl[31:30]==2'b01 && dram0_addr[2:1]==dbg_adr3[2:1]) ||
|
1019 |
|
|
(dbg_ctrl[31:30]==2'b10 && dram0_addr[2]==dbg_adr3[2]) ||
|
1020 |
|
|
dbg_ctrl[31:30]==2'b11)
|
1021 |
|
|
;
|
1022 |
|
|
wire dbg_lmatch31 =
|
1023 |
|
|
dbg_ctrl[3] && dbg_ctrl[29:28]==2'b11 && dram1_addr[AMSB:3]==dbg_adr3[AMSB:3] &&
|
1024 |
|
|
((dbg_ctrl[31:30]==2'b00 && dram1_addr[2:0]==dbg_adr3[2:0]) ||
|
1025 |
|
|
(dbg_ctrl[31:30]==2'b01 && dram1_addr[2:1]==dbg_adr3[2:1]) ||
|
1026 |
|
|
(dbg_ctrl[31:30]==2'b10 && dram1_addr[2]==dbg_adr3[2]) ||
|
1027 |
|
|
dbg_ctrl[31:30]==2'b11)
|
1028 |
|
|
;
|
1029 |
|
|
wire dbg_lmatch32 =
|
1030 |
|
|
dbg_ctrl[3] && dbg_ctrl[29:28]==2'b11 && dram2_addr[AMSB:3]==dbg_adr3[AMSB:3] &&
|
1031 |
|
|
((dbg_ctrl[31:30]==2'b00 && dram2_addr[2:0]==dbg_adr3[2:0]) ||
|
1032 |
|
|
(dbg_ctrl[31:30]==2'b01 && dram2_addr[2:1]==dbg_adr3[2:1]) ||
|
1033 |
|
|
(dbg_ctrl[31:30]==2'b10 && dram2_addr[2]==dbg_adr3[2]) ||
|
1034 |
|
|
dbg_ctrl[31:30]==2'b11)
|
1035 |
|
|
;
|
1036 |
|
|
wire dbg_lmatch0 = dbg_lmatch00|dbg_lmatch10|dbg_lmatch20|dbg_lmatch30;
|
1037 |
|
|
wire dbg_lmatch1 = dbg_lmatch01|dbg_lmatch11|dbg_lmatch21|dbg_lmatch31;
|
1038 |
|
|
wire dbg_lmatch2 = dbg_lmatch02|dbg_lmatch12|dbg_lmatch22|dbg_lmatch32;
|
1039 |
|
|
wire dbg_lmatch = dbg_lmatch00|dbg_lmatch10|dbg_lmatch20|dbg_lmatch30|
|
1040 |
|
|
dbg_lmatch01|dbg_lmatch11|dbg_lmatch21|dbg_lmatch31|
|
1041 |
|
|
dbg_lmatch02|dbg_lmatch12|dbg_lmatch22|dbg_lmatch32
|
1042 |
|
|
;
|
1043 |
|
|
|
1044 |
|
|
wire dbg_smatch00 =
|
1045 |
|
|
dbg_ctrl[0] && dbg_ctrl[17:16]==2'b11 && dram0_addr[AMSB:3]==dbg_adr0[AMSB:3] &&
|
1046 |
|
|
((dbg_ctrl[19:18]==2'b00 && dram0_addr[2:0]==dbg_adr0[2:0]) ||
|
1047 |
|
|
(dbg_ctrl[19:18]==2'b01 && dram0_addr[2:1]==dbg_adr0[2:1]) ||
|
1048 |
|
|
(dbg_ctrl[19:18]==2'b10 && dram0_addr[2]==dbg_adr0[2]) ||
|
1049 |
|
|
dbg_ctrl[19:18]==2'b11)
|
1050 |
|
|
;
|
1051 |
|
|
wire dbg_smatch01 =
|
1052 |
|
|
dbg_ctrl[0] && dbg_ctrl[17:16]==2'b11 && dram1_addr[AMSB:3]==dbg_adr0[AMSB:3] &&
|
1053 |
|
|
((dbg_ctrl[19:18]==2'b00 && dram1_addr[2:0]==dbg_adr0[2:0]) ||
|
1054 |
|
|
(dbg_ctrl[19:18]==2'b01 && dram1_addr[2:1]==dbg_adr0[2:1]) ||
|
1055 |
|
|
(dbg_ctrl[19:18]==2'b10 && dram1_addr[2]==dbg_adr0[2]) ||
|
1056 |
|
|
dbg_ctrl[19:18]==2'b11)
|
1057 |
|
|
;
|
1058 |
|
|
wire dbg_smatch02 =
|
1059 |
|
|
dbg_ctrl[0] && dbg_ctrl[17:16]==2'b11 && dram2_addr[AMSB:3]==dbg_adr0[AMSB:3] &&
|
1060 |
|
|
((dbg_ctrl[19:18]==2'b00 && dram2_addr[2:0]==dbg_adr0[2:0]) ||
|
1061 |
|
|
(dbg_ctrl[19:18]==2'b01 && dram2_addr[2:1]==dbg_adr0[2:1]) ||
|
1062 |
|
|
(dbg_ctrl[19:18]==2'b10 && dram2_addr[2]==dbg_adr0[2]) ||
|
1063 |
|
|
dbg_ctrl[19:18]==2'b11)
|
1064 |
|
|
;
|
1065 |
|
|
wire dbg_smatch10 =
|
1066 |
|
|
dbg_ctrl[1] && dbg_ctrl[21:20]==2'b11 && dram0_addr[AMSB:3]==dbg_adr1[AMSB:3] &&
|
1067 |
|
|
((dbg_ctrl[23:22]==2'b00 && dram0_addr[2:0]==dbg_adr1[2:0]) ||
|
1068 |
|
|
(dbg_ctrl[23:22]==2'b01 && dram0_addr[2:1]==dbg_adr1[2:1]) ||
|
1069 |
|
|
(dbg_ctrl[23:22]==2'b10 && dram0_addr[2]==dbg_adr1[2]) ||
|
1070 |
|
|
dbg_ctrl[23:22]==2'b11)
|
1071 |
|
|
;
|
1072 |
|
|
wire dbg_smatch11 =
|
1073 |
|
|
dbg_ctrl[1] && dbg_ctrl[21:20]==2'b11 && dram1_addr[AMSB:3]==dbg_adr1[AMSB:3] &&
|
1074 |
|
|
((dbg_ctrl[23:22]==2'b00 && dram1_addr[2:0]==dbg_adr1[2:0]) ||
|
1075 |
|
|
(dbg_ctrl[23:22]==2'b01 && dram1_addr[2:1]==dbg_adr1[2:1]) ||
|
1076 |
|
|
(dbg_ctrl[23:22]==2'b10 && dram1_addr[2]==dbg_adr1[2]) ||
|
1077 |
|
|
dbg_ctrl[23:22]==2'b11)
|
1078 |
|
|
;
|
1079 |
|
|
wire dbg_smatch12 =
|
1080 |
|
|
dbg_ctrl[1] && dbg_ctrl[21:20]==2'b11 && dram2_addr[AMSB:3]==dbg_adr1[AMSB:3] &&
|
1081 |
|
|
((dbg_ctrl[23:22]==2'b00 && dram2_addr[2:0]==dbg_adr1[2:0]) ||
|
1082 |
|
|
(dbg_ctrl[23:22]==2'b01 && dram2_addr[2:1]==dbg_adr1[2:1]) ||
|
1083 |
|
|
(dbg_ctrl[23:22]==2'b10 && dram2_addr[2]==dbg_adr1[2]) ||
|
1084 |
|
|
dbg_ctrl[23:22]==2'b11)
|
1085 |
|
|
;
|
1086 |
|
|
wire dbg_smatch20 =
|
1087 |
|
|
dbg_ctrl[2] && dbg_ctrl[25:24]==2'b11 && dram0_addr[AMSB:3]==dbg_adr2[AMSB:3] &&
|
1088 |
|
|
((dbg_ctrl[27:26]==2'b00 && dram0_addr[2:0]==dbg_adr2[2:0]) ||
|
1089 |
|
|
(dbg_ctrl[27:26]==2'b01 && dram0_addr[2:1]==dbg_adr2[2:1]) ||
|
1090 |
|
|
(dbg_ctrl[27:26]==2'b10 && dram0_addr[2]==dbg_adr2[2]) ||
|
1091 |
|
|
dbg_ctrl[27:26]==2'b11)
|
1092 |
|
|
;
|
1093 |
|
|
wire dbg_smatch21 =
|
1094 |
|
|
dbg_ctrl[2] && dbg_ctrl[25:24]==2'b11 && dram1_addr[AMSB:3]==dbg_adr2[AMSB:3] &&
|
1095 |
|
|
((dbg_ctrl[27:26]==2'b00 && dram1_addr[2:0]==dbg_adr2[2:0]) ||
|
1096 |
|
|
(dbg_ctrl[27:26]==2'b01 && dram1_addr[2:1]==dbg_adr2[2:1]) ||
|
1097 |
|
|
(dbg_ctrl[27:26]==2'b10 && dram1_addr[2]==dbg_adr2[2]) ||
|
1098 |
|
|
dbg_ctrl[27:26]==2'b11)
|
1099 |
|
|
;
|
1100 |
|
|
wire dbg_smatch22 =
|
1101 |
|
|
dbg_ctrl[2] && dbg_ctrl[25:24]==2'b11 && dram2_addr[AMSB:3]==dbg_adr2[AMSB:3] &&
|
1102 |
|
|
((dbg_ctrl[27:26]==2'b00 && dram2_addr[2:0]==dbg_adr2[2:0]) ||
|
1103 |
|
|
(dbg_ctrl[27:26]==2'b01 && dram2_addr[2:1]==dbg_adr2[2:1]) ||
|
1104 |
|
|
(dbg_ctrl[27:26]==2'b10 && dram2_addr[2]==dbg_adr2[2]) ||
|
1105 |
|
|
dbg_ctrl[27:26]==2'b11)
|
1106 |
|
|
;
|
1107 |
|
|
wire dbg_smatch30 =
|
1108 |
|
|
dbg_ctrl[3] && dbg_ctrl[29:28]==2'b11 && dram0_addr[AMSB:3]==dbg_adr3[AMSB:3] &&
|
1109 |
|
|
((dbg_ctrl[31:30]==2'b00 && dram0_addr[2:0]==dbg_adr3[2:0]) ||
|
1110 |
|
|
(dbg_ctrl[31:30]==2'b01 && dram0_addr[2:1]==dbg_adr3[2:1]) ||
|
1111 |
|
|
(dbg_ctrl[31:30]==2'b10 && dram0_addr[2]==dbg_adr3[2]) ||
|
1112 |
|
|
dbg_ctrl[31:30]==2'b11)
|
1113 |
|
|
;
|
1114 |
|
|
wire dbg_smatch31 =
|
1115 |
|
|
dbg_ctrl[3] && dbg_ctrl[29:28]==2'b11 && dram1_addr[AMSB:3]==dbg_adr3[AMSB:3] &&
|
1116 |
|
|
((dbg_ctrl[31:30]==2'b00 && dram1_addr[2:0]==dbg_adr3[2:0]) ||
|
1117 |
|
|
(dbg_ctrl[31:30]==2'b01 && dram1_addr[2:1]==dbg_adr3[2:1]) ||
|
1118 |
|
|
(dbg_ctrl[31:30]==2'b10 && dram1_addr[2]==dbg_adr3[2]) ||
|
1119 |
|
|
dbg_ctrl[31:30]==2'b11)
|
1120 |
|
|
;
|
1121 |
|
|
wire dbg_smatch32 =
|
1122 |
|
|
dbg_ctrl[3] && dbg_ctrl[29:28]==2'b11 && dram2_addr[AMSB:3]==dbg_adr3[AMSB:3] &&
|
1123 |
|
|
((dbg_ctrl[31:30]==2'b00 && dram2_addr[2:0]==dbg_adr3[2:0]) ||
|
1124 |
|
|
(dbg_ctrl[31:30]==2'b01 && dram2_addr[2:1]==dbg_adr3[2:1]) ||
|
1125 |
|
|
(dbg_ctrl[31:30]==2'b10 && dram2_addr[2]==dbg_adr3[2]) ||
|
1126 |
|
|
dbg_ctrl[31:30]==2'b11)
|
1127 |
|
|
;
|
1128 |
|
|
wire dbg_smatch0 = dbg_smatch00|dbg_smatch10|dbg_smatch20|dbg_smatch30;
|
1129 |
|
|
wire dbg_smatch1 = dbg_smatch01|dbg_smatch11|dbg_smatch21|dbg_smatch31;
|
1130 |
|
|
wire dbg_smatch2 = dbg_smatch02|dbg_smatch12|dbg_smatch22|dbg_smatch32;
|
1131 |
|
|
|
1132 |
|
|
wire dbg_smatch = dbg_smatch00|dbg_smatch10|dbg_smatch20|dbg_smatch30|
|
1133 |
|
|
dbg_smatch01|dbg_smatch11|dbg_smatch21|dbg_smatch31|
|
1134 |
|
|
dbg_smatch02|dbg_smatch12|dbg_smatch22|dbg_smatch32
|
1135 |
|
|
;
|
1136 |
|
|
|
1137 |
|
|
wire dbg_stat0 = dbg_imatchA0 | dbg_imatchB0 | dbg_lmatch00 | dbg_lmatch01 | dbg_lmatch02 | dbg_smatch00 | dbg_smatch01 | dbg_smatch02;
|
1138 |
|
|
wire dbg_stat1 = dbg_imatchA1 | dbg_imatchB1 | dbg_lmatch10 | dbg_lmatch11 | dbg_lmatch12 | dbg_smatch10 | dbg_smatch11 | dbg_smatch12;
|
1139 |
|
|
wire dbg_stat2 = dbg_imatchA2 | dbg_imatchB2 | dbg_lmatch20 | dbg_lmatch21 | dbg_lmatch22 | dbg_smatch20 | dbg_smatch21 | dbg_smatch22;
|
1140 |
|
|
wire dbg_stat3 = dbg_imatchA3 | dbg_imatchB3 | dbg_lmatch30 | dbg_lmatch31 | dbg_lmatch32 | dbg_smatch30 | dbg_smatch31 | dbg_smatch32;
|
1141 |
|
|
assign dbg_stat1x = {dbg_stat3,dbg_stat2,dbg_stat1,dbg_stat0};
|
1142 |
|
|
wire debug_on = |dbg_ctrl[3:0]|dbg_ctrl[7]|dbg_ctrl[63];
|
1143 |
|
|
|
1144 |
|
|
always @*
|
1145 |
|
|
begin
|
1146 |
|
|
if (dbg_ctrl[0] && dbg_ctrl[17:16]==2'b00 && fetchbuf0_pc==dbg_adr0)
|
1147 |
|
|
dbg_imatchA0 = `TRUE;
|
1148 |
|
|
if (dbg_ctrl[1] && dbg_ctrl[21:20]==2'b00 && fetchbuf0_pc==dbg_adr1)
|
1149 |
|
|
dbg_imatchA1 = `TRUE;
|
1150 |
|
|
if (dbg_ctrl[2] && dbg_ctrl[25:24]==2'b00 && fetchbuf0_pc==dbg_adr2)
|
1151 |
|
|
dbg_imatchA2 = `TRUE;
|
1152 |
|
|
if (dbg_ctrl[3] && dbg_ctrl[29:28]==2'b00 && fetchbuf0_pc==dbg_adr3)
|
1153 |
|
|
dbg_imatchA3 = `TRUE;
|
1154 |
|
|
if (dbg_imatchA0|dbg_imatchA1|dbg_imatchA2|dbg_imatchA3)
|
1155 |
|
|
dbg_imatchA = `TRUE;
|
1156 |
|
|
end
|
1157 |
|
|
|
1158 |
|
|
always @*
|
1159 |
|
|
begin
|
1160 |
|
|
if (dbg_ctrl[0] && dbg_ctrl[17:16]==2'b00 && fetchbuf1_pc==dbg_adr0)
|
1161 |
|
|
dbg_imatchB0 = `TRUE;
|
1162 |
|
|
if (dbg_ctrl[1] && dbg_ctrl[21:20]==2'b00 && fetchbuf1_pc==dbg_adr1)
|
1163 |
|
|
dbg_imatchB1 = `TRUE;
|
1164 |
|
|
if (dbg_ctrl[2] && dbg_ctrl[25:24]==2'b00 && fetchbuf1_pc==dbg_adr2)
|
1165 |
|
|
dbg_imatchB2 = `TRUE;
|
1166 |
|
|
if (dbg_ctrl[3] && dbg_ctrl[29:28]==2'b00 && fetchbuf1_pc==dbg_adr3)
|
1167 |
|
|
dbg_imatchB3 = `TRUE;
|
1168 |
|
|
if (dbg_imatchB0|dbg_imatchB1|dbg_imatchB2|dbg_imatchB3)
|
1169 |
|
|
dbg_imatchB = `TRUE;
|
1170 |
|
|
end
|
1171 |
|
|
`endif
|
1172 |
|
|
|
1173 |
|
|
//-----------------------------------------------------------------------------
|
1174 |
|
|
//-----------------------------------------------------------------------------
|
1175 |
|
|
|
1176 |
|
|
// hirq squashes the pc increment if there's an irq.
|
1177 |
|
|
wire hirq = (irq_i > im) && ~int_commit;
|
1178 |
|
|
always @*
|
1179 |
|
|
if (hirq)
|
1180 |
|
|
insn0 <= {13'd0,irq_i,1'b0,vec_i,`BRK};
|
1181 |
|
|
else if (phit) begin
|
1182 |
|
|
if (insn0a[`INSTRUCTION_OP]==`BRK && insn0a[23:19]==5'd0)
|
1183 |
|
|
insn0 <= {13'd1,3'd0,1'b0,`FLT_PRIV,`BRK};
|
1184 |
|
|
else
|
1185 |
|
|
insn0 <= insn0a;
|
1186 |
|
|
end
|
1187 |
|
|
else
|
1188 |
|
|
insn0 <= `NOP_INSN;
|
1189 |
|
|
always @*
|
1190 |
|
|
if (hirq & ~thread_en)
|
1191 |
|
|
insn1 <= {13'd0,irq_i,1'b0,vec_i,`BRK};
|
1192 |
|
|
else if (phit) begin
|
1193 |
|
|
if (insn1a[`INSTRUCTION_OP]==`BRK && insn1a[23:19]==5'd0)
|
1194 |
|
|
insn1 <= {13'd1,3'd0,1'b0,`FLT_PRIV,`BRK};
|
1195 |
|
|
else
|
1196 |
|
|
insn1 <= insn1a;
|
1197 |
|
|
end
|
1198 |
|
|
else
|
1199 |
|
|
insn1 <= `NOP_INSN;
|
1200 |
|
|
|
1201 |
|
|
wire [63:0] dc0_out, dc1_out, dc2_out;
|
1202 |
|
|
assign rdat0 = dram0_unc ? xdati : dc0_out;
|
1203 |
|
|
assign rdat1 = dram1_unc ? xdati : dc1_out;
|
1204 |
|
|
assign rdat2 = dram2_unc ? xdati : dc2_out;
|
1205 |
|
|
|
1206 |
|
|
reg [1:0] dccnt;
|
1207 |
|
|
wire dhit0, dhit1, dhit2;
|
1208 |
|
|
wire dhit00, dhit10, dhit20;
|
1209 |
|
|
wire dhit01, dhit11, dhit21;
|
1210 |
|
|
reg [31:0] dc_wadr;
|
1211 |
|
|
reg [63:0] dc_wdat;
|
1212 |
|
|
reg isStore;
|
1213 |
|
|
|
1214 |
|
|
FT64_dcache udc0
|
1215 |
|
|
(
|
1216 |
|
|
.rst(rst),
|
1217 |
|
|
.wclk(clk),
|
1218 |
|
|
.wr((bstate==B2d && ack_i)||((bstate==B1||(bstate==B19 && isStore)) && dhit0)),
|
1219 |
|
|
.sel(sel_o),
|
1220 |
|
|
.wadr({pcr[5:0],adr_o}),
|
1221 |
|
|
.i(bstate==B2d ? dat_i : dat_o),
|
1222 |
|
|
.rclk(clk),
|
1223 |
|
|
.rdsize(dram0_memsize),
|
1224 |
|
|
.radr({pcr[5:0],dram0_addr}),
|
1225 |
|
|
.o(dc0_out),
|
1226 |
|
|
.hit(),
|
1227 |
|
|
.hit0(dhit0),
|
1228 |
|
|
.hit1()
|
1229 |
|
|
);
|
1230 |
|
|
FT64_dcache udc1
|
1231 |
|
|
(
|
1232 |
|
|
.rst(rst),
|
1233 |
|
|
.wclk(clk),
|
1234 |
|
|
.wr((bstate==B2d && ack_i)||((bstate==B1||(bstate==B19 && isStore)) && dhit1)),
|
1235 |
|
|
.sel(sel_o),
|
1236 |
|
|
.wadr({pcr[5:0],adr_o}),
|
1237 |
|
|
.i(bstate==B2d ? dat_i : dat_o),
|
1238 |
|
|
.rclk(clk),
|
1239 |
|
|
.rdsize(dram1_memsize),
|
1240 |
|
|
.radr({pcr[5:0],dram1_addr}),
|
1241 |
|
|
.o(dc1_out),
|
1242 |
|
|
.hit(),
|
1243 |
|
|
.hit0(dhit1),
|
1244 |
|
|
.hit1()
|
1245 |
|
|
);
|
1246 |
|
|
FT64_dcache udc2
|
1247 |
|
|
(
|
1248 |
|
|
.rst(rst),
|
1249 |
|
|
.wclk(clk),
|
1250 |
|
|
.wr((bstate==B2d && ack_i)||((bstate==B1||(bstate==B19 && isStore)) && dhit2)),
|
1251 |
|
|
.sel(sel_o),
|
1252 |
|
|
.wadr({pcr[5:0],adr_o}),
|
1253 |
|
|
.i(bstate==B2d ? dat_i : dat_o),
|
1254 |
|
|
.rclk(clk),
|
1255 |
|
|
.rdsize(dram2_memsize),
|
1256 |
|
|
.radr({pcr[5:0],dram2_addr}),
|
1257 |
|
|
.o(dc2_out),
|
1258 |
|
|
.hit(),
|
1259 |
|
|
.hit0(dhit2),
|
1260 |
|
|
.hit1()
|
1261 |
|
|
);
|
1262 |
|
|
|
1263 |
|
|
function [`QBITS] idp1;
|
1264 |
|
|
input [`QBITS] id;
|
1265 |
|
|
case(id)
|
1266 |
|
|
3'd0: idp1 = 3'd1;
|
1267 |
|
|
3'd1: idp1 = 3'd2;
|
1268 |
|
|
3'd2: idp1 = 3'd3;
|
1269 |
|
|
3'd3: idp1 = 3'd4;
|
1270 |
|
|
3'd4: idp1 = 3'd5;
|
1271 |
|
|
3'd5: idp1 = 3'd6;
|
1272 |
|
|
3'd6: idp1 = 3'd7;
|
1273 |
|
|
3'd7: idp1 = 3'd0;
|
1274 |
|
|
endcase
|
1275 |
|
|
endfunction
|
1276 |
|
|
|
1277 |
|
|
function [`QBITS] idp2;
|
1278 |
|
|
input [`QBITS] id;
|
1279 |
|
|
case(id)
|
1280 |
|
|
3'd0: idp2 = 3'd2;
|
1281 |
|
|
3'd1: idp2 = 3'd3;
|
1282 |
|
|
3'd2: idp2 = 3'd4;
|
1283 |
|
|
3'd3: idp2 = 3'd5;
|
1284 |
|
|
3'd4: idp2 = 3'd6;
|
1285 |
|
|
3'd5: idp2 = 3'd7;
|
1286 |
|
|
3'd6: idp2 = 3'd0;
|
1287 |
|
|
3'd7: idp2 = 3'd1;
|
1288 |
|
|
endcase
|
1289 |
|
|
endfunction
|
1290 |
|
|
|
1291 |
|
|
function [`QBITS] idp3;
|
1292 |
|
|
input [`QBITS] id;
|
1293 |
|
|
case(id)
|
1294 |
|
|
3'd0: idp3 = 3'd3;
|
1295 |
|
|
3'd1: idp3 = 3'd4;
|
1296 |
|
|
3'd2: idp3 = 3'd5;
|
1297 |
|
|
3'd3: idp3 = 3'd6;
|
1298 |
|
|
3'd4: idp3 = 3'd7;
|
1299 |
|
|
3'd5: idp3 = 3'd0;
|
1300 |
|
|
3'd6: idp3 = 3'd1;
|
1301 |
|
|
3'd7: idp3 = 3'd2;
|
1302 |
|
|
endcase
|
1303 |
|
|
endfunction
|
1304 |
|
|
|
1305 |
|
|
function [`QBITS] idp4;
|
1306 |
|
|
input [`QBITS] id;
|
1307 |
|
|
case(id)
|
1308 |
|
|
3'd0: idp4 = 3'd4;
|
1309 |
|
|
3'd1: idp4 = 3'd5;
|
1310 |
|
|
3'd2: idp4 = 3'd6;
|
1311 |
|
|
3'd3: idp4 = 3'd7;
|
1312 |
|
|
3'd4: idp4 = 3'd0;
|
1313 |
|
|
3'd5: idp4 = 3'd1;
|
1314 |
|
|
3'd6: idp4 = 3'd2;
|
1315 |
|
|
3'd7: idp4 = 3'd3;
|
1316 |
|
|
endcase
|
1317 |
|
|
endfunction
|
1318 |
|
|
|
1319 |
|
|
function [`QBITS] idp5;
|
1320 |
|
|
input [`QBITS] id;
|
1321 |
|
|
case(id)
|
1322 |
|
|
3'd0: idp5 = 3'd5;
|
1323 |
|
|
3'd1: idp5 = 3'd6;
|
1324 |
|
|
3'd2: idp5 = 3'd7;
|
1325 |
|
|
3'd3: idp5 = 3'd0;
|
1326 |
|
|
3'd4: idp5 = 3'd1;
|
1327 |
|
|
3'd5: idp5 = 3'd2;
|
1328 |
|
|
3'd6: idp5 = 3'd3;
|
1329 |
|
|
3'd7: idp5 = 3'd4;
|
1330 |
|
|
endcase
|
1331 |
|
|
endfunction
|
1332 |
|
|
|
1333 |
|
|
function [`QBITS] idp6;
|
1334 |
|
|
input [`QBITS] id;
|
1335 |
|
|
case(id)
|
1336 |
|
|
3'd0: idp6 = 3'd6;
|
1337 |
|
|
3'd1: idp6 = 3'd7;
|
1338 |
|
|
3'd2: idp6 = 3'd0;
|
1339 |
|
|
3'd3: idp6 = 3'd1;
|
1340 |
|
|
3'd4: idp6 = 3'd2;
|
1341 |
|
|
3'd5: idp6 = 3'd3;
|
1342 |
|
|
3'd6: idp6 = 3'd4;
|
1343 |
|
|
3'd7: idp6 = 3'd5;
|
1344 |
|
|
endcase
|
1345 |
|
|
endfunction
|
1346 |
|
|
|
1347 |
|
|
function [`QBITS] idp7;
|
1348 |
|
|
input [`QBITS] id;
|
1349 |
|
|
case(id)
|
1350 |
|
|
3'd0: idp7 = 3'd7;
|
1351 |
|
|
3'd1: idp7 = 3'd0;
|
1352 |
|
|
3'd2: idp7 = 3'd1;
|
1353 |
|
|
3'd3: idp7 = 3'd2;
|
1354 |
|
|
3'd4: idp7 = 3'd3;
|
1355 |
|
|
3'd5: idp7 = 3'd4;
|
1356 |
|
|
3'd6: idp7 = 3'd5;
|
1357 |
|
|
3'd7: idp7 = 3'd6;
|
1358 |
|
|
endcase
|
1359 |
|
|
endfunction
|
1360 |
|
|
|
1361 |
|
|
function [`QBITS] idm1;
|
1362 |
|
|
input [`QBITS] id;
|
1363 |
|
|
case(id)
|
1364 |
|
|
3'd0: idm1 = 3'd7;
|
1365 |
|
|
3'd1: idm1 = 3'd0;
|
1366 |
|
|
3'd2: idm1 = 3'd1;
|
1367 |
|
|
3'd3: idm1 = 3'd2;
|
1368 |
|
|
3'd4: idm1 = 3'd3;
|
1369 |
|
|
3'd5: idm1 = 3'd4;
|
1370 |
|
|
3'd6: idm1 = 3'd5;
|
1371 |
|
|
3'd7: idm1 = 3'd6;
|
1372 |
|
|
endcase
|
1373 |
|
|
endfunction
|
1374 |
|
|
|
1375 |
|
|
function [RBIT:0] fnRa;
|
1376 |
|
|
input [31:0] isn;
|
1377 |
|
|
input [5:0] vqei;
|
1378 |
|
|
input [5:0] vli;
|
1379 |
|
|
input thrd;
|
1380 |
|
|
case(isn[`INSTRUCTION_OP])
|
1381 |
|
|
`VECTOR:
|
1382 |
|
|
case(isn[`INSTRUCTION_S2])
|
1383 |
|
|
`VCIDX,`VSCAN: fnRa = {6'd0,1'b1,isn[`INSTRUCTION_RA]};
|
1384 |
|
|
`VMxx:
|
1385 |
|
|
case(isn[25:23])
|
1386 |
|
|
`VMAND,`VMOR,`VMXOR,`VMXNOR,`VMPOP,`VMFIRST,`VMLAST:
|
1387 |
|
|
fnRa = {6'h3F,1'b1,2'b0,isn[8:6]};
|
1388 |
|
|
`VMFILL:fnRa = {6'd0,1'b1,isn[`INSTRUCTION_RA]};
|
1389 |
|
|
default:fnRa = {6'h3F,1'b1,2'b0,isn[8:6]};
|
1390 |
|
|
endcase
|
1391 |
|
|
`VSHLV: fnRa = (vqei+1+isn[15:11] >= vli) ? 11'h000 : {vli-vqei-isn[15:11]-1,1'b1,isn[`INSTRUCTION_RA]};
|
1392 |
|
|
`VSHRV: fnRa = (vqei+isn[15:11] >= vli) ? 11'h000 : {vqei+isn[15:11],1'b1,isn[`INSTRUCTION_RA]};
|
1393 |
|
|
`VSxx,`VSxxU,`VSxxS,`VSxxSU: fnRa = {vqei,1'b1,isn[`INSTRUCTION_RA]};
|
1394 |
|
|
default: fnRa = {vqei,1'b1,isn[`INSTRUCTION_RA]};
|
1395 |
|
|
endcase
|
1396 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1397 |
|
|
`MOV:
|
1398 |
|
|
case(isn[25:23])
|
1399 |
|
|
3'd0: fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1400 |
|
|
3'd1: fnRa = {isn[21:16],1'b0,isn[`INSTRUCTION_RA]};
|
1401 |
|
|
3'd2: fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1402 |
|
|
3'd3: fnRa = {rs_stack[thrd][5:0],1'b0,isn[`INSTRUCTION_RA]};
|
1403 |
|
|
3'd4: fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1404 |
|
|
3'd5: fnRa = {rgs[thrd][5:1],1'b1,1'b0,isn[`INSTRUCTION_RA]};
|
1405 |
|
|
default:fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1406 |
|
|
endcase
|
1407 |
|
|
`VMOV:
|
1408 |
|
|
case (isn[`INSTRUCTION_S1])
|
1409 |
|
|
5'h0: fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1410 |
|
|
5'h1: fnRa = {6'h3F,1'b1,isn[`INSTRUCTION_RA]};
|
1411 |
|
|
endcase
|
1412 |
|
|
default: fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1413 |
|
|
endcase
|
1414 |
|
|
`FLOAT: fnRa = {rgs[thrd][5:1],1'b1,1'b0,isn[`INSTRUCTION_RA]};
|
1415 |
|
|
default: fnRa = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1416 |
|
|
endcase
|
1417 |
|
|
endfunction
|
1418 |
|
|
|
1419 |
|
|
function [RBIT:0] fnRb;
|
1420 |
|
|
input [31:0] isn;
|
1421 |
|
|
input fb;
|
1422 |
|
|
input [5:0] vqei;
|
1423 |
|
|
input [5:0] rfoa0i;
|
1424 |
|
|
input [5:0] rfoa1i;
|
1425 |
|
|
input thrd;
|
1426 |
|
|
case(isn[`INSTRUCTION_OP])
|
1427 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1428 |
|
|
`VEX: fnRb = fb ? {rfoa1i,1'b1,isn[`INSTRUCTION_RB]} : {rfoa0i,1'b1,isn[`INSTRUCTION_RB]};
|
1429 |
|
|
`LVX,`SVX: fnRb = {vqei,1'b1,isn[`INSTRUCTION_RB]};
|
1430 |
|
|
default: fnRb = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1431 |
|
|
endcase
|
1432 |
|
|
`VECTOR:
|
1433 |
|
|
case(isn[`INSTRUCTION_S2])
|
1434 |
|
|
`VMxx:
|
1435 |
|
|
case(isn[25:23])
|
1436 |
|
|
`VMAND,`VMOR,`VMXOR,`VMXNOR,`VMPOP:
|
1437 |
|
|
fnRb = {6'h3F,1'b1,2'b0,isn[13:11]};
|
1438 |
|
|
default: fnRb = 12'h000;
|
1439 |
|
|
endcase
|
1440 |
|
|
`VXCHG: fnRb = {vqei,1'b1,isn[`INSTRUCTION_RB]};
|
1441 |
|
|
`VSxx,`VSxxU: fnRb = {vqei,1'b1,isn[`INSTRUCTION_RB]};
|
1442 |
|
|
`VSxxS,`VSxxSU: fnRb = {vqei,1'b0,isn[`INSTRUCTION_RB]};
|
1443 |
|
|
`VADDS,`VSUBS,`VMULS,`VANDS,`VORS,`VXORS,`VXORS:
|
1444 |
|
|
fnRb = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1445 |
|
|
`VSHL,`VSHR,`VASR:
|
1446 |
|
|
fnRb = {isn[25],isn[22]}==2'b00 ? {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]} : {vqei,1'b1,isn[`INSTRUCTION_RB]};
|
1447 |
|
|
default: fnRb = {vqei,1'b1,isn[`INSTRUCTION_RB]};
|
1448 |
|
|
endcase
|
1449 |
|
|
`FLOAT: fnRb = {rgs[thrd][5:1],1'b1,1'b0,isn[`INSTRUCTION_RB]};
|
1450 |
|
|
default: fnRb = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1451 |
|
|
endcase
|
1452 |
|
|
endfunction
|
1453 |
|
|
|
1454 |
|
|
function [RBIT:0] fnRc;
|
1455 |
|
|
input [31:0] isn;
|
1456 |
|
|
input [5:0] vqei;
|
1457 |
|
|
input thrd;
|
1458 |
|
|
case(isn[`INSTRUCTION_OP])
|
1459 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1460 |
|
|
`SVX: fnRc = {vqei,1'b1,isn[`INSTRUCTION_RC]};
|
1461 |
|
|
`SBX,`SCX,`SHX,`SWX,`SWCX,`CACHEX:
|
1462 |
|
|
fnRc = {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1463 |
|
|
`CMOVEQ,`CMOVNE,`MAJ:
|
1464 |
|
|
fnRc = {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1465 |
|
|
default: fnRc = {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1466 |
|
|
endcase
|
1467 |
|
|
`VECTOR:
|
1468 |
|
|
case(isn[`INSTRUCTION_S2])
|
1469 |
|
|
`VSxx,`VSxxS,`VSxxU,`VSxxSU: fnRc = {6'h3F,1'b1,2'b0,isn[18:16]};
|
1470 |
|
|
default: fnRc = {vqei,1'b1,isn[`INSTRUCTION_RC]};
|
1471 |
|
|
endcase
|
1472 |
|
|
`FLOAT: fnRc = {rgs[thrd][5:1],1'b1,1'b0,isn[`INSTRUCTION_RC]};
|
1473 |
|
|
`BccR: fnRc = {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1474 |
|
|
default: fnRc = {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1475 |
|
|
endcase
|
1476 |
|
|
endfunction
|
1477 |
|
|
|
1478 |
|
|
function [RBIT:0] fnRt;
|
1479 |
|
|
input [31:0] isn;
|
1480 |
|
|
input [5:0] vqei;
|
1481 |
|
|
input [5:0] vli;
|
1482 |
|
|
input thrd;
|
1483 |
|
|
casez(isn[`INSTRUCTION_OP])
|
1484 |
|
|
`VECTOR:
|
1485 |
|
|
case(isn[`INSTRUCTION_S2])
|
1486 |
|
|
`VMxx:
|
1487 |
|
|
case(isn[25:23])
|
1488 |
|
|
`VMAND,`VMOR,`VMXOR,`VMXNOR,`VMFILL:
|
1489 |
|
|
fnRt = {6'h3F,1'b1,2'b0,isn[18:16]};
|
1490 |
|
|
`VMPOP: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1491 |
|
|
default:
|
1492 |
|
|
fnRt = {6'h3F,1'b1,2'b0,isn[18:16]};
|
1493 |
|
|
endcase
|
1494 |
|
|
`VSxx,`VSxxU,`VSxxS,`VSxxSU: fnRt = {6'h3F,1'b1,2'b0,isn[18:16]};
|
1495 |
|
|
`VSHLV: fnRt = (vqei+1 >= vli) ? 11'h000 : {vli-vqei-1,1'b1,isn[`INSTRUCTION_RC]};
|
1496 |
|
|
`VSHRV: fnRt = (vqei >= vli) ? 11'h000 : {vqei,1'b1,isn[`INSTRUCTION_RC]};
|
1497 |
|
|
`VEINS: fnRt = {vqei,1'b1,isn[`INSTRUCTION_RC]}; // ToDo: add element # from Ra
|
1498 |
|
|
`V2BITS: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1499 |
|
|
default: fnRt = {vqei,1'b1,isn[`INSTRUCTION_RC]};
|
1500 |
|
|
endcase
|
1501 |
|
|
|
1502 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1503 |
|
|
`MOV:
|
1504 |
|
|
case(isn[25:23])
|
1505 |
|
|
3'd0: fnRt = {isn[21:16],1'b0,isn[`INSTRUCTION_RB]};
|
1506 |
|
|
3'd1: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1507 |
|
|
3'd2: fnRt = {rs_stack[thrd][5:0],1'b0,isn[`INSTRUCTION_RB]};
|
1508 |
|
|
3'd3: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1509 |
|
|
3'd4: fnRt = {rgs[thrd][5:1],1'b1,1'b0,isn[`INSTRUCTION_RB]};
|
1510 |
|
|
3'd5: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1511 |
|
|
default:fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1512 |
|
|
endcase
|
1513 |
|
|
`VMOV:
|
1514 |
|
|
case (isn[`INSTRUCTION_S1])
|
1515 |
|
|
5'h0: fnRt = {6'h3F,1'b1,isn[`INSTRUCTION_RB]};
|
1516 |
|
|
5'h1: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1517 |
|
|
default: fnRt = 12'h000;
|
1518 |
|
|
endcase
|
1519 |
|
|
`R1:
|
1520 |
|
|
case(isn[20:16])
|
1521 |
|
|
`CNTLO,`CNTLZ,`CNTPOP,`ABS,`NOT:
|
1522 |
|
|
fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1523 |
|
|
`MEMDB,`MEMSB,`SYNC:
|
1524 |
|
|
fnRt = 12'd0;
|
1525 |
|
|
default: fnRt = 12'd0;
|
1526 |
|
|
endcase
|
1527 |
|
|
`CMOVEQ: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_S1]};
|
1528 |
|
|
`CMOVNE: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_S1]};
|
1529 |
|
|
`MUX: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_S1]};
|
1530 |
|
|
`MIN: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_S1]};
|
1531 |
|
|
`MAX: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_S1]};
|
1532 |
|
|
`LVX: fnRt = {vqei,1'b1,isn[20:16]};
|
1533 |
|
|
`SHIFT,`SHIFTB,`SHIFTC,`SHIFTH:
|
1534 |
|
|
fnRt = isn[25] ? {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]} : {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1535 |
|
|
`SEI,`WAIT,`RTI,`CHK,
|
1536 |
|
|
`SBX,`SCX,`SHX,`SWX,`SWCX,`CACHEX:
|
1537 |
|
|
fnRt = 12'd0;
|
1538 |
|
|
default: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1539 |
|
|
endcase
|
1540 |
|
|
`FLOAT:
|
1541 |
|
|
case(isn[31:26])
|
1542 |
|
|
`FTX,`FCX,`FEX,`FDX,`FRM:
|
1543 |
|
|
fnRt = 12'd0;
|
1544 |
|
|
`FSYNC: fnRt = 12'd0;
|
1545 |
|
|
default: fnRt = {rgs[thrd][5:1],1'b1,1'b0,isn[`INSTRUCTION_RC]};
|
1546 |
|
|
endcase
|
1547 |
|
|
`BRK: fnRt = 12'd0;
|
1548 |
|
|
`REX: fnRt = 12'd0;
|
1549 |
|
|
`CHK: fnRt = 12'd0;
|
1550 |
|
|
`EXEC: fnRt = 12'd0;
|
1551 |
|
|
`Bcc: fnRt = 12'd0;
|
1552 |
|
|
`BccR: fnRt = 12'd0;
|
1553 |
|
|
`BBc: case(isn[19:17])
|
1554 |
|
|
`DBNZ: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1555 |
|
|
default: fnRt = 12'd0;
|
1556 |
|
|
endcase
|
1557 |
|
|
`BEQI: fnRt = 12'd0;
|
1558 |
|
|
`SB,`SC,`SH,`SW,`SWC,`CACHE:
|
1559 |
|
|
fnRt = 12'd0;
|
1560 |
|
|
`JMP: fnRt = 12'd0;
|
1561 |
|
|
`CALL: fnRt = {rgs[thrd],1'b0,regLR}; // regLR
|
1562 |
|
|
`RET: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RA]};
|
1563 |
|
|
`LV: fnRt = {vqei,1'b1,isn[`INSTRUCTION_RB]};
|
1564 |
|
|
`AMO: fnRt = isn[31] ? {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]} : {rgs[thrd],1'b0,isn[`INSTRUCTION_RC]};
|
1565 |
|
|
default: fnRt = {rgs[thrd],1'b0,isn[`INSTRUCTION_RB]};
|
1566 |
|
|
endcase
|
1567 |
|
|
endfunction
|
1568 |
|
|
|
1569 |
|
|
// Determines which lanes of the target register get updated.
|
1570 |
|
|
function [7:0] fnWe;
|
1571 |
|
|
input [31:0] isn;
|
1572 |
|
|
casez(isn[`INSTRUCTION_OP])
|
1573 |
|
|
`RR:
|
1574 |
|
|
case(isn[`INSTRUCTION_S2])
|
1575 |
|
|
`R1:
|
1576 |
|
|
case(isn[20:16])
|
1577 |
|
|
`ABS,`CNTLZ,`CNTLO,`CNTPOP:
|
1578 |
|
|
case(isn[23:21])
|
1579 |
|
|
3'b000: fnWe = 8'h01;
|
1580 |
|
|
3'b001: fnWe = 8'h03;
|
1581 |
|
|
3'b010: fnWe = 8'h0F;
|
1582 |
|
|
3'b011: fnWe = 8'hFF;
|
1583 |
|
|
default: fnWe = 8'hFF;
|
1584 |
|
|
endcase
|
1585 |
|
|
default: fnWe = 8'hFF;
|
1586 |
|
|
endcase
|
1587 |
|
|
`SHIFT: fnWe = (~isn[25] & isn[21]) ? 8'hFF : 8'hFF;
|
1588 |
|
|
`SHIFTH: fnWe = (~isn[25] & isn[21]) ? 8'hFF : 8'h0F;
|
1589 |
|
|
`SHIFTC: fnWe = (~isn[25] & isn[21]) ? 8'hFF : 8'h03;
|
1590 |
|
|
`SHIFTB: fnWe = (~isn[25] & isn[21]) ? 8'hFF : 8'h01;
|
1591 |
|
|
`ADD,`SUB,
|
1592 |
|
|
`AND,`OR,`XOR,
|
1593 |
|
|
`NAND,`NOR,`XNOR,
|
1594 |
|
|
`DIVMOD,`DIVMODU,`DIVMODSU,
|
1595 |
|
|
`MUL,`MULU,`MULSU:
|
1596 |
|
|
case(isn[23:21])
|
1597 |
|
|
3'b000: fnWe = 8'h01;
|
1598 |
|
|
3'b001: fnWe = 8'h03;
|
1599 |
|
|
3'b010: fnWe = 8'h0F;
|
1600 |
|
|
3'b011: fnWe = 8'hFF;
|
1601 |
|
|
default: fnWe = 8'hFF;
|
1602 |
|
|
endcase
|
1603 |
|
|
`CMP,`CMPU:
|
1604 |
|
|
case(isn[22:21])
|
1605 |
|
|
2'b00: fnWe = 8'h01;
|
1606 |
|
|
2'b01: fnWe = 8'h03;
|
1607 |
|
|
2'b10: fnWe = 8'h0F;
|
1608 |
|
|
2'b11: fnWe = 8'hFF;
|
1609 |
|
|
endcase
|
1610 |
|
|
`LBOX: fnWe = 8'h01;
|
1611 |
|
|
`LCOX: fnWe = 8'h03;
|
1612 |
|
|
`LHOX: fnWe = 8'h0F;
|
1613 |
|
|
default: fnWe = 8'hFF;
|
1614 |
|
|
endcase
|
1615 |
|
|
`LBO: fnWe = 8'h01;
|
1616 |
|
|
`LCO: fnWe = 8'h03;
|
1617 |
|
|
`LHO: fnWe = 8'h0F;
|
1618 |
|
|
default: fnWe = 8'hFF;
|
1619 |
|
|
endcase
|
1620 |
|
|
endfunction
|
1621 |
|
|
|
1622 |
|
|
// Detect if a source is automatically valid
|
1623 |
|
|
function Source1Valid;
|
1624 |
|
|
input [31:0] isn;
|
1625 |
|
|
casez(isn[`INSTRUCTION_OP])
|
1626 |
|
|
`BRK: Source1Valid = TRUE;
|
1627 |
|
|
`Bcc: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1628 |
|
|
`BccR: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1629 |
|
|
`BBc: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1630 |
|
|
`BEQI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1631 |
|
|
`CHK: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1632 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1633 |
|
|
`SHIFT: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1634 |
|
|
`SHIFTH: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1635 |
|
|
`SHIFTC: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1636 |
|
|
`SHIFTB: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1637 |
|
|
default: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1638 |
|
|
endcase
|
1639 |
|
|
`ADDI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1640 |
|
|
`CMPI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1641 |
|
|
`CMPUI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1642 |
|
|
`ANDI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1643 |
|
|
`ORI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1644 |
|
|
`XORI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1645 |
|
|
`MULUI: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1646 |
|
|
`AMO: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1647 |
|
|
`LB: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1648 |
|
|
`LBO: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1649 |
|
|
`LBU: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1650 |
|
|
`LC: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1651 |
|
|
`LCO: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1652 |
|
|
`LCU: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1653 |
|
|
`LH: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1654 |
|
|
`LHO: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1655 |
|
|
`LHU: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1656 |
|
|
`LW: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1657 |
|
|
`LWR: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1658 |
|
|
`LV: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1659 |
|
|
`LVx: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1660 |
|
|
`SB: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1661 |
|
|
`SC: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1662 |
|
|
`SH: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1663 |
|
|
`SW: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1664 |
|
|
`SWC: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1665 |
|
|
`SV: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1666 |
|
|
`CAS: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1667 |
|
|
`JAL: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1668 |
|
|
`RET: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1669 |
|
|
`CSRRW: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1670 |
|
|
`BITFIELD: case(isn[31:28])
|
1671 |
|
|
`BFINSI: Source1Valid = TRUE;
|
1672 |
|
|
default: Source1Valid = isn[`INSTRUCTION_RA]==5'd0;
|
1673 |
|
|
endcase
|
1674 |
|
|
`VECTOR:
|
1675 |
|
|
Source1Valid = FALSE;
|
1676 |
|
|
default: Source1Valid = TRUE;
|
1677 |
|
|
endcase
|
1678 |
|
|
endfunction
|
1679 |
|
|
|
1680 |
|
|
function Source2Valid;
|
1681 |
|
|
input [31:0] isn;
|
1682 |
|
|
casez(isn[`INSTRUCTION_OP])
|
1683 |
|
|
`BRK: Source2Valid = TRUE;
|
1684 |
|
|
`Bcc: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1685 |
|
|
`BccR: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1686 |
|
|
`BBc: Source2Valid = TRUE;
|
1687 |
|
|
`BEQI: Source2Valid = TRUE;
|
1688 |
|
|
`CHK: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1689 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1690 |
|
|
`R1: Source2Valid = TRUE;
|
1691 |
|
|
`SHIFT: Source2Valid = isn[25] ? 1'b1 : isn[`INSTRUCTION_RB]==5'd0;
|
1692 |
|
|
`SHIFTH: Source2Valid = isn[25] ? 1'b1 : isn[`INSTRUCTION_RB]==5'd0;
|
1693 |
|
|
`SHIFTC: Source2Valid = isn[25] ? 1'b1 : isn[`INSTRUCTION_RB]==5'd0;
|
1694 |
|
|
`SHIFTB: Source2Valid = isn[25] ? 1'b1 : isn[`INSTRUCTION_RB]==5'd0;
|
1695 |
|
|
`LVX,`SVX: Source2Valid = FALSE;
|
1696 |
|
|
default: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1697 |
|
|
endcase
|
1698 |
|
|
`ADDI: Source2Valid = TRUE;
|
1699 |
|
|
`CMPI: Source2Valid = TRUE;
|
1700 |
|
|
`CMPUI: Source2Valid = TRUE;
|
1701 |
|
|
`ANDI: Source2Valid = TRUE;
|
1702 |
|
|
`ORI: Source2Valid = TRUE;
|
1703 |
|
|
`XORI: Source2Valid = TRUE;
|
1704 |
|
|
`MULUI: Source2Valid = TRUE;
|
1705 |
|
|
`QOPI: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1706 |
|
|
`LB: Source2Valid = TRUE;
|
1707 |
|
|
`LBO: Source2Valid = TRUE;
|
1708 |
|
|
`LBU: Source2Valid = TRUE;
|
1709 |
|
|
`LC: Source2Valid = TRUE;
|
1710 |
|
|
`LCO: Source2Valid = TRUE;
|
1711 |
|
|
`LCU: Source2Valid = TRUE;
|
1712 |
|
|
`LH: Source2Valid = TRUE;
|
1713 |
|
|
`LHO: Source2Valid = TRUE;
|
1714 |
|
|
`LHU: Source2Valid = TRUE;
|
1715 |
|
|
`LW: Source2Valid = TRUE;
|
1716 |
|
|
`LWR: Source2Valid = TRUE;
|
1717 |
|
|
`LVx: Source2Valid = TRUE;
|
1718 |
|
|
`SB: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1719 |
|
|
`SC: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1720 |
|
|
`SH: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1721 |
|
|
`SW: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1722 |
|
|
`SWC: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1723 |
|
|
`CAS: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1724 |
|
|
`JAL: Source2Valid = TRUE;
|
1725 |
|
|
`RET: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1726 |
|
|
`VECTOR:
|
1727 |
|
|
case(isn[`INSTRUCTION_S2])
|
1728 |
|
|
`VABS: Source2Valid = TRUE;
|
1729 |
|
|
`VMAND,`VMOR,`VMXOR,`VMXNOR,`VMPOP:
|
1730 |
|
|
Source2Valid = FALSE;
|
1731 |
|
|
`VADDS,`VSUBS,`VANDS,`VORS,`VXORS:
|
1732 |
|
|
Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1733 |
|
|
`VBITS2V: Source2Valid = TRUE;
|
1734 |
|
|
`V2BITS: Source2Valid = isn[`INSTRUCTION_RB]==5'd0;
|
1735 |
|
|
`VSHL,`VSHR,`VASR: Source2Valid = isn[22:21]==2'd2;
|
1736 |
|
|
default: Source2Valid = FALSE;
|
1737 |
|
|
endcase
|
1738 |
|
|
`LV: Source2Valid = TRUE;
|
1739 |
|
|
`SV: Source2Valid = FALSE;
|
1740 |
|
|
`AMO: Source2Valid = isn[31] || isn[`INSTRUCTION_RB]==5'd0;
|
1741 |
|
|
default: Source2Valid = TRUE;
|
1742 |
|
|
endcase
|
1743 |
|
|
endfunction
|
1744 |
|
|
|
1745 |
|
|
function Source3Valid;
|
1746 |
|
|
input [31:0] isn;
|
1747 |
|
|
case(isn[`INSTRUCTION_OP])
|
1748 |
|
|
`VECTOR:
|
1749 |
|
|
case(isn[`INSTRUCTION_S2])
|
1750 |
|
|
`VEX: Source3Valid = TRUE;
|
1751 |
|
|
default: Source3Valid = TRUE;
|
1752 |
|
|
endcase
|
1753 |
|
|
`BccR: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1754 |
|
|
`CHK: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1755 |
|
|
`RR:
|
1756 |
|
|
case(isn[`INSTRUCTION_S2])
|
1757 |
|
|
`SBX: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1758 |
|
|
`SCX: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1759 |
|
|
`SHX: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1760 |
|
|
`SWX: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1761 |
|
|
`SWCX: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1762 |
|
|
`CASX: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1763 |
|
|
`CMOVEQ,`CMOVNE,`MAJ: Source3Valid = isn[`INSTRUCTION_RC]==5'd0;
|
1764 |
|
|
default: Source3Valid = TRUE;
|
1765 |
|
|
endcase
|
1766 |
|
|
default: Source3Valid = TRUE;
|
1767 |
|
|
endcase
|
1768 |
|
|
endfunction
|
1769 |
|
|
|
1770 |
|
|
function SourceTValid;
|
1771 |
|
|
input [31:0] isn;
|
1772 |
|
|
SourceTValid = FALSE;
|
1773 |
|
|
endfunction
|
1774 |
|
|
function SourceT2Valid;
|
1775 |
|
|
input [31:0] isn;
|
1776 |
|
|
case(isn[`INSTRUCTION_OP])
|
1777 |
|
|
`Bcc: SourceT2Valid = TRUE;
|
1778 |
|
|
`ORI: SourceT2Valid = TRUE;
|
1779 |
|
|
default: SourceT2Valid = FALSE;
|
1780 |
|
|
endcase
|
1781 |
|
|
endfunction
|
1782 |
|
|
|
1783 |
|
|
// Used to indicate to the queue logic that the instruction needs to be
|
1784 |
|
|
// recycled to the queue VL number of times.
|
1785 |
|
|
function IsVector;
|
1786 |
|
|
input [31:0] isn;
|
1787 |
|
|
case(isn[`INSTRUCTION_OP])
|
1788 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1789 |
|
|
`LVX,`SVX: IsVector = TRUE;
|
1790 |
|
|
default: IsVector = FALSE;
|
1791 |
|
|
endcase
|
1792 |
|
|
`VECTOR:
|
1793 |
|
|
case(isn[`INSTRUCTION_S2])
|
1794 |
|
|
`VMxx:
|
1795 |
|
|
case(isn[25:23])
|
1796 |
|
|
`VMAND,`VMOR,`VMXOR,`VMXNOR,`VMPOP:
|
1797 |
|
|
IsVector = FALSE;
|
1798 |
|
|
default: IsVector = TRUE;
|
1799 |
|
|
endcase
|
1800 |
|
|
`VEINS: IsVector = FALSE;
|
1801 |
|
|
`VEX: IsVector = FALSE;
|
1802 |
|
|
default: IsVector = TRUE;
|
1803 |
|
|
endcase
|
1804 |
|
|
`LV,`SV: IsVector = TRUE;
|
1805 |
|
|
default: IsVector = FALSE;
|
1806 |
|
|
endcase
|
1807 |
|
|
endfunction
|
1808 |
|
|
|
1809 |
|
|
function IsVeins;
|
1810 |
|
|
input [31:0] isn;
|
1811 |
|
|
case(isn[`INSTRUCTION_OP])
|
1812 |
|
|
`VECTOR: IsVeins = isn[`INSTRUCTION_S2]==`VEINS;
|
1813 |
|
|
default: IsVeins = FALSE;
|
1814 |
|
|
endcase
|
1815 |
|
|
endfunction
|
1816 |
|
|
|
1817 |
|
|
function IsVex;
|
1818 |
|
|
input [31:0] isn;
|
1819 |
|
|
case(isn[`INSTRUCTION_OP])
|
1820 |
|
|
`VECTOR: IsVex = isn[`INSTRUCTION_S2]==`VEX;
|
1821 |
|
|
default: IsVex = FALSE;
|
1822 |
|
|
endcase
|
1823 |
|
|
endfunction
|
1824 |
|
|
|
1825 |
|
|
function IsVCmprss;
|
1826 |
|
|
input [31:0] isn;
|
1827 |
|
|
case(isn[`INSTRUCTION_OP])
|
1828 |
|
|
`VECTOR: IsVCmprss = isn[`INSTRUCTION_S2]==`VCMPRSS || isn[`INSTRUCTION_S2]==`VCIDX;
|
1829 |
|
|
default: IsVCmprss = FALSE;
|
1830 |
|
|
endcase
|
1831 |
|
|
endfunction
|
1832 |
|
|
|
1833 |
|
|
function IsVShifti;
|
1834 |
|
|
input [31:0] isn;
|
1835 |
|
|
case(isn[`INSTRUCTION_OP])
|
1836 |
|
|
`VECTOR:
|
1837 |
|
|
case(isn[`INSTRUCTION_S2])
|
1838 |
|
|
`VSHL,`VSHR,`VASR:
|
1839 |
|
|
IsVShifti = {isn[25],isn[22]}==2'd2;
|
1840 |
|
|
default: IsVShifti = FALSE;
|
1841 |
|
|
endcase
|
1842 |
|
|
default: IsVShifti = FALSE;
|
1843 |
|
|
endcase
|
1844 |
|
|
endfunction
|
1845 |
|
|
|
1846 |
|
|
function IsVLS;
|
1847 |
|
|
input [31:0] isn;
|
1848 |
|
|
case(isn[`INSTRUCTION_OP])
|
1849 |
|
|
`RR:
|
1850 |
|
|
case(isn[`INSTRUCTION_S2])
|
1851 |
|
|
`LVX,`SVX,`LVWS,`SVWS: IsVLS = TRUE;
|
1852 |
|
|
default: IsVLS = FALSE;
|
1853 |
|
|
endcase
|
1854 |
|
|
`LV,`SV: IsVLS = TRUE;
|
1855 |
|
|
default: IsVLS = FALSE;
|
1856 |
|
|
endcase
|
1857 |
|
|
endfunction
|
1858 |
|
|
|
1859 |
|
|
function [1:0] fnM2;
|
1860 |
|
|
input [31:0] isn;
|
1861 |
|
|
case(isn[`INSTRUCTION_OP])
|
1862 |
|
|
`RR: fnM2 = isn[24:23];
|
1863 |
|
|
default: fnM2 = 2'b00;
|
1864 |
|
|
endcase
|
1865 |
|
|
endfunction
|
1866 |
|
|
|
1867 |
|
|
function IsALU;
|
1868 |
|
|
input [31:0] isn;
|
1869 |
|
|
casez(isn[`INSTRUCTION_OP])
|
1870 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
1871 |
|
|
`VMOV: IsALU = TRUE;
|
1872 |
|
|
`RTI: IsALU = FALSE;
|
1873 |
|
|
default: IsALU = TRUE;
|
1874 |
|
|
endcase
|
1875 |
|
|
`BRK: IsALU = FALSE;
|
1876 |
|
|
`Bcc: IsALU = FALSE;
|
1877 |
|
|
`BccR: IsALU = FALSE;
|
1878 |
|
|
`BBc: IsALU = FALSE;
|
1879 |
|
|
`BEQI: IsALU = FALSE;
|
1880 |
|
|
`CHK: IsALU = FALSE;
|
1881 |
|
|
`JAL: IsALU = FALSE;
|
1882 |
|
|
`JMP: IsALU = FALSE;
|
1883 |
|
|
`CALL: IsALU = FALSE;
|
1884 |
|
|
`RET: IsALU = FALSE;
|
1885 |
|
|
`VECTOR:
|
1886 |
|
|
case(isn[`INSTRUCTION_S2])
|
1887 |
|
|
`VSHL,`VSHR,`VASR: IsALU = TRUE;
|
1888 |
|
|
default: IsALU = isn[22:21]==2'b00; // Integer
|
1889 |
|
|
endcase
|
1890 |
|
|
`FLOAT: IsALU = FALSE;
|
1891 |
|
|
default: IsALU = TRUE;
|
1892 |
|
|
endcase
|
1893 |
|
|
endfunction
|
1894 |
|
|
|
1895 |
|
|
function IsFPU;
|
1896 |
|
|
input [31:0] isn;
|
1897 |
|
|
case(isn[`INSTRUCTION_OP])
|
1898 |
|
|
`FLOAT: IsFPU = TRUE;
|
1899 |
|
|
`VECTOR:
|
1900 |
|
|
case(isn[`INSTRUCTION_S2])
|
1901 |
|
|
`VSHL,`VSHR,`VASR: IsFPU = FALSE;
|
1902 |
|
|
default: IsFPU = isn[22:21]==2'b01;
|
1903 |
|
|
endcase
|
1904 |
|
|
default: IsFPU = FALSE;
|
1905 |
|
|
endcase
|
1906 |
|
|
|
1907 |
|
|
endfunction
|
1908 |
|
|
|
1909 |
|
|
function HasConst;
|
1910 |
|
|
input [31:0] isn;
|
1911 |
|
|
casez(isn[`INSTRUCTION_OP])
|
1912 |
|
|
`BRK: HasConst = FALSE;
|
1913 |
|
|
`Bcc: HasConst = FALSE;
|
1914 |
|
|
`BccR: HasConst = FALSE;
|
1915 |
|
|
`BBc: HasConst = FALSE;
|
1916 |
|
|
`BEQI: HasConst = FALSE;
|
1917 |
|
|
`RR: HasConst = FALSE;
|
1918 |
|
|
/*
|
1919 |
|
|
case(isn[`INSTRUCTION_S2])
|
1920 |
|
|
`SHLI: HasConst = TRUE;
|
1921 |
|
|
`SHRI: HasConst = TRUE;
|
1922 |
|
|
default: HasConst = FALSE;
|
1923 |
|
|
endcase*/
|
1924 |
|
|
`ADDI: HasConst = TRUE;
|
1925 |
|
|
`CMPI: HasConst = TRUE;
|
1926 |
|
|
`CMPUI: HasConst = TRUE;
|
1927 |
|
|
`ANDI: HasConst = TRUE;
|
1928 |
|
|
`ORI: HasConst = TRUE;
|
1929 |
|
|
`XORI: HasConst = TRUE;
|
1930 |
|
|
`MULUI: HasConst = TRUE;
|
1931 |
|
|
`MULSUI: HasConst = TRUE;
|
1932 |
|
|
`MULI: HasConst = TRUE;
|
1933 |
|
|
`DIVUI: HasConst = TRUE;
|
1934 |
|
|
`DIVSUI: HasConst = TRUE;
|
1935 |
|
|
`DIVI: HasConst = TRUE;
|
1936 |
|
|
`MODUI: HasConst = TRUE;
|
1937 |
|
|
`MODSUI: HasConst = TRUE;
|
1938 |
|
|
`MODI: HasConst = TRUE;
|
1939 |
|
|
`LB: HasConst = TRUE;
|
1940 |
|
|
`LBO: HasConst = TRUE;
|
1941 |
|
|
`LBU: HasConst = TRUE;
|
1942 |
|
|
`LC: HasConst = TRUE;
|
1943 |
|
|
`LCO: HasConst = TRUE;
|
1944 |
|
|
`LCU: HasConst = TRUE;
|
1945 |
|
|
`LH: HasConst = TRUE;
|
1946 |
|
|
`LHO: HasConst = TRUE;
|
1947 |
|
|
`LHU: HasConst = TRUE;
|
1948 |
|
|
`LW: HasConst = TRUE;
|
1949 |
|
|
`LWR: HasConst = TRUE;
|
1950 |
|
|
`LV: HasConst = TRUE;
|
1951 |
|
|
`SB: HasConst = TRUE;
|
1952 |
|
|
`SC: HasConst = TRUE;
|
1953 |
|
|
`SH: HasConst = TRUE;
|
1954 |
|
|
`SW: HasConst = TRUE;
|
1955 |
|
|
`SWC: HasConst = TRUE;
|
1956 |
|
|
`SV: HasConst = TRUE;
|
1957 |
|
|
`CAS: HasConst = TRUE;
|
1958 |
|
|
`JAL: HasConst = TRUE;
|
1959 |
|
|
`CALL: HasConst = TRUE;
|
1960 |
|
|
`RET: HasConst = TRUE;
|
1961 |
|
|
`SccI: HasConst = TRUE;
|
1962 |
|
|
`LVx: HasConst = TRUE;
|
1963 |
|
|
default: HasConst = FALSE;
|
1964 |
|
|
endcase
|
1965 |
|
|
endfunction
|
1966 |
|
|
|
1967 |
|
|
function [0:0] IsMem;
|
1968 |
|
|
input [31:0] isn;
|
1969 |
|
|
case(isn[`INSTRUCTION_OP])
|
1970 |
|
|
`RR:
|
1971 |
|
|
case(isn[`INSTRUCTION_S2])
|
1972 |
|
|
`LBX: IsMem = TRUE;
|
1973 |
|
|
`LBOX: IsMem = TRUE;
|
1974 |
|
|
`LBUX: IsMem = TRUE;
|
1975 |
|
|
`LCX: IsMem = TRUE;
|
1976 |
|
|
`LCOX: IsMem = TRUE;
|
1977 |
|
|
`LCUX: IsMem = TRUE;
|
1978 |
|
|
`LHX: IsMem = TRUE;
|
1979 |
|
|
`LHOX: IsMem = TRUE;
|
1980 |
|
|
`LHUX: IsMem = TRUE;
|
1981 |
|
|
`LWX: IsMem = TRUE;
|
1982 |
|
|
`LWRX: IsMem = TRUE;
|
1983 |
|
|
`SBX: IsMem = TRUE;
|
1984 |
|
|
`SCX: IsMem = TRUE;
|
1985 |
|
|
`SHX: IsMem = TRUE;
|
1986 |
|
|
`SWX: IsMem = TRUE;
|
1987 |
|
|
`SWCX: IsMem = TRUE;
|
1988 |
|
|
`CASX: IsMem = TRUE;
|
1989 |
|
|
`LVX,`SVX: IsMem = TRUE;
|
1990 |
|
|
`LVx: IsMem = TRUE;
|
1991 |
|
|
default: IsMem = FALSE;
|
1992 |
|
|
endcase
|
1993 |
|
|
`AMO: IsMem = TRUE;
|
1994 |
|
|
`LB: IsMem = TRUE;
|
1995 |
|
|
`LBO: IsMem = TRUE;
|
1996 |
|
|
`LBU: IsMem = TRUE;
|
1997 |
|
|
`LC: IsMem = TRUE;
|
1998 |
|
|
`LCO: IsMem = TRUE;
|
1999 |
|
|
`LCU: IsMem = TRUE;
|
2000 |
|
|
`LH: IsMem = TRUE;
|
2001 |
|
|
`LHO: IsMem = TRUE;
|
2002 |
|
|
`LHU: IsMem = TRUE;
|
2003 |
|
|
`LW: IsMem = TRUE;
|
2004 |
|
|
`LWR: IsMem = TRUE;
|
2005 |
|
|
`LV,`SV: IsMem = TRUE;
|
2006 |
|
|
`SB: IsMem = TRUE;
|
2007 |
|
|
`SC: IsMem = TRUE;
|
2008 |
|
|
`SH: IsMem = TRUE;
|
2009 |
|
|
`SW: IsMem = TRUE;
|
2010 |
|
|
`SWC: IsMem = TRUE;
|
2011 |
|
|
`CAS: IsMem = TRUE;
|
2012 |
|
|
`LVx: IsMem = TRUE;
|
2013 |
|
|
default: IsMem = FALSE;
|
2014 |
|
|
endcase
|
2015 |
|
|
endfunction
|
2016 |
|
|
|
2017 |
|
|
function IsMemNdx;
|
2018 |
|
|
input [31:0] isn;
|
2019 |
|
|
case(isn[`INSTRUCTION_OP])
|
2020 |
|
|
`RR:
|
2021 |
|
|
case(isn[`INSTRUCTION_S2])
|
2022 |
|
|
`LBX: IsMemNdx = TRUE;
|
2023 |
|
|
`LBOX: IsMemNdx = TRUE;
|
2024 |
|
|
`LBUX: IsMemNdx = TRUE;
|
2025 |
|
|
`LCX: IsMemNdx = TRUE;
|
2026 |
|
|
`LCOX: IsMemNdx = TRUE;
|
2027 |
|
|
`LCUX: IsMemNdx = TRUE;
|
2028 |
|
|
`LHX: IsMemNdx = TRUE;
|
2029 |
|
|
`LHOX: IsMemNdx = TRUE;
|
2030 |
|
|
`LHUX: IsMemNdx = TRUE;
|
2031 |
|
|
`LWX: IsMemNdx = TRUE;
|
2032 |
|
|
`LWRX: IsMemNdx = TRUE;
|
2033 |
|
|
`SBX: IsMemNdx = TRUE;
|
2034 |
|
|
`SCX: IsMemNdx = TRUE;
|
2035 |
|
|
`SHX: IsMemNdx = TRUE;
|
2036 |
|
|
`SWX: IsMemNdx = TRUE;
|
2037 |
|
|
`SWCX: IsMemNdx = TRUE;
|
2038 |
|
|
`CASX: IsMemNdx = TRUE;
|
2039 |
|
|
`LVX,`SVX: IsMemNdx = TRUE;
|
2040 |
|
|
`LVx: IsMemNdx = TRUE;
|
2041 |
|
|
default: IsMemNdx = FALSE;
|
2042 |
|
|
endcase
|
2043 |
|
|
default: IsMemNdx = FALSE;
|
2044 |
|
|
endcase
|
2045 |
|
|
endfunction
|
2046 |
|
|
|
2047 |
|
|
function IsLoad;
|
2048 |
|
|
input [31:0] isn;
|
2049 |
|
|
case(isn[`INSTRUCTION_OP])
|
2050 |
|
|
`RR:
|
2051 |
|
|
case(isn[`INSTRUCTION_S2])
|
2052 |
|
|
`LBX: IsLoad = TRUE;
|
2053 |
|
|
`LBOX: IsLoad = TRUE;
|
2054 |
|
|
`LBUX: IsLoad = TRUE;
|
2055 |
|
|
`LCX: IsLoad = TRUE;
|
2056 |
|
|
`LCOX: IsLoad = TRUE;
|
2057 |
|
|
`LCUX: IsLoad = TRUE;
|
2058 |
|
|
`LHX: IsLoad = TRUE;
|
2059 |
|
|
`LHOX: IsLoad = TRUE;
|
2060 |
|
|
`LHUX: IsLoad = TRUE;
|
2061 |
|
|
`LWX: IsLoad = TRUE;
|
2062 |
|
|
`LWRX: IsLoad = TRUE;
|
2063 |
|
|
`LVX: IsLoad = TRUE;
|
2064 |
|
|
`LVx: IsLoad = TRUE;
|
2065 |
|
|
default: IsLoad = FALSE;
|
2066 |
|
|
endcase
|
2067 |
|
|
`LB: IsLoad = TRUE;
|
2068 |
|
|
`LBO: IsLoad = TRUE;
|
2069 |
|
|
`LBU: IsLoad = TRUE;
|
2070 |
|
|
`LC: IsLoad = TRUE;
|
2071 |
|
|
`LCO: IsLoad = TRUE;
|
2072 |
|
|
`LCU: IsLoad = TRUE;
|
2073 |
|
|
`LH: IsLoad = TRUE;
|
2074 |
|
|
`LHO: IsLoad = TRUE;
|
2075 |
|
|
`LHU: IsLoad = TRUE;
|
2076 |
|
|
`LW: IsLoad = TRUE;
|
2077 |
|
|
`LWR: IsLoad = TRUE;
|
2078 |
|
|
`LV: IsLoad = TRUE;
|
2079 |
|
|
`LVx: IsLoad = TRUE;
|
2080 |
|
|
default: IsLoad = FALSE;
|
2081 |
|
|
endcase
|
2082 |
|
|
endfunction
|
2083 |
|
|
|
2084 |
|
|
function IsVolatileLoad;
|
2085 |
|
|
input [31:0] isn;
|
2086 |
|
|
case(isn[`INSTRUCTION_OP])
|
2087 |
|
|
`RR:
|
2088 |
|
|
case(isn[`INSTRUCTION_S2])
|
2089 |
|
|
`LWRX: IsVolatileLoad = TRUE;
|
2090 |
|
|
`LVx: IsVolatileLoad = TRUE;
|
2091 |
|
|
default: IsVolatileLoad = FALSE;
|
2092 |
|
|
endcase
|
2093 |
|
|
`LWR: IsVolatileLoad = TRUE;
|
2094 |
|
|
`LVx: IsVolatileLoad = TRUE;
|
2095 |
|
|
default: IsVolatileLoad = FALSE;
|
2096 |
|
|
endcase
|
2097 |
|
|
endfunction
|
2098 |
|
|
|
2099 |
|
|
function [2:0] MemSize;
|
2100 |
|
|
input [31:0] isn;
|
2101 |
|
|
case(isn[`INSTRUCTION_OP])
|
2102 |
|
|
`RR:
|
2103 |
|
|
case(isn[`INSTRUCTION_S2])
|
2104 |
|
|
`LBX,`LBOX,`LBUX,`SBX: MemSize = byt;
|
2105 |
|
|
`LCX,`LCOX,`LCUX,`SCX: MemSize = wyde;
|
2106 |
|
|
`LHX,`SHX: MemSize = tetra;
|
2107 |
|
|
`LHOX,`LHUX: MemSize = tetra;
|
2108 |
|
|
`LWX,`SWX: MemSize = octa;
|
2109 |
|
|
`LWRX,`SWCX: MemSize = octa;
|
2110 |
|
|
`LVX,`SVX: MemSize = octa;
|
2111 |
|
|
`LVx:
|
2112 |
|
|
case(isn[25:23])
|
2113 |
|
|
3'd0,3'd1: MemSize = byt;
|
2114 |
|
|
3'd2,3'd3: MemSize = wyde;
|
2115 |
|
|
3'd4,3'd5: MemSize = tetra;
|
2116 |
|
|
default: MemSize = octa;
|
2117 |
|
|
endcase
|
2118 |
|
|
default: MemSize = octa;
|
2119 |
|
|
endcase
|
2120 |
|
|
`LB,`LBO,`LBU,`SB: MemSize = byt;
|
2121 |
|
|
`LC,`LCO,`LCU,`SC: MemSize = wyde;
|
2122 |
|
|
`LH,`SH: MemSize = tetra;
|
2123 |
|
|
`LHO,`LHU: MemSize = tetra;
|
2124 |
|
|
`LW,`SW: MemSize = octa;
|
2125 |
|
|
`LWR,`SWC: MemSize = octa;
|
2126 |
|
|
`LV,`SV: MemSize = octa;
|
2127 |
|
|
`AMO:
|
2128 |
|
|
case(isn[23:21])
|
2129 |
|
|
3'd0: MemSize = byt;
|
2130 |
|
|
3'd1: MemSize = wyde;
|
2131 |
|
|
3'd2: MemSize = tetra;
|
2132 |
|
|
3'd3: MemSize = octa;
|
2133 |
|
|
default: MemSize = octa;
|
2134 |
|
|
endcase
|
2135 |
|
|
`LVx:
|
2136 |
|
|
case(isn[30:28])
|
2137 |
|
|
3'd0,3'd1: MemSize = byt;
|
2138 |
|
|
3'd2,3'd3: MemSize = wyde;
|
2139 |
|
|
3'd4,3'd5: MemSize = tetra;
|
2140 |
|
|
default: MemSize = octa;
|
2141 |
|
|
endcase
|
2142 |
|
|
default: MemSize = octa;
|
2143 |
|
|
endcase
|
2144 |
|
|
endfunction
|
2145 |
|
|
|
2146 |
|
|
function IsStore;
|
2147 |
|
|
input [31:0] isn;
|
2148 |
|
|
case(isn[`INSTRUCTION_OP])
|
2149 |
|
|
`RR:
|
2150 |
|
|
case(isn[`INSTRUCTION_S2])
|
2151 |
|
|
`SBX: IsStore = TRUE;
|
2152 |
|
|
`SCX: IsStore = TRUE;
|
2153 |
|
|
`SHX: IsStore = TRUE;
|
2154 |
|
|
`SWX: IsStore = TRUE;
|
2155 |
|
|
`SWCX: IsStore = TRUE;
|
2156 |
|
|
`SVX: IsStore = TRUE;
|
2157 |
|
|
`CASX: IsStore = TRUE;
|
2158 |
|
|
default: IsStore = FALSE;
|
2159 |
|
|
endcase
|
2160 |
|
|
`SB: IsStore = TRUE;
|
2161 |
|
|
`SC: IsStore = TRUE;
|
2162 |
|
|
`SH: IsStore = TRUE;
|
2163 |
|
|
`SW: IsStore = TRUE;
|
2164 |
|
|
`SWC: IsStore = TRUE;
|
2165 |
|
|
`SV: IsStore = TRUE;
|
2166 |
|
|
`CAS: IsStore = TRUE;
|
2167 |
|
|
`AMO: IsStore = TRUE;
|
2168 |
|
|
default: IsStore = FALSE;
|
2169 |
|
|
endcase
|
2170 |
|
|
endfunction
|
2171 |
|
|
|
2172 |
|
|
function IsSWC;
|
2173 |
|
|
input [31:0] isn;
|
2174 |
|
|
case(isn[`INSTRUCTION_OP])
|
2175 |
|
|
`RR:
|
2176 |
|
|
case(isn[`INSTRUCTION_S2])
|
2177 |
|
|
`SWCX: IsSWC = TRUE;
|
2178 |
|
|
default: IsSWC = FALSE;
|
2179 |
|
|
endcase
|
2180 |
|
|
`SWC: IsSWC = TRUE;
|
2181 |
|
|
default: IsSWC = FALSE;
|
2182 |
|
|
endcase
|
2183 |
|
|
endfunction
|
2184 |
|
|
|
2185 |
|
|
// Aquire / release bits are only available on indexed SWC / LWR
|
2186 |
|
|
function IsSWCX;
|
2187 |
|
|
input [31:0] isn;
|
2188 |
|
|
case(isn[`INSTRUCTION_OP])
|
2189 |
|
|
`RR:
|
2190 |
|
|
case(isn[`INSTRUCTION_S2])
|
2191 |
|
|
`SWCX: IsSWCX = TRUE;
|
2192 |
|
|
default: IsSWCX = FALSE;
|
2193 |
|
|
endcase
|
2194 |
|
|
default: IsSWCX = FALSE;
|
2195 |
|
|
endcase
|
2196 |
|
|
endfunction
|
2197 |
|
|
|
2198 |
|
|
function IsLWR;
|
2199 |
|
|
input [31:0] isn;
|
2200 |
|
|
case(isn[`INSTRUCTION_OP])
|
2201 |
|
|
`RR:
|
2202 |
|
|
case(isn[`INSTRUCTION_S2])
|
2203 |
|
|
`LWRX: IsLWR = TRUE;
|
2204 |
|
|
default: IsLWR = FALSE;
|
2205 |
|
|
endcase
|
2206 |
|
|
`LWR: IsLWR = TRUE;
|
2207 |
|
|
default: IsLWR = FALSE;
|
2208 |
|
|
endcase
|
2209 |
|
|
endfunction
|
2210 |
|
|
|
2211 |
|
|
function IsLWRX;
|
2212 |
|
|
input [31:0] isn;
|
2213 |
|
|
case(isn[`INSTRUCTION_OP])
|
2214 |
|
|
`RR:
|
2215 |
|
|
case(isn[`INSTRUCTION_S2])
|
2216 |
|
|
`LWRX: IsLWRX = TRUE;
|
2217 |
|
|
default: IsLWRX = FALSE;
|
2218 |
|
|
endcase
|
2219 |
|
|
default: IsLWRX = FALSE;
|
2220 |
|
|
endcase
|
2221 |
|
|
endfunction
|
2222 |
|
|
|
2223 |
|
|
function IsCAS;
|
2224 |
|
|
input [31:0] isn;
|
2225 |
|
|
case(isn[`INSTRUCTION_OP])
|
2226 |
|
|
`RR:
|
2227 |
|
|
case(isn[`INSTRUCTION_S2])
|
2228 |
|
|
`CASX: IsCAS = TRUE;
|
2229 |
|
|
default: IsCAS = FALSE;
|
2230 |
|
|
endcase
|
2231 |
|
|
`CAS: IsCAS = TRUE;
|
2232 |
|
|
default: IsCAS = FALSE;
|
2233 |
|
|
endcase
|
2234 |
|
|
endfunction
|
2235 |
|
|
|
2236 |
|
|
function IsAMO;
|
2237 |
|
|
input [31:0] isn;
|
2238 |
|
|
case(isn[`INSTRUCTION_OP])
|
2239 |
|
|
`AMO: IsAMO = TRUE;
|
2240 |
|
|
default: IsAMO = FALSE;
|
2241 |
|
|
endcase
|
2242 |
|
|
endfunction
|
2243 |
|
|
|
2244 |
|
|
// Really IsPredictableBranch
|
2245 |
|
|
// Does not include BccR's
|
2246 |
|
|
function IsBranch;
|
2247 |
|
|
input [31:0] isn;
|
2248 |
|
|
casez(isn[`INSTRUCTION_OP])
|
2249 |
|
|
`Bcc: IsBranch = TRUE;
|
2250 |
|
|
`BccR: IsBranch = TRUE;
|
2251 |
|
|
`BBc: IsBranch = TRUE;
|
2252 |
|
|
`BEQI: IsBranch = TRUE;
|
2253 |
|
|
`CHK: IsBranch = TRUE;
|
2254 |
|
|
default: IsBranch = FALSE;
|
2255 |
|
|
endcase
|
2256 |
|
|
endfunction
|
2257 |
|
|
|
2258 |
|
|
function IsWait;
|
2259 |
|
|
input [31:0] isn;
|
2260 |
|
|
IsWait = isn[`INSTRUCTION_OP]==`RR && isn[`INSTRUCTION_S2]==`WAIT;
|
2261 |
|
|
endfunction
|
2262 |
|
|
|
2263 |
|
|
function IsBrk;
|
2264 |
|
|
input [31:0] isn;
|
2265 |
|
|
IsBrk = isn[`INSTRUCTION_OP]==`BRK;
|
2266 |
|
|
endfunction
|
2267 |
|
|
|
2268 |
|
|
function IsRTI;
|
2269 |
|
|
input [31:0] isn;
|
2270 |
|
|
IsRTI = isn[`INSTRUCTION_OP]==`RR && isn[`INSTRUCTION_S2]==`RTI;
|
2271 |
|
|
endfunction
|
2272 |
|
|
|
2273 |
|
|
function IsJAL;
|
2274 |
|
|
input [31:0] isn;
|
2275 |
|
|
IsJAL = isn[`INSTRUCTION_OP]==`JAL;
|
2276 |
|
|
endfunction
|
2277 |
|
|
|
2278 |
|
|
function IsCall;
|
2279 |
|
|
input [31:0] isn;
|
2280 |
|
|
IsCall = isn[`INSTRUCTION_OP]==`CALL;
|
2281 |
|
|
endfunction
|
2282 |
|
|
|
2283 |
|
|
function IsJmp;
|
2284 |
|
|
input [31:0] isn;
|
2285 |
|
|
IsJmp = isn[`INSTRUCTION_OP]==`JMP;
|
2286 |
|
|
endfunction
|
2287 |
|
|
|
2288 |
|
|
function IsRet;
|
2289 |
|
|
input [31:0] isn;
|
2290 |
|
|
IsRet = isn[`INSTRUCTION_OP]==`RET;
|
2291 |
|
|
endfunction
|
2292 |
|
|
|
2293 |
|
|
function IsFlowCtrl;
|
2294 |
|
|
input [31:0] isn;
|
2295 |
|
|
casez(isn[`INSTRUCTION_OP])
|
2296 |
|
|
`BRK: IsFlowCtrl = TRUE;
|
2297 |
|
|
`RR: case(isn[`INSTRUCTION_S2])
|
2298 |
|
|
`RTI: IsFlowCtrl = TRUE;
|
2299 |
|
|
default: IsFlowCtrl = FALSE;
|
2300 |
|
|
endcase
|
2301 |
|
|
`Bcc: IsFlowCtrl = TRUE;
|
2302 |
|
|
`BccR: IsFlowCtrl = TRUE;
|
2303 |
|
|
`BBc: IsFlowCtrl = TRUE;
|
2304 |
|
|
`BEQI: IsFlowCtrl = TRUE;
|
2305 |
|
|
`CHK: IsFlowCtrl = TRUE;
|
2306 |
|
|
`JAL: IsFlowCtrl = TRUE;
|
2307 |
|
|
`JMP: IsFlowCtrl = TRUE;
|
2308 |
|
|
`CALL: IsFlowCtrl = TRUE;
|
2309 |
|
|
`RET: IsFlowCtrl = TRUE;
|
2310 |
|
|
default: IsFlowCtrl = FALSE;
|
2311 |
|
|
endcase
|
2312 |
|
|
endfunction
|
2313 |
|
|
|
2314 |
|
|
// fnCanException
|
2315 |
|
|
//
|
2316 |
|
|
// Used by memory issue logic.
|
2317 |
|
|
// Returns TRUE if the instruction can cause an exception.
|
2318 |
|
|
// In debug mode any instruction could potentially cause a breakpoint exception.
|
2319 |
|
|
// Rather than check all the addresses for potential debug exceptions it's
|
2320 |
|
|
// simpler to just have it so that all instructions could exception. This will
|
2321 |
|
|
// slow processing down somewhat as stores will only be done at the head of the
|
2322 |
|
|
// instruction queue, but it's debug mode so we probably don't care.
|
2323 |
|
|
//
|
2324 |
|
|
function fnCanException;
|
2325 |
|
|
input [31:0] isn;
|
2326 |
|
|
// ToDo add debug_on as input
|
2327 |
|
|
`ifdef SUPPORT_DBG
|
2328 |
|
|
if (debug_on)
|
2329 |
|
|
fnCanException = `TRUE;
|
2330 |
|
|
else
|
2331 |
|
|
`endif
|
2332 |
|
|
case(isn[`INSTRUCTION_OP])
|
2333 |
|
|
`FLOAT:
|
2334 |
|
|
case(isn[`INSTRUCTION_S2])
|
2335 |
|
|
`FDIV,`FMUL,`FADD,`FSUB,`FTX:
|
2336 |
|
|
fnCanException = `TRUE;
|
2337 |
|
|
default: fnCanException = `FALSE;
|
2338 |
|
|
endcase
|
2339 |
|
|
`ADDI,`DIVI,`MODI,`MULI:
|
2340 |
|
|
fnCanException = `TRUE;
|
2341 |
|
|
`RR:
|
2342 |
|
|
case(isn[`INSTRUCTION_S2])
|
2343 |
|
|
`ADD,`SUB,`MUL,`DIVMOD,`MULSU,`DIVMODSU: fnCanException = TRUE;
|
2344 |
|
|
`RTI: fnCanException = TRUE;
|
2345 |
|
|
default: fnCanException = FALSE;
|
2346 |
|
|
endcase
|
2347 |
|
|
default:
|
2348 |
|
|
fnCanException = IsMem(isn);
|
2349 |
|
|
endcase
|
2350 |
|
|
endfunction
|
2351 |
|
|
|
2352 |
|
|
|
2353 |
|
|
function IsCache;
|
2354 |
|
|
input [31:0] isn;
|
2355 |
|
|
case(isn[`INSTRUCTION_OP])
|
2356 |
|
|
`RR:
|
2357 |
|
|
case(isn[`INSTRUCTION_S2])
|
2358 |
|
|
`CACHEX: IsCache = TRUE;
|
2359 |
|
|
default: IsCache = FALSE;
|
2360 |
|
|
endcase
|
2361 |
|
|
`CACHE: IsCache = TRUE;
|
2362 |
|
|
default: IsCache = FALSE;
|
2363 |
|
|
endcase
|
2364 |
|
|
endfunction
|
2365 |
|
|
|
2366 |
|
|
function [4:0] CacheCmd;
|
2367 |
|
|
input [31:0] isn;
|
2368 |
|
|
case(isn[`INSTRUCTION_OP])
|
2369 |
|
|
`RR:
|
2370 |
|
|
case(isn[`INSTRUCTION_S2])
|
2371 |
|
|
`CACHEX: CacheCmd = isn[20:16];
|
2372 |
|
|
default: CacheCmd = 5'd0;
|
2373 |
|
|
endcase
|
2374 |
|
|
`CACHE: CacheCmd = isn[15:11];
|
2375 |
|
|
default: CacheCmd = 5'd0;
|
2376 |
|
|
endcase
|
2377 |
|
|
endfunction
|
2378 |
|
|
|
2379 |
|
|
function IsSync;
|
2380 |
|
|
input [31:0] isn;
|
2381 |
|
|
IsSync = (isn[`INSTRUCTION_OP]==`RR && isn[`INSTRUCTION_S2]==`R1 && isn[25:21]==`SYNC);
|
2382 |
|
|
endfunction
|
2383 |
|
|
|
2384 |
|
|
function IsFSync;
|
2385 |
|
|
input [31:0] isn;
|
2386 |
|
|
IsFSync = (isn[`INSTRUCTION_OP]==`FLOAT && isn[`INSTRUCTION_S2]==`FSYNC);
|
2387 |
|
|
endfunction
|
2388 |
|
|
|
2389 |
|
|
function IsMemdb;
|
2390 |
|
|
input [31:0] isn;
|
2391 |
|
|
IsMemdb = (isn[`INSTRUCTION_OP]==`RR && isn[`INSTRUCTION_S2]==`R1 && isn[25:21]==`MEMDB);
|
2392 |
|
|
endfunction
|
2393 |
|
|
|
2394 |
|
|
function IsMemsb;
|
2395 |
|
|
input [31:0] isn;
|
2396 |
|
|
IsMemsb = (isn[`INSTRUCTION_OP]==`RR && isn[`INSTRUCTION_S2]==`R1 && isn[25:21]==`MEMSB);
|
2397 |
|
|
endfunction
|
2398 |
|
|
|
2399 |
|
|
function IsSEI;
|
2400 |
|
|
input [31:0] isn;
|
2401 |
|
|
IsSEI = (isn[`INSTRUCTION_OP]==`RR && isn[`INSTRUCTION_S2]==`SEI);
|
2402 |
|
|
endfunction
|
2403 |
|
|
|
2404 |
|
|
function IsLV;
|
2405 |
|
|
input [31:0] isn;
|
2406 |
|
|
case(isn[`INSTRUCTION_OP])
|
2407 |
|
|
`RR:
|
2408 |
|
|
case(isn[`INSTRUCTION_S2])
|
2409 |
|
|
`LVX: IsLV = TRUE;
|
2410 |
|
|
default: IsLV = FALSE;
|
2411 |
|
|
endcase
|
2412 |
|
|
`LV: IsLV = TRUE;
|
2413 |
|
|
default: IsLV = FALSE;
|
2414 |
|
|
endcase
|
2415 |
|
|
endfunction
|
2416 |
|
|
|
2417 |
|
|
function IsRFW;
|
2418 |
|
|
input [31:0] isn;
|
2419 |
|
|
input [5:0] vqei;
|
2420 |
|
|
input [5:0] vli;
|
2421 |
|
|
input thrd;
|
2422 |
|
|
if (fnRt(isn,vqei,vli,thrd)==12'd0)
|
2423 |
|
|
IsRFW = FALSE;
|
2424 |
|
|
else
|
2425 |
|
|
casez(isn[`INSTRUCTION_OP])
|
2426 |
|
|
`VECTOR:
|
2427 |
|
|
IsRFW = TRUE;
|
2428 |
|
|
`RR:
|
2429 |
|
|
case(isn[`INSTRUCTION_S2])
|
2430 |
|
|
`R1: IsRFW = TRUE;
|
2431 |
|
|
`ADD: IsRFW = TRUE;
|
2432 |
|
|
`SUB: IsRFW = TRUE;
|
2433 |
|
|
`CMP: IsRFW = TRUE;
|
2434 |
|
|
`CMPU: IsRFW = TRUE;
|
2435 |
|
|
`AND: IsRFW = TRUE;
|
2436 |
|
|
`OR: IsRFW = TRUE;
|
2437 |
|
|
`XOR: IsRFW = TRUE;
|
2438 |
|
|
`MULU: IsRFW = TRUE;
|
2439 |
|
|
`MULSU: IsRFW = TRUE;
|
2440 |
|
|
`MUL: IsRFW = TRUE;
|
2441 |
|
|
`DIVMODU: IsRFW = TRUE;
|
2442 |
|
|
`DIVMODSU: IsRFW = TRUE;
|
2443 |
|
|
`DIVMOD:IsRFW = TRUE;
|
2444 |
|
|
`LBX: IsRFW = TRUE;
|
2445 |
|
|
`LBOX: IsRFW = TRUE;
|
2446 |
|
|
`LBUX: IsRFW = TRUE;
|
2447 |
|
|
`LCX: IsRFW = TRUE;
|
2448 |
|
|
`LCOX: IsRFW = TRUE;
|
2449 |
|
|
`LCUX: IsRFW = TRUE;
|
2450 |
|
|
`LHX: IsRFW = TRUE;
|
2451 |
|
|
`LHOX: IsRFW = TRUE;
|
2452 |
|
|
`LHUX: IsRFW = TRUE;
|
2453 |
|
|
`LWX: IsRFW = TRUE;
|
2454 |
|
|
`LWRX: IsRFW = TRUE;
|
2455 |
|
|
`LVX: IsRFW = TRUE;
|
2456 |
|
|
`LVx: IsRFW = TRUE;
|
2457 |
|
|
`CASX: IsRFW = TRUE;
|
2458 |
|
|
`MOV: IsRFW = TRUE;
|
2459 |
|
|
`VMOV: IsRFW = TRUE;
|
2460 |
|
|
`SHIFT,`SHIFTH,`SHIFTC,`SHIFTB:
|
2461 |
|
|
IsRFW = TRUE;
|
2462 |
|
|
`MIN,`MAX: IsRFW = TRUE;
|
2463 |
|
|
default: IsRFW = FALSE;
|
2464 |
|
|
endcase
|
2465 |
|
|
`BBc:
|
2466 |
|
|
case(isn[19:17])
|
2467 |
|
|
`DBNZ: IsRFW = TRUE;
|
2468 |
|
|
default: IsRFW = FALSE;
|
2469 |
|
|
endcase
|
2470 |
|
|
`BITFIELD: IsRFW = TRUE;
|
2471 |
|
|
`ADDI: IsRFW = TRUE;
|
2472 |
|
|
`CMPI: IsRFW = TRUE;
|
2473 |
|
|
`CMPUI: IsRFW = TRUE;
|
2474 |
|
|
`ANDI: IsRFW = TRUE;
|
2475 |
|
|
`ORI: IsRFW = TRUE;
|
2476 |
|
|
`XORI: IsRFW = TRUE;
|
2477 |
|
|
`MULUI: IsRFW = TRUE;
|
2478 |
|
|
`MULSUI: IsRFW = TRUE;
|
2479 |
|
|
`MULI: IsRFW = TRUE;
|
2480 |
|
|
`DIVUI: IsRFW = TRUE;
|
2481 |
|
|
`DIVSUI: IsRFW = TRUE;
|
2482 |
|
|
`DIVI: IsRFW = TRUE;
|
2483 |
|
|
`MODUI: IsRFW = TRUE;
|
2484 |
|
|
`MODSUI: IsRFW = TRUE;
|
2485 |
|
|
`MODI: IsRFW = TRUE;
|
2486 |
|
|
`QOPI: IsRFW = TRUE;
|
2487 |
|
|
`JAL: IsRFW = TRUE;
|
2488 |
|
|
`CALL: IsRFW = TRUE;
|
2489 |
|
|
`RET: IsRFW = TRUE;
|
2490 |
|
|
`LB: IsRFW = TRUE;
|
2491 |
|
|
`LBO: IsRFW = TRUE;
|
2492 |
|
|
`LBU: IsRFW = TRUE;
|
2493 |
|
|
`LC: IsRFW = TRUE;
|
2494 |
|
|
`LCO: IsRFW = TRUE;
|
2495 |
|
|
`LCU: IsRFW = TRUE;
|
2496 |
|
|
`LH: IsRFW = TRUE;
|
2497 |
|
|
`LHO: IsRFW = TRUE;
|
2498 |
|
|
`LHU: IsRFW = TRUE;
|
2499 |
|
|
`LW: IsRFW = TRUE;
|
2500 |
|
|
`LWR: IsRFW = TRUE;
|
2501 |
|
|
`LV: IsRFW = TRUE;
|
2502 |
|
|
`LVx: IsRFW = TRUE;
|
2503 |
|
|
`CAS: IsRFW = TRUE;
|
2504 |
|
|
`AMO: IsRFW = TRUE;
|
2505 |
|
|
`CSRRW: IsRFW = TRUE;
|
2506 |
|
|
default: IsRFW = FALSE;
|
2507 |
|
|
endcase
|
2508 |
|
|
endfunction
|
2509 |
|
|
|
2510 |
|
|
function IsShifti;
|
2511 |
|
|
input [31:0] isn;
|
2512 |
|
|
case(isn[`INSTRUCTION_OP])
|
2513 |
|
|
`RR:
|
2514 |
|
|
case(isn[`INSTRUCTION_S2])
|
2515 |
|
|
`SHIFT,`SHIFTH,`SHIFTC,`SHIFTB:
|
2516 |
|
|
IsShifti = isn[25];
|
2517 |
|
|
default: IsShifti = FALSE;
|
2518 |
|
|
endcase
|
2519 |
|
|
default: IsShifti = FALSE;
|
2520 |
|
|
endcase
|
2521 |
|
|
endfunction
|
2522 |
|
|
|
2523 |
|
|
function IsMul;
|
2524 |
|
|
input [31:0] isn;
|
2525 |
|
|
case(isn[`INSTRUCTION_OP])
|
2526 |
|
|
`RR:
|
2527 |
|
|
case(isn[`INSTRUCTION_S2])
|
2528 |
|
|
`MULU,`MULSU,`MUL: IsMul = TRUE;
|
2529 |
|
|
default: IsMul = FALSE;
|
2530 |
|
|
endcase
|
2531 |
|
|
`MULUI,`MULSUI,`MULI: IsMul = TRUE;
|
2532 |
|
|
default: IsMul = FALSE;
|
2533 |
|
|
endcase
|
2534 |
|
|
endfunction
|
2535 |
|
|
|
2536 |
|
|
function IsDivmod;
|
2537 |
|
|
input [31:0] isn;
|
2538 |
|
|
case(isn[`INSTRUCTION_OP])
|
2539 |
|
|
`RR:
|
2540 |
|
|
case(isn[`INSTRUCTION_S2])
|
2541 |
|
|
`DIVMODU,`DIVMODSU,`DIVMOD: IsDivmod = TRUE;
|
2542 |
|
|
default: IsDivmod = FALSE;
|
2543 |
|
|
endcase
|
2544 |
|
|
`DIVUI,`DIVSUI,`DIVI,`MODUI,`MODSUI,`MODI: IsDivmod = TRUE;
|
2545 |
|
|
default: IsDivmod = FALSE;
|
2546 |
|
|
endcase
|
2547 |
|
|
endfunction
|
2548 |
|
|
|
2549 |
|
|
function IsAlu0Only;
|
2550 |
|
|
input [31:0] isn;
|
2551 |
|
|
case(isn[`INSTRUCTION_OP])
|
2552 |
|
|
`RR:
|
2553 |
|
|
case(isn[`INSTRUCTION_S2])
|
2554 |
|
|
`R1: IsAlu0Only = TRUE;
|
2555 |
|
|
`SHIFT: IsAlu0Only = TRUE;
|
2556 |
|
|
`LBX,`LBOX,`LBUX,`LCX,`LCOX,`LCUX,`LHX,`LHOX,`LHUX,`LWX,`LWRX:
|
2557 |
|
|
IsAlu0Only = TRUE;
|
2558 |
|
|
`SBX,`SCX,`SHX,`SWX,`SWCX: IsAlu0Only = TRUE;
|
2559 |
|
|
`LVX,`SVX,`LVx: IsAlu0Only = TRUE;
|
2560 |
|
|
`MULU,`MULSU,`MUL,
|
2561 |
|
|
`DIVMODU,`DIVMODSU,`DIVMOD: IsAlu0Only = TRUE;
|
2562 |
|
|
`MIN,`MAX: IsAlu0Only = TRUE;
|
2563 |
|
|
default: IsAlu0Only = FALSE;
|
2564 |
|
|
endcase
|
2565 |
|
|
`VECTOR:
|
2566 |
|
|
case(isn[`INSTRUCTION_S2])
|
2567 |
|
|
`VSHL,`VSHR,`VASR: IsAlu0Only = TRUE;
|
2568 |
|
|
default: IsAlu0Only = FALSE;
|
2569 |
|
|
endcase
|
2570 |
|
|
`BITFIELD: IsAlu0Only = TRUE;
|
2571 |
|
|
`MULUI,`MULSUI,`MULI,
|
2572 |
|
|
`DIVUI,`DIVSUI,`DIVI,
|
2573 |
|
|
`MODUI,`MODSUI,`MODI: IsAlu0Only = TRUE;
|
2574 |
|
|
`CSRRW: IsAlu0Only = TRUE;
|
2575 |
|
|
default: IsAlu0Only = FALSE;
|
2576 |
|
|
endcase
|
2577 |
|
|
endfunction
|
2578 |
|
|
|
2579 |
|
|
function [7:0] fnSelect;
|
2580 |
|
|
input [31:0] ins;
|
2581 |
|
|
input [31:0] adr;
|
2582 |
|
|
begin
|
2583 |
|
|
case(ins[`INSTRUCTION_OP])
|
2584 |
|
|
`RR:
|
2585 |
|
|
case(ins[`INSTRUCTION_S2])
|
2586 |
|
|
`LBX,`LBOX,`LBUX,`SBX:
|
2587 |
|
|
case(adr[2:0])
|
2588 |
|
|
3'd0: fnSelect = 8'h01;
|
2589 |
|
|
3'd1: fnSelect = 8'h02;
|
2590 |
|
|
3'd2: fnSelect = 8'h04;
|
2591 |
|
|
3'd3: fnSelect = 8'h08;
|
2592 |
|
|
3'd4: fnSelect = 8'h10;
|
2593 |
|
|
3'd5: fnSelect = 8'h20;
|
2594 |
|
|
3'd6: fnSelect = 8'h40;
|
2595 |
|
|
3'd7: fnSelect = 8'h80;
|
2596 |
|
|
endcase
|
2597 |
|
|
`LCX,`LCOX,`LCUX,`SCX:
|
2598 |
|
|
case(adr[2:1])
|
2599 |
|
|
2'd0: fnSelect = 8'h03;
|
2600 |
|
|
2'd1: fnSelect = 8'hC0;
|
2601 |
|
|
2'd2: fnSelect = 8'h30;
|
2602 |
|
|
2'd3: fnSelect = 8'hC0;
|
2603 |
|
|
endcase
|
2604 |
|
|
`LHX,`LHOX,`LHUX,`SHX:
|
2605 |
|
|
case(adr[2])
|
2606 |
|
|
1'b0: fnSelect = 8'h0F;
|
2607 |
|
|
1'b1: fnSelect = 8'hF0;
|
2608 |
|
|
endcase
|
2609 |
|
|
`LWX,`SWX,`LWRX,`SWCX,`LVX,`SVX,`CASX:
|
2610 |
|
|
fnSelect = 8'hFF;
|
2611 |
|
|
`LVx:
|
2612 |
|
|
case(ins[25:23])
|
2613 |
|
|
`LVB,`LVBU:
|
2614 |
|
|
case(adr[2:0])
|
2615 |
|
|
3'd0: fnSelect = 8'h01;
|
2616 |
|
|
3'd1: fnSelect = 8'h02;
|
2617 |
|
|
3'd2: fnSelect = 8'h04;
|
2618 |
|
|
3'd3: fnSelect = 8'h08;
|
2619 |
|
|
3'd4: fnSelect = 8'h10;
|
2620 |
|
|
3'd5: fnSelect = 8'h20;
|
2621 |
|
|
3'd6: fnSelect = 8'h40;
|
2622 |
|
|
3'd7: fnSelect = 8'h80;
|
2623 |
|
|
endcase
|
2624 |
|
|
`LVC,`LVCU:
|
2625 |
|
|
case(adr[2:1])
|
2626 |
|
|
2'd0: fnSelect = 8'h03;
|
2627 |
|
|
2'd1: fnSelect = 8'hC0;
|
2628 |
|
|
2'd2: fnSelect = 8'h30;
|
2629 |
|
|
2'd3: fnSelect = 8'hC0;
|
2630 |
|
|
endcase
|
2631 |
|
|
`LVH,`LVHU:
|
2632 |
|
|
case(adr[2])
|
2633 |
|
|
1'b0: fnSelect = 8'h0F;
|
2634 |
|
|
1'b1: fnSelect = 8'hF0;
|
2635 |
|
|
endcase
|
2636 |
|
|
`LVW:
|
2637 |
|
|
fnSelect = 8'hFF;
|
2638 |
|
|
endcase
|
2639 |
|
|
default: fnSelect = 8'h00;
|
2640 |
|
|
endcase
|
2641 |
|
|
`LB,`LBO,`LBU,`SB:
|
2642 |
|
|
case(adr[2:0])
|
2643 |
|
|
3'd0: fnSelect = 8'h01;
|
2644 |
|
|
3'd1: fnSelect = 8'h02;
|
2645 |
|
|
3'd2: fnSelect = 8'h04;
|
2646 |
|
|
3'd3: fnSelect = 8'h08;
|
2647 |
|
|
3'd4: fnSelect = 8'h10;
|
2648 |
|
|
3'd5: fnSelect = 8'h20;
|
2649 |
|
|
3'd6: fnSelect = 8'h40;
|
2650 |
|
|
3'd7: fnSelect = 8'h80;
|
2651 |
|
|
endcase
|
2652 |
|
|
`LC,`LCO,`LCU,`SC:
|
2653 |
|
|
case(adr[2:1])
|
2654 |
|
|
2'd0: fnSelect = 8'h03;
|
2655 |
|
|
2'd1: fnSelect = 8'hC0;
|
2656 |
|
|
2'd2: fnSelect = 8'h30;
|
2657 |
|
|
2'd3: fnSelect = 8'hC0;
|
2658 |
|
|
endcase
|
2659 |
|
|
`LH,`LHO,`LHU,`SH:
|
2660 |
|
|
case(adr[2])
|
2661 |
|
|
1'b0: fnSelect = 8'h0F;
|
2662 |
|
|
1'b1: fnSelect = 8'hF0;
|
2663 |
|
|
endcase
|
2664 |
|
|
`LW,`SW,`LWR,`SWC,`CAS: fnSelect = 8'hFF;
|
2665 |
|
|
`LV,`SV: fnSelect = 8'hFF;
|
2666 |
|
|
`AMO:
|
2667 |
|
|
case(ins[23:21])
|
2668 |
|
|
3'd0: fnSelect = 8'h01 << adr[2:0];
|
2669 |
|
|
3'd1: fnSelect = 8'h03 << {adr[2:1],1'b0};
|
2670 |
|
|
3'd2: fnSelect = 8'h0F << {adr[2],2'b00};
|
2671 |
|
|
3'd3: fnSelect = 8'hFF;
|
2672 |
|
|
default: fnSelect = 8'hFF;
|
2673 |
|
|
endcase
|
2674 |
|
|
`LVx:
|
2675 |
|
|
case(ins[30:28])
|
2676 |
|
|
`LVB,`LVBU:
|
2677 |
|
|
case(adr[2:0])
|
2678 |
|
|
3'd0: fnSelect = 8'h01;
|
2679 |
|
|
3'd1: fnSelect = 8'h02;
|
2680 |
|
|
3'd2: fnSelect = 8'h04;
|
2681 |
|
|
3'd3: fnSelect = 8'h08;
|
2682 |
|
|
3'd4: fnSelect = 8'h10;
|
2683 |
|
|
3'd5: fnSelect = 8'h20;
|
2684 |
|
|
3'd6: fnSelect = 8'h40;
|
2685 |
|
|
3'd7: fnSelect = 8'h80;
|
2686 |
|
|
endcase
|
2687 |
|
|
`LVC,`LVCU:
|
2688 |
|
|
case(adr[2:1])
|
2689 |
|
|
2'd0: fnSelect = 8'h03;
|
2690 |
|
|
2'd1: fnSelect = 8'hC0;
|
2691 |
|
|
2'd2: fnSelect = 8'h30;
|
2692 |
|
|
2'd3: fnSelect = 8'hC0;
|
2693 |
|
|
endcase
|
2694 |
|
|
`LVH,`LVHU:
|
2695 |
|
|
case(adr[2])
|
2696 |
|
|
1'b0: fnSelect = 8'h0F;
|
2697 |
|
|
1'b1: fnSelect = 8'hF0;
|
2698 |
|
|
endcase
|
2699 |
|
|
`LVW:
|
2700 |
|
|
fnSelect = 8'hFF;
|
2701 |
|
|
endcase
|
2702 |
|
|
default: fnSelect = 8'h00;
|
2703 |
|
|
endcase
|
2704 |
|
|
end
|
2705 |
|
|
endfunction
|
2706 |
|
|
|
2707 |
|
|
function [63:0] fnDati;
|
2708 |
|
|
input [31:0] ins;
|
2709 |
|
|
input [31:0] adr;
|
2710 |
|
|
input [63:0] dat;
|
2711 |
|
|
case(ins[`INSTRUCTION_OP])
|
2712 |
|
|
`RR:
|
2713 |
|
|
case(ins[`INSTRUCTION_S2])
|
2714 |
|
|
`LBX:
|
2715 |
|
|
case(adr[2:0])
|
2716 |
|
|
3'd0: fnDati = {{56{dat[7]}},dat[7:0]};
|
2717 |
|
|
3'd1: fnDati = {{56{dat[15]}},dat[15:8]};
|
2718 |
|
|
3'd2: fnDati = {{56{dat[23]}},dat[23:16]};
|
2719 |
|
|
3'd3: fnDati = {{56{dat[31]}},dat[31:24]};
|
2720 |
|
|
3'd4: fnDati = {{56{dat[39]}},dat[39:32]};
|
2721 |
|
|
3'd5: fnDati = {{56{dat[47]}},dat[47:40]};
|
2722 |
|
|
3'd6: fnDati = {{56{dat[55]}},dat[55:48]};
|
2723 |
|
|
3'd7: fnDati = {{56{dat[63]}},dat[63:56]};
|
2724 |
|
|
endcase
|
2725 |
|
|
`LBOX,`LBUX:
|
2726 |
|
|
case(adr[2:0])
|
2727 |
|
|
3'd0: fnDati = {{56{1'b0}},dat[7:0]};
|
2728 |
|
|
3'd1: fnDati = {{56{1'b0}},dat[15:8]};
|
2729 |
|
|
3'd2: fnDati = {{56{1'b0}},dat[23:16]};
|
2730 |
|
|
3'd3: fnDati = {{56{1'b0}},dat[31:24]};
|
2731 |
|
|
3'd4: fnDati = {{56{1'b0}},dat[39:32]};
|
2732 |
|
|
3'd5: fnDati = {{56{1'b0}},dat[47:40]};
|
2733 |
|
|
3'd6: fnDati = {{56{1'b0}},dat[55:48]};
|
2734 |
|
|
3'd7: fnDati = {{56{2'b0}},dat[63:56]};
|
2735 |
|
|
endcase
|
2736 |
|
|
`LCX:
|
2737 |
|
|
case(adr[2:1])
|
2738 |
|
|
2'd0: fnDati = {{48{dat[15]}},dat[15:0]};
|
2739 |
|
|
2'd1: fnDati = {{48{dat[31]}},dat[31:16]};
|
2740 |
|
|
2'd2: fnDati = {{48{dat[47]}},dat[47:32]};
|
2741 |
|
|
2'd3: fnDati = {{48{dat[63]}},dat[63:48]};
|
2742 |
|
|
endcase
|
2743 |
|
|
`LCOX,`LCUX:
|
2744 |
|
|
case(adr[2:1])
|
2745 |
|
|
2'd0: fnDati = {{48{1'b0}},dat[15:0]};
|
2746 |
|
|
2'd1: fnDati = {{48{1'b0}},dat[31:16]};
|
2747 |
|
|
2'd2: fnDati = {{48{1'b0}},dat[47:32]};
|
2748 |
|
|
2'd3: fnDati = {{48{1'b0}},dat[63:48]};
|
2749 |
|
|
endcase
|
2750 |
|
|
`LHX:
|
2751 |
|
|
case(adr[2])
|
2752 |
|
|
1'b0: fnDati = {{32{dat[31]}},dat[31:0]};
|
2753 |
|
|
1'b1: fnDati = {{32{dat[63]}},dat[63:32]};
|
2754 |
|
|
endcase
|
2755 |
|
|
`LHOX,`LHUX:
|
2756 |
|
|
case(adr[2])
|
2757 |
|
|
1'b0: fnDati = {{32{1'b0}},dat[31:0]};
|
2758 |
|
|
1'b1: fnDati = {{32{1'b0}},dat[63:32]};
|
2759 |
|
|
endcase
|
2760 |
|
|
`LWX,`LWRX,`LVX,`CAS: fnDati = dat;
|
2761 |
|
|
`LVx:
|
2762 |
|
|
case(ins[25:23])
|
2763 |
|
|
`LVB:
|
2764 |
|
|
case(adr[2:0])
|
2765 |
|
|
3'd0: fnDati = {{56{dat[7]}},dat[7:0]};
|
2766 |
|
|
3'd1: fnDati = {{56{dat[15]}},dat[15:8]};
|
2767 |
|
|
3'd2: fnDati = {{56{dat[23]}},dat[23:16]};
|
2768 |
|
|
3'd3: fnDati = {{56{dat[31]}},dat[31:24]};
|
2769 |
|
|
3'd4: fnDati = {{56{dat[39]}},dat[39:32]};
|
2770 |
|
|
3'd5: fnDati = {{56{dat[47]}},dat[47:40]};
|
2771 |
|
|
3'd6: fnDati = {{56{dat[55]}},dat[55:48]};
|
2772 |
|
|
3'd7: fnDati = {{56{dat[63]}},dat[63:56]};
|
2773 |
|
|
endcase
|
2774 |
|
|
`LVBU:
|
2775 |
|
|
case(adr[2:0])
|
2776 |
|
|
3'd0: fnDati = {{56{1'b0}},dat[7:0]};
|
2777 |
|
|
3'd1: fnDati = {{56{1'b0}},dat[15:8]};
|
2778 |
|
|
3'd2: fnDati = {{56{1'b0}},dat[23:16]};
|
2779 |
|
|
3'd3: fnDati = {{56{1'b0}},dat[31:24]};
|
2780 |
|
|
3'd4: fnDati = {{56{1'b0}},dat[39:32]};
|
2781 |
|
|
3'd5: fnDati = {{56{1'b0}},dat[47:40]};
|
2782 |
|
|
3'd6: fnDati = {{56{1'b0}},dat[55:48]};
|
2783 |
|
|
3'd7: fnDati = {{56{2'b0}},dat[63:56]};
|
2784 |
|
|
endcase
|
2785 |
|
|
`LVC:
|
2786 |
|
|
case(adr[2:1])
|
2787 |
|
|
2'd0: fnDati = {{48{dat[15]}},dat[15:0]};
|
2788 |
|
|
2'd1: fnDati = {{48{dat[31]}},dat[31:16]};
|
2789 |
|
|
2'd2: fnDati = {{48{dat[47]}},dat[47:32]};
|
2790 |
|
|
2'd3: fnDati = {{48{dat[63]}},dat[63:48]};
|
2791 |
|
|
endcase
|
2792 |
|
|
`LVCU:
|
2793 |
|
|
case(adr[2:1])
|
2794 |
|
|
2'd0: fnDati = {{48{1'b0}},dat[15:0]};
|
2795 |
|
|
2'd1: fnDati = {{48{1'b0}},dat[31:16]};
|
2796 |
|
|
2'd2: fnDati = {{48{1'b0}},dat[47:32]};
|
2797 |
|
|
2'd3: fnDati = {{48{1'b0}},dat[63:48]};
|
2798 |
|
|
endcase
|
2799 |
|
|
`LVH:
|
2800 |
|
|
case(adr[2])
|
2801 |
|
|
1'b0: fnDati = {{32{dat[31]}},dat[31:0]};
|
2802 |
|
|
1'b1: fnDati = {{32{dat[63]}},dat[63:32]};
|
2803 |
|
|
endcase
|
2804 |
|
|
`LVHU:
|
2805 |
|
|
case(adr[2])
|
2806 |
|
|
1'b0: fnDati = {{32{1'b0}},dat[31:0]};
|
2807 |
|
|
1'b1: fnDati = {{32{1'b0}},dat[63:32]};
|
2808 |
|
|
endcase
|
2809 |
|
|
`LVW: fnDati = dat;
|
2810 |
|
|
endcase
|
2811 |
|
|
default: fnDati = dat;
|
2812 |
|
|
endcase
|
2813 |
|
|
`LB:
|
2814 |
|
|
case(adr[2:0])
|
2815 |
|
|
3'd0: fnDati = {{56{dat[7]}},dat[7:0]};
|
2816 |
|
|
3'd1: fnDati = {{56{dat[15]}},dat[15:8]};
|
2817 |
|
|
3'd2: fnDati = {{56{dat[23]}},dat[23:16]};
|
2818 |
|
|
3'd3: fnDati = {{56{dat[31]}},dat[31:24]};
|
2819 |
|
|
3'd4: fnDati = {{56{dat[39]}},dat[39:32]};
|
2820 |
|
|
3'd5: fnDati = {{56{dat[47]}},dat[47:40]};
|
2821 |
|
|
3'd6: fnDati = {{56{dat[55]}},dat[55:48]};
|
2822 |
|
|
3'd7: fnDati = {{56{dat[63]}},dat[63:56]};
|
2823 |
|
|
endcase
|
2824 |
|
|
`LBO,`LBU:
|
2825 |
|
|
case(adr[2:0])
|
2826 |
|
|
3'd0: fnDati = {{56{1'b0}},dat[7:0]};
|
2827 |
|
|
3'd1: fnDati = {{56{1'b0}},dat[15:8]};
|
2828 |
|
|
3'd2: fnDati = {{56{1'b0}},dat[23:16]};
|
2829 |
|
|
3'd3: fnDati = {{56{1'b0}},dat[31:24]};
|
2830 |
|
|
3'd4: fnDati = {{56{1'b0}},dat[39:32]};
|
2831 |
|
|
3'd5: fnDati = {{56{1'b0}},dat[47:40]};
|
2832 |
|
|
3'd6: fnDati = {{56{1'b0}},dat[55:48]};
|
2833 |
|
|
3'd7: fnDati = {{56{2'b0}},dat[63:56]};
|
2834 |
|
|
endcase
|
2835 |
|
|
`LC:
|
2836 |
|
|
case(adr[2:1])
|
2837 |
|
|
2'd0: fnDati = {{48{dat[15]}},dat[15:0]};
|
2838 |
|
|
2'd1: fnDati = {{48{dat[31]}},dat[31:16]};
|
2839 |
|
|
2'd2: fnDati = {{48{dat[47]}},dat[47:32]};
|
2840 |
|
|
2'd3: fnDati = {{48{dat[63]}},dat[63:48]};
|
2841 |
|
|
endcase
|
2842 |
|
|
`LCO,`LCU:
|
2843 |
|
|
case(adr[2:1])
|
2844 |
|
|
2'd0: fnDati = {{48{1'b0}},dat[15:0]};
|
2845 |
|
|
2'd1: fnDati = {{48{1'b0}},dat[31:16]};
|
2846 |
|
|
2'd2: fnDati = {{48{1'b0}},dat[47:32]};
|
2847 |
|
|
2'd3: fnDati = {{48{1'b0}},dat[63:48]};
|
2848 |
|
|
endcase
|
2849 |
|
|
`LH:
|
2850 |
|
|
case(adr[2])
|
2851 |
|
|
1'b0: fnDati = {{32{dat[31]}},dat[31:0]};
|
2852 |
|
|
1'b1: fnDati = {{32{dat[63]}},dat[63:32]};
|
2853 |
|
|
endcase
|
2854 |
|
|
`LHO,`LHU:
|
2855 |
|
|
case(adr[2])
|
2856 |
|
|
1'b0: fnDati = {{32{1'b0}},dat[31:0]};
|
2857 |
|
|
1'b1: fnDati = {{32{1'b0}},dat[63:32]};
|
2858 |
|
|
endcase
|
2859 |
|
|
`LW,`LWR,`LV,`CAS,`AMO: fnDati = dat;
|
2860 |
|
|
`LVx:
|
2861 |
|
|
case(ins[30:28])
|
2862 |
|
|
`LVB:
|
2863 |
|
|
case(adr[2:0])
|
2864 |
|
|
3'd0: fnDati = {{56{dat[7]}},dat[7:0]};
|
2865 |
|
|
3'd1: fnDati = {{56{dat[15]}},dat[15:8]};
|
2866 |
|
|
3'd2: fnDati = {{56{dat[23]}},dat[23:16]};
|
2867 |
|
|
3'd3: fnDati = {{56{dat[31]}},dat[31:24]};
|
2868 |
|
|
3'd4: fnDati = {{56{dat[39]}},dat[39:32]};
|
2869 |
|
|
3'd5: fnDati = {{56{dat[47]}},dat[47:40]};
|
2870 |
|
|
3'd6: fnDati = {{56{dat[55]}},dat[55:48]};
|
2871 |
|
|
3'd7: fnDati = {{56{dat[63]}},dat[63:56]};
|
2872 |
|
|
endcase
|
2873 |
|
|
`LVBU:
|
2874 |
|
|
case(adr[2:0])
|
2875 |
|
|
3'd0: fnDati = {{56{1'b0}},dat[7:0]};
|
2876 |
|
|
3'd1: fnDati = {{56{1'b0}},dat[15:8]};
|
2877 |
|
|
3'd2: fnDati = {{56{1'b0}},dat[23:16]};
|
2878 |
|
|
3'd3: fnDati = {{56{1'b0}},dat[31:24]};
|
2879 |
|
|
3'd4: fnDati = {{56{1'b0}},dat[39:32]};
|
2880 |
|
|
3'd5: fnDati = {{56{1'b0}},dat[47:40]};
|
2881 |
|
|
3'd6: fnDati = {{56{1'b0}},dat[55:48]};
|
2882 |
|
|
3'd7: fnDati = {{56{2'b0}},dat[63:56]};
|
2883 |
|
|
endcase
|
2884 |
|
|
`LVC:
|
2885 |
|
|
case(adr[2:1])
|
2886 |
|
|
2'd0: fnDati = {{48{dat[15]}},dat[15:0]};
|
2887 |
|
|
2'd1: fnDati = {{48{dat[31]}},dat[31:16]};
|
2888 |
|
|
2'd2: fnDati = {{48{dat[47]}},dat[47:32]};
|
2889 |
|
|
2'd3: fnDati = {{48{dat[63]}},dat[63:48]};
|
2890 |
|
|
endcase
|
2891 |
|
|
`LVCU:
|
2892 |
|
|
case(adr[2:1])
|
2893 |
|
|
2'd0: fnDati = {{48{1'b0}},dat[15:0]};
|
2894 |
|
|
2'd1: fnDati = {{48{1'b0}},dat[31:16]};
|
2895 |
|
|
2'd2: fnDati = {{48{1'b0}},dat[47:32]};
|
2896 |
|
|
2'd3: fnDati = {{48{1'b0}},dat[63:48]};
|
2897 |
|
|
endcase
|
2898 |
|
|
`LVH:
|
2899 |
|
|
case(adr[2])
|
2900 |
|
|
1'b0: fnDati = {{32{dat[31]}},dat[31:0]};
|
2901 |
|
|
1'b1: fnDati = {{32{dat[63]}},dat[63:32]};
|
2902 |
|
|
endcase
|
2903 |
|
|
`LVHU:
|
2904 |
|
|
case(adr[2])
|
2905 |
|
|
1'b0: fnDati = {{32{1'b0}},dat[31:0]};
|
2906 |
|
|
1'b1: fnDati = {{32{1'b0}},dat[63:32]};
|
2907 |
|
|
endcase
|
2908 |
|
|
`LVW: fnDati = dat;
|
2909 |
|
|
endcase
|
2910 |
|
|
default: fnDati = dat;
|
2911 |
|
|
endcase
|
2912 |
|
|
endfunction
|
2913 |
|
|
|
2914 |
|
|
function [63:0] fnDato;
|
2915 |
|
|
input [31:0] isn;
|
2916 |
|
|
input [63:0] dat;
|
2917 |
|
|
case(isn[`INSTRUCTION_OP])
|
2918 |
|
|
`RR:
|
2919 |
|
|
case(isn[`INSTRUCTION_S2])
|
2920 |
|
|
`SBX: fnDato = {8{dat[7:0]}};
|
2921 |
|
|
`SCX: fnDato = {4{dat[15:0]}};
|
2922 |
|
|
`SHX: fnDato = {2{dat[31:0]}};
|
2923 |
|
|
default: fnDato = dat;
|
2924 |
|
|
endcase
|
2925 |
|
|
`SB: fnDato = {8{dat[7:0]}};
|
2926 |
|
|
`SC: fnDato = {4{dat[15:0]}};
|
2927 |
|
|
`SH: fnDato = {2{dat[31:0]}};
|
2928 |
|
|
`AMO:
|
2929 |
|
|
case(isn[23:21])
|
2930 |
|
|
3'd0: fnDato = {8{dat[7:0]}};
|
2931 |
|
|
3'd1: fnDato = {4{dat[15:0]}};
|
2932 |
|
|
3'd2: fnDato = {2{dat[31:0]}};
|
2933 |
|
|
3'd3: fnDato = dat;
|
2934 |
|
|
default: fnDato = dat;
|
2935 |
|
|
endcase
|
2936 |
|
|
default: fnDato = dat;
|
2937 |
|
|
endcase
|
2938 |
|
|
endfunction
|
2939 |
|
|
|
2940 |
|
|
// Indicate if the ALU instruction is valid immediately (single cycle operation)
|
2941 |
|
|
function IsSingleCycle;
|
2942 |
|
|
input [31:0] isn;
|
2943 |
|
|
IsSingleCycle = TRUE;
|
2944 |
|
|
endfunction
|
2945 |
|
|
|
2946 |
|
|
`ifdef SUPPORT_SMT
|
2947 |
|
|
decoder8 iq0(.num({iqentry_tgt[0][8:7],iqentry_tgt[0][5:0]}), .out(iq0_out));
|
2948 |
|
|
decoder8 iq1(.num({iqentry_tgt[1][8:7],iqentry_tgt[1][5:0]}), .out(iq1_out));
|
2949 |
|
|
decoder8 iq2(.num({iqentry_tgt[2][8:7],iqentry_tgt[2][5:0]}), .out(iq2_out));
|
2950 |
|
|
decoder8 iq3(.num({iqentry_tgt[3][8:7],iqentry_tgt[3][5:0]}), .out(iq3_out));
|
2951 |
|
|
decoder8 iq4(.num({iqentry_tgt[4][8:7],iqentry_tgt[4][5:0]}), .out(iq4_out));
|
2952 |
|
|
decoder8 iq5(.num({iqentry_tgt[5][8:7],iqentry_tgt[5][5:0]}), .out(iq5_out));
|
2953 |
|
|
decoder8 iq6(.num({iqentry_tgt[6][8:7],iqentry_tgt[6][5:0]}), .out(iq6_out));
|
2954 |
|
|
decoder8 iq7(.num({iqentry_tgt[7][8:7],iqentry_tgt[7][5:0]}), .out(iq7_out));
|
2955 |
|
|
`else
|
2956 |
|
|
decoder7 iq0(.num({iqentry_tgt[0][7],iqentry_tgt[0][5:0]}), .out(iq0_out));
|
2957 |
|
|
decoder7 iq1(.num({iqentry_tgt[1][7],iqentry_tgt[1][5:0]}), .out(iq1_out));
|
2958 |
|
|
decoder7 iq2(.num({iqentry_tgt[2][7],iqentry_tgt[2][5:0]}), .out(iq2_out));
|
2959 |
|
|
decoder7 iq3(.num({iqentry_tgt[3][7],iqentry_tgt[3][5:0]}), .out(iq3_out));
|
2960 |
|
|
decoder7 iq4(.num({iqentry_tgt[4][7],iqentry_tgt[4][5:0]}), .out(iq4_out));
|
2961 |
|
|
decoder7 iq5(.num({iqentry_tgt[5][7],iqentry_tgt[5][5:0]}), .out(iq5_out));
|
2962 |
|
|
decoder7 iq6(.num({iqentry_tgt[6][7],iqentry_tgt[6][5:0]}), .out(iq6_out));
|
2963 |
|
|
decoder7 iq7(.num({iqentry_tgt[7][7],iqentry_tgt[7][5:0]}), .out(iq7_out));
|
2964 |
|
|
/*
|
2965 |
|
|
decoder6 iq0(.num({iqentry_tgt[0][5:0]}), .out(iq0_out));
|
2966 |
|
|
decoder6 iq1(.num({iqentry_tgt[1][5:0]}), .out(iq1_out));
|
2967 |
|
|
decoder6 iq2(.num({iqentry_tgt[2][5:0]}), .out(iq2_out));
|
2968 |
|
|
decoder6 iq3(.num({iqentry_tgt[3][5:0]}), .out(iq3_out));
|
2969 |
|
|
decoder6 iq4(.num({iqentry_tgt[4][5:0]}), .out(iq4_out));
|
2970 |
|
|
decoder6 iq5(.num({iqentry_tgt[5][5:0]}), .out(iq5_out));
|
2971 |
|
|
decoder6 iq6(.num({iqentry_tgt[6][5:0]}), .out(iq6_out));
|
2972 |
|
|
decoder6 iq7(.num({iqentry_tgt[7][5:0]}), .out(iq7_out));*/
|
2973 |
|
|
`endif
|
2974 |
|
|
|
2975 |
|
|
initial begin: Init
|
2976 |
|
|
//
|
2977 |
|
|
//
|
2978 |
|
|
// set up panic messages
|
2979 |
|
|
message[ `PANIC_NONE ] = "NONE ";
|
2980 |
|
|
message[ `PANIC_FETCHBUFBEQ ] = "FETCHBUFBEQ ";
|
2981 |
|
|
message[ `PANIC_INVALIDISLOT ] = "INVALIDISLOT ";
|
2982 |
|
|
message[ `PANIC_IDENTICALDRAMS ] = "IDENTICALDRAMS ";
|
2983 |
|
|
message[ `PANIC_OVERRUN ] = "OVERRUN ";
|
2984 |
|
|
message[ `PANIC_HALTINSTRUCTION ] = "HALTINSTRUCTION ";
|
2985 |
|
|
message[ `PANIC_INVALIDMEMOP ] = "INVALIDMEMOP ";
|
2986 |
|
|
message[ `PANIC_INVALIDFBSTATE ] = "INVALIDFBSTATE ";
|
2987 |
|
|
message[ `PANIC_INVALIDIQSTATE ] = "INVALIDIQSTATE ";
|
2988 |
|
|
message[ `PANIC_BRANCHBACK ] = "BRANCHBACK ";
|
2989 |
|
|
message[ `PANIC_MEMORYRACE ] = "MEMORYRACE ";
|
2990 |
|
|
|
2991 |
|
|
end
|
2992 |
|
|
|
2993 |
|
|
// ---------------------------------------------------------------------------
|
2994 |
|
|
// FETCH
|
2995 |
|
|
// ---------------------------------------------------------------------------
|
2996 |
|
|
//
|
2997 |
|
|
assign fetchbuf0_mem = IsMem(fetchbuf0_instr);
|
2998 |
|
|
assign fetchbuf0_memld = IsMem(fetchbuf0_instr) & IsLoad(fetchbuf0_instr);
|
2999 |
|
|
assign fetchbuf0_jmp = IsFlowCtrl(fetchbuf0_instr);
|
3000 |
|
|
assign fetchbuf0_rfw = IsRFW(fetchbuf0_instr,vqe0,vl,fetchbuf0_thrd);
|
3001 |
|
|
|
3002 |
|
|
assign fetchbuf1_mem = IsMem(fetchbuf1_instr);
|
3003 |
|
|
assign fetchbuf1_memld = IsMem(fetchbuf1_instr) & IsLoad(fetchbuf1_instr);
|
3004 |
|
|
assign fetchbuf1_jmp = IsFlowCtrl(fetchbuf1_instr);
|
3005 |
|
|
assign fetchbuf1_rfw = IsRFW(fetchbuf1_instr,vqe1,vl,fetchbuf1_thrd);
|
3006 |
|
|
|
3007 |
|
|
FT64_fetchbuf #(AMSB,RSTPC) ufb1
|
3008 |
|
|
(
|
3009 |
|
|
.rst(rst),
|
3010 |
|
|
.clk4x(clk4x),
|
3011 |
|
|
.clk(clk),
|
3012 |
|
|
.hirq(hirq),
|
3013 |
|
|
.regLR(regLR),
|
3014 |
|
|
.thread_en(thread_en),
|
3015 |
|
|
.insn0(insn0),
|
3016 |
|
|
.insn1(insn1),
|
3017 |
|
|
.phit(phit),
|
3018 |
|
|
.threadx(threadx),
|
3019 |
|
|
.branchmiss(branchmiss),
|
3020 |
|
|
.misspc(misspc),
|
3021 |
|
|
.branchmiss_thrd(branchmiss_thrd),
|
3022 |
|
|
.predict_takenA(predict_takenA),
|
3023 |
|
|
.predict_takenB(predict_takenB),
|
3024 |
|
|
.predict_takenC(predict_takenC),
|
3025 |
|
|
.predict_takenD(predict_takenD),
|
3026 |
|
|
.predict_taken0(predict_taken0),
|
3027 |
|
|
.predict_taken1(predict_taken1),
|
3028 |
|
|
.queued1(queued1),
|
3029 |
|
|
.queued2(queued2),
|
3030 |
|
|
.queuedNop(queuedNop),
|
3031 |
|
|
.pc0(pc0),
|
3032 |
|
|
.pc1(pc1),
|
3033 |
|
|
.fetchbuf(fetchbuf),
|
3034 |
|
|
.fetchbufA_v(fetchbufA_v),
|
3035 |
|
|
.fetchbufB_v(fetchbufB_v),
|
3036 |
|
|
.fetchbufC_v(fetchbufC_v),
|
3037 |
|
|
.fetchbufD_v(fetchbufD_v),
|
3038 |
|
|
.fetchbufA_pc(fetchbufA_pc),
|
3039 |
|
|
.fetchbufB_pc(fetchbufB_pc),
|
3040 |
|
|
.fetchbufC_pc(fetchbufC_pc),
|
3041 |
|
|
.fetchbufD_pc(fetchbufD_pc),
|
3042 |
|
|
.fetchbufA_instr(fetchbufA_instr),
|
3043 |
|
|
.fetchbufB_instr(fetchbufB_instr),
|
3044 |
|
|
.fetchbufC_instr(fetchbufC_instr),
|
3045 |
|
|
.fetchbufD_instr(fetchbufD_instr),
|
3046 |
|
|
.fetchbuf0_instr(fetchbuf0_instr),
|
3047 |
|
|
.fetchbuf1_instr(fetchbuf1_instr),
|
3048 |
|
|
.fetchbuf0_thrd(fetchbuf0_thrd),
|
3049 |
|
|
.fetchbuf1_thrd(fetchbuf1_thrd),
|
3050 |
|
|
.fetchbuf0_pc(fetchbuf0_pc),
|
3051 |
|
|
.fetchbuf1_pc(fetchbuf1_pc),
|
3052 |
|
|
.fetchbuf0_v(fetchbuf0_v),
|
3053 |
|
|
.fetchbuf1_v(fetchbuf1_v),
|
3054 |
|
|
.codebuf0(codebuf[insn0[21:16]]),
|
3055 |
|
|
.codebuf1(codebuf[insn1[21:16]]),
|
3056 |
|
|
.btgtA(btgtA),
|
3057 |
|
|
.btgtB(btgtB),
|
3058 |
|
|
.btgtC(btgtC),
|
3059 |
|
|
.btgtD(btgtD),
|
3060 |
|
|
.nop_fetchbuf(nop_fetchbuf),
|
3061 |
|
|
.take_branch0(take_branch0),
|
3062 |
|
|
.take_branch1(take_branch1),
|
3063 |
|
|
.stompedRets(stompedOnRets)
|
3064 |
|
|
);
|
3065 |
|
|
|
3066 |
|
|
//initial begin: stop_at
|
3067 |
|
|
//#1000000; panic <= `PANIC_OVERRUN;
|
3068 |
|
|
//end
|
3069 |
|
|
|
3070 |
|
|
//
|
3071 |
|
|
// BRANCH-MISS LOGIC: livetarget
|
3072 |
|
|
//
|
3073 |
|
|
// livetarget implies that there is a not-to-be-stomped instruction that targets the register in question
|
3074 |
|
|
// therefore, if it is zero it implies the rf_v value should become VALID on a branchmiss
|
3075 |
|
|
//
|
3076 |
|
|
|
3077 |
|
|
generate begin : live_target
|
3078 |
|
|
for (g = 1; g < PREGS; g = g + 1) begin : lvtgt
|
3079 |
|
|
assign livetarget[g] = iqentry_0_livetarget[g] |
|
3080 |
|
|
iqentry_1_livetarget[g] |
|
3081 |
|
|
iqentry_2_livetarget[g] |
|
3082 |
|
|
iqentry_3_livetarget[g] |
|
3083 |
|
|
iqentry_4_livetarget[g] |
|
3084 |
|
|
iqentry_5_livetarget[g] |
|
3085 |
|
|
iqentry_6_livetarget[g] |
|
3086 |
|
|
iqentry_7_livetarget[g];
|
3087 |
|
|
end
|
3088 |
|
|
end
|
3089 |
|
|
endgenerate
|
3090 |
|
|
|
3091 |
|
|
assign iqentry_0_livetarget = {PREGS {iqentry_v[0]}} & {PREGS {~iqentry_stomp[0] && iqentry_thrd[0]==branchmiss_thrd}} & iq0_out,
|
3092 |
|
|
iqentry_1_livetarget = {PREGS {iqentry_v[1]}} & {PREGS {~iqentry_stomp[1] && iqentry_thrd[1]==branchmiss_thrd}} & iq1_out,
|
3093 |
|
|
iqentry_2_livetarget = {PREGS {iqentry_v[2]}} & {PREGS {~iqentry_stomp[2] && iqentry_thrd[2]==branchmiss_thrd}} & iq2_out,
|
3094 |
|
|
iqentry_3_livetarget = {PREGS {iqentry_v[3]}} & {PREGS {~iqentry_stomp[3] && iqentry_thrd[3]==branchmiss_thrd}} & iq3_out,
|
3095 |
|
|
iqentry_4_livetarget = {PREGS {iqentry_v[4]}} & {PREGS {~iqentry_stomp[4] && iqentry_thrd[4]==branchmiss_thrd}} & iq4_out,
|
3096 |
|
|
iqentry_5_livetarget = {PREGS {iqentry_v[5]}} & {PREGS {~iqentry_stomp[5] && iqentry_thrd[5]==branchmiss_thrd}} & iq5_out,
|
3097 |
|
|
iqentry_6_livetarget = {PREGS {iqentry_v[6]}} & {PREGS {~iqentry_stomp[6] && iqentry_thrd[6]==branchmiss_thrd}} & iq6_out,
|
3098 |
|
|
iqentry_7_livetarget = {PREGS {iqentry_v[7]}} & {PREGS {~iqentry_stomp[7] && iqentry_thrd[7]==branchmiss_thrd}} & iq7_out;
|
3099 |
|
|
|
3100 |
|
|
//
|
3101 |
|
|
// BRANCH-MISS LOGIC: latestID
|
3102 |
|
|
//
|
3103 |
|
|
// latestID is the instruction queue ID of the newest instruction (latest) that targets
|
3104 |
|
|
// a particular register. looks a lot like scheduling logic, but in reverse.
|
3105 |
|
|
//
|
3106 |
|
|
assign iqentry_0_cumulative = (missid==3'd0) ? iqentry_0_livetarget :
|
3107 |
|
|
(missid==3'd1) ? iqentry_0_livetarget |
|
3108 |
|
|
iqentry_1_livetarget :
|
3109 |
|
|
(missid==3'd2) ? iqentry_0_livetarget |
|
3110 |
|
|
iqentry_1_livetarget |
|
3111 |
|
|
iqentry_2_livetarget :
|
3112 |
|
|
(missid==3'd3) ? iqentry_0_livetarget |
|
3113 |
|
|
iqentry_1_livetarget |
|
3114 |
|
|
iqentry_2_livetarget |
|
3115 |
|
|
iqentry_3_livetarget :
|
3116 |
|
|
(missid==3'd4) ? iqentry_0_livetarget |
|
3117 |
|
|
iqentry_1_livetarget |
|
3118 |
|
|
iqentry_2_livetarget |
|
3119 |
|
|
iqentry_3_livetarget |
|
3120 |
|
|
iqentry_4_livetarget :
|
3121 |
|
|
(missid==3'd5) ? iqentry_0_livetarget |
|
3122 |
|
|
iqentry_1_livetarget |
|
3123 |
|
|
iqentry_2_livetarget |
|
3124 |
|
|
iqentry_3_livetarget |
|
3125 |
|
|
iqentry_4_livetarget |
|
3126 |
|
|
iqentry_5_livetarget :
|
3127 |
|
|
(missid==3'd6) ? iqentry_0_livetarget |
|
3128 |
|
|
iqentry_1_livetarget |
|
3129 |
|
|
iqentry_2_livetarget |
|
3130 |
|
|
iqentry_3_livetarget |
|
3131 |
|
|
iqentry_4_livetarget |
|
3132 |
|
|
iqentry_5_livetarget |
|
3133 |
|
|
iqentry_6_livetarget :
|
3134 |
|
|
(missid==3'd7) ? iqentry_0_livetarget |
|
3135 |
|
|
iqentry_1_livetarget |
|
3136 |
|
|
iqentry_2_livetarget |
|
3137 |
|
|
iqentry_3_livetarget |
|
3138 |
|
|
iqentry_4_livetarget |
|
3139 |
|
|
iqentry_5_livetarget |
|
3140 |
|
|
iqentry_6_livetarget |
|
3141 |
|
|
iqentry_7_livetarget :
|
3142 |
|
|
{PREGS{1'b0}};
|
3143 |
|
|
|
3144 |
|
|
assign iqentry_1_cumulative = (missid==3'd1) ? iqentry_1_livetarget :
|
3145 |
|
|
(missid==3'd2) ? iqentry_1_livetarget |
|
3146 |
|
|
iqentry_2_livetarget :
|
3147 |
|
|
(missid==3'd3) ? iqentry_1_livetarget |
|
3148 |
|
|
iqentry_2_livetarget |
|
3149 |
|
|
iqentry_3_livetarget :
|
3150 |
|
|
(missid==3'd4) ? iqentry_1_livetarget |
|
3151 |
|
|
iqentry_2_livetarget |
|
3152 |
|
|
iqentry_3_livetarget |
|
3153 |
|
|
iqentry_4_livetarget :
|
3154 |
|
|
(missid==3'd5) ? iqentry_1_livetarget |
|
3155 |
|
|
iqentry_2_livetarget |
|
3156 |
|
|
iqentry_3_livetarget |
|
3157 |
|
|
iqentry_4_livetarget |
|
3158 |
|
|
iqentry_5_livetarget :
|
3159 |
|
|
(missid==3'd6) ? iqentry_1_livetarget |
|
3160 |
|
|
iqentry_2_livetarget |
|
3161 |
|
|
iqentry_3_livetarget |
|
3162 |
|
|
iqentry_4_livetarget |
|
3163 |
|
|
iqentry_5_livetarget |
|
3164 |
|
|
iqentry_6_livetarget :
|
3165 |
|
|
(missid==3'd7) ? iqentry_1_livetarget |
|
3166 |
|
|
iqentry_2_livetarget |
|
3167 |
|
|
iqentry_3_livetarget |
|
3168 |
|
|
iqentry_4_livetarget |
|
3169 |
|
|
iqentry_5_livetarget |
|
3170 |
|
|
iqentry_6_livetarget |
|
3171 |
|
|
iqentry_7_livetarget :
|
3172 |
|
|
(missid==3'd0) ? iqentry_1_livetarget |
|
3173 |
|
|
iqentry_2_livetarget |
|
3174 |
|
|
iqentry_3_livetarget |
|
3175 |
|
|
iqentry_4_livetarget |
|
3176 |
|
|
iqentry_5_livetarget |
|
3177 |
|
|
iqentry_6_livetarget |
|
3178 |
|
|
iqentry_7_livetarget |
|
3179 |
|
|
iqentry_0_livetarget :
|
3180 |
|
|
{PREGS{1'b0}};
|
3181 |
|
|
|
3182 |
|
|
assign iqentry_2_cumulative = (missid==3'd2) ? iqentry_2_livetarget :
|
3183 |
|
|
(missid==3'd3) ? iqentry_2_livetarget |
|
3184 |
|
|
iqentry_3_livetarget :
|
3185 |
|
|
(missid==3'd4) ? iqentry_2_livetarget |
|
3186 |
|
|
iqentry_3_livetarget |
|
3187 |
|
|
iqentry_4_livetarget :
|
3188 |
|
|
(missid==3'd5) ? iqentry_2_livetarget |
|
3189 |
|
|
iqentry_3_livetarget |
|
3190 |
|
|
iqentry_4_livetarget |
|
3191 |
|
|
iqentry_5_livetarget :
|
3192 |
|
|
(missid==3'd6) ? iqentry_2_livetarget |
|
3193 |
|
|
iqentry_3_livetarget |
|
3194 |
|
|
iqentry_4_livetarget |
|
3195 |
|
|
iqentry_5_livetarget |
|
3196 |
|
|
iqentry_6_livetarget :
|
3197 |
|
|
(missid==3'd7) ? iqentry_2_livetarget |
|
3198 |
|
|
iqentry_3_livetarget |
|
3199 |
|
|
iqentry_4_livetarget |
|
3200 |
|
|
iqentry_5_livetarget |
|
3201 |
|
|
iqentry_6_livetarget |
|
3202 |
|
|
iqentry_7_livetarget :
|
3203 |
|
|
(missid==3'd0) ? iqentry_2_livetarget |
|
3204 |
|
|
iqentry_3_livetarget |
|
3205 |
|
|
iqentry_4_livetarget |
|
3206 |
|
|
iqentry_5_livetarget |
|
3207 |
|
|
iqentry_6_livetarget |
|
3208 |
|
|
iqentry_7_livetarget |
|
3209 |
|
|
iqentry_0_livetarget :
|
3210 |
|
|
(missid==3'd1) ? iqentry_2_livetarget |
|
3211 |
|
|
iqentry_3_livetarget |
|
3212 |
|
|
iqentry_4_livetarget |
|
3213 |
|
|
iqentry_5_livetarget |
|
3214 |
|
|
iqentry_6_livetarget |
|
3215 |
|
|
iqentry_7_livetarget |
|
3216 |
|
|
iqentry_0_livetarget |
|
3217 |
|
|
iqentry_1_livetarget :
|
3218 |
|
|
{PREGS{1'b0}};
|
3219 |
|
|
|
3220 |
|
|
assign iqentry_3_cumulative = (missid==3'd3) ? iqentry_3_livetarget :
|
3221 |
|
|
(missid==3'd4) ? iqentry_3_livetarget |
|
3222 |
|
|
iqentry_4_livetarget :
|
3223 |
|
|
(missid==3'd5) ? iqentry_3_livetarget |
|
3224 |
|
|
iqentry_4_livetarget |
|
3225 |
|
|
iqentry_5_livetarget :
|
3226 |
|
|
(missid==3'd6) ? iqentry_3_livetarget |
|
3227 |
|
|
iqentry_4_livetarget |
|
3228 |
|
|
iqentry_5_livetarget |
|
3229 |
|
|
iqentry_6_livetarget :
|
3230 |
|
|
(missid==3'd7) ? iqentry_3_livetarget |
|
3231 |
|
|
iqentry_4_livetarget |
|
3232 |
|
|
iqentry_5_livetarget |
|
3233 |
|
|
iqentry_6_livetarget |
|
3234 |
|
|
iqentry_7_livetarget :
|
3235 |
|
|
(missid==3'd0) ? iqentry_3_livetarget |
|
3236 |
|
|
iqentry_4_livetarget |
|
3237 |
|
|
iqentry_5_livetarget |
|
3238 |
|
|
iqentry_6_livetarget |
|
3239 |
|
|
iqentry_7_livetarget |
|
3240 |
|
|
iqentry_0_livetarget :
|
3241 |
|
|
(missid==3'd1) ? iqentry_3_livetarget |
|
3242 |
|
|
iqentry_4_livetarget |
|
3243 |
|
|
iqentry_5_livetarget |
|
3244 |
|
|
iqentry_6_livetarget |
|
3245 |
|
|
iqentry_7_livetarget |
|
3246 |
|
|
iqentry_0_livetarget |
|
3247 |
|
|
iqentry_1_livetarget :
|
3248 |
|
|
(missid==3'd2) ? iqentry_3_livetarget |
|
3249 |
|
|
iqentry_4_livetarget |
|
3250 |
|
|
iqentry_5_livetarget |
|
3251 |
|
|
iqentry_6_livetarget |
|
3252 |
|
|
iqentry_7_livetarget |
|
3253 |
|
|
iqentry_0_livetarget |
|
3254 |
|
|
iqentry_1_livetarget |
|
3255 |
|
|
iqentry_2_livetarget :
|
3256 |
|
|
{PREGS{1'b0}};
|
3257 |
|
|
|
3258 |
|
|
assign iqentry_4_cumulative = (missid==3'd4) ? iqentry_4_livetarget :
|
3259 |
|
|
(missid==3'd5) ? iqentry_4_livetarget |
|
3260 |
|
|
iqentry_5_livetarget :
|
3261 |
|
|
(missid==3'd6) ? iqentry_4_livetarget |
|
3262 |
|
|
iqentry_5_livetarget |
|
3263 |
|
|
iqentry_6_livetarget :
|
3264 |
|
|
(missid==3'd7) ? iqentry_4_livetarget |
|
3265 |
|
|
iqentry_5_livetarget |
|
3266 |
|
|
iqentry_6_livetarget |
|
3267 |
|
|
iqentry_7_livetarget :
|
3268 |
|
|
(missid==3'd0) ? iqentry_4_livetarget |
|
3269 |
|
|
iqentry_5_livetarget |
|
3270 |
|
|
iqentry_6_livetarget |
|
3271 |
|
|
iqentry_7_livetarget |
|
3272 |
|
|
iqentry_0_livetarget :
|
3273 |
|
|
(missid==3'd1) ? iqentry_4_livetarget |
|
3274 |
|
|
iqentry_5_livetarget |
|
3275 |
|
|
iqentry_6_livetarget |
|
3276 |
|
|
iqentry_7_livetarget |
|
3277 |
|
|
iqentry_0_livetarget |
|
3278 |
|
|
iqentry_1_livetarget :
|
3279 |
|
|
(missid==3'd2) ? iqentry_4_livetarget |
|
3280 |
|
|
iqentry_5_livetarget |
|
3281 |
|
|
iqentry_6_livetarget |
|
3282 |
|
|
iqentry_7_livetarget |
|
3283 |
|
|
iqentry_0_livetarget |
|
3284 |
|
|
iqentry_1_livetarget |
|
3285 |
|
|
iqentry_2_livetarget :
|
3286 |
|
|
(missid==3'd3) ? iqentry_4_livetarget |
|
3287 |
|
|
iqentry_5_livetarget |
|
3288 |
|
|
iqentry_6_livetarget |
|
3289 |
|
|
iqentry_7_livetarget |
|
3290 |
|
|
iqentry_0_livetarget |
|
3291 |
|
|
iqentry_1_livetarget |
|
3292 |
|
|
iqentry_2_livetarget |
|
3293 |
|
|
iqentry_3_livetarget :
|
3294 |
|
|
{PREGS{1'b0}};
|
3295 |
|
|
|
3296 |
|
|
assign iqentry_5_cumulative = (missid==3'd5) ? iqentry_5_livetarget :
|
3297 |
|
|
(missid==3'd6) ? iqentry_5_livetarget |
|
3298 |
|
|
iqentry_6_livetarget :
|
3299 |
|
|
(missid==3'd7) ? iqentry_5_livetarget |
|
3300 |
|
|
iqentry_6_livetarget |
|
3301 |
|
|
iqentry_7_livetarget :
|
3302 |
|
|
(missid==3'd0) ? iqentry_5_livetarget |
|
3303 |
|
|
iqentry_6_livetarget |
|
3304 |
|
|
iqentry_7_livetarget |
|
3305 |
|
|
iqentry_0_livetarget :
|
3306 |
|
|
(missid==3'd1) ? iqentry_5_livetarget |
|
3307 |
|
|
iqentry_6_livetarget |
|
3308 |
|
|
iqentry_7_livetarget |
|
3309 |
|
|
iqentry_0_livetarget |
|
3310 |
|
|
iqentry_1_livetarget :
|
3311 |
|
|
(missid==3'd2) ? iqentry_5_livetarget |
|
3312 |
|
|
iqentry_6_livetarget |
|
3313 |
|
|
iqentry_7_livetarget |
|
3314 |
|
|
iqentry_0_livetarget |
|
3315 |
|
|
iqentry_1_livetarget |
|
3316 |
|
|
iqentry_2_livetarget :
|
3317 |
|
|
(missid==3'd3) ? iqentry_5_livetarget |
|
3318 |
|
|
iqentry_6_livetarget |
|
3319 |
|
|
iqentry_7_livetarget |
|
3320 |
|
|
iqentry_0_livetarget |
|
3321 |
|
|
iqentry_1_livetarget |
|
3322 |
|
|
iqentry_2_livetarget |
|
3323 |
|
|
iqentry_3_livetarget :
|
3324 |
|
|
(missid==3'd4) ? iqentry_5_livetarget |
|
3325 |
|
|
iqentry_6_livetarget |
|
3326 |
|
|
iqentry_7_livetarget |
|
3327 |
|
|
iqentry_0_livetarget |
|
3328 |
|
|
iqentry_1_livetarget |
|
3329 |
|
|
iqentry_2_livetarget |
|
3330 |
|
|
iqentry_3_livetarget |
|
3331 |
|
|
iqentry_4_livetarget :
|
3332 |
|
|
{PREGS{1'b0}};
|
3333 |
|
|
assign iqentry_6_cumulative = (missid==3'd6) ? iqentry_6_livetarget :
|
3334 |
|
|
(missid==3'd7) ? iqentry_6_livetarget |
|
3335 |
|
|
iqentry_7_livetarget :
|
3336 |
|
|
(missid==3'd0) ? iqentry_6_livetarget |
|
3337 |
|
|
iqentry_7_livetarget |
|
3338 |
|
|
iqentry_0_livetarget :
|
3339 |
|
|
(missid==3'd1) ? iqentry_6_livetarget |
|
3340 |
|
|
iqentry_7_livetarget |
|
3341 |
|
|
iqentry_0_livetarget |
|
3342 |
|
|
iqentry_1_livetarget :
|
3343 |
|
|
(missid==3'd2) ? iqentry_6_livetarget |
|
3344 |
|
|
iqentry_7_livetarget |
|
3345 |
|
|
iqentry_0_livetarget |
|
3346 |
|
|
iqentry_1_livetarget |
|
3347 |
|
|
iqentry_2_livetarget :
|
3348 |
|
|
(missid==3'd3) ? iqentry_6_livetarget |
|
3349 |
|
|
iqentry_7_livetarget |
|
3350 |
|
|
iqentry_0_livetarget |
|
3351 |
|
|
iqentry_1_livetarget |
|
3352 |
|
|
iqentry_2_livetarget |
|
3353 |
|
|
iqentry_3_livetarget :
|
3354 |
|
|
(missid==3'd4) ? iqentry_6_livetarget |
|
3355 |
|
|
iqentry_7_livetarget |
|
3356 |
|
|
iqentry_0_livetarget |
|
3357 |
|
|
iqentry_1_livetarget |
|
3358 |
|
|
iqentry_2_livetarget |
|
3359 |
|
|
iqentry_3_livetarget |
|
3360 |
|
|
iqentry_4_livetarget :
|
3361 |
|
|
(missid==3'd5) ? iqentry_6_livetarget |
|
3362 |
|
|
iqentry_7_livetarget |
|
3363 |
|
|
iqentry_0_livetarget |
|
3364 |
|
|
iqentry_1_livetarget |
|
3365 |
|
|
iqentry_2_livetarget |
|
3366 |
|
|
iqentry_3_livetarget |
|
3367 |
|
|
iqentry_4_livetarget |
|
3368 |
|
|
iqentry_5_livetarget :
|
3369 |
|
|
{PREGS{1'b0}};
|
3370 |
|
|
|
3371 |
|
|
assign iqentry_7_cumulative = (missid==3'd7) ? iqentry_7_livetarget :
|
3372 |
|
|
(missid==3'd0) ? iqentry_7_livetarget |
|
3373 |
|
|
iqentry_0_livetarget :
|
3374 |
|
|
(missid==3'd1) ? iqentry_7_livetarget |
|
3375 |
|
|
iqentry_0_livetarget |
|
3376 |
|
|
iqentry_1_livetarget :
|
3377 |
|
|
(missid==3'd2) ? iqentry_7_livetarget |
|
3378 |
|
|
iqentry_0_livetarget |
|
3379 |
|
|
iqentry_1_livetarget |
|
3380 |
|
|
iqentry_2_livetarget :
|
3381 |
|
|
(missid==3'd3) ? iqentry_7_livetarget |
|
3382 |
|
|
iqentry_0_livetarget |
|
3383 |
|
|
iqentry_1_livetarget |
|
3384 |
|
|
iqentry_2_livetarget |
|
3385 |
|
|
iqentry_3_livetarget :
|
3386 |
|
|
(missid==3'd4) ? iqentry_7_livetarget |
|
3387 |
|
|
iqentry_0_livetarget |
|
3388 |
|
|
iqentry_1_livetarget |
|
3389 |
|
|
iqentry_2_livetarget |
|
3390 |
|
|
iqentry_3_livetarget |
|
3391 |
|
|
iqentry_4_livetarget :
|
3392 |
|
|
(missid==3'd5) ? iqentry_7_livetarget |
|
3393 |
|
|
iqentry_0_livetarget |
|
3394 |
|
|
iqentry_1_livetarget |
|
3395 |
|
|
iqentry_2_livetarget |
|
3396 |
|
|
iqentry_3_livetarget |
|
3397 |
|
|
iqentry_4_livetarget |
|
3398 |
|
|
iqentry_5_livetarget :
|
3399 |
|
|
(missid==3'd6) ? iqentry_7_livetarget |
|
3400 |
|
|
iqentry_0_livetarget |
|
3401 |
|
|
iqentry_1_livetarget |
|
3402 |
|
|
iqentry_2_livetarget |
|
3403 |
|
|
iqentry_3_livetarget |
|
3404 |
|
|
iqentry_4_livetarget |
|
3405 |
|
|
iqentry_5_livetarget |
|
3406 |
|
|
iqentry_6_livetarget :
|
3407 |
|
|
{PREGS{1'b0}};
|
3408 |
|
|
|
3409 |
|
|
assign iqentry_0_latestID = (missid == 3'd0 || ((iqentry_0_livetarget & iqentry_1_cumulative) == {PREGS{1'b0}}))
|
3410 |
|
|
? iqentry_0_livetarget
|
3411 |
|
|
: {PREGS{1'b0}};
|
3412 |
|
|
|
3413 |
|
|
assign iqentry_1_latestID = (missid == 3'd1 || ((iqentry_1_livetarget & iqentry_2_cumulative) == {PREGS{1'b0}}))
|
3414 |
|
|
? iqentry_1_livetarget
|
3415 |
|
|
: {PREGS{1'b0}};
|
3416 |
|
|
|
3417 |
|
|
assign iqentry_2_latestID = (missid == 3'd2 || ((iqentry_2_livetarget & iqentry_3_cumulative) == {PREGS{1'b0}}))
|
3418 |
|
|
? iqentry_2_livetarget
|
3419 |
|
|
: {PREGS{1'b0}};
|
3420 |
|
|
|
3421 |
|
|
assign iqentry_3_latestID = (missid == 3'd3 || ((iqentry_3_livetarget & iqentry_4_cumulative) == {PREGS{1'b0}}))
|
3422 |
|
|
? iqentry_3_livetarget
|
3423 |
|
|
: {PREGS{1'b0}};
|
3424 |
|
|
|
3425 |
|
|
assign iqentry_4_latestID = (missid == 3'd4 || ((iqentry_4_livetarget & iqentry_5_cumulative) == {PREGS{1'b0}}))
|
3426 |
|
|
? iqentry_4_livetarget
|
3427 |
|
|
: {PREGS{1'b0}};
|
3428 |
|
|
|
3429 |
|
|
assign iqentry_5_latestID = (missid == 3'd5 || ((iqentry_5_livetarget & iqentry_6_cumulative) == {PREGS{1'b0}}))
|
3430 |
|
|
? iqentry_5_livetarget
|
3431 |
|
|
: {PREGS{1'b0}};
|
3432 |
|
|
|
3433 |
|
|
assign iqentry_6_latestID = (missid == 3'd6 || ((iqentry_6_livetarget & iqentry_7_cumulative) == {PREGS{1'b0}}))
|
3434 |
|
|
? iqentry_6_livetarget
|
3435 |
|
|
: {PREGS{1'b0}};
|
3436 |
|
|
|
3437 |
|
|
assign iqentry_7_latestID = (missid == 3'd7 || ((iqentry_7_livetarget & iqentry_0_cumulative) == {PREGS{1'b0}}))
|
3438 |
|
|
? iqentry_7_livetarget
|
3439 |
|
|
: {PREGS{1'b0}};
|
3440 |
|
|
|
3441 |
|
|
assign iqentry_source[0] = | iqentry_0_latestID,
|
3442 |
|
|
iqentry_source[1] = | iqentry_1_latestID,
|
3443 |
|
|
iqentry_source[2] = | iqentry_2_latestID,
|
3444 |
|
|
iqentry_source[3] = | iqentry_3_latestID,
|
3445 |
|
|
iqentry_source[4] = | iqentry_4_latestID,
|
3446 |
|
|
iqentry_source[5] = | iqentry_5_latestID,
|
3447 |
|
|
iqentry_source[6] = | iqentry_6_latestID,
|
3448 |
|
|
iqentry_source[7] = | iqentry_7_latestID;
|
3449 |
|
|
|
3450 |
|
|
|
3451 |
|
|
reg vqueued2;
|
3452 |
|
|
assign Ra0 = fnRa(fetchbuf0_instr,vqe0,vl,fetchbuf0_thrd) | {fetchbuf0_thrd,7'b0};
|
3453 |
|
|
assign Rb0 = fnRb(fetchbuf0_instr,1'b0,vqe0,rfoa0[5:0],rfoa1[5:0],fetchbuf0_thrd) | {fetchbuf0_thrd,7'b0};
|
3454 |
|
|
assign Rc0 = fnRc(fetchbuf0_instr,vqe0,fetchbuf0_thrd) | {fetchbuf0_thrd,7'b0};
|
3455 |
|
|
assign Rt0 = fnRt(fetchbuf0_instr,vqet0,vl,fetchbuf0_thrd) | {fetchbuf0_thrd,7'b0};
|
3456 |
|
|
assign Ra1 = fnRa(fetchbuf1_instr,vqueued2 ? vqe0 + 1 : vqe1,vl,fetchbuf1_thrd) | {fetchbuf1_thrd,7'b0};
|
3457 |
|
|
assign Rb1 = fnRb(fetchbuf1_instr,1'b1,vqueued2 ? vqe0 + 1 : vqe1,rfoa0[5:0],rfoa1[5:0],fetchbuf1_thrd) | {fetchbuf1_thrd,7'b0};
|
3458 |
|
|
assign Rc1 = fnRc(fetchbuf1_instr,vqueued2 ? vqe0 + 1 : vqe1,fetchbuf1_thrd) | {fetchbuf1_thrd,7'b0};
|
3459 |
|
|
assign Rt1 = fnRt(fetchbuf1_instr,vqueued2 ? vqet0 + 1 : vqet1,vl,fetchbuf1_thrd) | {fetchbuf1_thrd,7'b0};
|
3460 |
|
|
|
3461 |
|
|
//
|
3462 |
|
|
// additional logic for ISSUE
|
3463 |
|
|
//
|
3464 |
|
|
// for the moment, we look at ALU-input buffers to allow back-to-back issue of
|
3465 |
|
|
// dependent instructions ... we do not, however, look ahead for DRAM requests
|
3466 |
|
|
// that will become valid in the next cycle. instead, these have to propagate
|
3467 |
|
|
// their results into the IQ entry directly, at which point it becomes issue-able
|
3468 |
|
|
//
|
3469 |
|
|
|
3470 |
|
|
// note that, for all intents & purposes, iqentry_done == iqentry_agen ... no need to duplicate
|
3471 |
|
|
|
3472 |
|
|
wire [QENTRIES-1:0] args_valid;
|
3473 |
|
|
wire [QENTRIES-1:0] could_issue;
|
3474 |
|
|
|
3475 |
|
|
generate begin : issue_logic
|
3476 |
|
|
for (g = 0; g < QENTRIES; g = g + 1)
|
3477 |
|
|
begin
|
3478 |
|
|
assign args_valid[g] =
|
3479 |
|
|
(iqentry_a1_v[g]
|
3480 |
|
|
|| (iqentry_a1_s[g] == alu0_sourceid && alu0_dataready)
|
3481 |
|
|
|| (iqentry_a1_s[g] == alu1_sourceid && alu1_dataready))
|
3482 |
|
|
&& (iqentry_a2_v[g]
|
3483 |
|
|
|| (iqentry_mem[g] & ~iqentry_agen[g] & ~iqentry_memndx[g]) // a2 needs to be valid for indexed instruction
|
3484 |
|
|
|| (iqentry_a2_s[g] == alu0_sourceid && alu0_dataready)
|
3485 |
|
|
|| (iqentry_a2_s[g] == alu1_sourceid && alu1_dataready))
|
3486 |
|
|
&& (iqentry_a3_v[g]
|
3487 |
|
|
// || (iqentry_mem[g] & ~iqentry_agen[g])
|
3488 |
|
|
|| (iqentry_a3_s[g] == alu0_sourceid && alu0_dataready)
|
3489 |
|
|
|| (iqentry_a3_s[g] == alu1_sourceid && alu1_dataready))
|
3490 |
|
|
;
|
3491 |
|
|
|
3492 |
|
|
assign could_issue[g] = iqentry_v[g] && !iqentry_done[g] && !iqentry_out[g] && args_valid[g] &&
|
3493 |
|
|
(iqentry_mem[g] ? !iqentry_agen[g] : 1'b1);
|
3494 |
|
|
end
|
3495 |
|
|
end
|
3496 |
|
|
endgenerate
|
3497 |
|
|
|
3498 |
|
|
// The (old) simulator didn't handle the asynchronous race loop properly in the
|
3499 |
|
|
// original code. It would issue two instructions to the same islot. So the
|
3500 |
|
|
// issue logic has been re-written to eliminate the asynchronous loop.
|
3501 |
|
|
// Can't issue to the ALU if it's busy doing a long running operation like a
|
3502 |
|
|
// divide.
|
3503 |
|
|
// ToDo: fix the memory synchronization, see fp_issue below
|
3504 |
|
|
|
3505 |
|
|
always @*
|
3506 |
|
|
begin
|
3507 |
|
|
iqentry_issue = 8'h00;
|
3508 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
3509 |
|
|
iqentry_islot[n] = 2'b00;
|
3510 |
|
|
|
3511 |
|
|
// aluissue is a task
|
3512 |
|
|
if (alu0_idle) begin
|
3513 |
|
|
if (could_issue[head0] && iqentry_alu[head0]
|
3514 |
|
|
&& !iqentry_issue[head0]) begin
|
3515 |
|
|
iqentry_issue[head0] = `TRUE;
|
3516 |
|
|
iqentry_islot[head0] = 2'b00;
|
3517 |
|
|
end
|
3518 |
|
|
else if (could_issue[head1] && !iqentry_issue[head1] && iqentry_alu[head1]
|
3519 |
|
|
)
|
3520 |
|
|
begin
|
3521 |
|
|
iqentry_issue[head1] = `TRUE;
|
3522 |
|
|
iqentry_islot[head1] = 2'b00;
|
3523 |
|
|
end
|
3524 |
|
|
else if (could_issue[head2] && !iqentry_issue[head2] && iqentry_alu[head2]
|
3525 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3526 |
|
|
)
|
3527 |
|
|
begin
|
3528 |
|
|
iqentry_issue[head2] = `TRUE;
|
3529 |
|
|
iqentry_islot[head2] = 2'b00;
|
3530 |
|
|
end
|
3531 |
|
|
else if (could_issue[head3] && !iqentry_issue[head3] && iqentry_alu[head3]
|
3532 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3533 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3534 |
|
|
((!iqentry_v[head0])
|
3535 |
|
|
&& (!iqentry_v[head1]))
|
3536 |
|
|
)
|
3537 |
|
|
) begin
|
3538 |
|
|
iqentry_issue[head3] = `TRUE;
|
3539 |
|
|
iqentry_islot[head3] = 2'b00;
|
3540 |
|
|
end
|
3541 |
|
|
else if (could_issue[head4] && !iqentry_issue[head4] && iqentry_alu[head4]
|
3542 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3543 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3544 |
|
|
((!iqentry_v[head0])
|
3545 |
|
|
&& (!iqentry_v[head1]))
|
3546 |
|
|
)
|
3547 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3548 |
|
|
((!iqentry_v[head0])
|
3549 |
|
|
&& (!iqentry_v[head1])
|
3550 |
|
|
&& (!iqentry_v[head2]))
|
3551 |
|
|
)
|
3552 |
|
|
) begin
|
3553 |
|
|
iqentry_issue[head4] = `TRUE;
|
3554 |
|
|
iqentry_islot[head4] = 2'b00;
|
3555 |
|
|
end
|
3556 |
|
|
else if (could_issue[head5] && !iqentry_issue[head5] && iqentry_alu[head5]
|
3557 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3558 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3559 |
|
|
((!iqentry_v[head0])
|
3560 |
|
|
&& (!iqentry_v[head1]))
|
3561 |
|
|
)
|
3562 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3563 |
|
|
((!iqentry_v[head0])
|
3564 |
|
|
&& (!iqentry_v[head1])
|
3565 |
|
|
&& (!iqentry_v[head2]))
|
3566 |
|
|
)
|
3567 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
3568 |
|
|
((!iqentry_v[head0])
|
3569 |
|
|
&& (!iqentry_v[head1])
|
3570 |
|
|
&& (!iqentry_v[head2])
|
3571 |
|
|
&& (!iqentry_v[head3]))
|
3572 |
|
|
)
|
3573 |
|
|
) begin
|
3574 |
|
|
iqentry_issue[head5] = `TRUE;
|
3575 |
|
|
iqentry_islot[head5] = 2'b00;
|
3576 |
|
|
end
|
3577 |
|
|
`ifdef FULL_ISSUE_LOGIC
|
3578 |
|
|
else if (could_issue[head6] && !iqentry_issue[head6] && iqentry_alu[head6]
|
3579 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3580 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3581 |
|
|
((!iqentry_v[head0])
|
3582 |
|
|
&& (!iqentry_v[head1]))
|
3583 |
|
|
)
|
3584 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3585 |
|
|
((!iqentry_v[head0])
|
3586 |
|
|
&& (!iqentry_v[head1])
|
3587 |
|
|
&& (!iqentry_v[head2]))
|
3588 |
|
|
)
|
3589 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
3590 |
|
|
((!iqentry_v[head0])
|
3591 |
|
|
&& (!iqentry_v[head1])
|
3592 |
|
|
&& (!iqentry_v[head2])
|
3593 |
|
|
&& (!iqentry_v[head3]))
|
3594 |
|
|
)
|
3595 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
3596 |
|
|
((!iqentry_v[head0])
|
3597 |
|
|
&& (!iqentry_v[head1])
|
3598 |
|
|
&& (!iqentry_v[head2])
|
3599 |
|
|
&& (!iqentry_v[head3])
|
3600 |
|
|
&& (!iqentry_v[head4]))
|
3601 |
|
|
)
|
3602 |
|
|
) begin
|
3603 |
|
|
iqentry_issue[head6] = `TRUE;
|
3604 |
|
|
iqentry_islot[head6] = 2'b00;
|
3605 |
|
|
end
|
3606 |
|
|
else if (could_issue[head7] && !iqentry_issue[head7] && iqentry_alu[head7]
|
3607 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3608 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3609 |
|
|
((!iqentry_v[head0])
|
3610 |
|
|
&& (!iqentry_v[head1]))
|
3611 |
|
|
)
|
3612 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3613 |
|
|
((!iqentry_v[head0])
|
3614 |
|
|
&& (!iqentry_v[head1])
|
3615 |
|
|
&& (!iqentry_v[head2]))
|
3616 |
|
|
)
|
3617 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
3618 |
|
|
((!iqentry_v[head0])
|
3619 |
|
|
&& (!iqentry_v[head1])
|
3620 |
|
|
&& (!iqentry_v[head2])
|
3621 |
|
|
&& (!iqentry_v[head3]))
|
3622 |
|
|
)
|
3623 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
3624 |
|
|
((!iqentry_v[head0])
|
3625 |
|
|
&& (!iqentry_v[head1])
|
3626 |
|
|
&& (!iqentry_v[head2])
|
3627 |
|
|
&& (!iqentry_v[head3])
|
3628 |
|
|
&& (!iqentry_v[head4]))
|
3629 |
|
|
)
|
3630 |
|
|
&& (!(iqentry_v[head6] && iqentry_sync[head6]) ||
|
3631 |
|
|
((!iqentry_v[head0])
|
3632 |
|
|
&& (!iqentry_v[head1])
|
3633 |
|
|
&& (!iqentry_v[head2])
|
3634 |
|
|
&& (!iqentry_v[head3])
|
3635 |
|
|
&& (!iqentry_v[head4])
|
3636 |
|
|
&& (!iqentry_v[head5]))
|
3637 |
|
|
)
|
3638 |
|
|
) begin
|
3639 |
|
|
iqentry_issue[head7] = `TRUE;
|
3640 |
|
|
iqentry_islot[head7] = 2'b00;
|
3641 |
|
|
end
|
3642 |
|
|
`endif
|
3643 |
|
|
end
|
3644 |
|
|
|
3645 |
|
|
if (alu1_idle) begin
|
3646 |
|
|
if (could_issue[head0] && iqentry_alu[head0]
|
3647 |
|
|
&& !iqentry_alu0[head0] // alu0only
|
3648 |
|
|
&& !iqentry_issue[head0]) begin
|
3649 |
|
|
iqentry_issue[head0] = `TRUE;
|
3650 |
|
|
iqentry_islot[head0] = 2'b01;
|
3651 |
|
|
end
|
3652 |
|
|
else if (could_issue[head1] && !iqentry_issue[head1] && iqentry_alu[head1]
|
3653 |
|
|
&& !iqentry_alu0[head1])
|
3654 |
|
|
begin
|
3655 |
|
|
iqentry_issue[head1] = `TRUE;
|
3656 |
|
|
iqentry_islot[head1] = 2'b01;
|
3657 |
|
|
end
|
3658 |
|
|
else if (could_issue[head2] && !iqentry_issue[head2] && iqentry_alu[head2]
|
3659 |
|
|
&& !iqentry_alu0[head2]
|
3660 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3661 |
|
|
)
|
3662 |
|
|
begin
|
3663 |
|
|
iqentry_issue[head2] = `TRUE;
|
3664 |
|
|
iqentry_islot[head2] = 2'b01;
|
3665 |
|
|
end
|
3666 |
|
|
else if (could_issue[head3] && !iqentry_issue[head3] && iqentry_alu[head3]
|
3667 |
|
|
&& !iqentry_alu0[head3]
|
3668 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3669 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3670 |
|
|
((!iqentry_v[head0])
|
3671 |
|
|
&& (!iqentry_v[head1]))
|
3672 |
|
|
)
|
3673 |
|
|
) begin
|
3674 |
|
|
iqentry_issue[head3] = `TRUE;
|
3675 |
|
|
iqentry_islot[head3] = 2'b01;
|
3676 |
|
|
end
|
3677 |
|
|
else if (could_issue[head4] && !iqentry_issue[head4] && iqentry_alu[head4]
|
3678 |
|
|
&& !iqentry_alu0[head4]
|
3679 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3680 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3681 |
|
|
((!iqentry_v[head0])
|
3682 |
|
|
&& (!iqentry_v[head1]))
|
3683 |
|
|
)
|
3684 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3685 |
|
|
((!iqentry_v[head0])
|
3686 |
|
|
&& (!iqentry_v[head1])
|
3687 |
|
|
&& (!iqentry_v[head2]))
|
3688 |
|
|
)
|
3689 |
|
|
) begin
|
3690 |
|
|
iqentry_issue[head4] = `TRUE;
|
3691 |
|
|
iqentry_islot[head4] = 2'b01;
|
3692 |
|
|
end
|
3693 |
|
|
else if (could_issue[head5] && !iqentry_issue[head5] && iqentry_alu[head5]
|
3694 |
|
|
&& !iqentry_alu0[head5]
|
3695 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3696 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3697 |
|
|
((!iqentry_v[head0])
|
3698 |
|
|
&& (!iqentry_v[head1]))
|
3699 |
|
|
)
|
3700 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3701 |
|
|
((!iqentry_v[head0])
|
3702 |
|
|
&& (!iqentry_v[head1])
|
3703 |
|
|
&& (!iqentry_v[head2]))
|
3704 |
|
|
)
|
3705 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
3706 |
|
|
((!iqentry_v[head0])
|
3707 |
|
|
&& (!iqentry_v[head1])
|
3708 |
|
|
&& (!iqentry_v[head2])
|
3709 |
|
|
&& (!iqentry_v[head3]))
|
3710 |
|
|
)
|
3711 |
|
|
) begin
|
3712 |
|
|
iqentry_issue[head5] = `TRUE;
|
3713 |
|
|
iqentry_islot[head5] = 2'b01;
|
3714 |
|
|
end
|
3715 |
|
|
`ifdef FULL_ISSUE_LOGIC
|
3716 |
|
|
else if (could_issue[head6] && !iqentry_issue[head6] && iqentry_alu[head6]
|
3717 |
|
|
&& !iqentry_alu0[head6]
|
3718 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3719 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3720 |
|
|
((!iqentry_v[head0])
|
3721 |
|
|
&& (!iqentry_v[head1]))
|
3722 |
|
|
)
|
3723 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3724 |
|
|
((!iqentry_v[head0])
|
3725 |
|
|
&& (!iqentry_v[head1])
|
3726 |
|
|
&& (!iqentry_v[head2]))
|
3727 |
|
|
)
|
3728 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
3729 |
|
|
((!iqentry_v[head0])
|
3730 |
|
|
&& (!iqentry_v[head1])
|
3731 |
|
|
&& (!iqentry_v[head2])
|
3732 |
|
|
&& (!iqentry_v[head3]))
|
3733 |
|
|
)
|
3734 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
3735 |
|
|
((!iqentry_v[head0])
|
3736 |
|
|
&& (!iqentry_v[head1])
|
3737 |
|
|
&& (!iqentry_v[head2])
|
3738 |
|
|
&& (!iqentry_v[head3])
|
3739 |
|
|
&& (!iqentry_v[head4]))
|
3740 |
|
|
)
|
3741 |
|
|
) begin
|
3742 |
|
|
iqentry_issue[head6] = `TRUE;
|
3743 |
|
|
iqentry_islot[head6] = 2'b01;
|
3744 |
|
|
end
|
3745 |
|
|
else if (could_issue[head7] && !iqentry_issue[head7] && iqentry_alu[head7]
|
3746 |
|
|
&& !iqentry_alu0[head7]
|
3747 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
3748 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
3749 |
|
|
((!iqentry_v[head0])
|
3750 |
|
|
&& (!iqentry_v[head1]))
|
3751 |
|
|
)
|
3752 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
3753 |
|
|
((!iqentry_v[head0])
|
3754 |
|
|
&& (!iqentry_v[head1])
|
3755 |
|
|
&& (!iqentry_v[head2]))
|
3756 |
|
|
)
|
3757 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
3758 |
|
|
((!iqentry_v[head0])
|
3759 |
|
|
&& (!iqentry_v[head1])
|
3760 |
|
|
&& (!iqentry_v[head2])
|
3761 |
|
|
&& (!iqentry_v[head3]))
|
3762 |
|
|
)
|
3763 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
3764 |
|
|
((!iqentry_v[head0])
|
3765 |
|
|
&& (!iqentry_v[head1])
|
3766 |
|
|
&& (!iqentry_v[head2])
|
3767 |
|
|
&& (!iqentry_v[head3])
|
3768 |
|
|
&& (!iqentry_v[head4]))
|
3769 |
|
|
)
|
3770 |
|
|
&& (!(iqentry_v[head6] && iqentry_sync[head6]) ||
|
3771 |
|
|
((!iqentry_v[head0])
|
3772 |
|
|
&& (!iqentry_v[head1])
|
3773 |
|
|
&& (!iqentry_v[head2])
|
3774 |
|
|
&& (!iqentry_v[head3])
|
3775 |
|
|
&& (!iqentry_v[head4])
|
3776 |
|
|
&& (!iqentry_v[head5]))
|
3777 |
|
|
)
|
3778 |
|
|
) begin
|
3779 |
|
|
iqentry_issue[head7] = `TRUE;
|
3780 |
|
|
iqentry_islot[head7] = 2'b01;
|
3781 |
|
|
end
|
3782 |
|
|
`endif
|
3783 |
|
|
end
|
3784 |
|
|
// aluissue(alu0_idle,8'h00,2'b00);
|
3785 |
|
|
// aluissue(alu1_idle,iqentry_alu0,2'b01);
|
3786 |
|
|
|
3787 |
|
|
end
|
3788 |
|
|
|
3789 |
|
|
always @*
|
3790 |
|
|
begin
|
3791 |
|
|
iqentry_fpu_issue = 8'h00;
|
3792 |
|
|
// fpuissue(fpu_idle,2'b00);
|
3793 |
|
|
if (fpu_idle) begin
|
3794 |
|
|
if (could_issue[head0] && iqentry_fpu[head0]) begin
|
3795 |
|
|
iqentry_fpu_issue[head0] = `TRUE;
|
3796 |
|
|
iqentry_fpu_islot[head0] = 2'b00;
|
3797 |
|
|
end
|
3798 |
|
|
else if (could_issue[head1] && iqentry_fpu[head1])
|
3799 |
|
|
begin
|
3800 |
|
|
iqentry_fpu_issue[head1] = `TRUE;
|
3801 |
|
|
iqentry_fpu_islot[head1] = 2'b00;
|
3802 |
|
|
end
|
3803 |
|
|
else if (could_issue[head2] && iqentry_fpu[head2]
|
3804 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
3805 |
|
|
) begin
|
3806 |
|
|
iqentry_fpu_issue[head2] = `TRUE;
|
3807 |
|
|
iqentry_fpu_islot[head2] = 2'b00;
|
3808 |
|
|
end
|
3809 |
|
|
else if (could_issue[head3] && iqentry_fpu[head3]
|
3810 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
3811 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
3812 |
|
|
((!iqentry_v[head0])
|
3813 |
|
|
&& (!iqentry_v[head1]))
|
3814 |
|
|
)
|
3815 |
|
|
) begin
|
3816 |
|
|
iqentry_fpu_issue[head3] = `TRUE;
|
3817 |
|
|
iqentry_fpu_islot[head3] = 2'b00;
|
3818 |
|
|
end
|
3819 |
|
|
else if (could_issue[head4] && iqentry_fpu[head4]
|
3820 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
3821 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
3822 |
|
|
((!iqentry_v[head0])
|
3823 |
|
|
&& (!iqentry_v[head1]))
|
3824 |
|
|
)
|
3825 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
3826 |
|
|
((!iqentry_v[head0])
|
3827 |
|
|
&& (!iqentry_v[head1])
|
3828 |
|
|
&& (!iqentry_v[head2]))
|
3829 |
|
|
)
|
3830 |
|
|
) begin
|
3831 |
|
|
iqentry_fpu_issue[head4] = `TRUE;
|
3832 |
|
|
iqentry_fpu_islot[head4] = 2'b00;
|
3833 |
|
|
end
|
3834 |
|
|
else if (could_issue[head5] && iqentry_fpu[head5]
|
3835 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
3836 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
3837 |
|
|
((!iqentry_v[head0])
|
3838 |
|
|
&& (!iqentry_v[head1]))
|
3839 |
|
|
)
|
3840 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
3841 |
|
|
((!iqentry_v[head0])
|
3842 |
|
|
&& (!iqentry_v[head1])
|
3843 |
|
|
&& (!iqentry_v[head2]))
|
3844 |
|
|
)
|
3845 |
|
|
&& (!(iqentry_v[head4] && (iqentry_sync[head4] || iqentry_fsync[head4])) ||
|
3846 |
|
|
((!iqentry_v[head0])
|
3847 |
|
|
&& (!iqentry_v[head1])
|
3848 |
|
|
&& (!iqentry_v[head2])
|
3849 |
|
|
&& (!iqentry_v[head3]))
|
3850 |
|
|
)
|
3851 |
|
|
) begin
|
3852 |
|
|
iqentry_fpu_issue[head5] = `TRUE;
|
3853 |
|
|
iqentry_fpu_islot[head5] = 2'b00;
|
3854 |
|
|
end
|
3855 |
|
|
`ifdef FULL_ISSUE_LOGIC
|
3856 |
|
|
else if (could_issue[head6] && iqentry_fpu[head6]
|
3857 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
3858 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
3859 |
|
|
((!iqentry_v[head0])
|
3860 |
|
|
&& (!iqentry_v[head1]))
|
3861 |
|
|
)
|
3862 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
3863 |
|
|
((!iqentry_v[head0])
|
3864 |
|
|
&& (!iqentry_v[head1])
|
3865 |
|
|
&& (!iqentry_v[head2]))
|
3866 |
|
|
)
|
3867 |
|
|
&& (!(iqentry_v[head4] && (iqentry_sync[head4] || iqentry_fsync[head4])) ||
|
3868 |
|
|
((!iqentry_v[head0])
|
3869 |
|
|
&& (!iqentry_v[head1])
|
3870 |
|
|
&& (!iqentry_v[head2])
|
3871 |
|
|
&& (!iqentry_v[head3]))
|
3872 |
|
|
)
|
3873 |
|
|
&& (!(iqentry_v[head5] && (iqentry_sync[head5] || iqentry_fsync[head5])) ||
|
3874 |
|
|
((!iqentry_v[head0])
|
3875 |
|
|
&& (!iqentry_v[head1])
|
3876 |
|
|
&& (!iqentry_v[head2])
|
3877 |
|
|
&& (!iqentry_v[head3])
|
3878 |
|
|
&& (!iqentry_v[head4]))
|
3879 |
|
|
)
|
3880 |
|
|
) begin
|
3881 |
|
|
iqentry_fpu_issue[head6] = `TRUE;
|
3882 |
|
|
iqentry_fpu_islot[head6] = 2'b00;
|
3883 |
|
|
end
|
3884 |
|
|
else if (could_issue[head7] && iqentry_fpu[head7]
|
3885 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
3886 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
3887 |
|
|
((!iqentry_v[head0])
|
3888 |
|
|
&& (!iqentry_v[head1]))
|
3889 |
|
|
)
|
3890 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
3891 |
|
|
((!iqentry_v[head0])
|
3892 |
|
|
&& (!iqentry_v[head1])
|
3893 |
|
|
&& (!iqentry_v[head2]))
|
3894 |
|
|
)
|
3895 |
|
|
&& (!(iqentry_v[head4] && (iqentry_sync[head4] || iqentry_fsync[head4])) ||
|
3896 |
|
|
((!iqentry_v[head0])
|
3897 |
|
|
&& (!iqentry_v[head1])
|
3898 |
|
|
&& (!iqentry_v[head2])
|
3899 |
|
|
&& (!iqentry_v[head3]))
|
3900 |
|
|
)
|
3901 |
|
|
&& (!(iqentry_v[head5] && (iqentry_sync[head5] || iqentry_fsync[head5])) ||
|
3902 |
|
|
((!iqentry_v[head0])
|
3903 |
|
|
&& (!iqentry_v[head1])
|
3904 |
|
|
&& (!iqentry_v[head2])
|
3905 |
|
|
&& (!iqentry_v[head3])
|
3906 |
|
|
&& (!iqentry_v[head4]))
|
3907 |
|
|
)
|
3908 |
|
|
&& (!(iqentry_v[head6] && (iqentry_sync[head6] || iqentry_fsync[head6])) ||
|
3909 |
|
|
((!iqentry_v[head0])
|
3910 |
|
|
&& (!iqentry_v[head1])
|
3911 |
|
|
&& (!iqentry_v[head2])
|
3912 |
|
|
&& (!iqentry_v[head3])
|
3913 |
|
|
&& (!iqentry_v[head4])
|
3914 |
|
|
&& (!iqentry_v[head5]))
|
3915 |
|
|
)
|
3916 |
|
|
)
|
3917 |
|
|
begin
|
3918 |
|
|
iqentry_fpu_issue[head7] = `TRUE;
|
3919 |
|
|
iqentry_fpu_islot[head7] = 2'b00;
|
3920 |
|
|
end
|
3921 |
|
|
`endif
|
3922 |
|
|
end
|
3923 |
|
|
end
|
3924 |
|
|
|
3925 |
|
|
|
3926 |
|
|
wire [QENTRIES-1:0] nextqd;
|
3927 |
|
|
// Next queue id
|
3928 |
|
|
|
3929 |
|
|
reg [`QBITS] nid0;
|
3930 |
|
|
always @*
|
3931 |
|
|
if (iqentry_thrd[1]==iqentry_thrd[0])
|
3932 |
|
|
nid0 = 3'd1;
|
3933 |
|
|
else if (iqentry_thrd[2]==iqentry_thrd[0])
|
3934 |
|
|
nid0 = 3'd2;
|
3935 |
|
|
else if (iqentry_thrd[3]==iqentry_thrd[0])
|
3936 |
|
|
nid0 = 3'd3;
|
3937 |
|
|
else if (iqentry_thrd[4]==iqentry_thrd[0])
|
3938 |
|
|
nid0 = 3'd4;
|
3939 |
|
|
else if (iqentry_thrd[5]==iqentry_thrd[0])
|
3940 |
|
|
nid0 = 3'd5;
|
3941 |
|
|
else if (iqentry_thrd[6]==iqentry_thrd[0])
|
3942 |
|
|
nid0 = 3'd6;
|
3943 |
|
|
else if (iqentry_thrd[7]==iqentry_thrd[0])
|
3944 |
|
|
nid0 = 3'd7;
|
3945 |
|
|
else
|
3946 |
|
|
nid0 = 3'd0;
|
3947 |
|
|
|
3948 |
|
|
reg [`QBITS] nid1;
|
3949 |
|
|
always @*
|
3950 |
|
|
if (iqentry_thrd[2]==iqentry_thrd[1])
|
3951 |
|
|
nid1 = 3'd2;
|
3952 |
|
|
else if (iqentry_thrd[3]==iqentry_thrd[1])
|
3953 |
|
|
nid1 = 3'd3;
|
3954 |
|
|
else if (iqentry_thrd[4]==iqentry_thrd[1])
|
3955 |
|
|
nid1 = 3'd4;
|
3956 |
|
|
else if (iqentry_thrd[5]==iqentry_thrd[1])
|
3957 |
|
|
nid1 = 3'd5;
|
3958 |
|
|
else if (iqentry_thrd[6]==iqentry_thrd[1])
|
3959 |
|
|
nid1 = 3'd6;
|
3960 |
|
|
else if (iqentry_thrd[7]==iqentry_thrd[1])
|
3961 |
|
|
nid1 = 3'd7;
|
3962 |
|
|
else if (iqentry_thrd[0]==iqentry_thrd[1])
|
3963 |
|
|
nid1 = 3'd0;
|
3964 |
|
|
else
|
3965 |
|
|
nid1 = 3'd1;
|
3966 |
|
|
|
3967 |
|
|
reg [`QBITS] nid2;
|
3968 |
|
|
always @*
|
3969 |
|
|
if (iqentry_thrd[3]==iqentry_thrd[2])
|
3970 |
|
|
nid2 = 3'd3;
|
3971 |
|
|
else if (iqentry_thrd[4]==iqentry_thrd[2])
|
3972 |
|
|
nid2 = 3'd4;
|
3973 |
|
|
else if (iqentry_thrd[5]==iqentry_thrd[2])
|
3974 |
|
|
nid2 = 3'd5;
|
3975 |
|
|
else if (iqentry_thrd[6]==iqentry_thrd[2])
|
3976 |
|
|
nid2 = 3'd6;
|
3977 |
|
|
else if (iqentry_thrd[7]==iqentry_thrd[2])
|
3978 |
|
|
nid2 = 3'd7;
|
3979 |
|
|
else if (iqentry_thrd[0]==iqentry_thrd[2])
|
3980 |
|
|
nid2 = 3'd0;
|
3981 |
|
|
else if (iqentry_thrd[1]==iqentry_thrd[2])
|
3982 |
|
|
nid2 = 3'd1;
|
3983 |
|
|
else
|
3984 |
|
|
nid2 = 3'd2;
|
3985 |
|
|
|
3986 |
|
|
reg [`QBITS] nid3;
|
3987 |
|
|
always @*
|
3988 |
|
|
if (iqentry_thrd[4]==iqentry_thrd[3])
|
3989 |
|
|
nid3 = 3'd4;
|
3990 |
|
|
else if (iqentry_thrd[5]==iqentry_thrd[3])
|
3991 |
|
|
nid3 = 3'd5;
|
3992 |
|
|
else if (iqentry_thrd[6]==iqentry_thrd[3])
|
3993 |
|
|
nid3 = 3'd6;
|
3994 |
|
|
else if (iqentry_thrd[7]==iqentry_thrd[3])
|
3995 |
|
|
nid3 = 3'd7;
|
3996 |
|
|
else if (iqentry_thrd[0]==iqentry_thrd[3])
|
3997 |
|
|
nid3 = 3'd0;
|
3998 |
|
|
else if (iqentry_thrd[1]==iqentry_thrd[3])
|
3999 |
|
|
nid3 = 3'd1;
|
4000 |
|
|
else if (iqentry_thrd[2]==iqentry_thrd[3])
|
4001 |
|
|
nid3 = 3'd2;
|
4002 |
|
|
else
|
4003 |
|
|
nid3 = 3'd3;
|
4004 |
|
|
|
4005 |
|
|
reg [`QBITS] nid4;
|
4006 |
|
|
always @*
|
4007 |
|
|
if (iqentry_thrd[5]==iqentry_thrd[4])
|
4008 |
|
|
nid4 = 3'd5;
|
4009 |
|
|
else if (iqentry_thrd[6]==iqentry_thrd[4])
|
4010 |
|
|
nid4 = 3'd6;
|
4011 |
|
|
else if (iqentry_thrd[7]==iqentry_thrd[4])
|
4012 |
|
|
nid4 = 3'd7;
|
4013 |
|
|
else if (iqentry_thrd[0]==iqentry_thrd[4])
|
4014 |
|
|
nid4 = 3'd0;
|
4015 |
|
|
else if (iqentry_thrd[1]==iqentry_thrd[4])
|
4016 |
|
|
nid4 = 3'd1;
|
4017 |
|
|
else if (iqentry_thrd[2]==iqentry_thrd[4])
|
4018 |
|
|
nid4 = 3'd2;
|
4019 |
|
|
else if (iqentry_thrd[3]==iqentry_thrd[4])
|
4020 |
|
|
nid4 = 3'd3;
|
4021 |
|
|
else
|
4022 |
|
|
nid4 = 3'd4;
|
4023 |
|
|
|
4024 |
|
|
reg [`QBITS] nid5;
|
4025 |
|
|
always @*
|
4026 |
|
|
if (iqentry_thrd[6]==iqentry_thrd[5])
|
4027 |
|
|
nid5 = 3'd6;
|
4028 |
|
|
else if (iqentry_thrd[7]==iqentry_thrd[5])
|
4029 |
|
|
nid5 = 3'd7;
|
4030 |
|
|
else if (iqentry_thrd[0]==iqentry_thrd[5])
|
4031 |
|
|
nid5 = 3'd0;
|
4032 |
|
|
else if (iqentry_thrd[1]==iqentry_thrd[5])
|
4033 |
|
|
nid5 = 3'd1;
|
4034 |
|
|
else if (iqentry_thrd[2]==iqentry_thrd[5])
|
4035 |
|
|
nid5 = 3'd2;
|
4036 |
|
|
else if (iqentry_thrd[3]==iqentry_thrd[5])
|
4037 |
|
|
nid5 = 3'd3;
|
4038 |
|
|
else if (iqentry_thrd[4]==iqentry_thrd[5])
|
4039 |
|
|
nid5 = 3'd4;
|
4040 |
|
|
else
|
4041 |
|
|
nid5 = 3'd5;
|
4042 |
|
|
|
4043 |
|
|
reg [`QBITS] nid6;
|
4044 |
|
|
always @*
|
4045 |
|
|
if (iqentry_thrd[7]==iqentry_thrd[6])
|
4046 |
|
|
nid6 = 3'd7;
|
4047 |
|
|
else if (iqentry_thrd[0]==iqentry_thrd[6])
|
4048 |
|
|
nid6 = 3'd0;
|
4049 |
|
|
else if (iqentry_thrd[1]==iqentry_thrd[6])
|
4050 |
|
|
nid6 = 3'd1;
|
4051 |
|
|
else if (iqentry_thrd[2]==iqentry_thrd[6])
|
4052 |
|
|
nid6 = 3'd2;
|
4053 |
|
|
else if (iqentry_thrd[3]==iqentry_thrd[6])
|
4054 |
|
|
nid6 = 3'd3;
|
4055 |
|
|
else if (iqentry_thrd[4]==iqentry_thrd[6])
|
4056 |
|
|
nid6 = 3'd4;
|
4057 |
|
|
else if (iqentry_thrd[5]==iqentry_thrd[6])
|
4058 |
|
|
nid6 = 3'd5;
|
4059 |
|
|
else
|
4060 |
|
|
nid6 = 3'd6;
|
4061 |
|
|
|
4062 |
|
|
reg [`QBITS] nid7;
|
4063 |
|
|
always @*
|
4064 |
|
|
if (iqentry_thrd[0]==iqentry_thrd[7])
|
4065 |
|
|
nid7 = 3'd0;
|
4066 |
|
|
else if (iqentry_thrd[1]==iqentry_thrd[7])
|
4067 |
|
|
nid7 = 3'd1;
|
4068 |
|
|
else if (iqentry_thrd[2]==iqentry_thrd[7])
|
4069 |
|
|
nid7 = 3'd2;
|
4070 |
|
|
else if (iqentry_thrd[3]==iqentry_thrd[7])
|
4071 |
|
|
nid7 = 3'd3;
|
4072 |
|
|
else if (iqentry_thrd[4]==iqentry_thrd[7])
|
4073 |
|
|
nid7 = 3'd4;
|
4074 |
|
|
else if (iqentry_thrd[5]==iqentry_thrd[7])
|
4075 |
|
|
nid7 = 3'd5;
|
4076 |
|
|
else if (iqentry_thrd[6]==iqentry_thrd[7])
|
4077 |
|
|
nid7 = 3'd6;
|
4078 |
|
|
else
|
4079 |
|
|
nid7 = 3'd7;
|
4080 |
|
|
|
4081 |
|
|
// Search the queue for the next entry on the same thread.
|
4082 |
|
|
reg [`QBITS] nid;
|
4083 |
|
|
always @*
|
4084 |
|
|
if (iqentry_thrd[idp1(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4085 |
|
|
nid = idp1(fcu_id);
|
4086 |
|
|
else if (iqentry_thrd[idp2(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4087 |
|
|
nid = idp2(fcu_id);
|
4088 |
|
|
else if (iqentry_thrd[idp3(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4089 |
|
|
nid = idp3(fcu_id);
|
4090 |
|
|
else if (iqentry_thrd[idp4(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4091 |
|
|
nid = idp4(fcu_id);
|
4092 |
|
|
else if (iqentry_thrd[idp5(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4093 |
|
|
nid = idp5(fcu_id);
|
4094 |
|
|
else if (iqentry_thrd[idp6(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4095 |
|
|
nid = idp6(fcu_id);
|
4096 |
|
|
else if (iqentry_thrd[idp7(fcu_id)]==iqentry_thrd[fcu_id[`QBITS]])
|
4097 |
|
|
nid = idp7(fcu_id);
|
4098 |
|
|
else
|
4099 |
|
|
nid = fcu_id;
|
4100 |
|
|
|
4101 |
|
|
|
4102 |
|
|
assign nextqd[0] = iqentry_sn[nid0] > iqentry_sn[0] || iqentry_v[0];
|
4103 |
|
|
assign nextqd[1] = iqentry_sn[nid1] > iqentry_sn[1] || iqentry_v[1];
|
4104 |
|
|
assign nextqd[2] = iqentry_sn[nid2] > iqentry_sn[2] || iqentry_v[2];
|
4105 |
|
|
assign nextqd[3] = iqentry_sn[nid3] > iqentry_sn[3] || iqentry_v[3];
|
4106 |
|
|
assign nextqd[4] = iqentry_sn[nid4] > iqentry_sn[4] || iqentry_v[4];
|
4107 |
|
|
assign nextqd[5] = iqentry_sn[nid5] > iqentry_sn[5] || iqentry_v[5];
|
4108 |
|
|
assign nextqd[6] = iqentry_sn[nid6] > iqentry_sn[6] || iqentry_v[6];
|
4109 |
|
|
assign nextqd[7] = iqentry_sn[nid7] > iqentry_sn[7] || iqentry_v[7];
|
4110 |
|
|
|
4111 |
|
|
//assign nextqd = 8'hFF;
|
4112 |
|
|
|
4113 |
|
|
// Don't issue to the fcu until the following instruction is enqueued.
|
4114 |
|
|
// However, if the queue is full then issue anyway. A branch miss will likely occur.
|
4115 |
|
|
always @*//(could_issue or head0 or head1 or head2 or head3 or head4 or head5 or head6 or head7)
|
4116 |
|
|
begin
|
4117 |
|
|
iqentry_fcu_issue = 8'h00;
|
4118 |
|
|
if (fcu_done) begin
|
4119 |
|
|
if (could_issue[head0] && iqentry_fc[head0] && nextqd[head0]) begin
|
4120 |
|
|
iqentry_fcu_issue[head0] = `TRUE;
|
4121 |
|
|
end
|
4122 |
|
|
else if (could_issue[head1] && iqentry_fc[head1] && nextqd[head1])
|
4123 |
|
|
begin
|
4124 |
|
|
iqentry_fcu_issue[head1] = `TRUE;
|
4125 |
|
|
end
|
4126 |
|
|
else if (could_issue[head2] && iqentry_fc[head2] && nextqd[head2]
|
4127 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
4128 |
|
|
) begin
|
4129 |
|
|
iqentry_fcu_issue[head2] = `TRUE;
|
4130 |
|
|
end
|
4131 |
|
|
else if (could_issue[head3] && iqentry_fc[head3] && nextqd[head3]
|
4132 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
4133 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
4134 |
|
|
((!iqentry_v[head0])
|
4135 |
|
|
&& (!iqentry_v[head1]))
|
4136 |
|
|
)
|
4137 |
|
|
) begin
|
4138 |
|
|
iqentry_fcu_issue[head3] = `TRUE;
|
4139 |
|
|
end
|
4140 |
|
|
else if (could_issue[head4] && iqentry_fc[head4] && nextqd[head4]
|
4141 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
4142 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
4143 |
|
|
((!iqentry_v[head0])
|
4144 |
|
|
&& (!iqentry_v[head1]))
|
4145 |
|
|
)
|
4146 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
4147 |
|
|
((!iqentry_v[head0])
|
4148 |
|
|
&& (!iqentry_v[head1])
|
4149 |
|
|
&& (!iqentry_v[head2]))
|
4150 |
|
|
)
|
4151 |
|
|
) begin
|
4152 |
|
|
iqentry_fcu_issue[head4] = `TRUE;
|
4153 |
|
|
end
|
4154 |
|
|
else if (could_issue[head5] && iqentry_fc[head5] && nextqd[head5]
|
4155 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
4156 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
4157 |
|
|
((!iqentry_v[head0])
|
4158 |
|
|
&& (!iqentry_v[head1]))
|
4159 |
|
|
)
|
4160 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
4161 |
|
|
((!iqentry_v[head0])
|
4162 |
|
|
&& (!iqentry_v[head1])
|
4163 |
|
|
&& (!iqentry_v[head2]))
|
4164 |
|
|
)
|
4165 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
4166 |
|
|
((!iqentry_v[head0])
|
4167 |
|
|
&& (!iqentry_v[head1])
|
4168 |
|
|
&& (!iqentry_v[head2])
|
4169 |
|
|
&& (!iqentry_v[head3]))
|
4170 |
|
|
)
|
4171 |
|
|
) begin
|
4172 |
|
|
iqentry_fcu_issue[head5] = `TRUE;
|
4173 |
|
|
end
|
4174 |
|
|
|
4175 |
|
|
`ifdef FULL_ISSUE_LOGIC
|
4176 |
|
|
else if (could_issue[head6] && iqentry_fc[head6] && nextqd[head6]
|
4177 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
4178 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
4179 |
|
|
((!iqentry_v[head0])
|
4180 |
|
|
&& (!iqentry_v[head1]))
|
4181 |
|
|
)
|
4182 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
4183 |
|
|
((!iqentry_v[head0])
|
4184 |
|
|
&& (!iqentry_v[head1])
|
4185 |
|
|
&& (!iqentry_v[head2]))
|
4186 |
|
|
)
|
4187 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
4188 |
|
|
((!iqentry_v[head0])
|
4189 |
|
|
&& (!iqentry_v[head1])
|
4190 |
|
|
&& (!iqentry_v[head2])
|
4191 |
|
|
&& (!iqentry_v[head3]))
|
4192 |
|
|
)
|
4193 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
4194 |
|
|
((!iqentry_v[head0])
|
4195 |
|
|
&& (!iqentry_v[head1])
|
4196 |
|
|
&& (!iqentry_v[head2])
|
4197 |
|
|
&& (!iqentry_v[head3])
|
4198 |
|
|
&& (!iqentry_v[head4]))
|
4199 |
|
|
)
|
4200 |
|
|
) begin
|
4201 |
|
|
iqentry_fcu_issue[head6] = `TRUE;
|
4202 |
|
|
end
|
4203 |
|
|
|
4204 |
|
|
else if (could_issue[head7] && iqentry_fc[head7]
|
4205 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
4206 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
4207 |
|
|
((!iqentry_v[head0])
|
4208 |
|
|
&& (!iqentry_v[head1]))
|
4209 |
|
|
)
|
4210 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
4211 |
|
|
((!iqentry_v[head0])
|
4212 |
|
|
&& (!iqentry_v[head1])
|
4213 |
|
|
&& (!iqentry_v[head2]))
|
4214 |
|
|
)
|
4215 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
4216 |
|
|
((!iqentry_v[head0])
|
4217 |
|
|
&& (!iqentry_v[head1])
|
4218 |
|
|
&& (!iqentry_v[head2])
|
4219 |
|
|
&& (!iqentry_v[head3]))
|
4220 |
|
|
)
|
4221 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
4222 |
|
|
((!iqentry_v[head0])
|
4223 |
|
|
&& (!iqentry_v[head1])
|
4224 |
|
|
&& (!iqentry_v[head2])
|
4225 |
|
|
&& (!iqentry_v[head3])
|
4226 |
|
|
&& (!iqentry_v[head4]))
|
4227 |
|
|
)
|
4228 |
|
|
&& (!(iqentry_v[head6] && iqentry_sync[head6]) ||
|
4229 |
|
|
((!iqentry_v[head0])
|
4230 |
|
|
&& (!iqentry_v[head1])
|
4231 |
|
|
&& (!iqentry_v[head2])
|
4232 |
|
|
&& (!iqentry_v[head3])
|
4233 |
|
|
&& (!iqentry_v[head4])
|
4234 |
|
|
&& (!iqentry_v[head5]))
|
4235 |
|
|
)
|
4236 |
|
|
) begin
|
4237 |
|
|
iqentry_fcu_issue[head7] = `TRUE;
|
4238 |
|
|
end
|
4239 |
|
|
`endif
|
4240 |
|
|
end
|
4241 |
|
|
end
|
4242 |
|
|
|
4243 |
|
|
//
|
4244 |
|
|
// determine if the instructions ready to issue can, in fact, issue.
|
4245 |
|
|
// "ready" means that the instruction has valid operands but has not gone yet
|
4246 |
|
|
reg [1:0] issue_count, missue_count;
|
4247 |
|
|
always @*
|
4248 |
|
|
begin
|
4249 |
|
|
issue_count = 0;
|
4250 |
|
|
memissue[ head0 ] = iqentry_memready[ head0 ]; // first in line ... go as soon as ready
|
4251 |
|
|
if (memissue[head0])
|
4252 |
|
|
issue_count = issue_count + 1;
|
4253 |
|
|
|
4254 |
|
|
memissue[ head1 ] = ~iqentry_stomp[head1] && iqentry_memready[ head1 ] // addr and data are valid
|
4255 |
|
|
// ... and no preceding instruction is ready to go
|
4256 |
|
|
//&& ~iqentry_memready[head0]
|
4257 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4258 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4259 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head1] != iqentry_a1[head0]))
|
4260 |
|
|
// ... if a release, any prior memory ops must be done before this one
|
4261 |
|
|
&& (iqentry_rl[head1] ? iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0] : 1'b1)
|
4262 |
|
|
// ... if a preivous op has the aquire bit set
|
4263 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4264 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4265 |
|
|
&& (iqentry_load[head1] ||
|
4266 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0]));
|
4267 |
|
|
if (memissue[head1])
|
4268 |
|
|
issue_count = issue_count + 1;
|
4269 |
|
|
|
4270 |
|
|
memissue[ head2 ] = ~iqentry_stomp[head2] && iqentry_memready[ head2 ] // addr and data are valid
|
4271 |
|
|
// ... and no preceding instruction is ready to go
|
4272 |
|
|
//&& ~iqentry_memready[head0]
|
4273 |
|
|
//&& ~iqentry_memready[head1]
|
4274 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4275 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4276 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head2] != iqentry_a1[head0]))
|
4277 |
|
|
&& (!iqentry_mem[head1] || (iqentry_agen[head1] & iqentry_out[head1])
|
4278 |
|
|
|| (iqentry_a1_v[head1] && iqentry_a1[head2] != iqentry_a1[head1]))
|
4279 |
|
|
// ... if a release, any prior memory ops must be done before this one
|
4280 |
|
|
&& (iqentry_rl[head2] ? (iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0])
|
4281 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1] || !iqentry_mem[head1])
|
4282 |
|
|
: 1'b1)
|
4283 |
|
|
// ... if a preivous op has the aquire bit set
|
4284 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4285 |
|
|
&& !(iqentry_aq[head1] && iqentry_v[head1])
|
4286 |
|
|
// ... and there isn't a barrier, or everything before the barrier is done or invalid
|
4287 |
|
|
&& (!(iqentry_v[head1] && iqentry_memsb[head1]) || (iqentry_done[head0] || !iqentry_v[head0]))
|
4288 |
|
|
&& (!(iqentry_v[head1] && iqentry_memdb[head1]) || (!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0]))
|
4289 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4290 |
|
|
&& (iqentry_load[head2] ||
|
4291 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0])
|
4292 |
|
|
&& !(iqentry_fc[head1]||iqentry_canex[head1]));
|
4293 |
|
|
if (memissue[head2])
|
4294 |
|
|
issue_count = issue_count + 1;
|
4295 |
|
|
|
4296 |
|
|
memissue[ head3 ] = ~iqentry_stomp[head3] && iqentry_memready[ head3 ] // addr and data are valid
|
4297 |
|
|
// ... and no preceding instruction is ready to go
|
4298 |
|
|
&& issue_count < 3
|
4299 |
|
|
//&& ~iqentry_memready[head0]
|
4300 |
|
|
//&& ~iqentry_memready[head1]
|
4301 |
|
|
//&& ~iqentry_memready[head2]
|
4302 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4303 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4304 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head3] != iqentry_a1[head0]))
|
4305 |
|
|
&& (!iqentry_mem[head1] || (iqentry_agen[head1] & iqentry_out[head1])
|
4306 |
|
|
|| (iqentry_a1_v[head1] && iqentry_a1[head3] != iqentry_a1[head1]))
|
4307 |
|
|
&& (!iqentry_mem[head2] || (iqentry_agen[head2] & iqentry_out[head2])
|
4308 |
|
|
|| (iqentry_a1_v[head2] && iqentry_a1[head3] != iqentry_a1[head2]))
|
4309 |
|
|
// ... if a release, any prior memory ops must be done before this one
|
4310 |
|
|
&& (iqentry_rl[head3] ? (iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0])
|
4311 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1] || !iqentry_mem[head1])
|
4312 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2] || !iqentry_mem[head2])
|
4313 |
|
|
: 1'b1)
|
4314 |
|
|
// ... if a preivous op has the aquire bit set
|
4315 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4316 |
|
|
&& !(iqentry_aq[head1] && iqentry_v[head1])
|
4317 |
|
|
&& !(iqentry_aq[head2] && iqentry_v[head2])
|
4318 |
|
|
// ... and there isn't a barrier, or everything before the barrier is done or invalid
|
4319 |
|
|
&& (!(iqentry_v[head1] && iqentry_memsb[head1]) || (iqentry_done[head0] || !iqentry_v[head0]))
|
4320 |
|
|
&& (!(iqentry_v[head2] && iqentry_memsb[head2]) ||
|
4321 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4322 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1]))
|
4323 |
|
|
)
|
4324 |
|
|
&& (!(iqentry_v[head1] && iqentry_memdb[head1]) || (!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0]))
|
4325 |
|
|
&& (!(iqentry_v[head2] && iqentry_memdb[head2]) ||
|
4326 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4327 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1]))
|
4328 |
|
|
)
|
4329 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4330 |
|
|
&& (iqentry_load[head3] ||
|
4331 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0])
|
4332 |
|
|
&& !(iqentry_fc[head1]||iqentry_canex[head1])
|
4333 |
|
|
&& !(iqentry_fc[head2]||iqentry_canex[head2]));
|
4334 |
|
|
if (memissue[head3])
|
4335 |
|
|
issue_count = issue_count + 1;
|
4336 |
|
|
|
4337 |
|
|
memissue[ head4 ] = ~iqentry_stomp[head4] && iqentry_memready[ head4 ] // addr and data are valid
|
4338 |
|
|
// ... and no preceding instruction is ready to go
|
4339 |
|
|
&& issue_count < 3
|
4340 |
|
|
//&& ~iqentry_memready[head0]
|
4341 |
|
|
//&& ~iqentry_memready[head1]
|
4342 |
|
|
//&& ~iqentry_memready[head2]
|
4343 |
|
|
//&& ~iqentry_memready[head3]
|
4344 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4345 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4346 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head4] != iqentry_a1[head0]))
|
4347 |
|
|
&& (!iqentry_mem[head1] || (iqentry_agen[head1] & iqentry_out[head1])
|
4348 |
|
|
|| (iqentry_a1_v[head1] && iqentry_a1[head4] != iqentry_a1[head1]))
|
4349 |
|
|
&& (!iqentry_mem[head2] || (iqentry_agen[head2] & iqentry_out[head2])
|
4350 |
|
|
|| (iqentry_a1_v[head2] && iqentry_a1[head4] != iqentry_a1[head2]))
|
4351 |
|
|
&& (!iqentry_mem[head3] || (iqentry_agen[head3] & iqentry_out[head3])
|
4352 |
|
|
|| (iqentry_a1_v[head3] && iqentry_a1[head4] != iqentry_a1[head3]))
|
4353 |
|
|
// ... if a release, any prior memory ops must be done before this one
|
4354 |
|
|
&& (iqentry_rl[head4] ? (iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0])
|
4355 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1] || !iqentry_mem[head1])
|
4356 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2] || !iqentry_mem[head2])
|
4357 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3] || !iqentry_mem[head3])
|
4358 |
|
|
: 1'b1)
|
4359 |
|
|
// ... if a preivous op has the aquire bit set
|
4360 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4361 |
|
|
&& !(iqentry_aq[head1] && iqentry_v[head1])
|
4362 |
|
|
&& !(iqentry_aq[head2] && iqentry_v[head2])
|
4363 |
|
|
&& !(iqentry_aq[head3] && iqentry_v[head3])
|
4364 |
|
|
// ... and there isn't a barrier, or everything before the barrier is done or invalid
|
4365 |
|
|
&& (!(iqentry_v[head1] && iqentry_memsb[head1]) || (iqentry_done[head0] || !iqentry_v[head0]))
|
4366 |
|
|
&& (!(iqentry_v[head2] && iqentry_memsb[head2]) ||
|
4367 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4368 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1]))
|
4369 |
|
|
)
|
4370 |
|
|
&& (!(iqentry_v[head3] && iqentry_memsb[head3]) ||
|
4371 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4372 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4373 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2]))
|
4374 |
|
|
)
|
4375 |
|
|
&& (!(iqentry_v[head1] && iqentry_memdb[head1]) || (!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0]))
|
4376 |
|
|
&& (!(iqentry_v[head2] && iqentry_memdb[head2]) ||
|
4377 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4378 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1]))
|
4379 |
|
|
)
|
4380 |
|
|
&& (!(iqentry_v[head3] && iqentry_memdb[head3]) ||
|
4381 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4382 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4383 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2]))
|
4384 |
|
|
)
|
4385 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4386 |
|
|
&& (iqentry_load[head4] ||
|
4387 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0])
|
4388 |
|
|
&& !(iqentry_fc[head1]||iqentry_canex[head1])
|
4389 |
|
|
&& !(iqentry_fc[head2]||iqentry_canex[head2])
|
4390 |
|
|
&& !(iqentry_fc[head3]||iqentry_canex[head3]));
|
4391 |
|
|
if (memissue[head4])
|
4392 |
|
|
issue_count = issue_count + 1;
|
4393 |
|
|
|
4394 |
|
|
memissue[ head5 ] = ~iqentry_stomp[head5] && iqentry_memready[ head5 ] // addr and data are valid
|
4395 |
|
|
// ... and no preceding instruction is ready to go
|
4396 |
|
|
&& issue_count < 3
|
4397 |
|
|
//&& ~iqentry_memready[head0]
|
4398 |
|
|
//&& ~iqentry_memready[head1]
|
4399 |
|
|
//&& ~iqentry_memready[head2]
|
4400 |
|
|
//&& ~iqentry_memready[head3]
|
4401 |
|
|
//&& ~iqentry_memready[head4]
|
4402 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4403 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4404 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head5] != iqentry_a1[head0]))
|
4405 |
|
|
&& (!iqentry_mem[head1] || (iqentry_agen[head1] & iqentry_out[head1])
|
4406 |
|
|
|| (iqentry_a1_v[head1] && iqentry_a1[head5] != iqentry_a1[head1]))
|
4407 |
|
|
&& (!iqentry_mem[head2] || (iqentry_agen[head2] & iqentry_out[head2])
|
4408 |
|
|
|| (iqentry_a1_v[head2] && iqentry_a1[head5] != iqentry_a1[head2]))
|
4409 |
|
|
&& (!iqentry_mem[head3] || (iqentry_agen[head3] & iqentry_out[head3])
|
4410 |
|
|
|| (iqentry_a1_v[head3] && iqentry_a1[head5] != iqentry_a1[head3]))
|
4411 |
|
|
&& (!iqentry_mem[head4] || (iqentry_agen[head4] & iqentry_out[head4])
|
4412 |
|
|
|| (iqentry_a1_v[head4] && iqentry_a1[head5] != iqentry_a1[head4]))
|
4413 |
|
|
// ... if a release, any prior memory ops must be done before this one
|
4414 |
|
|
&& (iqentry_rl[head5] ? (iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0])
|
4415 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1] || !iqentry_mem[head1])
|
4416 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2] || !iqentry_mem[head2])
|
4417 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3] || !iqentry_mem[head3])
|
4418 |
|
|
&& (iqentry_done[head4] || !iqentry_v[head4] || !iqentry_mem[head4])
|
4419 |
|
|
: 1'b1)
|
4420 |
|
|
// ... if a preivous op has the aquire bit set
|
4421 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4422 |
|
|
&& !(iqentry_aq[head1] && iqentry_v[head1])
|
4423 |
|
|
&& !(iqentry_aq[head2] && iqentry_v[head2])
|
4424 |
|
|
&& !(iqentry_aq[head3] && iqentry_v[head3])
|
4425 |
|
|
&& !(iqentry_aq[head4] && iqentry_v[head4])
|
4426 |
|
|
// ... and there isn't a barrier, or everything before the barrier is done or invalid
|
4427 |
|
|
&& (!(iqentry_v[head1] && iqentry_memsb[head1]) || (iqentry_done[head0] || !iqentry_v[head0]))
|
4428 |
|
|
&& (!(iqentry_v[head2] && iqentry_memsb[head2]) ||
|
4429 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4430 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1]))
|
4431 |
|
|
)
|
4432 |
|
|
&& (!(iqentry_v[head3] && iqentry_memsb[head3]) ||
|
4433 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4434 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4435 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2]))
|
4436 |
|
|
)
|
4437 |
|
|
&& (!(iqentry_v[head4] && iqentry_memsb[head4]) ||
|
4438 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4439 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4440 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2])
|
4441 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3]))
|
4442 |
|
|
)
|
4443 |
|
|
&& (!(iqentry_v[head1] && iqentry_memdb[head1]) || (!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0]))
|
4444 |
|
|
&& (!(iqentry_v[head2] && iqentry_memdb[head2]) ||
|
4445 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4446 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1]))
|
4447 |
|
|
)
|
4448 |
|
|
&& (!(iqentry_v[head3] && iqentry_memdb[head3]) ||
|
4449 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4450 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4451 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2]))
|
4452 |
|
|
)
|
4453 |
|
|
&& (!(iqentry_v[head4] && iqentry_memdb[head4]) ||
|
4454 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4455 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4456 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2])
|
4457 |
|
|
&& (!iqentry_mem[head3] || iqentry_done[head3] || !iqentry_v[head3]))
|
4458 |
|
|
)
|
4459 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4460 |
|
|
&& (iqentry_load[head5] ||
|
4461 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0])
|
4462 |
|
|
&& !(iqentry_fc[head1]||iqentry_canex[head1])
|
4463 |
|
|
&& !(iqentry_fc[head2]||iqentry_canex[head2])
|
4464 |
|
|
&& !(iqentry_fc[head3]||iqentry_canex[head3])
|
4465 |
|
|
&& !(iqentry_fc[head4]||iqentry_canex[head4]));
|
4466 |
|
|
if (memissue[head5])
|
4467 |
|
|
issue_count = issue_count + 1;
|
4468 |
|
|
|
4469 |
|
|
`ifdef FULL_ISSUE_LOGIC
|
4470 |
|
|
memissue[ head6 ] = ~iqentry_stomp[head6] && iqentry_memready[ head6 ] // addr and data are valid
|
4471 |
|
|
// ... and no preceding instruction is ready to go
|
4472 |
|
|
&& issue_count < 3
|
4473 |
|
|
//&& ~iqentry_memready[head0]
|
4474 |
|
|
//&& ~iqentry_memready[head1]
|
4475 |
|
|
//&& ~iqentry_memready[head2]
|
4476 |
|
|
//&& ~iqentry_memready[head3]
|
4477 |
|
|
//&& ~iqentry_memready[head4]
|
4478 |
|
|
//&& ~iqentry_memready[head5]
|
4479 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4480 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4481 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head6] != iqentry_a1[head0]))
|
4482 |
|
|
&& (!iqentry_mem[head1] || (iqentry_agen[head1] & iqentry_out[head1])
|
4483 |
|
|
|| (iqentry_a1_v[head1] && iqentry_a1[head6] != iqentry_a1[head1]))
|
4484 |
|
|
&& (!iqentry_mem[head2] || (iqentry_agen[head2] & iqentry_out[head2])
|
4485 |
|
|
|| (iqentry_a1_v[head2] && iqentry_a1[head6] != iqentry_a1[head2]))
|
4486 |
|
|
&& (!iqentry_mem[head3] || (iqentry_agen[head3] & iqentry_out[head3])
|
4487 |
|
|
|| (iqentry_a1_v[head3] && iqentry_a1[head6] != iqentry_a1[head3]))
|
4488 |
|
|
&& (!iqentry_mem[head4] || (iqentry_agen[head4] & iqentry_out[head4])
|
4489 |
|
|
|| (iqentry_a1_v[head4] && iqentry_a1[head6] != iqentry_a1[head4]))
|
4490 |
|
|
&& (!iqentry_mem[head5] || (iqentry_agen[head5] & iqentry_out[head5])
|
4491 |
|
|
|| (iqentry_a1_v[head5] && iqentry_a1[head6] != iqentry_a1[head5]))
|
4492 |
|
|
&& (iqentry_rl[head6] ? (iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0])
|
4493 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1] || !iqentry_mem[head1])
|
4494 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2] || !iqentry_mem[head2])
|
4495 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3] || !iqentry_mem[head3])
|
4496 |
|
|
&& (iqentry_done[head4] || !iqentry_v[head4] || !iqentry_mem[head4])
|
4497 |
|
|
&& (iqentry_done[head5] || !iqentry_v[head5] || !iqentry_mem[head5])
|
4498 |
|
|
: 1'b1)
|
4499 |
|
|
// ... if a preivous op has the aquire bit set
|
4500 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4501 |
|
|
&& !(iqentry_aq[head1] && iqentry_v[head1])
|
4502 |
|
|
&& !(iqentry_aq[head2] && iqentry_v[head2])
|
4503 |
|
|
&& !(iqentry_aq[head3] && iqentry_v[head3])
|
4504 |
|
|
&& !(iqentry_aq[head4] && iqentry_v[head4])
|
4505 |
|
|
&& !(iqentry_aq[head5] && iqentry_v[head5])
|
4506 |
|
|
// ... and there isn't a barrier, or everything before the barrier is done or invalid
|
4507 |
|
|
&& (!(iqentry_v[head1] && iqentry_memsb[head1]) || (iqentry_done[head0] || !iqentry_v[head0]))
|
4508 |
|
|
&& (!(iqentry_v[head2] && iqentry_memsb[head2]) ||
|
4509 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4510 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1]))
|
4511 |
|
|
)
|
4512 |
|
|
&& (!(iqentry_v[head3] && iqentry_memsb[head3]) ||
|
4513 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4514 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4515 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2]))
|
4516 |
|
|
)
|
4517 |
|
|
&& (!(iqentry_v[head4] && iqentry_memsb[head4]) ||
|
4518 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4519 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4520 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2])
|
4521 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3]))
|
4522 |
|
|
)
|
4523 |
|
|
&& (!(iqentry_v[head5] && iqentry_memsb[head5]) ||
|
4524 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4525 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4526 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2])
|
4527 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3])
|
4528 |
|
|
&& (iqentry_done[head4] || !iqentry_v[head4]))
|
4529 |
|
|
)
|
4530 |
|
|
&& (!(iqentry_v[head1] && iqentry_memdb[head1]) || (!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0]))
|
4531 |
|
|
&& (!(iqentry_v[head2] && iqentry_memdb[head2]) ||
|
4532 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4533 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1]))
|
4534 |
|
|
)
|
4535 |
|
|
&& (!(iqentry_v[head3] && iqentry_memdb[head3]) ||
|
4536 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4537 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4538 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2]))
|
4539 |
|
|
)
|
4540 |
|
|
&& (!(iqentry_v[head4] && iqentry_memdb[head4]) ||
|
4541 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4542 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4543 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2])
|
4544 |
|
|
&& (!iqentry_mem[head3] || iqentry_done[head3] || !iqentry_v[head3]))
|
4545 |
|
|
)
|
4546 |
|
|
&& (!(iqentry_v[head5] && iqentry_memdb[head5]) ||
|
4547 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4548 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4549 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2])
|
4550 |
|
|
&& (!iqentry_mem[head3] || iqentry_done[head3] || !iqentry_v[head3])
|
4551 |
|
|
&& (!iqentry_mem[head4] || iqentry_done[head4] || !iqentry_v[head4]))
|
4552 |
|
|
)
|
4553 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4554 |
|
|
&& (iqentry_load[head6] ||
|
4555 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0])
|
4556 |
|
|
&& !(iqentry_fc[head1]||iqentry_canex[head1])
|
4557 |
|
|
&& !(iqentry_fc[head2]||iqentry_canex[head2])
|
4558 |
|
|
&& !(iqentry_fc[head3]||iqentry_canex[head3])
|
4559 |
|
|
&& !(iqentry_fc[head4]||iqentry_canex[head4])
|
4560 |
|
|
&& !(iqentry_fc[head5]||iqentry_canex[head5]));
|
4561 |
|
|
if (memissue[head6])
|
4562 |
|
|
issue_count = issue_count + 1;
|
4563 |
|
|
|
4564 |
|
|
memissue[ head7 ] = ~iqentry_stomp[head7] && iqentry_memready[ head7 ] // addr and data are valid
|
4565 |
|
|
// ... and no preceding instruction is ready to go
|
4566 |
|
|
&& issue_count < 3
|
4567 |
|
|
//&& ~iqentry_memready[head0]
|
4568 |
|
|
//&& ~iqentry_memready[head1]
|
4569 |
|
|
//&& ~iqentry_memready[head2]
|
4570 |
|
|
//&& ~iqentry_memready[head3]
|
4571 |
|
|
//&& ~iqentry_memready[head4]
|
4572 |
|
|
//&& ~iqentry_memready[head5]
|
4573 |
|
|
//&& ~iqentry_memready[head6]
|
4574 |
|
|
// ... and there is no address-overlap with any preceding instruction
|
4575 |
|
|
&& (!iqentry_mem[head0] || (iqentry_agen[head0] & iqentry_out[head0])
|
4576 |
|
|
|| (iqentry_a1_v[head0] && iqentry_a1[head7] != iqentry_a1[head0]))
|
4577 |
|
|
&& (!iqentry_mem[head1] || (iqentry_agen[head1] & iqentry_out[head1])
|
4578 |
|
|
|| (iqentry_a1_v[head1] && iqentry_a1[head7] != iqentry_a1[head1]))
|
4579 |
|
|
&& (!iqentry_mem[head2] || (iqentry_agen[head2] & iqentry_out[head2])
|
4580 |
|
|
|| (iqentry_a1_v[head2] && iqentry_a1[head7] != iqentry_a1[head2]))
|
4581 |
|
|
&& (!iqentry_mem[head3] || (iqentry_agen[head3] & iqentry_out[head3])
|
4582 |
|
|
|| (iqentry_a1_v[head3] && iqentry_a1[head7] != iqentry_a1[head3]))
|
4583 |
|
|
&& (!iqentry_mem[head4] || (iqentry_agen[head4] & iqentry_out[head4])
|
4584 |
|
|
|| (iqentry_a1_v[head4] && iqentry_a1[head7] != iqentry_a1[head4]))
|
4585 |
|
|
&& (!iqentry_mem[head5] || (iqentry_agen[head5] & iqentry_out[head5])
|
4586 |
|
|
|| (iqentry_a1_v[head5] && iqentry_a1[head7] != iqentry_a1[head5]))
|
4587 |
|
|
&& (!iqentry_mem[head6] || (iqentry_agen[head6] & iqentry_out[head6])
|
4588 |
|
|
|| (iqentry_a1_v[head6] && iqentry_a1[head7] != iqentry_a1[head6]))
|
4589 |
|
|
&& (iqentry_rl[head7] ? (iqentry_done[head0] || !iqentry_v[head0] || !iqentry_mem[head0])
|
4590 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1] || !iqentry_mem[head1])
|
4591 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2] || !iqentry_mem[head2])
|
4592 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3] || !iqentry_mem[head3])
|
4593 |
|
|
&& (iqentry_done[head4] || !iqentry_v[head4] || !iqentry_mem[head4])
|
4594 |
|
|
&& (iqentry_done[head5] || !iqentry_v[head5] || !iqentry_mem[head5])
|
4595 |
|
|
&& (iqentry_done[head6] || !iqentry_v[head6] || !iqentry_mem[head6])
|
4596 |
|
|
: 1'b1)
|
4597 |
|
|
// ... if a preivous op has the aquire bit set
|
4598 |
|
|
&& !(iqentry_aq[head0] && iqentry_v[head0])
|
4599 |
|
|
&& !(iqentry_aq[head1] && iqentry_v[head1])
|
4600 |
|
|
&& !(iqentry_aq[head2] && iqentry_v[head2])
|
4601 |
|
|
&& !(iqentry_aq[head3] && iqentry_v[head3])
|
4602 |
|
|
&& !(iqentry_aq[head4] && iqentry_v[head4])
|
4603 |
|
|
&& !(iqentry_aq[head5] && iqentry_v[head5])
|
4604 |
|
|
&& !(iqentry_aq[head6] && iqentry_v[head6])
|
4605 |
|
|
// ... and there isn't a barrier, or everything before the barrier is done or invalid
|
4606 |
|
|
&& (!(iqentry_v[head1] && iqentry_memsb[head1]) || (iqentry_done[head0] || !iqentry_v[head0]))
|
4607 |
|
|
&& (!(iqentry_v[head2] && iqentry_memsb[head2]) ||
|
4608 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4609 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1]))
|
4610 |
|
|
)
|
4611 |
|
|
&& (!(iqentry_v[head3] && iqentry_memsb[head3]) ||
|
4612 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4613 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4614 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2]))
|
4615 |
|
|
)
|
4616 |
|
|
&& (!(iqentry_v[head4] && iqentry_memsb[head4]) ||
|
4617 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4618 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4619 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2])
|
4620 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3]))
|
4621 |
|
|
)
|
4622 |
|
|
&& (!(iqentry_v[head5] && iqentry_memsb[head5]) ||
|
4623 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4624 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4625 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2])
|
4626 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3])
|
4627 |
|
|
&& (iqentry_done[head4] || !iqentry_v[head4]))
|
4628 |
|
|
)
|
4629 |
|
|
&& (!(iqentry_v[head6] && iqentry_memsb[head6]) ||
|
4630 |
|
|
((iqentry_done[head0] || !iqentry_v[head0])
|
4631 |
|
|
&& (iqentry_done[head1] || !iqentry_v[head1])
|
4632 |
|
|
&& (iqentry_done[head2] || !iqentry_v[head2])
|
4633 |
|
|
&& (iqentry_done[head3] || !iqentry_v[head3])
|
4634 |
|
|
&& (iqentry_done[head4] || !iqentry_v[head4])
|
4635 |
|
|
&& (iqentry_done[head5] || !iqentry_v[head5]))
|
4636 |
|
|
)
|
4637 |
|
|
&& (!(iqentry_v[head1] && iqentry_memdb[head1]) || (!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0]))
|
4638 |
|
|
&& (!(iqentry_v[head2] && iqentry_memdb[head2]) ||
|
4639 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4640 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1]))
|
4641 |
|
|
)
|
4642 |
|
|
&& (!(iqentry_v[head3] && iqentry_memdb[head3]) ||
|
4643 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4644 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4645 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2]))
|
4646 |
|
|
)
|
4647 |
|
|
&& (!(iqentry_v[head4] && iqentry_memdb[head4]) ||
|
4648 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4649 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4650 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2])
|
4651 |
|
|
&& (!iqentry_mem[head3] || iqentry_done[head3] || !iqentry_v[head3]))
|
4652 |
|
|
)
|
4653 |
|
|
&& (!(iqentry_v[head5] && iqentry_memdb[head5]) ||
|
4654 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4655 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4656 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2])
|
4657 |
|
|
&& (!iqentry_mem[head3] || iqentry_done[head3] || !iqentry_v[head3])
|
4658 |
|
|
&& (!iqentry_mem[head4] || iqentry_done[head4] || !iqentry_v[head4]))
|
4659 |
|
|
)
|
4660 |
|
|
&& (!(iqentry_v[head6] && iqentry_memdb[head6]) ||
|
4661 |
|
|
((!iqentry_mem[head0] || iqentry_done[head0] || !iqentry_v[head0])
|
4662 |
|
|
&& (!iqentry_mem[head1] || iqentry_done[head1] || !iqentry_v[head1])
|
4663 |
|
|
&& (!iqentry_mem[head2] || iqentry_done[head2] || !iqentry_v[head2])
|
4664 |
|
|
&& (!iqentry_mem[head3] || iqentry_done[head3] || !iqentry_v[head3])
|
4665 |
|
|
&& (!iqentry_mem[head4] || iqentry_done[head4] || !iqentry_v[head4])
|
4666 |
|
|
&& (!iqentry_mem[head5] || iqentry_done[head5] || !iqentry_v[head5]))
|
4667 |
|
|
)
|
4668 |
|
|
// ... and, if it is a SW, there is no chance of it being undone
|
4669 |
|
|
&& (iqentry_load[head7] ||
|
4670 |
|
|
!(iqentry_fc[head0]||iqentry_canex[head0])
|
4671 |
|
|
&& !(iqentry_fc[head1]||iqentry_canex[head1])
|
4672 |
|
|
&& !(iqentry_fc[head2]||iqentry_canex[head2])
|
4673 |
|
|
&& !(iqentry_fc[head3]||iqentry_canex[head3])
|
4674 |
|
|
&& !(iqentry_fc[head4]||iqentry_canex[head4])
|
4675 |
|
|
&& !(iqentry_fc[head5]||iqentry_canex[head5])
|
4676 |
|
|
&& !(iqentry_fc[head6]||iqentry_canex[head6]));
|
4677 |
|
|
`endif
|
4678 |
|
|
end
|
4679 |
|
|
|
4680 |
|
|
// Stomp logic for branch miss.
|
4681 |
|
|
|
4682 |
|
|
FT64_stomp #(QENTRIES) ustmp1
|
4683 |
|
|
(
|
4684 |
|
|
.branchmiss(branchmiss),
|
4685 |
|
|
.branchmiss_thrd(branchmiss_thrd),
|
4686 |
|
|
.missid(missid),
|
4687 |
|
|
.head0(head0),
|
4688 |
|
|
.thread_en(thread_en),
|
4689 |
|
|
.thrd(iqentry_thrd),
|
4690 |
|
|
.iqentry_v(iqentry_v),
|
4691 |
|
|
.stomp(iqentry_stomp)
|
4692 |
|
|
);
|
4693 |
|
|
|
4694 |
|
|
always @*
|
4695 |
|
|
begin
|
4696 |
|
|
if (iqentry_stomp[0] && IsRet(iqentry_instr[0]))
|
4697 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4698 |
|
|
if (iqentry_stomp[1] && IsRet(iqentry_instr[1]))
|
4699 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4700 |
|
|
if (iqentry_stomp[2] && IsRet(iqentry_instr[2]))
|
4701 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4702 |
|
|
if (iqentry_stomp[3] && IsRet(iqentry_instr[3]))
|
4703 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4704 |
|
|
if (iqentry_stomp[4] && IsRet(iqentry_instr[4]))
|
4705 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4706 |
|
|
if (iqentry_stomp[5] && IsRet(iqentry_instr[5]))
|
4707 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4708 |
|
|
if (iqentry_stomp[6] && IsRet(iqentry_instr[6]))
|
4709 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4710 |
|
|
if (iqentry_stomp[7] && IsRet(iqentry_instr[7]))
|
4711 |
|
|
stompedOnRets = stompedOnRets + 4'd1;
|
4712 |
|
|
end
|
4713 |
|
|
|
4714 |
|
|
//
|
4715 |
|
|
// EXECUTE
|
4716 |
|
|
//
|
4717 |
|
|
reg [63:0] csr_r;
|
4718 |
|
|
always @*
|
4719 |
|
|
read_csr(alu0_instr[29:16],csr_r,alu0_thrd);
|
4720 |
|
|
FT64alu #(.BIG(1'b1),.SUP_VECTOR(SUP_VECTOR)) ualu0 (
|
4721 |
|
|
.rst(rst),
|
4722 |
|
|
.clk(clk),
|
4723 |
|
|
.ld(alu0_ld),
|
4724 |
|
|
.abort(1'b0),
|
4725 |
|
|
.instr(alu0_instr),
|
4726 |
|
|
.a(alu0_argA),
|
4727 |
|
|
.b(alu0_argB),
|
4728 |
|
|
.c(alu0_argC),
|
4729 |
|
|
.imm(alu0_argI),
|
4730 |
|
|
.tgt(alu0_tgt),
|
4731 |
|
|
.ven(alu0_ven),
|
4732 |
|
|
.vm(vm[alu0_instr[24:23]]),
|
4733 |
|
|
.sbl(sbl),
|
4734 |
|
|
.sbu(sbu),
|
4735 |
|
|
.csr(csr_r),
|
4736 |
|
|
.o(alu0_bus),
|
4737 |
|
|
.ob(alu0b_bus),
|
4738 |
|
|
.done(alu0_done),
|
4739 |
|
|
.idle(alu0_idle),
|
4740 |
|
|
.excen(aec[4:0]),
|
4741 |
|
|
.exc(alu0_exc),
|
4742 |
|
|
.thrd(alu0_thrd)
|
4743 |
|
|
);
|
4744 |
|
|
FT64alu #(.BIG(1'b0),.SUP_VECTOR(SUP_VECTOR)) ualu1 (
|
4745 |
|
|
.rst(rst),
|
4746 |
|
|
.clk(clk),
|
4747 |
|
|
.ld(alu1_ld),
|
4748 |
|
|
.abort(1'b0),
|
4749 |
|
|
.instr(alu1_instr),
|
4750 |
|
|
.a(alu1_argA),
|
4751 |
|
|
.b(alu1_argB),
|
4752 |
|
|
.c(alu1_argC),
|
4753 |
|
|
.imm(alu1_argI),
|
4754 |
|
|
.tgt(alu1_tgt),
|
4755 |
|
|
.ven(alu1_ven),
|
4756 |
|
|
.vm(vm[alu1_instr[24:23]]),
|
4757 |
|
|
.sbl(sbl),
|
4758 |
|
|
.sbu(sbu),
|
4759 |
|
|
.csr(64'd0),
|
4760 |
|
|
.o(alu1_bus),
|
4761 |
|
|
.ob(alu1b_bus),
|
4762 |
|
|
.done(alu1_done),
|
4763 |
|
|
.idle(alu1_idle),
|
4764 |
|
|
.excen(aec[4:0]),
|
4765 |
|
|
.exc(alu1_exc),
|
4766 |
|
|
.thrd(1'b0)
|
4767 |
|
|
);
|
4768 |
|
|
fpUnit ufp1
|
4769 |
|
|
(
|
4770 |
|
|
.rst(rst),
|
4771 |
|
|
.clk(clk),
|
4772 |
|
|
.clk4x(clk4x),
|
4773 |
|
|
.ce(1'b1),
|
4774 |
|
|
.ir(fpu_instr),
|
4775 |
|
|
.ld(fpu_ld),
|
4776 |
|
|
.a(fpu_argA),
|
4777 |
|
|
.b(fpu_argB),
|
4778 |
|
|
.imm(fpu_argI),
|
4779 |
|
|
.o(fpu_bus),
|
4780 |
|
|
.csr_i(),
|
4781 |
|
|
.status(fpu_status),
|
4782 |
|
|
.exception(),
|
4783 |
|
|
.done(fpu_done)
|
4784 |
|
|
);
|
4785 |
|
|
assign fpu_exc = |fpu_status[15:0] ? `FLT_FLT : `FLT_NONE;
|
4786 |
|
|
|
4787 |
|
|
assign alu0_v = alu0_dataready,
|
4788 |
|
|
alu1_v = alu1_dataready;
|
4789 |
|
|
assign alu0_id = alu0_sourceid,
|
4790 |
|
|
alu1_id = alu1_sourceid;
|
4791 |
|
|
assign fpu_v = fpu_dataready;
|
4792 |
|
|
assign fpu_id = fpu_sourceid;
|
4793 |
|
|
|
4794 |
|
|
assign fcu_v = fcu_dataready;
|
4795 |
|
|
assign fcu_id = fcu_sourceid;
|
4796 |
|
|
|
4797 |
|
|
wire [4:0] fcmpo;
|
4798 |
|
|
wire fnanx;
|
4799 |
|
|
fp_cmp_unit ufcmp1 (fcu_argA, fcu_argB, fcmpo, fnanx);
|
4800 |
|
|
|
4801 |
|
|
wire fcu_takb;
|
4802 |
|
|
|
4803 |
|
|
always @*
|
4804 |
|
|
begin
|
4805 |
|
|
fcu_exc <= `FLT_NONE;
|
4806 |
|
|
casez(fcu_instr[`INSTRUCTION_OP])
|
4807 |
|
|
`CHK: begin
|
4808 |
|
|
if (fcu_instr[21])
|
4809 |
|
|
fcu_exc <= fcu_argA >= fcu_argB && fcu_argA < fcu_argC ? `FLT_NONE : `FLT_CHK;
|
4810 |
|
|
end
|
4811 |
|
|
`REX:
|
4812 |
|
|
case(ol[fcu_thrd])
|
4813 |
|
|
`OL_USER: fcu_exc <= `FLT_PRIV;
|
4814 |
|
|
default: ;
|
4815 |
|
|
endcase
|
4816 |
|
|
endcase
|
4817 |
|
|
end
|
4818 |
|
|
|
4819 |
|
|
FT64_EvalBranch ube1
|
4820 |
|
|
(
|
4821 |
|
|
.instr(fcu_instr),
|
4822 |
|
|
.a(fcu_argA),
|
4823 |
|
|
.b(fcu_argB),
|
4824 |
|
|
.c(fcu_argC),
|
4825 |
|
|
.takb(fcu_takb)
|
4826 |
|
|
);
|
4827 |
|
|
|
4828 |
|
|
FT64_FCU_Calc ufcuc1
|
4829 |
|
|
(
|
4830 |
|
|
.ol(ol[fcu_thrd]),
|
4831 |
|
|
.instr(fcu_instr),
|
4832 |
|
|
.tvec(tvec[fcu_instr[13:11]]),
|
4833 |
|
|
.a(fcu_argA),
|
4834 |
|
|
.i(fcu_argI),
|
4835 |
|
|
.pc(fcu_pc),
|
4836 |
|
|
.im(im),
|
4837 |
|
|
.waitctr(waitctr),
|
4838 |
|
|
.bus(fcu_bus)
|
4839 |
|
|
);
|
4840 |
|
|
|
4841 |
|
|
assign fcu_misspc =
|
4842 |
|
|
IsRTI(fcu_instr) ? fcu_argB :
|
4843 |
|
|
(fcu_instr[`INSTRUCTION_OP] == `REX) ? fcu_bus :
|
4844 |
|
|
(IsBrk(fcu_instr)) ? {tvec[0][31:8], ol[fcu_thrd], 5'h0} :
|
4845 |
|
|
(IsRet(fcu_instr)) ? fcu_argB:
|
4846 |
|
|
(IsJAL(fcu_instr)) ? fcu_argA + fcu_argI:
|
4847 |
|
|
(fcu_instr[`INSTRUCTION_OP] == `CHK) ? (fcu_pc + 32'd4 + fcu_argI) :
|
4848 |
|
|
(fcu_instr[`INSTRUCTION_OP] == `BccR) ? (~fcu_takb ? fcu_pc + 4 : fcu_argC) :
|
4849 |
|
|
(~fcu_takb ? fcu_pc + 4 : fcu_pc + 4 +
|
4850 |
|
|
{{51{fcu_instr[`INSTRUCTION_SB]}},fcu_instr[31:22],fcu_instr[0],2'b00});
|
4851 |
|
|
//fcu_argI);
|
4852 |
|
|
|
4853 |
|
|
// To avoid false branch mispredicts the branch isn't evaluated until the
|
4854 |
|
|
// following instruction queues. The address of the next instruction is
|
4855 |
|
|
// looked at to see if the BTB predicted correctly.
|
4856 |
|
|
|
4857 |
|
|
wire fcu_brk_miss = (IsBrk(fcu_instr) || IsRTI(fcu_instr)) && fcu_v;
|
4858 |
|
|
wire fcu_ret_miss = IsRet(fcu_instr) && fcu_v && (fcu_argB != iqentry_pc[thread_en ? idp2(fcu_id) : idp1(fcu_id)]);
|
4859 |
|
|
wire fcu_jal_miss = IsJAL(fcu_instr) && fcu_v && fcu_argA + fcu_argI != iqentry_pc[thread_en ? idp2(fcu_id) : idp1(fcu_id)];
|
4860 |
|
|
wire fcu_followed = iqentry_sn[nid] > iqentry_sn[fcu_id[`QBITS]];
|
4861 |
|
|
always @*
|
4862 |
|
|
if (fcu_dataready) begin
|
4863 |
|
|
// if (fcu_timeout[7])
|
4864 |
|
|
// fcu_branchmiss = TRUE;
|
4865 |
|
|
// Break and RTI switch register sets, and so are always treated as a branch miss in order to
|
4866 |
|
|
// flush the pipeline. Hardware interrupts also stream break instructions so they need to
|
4867 |
|
|
// flushed from the queue so the interrupt is recognized only once.
|
4868 |
|
|
// BRK and RTI are handled as excmiss types which are processed during the commit stage.
|
4869 |
|
|
// else
|
4870 |
|
|
if (fcu_brk_miss)
|
4871 |
|
|
fcu_branchmiss = TRUE;
|
4872 |
|
|
// the following instruction is queued
|
4873 |
|
|
else
|
4874 |
|
|
if (fcu_followed) begin
|
4875 |
|
|
if (fcu_instr[`INSTRUCTION_OP] == `REX && (im < ~ol[fcu_thrd]) && fcu_v)
|
4876 |
|
|
fcu_branchmiss = TRUE;
|
4877 |
|
|
else if (fcu_ret_miss)
|
4878 |
|
|
fcu_branchmiss = TRUE;
|
4879 |
|
|
else if (IsBranch(fcu_instr) && fcu_v && (((fcu_takb && (~fcu_bt || (fcu_misspc != iqentry_pc[nid]))) ||
|
4880 |
|
|
(~fcu_takb && ( fcu_bt || (fcu_pc + 32'd4 != iqentry_pc[nid])))) || iqentry_v[nid]))
|
4881 |
|
|
fcu_branchmiss = TRUE;
|
4882 |
|
|
else if (fcu_jal_miss)
|
4883 |
|
|
fcu_branchmiss = TRUE;
|
4884 |
|
|
else if (fcu_instr[`INSTRUCTION_OP] == `CHK && ~fcu_takb && fcu_v)
|
4885 |
|
|
fcu_branchmiss = TRUE;
|
4886 |
|
|
else
|
4887 |
|
|
fcu_branchmiss = FALSE;
|
4888 |
|
|
end
|
4889 |
|
|
else begin
|
4890 |
|
|
// Stuck at the head and can't finish because there's still an uncommitted instruction in the queue.
|
4891 |
|
|
// -> cause a branch miss to clear the queue.
|
4892 |
|
|
if (iqentry_v[nid] && !IsCall(fcu_instr) && !IsJmp(fcu_instr) && fcu_v)
|
4893 |
|
|
fcu_branchmiss = TRUE;
|
4894 |
|
|
else
|
4895 |
|
|
/*
|
4896 |
|
|
if (fcu_id==head0 && iqentry_v[idp1(head0)]) begin
|
4897 |
|
|
if ((fcu_bus[0] && (~fcu_bt || (fcu_misspc == iqentry_pc[nid]))) ||
|
4898 |
|
|
(~fcu_bus[0] && ( fcu_bt || (fcu_pc + 32'd4 == iqentry_pc[nid]))))
|
4899 |
|
|
fcu_branchmiss = FALSE;
|
4900 |
|
|
else
|
4901 |
|
|
fcu_branchmiss = TRUE;
|
4902 |
|
|
end
|
4903 |
|
|
else if (fcu_id==head1 && iqentry_v[idp2(head1)]) begin
|
4904 |
|
|
if ((fcu_bus[0] && (~fcu_bt || (fcu_misspc == iqentry_pc[nid]))) ||
|
4905 |
|
|
(~fcu_bus[0] && ( fcu_bt || (fcu_pc + 32'd4 == iqentry_pc[nid]))))
|
4906 |
|
|
fcu_branchmiss = FALSE;
|
4907 |
|
|
else
|
4908 |
|
|
fcu_branchmiss = TRUE;
|
4909 |
|
|
end
|
4910 |
|
|
else*/
|
4911 |
|
|
fcu_branchmiss = FALSE;
|
4912 |
|
|
end
|
4913 |
|
|
end
|
4914 |
|
|
else
|
4915 |
|
|
fcu_branchmiss = FALSE;
|
4916 |
|
|
/*
|
4917 |
|
|
assign fcu_branchmiss = fcu_dataready &&
|
4918 |
|
|
// and the following instruction is queued
|
4919 |
|
|
iqentry_v[idp1(fcu_id)] && iqentry_sn[idp1(fcu_id)]==iqentry_sn[fcu_id[`QBITS]]+5'd1 &&
|
4920 |
|
|
((IsBrk(fcu_instr) || IsRTI(fcu_instr)) ||
|
4921 |
|
|
((fcu_instr[`INSTRUCTION_OP] == `REX && (im < ~ol)) ||
|
4922 |
|
|
(fcu_instr[`INSTRUCTION_OP] == `CHK && ~fcu_bus[0]) ||
|
4923 |
|
|
(IsRTI(fcu_instr) && epc != iqentry_pc[idp1(fcu_id[`QBITS])]) ||
|
4924 |
|
|
// If it's a ret and the return address doesn't match the address of the
|
4925 |
|
|
// next queued instruction then the return prediction was wrong.
|
4926 |
|
|
(/*IsRet(fcu_instr) &&
|
4927 |
|
|
IsRet(fcu_instr) && ((fcu_argB != iqentry_pc[idp1(fcu_id)]) || (iqentry_sn[fcu_id[`QBITS]]+5'd1!=iqentry_sn[idp1(fcu_id)]) || !iqentry_v[idp1(fcu_id)])) ||
|
4928 |
|
|
(IsBrk(fcu_instr) && {tvec[0][31:8], ol, 5'h0} != iqentry_pc[idp1(fcu_id)]) ||
|
4929 |
|
|
// (fcu_instr[`INSTRUCTION_OP] == `BccR && fcu_argC != iqentry_pc[(fcu_id[`QBITS]+3'd1)&7] && fcu_bus[0]) ||
|
4930 |
|
|
(IsBranch(fcu_instr) && ((fcu_bus[0] && (~fcu_bt || (fcu_misspc != iqentry_pc[idp1(fcu_id)]))) ||
|
4931 |
|
|
(~fcu_bus[0] && ( fcu_bt || (fcu_pc + 32'd4 != iqentry_pc[idp1(fcu_id)]))))) ||
|
4932 |
|
|
(IsJAL(fcu_instr)) && fcu_argA + fcu_argI != iqentry_pc[idp1(fcu_id)]));
|
4933 |
|
|
*/
|
4934 |
|
|
|
4935 |
|
|
// Flow control ops don't issue until the next instruction queues.
|
4936 |
|
|
// The fcu_timeout tracks how long the flow control op has been in the "out" state.
|
4937 |
|
|
// It should never be that way more than a couple of cycles. Sometimes the fcu_wr pulse got missed
|
4938 |
|
|
// because the following instruction got stomped on during a branchmiss, hence iqentry_v isn't true.
|
4939 |
|
|
wire fcu_wr = (fcu_v && iqentry_v[nid] && iqentry_sn[nid] > iqentry_sn[fcu_id[`QBITS]] // && iqentry_v[nid]
|
4940 |
|
|
&& fcu_instr==iqentry_instr[fcu_id[`QBITS]]) || fcu_timeout==8'h05;
|
4941 |
|
|
|
4942 |
|
|
FT64_AMO_alu uamoalu0 (amo_instr, amo_argA, amo_argB, amo_res);
|
4943 |
|
|
|
4944 |
|
|
//assign fcu_done = IsWait(fcu_instr) ? ((waitctr==64'd1) || signal_i[fcu_argA[4:0]|fcu_argI[4:0]]) :
|
4945 |
|
|
// fcu_v && iqentry_v[idp1(fcu_id)] && iqentry_sn[idp1(fcu_id)]==iqentry_sn[fcu_id[`QBITS]]+5'd1;
|
4946 |
|
|
|
4947 |
|
|
// An exception in a committing instruction takes precedence
|
4948 |
|
|
assign branchmiss = excmiss|fcu_branchmiss,
|
4949 |
|
|
misspc = excmiss ? excmisspc : fcu_misspc,
|
4950 |
|
|
missid = excmiss ? (|iqentry_exc[head0] ? head0 : head1) : fcu_sourceid;
|
4951 |
|
|
assign branchmiss_thrd = excmiss ? excthrd : fcu_thrd;
|
4952 |
|
|
|
4953 |
|
|
//
|
4954 |
|
|
// additional DRAM-enqueue logic
|
4955 |
|
|
|
4956 |
|
|
assign dram_avail = (dram0 == `DRAMSLOT_AVAIL || dram1 == `DRAMSLOT_AVAIL || dram2 == `DRAMSLOT_AVAIL);
|
4957 |
|
|
|
4958 |
|
|
assign iqentry_memopsvalid[0] = (iqentry_mem[0] & iqentry_a2_v[0] & iqentry_agen[0]),
|
4959 |
|
|
iqentry_memopsvalid[1] = (iqentry_mem[1] & iqentry_a2_v[1] & iqentry_agen[1]),
|
4960 |
|
|
iqentry_memopsvalid[2] = (iqentry_mem[2] & iqentry_a2_v[2] & iqentry_agen[2]),
|
4961 |
|
|
iqentry_memopsvalid[3] = (iqentry_mem[3] & iqentry_a2_v[3] & iqentry_agen[3]),
|
4962 |
|
|
iqentry_memopsvalid[4] = (iqentry_mem[4] & iqentry_a2_v[4] & iqentry_agen[4]),
|
4963 |
|
|
iqentry_memopsvalid[5] = (iqentry_mem[5] & iqentry_a2_v[5] & iqentry_agen[5]),
|
4964 |
|
|
iqentry_memopsvalid[6] = (iqentry_mem[6] & iqentry_a2_v[6] & iqentry_agen[6]),
|
4965 |
|
|
iqentry_memopsvalid[7] = (iqentry_mem[7] & iqentry_a2_v[7] & iqentry_agen[7]);
|
4966 |
|
|
|
4967 |
|
|
assign iqentry_memready[0] = (iqentry_v[0] & iqentry_memopsvalid[0] & ~iqentry_memissue[0] & ~iqentry_done[0] & ~iqentry_out[0] & ~iqentry_stomp[0]),
|
4968 |
|
|
iqentry_memready[1] = (iqentry_v[1] & iqentry_memopsvalid[1] & ~iqentry_memissue[1] & ~iqentry_done[1] & ~iqentry_out[1] & ~iqentry_stomp[1]),
|
4969 |
|
|
iqentry_memready[2] = (iqentry_v[2] & iqentry_memopsvalid[2] & ~iqentry_memissue[2] & ~iqentry_done[2] & ~iqentry_out[2] & ~iqentry_stomp[2]),
|
4970 |
|
|
iqentry_memready[3] = (iqentry_v[3] & iqentry_memopsvalid[3] & ~iqentry_memissue[3] & ~iqentry_done[3] & ~iqentry_out[3] & ~iqentry_stomp[3]),
|
4971 |
|
|
iqentry_memready[4] = (iqentry_v[4] & iqentry_memopsvalid[4] & ~iqentry_memissue[4] & ~iqentry_done[4] & ~iqentry_out[4] & ~iqentry_stomp[4]),
|
4972 |
|
|
iqentry_memready[5] = (iqentry_v[5] & iqentry_memopsvalid[5] & ~iqentry_memissue[5] & ~iqentry_done[5] & ~iqentry_out[5] & ~iqentry_stomp[5]),
|
4973 |
|
|
iqentry_memready[6] = (iqentry_v[6] & iqentry_memopsvalid[6] & ~iqentry_memissue[6] & ~iqentry_done[6] & ~iqentry_out[6] & ~iqentry_stomp[6]),
|
4974 |
|
|
iqentry_memready[7] = (iqentry_v[7] & iqentry_memopsvalid[7] & ~iqentry_memissue[7] & ~iqentry_done[7] & ~iqentry_out[7] & ~iqentry_stomp[7]);
|
4975 |
|
|
|
4976 |
|
|
assign outstanding_stores = (dram0 && IsStore(dram0_instr)) ||
|
4977 |
|
|
(dram1 && IsStore(dram1_instr)) ||
|
4978 |
|
|
(dram2 && IsStore(dram2_instr));
|
4979 |
|
|
|
4980 |
|
|
//
|
4981 |
|
|
// additional COMMIT logic
|
4982 |
|
|
//
|
4983 |
|
|
always @*
|
4984 |
|
|
begin
|
4985 |
|
|
commit0_v <= ({iqentry_v[head0], iqentry_cmt[head0]} == 2'b11 && ~|panic);
|
4986 |
|
|
commit0_id <= {iqentry_mem[head0], head0}; // if a memory op, it has a DRAM-bus id
|
4987 |
|
|
commit0_tgt <= iqentry_tgt[head0];
|
4988 |
|
|
commit0_we <= iqentry_we[head0];
|
4989 |
|
|
commit0_bus <= iqentry_res[head0];
|
4990 |
|
|
commit1_v <= ({iqentry_v[head0], iqentry_cmt[head0]} != 2'b10
|
4991 |
|
|
&& {iqentry_v[head1], iqentry_cmt[head1]} == 2'b11
|
4992 |
|
|
&& ~|panic);
|
4993 |
|
|
commit1_id <= {iqentry_mem[head1], head1};
|
4994 |
|
|
commit1_tgt <= iqentry_tgt[head1];
|
4995 |
|
|
commit1_we <= iqentry_we[head1];
|
4996 |
|
|
commit1_bus <= iqentry_res[head1];
|
4997 |
|
|
end
|
4998 |
|
|
|
4999 |
|
|
assign int_commit = (commit0_v && IsBrk(iqentry_instr[head0])) ||
|
5000 |
|
|
(commit0_v && commit1_v && IsBrk(iqentry_instr[head1]));
|
5001 |
|
|
|
5002 |
|
|
// Detect if a given register will become valid during the current cycle.
|
5003 |
|
|
// We want a signal that is active during the current clock cycle for the read
|
5004 |
|
|
// through register file, which trims a cycle off register access for every
|
5005 |
|
|
// instruction. But two different kinds of assignment statements can't be
|
5006 |
|
|
// placed under the same always block, it's a bad practice and may not work.
|
5007 |
|
|
// So a signal is created here with it's own always block.
|
5008 |
|
|
reg [AREGS-1:0] regIsValid;
|
5009 |
|
|
always @*
|
5010 |
|
|
begin
|
5011 |
|
|
for (n = 1; n < AREGS; n = n + 1)
|
5012 |
|
|
begin
|
5013 |
|
|
regIsValid[n] = rf_v[n];
|
5014 |
|
|
if (branchmiss)
|
5015 |
|
|
if (~livetarget[n]) begin
|
5016 |
|
|
if (branchmiss_thrd & thread_en) begin
|
5017 |
|
|
if (n >= 128)
|
5018 |
|
|
regIsValid[n] = `VAL;
|
5019 |
|
|
end
|
5020 |
|
|
else begin
|
5021 |
|
|
if (n < 128 | ~thread_en)
|
5022 |
|
|
regIsValid[n] = `VAL;
|
5023 |
|
|
end
|
5024 |
|
|
end
|
5025 |
|
|
if (commit0_v && n=={commit0_tgt[7:0]})
|
5026 |
|
|
regIsValid[n] = regIsValid[n] | (rf_source[ {commit0_tgt[7:0]} ] == commit0_id
|
5027 |
|
|
|| (branchmiss && branchmiss_thrd == iqentry_thrd[commit0_id[`QBITS]] && iqentry_source[ commit0_id[`QBITS] ]));
|
5028 |
|
|
if (commit1_v && n=={commit1_tgt[7:0]})
|
5029 |
|
|
regIsValid[n] = regIsValid[n] | (rf_source[ {commit1_tgt[7:0]} ] == commit1_id
|
5030 |
|
|
|| (branchmiss && branchmiss_thrd == iqentry_thrd[commit0_id[`QBITS]] && iqentry_source[ commit1_id[`QBITS] ]));
|
5031 |
|
|
end
|
5032 |
|
|
regIsValid[0] = `VAL;
|
5033 |
|
|
end
|
5034 |
|
|
|
5035 |
|
|
// Wait until the cycle after Ra becomes valid to give time to read
|
5036 |
|
|
// the vector element from the register file.
|
5037 |
|
|
reg rf_vra0, rf_vra1;
|
5038 |
|
|
/*always @(posedge clk)
|
5039 |
|
|
rf_vra0 <= regIsValid[Ra0s];
|
5040 |
|
|
always @(posedge clk)
|
5041 |
|
|
rf_vra1 <= regIsValid[Ra1s];
|
5042 |
|
|
*/
|
5043 |
|
|
// Check how many instructions can be queued. This might be fewer than the
|
5044 |
|
|
// number ready to queue from the fetch stage if queue slots aren't
|
5045 |
|
|
// available or if there are no more physical registers left for remapping.
|
5046 |
|
|
// The fetch stage needs to know how many instructions will queue so this
|
5047 |
|
|
// logic is placed here.
|
5048 |
|
|
// NOPs are filtered out and do not enter the instruction queue. The core
|
5049 |
|
|
// will stream NOPs on a cache miss and they would mess up the queue order
|
5050 |
|
|
// if there are immediate prefixes in the queue.
|
5051 |
|
|
// For the VEX instruction, the instruction can't queue until register Ra
|
5052 |
|
|
// is valid, because register Ra is used to specify the vector element to
|
5053 |
|
|
// read.
|
5054 |
|
|
wire q2open = iqentry_v[tail0]==`INV && iqentry_v[tail1]==`INV;
|
5055 |
|
|
wire q3open = iqentry_v[tail0]==`INV && iqentry_v[tail1]==`INV && iqentry_v[idp1(tail1)]==`INV;
|
5056 |
|
|
always @*
|
5057 |
|
|
begin
|
5058 |
|
|
canq1 <= FALSE;
|
5059 |
|
|
canq2 <= FALSE;
|
5060 |
|
|
queued1 <= FALSE;
|
5061 |
|
|
queued2 <= FALSE;
|
5062 |
|
|
queuedNop <= FALSE;
|
5063 |
|
|
vqueued2 <= FALSE;
|
5064 |
|
|
if (!branchmiss) begin
|
5065 |
|
|
// Two available
|
5066 |
|
|
if (fetchbuf1_v & fetchbuf0_v) begin
|
5067 |
|
|
// Is there a pair of NOPs ? (cache miss)
|
5068 |
|
|
if ((fetchbuf0_instr[`INSTRUCTION_OP]==`NOP) && (fetchbuf1_instr[`INSTRUCTION_OP]==`NOP))
|
5069 |
|
|
queuedNop <= TRUE;
|
5070 |
|
|
else begin
|
5071 |
|
|
// If it's a predicted branch queue only the first instruction, the second
|
5072 |
|
|
// instruction will be stomped on.
|
5073 |
|
|
if (take_branch0 && fetchbuf1_thrd==fetchbuf0_thrd) begin
|
5074 |
|
|
if (iqentry_v[tail0]==`INV) begin
|
5075 |
|
|
canq1 <= TRUE;
|
5076 |
|
|
queued1 <= TRUE;
|
5077 |
|
|
end
|
5078 |
|
|
end
|
5079 |
|
|
// This is where a single NOP is allowed through to simplify the code. A
|
5080 |
|
|
// single NOP can't be a cache miss. Otherwise it would be necessary to queue
|
5081 |
|
|
// fetchbuf1 on tail0 it would add a nightmare to the enqueue code.
|
5082 |
|
|
// Not a branch and there are two instructions fetched, see whether or not
|
5083 |
|
|
// both instructions can be queued.
|
5084 |
|
|
else begin
|
5085 |
|
|
if (iqentry_v[tail0]==`INV) begin
|
5086 |
|
|
canq1 <= !IsVex(fetchbuf0_instr) || rf_vra0 || !SUP_VECTOR;
|
5087 |
|
|
queued1 <= (
|
5088 |
|
|
((!IsVex(fetchbuf0_instr) || rf_vra0) && (!IsVector(fetchbuf0_instr))) || !SUP_VECTOR);
|
5089 |
|
|
if (iqentry_v[tail1]==`INV) begin
|
5090 |
|
|
canq2 <= ((!IsVex(fetchbuf1_instr) || rf_vra1)) || !SUP_VECTOR;
|
5091 |
|
|
queued2 <= (
|
5092 |
|
|
(!IsVector(fetchbuf1_instr) && (!IsVex(fetchbuf1_instr) || rf_vra1) && (!IsVector(fetchbuf0_instr))) || !SUP_VECTOR);
|
5093 |
|
|
vqueued2 <= IsVector(fetchbuf0_instr) && vqe0 < vl-2 && !vechain;
|
5094 |
|
|
end
|
5095 |
|
|
end
|
5096 |
|
|
// If an irq is active during a vector instruction fetch, claim the vector instruction
|
5097 |
|
|
// is finished queueing even though it may not be. It'll pick up where it left off after
|
5098 |
|
|
// the exception is processed.
|
5099 |
|
|
if (hirq) begin
|
5100 |
|
|
if (IsVector(fetchbuf0_instr) && IsVector(fetchbuf1_instr) && vechain) begin
|
5101 |
|
|
queued1 <= TRUE;
|
5102 |
|
|
queued2 <= TRUE;
|
5103 |
|
|
end
|
5104 |
|
|
else if (IsVector(fetchbuf0_instr)) begin
|
5105 |
|
|
queued1 <= TRUE;
|
5106 |
|
|
if (vqe0 < vl-2)
|
5107 |
|
|
queued2 <= TRUE;
|
5108 |
|
|
else
|
5109 |
|
|
queued2 <= iqentry_v[tail1]==`INV;
|
5110 |
|
|
end
|
5111 |
|
|
end
|
5112 |
|
|
end
|
5113 |
|
|
end
|
5114 |
|
|
end
|
5115 |
|
|
// One available
|
5116 |
|
|
else if (fetchbuf0_v) begin
|
5117 |
|
|
if (fetchbuf0_instr[`INSTRUCTION_OP]!=`NOP) begin
|
5118 |
|
|
if (iqentry_v[tail0]==`INV) begin
|
5119 |
|
|
canq1 <= !IsVex(fetchbuf0_instr) || rf_vra0 || !SUP_VECTOR;
|
5120 |
|
|
queued1 <=
|
5121 |
|
|
(((!IsVex(fetchbuf0_instr) || rf_vra0) && (!IsVector(fetchbuf0_instr))) || !SUP_VECTOR);
|
5122 |
|
|
end
|
5123 |
|
|
if (iqentry_v[tail1]==`INV) begin
|
5124 |
|
|
canq2 <= IsVector(fetchbuf0_instr) && vqe0 < vl-2 && SUP_VECTOR;
|
5125 |
|
|
vqueued2 <= IsVector(fetchbuf0_instr) && vqe0 < vl-2 && !vechain;
|
5126 |
|
|
end
|
5127 |
|
|
if (hirq) begin
|
5128 |
|
|
if (IsVector(fetchbuf0_instr)) begin
|
5129 |
|
|
queued1 <= TRUE;
|
5130 |
|
|
if (vqe0 < vl-2)
|
5131 |
|
|
queued2 <= iqentry_v[tail1]==`INV;
|
5132 |
|
|
end
|
5133 |
|
|
end
|
5134 |
|
|
end
|
5135 |
|
|
else
|
5136 |
|
|
queuedNop <= TRUE;
|
5137 |
|
|
end
|
5138 |
|
|
else if (fetchbuf1_v) begin
|
5139 |
|
|
if (fetchbuf1_instr[`INSTRUCTION_OP]!=`NOP) begin
|
5140 |
|
|
if (iqentry_v[tail0]==`INV) begin
|
5141 |
|
|
canq1 <= !IsVex(fetchbuf1_instr) || rf_vra1 || !SUP_VECTOR;
|
5142 |
|
|
queued1 <= (
|
5143 |
|
|
((!IsVex(fetchbuf1_instr) || rf_vra1) && (!IsVector(fetchbuf1_instr))) || !SUP_VECTOR);
|
5144 |
|
|
end
|
5145 |
|
|
if (iqentry_v[tail1]==`INV) begin
|
5146 |
|
|
canq2 <= IsVector(fetchbuf1_instr) && vqe1 < vl-2 && SUP_VECTOR;
|
5147 |
|
|
vqueued2 <= IsVector(fetchbuf1_instr) && vqe1 < vl-2;
|
5148 |
|
|
end
|
5149 |
|
|
if (hirq) begin
|
5150 |
|
|
if (IsVector(fetchbuf1_instr)) begin
|
5151 |
|
|
queued1 <= TRUE;
|
5152 |
|
|
if (vqe1 < vl-2)
|
5153 |
|
|
queued2 <= iqentry_v[tail1]==`INV;
|
5154 |
|
|
end
|
5155 |
|
|
end
|
5156 |
|
|
end
|
5157 |
|
|
else
|
5158 |
|
|
queuedNop <= TRUE;
|
5159 |
|
|
end
|
5160 |
|
|
//else no instructions available to queue
|
5161 |
|
|
end
|
5162 |
|
|
else begin
|
5163 |
|
|
// One available
|
5164 |
|
|
if (fetchbuf0_v && fetchbuf0_thrd != branchmiss_thrd) begin
|
5165 |
|
|
if (fetchbuf0_instr[`INSTRUCTION_OP]!=`NOP) begin
|
5166 |
|
|
if (iqentry_v[tail0]==`INV) begin
|
5167 |
|
|
canq1 <= !IsVex(fetchbuf0_instr) || rf_vra0 || !SUP_VECTOR;
|
5168 |
|
|
queued1 <= (
|
5169 |
|
|
((!IsVex(fetchbuf0_instr) || rf_vra0) && (!IsVector(fetchbuf0_instr))) || !SUP_VECTOR);
|
5170 |
|
|
end
|
5171 |
|
|
if (iqentry_v[tail1]==`INV) begin
|
5172 |
|
|
canq2 <= IsVector(fetchbuf0_instr) && vqe0 < vl-2 && SUP_VECTOR;
|
5173 |
|
|
vqueued2 <= IsVector(fetchbuf0_instr) && vqe0 < vl-2 && !vechain;
|
5174 |
|
|
end
|
5175 |
|
|
end
|
5176 |
|
|
else
|
5177 |
|
|
queuedNop <= TRUE;
|
5178 |
|
|
end
|
5179 |
|
|
else if (fetchbuf1_v && fetchbuf1_thrd != branchmiss_thrd) begin
|
5180 |
|
|
if (fetchbuf1_instr[`INSTRUCTION_OP]!=`NOP) begin
|
5181 |
|
|
if (iqentry_v[tail0]==`INV) begin
|
5182 |
|
|
canq1 <= !IsVex(fetchbuf1_instr) || rf_vra1 || !SUP_VECTOR;
|
5183 |
|
|
queued1 <= (
|
5184 |
|
|
((!IsVex(fetchbuf1_instr) || rf_vra1) && (!IsVector(fetchbuf1_instr))) || !SUP_VECTOR);
|
5185 |
|
|
end
|
5186 |
|
|
if (iqentry_v[tail1]==`INV) begin
|
5187 |
|
|
canq2 <= IsVector(fetchbuf1_instr) && vqe1 < vl-2 && SUP_VECTOR;
|
5188 |
|
|
vqueued2 <= IsVector(fetchbuf0_instr) && vqe0 < vl-2 && !vechain;
|
5189 |
|
|
end
|
5190 |
|
|
end
|
5191 |
|
|
else
|
5192 |
|
|
queuedNop <= TRUE;
|
5193 |
|
|
end
|
5194 |
|
|
end
|
5195 |
|
|
end
|
5196 |
|
|
|
5197 |
|
|
//
|
5198 |
|
|
// Branchmiss seems to be sticky sometimes during simulation. For instance branch miss
|
5199 |
|
|
// and cache miss at same time. The branchmiss should clear before the core continues
|
5200 |
|
|
// so the positive edge is detected to avoid incrementing the sequnce number too many
|
5201 |
|
|
// times.
|
5202 |
|
|
wire pebm;
|
5203 |
|
|
edge_det uedbm (.rst(rst), .clk(clk), .ce(1'b1), .i(branchmiss), .pe(pebm), .ne(), .ee() );
|
5204 |
|
|
|
5205 |
|
|
// Monster clock domain.
|
5206 |
|
|
// Like to move some of this to clocking under different always blocks in order
|
5207 |
|
|
// to help out the toolset's synthesis, but it ain't gonna be easy.
|
5208 |
|
|
// Simulation doesn't like it if things are under separate always blocks.
|
5209 |
|
|
// Synthesis doesn't like it if things are under the same always block.
|
5210 |
|
|
|
5211 |
|
|
always @(posedge clk)
|
5212 |
|
|
if (rst) begin
|
5213 |
|
|
mstatus[0] <= 64'h0007; // select register set #0 for thread 0
|
5214 |
|
|
`ifdef SUPPORT_SMT
|
5215 |
|
|
mstatus[1] <= 64'h8007; // select register set #2 for thread 1
|
5216 |
|
|
`endif
|
5217 |
|
|
for (n = 0; n < QENTRIES; n = n + 1) begin
|
5218 |
|
|
iqentry_v[n] <= 1'b0;
|
5219 |
|
|
iqentry_done[n] <= 1'b0;
|
5220 |
|
|
iqentry_cmt[n] <= 1'b0;
|
5221 |
|
|
iqentry_out[n] <= 1'b0;
|
5222 |
|
|
iqentry_agen[n] <= 1'b0;
|
5223 |
|
|
iqentry_sn[n] <= 8'd0;
|
5224 |
|
|
iqentry_bt[n] <= 1'b0;
|
5225 |
|
|
iqentry_instr[n] <= `NOP_INSN;
|
5226 |
|
|
iqentry_mem[n] <= 1'b0;
|
5227 |
|
|
iqentry_memndx[n] <= FALSE;
|
5228 |
|
|
iqentry_memissue[n] <= FALSE;
|
5229 |
|
|
iqentry_tgt[n] <= 6'd0;
|
5230 |
|
|
iqentry_a1[n] <= 64'd0;
|
5231 |
|
|
iqentry_a2[n] <= 64'd0;
|
5232 |
|
|
iqentry_a3[n] <= 64'd0;
|
5233 |
|
|
iqentry_a1_v[n] <= `INV;
|
5234 |
|
|
iqentry_a2_v[n] <= `INV;
|
5235 |
|
|
iqentry_a3_v[n] <= `INV;
|
5236 |
|
|
iqentry_a1_s[n] <= 5'd0;
|
5237 |
|
|
iqentry_a2_s[n] <= 5'd0;
|
5238 |
|
|
iqentry_a3_s[n] <= 5'd0;
|
5239 |
|
|
end
|
5240 |
|
|
dram0 <= `DRAMSLOT_AVAIL;
|
5241 |
|
|
dram1 <= `DRAMSLOT_AVAIL;
|
5242 |
|
|
dram2 <= `DRAMSLOT_AVAIL;
|
5243 |
|
|
dram0_instr <= `NOP_INSN;
|
5244 |
|
|
dram1_instr <= `NOP_INSN;
|
5245 |
|
|
dram2_instr <= `NOP_INSN;
|
5246 |
|
|
dram0_addr <= 32'h0;
|
5247 |
|
|
dram1_addr <= 32'h0;
|
5248 |
|
|
dram2_addr <= 32'h0;
|
5249 |
|
|
L1_adr <= RSTPC;
|
5250 |
|
|
invic <= FALSE;
|
5251 |
|
|
tail0 <= 3'd0;
|
5252 |
|
|
tail1 <= 3'd1;
|
5253 |
|
|
head0 <= 0;
|
5254 |
|
|
head1 <= 1;
|
5255 |
|
|
head2 <= 2;
|
5256 |
|
|
head3 <= 3;
|
5257 |
|
|
head4 <= 4;
|
5258 |
|
|
head5 <= 5;
|
5259 |
|
|
head6 <= 6;
|
5260 |
|
|
head7 <= 7;
|
5261 |
|
|
panic = `PANIC_NONE;
|
5262 |
|
|
alu0_available <= 1;
|
5263 |
|
|
alu0_dataready <= 0;
|
5264 |
|
|
alu1_available <= 1;
|
5265 |
|
|
alu1_dataready <= 0;
|
5266 |
|
|
alu0_sourceid <= 5'd0;
|
5267 |
|
|
alu1_sourceid <= 5'd0;
|
5268 |
|
|
fcu_dataready <= 0;
|
5269 |
|
|
fcu_instr <= `NOP_INSN;
|
5270 |
|
|
fcu_retadr_v <= 0;
|
5271 |
|
|
dramA_v <= 0;
|
5272 |
|
|
dramB_v <= 0;
|
5273 |
|
|
dramC_v <= 0;
|
5274 |
|
|
I <= 0;
|
5275 |
|
|
icstate <= IDLE;
|
5276 |
|
|
bstate <= BIDLE;
|
5277 |
|
|
tick <= 64'd0;
|
5278 |
|
|
bte_o <= 2'b00;
|
5279 |
|
|
cti_o <= 3'b000;
|
5280 |
|
|
cyc_o <= `LOW;
|
5281 |
|
|
stb_o <= `LOW;
|
5282 |
|
|
we_o <= `LOW;
|
5283 |
|
|
sel_o <= 8'h00;
|
5284 |
|
|
sr_o <= `LOW;
|
5285 |
|
|
cr_o <= `LOW;
|
5286 |
|
|
adr_o <= RSTPC;
|
5287 |
|
|
icl_o <= `LOW; // instruction cache load
|
5288 |
|
|
cr0 <= 64'd0;
|
5289 |
|
|
cr0[13:8] <= 6'd0; // select register set #0
|
5290 |
|
|
cr0[30] <= TRUE; // enable data caching
|
5291 |
|
|
cr0[32] <= TRUE; // enable branch predictor
|
5292 |
|
|
cr0[16] <= 1'b0; // disable SMT
|
5293 |
|
|
cr0[17] <= 1'b0; // sequence number reset = 1
|
5294 |
|
|
pcr <= 32'd0;
|
5295 |
|
|
pcr2 <= 64'd0;
|
5296 |
|
|
for (n = 0; n < PREGS; n = n + 1)
|
5297 |
|
|
rf_v[n] <= `VAL;
|
5298 |
|
|
tgtq <= FALSE;
|
5299 |
|
|
fp_rm <= 3'd0; // round nearest even - default rounding mode
|
5300 |
|
|
waitctr <= 64'd0;
|
5301 |
|
|
for (n = 0; n < 16; n = n + 1)
|
5302 |
|
|
badaddr[n] <= 64'd0;
|
5303 |
|
|
sbl <= 32'h0;
|
5304 |
|
|
sbu <= 32'hFFFFFFFF;
|
5305 |
|
|
// Vector
|
5306 |
|
|
vqe0 <= 6'd0;
|
5307 |
|
|
vqet0 <= 6'd0;
|
5308 |
|
|
vqe1 <= 6'd0;
|
5309 |
|
|
vqet1 <= 6'd0;
|
5310 |
|
|
vl <= 7'd62;
|
5311 |
|
|
for (n = 0; n < 8; n = n + 1)
|
5312 |
|
|
vm[n] <= 64'h7FFFFFFFFFFFFFFF;
|
5313 |
|
|
nop_fetchbuf <= 4'h0;
|
5314 |
|
|
seq_num <= 5'd0;
|
5315 |
|
|
seq_num1 <= 5'd0;
|
5316 |
|
|
fcu_done <= `TRUE;
|
5317 |
|
|
end
|
5318 |
|
|
else begin
|
5319 |
|
|
rf_vra0 <= regIsValid[Ra0s];
|
5320 |
|
|
rf_vra1 <= regIsValid[Ra1s];
|
5321 |
|
|
if (vqe0 >= vl) begin
|
5322 |
|
|
vqe0 <= 6'd0;
|
5323 |
|
|
vqet0 <= 6'h0;
|
5324 |
|
|
end
|
5325 |
|
|
if (vqe1 >= vl) begin
|
5326 |
|
|
vqe1 <= 6'd0;
|
5327 |
|
|
vqet1 <= 6'h0;
|
5328 |
|
|
end
|
5329 |
|
|
// Turn off vector chaining indicator when chained instructions are done.
|
5330 |
|
|
if ((vqe0 >= vl || vqe0==6'd0) && (vqe1 >= vl || vqe1==6'd0))
|
5331 |
|
|
mstatus[0][32] <= 1'b0;
|
5332 |
|
|
|
5333 |
|
|
nop_fetchbuf <= 4'h0;
|
5334 |
|
|
excmiss <= FALSE;
|
5335 |
|
|
invic <= FALSE;
|
5336 |
|
|
tick <= tick + 64'd1;
|
5337 |
|
|
alu0_ld <= FALSE;
|
5338 |
|
|
alu1_ld <= FALSE;
|
5339 |
|
|
fpu_ld <= FALSE;
|
5340 |
|
|
fcu_ld <= FALSE;
|
5341 |
|
|
fcu_retadr_v <= FALSE;
|
5342 |
|
|
dramA_v <= FALSE;
|
5343 |
|
|
dramB_v <= FALSE;
|
5344 |
|
|
dramC_v <= FALSE;
|
5345 |
|
|
cr0[17] <= 1'b0;
|
5346 |
|
|
if (waitctr != 64'd0)
|
5347 |
|
|
waitctr <= waitctr - 64'd1;
|
5348 |
|
|
|
5349 |
|
|
if (IsFlowCtrl(iqentry_instr[fcu_id[`QBITS]]) && iqentry_v[fcu_id[`QBITS]] && !iqentry_done[fcu_id[`QBITS]] && iqentry_out[fcu_id[`QBITS]])
|
5350 |
|
|
fcu_timeout <= fcu_timeout + 8'd1;
|
5351 |
|
|
|
5352 |
|
|
if (branchmiss) begin
|
5353 |
|
|
for (n = 1; n < PREGS; n = n + 1)
|
5354 |
|
|
if (~livetarget[n]) begin
|
5355 |
|
|
if (branchmiss_thrd & thread_en) begin
|
5356 |
|
|
if (n >= 128)
|
5357 |
|
|
rf_v[n] <= `VAL;
|
5358 |
|
|
end
|
5359 |
|
|
else begin
|
5360 |
|
|
if (n < 128 || !thread_en)
|
5361 |
|
|
rf_v[n] <= `VAL;
|
5362 |
|
|
end
|
5363 |
|
|
end
|
5364 |
|
|
|
5365 |
|
|
if (|iqentry_0_latestID) if (iqentry_thrd[0]==branchmiss_thrd) rf_source[ {iqentry_tgt[0][7:0]} ] <= { 1'b0, iqentry_mem[0], 3'd0 };
|
5366 |
|
|
if (|iqentry_1_latestID) if (iqentry_thrd[1]==branchmiss_thrd) rf_source[ {iqentry_tgt[1][7:0]} ] <= { 1'b0, iqentry_mem[1], 3'd1 };
|
5367 |
|
|
if (|iqentry_2_latestID) if (iqentry_thrd[2]==branchmiss_thrd) rf_source[ {iqentry_tgt[2][7:0]} ] <= { 1'b0, iqentry_mem[2], 3'd2 };
|
5368 |
|
|
if (|iqentry_3_latestID) if (iqentry_thrd[3]==branchmiss_thrd) rf_source[ {iqentry_tgt[3][7:0]} ] <= { 1'b0, iqentry_mem[3], 3'd3 };
|
5369 |
|
|
if (|iqentry_4_latestID) if (iqentry_thrd[4]==branchmiss_thrd) rf_source[ {iqentry_tgt[4][7:0]} ] <= { 1'b0, iqentry_mem[4], 3'd4 };
|
5370 |
|
|
if (|iqentry_5_latestID) if (iqentry_thrd[5]==branchmiss_thrd) rf_source[ {iqentry_tgt[5][7:0]} ] <= { 1'b0, iqentry_mem[5], 3'd5 };
|
5371 |
|
|
if (|iqentry_6_latestID) if (iqentry_thrd[6]==branchmiss_thrd) rf_source[ {iqentry_tgt[6][7:0]} ] <= { 1'b0, iqentry_mem[6], 3'd6 };
|
5372 |
|
|
if (|iqentry_7_latestID) if (iqentry_thrd[7]==branchmiss_thrd) rf_source[ {iqentry_tgt[7][7:0]} ] <= { 1'b0, iqentry_mem[7], 3'd7 };
|
5373 |
|
|
|
5374 |
|
|
end
|
5375 |
|
|
|
5376 |
|
|
// The source for the register file data might have changed since it was
|
5377 |
|
|
// placed on the commit bus. So it's needed to check that the source is
|
5378 |
|
|
// still as expected to validate the register.
|
5379 |
|
|
if (commit0_v) begin
|
5380 |
|
|
if (!rf_v[ {commit0_tgt[7:0]} ])
|
5381 |
|
|
// rf_v[ {commit0_tgt[7:0]} ] <= rf_source[ commit0_tgt[7:0] ] == commit0_id || (branchmiss && iqentry_source[ commit0_id[`QBITS] ]);
|
5382 |
|
|
rf_v[ {commit0_tgt[7:0]} ] <= regIsValid[{commit0_tgt[7:0]}];//rf_source[ commit0_tgt[4:0] ] == commit0_id || (branchmiss && iqentry_source[ commit0_id[`QBITS] ]);
|
5383 |
|
|
if (commit0_tgt[5:0] != 6'd0) $display("r%d <- %h v[%d]<-%d", commit0_tgt, commit0_bus, regIsValid[commit0_tgt[5:0]],
|
5384 |
|
|
rf_source[ {commit0_tgt[7:0]} ] == commit0_id || (branchmiss && iqentry_source[ commit0_id[`QBITS] ]));
|
5385 |
|
|
if (commit0_tgt[5:0]==6'd30 && commit0_bus==64'd0)
|
5386 |
|
|
$display("FP <= 0");
|
5387 |
|
|
end
|
5388 |
|
|
if (commit1_v) begin
|
5389 |
|
|
if (!rf_v[ {commit1_tgt[7:0]} ]) begin
|
5390 |
|
|
if ({commit1_tgt[7:0]}=={commit0_tgt[7:0]})
|
5391 |
|
|
rf_v[ {commit1_tgt[7:0]} ] <= regIsValid[{commit0_tgt[7:0]}] | regIsValid[{commit1_tgt[7:0]}];
|
5392 |
|
|
/*
|
5393 |
|
|
(rf_source[ commit0_tgt[4:0] ] == commit0_id || (branchmiss && iqentry_source[ commit0_id[`QBITS] ])) ||
|
5394 |
|
|
(rf_source[ commit1_tgt[4:0] ] == commit1_id || (branchmiss && iqentry_source[ commit1_id[`QBITS] ]));
|
5395 |
|
|
*/
|
5396 |
|
|
else
|
5397 |
|
|
rf_v[ {commit1_tgt[7:0]} ] <= regIsValid[{commit1_tgt[7:0]}];//rf_source[ commit1_tgt[4:0] ] == commit1_id || (branchmiss && iqentry_source[ commit1_id[`QBITS] ]);
|
5398 |
|
|
end
|
5399 |
|
|
if (commit1_tgt[5:0] != 6'd0) $display("r%d <- %h v[%d]<-%d", commit1_tgt, commit1_bus, regIsValid[commit1_tgt[5:0]],
|
5400 |
|
|
rf_source[ {commit1_tgt[7:0]} ] == commit1_id || (branchmiss && iqentry_source[ commit1_id[`QBITS] ]));
|
5401 |
|
|
if (commit1_tgt[5:0]==6'd30 && commit1_bus==64'd0)
|
5402 |
|
|
$display("FP <= 0");
|
5403 |
|
|
end
|
5404 |
|
|
rf_v[0] <= 1;
|
5405 |
|
|
|
5406 |
|
|
//
|
5407 |
|
|
// ENQUEUE
|
5408 |
|
|
//
|
5409 |
|
|
// place up to two instructions from the fetch buffer into slots in the IQ.
|
5410 |
|
|
// note: they are placed in-order, and they are expected to be executed
|
5411 |
|
|
// 0, 1, or 2 of the fetch buffers may have valid data
|
5412 |
|
|
// 0, 1, or 2 slots in the instruction queue may be available.
|
5413 |
|
|
// if we notice that one of the instructions in the fetch buffer is a predicted branch,
|
5414 |
|
|
// (set branchback/backpc and delete any instructions after it in fetchbuf)
|
5415 |
|
|
//
|
5416 |
|
|
|
5417 |
|
|
// enqueue fetchbuf0 and fetchbuf1, but only if there is room,
|
5418 |
|
|
// and ignore fetchbuf1 if fetchbuf0 has a backwards branch in it.
|
5419 |
|
|
//
|
5420 |
|
|
// also, do some instruction-decode ... set the operand_valid bits in the IQ
|
5421 |
|
|
// appropriately so that the DATAINCOMING stage does not have to look at the opcode
|
5422 |
|
|
//
|
5423 |
|
|
if (!branchmiss) // don't bother doing anything if there's been a branch miss
|
5424 |
|
|
|
5425 |
|
|
case ({fetchbuf0_v, fetchbuf1_v})
|
5426 |
|
|
|
5427 |
|
|
2'b00: ; // do nothing
|
5428 |
|
|
|
5429 |
|
|
2'b01:
|
5430 |
|
|
if (canq1) begin
|
5431 |
|
|
if (IsVector(fetchbuf1_instr) && SUP_VECTOR) begin
|
5432 |
|
|
vqe1 <= vqe1 + 4'd1;
|
5433 |
|
|
if (IsVCmprss(fetchbuf1_instr)) begin
|
5434 |
|
|
if (vm[fetchbuf1_instr[25:23]][vqe1])
|
5435 |
|
|
vqet1 <= vqet1 + 4'd1;
|
5436 |
|
|
end
|
5437 |
|
|
else
|
5438 |
|
|
vqet1 <= vqet1 + 4'd1;
|
5439 |
|
|
if (vqe1 >= vl-2)
|
5440 |
|
|
nop_fetchbuf <= fetchbuf ? 4'b0100 : 4'b0001;
|
5441 |
|
|
enque1(tail0, fetchbuf1_thrd ? seq_num1 : seq_num, vqe1);
|
5442 |
|
|
if (fetchbuf1_thrd)
|
5443 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5444 |
|
|
else
|
5445 |
|
|
seq_num <= seq_num + 5'd1;
|
5446 |
|
|
tgtq <= FALSE;
|
5447 |
|
|
if (fetchbuf1_rfw) begin
|
5448 |
|
|
rf_source[ Rt1s ] <= { 1'b0, fetchbuf1_memld, tail0 }; // top bit indicates ALU/MEM bus
|
5449 |
|
|
rf_v [Rt1s] <= `INV;
|
5450 |
|
|
end
|
5451 |
|
|
if (canq2 && vqe1 < vl-2) begin
|
5452 |
|
|
vqe1 <= vqe1 + 4'd2;
|
5453 |
|
|
if (IsVCmprss(fetchbuf1_instr)) begin
|
5454 |
|
|
if (vm[fetchbuf1_instr[25:23]][vqe1+6'd1])
|
5455 |
|
|
vqet1 <= vqet1 + 4'd2;
|
5456 |
|
|
end
|
5457 |
|
|
else
|
5458 |
|
|
vqet1 <= vqet1 + 4'd2;
|
5459 |
|
|
enque1(tail1, fetchbuf1_thrd ? seq_num1 + 5'd1 : seq_num + 5'd1, vqe1 + 6'd1);
|
5460 |
|
|
if (fetchbuf1_thrd)
|
5461 |
|
|
seq_num1 <= seq_num1 + 5'd2;
|
5462 |
|
|
else
|
5463 |
|
|
seq_num <= seq_num + 5'd2;
|
5464 |
|
|
tgtq <= FALSE;
|
5465 |
|
|
if (fetchbuf1_rfw) begin
|
5466 |
|
|
rf_source[ Rt1s ] <= { 1'b0, fetchbuf1_memld, tail1 }; // top bit indicates ALU/MEM bus
|
5467 |
|
|
rf_v [Rt1s] <= `INV;
|
5468 |
|
|
end
|
5469 |
|
|
end
|
5470 |
|
|
end
|
5471 |
|
|
else begin
|
5472 |
|
|
enque1(tail0, fetchbuf1_thrd ? seq_num1 : seq_num, 6'd0);
|
5473 |
|
|
if (fetchbuf1_thrd)
|
5474 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5475 |
|
|
else
|
5476 |
|
|
seq_num <= seq_num + 5'd1;
|
5477 |
|
|
tgtq <= FALSE;
|
5478 |
|
|
if (fetchbuf1_rfw) begin
|
5479 |
|
|
rf_source[ Rt1s ] <= { 1'b0, fetchbuf1_memld, tail0 }; // top bit indicates ALU/MEM bus
|
5480 |
|
|
rf_v [Rt1s] <= `INV;
|
5481 |
|
|
end
|
5482 |
|
|
end
|
5483 |
|
|
end
|
5484 |
|
|
|
5485 |
|
|
2'b10:
|
5486 |
|
|
if (canq1) begin
|
5487 |
|
|
// $display("queued1: %d", queued1);
|
5488 |
|
|
// if (!IsBranch(fetchbuf0_instr)) panic <= `PANIC_FETCHBUFBEQ;
|
5489 |
|
|
// if (!predict_taken0) panic <= `PANIC_FETCHBUFBEQ;
|
5490 |
|
|
//
|
5491 |
|
|
// this should only happen when the first instruction is a BEQ-backwards and the IQ
|
5492 |
|
|
// happened to be full on the previous cycle (thus we deleted fetchbuf1 but did not
|
5493 |
|
|
// enqueue fetchbuf0) ... probably no need to check for LW -- sanity check, just in case
|
5494 |
|
|
//
|
5495 |
|
|
if (IsVector(fetchbuf0_instr) && SUP_VECTOR) begin
|
5496 |
|
|
vqe0 <= vqe0 + 4'd1;
|
5497 |
|
|
if (IsVCmprss(fetchbuf0_instr)) begin
|
5498 |
|
|
if (vm[fetchbuf0_instr[25:23]][vqe0])
|
5499 |
|
|
vqet0 <= vqet0 + 4'd1;
|
5500 |
|
|
end
|
5501 |
|
|
else
|
5502 |
|
|
vqet0 <= vqet0 + 4'd1;
|
5503 |
|
|
if (vqe0 >= vl-2)
|
5504 |
|
|
nop_fetchbuf <= fetchbuf ? 4'b1000 : 4'b0010;
|
5505 |
|
|
enque0(tail0, fetchbuf0_thrd ? seq_num1 : seq_num, vqe0);
|
5506 |
|
|
if (fetchbuf0_thrd)
|
5507 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5508 |
|
|
else
|
5509 |
|
|
seq_num <= seq_num + 5'd1;
|
5510 |
|
|
tgtq <= FALSE;
|
5511 |
|
|
if (fetchbuf0_rfw) begin
|
5512 |
|
|
rf_source[ Rt0s ] <= { 1'b0, fetchbuf0_memld, tail0 }; // top bit indicates ALU/MEM bus
|
5513 |
|
|
rf_v[Rt0s] <= `INV;
|
5514 |
|
|
end
|
5515 |
|
|
if (canq2) begin
|
5516 |
|
|
if (vqe0 < vl-2) begin
|
5517 |
|
|
vqe0 <= vqe0 + 4'd2;
|
5518 |
|
|
if (IsVCmprss(fetchbuf0_instr)) begin
|
5519 |
|
|
if (vm[fetchbuf0_instr[25:23]][vqe0+6'd1])
|
5520 |
|
|
vqet0 <= vqet0 + 4'd2;
|
5521 |
|
|
end
|
5522 |
|
|
else
|
5523 |
|
|
vqet0 <= vqet0 + 4'd2;
|
5524 |
|
|
enque0(tail1, fetchbuf0_thrd ? seq_num1 + 5'd1 : seq_num+5'd1, vqe0 + 6'd1);
|
5525 |
|
|
if (fetchbuf0_thrd)
|
5526 |
|
|
seq_num1 <= seq_num1 + 5'd2;
|
5527 |
|
|
else
|
5528 |
|
|
seq_num <= seq_num + 5'd2;
|
5529 |
|
|
tgtq <= FALSE;
|
5530 |
|
|
if (fetchbuf0_rfw) begin
|
5531 |
|
|
rf_source[ Rt0s ] <= { 1'b0, fetchbuf0_memld, tail1 }; // top bit indicates ALU/MEM bus
|
5532 |
|
|
rf_v[Rt0s] <= `INV;
|
5533 |
|
|
end
|
5534 |
|
|
end
|
5535 |
|
|
end
|
5536 |
|
|
end
|
5537 |
|
|
else begin
|
5538 |
|
|
enque0(tail0, fetchbuf0_thrd ? seq_num1 : seq_num, 6'd0);
|
5539 |
|
|
if (fetchbuf0_thrd)
|
5540 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5541 |
|
|
else
|
5542 |
|
|
seq_num <= seq_num + 5'd1;
|
5543 |
|
|
tgtq <= FALSE;
|
5544 |
|
|
if (fetchbuf0_rfw) begin
|
5545 |
|
|
rf_source[ Rt0s ] <= { 1'b0, fetchbuf0_memld, tail0 }; // top bit indicates ALU/MEM bus
|
5546 |
|
|
rf_v[Rt0s] <= `INV;
|
5547 |
|
|
end
|
5548 |
|
|
end
|
5549 |
|
|
end
|
5550 |
|
|
|
5551 |
|
|
2'b11:
|
5552 |
|
|
if (canq1) begin
|
5553 |
|
|
//
|
5554 |
|
|
// if the first instruction is a predicted branch, enqueue it & stomp on all following instructions
|
5555 |
|
|
// but only if the following instruction is in the same thread. Otherwise we want to queue two.
|
5556 |
|
|
//
|
5557 |
|
|
if (take_branch0 && fetchbuf1_thrd==fetchbuf0_thrd) begin
|
5558 |
|
|
tgtq <= FALSE;
|
5559 |
|
|
enque0(tail0,fetchbuf0_thrd ? seq_num1 : seq_num,6'd0);
|
5560 |
|
|
if (fetchbuf0_thrd)
|
5561 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5562 |
|
|
else
|
5563 |
|
|
seq_num <= seq_num + 5'd1;
|
5564 |
|
|
if (fetchbuf0_rfw) begin
|
5565 |
|
|
rf_source[ Rt0s ] <= {1'b0,fetchbuf0_memld, tail0};
|
5566 |
|
|
rf_v [ Rt0s ] <= `INV;
|
5567 |
|
|
end
|
5568 |
|
|
end
|
5569 |
|
|
|
5570 |
|
|
else begin // fetchbuf0 doesn't contain a predicted branch
|
5571 |
|
|
//
|
5572 |
|
|
// so -- we can enqueue 1 or 2 instructions, depending on space in the IQ
|
5573 |
|
|
// update the rf_v and rf_source bits separately (at end)
|
5574 |
|
|
// the problem is that if we do have two instructions,
|
5575 |
|
|
// they may interact with each other, so we have to be
|
5576 |
|
|
// careful about where things point.
|
5577 |
|
|
//
|
5578 |
|
|
// enqueue the first instruction ...
|
5579 |
|
|
//
|
5580 |
|
|
if (IsVector(fetchbuf0_instr) && SUP_VECTOR) begin
|
5581 |
|
|
vqe0 <= vqe0 + 4'd1;
|
5582 |
|
|
if (IsVCmprss(fetchbuf0_instr)) begin
|
5583 |
|
|
if (vm[fetchbuf0_instr[25:23]][vqe0])
|
5584 |
|
|
vqet0 <= vqet0 + 4'd1;
|
5585 |
|
|
end
|
5586 |
|
|
else
|
5587 |
|
|
vqet0 <= vqet0 + 4'd1;
|
5588 |
|
|
if (vqe0 >= vl-2)
|
5589 |
|
|
nop_fetchbuf <= fetchbuf ? 4'b1000 : 4'b0010;
|
5590 |
|
|
end
|
5591 |
|
|
tgtq <= FALSE;
|
5592 |
|
|
if (vqe0 < vl || !IsVector(fetchbuf0_instr)) begin
|
5593 |
|
|
enque0(tail0, fetchbuf0_thrd ? seq_num1 : seq_num, vqe0);
|
5594 |
|
|
if (fetchbuf0_thrd)
|
5595 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5596 |
|
|
else
|
5597 |
|
|
seq_num <= seq_num + 5'd1;
|
5598 |
|
|
//
|
5599 |
|
|
// if there is room for a second instruction, enqueue it
|
5600 |
|
|
//
|
5601 |
|
|
if (canq2) begin
|
5602 |
|
|
if (vechain && IsVector(fetchbuf1_instr)
|
5603 |
|
|
&& Ra1s != Rt0s // And there is no dependency
|
5604 |
|
|
&& Rb1s != Rt0s
|
5605 |
|
|
&& Rc1s != Rt0s
|
5606 |
|
|
) begin
|
5607 |
|
|
mstatus[0][32] <= 1'b1;
|
5608 |
|
|
vqe1 <= vqe1 + 4'd1;
|
5609 |
|
|
if (IsVCmprss(fetchbuf1_instr)) begin
|
5610 |
|
|
if (vm[fetchbuf1_instr[25:23]][vqe1])
|
5611 |
|
|
vqet1 <= vqet1 + 4'd1;
|
5612 |
|
|
end
|
5613 |
|
|
else
|
5614 |
|
|
vqet1 <= vqet1 + 4'd1;
|
5615 |
|
|
if (vqe1 >= vl-2)
|
5616 |
|
|
nop_fetchbuf <= fetchbuf ? 4'b0100 : 4'b0001;
|
5617 |
|
|
enque1(tail1,
|
5618 |
|
|
fetchbuf1_thrd==fetchbuf0_thrd && fetchbuf1_thrd==1'b1 ? seq_num1 + 5'd1 :
|
5619 |
|
|
fetchbuf1_thrd==fetchbuf0_thrd && fetchbuf1_thrd==1'b0 ? seq_num + 5'd1 :
|
5620 |
|
|
fetchbuf1_thrd ? seq_num1 + 5'd1: seq_num + 5'd1, 6'd0);
|
5621 |
|
|
if (fetchbuf1_thrd==fetchbuf0_thrd) begin
|
5622 |
|
|
if (fetchbuf1_thrd)
|
5623 |
|
|
seq_num1 <= seq_num1 + 5'd2;
|
5624 |
|
|
else
|
5625 |
|
|
seq_num <= seq_num + 5'd2;
|
5626 |
|
|
end
|
5627 |
|
|
else begin
|
5628 |
|
|
if (fetchbuf1_thrd)
|
5629 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5630 |
|
|
else
|
5631 |
|
|
seq_num <= seq_num + 5'd1;
|
5632 |
|
|
end
|
5633 |
|
|
|
5634 |
|
|
// SOURCE 1 ...
|
5635 |
|
|
// if the argument is an immediate or not needed, we're done
|
5636 |
|
|
if (Source1Valid( fetchbuf1_instr ) == `VAL) begin
|
5637 |
|
|
iqentry_a1_v [tail1] <= `VAL;
|
5638 |
|
|
iqentry_a1_s [tail1] <= 4'd0;
|
5639 |
|
|
end
|
5640 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5641 |
|
|
else if (~fetchbuf0_rfw) begin
|
5642 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra1s];
|
5643 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra1s];
|
5644 |
|
|
end
|
5645 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5646 |
|
|
else if (Ra1 == Rt0) begin
|
5647 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5648 |
|
|
iqentry_a1_v [tail1] <= `INV;
|
5649 |
|
|
iqentry_a1_s [tail1] <= { 1'b0, fetchbuf0_mem &IsLoad(fetchbuf0_instr), tail0 };
|
5650 |
|
|
end
|
5651 |
|
|
// if no overlap, get info from rf_v and rf_source
|
5652 |
|
|
else begin
|
5653 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra1s];
|
5654 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra1s];
|
5655 |
|
|
end
|
5656 |
|
|
|
5657 |
|
|
// SOURCE 2 ...
|
5658 |
|
|
// if the argument is an immediate or not needed, we're done
|
5659 |
|
|
if (Source2Valid( fetchbuf1_instr ) == `VAL) begin
|
5660 |
|
|
iqentry_a2_v [tail1] <= `VAL;
|
5661 |
|
|
iqentry_a2_s [tail1] <= 4'd0;
|
5662 |
|
|
end
|
5663 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5664 |
|
|
else if (~fetchbuf0_rfw) begin
|
5665 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb1s];
|
5666 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb1s ];
|
5667 |
|
|
end
|
5668 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5669 |
|
|
else if (Rb1s == Rt0s) begin
|
5670 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5671 |
|
|
iqentry_a2_v [tail1] <= `INV;
|
5672 |
|
|
iqentry_a2_s [tail1] <= { 1'b0, fetchbuf0_mem &IsLoad(fetchbuf0_instr), tail0 };
|
5673 |
|
|
end
|
5674 |
|
|
// if no overlap, get info from rf_v and rf_source
|
5675 |
|
|
else begin
|
5676 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb1s];
|
5677 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb1s ];
|
5678 |
|
|
end
|
5679 |
|
|
|
5680 |
|
|
// SOURCE 3 ...
|
5681 |
|
|
// if the argument is an immediate or not needed, we're done
|
5682 |
|
|
if (Source3Valid( fetchbuf1_instr ) == `VAL) begin
|
5683 |
|
|
iqentry_a3_v [tail1] <= `VAL;
|
5684 |
|
|
iqentry_a3_s [tail1] <= 4'd0;
|
5685 |
|
|
end
|
5686 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5687 |
|
|
else if (~fetchbuf0_rfw) begin
|
5688 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc1s];
|
5689 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc1s ];
|
5690 |
|
|
end
|
5691 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5692 |
|
|
else if (Rc1 == Rt0) begin
|
5693 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5694 |
|
|
iqentry_a3_v [tail1] <= `INV;
|
5695 |
|
|
iqentry_a3_s [tail1] <= { 1'b0, fetchbuf0_mem &IsLoad(fetchbuf0_instr), tail0 };
|
5696 |
|
|
end
|
5697 |
|
|
// if no overlap, get info from rf_v and rf_source
|
5698 |
|
|
else begin
|
5699 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc1s];
|
5700 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc1s ];
|
5701 |
|
|
end
|
5702 |
|
|
|
5703 |
|
|
// if the two instructions enqueued target the same register,
|
5704 |
|
|
// make sure only the second writes to rf_v and rf_source.
|
5705 |
|
|
// first is allowed to update rf_v and rf_source only if the
|
5706 |
|
|
// second has no target
|
5707 |
|
|
//
|
5708 |
|
|
if (fetchbuf0_rfw) begin
|
5709 |
|
|
rf_source[ Rt0s ] <= { 1'b0,fetchbuf0_memld, tail0 };
|
5710 |
|
|
rf_v [ Rt0s] <= `INV;
|
5711 |
|
|
end
|
5712 |
|
|
if (fetchbuf1_rfw) begin
|
5713 |
|
|
rf_source[ Rt1s ] <= { 1'b0,fetchbuf1_memld, tail1 };
|
5714 |
|
|
rf_v [ Rt1s ] <= `INV;
|
5715 |
|
|
end
|
5716 |
|
|
end
|
5717 |
|
|
// If there was a vector instruction in fetchbuf0, we really
|
5718 |
|
|
// want to queue the next vector element, not the next
|
5719 |
|
|
// instruction waiting in fetchbuf1.
|
5720 |
|
|
else if (IsVector(fetchbuf0_instr) && SUP_VECTOR && vqe0 < vl-1) begin
|
5721 |
|
|
vqe0 <= vqe0 + 4'd2;
|
5722 |
|
|
if (IsVCmprss(fetchbuf0_instr)) begin
|
5723 |
|
|
if (vm[fetchbuf0_instr[25:23]][vqe0+6'd1])
|
5724 |
|
|
vqet0 <= vqet0 + 4'd2;
|
5725 |
|
|
end
|
5726 |
|
|
else
|
5727 |
|
|
vqet0 <= vqet0 + 4'd2;
|
5728 |
|
|
if (vqe0 >= vl-3)
|
5729 |
|
|
nop_fetchbuf <= fetchbuf ? 4'b1000 : 4'b0010;
|
5730 |
|
|
if (vqe0 < vl-1) begin
|
5731 |
|
|
enque0(tail1, fetchbuf0_thrd ? seq_num1 + 5'd1 : seq_num + 5'd1, vqe0 + 6'd1);
|
5732 |
|
|
if (fetchbuf0_thrd)
|
5733 |
|
|
seq_num1 <= seq_num1 + 5'd2;
|
5734 |
|
|
else
|
5735 |
|
|
seq_num <= seq_num + 5'd2;
|
5736 |
|
|
|
5737 |
|
|
// SOURCE 1 ...
|
5738 |
|
|
// if the argument is an immediate or not needed, we're done
|
5739 |
|
|
if (Source1Valid( fetchbuf0_instr ) == `VAL) begin
|
5740 |
|
|
iqentry_a1_v [tail1] <= `VAL;
|
5741 |
|
|
iqentry_a1_s [tail1] <= 5'd0;
|
5742 |
|
|
end
|
5743 |
|
|
else begin
|
5744 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra0s];
|
5745 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra0s];
|
5746 |
|
|
end
|
5747 |
|
|
|
5748 |
|
|
// SOURCE 2 ...
|
5749 |
|
|
// if the argument is an immediate or not needed, we're done
|
5750 |
|
|
if (Source2Valid( fetchbuf0_instr ) == `VAL) begin
|
5751 |
|
|
iqentry_a2_v [tail1] <= `VAL;
|
5752 |
|
|
iqentry_a2_s [tail1] <= 5'd0;
|
5753 |
|
|
end
|
5754 |
|
|
else begin
|
5755 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb0s];
|
5756 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb0s ];
|
5757 |
|
|
end
|
5758 |
|
|
|
5759 |
|
|
// SOURCE 3 ...
|
5760 |
|
|
// if the argument is an immediate or not needed, we're done
|
5761 |
|
|
if (Source3Valid( fetchbuf0_instr ) == `VAL) begin
|
5762 |
|
|
iqentry_a3_v [tail1] <= `VAL;
|
5763 |
|
|
iqentry_a3_s [tail1] <= 5'd0;
|
5764 |
|
|
end
|
5765 |
|
|
else begin
|
5766 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc0s];
|
5767 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc0s ];
|
5768 |
|
|
end
|
5769 |
|
|
// if the two instructions enqueued target the same register,
|
5770 |
|
|
// make sure only the second writes to rf_v and rf_source.
|
5771 |
|
|
// first is allowed to update rf_v and rf_source only if the
|
5772 |
|
|
// second has no target (BEQ or SW)
|
5773 |
|
|
//
|
5774 |
|
|
if (fetchbuf0_rfw) begin
|
5775 |
|
|
rf_source[ Rt0s ] <= { 1'b0, fetchbuf0_memld, tail1 };
|
5776 |
|
|
rf_v [ Rt0s ] <= `INV;
|
5777 |
|
|
end
|
5778 |
|
|
end
|
5779 |
|
|
end
|
5780 |
|
|
else if (IsVector(fetchbuf1_instr) && SUP_VECTOR) begin
|
5781 |
|
|
vqe1 <= 6'd1;
|
5782 |
|
|
if (IsVCmprss(fetchbuf1_instr)) begin
|
5783 |
|
|
if (vm[fetchbuf1_instr[25:23]][IsVector(fetchbuf0_instr)? 6'd0:vqe1+6'd1])
|
5784 |
|
|
vqet1 <= 6'd1;
|
5785 |
|
|
else
|
5786 |
|
|
vqet1 <= 6'd0;
|
5787 |
|
|
end
|
5788 |
|
|
else
|
5789 |
|
|
vqet1 <= 6'd1;
|
5790 |
|
|
if (IsVector(fetchbuf0_instr) && SUP_VECTOR)
|
5791 |
|
|
nop_fetchbuf <= fetchbuf ? 4'b1000 : 4'b0010;
|
5792 |
|
|
enque1(tail1,
|
5793 |
|
|
fetchbuf1_thrd==fetchbuf0_thrd && fetchbuf1_thrd==1'b1 ? seq_num1 + 5'd1 :
|
5794 |
|
|
fetchbuf1_thrd==fetchbuf0_thrd && fetchbuf1_thrd==1'b0 ? seq_num + 5'd1 :
|
5795 |
|
|
fetchbuf1_thrd ? seq_num1 + 5'd1: seq_num + 5'd1, 6'd0);
|
5796 |
|
|
if (fetchbuf1_thrd==fetchbuf0_thrd) begin
|
5797 |
|
|
if (fetchbuf1_thrd)
|
5798 |
|
|
seq_num1 <= seq_num1 + 5'd2;
|
5799 |
|
|
else
|
5800 |
|
|
seq_num <= seq_num + 5'd2;
|
5801 |
|
|
end
|
5802 |
|
|
else begin
|
5803 |
|
|
if (fetchbuf1_thrd)
|
5804 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5805 |
|
|
else
|
5806 |
|
|
seq_num <= seq_num + 5'd1;
|
5807 |
|
|
end
|
5808 |
|
|
|
5809 |
|
|
// SOURCE 1 ...
|
5810 |
|
|
// if the argument is an immediate or not needed, we're done
|
5811 |
|
|
if (Source1Valid( fetchbuf1_instr ) == `VAL) begin
|
5812 |
|
|
iqentry_a1_v [tail1] <= `VAL;
|
5813 |
|
|
iqentry_a1_s [tail1] <= 4'd0;
|
5814 |
|
|
end
|
5815 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5816 |
|
|
else if (~fetchbuf0_rfw) begin
|
5817 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra1s];
|
5818 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra1s];
|
5819 |
|
|
end
|
5820 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5821 |
|
|
else if (Ra1 == Rt0) begin
|
5822 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5823 |
|
|
iqentry_a1_v [tail1] <= `INV;
|
5824 |
|
|
iqentry_a1_s [tail1] <= { 1'b0, fetchbuf0_mem &IsLoad(fetchbuf0_instr), tail0 };
|
5825 |
|
|
end
|
5826 |
|
|
// if no overlap, get info from rf_v and rf_source
|
5827 |
|
|
else begin
|
5828 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra1s];
|
5829 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra1s];
|
5830 |
|
|
end
|
5831 |
|
|
|
5832 |
|
|
// SOURCE 2 ...
|
5833 |
|
|
// if the argument is an immediate or not needed, we're done
|
5834 |
|
|
if (Source2Valid( fetchbuf1_instr ) == `VAL) begin
|
5835 |
|
|
iqentry_a2_v [tail1] <= `VAL;
|
5836 |
|
|
iqentry_a2_s [tail1] <= 4'd0;
|
5837 |
|
|
end
|
5838 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5839 |
|
|
else if (~fetchbuf0_rfw) begin
|
5840 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb1s];
|
5841 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb1s ];
|
5842 |
|
|
end
|
5843 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5844 |
|
|
else if (Rb1s == Rt0s) begin
|
5845 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5846 |
|
|
iqentry_a2_v [tail1] <= `INV;
|
5847 |
|
|
iqentry_a2_s [tail1] <= { 1'b0, fetchbuf0_mem &IsLoad(fetchbuf0_instr), tail0 };
|
5848 |
|
|
end
|
5849 |
|
|
// if no overlap, get info from rf_v and rf_source
|
5850 |
|
|
else begin
|
5851 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb1s];
|
5852 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb1s ];
|
5853 |
|
|
end
|
5854 |
|
|
|
5855 |
|
|
// SOURCE 3 ...
|
5856 |
|
|
// if the argument is an immediate or not needed, we're done
|
5857 |
|
|
if (Source3Valid( fetchbuf1_instr ) == `VAL) begin
|
5858 |
|
|
iqentry_a3_v [tail1] <= `VAL;
|
5859 |
|
|
iqentry_a3_s [tail1] <= 4'd0;
|
5860 |
|
|
end
|
5861 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5862 |
|
|
else if (~fetchbuf0_rfw) begin
|
5863 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc1s];
|
5864 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc1s ];
|
5865 |
|
|
end
|
5866 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5867 |
|
|
else if (Rc1 == Rt0) begin
|
5868 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5869 |
|
|
iqentry_a3_v [tail1] <= `INV;
|
5870 |
|
|
iqentry_a3_s [tail1] <= { 1'b0, fetchbuf0_mem &IsLoad(fetchbuf0_instr), tail0 };
|
5871 |
|
|
end
|
5872 |
|
|
// if no overlap, get info from rf_v and rf_source
|
5873 |
|
|
else begin
|
5874 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc1s];
|
5875 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc1s ];
|
5876 |
|
|
end
|
5877 |
|
|
|
5878 |
|
|
// if the two instructions enqueued target the same register,
|
5879 |
|
|
// make sure only the second writes to rf_v and rf_source.
|
5880 |
|
|
// first is allowed to update rf_v and rf_source only if the
|
5881 |
|
|
// second has no target
|
5882 |
|
|
//
|
5883 |
|
|
if (fetchbuf0_rfw) begin
|
5884 |
|
|
rf_source[ Rt0s ] <= { 1'b0,fetchbuf0_memld, tail0 };
|
5885 |
|
|
rf_v [ Rt0s] <= `INV;
|
5886 |
|
|
end
|
5887 |
|
|
if (fetchbuf1_rfw) begin
|
5888 |
|
|
rf_source[ Rt1s ] <= { 1'b0,fetchbuf1_memld, tail1 };
|
5889 |
|
|
rf_v [ Rt1s ] <= `INV;
|
5890 |
|
|
end
|
5891 |
|
|
end
|
5892 |
|
|
else begin
|
5893 |
|
|
// enque1(tail1, seq_num + 5'd1, 6'd0);
|
5894 |
|
|
enque1(tail1,
|
5895 |
|
|
fetchbuf1_thrd==fetchbuf0_thrd && fetchbuf1_thrd==1'b1 ? seq_num1 + 5'd1 :
|
5896 |
|
|
fetchbuf1_thrd==fetchbuf0_thrd && fetchbuf1_thrd==1'b0 ? seq_num + 5'd1 :
|
5897 |
|
|
fetchbuf1_thrd ? seq_num1: seq_num, 6'd0);
|
5898 |
|
|
if (fetchbuf1_thrd==fetchbuf0_thrd) begin
|
5899 |
|
|
if (fetchbuf1_thrd)
|
5900 |
|
|
seq_num1 <= seq_num1 + 5'd2;
|
5901 |
|
|
else
|
5902 |
|
|
seq_num <= seq_num + 5'd2;
|
5903 |
|
|
end
|
5904 |
|
|
else begin
|
5905 |
|
|
seq_num1 <= seq_num1 + 5'd1;
|
5906 |
|
|
seq_num <= seq_num + 5'd1;
|
5907 |
|
|
end
|
5908 |
|
|
|
5909 |
|
|
// SOURCE 1 ...
|
5910 |
|
|
// if the argument is an immediate or not needed, we're done
|
5911 |
|
|
if (Source1Valid( fetchbuf1_instr ) == `VAL) begin
|
5912 |
|
|
iqentry_a1_v [tail1] <= `VAL;
|
5913 |
|
|
iqentry_a1_s [tail1] <= 4'd0;
|
5914 |
|
|
end
|
5915 |
|
|
// if previous instruction writes nothing to RF, then get info from rf_v and rf_source
|
5916 |
|
|
else if (~fetchbuf0_rfw) begin
|
5917 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra1s];
|
5918 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra1s];
|
5919 |
|
|
end
|
5920 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5921 |
|
|
else if (Ra1s == Rt0s) begin
|
5922 |
|
|
iqentry_a1_v [tail1] <= `INV;
|
5923 |
|
|
iqentry_a1_s [tail1] <= { 1'b0, fetchbuf0_memld, tail0 };
|
5924 |
|
|
end
|
5925 |
|
|
// if no overlap, get info from regIsValid and rf_source
|
5926 |
|
|
else begin
|
5927 |
|
|
iqentry_a1_v [tail1] <= regIsValid[Ra1s];
|
5928 |
|
|
iqentry_a1_s [tail1] <= rf_source [Ra1s];
|
5929 |
|
|
end
|
5930 |
|
|
|
5931 |
|
|
// SOURCE 2 ...
|
5932 |
|
|
// if the argument is an immediate or not needed, we're done
|
5933 |
|
|
$display("Rb1s=%h, Rt0s=%h", Rb1s, Rt0s);
|
5934 |
|
|
$display("instr=%h", fetchbuf1_instr);
|
5935 |
|
|
if (Source2Valid( fetchbuf1_instr ) == `VAL) begin
|
5936 |
|
|
$display("Source2=Valid, instr=%h", fetchbuf1_instr);
|
5937 |
|
|
iqentry_a2_v [tail1] <= `VAL;
|
5938 |
|
|
iqentry_a2_s [tail1] <= 4'd0;
|
5939 |
|
|
end
|
5940 |
|
|
// if previous instruction writes nothing to RF, then get info from regIsValid and rf_source
|
5941 |
|
|
else if (~fetchbuf0_rfw) begin
|
5942 |
|
|
$display("fetchbuf0_rfw=0");
|
5943 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb1s];
|
5944 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb1s ];
|
5945 |
|
|
end
|
5946 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5947 |
|
|
else if (Rb1s == Rt0s) begin
|
5948 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5949 |
|
|
iqentry_a2_v [tail1] <= `INV;
|
5950 |
|
|
iqentry_a2_s [tail1] <= { 1'b0, fetchbuf0_memld, tail0 };
|
5951 |
|
|
end
|
5952 |
|
|
// if no overlap, get info from regIsValid and rf_source
|
5953 |
|
|
else begin
|
5954 |
|
|
$display("No overlap");
|
5955 |
|
|
iqentry_a2_v [tail1] <= regIsValid[Rb1s];
|
5956 |
|
|
iqentry_a2_s [tail1] <= rf_source[ Rb1s ];
|
5957 |
|
|
end
|
5958 |
|
|
|
5959 |
|
|
// SOURCE 3 ...
|
5960 |
|
|
// if the argument is an immediate or not needed, we're done
|
5961 |
|
|
if (Source3Valid( fetchbuf1_instr ) == `VAL) begin
|
5962 |
|
|
iqentry_a3_v [tail1] <= `VAL;
|
5963 |
|
|
iqentry_a3_s [tail1] <= 4'd0;
|
5964 |
|
|
end
|
5965 |
|
|
// if previous instruction writes nothing to RF, then get info from regIsValid and rf_source
|
5966 |
|
|
else if (~fetchbuf0_rfw) begin
|
5967 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc1s];
|
5968 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc1s ];
|
5969 |
|
|
end
|
5970 |
|
|
// otherwise, previous instruction does write to RF ... see if overlap
|
5971 |
|
|
else if (Rc1s == Rt0s) begin
|
5972 |
|
|
// if the previous instruction is a LW, then grab result from memq, not the iq
|
5973 |
|
|
iqentry_a3_v [tail1] <= `INV;
|
5974 |
|
|
iqentry_a3_s [tail1] <= { 1'b0, fetchbuf0_memld, tail0 };
|
5975 |
|
|
end
|
5976 |
|
|
// if no overlap, get info from regIsValid and rf_source
|
5977 |
|
|
else begin
|
5978 |
|
|
iqentry_a3_v [tail1] <= regIsValid[Rc1s];
|
5979 |
|
|
iqentry_a3_s [tail1] <= rf_source[ Rc1s ];
|
5980 |
|
|
end
|
5981 |
|
|
|
5982 |
|
|
// if the two instructions enqueued target the same register,
|
5983 |
|
|
// make sure only the second writes to regIsValid and rf_source.
|
5984 |
|
|
// first is allowed to update regIsValid and rf_source only if the
|
5985 |
|
|
// second has no target (BEQ or SW)
|
5986 |
|
|
//
|
5987 |
|
|
if (fetchbuf0_rfw) begin
|
5988 |
|
|
rf_source[ Rt0s ] <= { 1'b0,fetchbuf0_memld, tail0 };
|
5989 |
|
|
rf_v [ Rt0s] <= `INV;
|
5990 |
|
|
$display("r%dx (%d) Invalidated", Rt0s, Rt0s[4:0]);
|
5991 |
|
|
end
|
5992 |
|
|
else
|
5993 |
|
|
$display("No rfw");
|
5994 |
|
|
if (fetchbuf1_rfw) begin
|
5995 |
|
|
rf_source[ Rt1s ] <= { 1'b0,fetchbuf1_memld, tail1 };
|
5996 |
|
|
$display("r%dx (%d) Invalidated", Rt1s, Rt1s[4:0]);
|
5997 |
|
|
rf_v [ Rt1s ] <= `INV;
|
5998 |
|
|
end
|
5999 |
|
|
else
|
6000 |
|
|
$display("No rfw");
|
6001 |
|
|
end
|
6002 |
|
|
|
6003 |
|
|
end // ends the "if IQ[tail1] is available" clause
|
6004 |
|
|
else begin // only first instruction was enqueued
|
6005 |
|
|
if (fetchbuf0_rfw) begin
|
6006 |
|
|
$display("r%dx (%d) Invalidated 1", Rt0s, Rt0s[4:0]);
|
6007 |
|
|
rf_source[ Rt0s ] <= {1'b0,fetchbuf0_memld, tail0};
|
6008 |
|
|
rf_v [ Rt0s ] <= `INV;
|
6009 |
|
|
end
|
6010 |
|
|
end
|
6011 |
|
|
end
|
6012 |
|
|
|
6013 |
|
|
end // ends the "else fetchbuf0 doesn't have a backwards branch" clause
|
6014 |
|
|
end
|
6015 |
|
|
endcase
|
6016 |
|
|
if (pebm) begin
|
6017 |
|
|
if (branchmiss_thrd==1'b0)
|
6018 |
|
|
seq_num <= seq_num + 5'd3;
|
6019 |
|
|
else
|
6020 |
|
|
seq_num1 <= seq_num1 + 5'd3;
|
6021 |
|
|
end
|
6022 |
|
|
|
6023 |
|
|
//
|
6024 |
|
|
// DATAINCOMING
|
6025 |
|
|
//
|
6026 |
|
|
// wait for operand/s to appear on alu busses and puts them into
|
6027 |
|
|
// the iqentry_a1 and iqentry_a2 slots (if appropriate)
|
6028 |
|
|
// as well as the appropriate iqentry_res slots (and setting valid bits)
|
6029 |
|
|
//
|
6030 |
|
|
// put results into the appropriate instruction entries
|
6031 |
|
|
//
|
6032 |
|
|
// This chunk of code has to be before the enqueue stage so that the agen bit
|
6033 |
|
|
// can be reset to zero by enqueue.
|
6034 |
|
|
// put results into the appropriate instruction entries
|
6035 |
|
|
//
|
6036 |
|
|
if (IsMul(alu0_instr)|IsDivmod(alu0_instr)) begin
|
6037 |
|
|
if (alu0_done) begin
|
6038 |
|
|
alu0_dataready <= `TRUE;
|
6039 |
|
|
end
|
6040 |
|
|
end
|
6041 |
|
|
|
6042 |
|
|
if (alu0_v) begin
|
6043 |
|
|
iqentry_tgt [ alu0_id[`QBITS] ] <= alu0_tgt;
|
6044 |
|
|
iqentry_res [ alu0_id[`QBITS] ] <= alu0_bus;
|
6045 |
|
|
iqentry_exc [ alu0_id[`QBITS] ] <= alu0_exc;
|
6046 |
|
|
iqentry_done[ alu0_id[`QBITS] ] <= !iqentry_mem[ alu0_id[`QBITS] ] && alu0_done;
|
6047 |
|
|
iqentry_cmt[ alu0_id[`QBITS] ] <= !iqentry_mem[ alu0_id[`QBITS] ] && alu0_done;
|
6048 |
|
|
iqentry_out [ alu0_id[`QBITS] ] <= `INV;
|
6049 |
|
|
iqentry_agen[ alu0_id[`QBITS] ] <= `VAL;//!iqentry_fc[alu0_id[`QBITS]]; // RET
|
6050 |
|
|
alu0_dataready <= FALSE;
|
6051 |
|
|
end
|
6052 |
|
|
if (alu1_v) begin
|
6053 |
|
|
iqentry_tgt [ alu1_id[`QBITS] ] <= alu1_tgt;
|
6054 |
|
|
iqentry_res [ alu1_id[`QBITS] ] <= alu1_bus;
|
6055 |
|
|
iqentry_exc [ alu1_id[`QBITS] ] <= alu1_exc;
|
6056 |
|
|
iqentry_done[ alu1_id[`QBITS] ] <= !iqentry_mem[ alu1_id[`QBITS] ] && alu1_done;
|
6057 |
|
|
iqentry_cmt[ alu1_id[`QBITS] ] <= !iqentry_mem[ alu1_id[`QBITS] ] && alu1_done;
|
6058 |
|
|
iqentry_out [ alu1_id[`QBITS] ] <= `INV;
|
6059 |
|
|
iqentry_agen[ alu1_id[`QBITS] ] <= `VAL;//!iqentry_fc[alu1_id[`QBITS]]; // RET
|
6060 |
|
|
alu1_dataready <= FALSE;
|
6061 |
|
|
end
|
6062 |
|
|
if (fpu_v) begin
|
6063 |
|
|
iqentry_res [ fpu_id[`QBITS] ] <= fpu_bus;
|
6064 |
|
|
iqentry_a0 [ fpu_id[`QBITS] ] <= fpu_status;
|
6065 |
|
|
iqentry_exc [ fpu_id[`QBITS] ] <= fpu_exc;
|
6066 |
|
|
iqentry_done[ fpu_id[`QBITS] ] <= fpu_done;
|
6067 |
|
|
iqentry_cmt[ fpu_id[`QBITS] ] <= fpu_done;
|
6068 |
|
|
iqentry_out [ fpu_id[`QBITS] ] <= `INV;
|
6069 |
|
|
//iqentry_agen[ fpu_id[`QBITS] ] <= `VAL; // RET
|
6070 |
|
|
fpu_dataready <= FALSE;
|
6071 |
|
|
end
|
6072 |
|
|
if (fcu_wr) begin
|
6073 |
|
|
if (fcu_ld)
|
6074 |
|
|
waitctr <= fcu_argA;
|
6075 |
|
|
iqentry_res [ fcu_id[`QBITS] ] <= fcu_bus;
|
6076 |
|
|
iqentry_exc [ fcu_id[`QBITS] ] <= fcu_exc;
|
6077 |
|
|
if (IsWait(fcu_instr)) begin
|
6078 |
|
|
iqentry_done [ fcu_id[`QBITS] ] <= (waitctr==64'd1) || signal_i[fcu_argA[4:0]|fcu_argI[4:0]];
|
6079 |
|
|
iqentry_cmt [ fcu_id[`QBITS] ] <= (waitctr==64'd1) || signal_i[fcu_argA[4:0]|fcu_argI[4:0]];
|
6080 |
|
|
fcu_done <= `TRUE;
|
6081 |
|
|
end
|
6082 |
|
|
else begin
|
6083 |
|
|
iqentry_done[ fcu_id[`QBITS] ] <= `TRUE;
|
6084 |
|
|
iqentry_cmt[ fcu_id[`QBITS] ] <= `TRUE;
|
6085 |
|
|
fcu_done <= `TRUE;
|
6086 |
|
|
end
|
6087 |
|
|
// if (IsWait(fcu_instr) ? (waitctr==64'd1) || signal_i[fcu_argA[4:0]|fcu_argI[4:0]] : !IsMem(fcu_instr) && !IsImmp(fcu_instr))
|
6088 |
|
|
// iqentry_instr[ dram_id[`QBITS]] <= `NOP_INSN;
|
6089 |
|
|
// Only safe place to propagate the miss pc is a0.
|
6090 |
|
|
iqentry_a0[ fcu_id[`QBITS] ] <= fcu_misspc;
|
6091 |
|
|
// Update branch taken indicator.
|
6092 |
|
|
if (IsJAL(fcu_instr) || IsRet(fcu_instr) || IsBrk(fcu_instr) || IsRTI(fcu_instr) ) begin
|
6093 |
|
|
iqentry_bt[ fcu_id[`QBITS] ] <= `VAL;
|
6094 |
|
|
// Only safe place to propagate the miss pc is a0.
|
6095 |
|
|
// iqentry_a0[ fcu_id[`QBITS] ] <= fcu_misspc;
|
6096 |
|
|
end
|
6097 |
|
|
else if (IsBranch(fcu_instr)) begin
|
6098 |
|
|
iqentry_bt[ fcu_id[`QBITS] ] <= fcu_takb;
|
6099 |
|
|
// iqentry_a0[ fcu_id[`QBITS] ] <= fcu_misspc;
|
6100 |
|
|
end
|
6101 |
|
|
iqentry_out [ fcu_id[`QBITS] ] <= `INV;
|
6102 |
|
|
//iqentry_agen[ fcu_id[`QBITS] ] <= `VAL;//!IsRet(fcu_instr);
|
6103 |
|
|
fcu_dataready <= fcu_branchmiss || !iqentry_agen[ fcu_id[`QBITS] ] || !(iqentry_mem[ fcu_id[`QBITS] ] && IsLoad(iqentry_instr[fcu_id[`QBITS]]));
|
6104 |
|
|
//fcu_instr[`INSTRUCTION_OP] <= fcu_branchmiss|| (!IsMem(fcu_instr) && !IsWait(fcu_instr))? `NOP : fcu_instr[`INSTRUCTION_OP]; // to clear branchmiss
|
6105 |
|
|
end
|
6106 |
|
|
// Clear a branch miss when target instruction is fetched.
|
6107 |
|
|
if (fcu_branchmiss) begin
|
6108 |
|
|
if ((fetchbuf0_v && fetchbuf0_pc==misspc) ||
|
6109 |
|
|
(fetchbuf1_v && fetchbuf1_pc==misspc))
|
6110 |
|
|
fcu_dataready <= `INV;
|
6111 |
|
|
//fcu_instr[`INSTRUCTION_OP] <= `NOP;
|
6112 |
|
|
//iqentry_instr[fcu_id][`INSTRUCTION_OP] <= `NOP;
|
6113 |
|
|
end
|
6114 |
|
|
// if (dram_v && iqentry_v[ dram_id[`QBITS] ] && iqentry_mem[ dram_id[`QBITS] ] ) begin // if data for stomped instruction, ignore
|
6115 |
|
|
if (dramA_v && iqentry_v[ dramA_id[`QBITS] ] && iqentry_load[ dramA_id[`QBITS] ] ) begin // if data for stomped instruction, ignore
|
6116 |
|
|
iqentry_res [ dramA_id[`QBITS] ] <= dramA_bus;
|
6117 |
|
|
iqentry_exc [ dramA_id[`QBITS] ] <= dramA_exc;
|
6118 |
|
|
iqentry_done[ dramA_id[`QBITS] ] <= `VAL;
|
6119 |
|
|
iqentry_out [ dramA_id[`QBITS] ] <= `INV;
|
6120 |
|
|
iqentry_cmt[ dramA_id[`QBITS] ] <= `VAL;
|
6121 |
|
|
iqentry_aq [ dramA_id[`QBITS] ] <= `INV;
|
6122 |
|
|
end
|
6123 |
|
|
if (dramB_v && iqentry_v[ dramB_id[`QBITS] ] && iqentry_load[ dramB_id[`QBITS] ] ) begin // if data for stomped instruction, ignore
|
6124 |
|
|
iqentry_res [ dramB_id[`QBITS] ] <= dramB_bus;
|
6125 |
|
|
iqentry_exc [ dramB_id[`QBITS] ] <= dramB_exc;
|
6126 |
|
|
iqentry_done[ dramB_id[`QBITS] ] <= `VAL;
|
6127 |
|
|
iqentry_out [ dramB_id[`QBITS] ] <= `INV;
|
6128 |
|
|
iqentry_cmt[ dramB_id[`QBITS] ] <= `VAL;
|
6129 |
|
|
iqentry_aq [ dramB_id[`QBITS] ] <= `INV;
|
6130 |
|
|
end
|
6131 |
|
|
if (dramC_v && iqentry_v[ dramC_id[`QBITS] ] && iqentry_load[ dramC_id[`QBITS] ] ) begin // if data for stomped instruction, ignore
|
6132 |
|
|
iqentry_res [ dramC_id[`QBITS] ] <= dramC_bus;
|
6133 |
|
|
iqentry_exc [ dramC_id[`QBITS] ] <= dramC_exc;
|
6134 |
|
|
iqentry_done[ dramC_id[`QBITS] ] <= `VAL;
|
6135 |
|
|
iqentry_out [ dramC_id[`QBITS] ] <= `INV;
|
6136 |
|
|
iqentry_cmt[ dramC_id[`QBITS] ] <= `VAL;
|
6137 |
|
|
iqentry_aq [ dramC_id[`QBITS] ] <= `INV;
|
6138 |
|
|
end
|
6139 |
|
|
|
6140 |
|
|
//
|
6141 |
|
|
// set the IQ entry == DONE as soon as the SW is let loose to the memory system
|
6142 |
|
|
//
|
6143 |
|
|
if (dram0 == `DRAMSLOT_BUSY && IsStore(dram0_instr)) begin
|
6144 |
|
|
if ((alu0_v && (dram0_id[`QBITS] == alu0_id[`QBITS])) || (alu1_v && (dram0_id[`QBITS] == alu1_id[`QBITS]))) panic <= `PANIC_MEMORYRACE;
|
6145 |
|
|
iqentry_done[ dram0_id[`QBITS] ] <= `VAL;
|
6146 |
|
|
iqentry_out[ dram0_id[`QBITS] ] <= `INV;
|
6147 |
|
|
end
|
6148 |
|
|
if (dram1 == `DRAMSLOT_BUSY && IsStore(dram1_instr)) begin
|
6149 |
|
|
if ((alu0_v && (dram1_id[`QBITS] == alu0_id[`QBITS])) || (alu1_v && (dram1_id[`QBITS] == alu1_id[`QBITS]))) panic <= `PANIC_MEMORYRACE;
|
6150 |
|
|
iqentry_done[ dram1_id[`QBITS] ] <= `VAL;
|
6151 |
|
|
iqentry_out[ dram1_id[`QBITS] ] <= `INV;
|
6152 |
|
|
end
|
6153 |
|
|
if (dram2 == `DRAMSLOT_BUSY && IsStore(dram2_instr)) begin
|
6154 |
|
|
if ((alu0_v && (dram2_id[`QBITS] == alu0_id[`QBITS])) || (alu1_v && (dram2_id[`QBITS] == alu1_id[`QBITS]))) panic <= `PANIC_MEMORYRACE;
|
6155 |
|
|
iqentry_done[ dram2_id[`QBITS] ] <= `VAL;
|
6156 |
|
|
iqentry_out[ dram2_id[`QBITS] ] <= `INV;
|
6157 |
|
|
end
|
6158 |
|
|
|
6159 |
|
|
//
|
6160 |
|
|
// see if anybody else wants the results ... look at lots of buses:
|
6161 |
|
|
// - fpu_bus
|
6162 |
|
|
// - alu0_bus
|
6163 |
|
|
// - alu1_bus
|
6164 |
|
|
// - fcu_bus
|
6165 |
|
|
// - dram_bus
|
6166 |
|
|
// - commit0_bus
|
6167 |
|
|
// - commit1_bus
|
6168 |
|
|
//
|
6169 |
|
|
|
6170 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6171 |
|
|
begin
|
6172 |
|
|
setargs(n,{1'b0,fpu_id},fpu_v,fpu_bus);
|
6173 |
|
|
setargs(n,{1'b0,alu0_id},alu0_v,alu0_bus);
|
6174 |
|
|
setargs(n,{1'b0,alu1_id},alu1_v,alu1_bus);
|
6175 |
|
|
setargs(n,{1'b0,fcu_id},fcu_wr,fcu_bus);
|
6176 |
|
|
setargs(n,{1'b0,dramA_id},dramA_v,dramA_bus);
|
6177 |
|
|
setargs(n,{1'b0,dramB_id},dramB_v,dramB_bus);
|
6178 |
|
|
setargs(n,{1'b0,dramC_id},dramC_v,dramC_bus);
|
6179 |
|
|
setargs(n,commit0_id,commit0_v,commit0_bus);
|
6180 |
|
|
setargs(n,commit1_id,commit1_v,commit1_bus);
|
6181 |
|
|
end
|
6182 |
|
|
|
6183 |
|
|
//
|
6184 |
|
|
// ISSUE
|
6185 |
|
|
//
|
6186 |
|
|
// determines what instructions are ready to go, then places them
|
6187 |
|
|
// in the various ALU queues.
|
6188 |
|
|
// also invalidates instructions following a branch-miss BEQ or any JALR (STOMP logic)
|
6189 |
|
|
//
|
6190 |
|
|
|
6191 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6192 |
|
|
if (iqentry_issue[n] && !(iqentry_v[n] && iqentry_stomp[n])) begin
|
6193 |
|
|
case (iqentry_islot[n])
|
6194 |
|
|
2'd0: if (alu0_available & alu0_done) begin
|
6195 |
|
|
alu0_sourceid <= n[3:0];
|
6196 |
|
|
alu0_pred <= iqentry_pred[n];
|
6197 |
|
|
alu0_instr <= iqentry_instr[n];
|
6198 |
|
|
alu0_bt <= iqentry_bt[n];
|
6199 |
|
|
alu0_pc <= iqentry_pc[n];
|
6200 |
|
|
alu0_argA <= iqentry_a1_v[n] ? iqentry_a1[n]
|
6201 |
|
|
: (iqentry_a1_s[n] == alu0_id) ? alu0_bus
|
6202 |
|
|
: (iqentry_a1_s[n] == alu1_id) ? alu1_bus
|
6203 |
|
|
: {4{16'hDEAD}};
|
6204 |
|
|
alu0_argB <= iqentry_imm[n]
|
6205 |
|
|
? iqentry_a0[n]
|
6206 |
|
|
: (iqentry_a2_v[n] ? iqentry_a2[n]
|
6207 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus
|
6208 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus
|
6209 |
|
|
: {4{16'hDEAD}});
|
6210 |
|
|
alu0_argC <= iqentry_a3_v[n] ? iqentry_a3[n]
|
6211 |
|
|
: (iqentry_a3_s[n] == alu0_id) ? alu0_bus
|
6212 |
|
|
: (iqentry_a3_s[n] == alu1_id) ? alu1_bus
|
6213 |
|
|
: {4{16'hDEAD}};
|
6214 |
|
|
alu0_argI <= iqentry_a0[n];
|
6215 |
|
|
alu0_tgt <= IsVeins(iqentry_instr[n]) ?
|
6216 |
|
|
{6'h0,1'b1,iqentry_tgt[n][4:0]} | ((iqentry_a2_v[n] ? iqentry_a2[n][5:0]
|
6217 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus[5:0]
|
6218 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus[5:0]
|
6219 |
|
|
: {4{16'h0000}})) << 6 :
|
6220 |
|
|
iqentry_tgt[n];
|
6221 |
|
|
alu0_ven <= iqentry_ven[n];
|
6222 |
|
|
alu0_thrd <= iqentry_thrd[n];
|
6223 |
|
|
alu0_dataready <= IsSingleCycle(iqentry_instr[n]);
|
6224 |
|
|
alu0_ld <= TRUE;
|
6225 |
|
|
iqentry_out[n] <= `VAL;
|
6226 |
|
|
// if it is a memory operation, this is the address-generation step ... collect result into arg1
|
6227 |
|
|
if (iqentry_mem[n]) begin
|
6228 |
|
|
iqentry_a1_v[n] <= `INV;
|
6229 |
|
|
iqentry_a1_s[n] <= n[3:0];
|
6230 |
|
|
end
|
6231 |
|
|
end
|
6232 |
|
|
2'd1: if (alu1_available && alu1_done) begin
|
6233 |
|
|
alu1_sourceid <= n[3:0];
|
6234 |
|
|
alu1_pred <= iqentry_pred[n];
|
6235 |
|
|
alu1_instr <= iqentry_instr[n];
|
6236 |
|
|
alu1_bt <= iqentry_bt[n];
|
6237 |
|
|
alu1_pc <= iqentry_pc[n];
|
6238 |
|
|
alu1_argA <= iqentry_a1_v[n] ? iqentry_a1[n]
|
6239 |
|
|
: (iqentry_a1_s[n] == alu0_id) ? alu0_bus
|
6240 |
|
|
: (iqentry_a1_s[n] == alu1_id) ? alu1_bus
|
6241 |
|
|
: {4{16'hDEAD}};
|
6242 |
|
|
alu1_argB <= iqentry_imm[n]
|
6243 |
|
|
? iqentry_a0[n]
|
6244 |
|
|
: (iqentry_a2_v[n] ? iqentry_a2[n]
|
6245 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus
|
6246 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus
|
6247 |
|
|
: {4{16'hDEAD}});
|
6248 |
|
|
alu1_argC <= iqentry_a3_v[n] ? iqentry_a3[n]
|
6249 |
|
|
: (iqentry_a3_s[n] == alu0_id) ? alu0_bus
|
6250 |
|
|
: (iqentry_a3_s[n] == alu1_id) ? alu1_bus
|
6251 |
|
|
: {4{16'hDEAD}};
|
6252 |
|
|
alu1_argI <= iqentry_a0[n];
|
6253 |
|
|
alu1_tgt <= IsVeins(iqentry_instr[n]) ?
|
6254 |
|
|
{6'h0,1'b1,iqentry_tgt[n][4:0]} | ((iqentry_a2_v[n] ? iqentry_a2[n][5:0]
|
6255 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus[5:0]
|
6256 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus[5:0]
|
6257 |
|
|
: {4{16'h0000}})) << 6 :
|
6258 |
|
|
iqentry_tgt[n];
|
6259 |
|
|
alu1_ven <= iqentry_ven[n];
|
6260 |
|
|
alu1_dataready <= IsSingleCycle(iqentry_instr[n]);
|
6261 |
|
|
alu1_ld <= TRUE;
|
6262 |
|
|
iqentry_out[n] <= `VAL;
|
6263 |
|
|
// if it is a memory operation, this is the address-generation step ... collect result into arg1
|
6264 |
|
|
if (iqentry_mem[n]) begin
|
6265 |
|
|
iqentry_a1_v[n] <= `INV;
|
6266 |
|
|
iqentry_a1_s[n] <= n[3:0];
|
6267 |
|
|
end
|
6268 |
|
|
end
|
6269 |
|
|
default: panic <= `PANIC_INVALIDISLOT;
|
6270 |
|
|
endcase
|
6271 |
|
|
end
|
6272 |
|
|
|
6273 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6274 |
|
|
if (iqentry_fpu_issue[n] && !(iqentry_v[n] && iqentry_stomp[n])) begin
|
6275 |
|
|
if (fpu_done) begin
|
6276 |
|
|
fpu_sourceid <= n[3:0];
|
6277 |
|
|
fpu_pred <= iqentry_pred[n];
|
6278 |
|
|
fpu_instr <= iqentry_instr[n];
|
6279 |
|
|
fpu_pc <= iqentry_pc[n];
|
6280 |
|
|
fpu_argA <= iqentry_a1_v[n] ? iqentry_a1[n]
|
6281 |
|
|
: (iqentry_a1_s[n] == alu0_id) ? alu0_bus
|
6282 |
|
|
: (iqentry_a1_s[n] == alu1_id) ? alu1_bus
|
6283 |
|
|
: {4{16'hDEAD}};
|
6284 |
|
|
fpu_argB <= (iqentry_a2_v[n] ? iqentry_a2[n]
|
6285 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus
|
6286 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus
|
6287 |
|
|
: {4{16'hDEAD}});
|
6288 |
|
|
fpu_argC <= iqentry_a3_v[n] ? iqentry_a3[n]
|
6289 |
|
|
: (iqentry_a3_s[n] == alu0_id) ? alu0_bus
|
6290 |
|
|
: (iqentry_a3_s[n] == alu1_id) ? alu1_bus
|
6291 |
|
|
: {4{16'hDEAD}};
|
6292 |
|
|
fpu_argI <= iqentry_a0[n];
|
6293 |
|
|
fpu_dataready <= `VAL;
|
6294 |
|
|
fpu_ld <= TRUE;
|
6295 |
|
|
iqentry_out[n] <= `VAL;
|
6296 |
|
|
end
|
6297 |
|
|
end
|
6298 |
|
|
|
6299 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6300 |
|
|
if (iqentry_fcu_issue[n] && !(iqentry_v[n] && iqentry_stomp[n])) begin
|
6301 |
|
|
if (fcu_done) begin
|
6302 |
|
|
fcu_sourceid <= n[3:0];
|
6303 |
|
|
fcu_pred <= iqentry_pred[n];
|
6304 |
|
|
fcu_instr <= iqentry_instr[n];
|
6305 |
|
|
fcu_call <= IsCall(iqentry_instr[n])|IsJAL(iqentry_instr[n]);
|
6306 |
|
|
fcu_bt <= iqentry_bt[n];
|
6307 |
|
|
fcu_pc <= iqentry_pc[n];
|
6308 |
|
|
fcu_argA <= iqentry_a1_v[n] ? iqentry_a1[n]
|
6309 |
|
|
: (iqentry_a1_s[n] == alu0_id) ? alu0_bus
|
6310 |
|
|
: (iqentry_a1_s[n] == alu1_id) ? alu1_bus
|
6311 |
|
|
: {4{16'hDEAD}};
|
6312 |
|
|
fcu_argB <= IsRTI(iqentry_instr[n]) ? epc0[iqentry_thrd[n]]
|
6313 |
|
|
: (iqentry_a2_v[n] ? iqentry_a2[n]
|
6314 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus
|
6315 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus
|
6316 |
|
|
: {4{16'hDEAD}});
|
6317 |
|
|
waitctr <= iqentry_imm[n]
|
6318 |
|
|
? iqentry_a0[n]
|
6319 |
|
|
: (iqentry_a2_v[n] ? iqentry_a2[n]
|
6320 |
|
|
: (iqentry_a2_s[n] == alu0_id) ? alu0_bus
|
6321 |
|
|
: (iqentry_a2_s[n] == alu1_id) ? alu1_bus
|
6322 |
|
|
: {4{16'hDEAD}});
|
6323 |
|
|
fcu_argC <= iqentry_a3_v[n] ? iqentry_a3[n]
|
6324 |
|
|
: (iqentry_a3_s[n] == alu0_id) ? alu0_bus
|
6325 |
|
|
: (iqentry_a3_s[n] == alu1_id) ? alu1_bus
|
6326 |
|
|
: {4{16'hDEAD}};
|
6327 |
|
|
fcu_argI <= iqentry_a0[n];
|
6328 |
|
|
fcu_thrd <= iqentry_thrd[n];
|
6329 |
|
|
fcu_dataready <= `VAL;
|
6330 |
|
|
fcu_retadr_v <= `INV;
|
6331 |
|
|
fcu_ld <= TRUE;
|
6332 |
|
|
fcu_timeout <= 8'h00;
|
6333 |
|
|
iqentry_out[n] <= `VAL;
|
6334 |
|
|
fcu_done <= `FALSE;
|
6335 |
|
|
end
|
6336 |
|
|
end
|
6337 |
|
|
//
|
6338 |
|
|
// MEMORY
|
6339 |
|
|
//
|
6340 |
|
|
// update the memory queues and put data out on bus if appropriate
|
6341 |
|
|
//
|
6342 |
|
|
|
6343 |
|
|
//
|
6344 |
|
|
// dram0, dram1, dram2 are the "state machines" that keep track
|
6345 |
|
|
// of three pipelined DRAM requests. if any has the value "00",
|
6346 |
|
|
// then it can accept a request (which bumps it up to the value "01"
|
6347 |
|
|
// at the end of the cycle). once it hits the value "11" the request
|
6348 |
|
|
// is finished and the dram_bus takes the value. if it is a store, the
|
6349 |
|
|
// dram_bus value is not used, but the dram_v value along with the
|
6350 |
|
|
// dram_id value signals the waiting memq entry that the store is
|
6351 |
|
|
// completed and the instruction can commit.
|
6352 |
|
|
//
|
6353 |
|
|
|
6354 |
|
|
// if (dram0 != `DRAMSLOT_AVAIL) dram0 <= dram0 + 2'd1;
|
6355 |
|
|
// if (dram1 != `DRAMSLOT_AVAIL) dram1 <= dram1 + 2'd1;
|
6356 |
|
|
// if (dram2 != `DRAMSLOT_AVAIL) dram2 <= dram2 + 2'd1;
|
6357 |
|
|
|
6358 |
|
|
//
|
6359 |
|
|
// grab requests that have finished and put them on the dram_bus
|
6360 |
|
|
if (dram0 == `DRAMREQ_READY) begin
|
6361 |
|
|
dram0 <= `DRAMSLOT_AVAIL;
|
6362 |
|
|
dramA_v <= dram0_load;
|
6363 |
|
|
dramA_id <= dram0_id;
|
6364 |
|
|
dramA_exc <= dram0_exc;
|
6365 |
|
|
dramA_bus <= fnDati(dram0_instr,dram0_addr,rdat0);
|
6366 |
|
|
if (IsStore(dram0_instr)) $display("m[%h] <- %h", dram0_addr, dram0_data);
|
6367 |
|
|
end
|
6368 |
|
|
// else
|
6369 |
|
|
// dramA_v <= `INV;
|
6370 |
|
|
if (dram1 == `DRAMREQ_READY) begin
|
6371 |
|
|
dram1 <= `DRAMSLOT_AVAIL;
|
6372 |
|
|
dramB_v <= dram1_load;
|
6373 |
|
|
dramB_id <= dram1_id;
|
6374 |
|
|
dramB_exc <= dram1_exc;
|
6375 |
|
|
dramB_bus <= fnDati(dram1_instr,dram1_addr,rdat1);
|
6376 |
|
|
if (IsStore(dram1_instr)) $display("m[%h] <- %h", dram1_addr, dram1_data);
|
6377 |
|
|
end
|
6378 |
|
|
// else
|
6379 |
|
|
// dramB_v <= `INV;
|
6380 |
|
|
if (dram2 == `DRAMREQ_READY) begin
|
6381 |
|
|
dram2 <= `DRAMSLOT_AVAIL;
|
6382 |
|
|
dramC_v <= dram2_load;
|
6383 |
|
|
dramC_id <= dram2_id;
|
6384 |
|
|
dramC_exc <= dram2_exc;
|
6385 |
|
|
dramC_bus <= fnDati(dram2_instr,dram2_addr,rdat2);
|
6386 |
|
|
if (IsStore(dram2_instr)) $display("m[%h] <- %h", dram2_addr, dram2_data);
|
6387 |
|
|
end
|
6388 |
|
|
// else
|
6389 |
|
|
// dramC_v <= `INV;
|
6390 |
|
|
|
6391 |
|
|
//
|
6392 |
|
|
// determine if the instructions ready to issue can, in fact, issue.
|
6393 |
|
|
// "ready" means that the instruction has valid operands but has not gone yet
|
6394 |
|
|
iqentry_memissue <= memissue;
|
6395 |
|
|
missue_count <= issue_count;
|
6396 |
|
|
|
6397 |
|
|
|
6398 |
|
|
//
|
6399 |
|
|
// take requests that are ready and put them into DRAM slots
|
6400 |
|
|
|
6401 |
|
|
if (dram0 == `DRAMSLOT_AVAIL) dram0_exc <= `FLT_NONE;
|
6402 |
|
|
if (dram1 == `DRAMSLOT_AVAIL) dram1_exc <= `FLT_NONE;
|
6403 |
|
|
if (dram2 == `DRAMSLOT_AVAIL) dram2_exc <= `FLT_NONE;
|
6404 |
|
|
|
6405 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6406 |
|
|
if (iqentry_v[n] && iqentry_stomp[n]) begin
|
6407 |
|
|
iqentry_v[n] <= `INV;
|
6408 |
|
|
if (dram0_id[`QBITS] == n[`QBITS]) dram0 <= `DRAMSLOT_AVAIL;
|
6409 |
|
|
if (dram1_id[`QBITS] == n[`QBITS]) dram1 <= `DRAMSLOT_AVAIL;
|
6410 |
|
|
if (dram2_id[`QBITS] == n[`QBITS]) dram2 <= `DRAMSLOT_AVAIL;
|
6411 |
|
|
end
|
6412 |
|
|
|
6413 |
|
|
last_issue = 8;
|
6414 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6415 |
|
|
if (~iqentry_stomp[n] && iqentry_memissue[n] && iqentry_agen[n] && ~iqentry_out[n]) begin
|
6416 |
|
|
if (dram0 == `DRAMSLOT_AVAIL) begin
|
6417 |
|
|
dramA_v <= `INV;
|
6418 |
|
|
dram0 <= `DRAMSLOT_BUSY;
|
6419 |
|
|
dram0_id <= { 1'b1, n[`QBITS] };
|
6420 |
|
|
dram0_instr <= iqentry_instr[n];
|
6421 |
|
|
dram0_tgt <= iqentry_tgt[n];
|
6422 |
|
|
dram0_data <= iqentry_memndx[n] ? iqentry_a3[n] : iqentry_a2[n];
|
6423 |
|
|
dram0_addr <= iqentry_a1[n];
|
6424 |
|
|
dram0_unc <= iqentry_a1[n][31:20]==12'hFFD || !dce || IsVolatileLoad(iqentry_instr[n]);
|
6425 |
|
|
dram0_memsize <= MemSize(iqentry_instr[n]);
|
6426 |
|
|
dram0_load <= iqentry_load[n];
|
6427 |
|
|
last_issue = n;
|
6428 |
|
|
end
|
6429 |
|
|
end
|
6430 |
|
|
if (last_issue < 8)
|
6431 |
|
|
iqentry_out[last_issue] <= `VAL;
|
6432 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6433 |
|
|
if (~iqentry_stomp[n] && iqentry_memissue[n] && iqentry_agen[n] && ~iqentry_out[n]) begin
|
6434 |
|
|
if (n < last_issue) begin
|
6435 |
|
|
if (dram1 == `DRAMSLOT_AVAIL) begin
|
6436 |
|
|
dramB_v <= `INV;
|
6437 |
|
|
dram1 <= `DRAMSLOT_BUSY;
|
6438 |
|
|
dram1_id <= { 1'b1, n[`QBITS] };
|
6439 |
|
|
dram1_instr <= iqentry_instr[n];
|
6440 |
|
|
dram1_tgt <= iqentry_tgt[n];
|
6441 |
|
|
dram1_data <= iqentry_memndx[n] ? iqentry_a3[n] : iqentry_a2[n];
|
6442 |
|
|
dram1_addr <= iqentry_a1[n];
|
6443 |
|
|
dram1_unc <= iqentry_a1[n][31:20]==12'hFFD || !dce || IsVolatileLoad(iqentry_instr[n]);
|
6444 |
|
|
dram1_memsize <= MemSize(iqentry_instr[n]);
|
6445 |
|
|
dram1_load <= iqentry_load[n];
|
6446 |
|
|
last_issue = n;
|
6447 |
|
|
end
|
6448 |
|
|
end
|
6449 |
|
|
end
|
6450 |
|
|
if (last_issue < 8)
|
6451 |
|
|
iqentry_out[last_issue] <= `VAL;
|
6452 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6453 |
|
|
if (~iqentry_stomp[n] && iqentry_memissue[n] && iqentry_agen[n] && ~iqentry_out[n]) begin
|
6454 |
|
|
if (n < last_issue) begin
|
6455 |
|
|
if (dram2 == `DRAMSLOT_AVAIL) begin
|
6456 |
|
|
dramC_v <= `INV;
|
6457 |
|
|
dram2 <= `DRAMSLOT_BUSY;
|
6458 |
|
|
dram2_id <= { 1'b1, n[`QBITS] };
|
6459 |
|
|
dram2_instr <= iqentry_instr[n];
|
6460 |
|
|
dram2_tgt <= iqentry_tgt[n];
|
6461 |
|
|
dram2_data <= iqentry_memndx[n] ? iqentry_a3[n] : iqentry_a2[n];
|
6462 |
|
|
dram2_addr <= iqentry_a1[n];
|
6463 |
|
|
dram2_unc <= iqentry_a1[n][31:20]==12'hFFD || !dce || IsVolatileLoad(iqentry_instr[n]);
|
6464 |
|
|
dram2_memsize <= MemSize(iqentry_instr[n]);
|
6465 |
|
|
dram2_load <= iqentry_load[n];
|
6466 |
|
|
end
|
6467 |
|
|
end
|
6468 |
|
|
end
|
6469 |
|
|
if (last_issue < 8)
|
6470 |
|
|
iqentry_out[last_issue] <= `VAL;
|
6471 |
|
|
|
6472 |
|
|
// It's better to check a sequence number here because if the code is in a
|
6473 |
|
|
// loop that such that the previous iteration of the loop is still in the
|
6474 |
|
|
// queue the PC could match when we don;t really want a prefix for that
|
6475 |
|
|
// iteration.
|
6476 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
6477 |
|
|
begin
|
6478 |
|
|
if (!iqentry_v[n])
|
6479 |
|
|
iqentry_done[n] <= FALSE;
|
6480 |
|
|
end
|
6481 |
|
|
|
6482 |
|
|
|
6483 |
|
|
|
6484 |
|
|
//
|
6485 |
|
|
// COMMIT PHASE (dequeue only ... not register-file update)
|
6486 |
|
|
//
|
6487 |
|
|
// look at head0 and head1 and let 'em write to the register file if they are ready
|
6488 |
|
|
//
|
6489 |
|
|
// always @(posedge clk) begin: commit_phase
|
6490 |
|
|
|
6491 |
|
|
oddball_commit(commit0_v, head0);
|
6492 |
|
|
oddball_commit(commit1_v, head1);
|
6493 |
|
|
|
6494 |
|
|
// Fetch and queue are limited to two instructions per cycle, so we might as
|
6495 |
|
|
// well limit retiring to two instructions max to conserve logic.
|
6496 |
|
|
//
|
6497 |
|
|
if (~|panic)
|
6498 |
|
|
casez ({ iqentry_v[head0],
|
6499 |
|
|
iqentry_cmt[head0],
|
6500 |
|
|
iqentry_v[head1],
|
6501 |
|
|
iqentry_cmt[head1]})
|
6502 |
|
|
|
6503 |
|
|
// retire 3
|
6504 |
|
|
4'b0?_0?:
|
6505 |
|
|
if (head0 != tail0 && head1 != tail0) begin
|
6506 |
|
|
head_inc(2);
|
6507 |
|
|
end
|
6508 |
|
|
else if (head0 != tail0) begin
|
6509 |
|
|
head_inc(1);
|
6510 |
|
|
end
|
6511 |
|
|
|
6512 |
|
|
// retire 1 (wait for regfile for head1)
|
6513 |
|
|
4'b0?_10:
|
6514 |
|
|
head_inc(1);
|
6515 |
|
|
|
6516 |
|
|
// retire 2
|
6517 |
|
|
4'b0?_11:
|
6518 |
|
|
begin
|
6519 |
|
|
iqentry_v[head1] <= `INV;
|
6520 |
|
|
head_inc(2);
|
6521 |
|
|
end
|
6522 |
|
|
|
6523 |
|
|
// retire 0 (stuck on head0)
|
6524 |
|
|
4'b10_??: ;
|
6525 |
|
|
|
6526 |
|
|
// retire 1 or 2
|
6527 |
|
|
4'b11_0?:
|
6528 |
|
|
if (head1 != tail0) begin
|
6529 |
|
|
iqentry_v[head0] <= `INV;
|
6530 |
|
|
head_inc(2);
|
6531 |
|
|
end
|
6532 |
|
|
else begin
|
6533 |
|
|
iqentry_v[head0] <= `INV;
|
6534 |
|
|
head_inc(1);
|
6535 |
|
|
end
|
6536 |
|
|
|
6537 |
|
|
// retire 1 (wait for regfile for head1)
|
6538 |
|
|
4'b11_10:
|
6539 |
|
|
begin
|
6540 |
|
|
iqentry_v[head0] <= `INV;
|
6541 |
|
|
head_inc(1);
|
6542 |
|
|
end
|
6543 |
|
|
|
6544 |
|
|
// retire 2
|
6545 |
|
|
4'b11_11:
|
6546 |
|
|
begin
|
6547 |
|
|
iqentry_v[head0] <= `INV; // may conflict with STOMP, but since both are setting to 0, it is okay
|
6548 |
|
|
iqentry_v[head1] <= `INV; // may conflict with STOMP, but since both are setting to 0, it is okay
|
6549 |
|
|
head_inc(2);
|
6550 |
|
|
end
|
6551 |
|
|
endcase
|
6552 |
|
|
|
6553 |
|
|
|
6554 |
|
|
rf_source[0] <= 0;
|
6555 |
|
|
L1_wr0 <= FALSE;
|
6556 |
|
|
L1_wr1 <= FALSE;
|
6557 |
|
|
L1_invline <= FALSE;
|
6558 |
|
|
icnxt <= FALSE;
|
6559 |
|
|
L2_nxt <= FALSE;
|
6560 |
|
|
// Instruction cache state machine.
|
6561 |
|
|
// On a miss first see if the instruction is in the L2 cache. No need to go to
|
6562 |
|
|
// the BIU on an L1 miss.
|
6563 |
|
|
// If not the machine will wait until the BIU loads the L2 cache.
|
6564 |
|
|
|
6565 |
|
|
// Capture the previous ic state, used to determine how long to wait in
|
6566 |
|
|
// icstate #4.
|
6567 |
|
|
picstate <= icstate;
|
6568 |
|
|
case(icstate)
|
6569 |
|
|
IDLE:
|
6570 |
|
|
// If the bus unit is busy doing an update involving L1_adr or L2_adr
|
6571 |
|
|
// we have to wait.
|
6572 |
|
|
if (bstate != B7 && bstate != B9) begin
|
6573 |
|
|
if (!ihit0) begin
|
6574 |
|
|
L1_adr <= {pcr[5:0],pc0[31:3],3'h0};
|
6575 |
|
|
L2_adr <= {pcr[5:0],pc0[31:3],3'h0};
|
6576 |
|
|
L1_invline <= TRUE;
|
6577 |
|
|
icwhich <= 1'b0;
|
6578 |
|
|
iccnt <= 2'b00;
|
6579 |
|
|
icstate <= IC2;
|
6580 |
|
|
end
|
6581 |
|
|
else if (!ihit1) begin
|
6582 |
|
|
L1_adr <= {pcr[5:0],pc1[31:3],3'h0};
|
6583 |
|
|
L2_adr <= {pcr[5:0],pc1[31:3],3'h0};
|
6584 |
|
|
L1_invline <= TRUE;
|
6585 |
|
|
icwhich <= 1'b1;
|
6586 |
|
|
iccnt <= 2'b00;
|
6587 |
|
|
icstate <= IC2;
|
6588 |
|
|
end
|
6589 |
|
|
end
|
6590 |
|
|
IC2: icstate <= IC3;
|
6591 |
|
|
IC3: icstate <= IC3a;
|
6592 |
|
|
IC3a: icstate <= IC4;
|
6593 |
|
|
// If data was in the L2 cache already there's no need to wait on the
|
6594 |
|
|
// BIU to retrieve data. It can be determined if the hit signal was
|
6595 |
|
|
// already active when this state was entered in which case waiting
|
6596 |
|
|
// will do no good.
|
6597 |
|
|
// The IC machine will stall in this state until the BIU has loaded the
|
6598 |
|
|
// L2 cache.
|
6599 |
|
|
IC4: if (ihit2 && picstate==IC3a) begin
|
6600 |
|
|
L1_en <= 8'hFF;
|
6601 |
|
|
L1_wr1 <= TRUE;
|
6602 |
|
|
L1_wr0 <= TRUE;
|
6603 |
|
|
L1_adr <= L2_adr;
|
6604 |
|
|
L2_rdat <= L2_dato;
|
6605 |
|
|
icstate <= IC5;
|
6606 |
|
|
end
|
6607 |
|
|
else if (bstate!=B9)
|
6608 |
|
|
;
|
6609 |
|
|
else begin
|
6610 |
|
|
//L1_wr1 <= TRUE;
|
6611 |
|
|
//L1_wr0 <= TRUE;
|
6612 |
|
|
//L1_adr <= L2_adr;
|
6613 |
|
|
//L2_rdat <= L2_dato;
|
6614 |
|
|
icstate <= IC5;
|
6615 |
|
|
end
|
6616 |
|
|
IC5: icstate <= IC6;
|
6617 |
|
|
IC6: icstate <= IC8;
|
6618 |
|
|
IC7: icstate <= IC8;
|
6619 |
|
|
IC8: begin
|
6620 |
|
|
icstate <= IDLE;
|
6621 |
|
|
icnxt <= TRUE;
|
6622 |
|
|
end
|
6623 |
|
|
default: icstate <= IDLE;
|
6624 |
|
|
endcase
|
6625 |
|
|
|
6626 |
|
|
if (dram0_load)
|
6627 |
|
|
case(dram0)
|
6628 |
|
|
`DRAMSLOT_AVAIL: ;
|
6629 |
|
|
`DRAMSLOT_BUSY: dram0 <= dram0 + !dram0_unc;
|
6630 |
|
|
3'd2: dram0 <= dram0 + 3'd1;
|
6631 |
|
|
3'd3: dram0 <= dram0 + 3'd1;
|
6632 |
|
|
3'd4: if (dhit0) dram0 <= `DRAMREQ_READY; else dram0 <= `DRAMSLOT_REQBUS;
|
6633 |
|
|
`DRAMSLOT_REQBUS: ;
|
6634 |
|
|
`DRAMSLOT_HASBUS: ;
|
6635 |
|
|
`DRAMREQ_READY: ;
|
6636 |
|
|
endcase
|
6637 |
|
|
|
6638 |
|
|
if (dram1_load)
|
6639 |
|
|
case(dram1)
|
6640 |
|
|
`DRAMSLOT_AVAIL: ;
|
6641 |
|
|
`DRAMSLOT_BUSY: dram1 <= dram1 + !dram1_unc;
|
6642 |
|
|
3'd2: dram1 <= dram1 + 3'd1;
|
6643 |
|
|
3'd3: dram1 <= dram1 + 3'd1;
|
6644 |
|
|
3'd4: if (dhit1) dram1 <= `DRAMREQ_READY; else dram1 <= `DRAMSLOT_REQBUS;
|
6645 |
|
|
`DRAMSLOT_REQBUS: ;
|
6646 |
|
|
`DRAMSLOT_HASBUS: ;
|
6647 |
|
|
`DRAMREQ_READY: ;
|
6648 |
|
|
endcase
|
6649 |
|
|
|
6650 |
|
|
if (dram2_load)
|
6651 |
|
|
case(dram2)
|
6652 |
|
|
`DRAMSLOT_AVAIL: ;
|
6653 |
|
|
`DRAMSLOT_BUSY: dram2 <= dram2 + !dram2_unc;
|
6654 |
|
|
3'd2: dram2 <= dram2 + 3'd1;
|
6655 |
|
|
3'd3: dram2 <= dram2 + 3'd1;
|
6656 |
|
|
3'd4: if (dhit2) dram2 <= `DRAMREQ_READY; else dram2 <= `DRAMSLOT_REQBUS;
|
6657 |
|
|
`DRAMSLOT_REQBUS: ;
|
6658 |
|
|
`DRAMSLOT_HASBUS: ;
|
6659 |
|
|
`DRAMREQ_READY: ;
|
6660 |
|
|
endcase
|
6661 |
|
|
|
6662 |
|
|
// Bus Interface Unit (BIU)
|
6663 |
|
|
// Interfaces to the external bus which is WISHBONE compatible.
|
6664 |
|
|
// Stores take precedence over other operations.
|
6665 |
|
|
// Next data cache read misses are serviced.
|
6666 |
|
|
// Uncached data reads are serviced.
|
6667 |
|
|
// Finally L2 instruction cache misses are serviced.
|
6668 |
|
|
|
6669 |
|
|
case(bstate)
|
6670 |
|
|
BIDLE:
|
6671 |
|
|
begin
|
6672 |
|
|
isCAS <= FALSE;
|
6673 |
|
|
isAMO <= FALSE;
|
6674 |
|
|
rdvq <= 1'b0;
|
6675 |
|
|
errq <= 1'b0;
|
6676 |
|
|
exvq <= 1'b0;
|
6677 |
|
|
bwhich <= 2'b11;
|
6678 |
|
|
if (dram0==`DRAMSLOT_BUSY && (IsCAS(dram0_instr) || IsAMO(dram0_instr))) begin
|
6679 |
|
|
`ifdef SUPPORT_DBG
|
6680 |
|
|
if (dbg_smatch0|dbg_lmatch0) begin
|
6681 |
|
|
dramA_v <= `TRUE;
|
6682 |
|
|
dramA_id <= dram0_id;
|
6683 |
|
|
dramA_exc <= `FLT_DBG;
|
6684 |
|
|
dramA_bus <= 64'h0;
|
6685 |
|
|
dram0 <= `DRAMSLOT_AVAIL;
|
6686 |
|
|
end
|
6687 |
|
|
else
|
6688 |
|
|
`endif
|
6689 |
|
|
begin
|
6690 |
|
|
dram0 <= `DRAMSLOT_HASBUS;
|
6691 |
|
|
isCAS <= IsCAS(dram0_instr);
|
6692 |
|
|
isAMO <= IsAMO(dram0_instr);
|
6693 |
|
|
casid <= dram0_id;
|
6694 |
|
|
bwhich <= 2'b00;
|
6695 |
|
|
cyc_o <= `HIGH;
|
6696 |
|
|
stb_o <= `HIGH;
|
6697 |
|
|
sel_o <= fnSelect(dram0_instr,dram0_addr);
|
6698 |
|
|
adr_o <= dram0_addr;
|
6699 |
|
|
dat_o <= fnDato(dram0_instr,dram0_data);
|
6700 |
|
|
bstate <= B12;
|
6701 |
|
|
end
|
6702 |
|
|
end
|
6703 |
|
|
else if (dram1==`DRAMSLOT_BUSY && (IsCAS(dram1_instr) || IsAMO(dram1_instr))) begin
|
6704 |
|
|
`ifdef SUPPORT_DBG
|
6705 |
|
|
if (dbg_smatch1|dbg_lmatch1) begin
|
6706 |
|
|
dramB_v <= `TRUE;
|
6707 |
|
|
dramB_id <= dram1_id;
|
6708 |
|
|
dramB_exc <= `FLT_DBG;
|
6709 |
|
|
dramB_bus <= 64'h0;
|
6710 |
|
|
dram1 <= `DRAMSLOT_AVAIL;
|
6711 |
|
|
end
|
6712 |
|
|
else
|
6713 |
|
|
`endif
|
6714 |
|
|
begin
|
6715 |
|
|
dram1 <= `DRAMSLOT_HASBUS;
|
6716 |
|
|
isCAS <= IsCAS(dram1_instr);
|
6717 |
|
|
isAMO <= IsAMO(dram1_instr);
|
6718 |
|
|
casid <= dram1_id;
|
6719 |
|
|
bwhich <= 2'b01;
|
6720 |
|
|
cyc_o <= `HIGH;
|
6721 |
|
|
stb_o <= `HIGH;
|
6722 |
|
|
sel_o <= fnSelect(dram1_instr,dram1_addr);
|
6723 |
|
|
adr_o <= dram1_addr;
|
6724 |
|
|
dat_o <= fnDato(dram1_instr,dram1_data);
|
6725 |
|
|
bstate <= B12;
|
6726 |
|
|
end
|
6727 |
|
|
end
|
6728 |
|
|
else if (dram2==`DRAMSLOT_BUSY && (IsCAS(dram2_instr) || IsAMO(dram2_instr))) begin
|
6729 |
|
|
`ifdef SUPPORT_DBG
|
6730 |
|
|
if (dbg_smatch2|dbg_lmatch2) begin
|
6731 |
|
|
dramC_v <= `TRUE;
|
6732 |
|
|
dramC_id <= dram2_id;
|
6733 |
|
|
dramC_exc <= `FLT_DBG;
|
6734 |
|
|
dramC_bus <= 64'h0;
|
6735 |
|
|
dram2 <= `DRAMSLOT_AVAIL;
|
6736 |
|
|
end
|
6737 |
|
|
else
|
6738 |
|
|
`endif
|
6739 |
|
|
begin
|
6740 |
|
|
dram2 <= `DRAMSLOT_HASBUS;
|
6741 |
|
|
isCAS <= IsCAS(dram2_instr);
|
6742 |
|
|
isAMO <= IsAMO(dram2_instr);
|
6743 |
|
|
casid <= dram2_id;
|
6744 |
|
|
bwhich <= 2'b10;
|
6745 |
|
|
cyc_o <= `HIGH;
|
6746 |
|
|
stb_o <= `HIGH;
|
6747 |
|
|
sel_o <= fnSelect(dram2_instr,dram2_addr);
|
6748 |
|
|
adr_o <= dram2_addr;
|
6749 |
|
|
dat_o <= fnDato(dram2_instr,dram2_data);
|
6750 |
|
|
bstate <= B12;
|
6751 |
|
|
end
|
6752 |
|
|
end
|
6753 |
|
|
else if (dram0==`DRAMSLOT_BUSY && IsStore(dram0_instr)) begin
|
6754 |
|
|
`ifdef SUPPORT_DBG
|
6755 |
|
|
if (dbg_smatch0) begin
|
6756 |
|
|
dramA_v <= `TRUE;
|
6757 |
|
|
dramA_id <= dram0_id;
|
6758 |
|
|
dramA_exc <= `FLT_DBG;
|
6759 |
|
|
dramA_bus <= 64'h0;
|
6760 |
|
|
dram0 <= `DRAMSLOT_AVAIL;
|
6761 |
|
|
end
|
6762 |
|
|
else
|
6763 |
|
|
`endif
|
6764 |
|
|
begin
|
6765 |
|
|
dram0 <= `DRAMSLOT_HASBUS;
|
6766 |
|
|
dram0_instr[`INSTRUCTION_OP] <= `NOP;
|
6767 |
|
|
bwhich <= 2'b00;
|
6768 |
|
|
cyc_o <= `HIGH;
|
6769 |
|
|
stb_o <= `HIGH;
|
6770 |
|
|
we_o <= `HIGH;
|
6771 |
|
|
sel_o <= fnSelect(dram0_instr,dram0_addr);
|
6772 |
|
|
adr_o <= dram0_addr;
|
6773 |
|
|
dat_o <= fnDato(dram0_instr,dram0_data);
|
6774 |
|
|
cr_o <= IsSWC(dram0_instr);
|
6775 |
|
|
bstate <= B1;
|
6776 |
|
|
end
|
6777 |
|
|
end
|
6778 |
|
|
else if (dram1==`DRAMSLOT_BUSY && IsStore(dram1_instr)) begin
|
6779 |
|
|
`ifdef SUPPORT_DBG
|
6780 |
|
|
if (dbg_smatch1) begin
|
6781 |
|
|
dramB_v <= `TRUE;
|
6782 |
|
|
dramB_id <= dram1_id;
|
6783 |
|
|
dramB_exc <= `FLT_DBG;
|
6784 |
|
|
dramB_bus <= 64'h0;
|
6785 |
|
|
dram1 <= `DRAMSLOT_AVAIL;
|
6786 |
|
|
end
|
6787 |
|
|
else
|
6788 |
|
|
`endif
|
6789 |
|
|
begin
|
6790 |
|
|
dram1 <= `DRAMSLOT_HASBUS;
|
6791 |
|
|
dram1_instr[`INSTRUCTION_OP] <= `NOP;
|
6792 |
|
|
bwhich <= 2'b01;
|
6793 |
|
|
cyc_o <= `HIGH;
|
6794 |
|
|
stb_o <= `HIGH;
|
6795 |
|
|
we_o <= `HIGH;
|
6796 |
|
|
sel_o <= fnSelect(dram1_instr,dram1_addr);
|
6797 |
|
|
adr_o <= dram1_addr;
|
6798 |
|
|
dat_o <= fnDato(dram1_instr,dram1_data);
|
6799 |
|
|
cr_o <= IsSWC(dram1_instr);
|
6800 |
|
|
bstate <= B1;
|
6801 |
|
|
end
|
6802 |
|
|
end
|
6803 |
|
|
else if (dram2==`DRAMSLOT_BUSY && IsStore(dram2_instr)) begin
|
6804 |
|
|
`ifdef SUPPORT_DBG
|
6805 |
|
|
if (dbg_smatch2) begin
|
6806 |
|
|
dramC_v <= `TRUE;
|
6807 |
|
|
dramC_id <= dram2_id;
|
6808 |
|
|
dramC_exc <= `FLT_DBG;
|
6809 |
|
|
dramC_bus <= 64'h0;
|
6810 |
|
|
dram2 <= `DRAMSLOT_AVAIL;
|
6811 |
|
|
end
|
6812 |
|
|
else
|
6813 |
|
|
`endif
|
6814 |
|
|
begin
|
6815 |
|
|
dram2 <= `DRAMSLOT_HASBUS;
|
6816 |
|
|
dram2_instr[`INSTRUCTION_OP] <= `NOP;
|
6817 |
|
|
bwhich <= 2'b10;
|
6818 |
|
|
cyc_o <= `HIGH;
|
6819 |
|
|
stb_o <= `HIGH;
|
6820 |
|
|
we_o <= `HIGH;
|
6821 |
|
|
sel_o <= fnSelect(dram2_instr,dram2_addr);
|
6822 |
|
|
adr_o <= dram2_addr;
|
6823 |
|
|
dat_o <= fnDato(dram2_instr,dram2_data);
|
6824 |
|
|
cr_o <= IsSWC(dram2_instr);
|
6825 |
|
|
bstate <= B1;
|
6826 |
|
|
end
|
6827 |
|
|
end
|
6828 |
|
|
// Check for read misses on the data cache
|
6829 |
|
|
else if (!dram0_unc && dram0==`DRAMSLOT_REQBUS && dram0_load) begin
|
6830 |
|
|
`ifdef SUPPORT_DBG
|
6831 |
|
|
if (dbg_lmatch0) begin
|
6832 |
|
|
dramA_v <= `TRUE;
|
6833 |
|
|
dramA_id <= dram0_id;
|
6834 |
|
|
dramA_exc <= `FLT_DBG;
|
6835 |
|
|
dramA_bus <= 64'h0;
|
6836 |
|
|
dram0 <= `DRAMSLOT_AVAIL;
|
6837 |
|
|
end
|
6838 |
|
|
else
|
6839 |
|
|
`endif
|
6840 |
|
|
begin
|
6841 |
|
|
dram0 <= `DRAMSLOT_HASBUS;
|
6842 |
|
|
bwhich <= 2'b00;
|
6843 |
|
|
bstate <= B2;
|
6844 |
|
|
end
|
6845 |
|
|
end
|
6846 |
|
|
else if (!dram1_unc && dram1==`DRAMSLOT_REQBUS && dram1_load) begin
|
6847 |
|
|
`ifdef SUPPORT_DBG
|
6848 |
|
|
if (dbg_lmatch1) begin
|
6849 |
|
|
dramB_v <= `TRUE;
|
6850 |
|
|
dramB_id <= dram1_id;
|
6851 |
|
|
dramB_exc <= `FLT_DBG;
|
6852 |
|
|
dramB_bus <= 64'h0;
|
6853 |
|
|
dram1 <= `DRAMSLOT_AVAIL;
|
6854 |
|
|
end
|
6855 |
|
|
else
|
6856 |
|
|
`endif
|
6857 |
|
|
begin
|
6858 |
|
|
dram1 <= `DRAMSLOT_HASBUS;
|
6859 |
|
|
bwhich <= 2'b01;
|
6860 |
|
|
bstate <= B2;
|
6861 |
|
|
end
|
6862 |
|
|
end
|
6863 |
|
|
else if (!dram2_unc && dram2==`DRAMSLOT_REQBUS && dram2_load) begin
|
6864 |
|
|
`ifdef SUPPORT_DBG
|
6865 |
|
|
if (dbg_lmatch2) begin
|
6866 |
|
|
dramC_v <= `TRUE;
|
6867 |
|
|
dramC_id <= dram2_id;
|
6868 |
|
|
dramC_exc <= `FLT_DBG;
|
6869 |
|
|
dramC_bus <= 64'h0;
|
6870 |
|
|
dram2 <= `DRAMSLOT_AVAIL;
|
6871 |
|
|
end
|
6872 |
|
|
else
|
6873 |
|
|
`endif
|
6874 |
|
|
begin
|
6875 |
|
|
dram2 <= `DRAMSLOT_HASBUS;
|
6876 |
|
|
bwhich <= 2'b10;
|
6877 |
|
|
bstate <= B2;
|
6878 |
|
|
end
|
6879 |
|
|
end
|
6880 |
|
|
else if (dram0_unc && dram0==`DRAMSLOT_BUSY && dram0_load) begin
|
6881 |
|
|
`ifdef SUPPORT_DBG
|
6882 |
|
|
if (dbg_lmatch0) begin
|
6883 |
|
|
dramA_v <= `TRUE;
|
6884 |
|
|
dramA_id <= dram0_id;
|
6885 |
|
|
dramA_exc <= `FLT_DBG;
|
6886 |
|
|
dramA_bus <= 64'h0;
|
6887 |
|
|
dram0 <= `DRAMSLOT_AVAIL;
|
6888 |
|
|
end
|
6889 |
|
|
else
|
6890 |
|
|
`endif
|
6891 |
|
|
begin
|
6892 |
|
|
bwhich <= 2'b00;
|
6893 |
|
|
cyc_o <= `HIGH;
|
6894 |
|
|
stb_o <= `HIGH;
|
6895 |
|
|
sel_o <= fnSelect(dram0_instr,dram0_addr);
|
6896 |
|
|
adr_o <= {dram0_addr[31:3],3'b0};
|
6897 |
|
|
sr_o <= IsLWR(dram0_instr);
|
6898 |
|
|
bstate <= B12;
|
6899 |
|
|
end
|
6900 |
|
|
end
|
6901 |
|
|
else if (dram1_unc && dram1==`DRAMSLOT_BUSY && dram1_load) begin
|
6902 |
|
|
`ifdef SUPPORT_DBG
|
6903 |
|
|
if (dbg_lmatch1) begin
|
6904 |
|
|
dramB_v <= `TRUE;
|
6905 |
|
|
dramB_id <= dram1_id;
|
6906 |
|
|
dramB_exc <= `FLT_DBG;
|
6907 |
|
|
dramB_bus <= 64'h0;
|
6908 |
|
|
dram1 <= `DRAMSLOT_AVAIL;
|
6909 |
|
|
end
|
6910 |
|
|
else
|
6911 |
|
|
`endif
|
6912 |
|
|
begin
|
6913 |
|
|
bwhich <= 2'b01;
|
6914 |
|
|
cyc_o <= `HIGH;
|
6915 |
|
|
stb_o <= `HIGH;
|
6916 |
|
|
sel_o <= fnSelect(dram1_instr,dram1_addr);
|
6917 |
|
|
adr_o <= {dram1_addr[31:3],3'b0};
|
6918 |
|
|
sr_o <= IsLWR(dram1_instr);
|
6919 |
|
|
bstate <= B12;
|
6920 |
|
|
end
|
6921 |
|
|
end
|
6922 |
|
|
else if (dram2_unc && dram2==`DRAMSLOT_BUSY && dram2_load) begin
|
6923 |
|
|
`ifdef SUPPORT_DBG
|
6924 |
|
|
if (dbg_lmatch2) begin
|
6925 |
|
|
dramC_v <= `TRUE;
|
6926 |
|
|
dramC_id <= dram2_id;
|
6927 |
|
|
dramC_exc <= `FLT_DBG;
|
6928 |
|
|
dramC_bus <= 64'h0;
|
6929 |
|
|
dram2 <= 2'd0;
|
6930 |
|
|
end
|
6931 |
|
|
else
|
6932 |
|
|
`endif
|
6933 |
|
|
begin
|
6934 |
|
|
bwhich <= 2'b10;
|
6935 |
|
|
cyc_o <= `HIGH;
|
6936 |
|
|
stb_o <= `HIGH;
|
6937 |
|
|
sel_o <= fnSelect(dram2_instr,dram2_addr);
|
6938 |
|
|
adr_o <= {dram2_addr[31:3],3'b0};
|
6939 |
|
|
sr_o <= IsLWR(dram2_instr);
|
6940 |
|
|
bstate <= B12;
|
6941 |
|
|
end
|
6942 |
|
|
end
|
6943 |
|
|
// Check for L2 cache miss
|
6944 |
|
|
else if (!ihit2) begin
|
6945 |
|
|
cti_o <= 3'b001;
|
6946 |
|
|
bte_o <= 2'b01; // 4 beat burst wrap
|
6947 |
|
|
cyc_o <= `HIGH;
|
6948 |
|
|
stb_o <= `HIGH;
|
6949 |
|
|
sel_o <= 8'hFF;
|
6950 |
|
|
icl_o <= `HIGH;
|
6951 |
|
|
// adr_o <= icwhich ? {pc0[31:5],5'b0} : {pc1[31:5],5'b0};
|
6952 |
|
|
// L2_adr <= icwhich ? {pc0[31:5],5'b0} : {pc1[31:5],5'b0};
|
6953 |
|
|
adr_o <= {pcr[5:0],L1_adr[31:3],3'h0};
|
6954 |
|
|
L2_adr <= {pcr[5:0],L1_adr[31:3],3'h0};
|
6955 |
|
|
bstate <= B7;
|
6956 |
|
|
end
|
6957 |
|
|
end
|
6958 |
|
|
// Terminal state for a store operation.
|
6959 |
|
|
B1:
|
6960 |
|
|
if (ack_i|err_i) begin
|
6961 |
|
|
isStore <= `TRUE;
|
6962 |
|
|
cyc_o <= `LOW;
|
6963 |
|
|
stb_o <= `LOW;
|
6964 |
|
|
we_o <= `LOW;
|
6965 |
|
|
sel_o <= 8'h00;
|
6966 |
|
|
cr_o <= 1'b0;
|
6967 |
|
|
// This isn't a good way of doing things; the state should be propagated
|
6968 |
|
|
// to the commit stage, however since this is a store we know there will
|
6969 |
|
|
// be no change of program flow. So the reservation status bit is set
|
6970 |
|
|
// here. The author wanted to avoid the complexity of propagating the
|
6971 |
|
|
// input signal to the commit stage. It does mean that the SWC
|
6972 |
|
|
// instruction should be surrounded by SYNC's.
|
6973 |
|
|
if (cr_o)
|
6974 |
|
|
sema[0] <= rbi_i;
|
6975 |
|
|
case(bwhich)
|
6976 |
|
|
2'd0: begin
|
6977 |
|
|
dram0 <= `DRAMREQ_READY;
|
6978 |
|
|
iqentry_exc[dram0_id[`QBITS]] <= wrv_i|err_i ? `FLT_DWF : `FLT_NONE;
|
6979 |
|
|
if (err_i|wrv_i) iqentry_a1[dram0_id[`QBITS]] <= adr_o;
|
6980 |
|
|
iqentry_cmt[ dram0_id[`QBITS] ] <= `VAL;
|
6981 |
|
|
iqentry_aq[ dram0_id[`QBITS] ] <= `INV;
|
6982 |
|
|
//iqentry_out[ dram0_id[`QBITS] ] <= `INV;
|
6983 |
|
|
end
|
6984 |
|
|
2'd1: begin
|
6985 |
|
|
dram1 <= `DRAMREQ_READY;
|
6986 |
|
|
iqentry_exc[dram1_id[`QBITS]] <= wrv_i|err_i ? `FLT_DWF : `FLT_NONE;
|
6987 |
|
|
if (err_i|wrv_i) iqentry_a1[dram1_id[`QBITS]] <= adr_o;
|
6988 |
|
|
iqentry_cmt[ dram1_id[`QBITS] ] <= `VAL;
|
6989 |
|
|
iqentry_aq[ dram1_id[`QBITS] ] <= `INV;
|
6990 |
|
|
//iqentry_out[ dram1_id[`QBITS] ] <= `INV;
|
6991 |
|
|
end
|
6992 |
|
|
2'd2: begin
|
6993 |
|
|
dram2 <= `DRAMREQ_READY;
|
6994 |
|
|
iqentry_exc[dram2_id[`QBITS]] <= wrv_i|err_i ? `FLT_DWF : `FLT_NONE;
|
6995 |
|
|
if (err_i|wrv_i) iqentry_a1[dram2_id[`QBITS]] <= adr_o;
|
6996 |
|
|
iqentry_cmt[ dram2_id[`QBITS] ] <= `VAL;
|
6997 |
|
|
iqentry_aq[ dram2_id[`QBITS] ] <= `INV;
|
6998 |
|
|
//iqentry_out[ dram2_id[`QBITS] ] <= `INV;
|
6999 |
|
|
end
|
7000 |
|
|
default: ;
|
7001 |
|
|
endcase
|
7002 |
|
|
bstate <= B19;
|
7003 |
|
|
end
|
7004 |
|
|
B2:
|
7005 |
|
|
begin
|
7006 |
|
|
dccnt <= 2'd0;
|
7007 |
|
|
case(bwhich)
|
7008 |
|
|
2'd0: begin
|
7009 |
|
|
cti_o <= 3'b001;
|
7010 |
|
|
bte_o <= 2'b01;
|
7011 |
|
|
cyc_o <= `HIGH;
|
7012 |
|
|
stb_o <= `HIGH;
|
7013 |
|
|
sel_o <= fnSelect(dram0_instr,dram0_addr);
|
7014 |
|
|
adr_o <= {dram0_addr[31:3],3'b0};
|
7015 |
|
|
bstate <= B2d;
|
7016 |
|
|
end
|
7017 |
|
|
2'd1: begin
|
7018 |
|
|
cti_o <= 3'b001;
|
7019 |
|
|
bte_o <= 2'b01;
|
7020 |
|
|
cyc_o <= `HIGH;
|
7021 |
|
|
stb_o <= `HIGH;
|
7022 |
|
|
sel_o <= fnSelect(dram1_instr,dram1_addr);
|
7023 |
|
|
adr_o <= {dram1_addr[31:3],3'b0};
|
7024 |
|
|
bstate <= B2d;
|
7025 |
|
|
end
|
7026 |
|
|
2'd2: begin
|
7027 |
|
|
cti_o <= 3'b001;
|
7028 |
|
|
bte_o <= 2'b01;
|
7029 |
|
|
cyc_o <= `HIGH;
|
7030 |
|
|
stb_o <= `HIGH;
|
7031 |
|
|
sel_o <= fnSelect(dram2_instr,dram2_addr);
|
7032 |
|
|
adr_o <= {dram2_addr[31:3],3'b0};
|
7033 |
|
|
bstate <= B2d;
|
7034 |
|
|
end
|
7035 |
|
|
default: if (~ack_i) bstate <= BIDLE;
|
7036 |
|
|
endcase
|
7037 |
|
|
end
|
7038 |
|
|
// Data cache load terminal state
|
7039 |
|
|
B2d:
|
7040 |
|
|
if (ack_i|err_i) begin
|
7041 |
|
|
errq <= errq | err_i;
|
7042 |
|
|
rdvq <= rdvq | rdv_i;
|
7043 |
|
|
case(bwhich)
|
7044 |
|
|
2'd0: if (err_i|rdv_i) begin
|
7045 |
|
|
iqentry_a1[dram0_id[`QBITS]] <= adr_o;
|
7046 |
|
|
iqentry_exc[dram0_id[`QBITS]] <= err_i ? `FLT_DBE : `FLT_DRF;
|
7047 |
|
|
end
|
7048 |
|
|
2'd1: if (err_i|rdv_i) begin
|
7049 |
|
|
iqentry_a1[dram1_id[`QBITS]] <= adr_o;
|
7050 |
|
|
iqentry_exc[dram1_id[`QBITS]] <= err_i ? `FLT_DBE : `FLT_DRF;
|
7051 |
|
|
end
|
7052 |
|
|
2'd2: if (err_i|rdv_i) begin
|
7053 |
|
|
iqentry_a1[dram2_id[`QBITS]] <= adr_o;
|
7054 |
|
|
iqentry_exc[dram2_id[`QBITS]] <= err_i ? `FLT_DBE : `FLT_DRF;
|
7055 |
|
|
end
|
7056 |
|
|
default: ;
|
7057 |
|
|
endcase
|
7058 |
|
|
dccnt <= dccnt + 2'd1;
|
7059 |
|
|
adr_o[4:3] <= adr_o[4:3] + 2'd1;
|
7060 |
|
|
bstate <= B2d;
|
7061 |
|
|
if (dccnt==2'd2)
|
7062 |
|
|
cti_o <= 3'b111;
|
7063 |
|
|
if (dccnt==2'd3) begin
|
7064 |
|
|
cti_o <= 3'b000;
|
7065 |
|
|
bte_o <= 2'b00;
|
7066 |
|
|
cyc_o <= `LOW;
|
7067 |
|
|
stb_o <= `LOW;
|
7068 |
|
|
sel_o <= 8'h00;
|
7069 |
|
|
bstate <= B4;
|
7070 |
|
|
end
|
7071 |
|
|
end
|
7072 |
|
|
B3: begin
|
7073 |
|
|
stb_o <= `HIGH;
|
7074 |
|
|
bstate <= B2d;
|
7075 |
|
|
end
|
7076 |
|
|
B4: bstate <= B5;
|
7077 |
|
|
B5: bstate <= B6;
|
7078 |
|
|
B6: begin
|
7079 |
|
|
case(bwhich)
|
7080 |
|
|
2'd0: dram0 <= `DRAMSLOT_BUSY; // causes retest of dhit
|
7081 |
|
|
2'd1: dram1 <= `DRAMSLOT_BUSY;
|
7082 |
|
|
2'd2: dram2 <= `DRAMSLOT_BUSY;
|
7083 |
|
|
default: ;
|
7084 |
|
|
endcase
|
7085 |
|
|
if (~ack_i) bstate <= BIDLE;
|
7086 |
|
|
end
|
7087 |
|
|
|
7088 |
|
|
// Ack state for instruction cache load
|
7089 |
|
|
B7:
|
7090 |
|
|
if (ack_i|err_i) begin
|
7091 |
|
|
errq <= errq | err_i;
|
7092 |
|
|
exvq <= exvq | exv_i;
|
7093 |
|
|
L1_en <= 8'h3 << {L2_adr[4:3],1'b0};
|
7094 |
|
|
L1_wr0 <= `TRUE;
|
7095 |
|
|
L1_wr1 <= `TRUE;
|
7096 |
|
|
L1_adr <= L2_adr;
|
7097 |
|
|
L2_rdat <= {4{dat_i}};
|
7098 |
|
|
iccnt <= iccnt + 2'd1;
|
7099 |
|
|
//stb_o <= `LOW;
|
7100 |
|
|
if (iccnt==2'd2)
|
7101 |
|
|
cti_o <= 3'b111;
|
7102 |
|
|
if (iccnt==2'd3) begin
|
7103 |
|
|
cti_o <= 3'b000;
|
7104 |
|
|
bte_o <= 2'b00; // linear burst
|
7105 |
|
|
cyc_o <= `LOW;
|
7106 |
|
|
stb_o <= `LOW;
|
7107 |
|
|
sel_o <= 8'h00;
|
7108 |
|
|
icl_o <= `LOW;
|
7109 |
|
|
bstate <= B9;
|
7110 |
|
|
end
|
7111 |
|
|
else begin
|
7112 |
|
|
L2_adr[4:3] <= L2_adr[4:3] + 2'd1;
|
7113 |
|
|
end
|
7114 |
|
|
end
|
7115 |
|
|
B9:
|
7116 |
|
|
begin
|
7117 |
|
|
L1_wr0 <= `FALSE;
|
7118 |
|
|
L1_wr1 <= `FALSE;
|
7119 |
|
|
L1_en <= 8'hFF;
|
7120 |
|
|
if (~ack_i) begin
|
7121 |
|
|
bstate <= BIDLE;
|
7122 |
|
|
L2_nxt <= TRUE;
|
7123 |
|
|
end
|
7124 |
|
|
end
|
7125 |
|
|
B12:
|
7126 |
|
|
if (ack_i|err_i) begin
|
7127 |
|
|
if (isCAS) begin
|
7128 |
|
|
iqentry_res [ casid[`QBITS] ] <= (dat_i == cas);
|
7129 |
|
|
iqentry_exc [ casid[`QBITS] ] <= err_i ? `FLT_DRF : rdv_i ? `FLT_DRF : `FLT_NONE;
|
7130 |
|
|
iqentry_done[ casid[`QBITS] ] <= `VAL;
|
7131 |
|
|
iqentry_instr[ casid[`QBITS]] <= `NOP_INSN;
|
7132 |
|
|
iqentry_out [ casid[`QBITS] ] <= `INV;
|
7133 |
|
|
if (err_i | rdv_i) iqentry_a1[casid[`QBITS]] <= adr_o;
|
7134 |
|
|
if (dat_i == cas) begin
|
7135 |
|
|
stb_o <= `LOW;
|
7136 |
|
|
we_o <= `TRUE;
|
7137 |
|
|
bstate <= B15;
|
7138 |
|
|
end
|
7139 |
|
|
else begin
|
7140 |
|
|
cas <= dat_i;
|
7141 |
|
|
cyc_o <= `LOW;
|
7142 |
|
|
stb_o <= `LOW;
|
7143 |
|
|
sel_o <= 8'h00;
|
7144 |
|
|
case(bwhich)
|
7145 |
|
|
2'b00: dram0 <= `DRAMREQ_READY;
|
7146 |
|
|
2'b01: dram1 <= `DRAMREQ_READY;
|
7147 |
|
|
2'b10: dram2 <= `DRAMREQ_READY;
|
7148 |
|
|
default: ;
|
7149 |
|
|
endcase
|
7150 |
|
|
bstate <= B19;
|
7151 |
|
|
end
|
7152 |
|
|
end
|
7153 |
|
|
else if (isAMO) begin
|
7154 |
|
|
iqentry_res [ casid[`QBITS] ] <= dat_i;
|
7155 |
|
|
amo_argA <= dat_i;
|
7156 |
|
|
amo_argB <= iqentry_instr[casid[`QBITS]][31] ? {{59{iqentry_instr[casid[`QBITS]][20:16]}},iqentry_instr[casid[`QBITS]][20:16]} : iqentry_a2[casid[`QBITS]];
|
7157 |
|
|
amo_instr <= iqentry_instr[casid[`QBITS]];
|
7158 |
|
|
iqentry_exc [ casid[`QBITS] ] <= err_i ? `FLT_DRF : rdv_i ? `FLT_DRF : `FLT_NONE;
|
7159 |
|
|
if (err_i | rdv_i) iqentry_a1[casid[`QBITS]] <= adr_o;
|
7160 |
|
|
stb_o <= `LOW;
|
7161 |
|
|
bstate <= B20;
|
7162 |
|
|
end
|
7163 |
|
|
else begin
|
7164 |
|
|
cyc_o <= `LOW;
|
7165 |
|
|
stb_o <= `LOW;
|
7166 |
|
|
sel_o <= 8'h00;
|
7167 |
|
|
sr_o <= `LOW;
|
7168 |
|
|
xdati <= dat_i;
|
7169 |
|
|
case(bwhich)
|
7170 |
|
|
2'b00: begin
|
7171 |
|
|
dram0 <= `DRAMREQ_READY;
|
7172 |
|
|
iqentry_exc [ dram0_id[`QBITS] ] <= err_i ? `FLT_DRF : rdv_i ? `FLT_DRF : `FLT_NONE;
|
7173 |
|
|
if (err_i|rdv_i) iqentry_a1[dram0_id[`QBITS]] <= adr_o;
|
7174 |
|
|
end
|
7175 |
|
|
2'b01: begin
|
7176 |
|
|
dram1 <= `DRAMREQ_READY;
|
7177 |
|
|
iqentry_exc [ dram1_id[`QBITS] ] <= err_i ? `FLT_DRF : rdv_i ? `FLT_DRF : `FLT_NONE;
|
7178 |
|
|
if (err_i|rdv_i) iqentry_a1[dram1_id[`QBITS]] <= adr_o;
|
7179 |
|
|
end
|
7180 |
|
|
2'b10: begin
|
7181 |
|
|
dram2 <= `DRAMREQ_READY;
|
7182 |
|
|
iqentry_exc [ dram2_id[`QBITS] ] <= err_i ? `FLT_DRF : rdv_i ? `FLT_DRF : `FLT_NONE;
|
7183 |
|
|
if (err_i|rdv_i) iqentry_a1[dram2_id[`QBITS]] <= adr_o;
|
7184 |
|
|
end
|
7185 |
|
|
default: ;
|
7186 |
|
|
endcase
|
7187 |
|
|
bstate <= B19;
|
7188 |
|
|
end
|
7189 |
|
|
end
|
7190 |
|
|
// Three cycles to detemrine if there's a cache hit during a store.
|
7191 |
|
|
B16: begin
|
7192 |
|
|
case(bwhich)
|
7193 |
|
|
2'd0: if (dhit0) begin dram0 <= `DRAMREQ_READY; bstate <= B17; end
|
7194 |
|
|
2'd1: if (dhit1) begin dram1 <= `DRAMREQ_READY; bstate <= B17; end
|
7195 |
|
|
2'd2: if (dhit2) begin dram2 <= `DRAMREQ_READY; bstate <= B17; end
|
7196 |
|
|
default: bstate <= BIDLE;
|
7197 |
|
|
endcase
|
7198 |
|
|
end
|
7199 |
|
|
B17: bstate <= B18;
|
7200 |
|
|
B18: bstate <= B19;
|
7201 |
|
|
B19: if (~ack_i) begin bstate <= BIDLE; isStore <= `FALSE; end
|
7202 |
|
|
B20:
|
7203 |
|
|
if (~ack_i) begin
|
7204 |
|
|
stb_o <= `HIGH;
|
7205 |
|
|
we_o <= `HIGH;
|
7206 |
|
|
dat_o <= fnDato(amo_instr,amo_res);
|
7207 |
|
|
bstate <= B1;
|
7208 |
|
|
end
|
7209 |
|
|
default: bstate <= BIDLE;
|
7210 |
|
|
endcase
|
7211 |
|
|
|
7212 |
|
|
if (!branchmiss) begin
|
7213 |
|
|
case({fetchbuf0_v, fetchbuf1_v})
|
7214 |
|
|
2'b00: ;
|
7215 |
|
|
2'b01:
|
7216 |
|
|
if (canq1) begin
|
7217 |
|
|
tail0 <= idp1(tail0);
|
7218 |
|
|
tail1 <= idp1(tail1);
|
7219 |
|
|
end
|
7220 |
|
|
2'b10:
|
7221 |
|
|
if (canq1) begin
|
7222 |
|
|
tail0 <= idp1(tail0);
|
7223 |
|
|
tail1 <= idp1(tail1);
|
7224 |
|
|
end
|
7225 |
|
|
2'b11:
|
7226 |
|
|
if (canq1) begin
|
7227 |
|
|
if (IsBranch(fetchbuf0_instr) && predict_taken0 && fetchbuf0_thrd==fetchbuf1_thrd) begin
|
7228 |
|
|
tail0 <= idp1(tail0);
|
7229 |
|
|
tail1 <= idp1(tail1);
|
7230 |
|
|
end
|
7231 |
|
|
else begin
|
7232 |
|
|
if (vqe0 < vl || !IsVector(fetchbuf0_instr)) begin
|
7233 |
|
|
if (canq2) begin
|
7234 |
|
|
tail0 <= idp2(tail0);
|
7235 |
|
|
tail1 <= idp2(tail1);
|
7236 |
|
|
end
|
7237 |
|
|
else begin // queued1 will be true
|
7238 |
|
|
tail0 <= idp1(tail0);
|
7239 |
|
|
tail1 <= idp1(tail1);
|
7240 |
|
|
end
|
7241 |
|
|
end
|
7242 |
|
|
end
|
7243 |
|
|
end
|
7244 |
|
|
endcase
|
7245 |
|
|
end
|
7246 |
|
|
else begin // if branchmiss
|
7247 |
|
|
if (!thread_en) begin
|
7248 |
|
|
if (iqentry_stomp[0] & ~iqentry_stomp[7]) begin
|
7249 |
|
|
tail0 <= 3'd0;
|
7250 |
|
|
tail1 <= 3'd1;
|
7251 |
|
|
end
|
7252 |
|
|
else if (iqentry_stomp[1] & ~iqentry_stomp[0]) begin
|
7253 |
|
|
tail0 <= 3'd1;
|
7254 |
|
|
tail1 <= 3'd2;
|
7255 |
|
|
end
|
7256 |
|
|
else if (iqentry_stomp[2] & ~iqentry_stomp[1]) begin
|
7257 |
|
|
tail0 <= 3'd2;
|
7258 |
|
|
tail1 <= 3'd3;
|
7259 |
|
|
end
|
7260 |
|
|
else if (iqentry_stomp[3] & ~iqentry_stomp[2]) begin
|
7261 |
|
|
tail0 <= 3'd3;
|
7262 |
|
|
tail1 <= 3'd4;
|
7263 |
|
|
end
|
7264 |
|
|
else if (iqentry_stomp[4] & ~iqentry_stomp[3]) begin
|
7265 |
|
|
tail0 <= 3'd4;
|
7266 |
|
|
tail1 <= 3'd5;
|
7267 |
|
|
end
|
7268 |
|
|
else if (iqentry_stomp[5] & ~iqentry_stomp[4]) begin
|
7269 |
|
|
tail0 <= 3'd5;
|
7270 |
|
|
tail1 <= 3'd6;
|
7271 |
|
|
end
|
7272 |
|
|
else if (iqentry_stomp[6] & ~iqentry_stomp[5]) begin
|
7273 |
|
|
tail0 <= 3'd6;
|
7274 |
|
|
tail1 <= 3'd7;
|
7275 |
|
|
end
|
7276 |
|
|
else if (iqentry_stomp[7] & ~iqentry_stomp[6]) begin
|
7277 |
|
|
tail0 <= 3'd7;
|
7278 |
|
|
tail1 <= 3'd0;
|
7279 |
|
|
end
|
7280 |
|
|
end
|
7281 |
|
|
// otherwise, it is the last instruction in the queue that has been mispredicted ... do nothing
|
7282 |
|
|
end
|
7283 |
|
|
/*
|
7284 |
|
|
if (pebm)
|
7285 |
|
|
seq_num <= seq_num + 5'd3;
|
7286 |
|
|
else if (queued2)
|
7287 |
|
|
seq_num <= seq_num + 5'd2;
|
7288 |
|
|
else if (queued1)
|
7289 |
|
|
seq_num <= seq_num + 5'd1;
|
7290 |
|
|
*/
|
7291 |
|
|
// #5 rf[0] = 0; rf_v[0] = 1; rf_source[0] = 0;
|
7292 |
|
|
$display("\n\n\n\n\n\n\n\n");
|
7293 |
|
|
$display("TIME %0d", $time);
|
7294 |
|
|
$display("%h #", pc0);
|
7295 |
|
|
|
7296 |
|
|
$display ("Regfile: %d", rgs[0]);
|
7297 |
|
|
for (n=0; n < 32; n=n+4) begin
|
7298 |
|
|
$display("%d: %h %d %o %d: %h %d %o %d: %h %d %o %d: %h %d %o#",
|
7299 |
|
|
n[4:0]+0, urf1.urf10.mem[{rgs[0],1'b0,n[4:2],2'b00}], regIsValid[n+0], rf_source[n+0],
|
7300 |
|
|
n[4:0]+1, urf1.urf10.mem[{rgs[0],1'b0,n[4:2],2'b01}], regIsValid[n+1], rf_source[n+1],
|
7301 |
|
|
n[4:0]+2, urf1.urf10.mem[{rgs[0],1'b0,n[4:2],2'b10}], regIsValid[n+2], rf_source[n+2],
|
7302 |
|
|
n[4:0]+3, urf1.urf10.mem[{rgs[0],1'b0,n[4:2],2'b11}], regIsValid[n+3], rf_source[n+3]
|
7303 |
|
|
);
|
7304 |
|
|
end
|
7305 |
|
|
if (thread_en) begin
|
7306 |
|
|
$display ("Regfile: %d", rgs[1]);
|
7307 |
|
|
for (n=128; n < 160; n=n+4) begin
|
7308 |
|
|
$display("%d: %h %d %o %d: %h %d %o %d: %h %d %o %d: %h %d %o#",
|
7309 |
|
|
n[4:0]+0, urf1.urf10.mem[{rgs[1],1'b0,n[4:2],2'b00}], regIsValid[n+0], rf_source[n+0],
|
7310 |
|
|
n[4:0]+1, urf1.urf10.mem[{rgs[1],1'b0,n[4:2],2'b01}], regIsValid[n+1], rf_source[n+1],
|
7311 |
|
|
n[4:0]+2, urf1.urf10.mem[{rgs[1],1'b0,n[4:2],2'b10}], regIsValid[n+2], rf_source[n+2],
|
7312 |
|
|
n[4:0]+3, urf1.urf10.mem[{rgs[1],1'b0,n[4:2],2'b11}], regIsValid[n+3], rf_source[n+3]
|
7313 |
|
|
);
|
7314 |
|
|
end
|
7315 |
|
|
end
|
7316 |
|
|
$display("Call Stack:");
|
7317 |
|
|
for (n = 0; n < 32; n = n + 4)
|
7318 |
|
|
$display("%c%d: %h %c%d: %h %c%d: %h %c%d: %h",
|
7319 |
|
|
ufb1.ursb1.rasp==n+0 ?">" : " ", n[4:0]+0, ufb1.ursb1.ras[n+0],
|
7320 |
|
|
ufb1.ursb1.rasp==n+1 ?">" : " ", n[4:0]+1, ufb1.ursb1.ras[n+1],
|
7321 |
|
|
ufb1.ursb1.rasp==n+2 ?">" : " ", n[4:0]+2, ufb1.ursb1.ras[n+2],
|
7322 |
|
|
ufb1.ursb1.rasp==n+3 ?">" : " ", n[4:0]+3, ufb1.ursb1.ras[n+3]
|
7323 |
|
|
);
|
7324 |
|
|
$display("\n");
|
7325 |
|
|
|
7326 |
|
|
// $display("Return address stack:");
|
7327 |
|
|
// for (n = 0; n < 16; n = n + 1)
|
7328 |
|
|
// $display("%d %h", rasp+n[3:0], ras[rasp+n[3:0]]);
|
7329 |
|
|
$display("TakeBr:%d #", take_branch);//, backpc);
|
7330 |
|
|
$display("%c%c A: %d %h %h #",
|
7331 |
|
|
45, fetchbuf?45:62, fetchbufA_v, fetchbufA_instr, fetchbufA_pc);
|
7332 |
|
|
$display("%c%c B: %d %h %h #",
|
7333 |
|
|
45, fetchbuf?45:62, fetchbufB_v, fetchbufB_instr, fetchbufB_pc);
|
7334 |
|
|
$display("%c%c C: %d %h %h #",
|
7335 |
|
|
45, fetchbuf?62:45, fetchbufC_v, fetchbufC_instr, fetchbufC_pc);
|
7336 |
|
|
$display("%c%c D: %d %h %h #",
|
7337 |
|
|
45, fetchbuf?62:45, fetchbufD_v, fetchbufD_instr, fetchbufD_pc);
|
7338 |
|
|
|
7339 |
|
|
for (i=0; i<QENTRIES; i=i+1)
|
7340 |
|
|
$display("%c%c %d: %c%c%c %d %d %c%c %d %c %c%h 0%d %o %h %h %h %d %o %h %d %o %h %d %o %d:%h %h %d#",
|
7341 |
|
|
(i[`QBITS]==head0)?"C":".", (i[`QBITS]==tail0)?"Q":".", i[`QBITS],
|
7342 |
|
|
iqentry_v[i]?"v":"-", iqentry_done[i]?"d":"-", iqentry_out[i]?"o":"-", iqentry_bt[i], iqentry_memissue[i], iqentry_agen[i] ? "a": "-", iqentry_issue[i]?"i":"-",
|
7343 |
|
|
((i==0) ? iqentry_islot[0] : (i==1) ? iqentry_islot[1] : (i==2) ? iqentry_islot[2] : (i==3) ? iqentry_islot[3] :
|
7344 |
|
|
(i==4) ? iqentry_islot[4] : (i==5) ? iqentry_islot[5] : (i==6) ? iqentry_islot[6] : iqentry_islot[7]), iqentry_stomp[i]?"s":"-",
|
7345 |
|
|
(IsFlowCtrl(iqentry_instr[i]) ? 98 : (IsMem(iqentry_instr[i])) ? 109 : 97),
|
7346 |
|
|
iqentry_instr[i], iqentry_tgt[i][4:0],
|
7347 |
|
|
iqentry_exc[i], iqentry_res[i], iqentry_a0[i], iqentry_a1[i], iqentry_a1_v[i],
|
7348 |
|
|
iqentry_a1_s[i],
|
7349 |
|
|
iqentry_a2[i], iqentry_a2_v[i], iqentry_a2_s[i],
|
7350 |
|
|
iqentry_a3[i], iqentry_a3_v[i], iqentry_a3_s[i],
|
7351 |
|
|
iqentry_thrd[i],
|
7352 |
|
|
iqentry_pc[i],
|
7353 |
|
|
iqentry_sn[i], iqentry_ven[i]
|
7354 |
|
|
);
|
7355 |
|
|
$display("DRAM");
|
7356 |
|
|
$display("%d %h %h %c%h %o #",
|
7357 |
|
|
dram0, dram0_addr, dram0_data, (IsFlowCtrl(dram0_instr) ? 98 : (IsMem(dram0_instr)) ? 109 : 97),
|
7358 |
|
|
dram0_instr, dram0_id);
|
7359 |
|
|
$display("%d %h %h %c%h %o #",
|
7360 |
|
|
dram1, dram1_addr, dram1_data, (IsFlowCtrl(dram1_instr) ? 98 : (IsMem(dram1_instr)) ? 109 : 97),
|
7361 |
|
|
dram1_instr, dram1_id);
|
7362 |
|
|
$display("%d %h %h %c%h %o #",
|
7363 |
|
|
dram2, dram2_addr, dram2_data, (IsFlowCtrl(dram2_instr) ? 98 : (IsMem(dram2_instr)) ? 109 : 97),
|
7364 |
|
|
dram2_instr, dram2_id);
|
7365 |
|
|
$display("%d %h %o %h #", dramA_v, dramA_bus, dramA_id, dramA_exc);
|
7366 |
|
|
$display("%d %h %o %h #", dramB_v, dramB_bus, dramB_id, dramB_exc);
|
7367 |
|
|
$display("%d %h %o %h #", dramC_v, dramC_bus, dramC_id, dramC_exc);
|
7368 |
|
|
$display("ALU");
|
7369 |
|
|
$display("%d %h %h %h %c%h %d %o %h #",
|
7370 |
|
|
alu0_dataready, alu0_argI, alu0_argA, alu0_argB,
|
7371 |
|
|
(IsFlowCtrl(alu0_instr) ? 98 : IsMem(alu0_instr) ? 109 : 97),
|
7372 |
|
|
alu0_instr, alu0_bt, alu0_sourceid, alu0_pc);
|
7373 |
|
|
$display("%d %h %o 0 #", alu0_v, alu0_bus, alu0_id);
|
7374 |
|
|
|
7375 |
|
|
$display("%d %h %h %h %c%h %d %o %h #",
|
7376 |
|
|
alu1_dataready, alu1_argI, alu1_argA, alu1_argB,
|
7377 |
|
|
(IsFlowCtrl(alu1_instr) ? 98 : IsMem(alu1_instr) ? 109 : 97),
|
7378 |
|
|
alu1_instr, alu1_bt, alu1_sourceid, alu1_pc);
|
7379 |
|
|
$display("%d %h %o 0 #", alu1_v, alu1_bus, alu1_id);
|
7380 |
|
|
$display("FCU");
|
7381 |
|
|
$display("%d %h %h %h %h #", fcu_v, fcu_bus, fcu_argI, fcu_argA, fcu_argB);
|
7382 |
|
|
$display("%c %h %h #", fcu_branchmiss?"m":" ", fcu_sourceid, fcu_misspc);
|
7383 |
|
|
$display("Commit");
|
7384 |
|
|
$display("0: %c %h %o 0%d #", commit0_v?"v":" ", commit0_bus, commit0_id, commit0_tgt[4:0]);
|
7385 |
|
|
$display("1: %c %h %o 0%d #", commit1_v?"v":" ", commit1_bus, commit1_id, commit1_tgt[4:0]);
|
7386 |
|
|
$display("instructions committed: %d ticks: %d ", I, tick);
|
7387 |
|
|
//
|
7388 |
|
|
// $display("\n\n\n\n\n\n\n\n");
|
7389 |
|
|
// $display("TIME %0d", $time);
|
7390 |
|
|
// $display(" pc0=%h", pc0);
|
7391 |
|
|
// $display(" pc1=%h", pc1);
|
7392 |
|
|
// $display(" reg0=%h, v=%d, src=%o", rf[0], rf_v[0], rf_source[0]);
|
7393 |
|
|
// $display(" reg1=%h, v=%d, src=%o", rf[1], rf_v[1], rf_source[1]);
|
7394 |
|
|
// $display(" reg2=%h, v=%d, src=%o", rf[2], rf_v[2], rf_source[2]);
|
7395 |
|
|
// $display(" reg3=%h, v=%d, src=%o", rf[3], rf_v[3], rf_source[3]);
|
7396 |
|
|
// $display(" reg4=%h, v=%d, src=%o", rf[4], rf_v[4], rf_source[4]);
|
7397 |
|
|
// $display(" reg5=%h, v=%d, src=%o", rf[5], rf_v[5], rf_source[5]);
|
7398 |
|
|
// $display(" reg6=%h, v=%d, src=%o", rf[6], rf_v[6], rf_source[6]);
|
7399 |
|
|
// $display(" reg7=%h, v=%d, src=%o", rf[7], rf_v[7], rf_source[7]);
|
7400 |
|
|
|
7401 |
|
|
// $display("Fetch Buffers:");
|
7402 |
|
|
// $display(" %c%c fbA: v=%d instr=%h pc=%h %c%c fbC: v=%d instr=%h pc=%h",
|
7403 |
|
|
// fetchbuf?32:45, fetchbuf?32:62, fetchbufA_v, fetchbufA_instr, fetchbufA_pc,
|
7404 |
|
|
// fetchbuf?45:32, fetchbuf?62:32, fetchbufC_v, fetchbufC_instr, fetchbufC_pc);
|
7405 |
|
|
// $display(" %c%c fbB: v=%d instr=%h pc=%h %c%c fbD: v=%d instr=%h pc=%h",
|
7406 |
|
|
// fetchbuf?32:45, fetchbuf?32:62, fetchbufB_v, fetchbufB_instr, fetchbufB_pc,
|
7407 |
|
|
// fetchbuf?45:32, fetchbuf?62:32, fetchbufD_v, fetchbufD_instr, fetchbufD_pc);
|
7408 |
|
|
// $display(" branchback=%d backpc=%h", branchback, backpc);
|
7409 |
|
|
|
7410 |
|
|
// $display("Instruction Queue:");
|
7411 |
|
|
// for (i=0; i<8; i=i+1)
|
7412 |
|
|
// $display(" %c%c%d: v=%d done=%d out=%d agen=%d res=%h op=%d bt=%d tgt=%d a1=%h (v=%d/s=%o) a2=%h (v=%d/s=%o) im=%h pc=%h exc=%h",
|
7413 |
|
|
// (i[`QBITS]==head0)?72:32, (i[`QBITS]==tail0)?84:32, i,
|
7414 |
|
|
// iqentry_v[i], iqentry_done[i], iqentry_out[i], iqentry_agen[i], iqentry_res[i], iqentry_op[i],
|
7415 |
|
|
// iqentry_bt[i], iqentry_tgt[i], iqentry_a1[i], iqentry_a1_v[i], iqentry_a1_s[i], iqentry_a2[i], iqentry_a2_v[i],
|
7416 |
|
|
// iqentry_a2_s[i], iqentry_a0[i], iqentry_pc[i], iqentry_exc[i]);
|
7417 |
|
|
|
7418 |
|
|
// $display("Scheduling Status:");
|
7419 |
|
|
// $display(" iqentry0 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7420 |
|
|
// iqentry_0_issue, iqentry_0_islot, iqentry_stomp[0], iqentry_source[0], iqentry_memready[0], iqentry_memissue[0]);
|
7421 |
|
|
// $display(" iqentry1 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7422 |
|
|
// iqentry_1_issue, iqentry_1_islot, iqentry_stomp[1], iqentry_source[1], iqentry_memready[1], iqentry_memissue[1]);
|
7423 |
|
|
// $display(" iqentry2 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7424 |
|
|
// iqentry_2_issue, iqentry_2_islot, iqentry_stomp[2], iqentry_source[2], iqentry_memready[2], iqentry_memissue[2]);
|
7425 |
|
|
// $display(" iqentry3 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7426 |
|
|
// iqentry_3_issue, iqentry_3_islot, iqentry_stomp[3], iqentry_source[3], iqentry_memready[3], iqentry_memissue[3]);
|
7427 |
|
|
// $display(" iqentry4 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7428 |
|
|
// iqentry_4_issue, iqentry_4_islot, iqentry_stomp[4], iqentry_source[4], iqentry_memready[4], iqentry_memissue[4]);
|
7429 |
|
|
// $display(" iqentry5 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7430 |
|
|
// iqentry_5_issue, iqentry_5_islot, iqentry_stomp[5], iqentry_source[5], iqentry_memready[5], iqentry_memissue[5]);
|
7431 |
|
|
// $display(" iqentry6 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7432 |
|
|
// iqentry_6_issue, iqentry_6_islot, iqentry_stomp[6], iqentry_source[6], iqentry_memready[6], iqentry_memissue[6]);
|
7433 |
|
|
// $display(" iqentry7 issue=%d islot=%d stomp=%d source=%d - memready=%d memissue=%b",
|
7434 |
|
|
// iqentry_7_issue, iqentry_7_islot, iqentry_stomp[7], iqentry_source[7], iqentry_memready[7], iqentry_memissue[7]);
|
7435 |
|
|
|
7436 |
|
|
// $display("ALU Inputs:");
|
7437 |
|
|
// $display(" 0: avail=%d data=%d id=%o op=%d a1=%h a2=%h im=%h bt=%d",
|
7438 |
|
|
// alu0_available, alu0_dataready, alu0_sourceid, alu0_op, alu0_argA,
|
7439 |
|
|
// alu0_argB, alu0_argI, alu0_bt);
|
7440 |
|
|
// $display(" 1: avail=%d data=%d id=%o op=%d a1=%h a2=%h im=%h bt=%d",
|
7441 |
|
|
// alu1_available, alu1_dataready, alu1_sourceid, alu1_op, alu1_argA,
|
7442 |
|
|
// alu1_argB, alu1_argI, alu1_bt);
|
7443 |
|
|
|
7444 |
|
|
// $display("ALU Outputs:");
|
7445 |
|
|
// $display(" 0: v=%d bus=%h id=%o bmiss=%d misspc=%h missid=%o",
|
7446 |
|
|
// alu0_v, alu0_bus, alu0_id, alu0_branchmiss, alu0_misspc, alu0_sourceid);
|
7447 |
|
|
// $display(" 1: v=%d bus=%h id=%o bmiss=%d misspc=%h missid=%o",
|
7448 |
|
|
// alu1_v, alu1_bus, alu1_id, alu1_branchmiss, alu1_misspc, alu1_sourceid);
|
7449 |
|
|
|
7450 |
|
|
// $display("DRAM Status:");
|
7451 |
|
|
// $display(" OUT: v=%d data=%h tgt=%d id=%o", dram_v, dram_bus, dram_tgt, dram_id);
|
7452 |
|
|
// $display(" dram0: status=%h addr=%h data=%h op=%d tgt=%d id=%o",
|
7453 |
|
|
// dram0, dram0_addr, dram0_data, dram0_op, dram0_tgt, dram0_id);
|
7454 |
|
|
// $display(" dram1: status=%h addr=%h data=%h op=%d tgt=%d id=%o",
|
7455 |
|
|
// dram1, dram1_addr, dram1_data, dram1_op, dram1_tgt, dram1_id);
|
7456 |
|
|
// $display(" dram2: status=%h addr=%h data=%h op=%d tgt=%d id=%o",
|
7457 |
|
|
// dram2, dram2_addr, dram2_data, dram2_op, dram2_tgt, dram2_id);
|
7458 |
|
|
|
7459 |
|
|
// $display("Commit Buses:");
|
7460 |
|
|
// $display(" 0: v=%d id=%o data=%h", commit0_v, commit0_id, commit0_bus);
|
7461 |
|
|
// $display(" 1: v=%d id=%o data=%h", commit1_v, commit1_id, commit1_bus);
|
7462 |
|
|
|
7463 |
|
|
//
|
7464 |
|
|
// $display("Memory Contents:");
|
7465 |
|
|
// for (j=0; j<64; j=j+16)
|
7466 |
|
|
// $display(" %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h %h",
|
7467 |
|
|
// m[j+0], m[j+1], m[j+2], m[j+3], m[j+4], m[j+5], m[j+6], m[j+7],
|
7468 |
|
|
// m[j+8], m[j+9], m[j+10], m[j+11], m[j+12], m[j+13], m[j+14], m[j+15]);
|
7469 |
|
|
|
7470 |
|
|
$display("");
|
7471 |
|
|
|
7472 |
|
|
if (|panic) begin
|
7473 |
|
|
$display("");
|
7474 |
|
|
$display("-----------------------------------------------------------------");
|
7475 |
|
|
$display("-----------------------------------------------------------------");
|
7476 |
|
|
$display("--------------- PANIC:%s -----------------", message[panic]);
|
7477 |
|
|
$display("-----------------------------------------------------------------");
|
7478 |
|
|
$display("-----------------------------------------------------------------");
|
7479 |
|
|
$display("");
|
7480 |
|
|
$display("instructions committed: %d", I);
|
7481 |
|
|
$display("total execution cycles: %d", $time / 10);
|
7482 |
|
|
$display("");
|
7483 |
|
|
end
|
7484 |
|
|
if (|panic && ~outstanding_stores) begin
|
7485 |
|
|
$finish;
|
7486 |
|
|
end
|
7487 |
|
|
for (n = 0; n < QENTRIES; n = n + 1)
|
7488 |
|
|
if (branchmiss) begin
|
7489 |
|
|
if (!setpred[n]) begin
|
7490 |
|
|
iqentry_instr[n][`INSTRUCTION_OP] <= `NOP;
|
7491 |
|
|
iqentry_done[n] <= `VAL;
|
7492 |
|
|
iqentry_cmt[n] <= `VAL;
|
7493 |
|
|
end
|
7494 |
|
|
end
|
7495 |
|
|
|
7496 |
|
|
if (snr) begin
|
7497 |
|
|
seq_num <= 32'd0;
|
7498 |
|
|
seq_num1 <= 32'd0;
|
7499 |
|
|
end
|
7500 |
|
|
end // clock domain
|
7501 |
|
|
/*
|
7502 |
|
|
always @(posedge clk)
|
7503 |
|
|
if (rst) begin
|
7504 |
|
|
tail0 <= 3'd0;
|
7505 |
|
|
tail1 <= 3'd1;
|
7506 |
|
|
end
|
7507 |
|
|
else begin
|
7508 |
|
|
if (!branchmiss) begin
|
7509 |
|
|
case({fetchbuf0_v, fetchbuf1_v})
|
7510 |
|
|
2'b00: ;
|
7511 |
|
|
2'b01:
|
7512 |
|
|
if (canq1) begin
|
7513 |
|
|
tail0 <= idp1(tail0);
|
7514 |
|
|
tail1 <= idp1(tail1);
|
7515 |
|
|
end
|
7516 |
|
|
2'b10:
|
7517 |
|
|
if (canq1) begin
|
7518 |
|
|
tail0 <= idp1(tail0);
|
7519 |
|
|
tail1 <= idp1(tail1);
|
7520 |
|
|
end
|
7521 |
|
|
2'b11:
|
7522 |
|
|
if (canq1) begin
|
7523 |
|
|
if (IsBranch(fetchbuf0_instr) && predict_taken0) begin
|
7524 |
|
|
tail0 <= idp1(tail0);
|
7525 |
|
|
tail1 <= idp1(tail1);
|
7526 |
|
|
end
|
7527 |
|
|
else begin
|
7528 |
|
|
if (vqe < vl || !IsVector(fetchbuf0_instr)) begin
|
7529 |
|
|
if (canq2) begin
|
7530 |
|
|
tail0 <= idp2(tail0);
|
7531 |
|
|
tail1 <= idp2(tail1);
|
7532 |
|
|
end
|
7533 |
|
|
else begin // queued1 will be true
|
7534 |
|
|
tail0 <= idp1(tail0);
|
7535 |
|
|
tail1 <= idp1(tail1);
|
7536 |
|
|
end
|
7537 |
|
|
end
|
7538 |
|
|
end
|
7539 |
|
|
end
|
7540 |
|
|
endcase
|
7541 |
|
|
end
|
7542 |
|
|
else begin // if branchmiss
|
7543 |
|
|
if (iqentry_stomp[0] & ~iqentry_stomp[7]) begin
|
7544 |
|
|
tail0 <= 3'd0;
|
7545 |
|
|
tail1 <= 3'd1;
|
7546 |
|
|
end
|
7547 |
|
|
else if (iqentry_stomp[1] & ~iqentry_stomp[0]) begin
|
7548 |
|
|
tail0 <= 3'd1;
|
7549 |
|
|
tail1 <= 3'd2;
|
7550 |
|
|
end
|
7551 |
|
|
else if (iqentry_stomp[2] & ~iqentry_stomp[1]) begin
|
7552 |
|
|
tail0 <= 3'd2;
|
7553 |
|
|
tail1 <= 3'd3;
|
7554 |
|
|
end
|
7555 |
|
|
else if (iqentry_stomp[3] & ~iqentry_stomp[2]) begin
|
7556 |
|
|
tail0 <= 3'd3;
|
7557 |
|
|
tail1 <= 3'd4;
|
7558 |
|
|
end
|
7559 |
|
|
else if (iqentry_stomp[4] & ~iqentry_stomp[3]) begin
|
7560 |
|
|
tail0 <= 3'd4;
|
7561 |
|
|
tail1 <= 3'd5;
|
7562 |
|
|
end
|
7563 |
|
|
else if (iqentry_stomp[5] & ~iqentry_stomp[4]) begin
|
7564 |
|
|
tail0 <= 3'd5;
|
7565 |
|
|
tail1 <= 3'd6;
|
7566 |
|
|
end
|
7567 |
|
|
else if (iqentry_stomp[6] & ~iqentry_stomp[5]) begin
|
7568 |
|
|
tail0 <= 3'd6;
|
7569 |
|
|
tail1 <= 3'd7;
|
7570 |
|
|
end
|
7571 |
|
|
else if (iqentry_stomp[7] & ~iqentry_stomp[6]) begin
|
7572 |
|
|
tail0 <= 3'd7;
|
7573 |
|
|
tail1 <= 3'd0;
|
7574 |
|
|
end
|
7575 |
|
|
// otherwise, it is the last instruction in the queue that has been mispredicted ... do nothing
|
7576 |
|
|
end
|
7577 |
|
|
end
|
7578 |
|
|
*/
|
7579 |
|
|
/*
|
7580 |
|
|
always @(posedge clk)
|
7581 |
|
|
if (rst)
|
7582 |
|
|
seq_num <= 5'd0;
|
7583 |
|
|
else begin
|
7584 |
|
|
if (pebm)
|
7585 |
|
|
seq_num <= seq_num + 5'd3;
|
7586 |
|
|
else if (queued2)
|
7587 |
|
|
seq_num <= seq_num + 5'd2;
|
7588 |
|
|
else if (queued1)
|
7589 |
|
|
seq_num <= seq_num + 5'd1;
|
7590 |
|
|
end
|
7591 |
|
|
*/
|
7592 |
|
|
// Increment the head pointers
|
7593 |
|
|
// Also increments the instruction counter
|
7594 |
|
|
// Used when instructions are committed.
|
7595 |
|
|
// Also clear any outstanding state bits that foul things up.
|
7596 |
|
|
//
|
7597 |
|
|
task head_inc;
|
7598 |
|
|
input [`QBITS] amt;
|
7599 |
|
|
begin
|
7600 |
|
|
head0 <= head0 + amt;
|
7601 |
|
|
head1 <= head1 + amt;
|
7602 |
|
|
head2 <= head2 + amt;
|
7603 |
|
|
head3 <= head3 + amt;
|
7604 |
|
|
head4 <= head4 + amt;
|
7605 |
|
|
head5 <= head5 + amt;
|
7606 |
|
|
head6 <= head6 + amt;
|
7607 |
|
|
head7 <= head7 + amt;
|
7608 |
|
|
I <= I + amt;
|
7609 |
|
|
if (amt==3'd2) begin
|
7610 |
|
|
iqentry_agen[head0] <= `INV;
|
7611 |
|
|
iqentry_agen[head1] <= `INV;
|
7612 |
|
|
end else if (amt==3'd1)
|
7613 |
|
|
iqentry_agen[head0] <= `INV;
|
7614 |
|
|
end
|
7615 |
|
|
endtask
|
7616 |
|
|
|
7617 |
|
|
task setargs;
|
7618 |
|
|
input [`QBITS] nn;
|
7619 |
|
|
input [4:0] id;
|
7620 |
|
|
input v;
|
7621 |
|
|
input [63:0] bus;
|
7622 |
|
|
begin
|
7623 |
|
|
if (iqentry_a1_v[nn] == `INV && iqentry_a1_s[nn] == id && iqentry_v[nn] == `VAL && v == `VAL) begin
|
7624 |
|
|
iqentry_a1[nn] <= bus;
|
7625 |
|
|
iqentry_a1_v[nn] <= `VAL;
|
7626 |
|
|
end
|
7627 |
|
|
if (iqentry_a2_v[nn] == `INV && iqentry_a2_s[nn] == id && iqentry_v[nn] == `VAL && v == `VAL) begin
|
7628 |
|
|
iqentry_a2[nn] <= bus;
|
7629 |
|
|
iqentry_a2_v[nn] <= `VAL;
|
7630 |
|
|
end
|
7631 |
|
|
if (iqentry_a3_v[nn] == `INV && iqentry_a3_s[nn] == id && iqentry_v[nn] == `VAL && v == `VAL) begin
|
7632 |
|
|
iqentry_a3[nn] <= bus;
|
7633 |
|
|
iqentry_a3_v[nn] <= `VAL;
|
7634 |
|
|
end
|
7635 |
|
|
end
|
7636 |
|
|
endtask
|
7637 |
|
|
|
7638 |
|
|
// Enqueue fetchbuf0 onto the tail of the instruction queue
|
7639 |
|
|
task enque0;
|
7640 |
|
|
input [`QBITS] tail;
|
7641 |
|
|
input [63:0] seqnum;
|
7642 |
|
|
input [5:0] venno;
|
7643 |
|
|
begin
|
7644 |
|
|
iqentry_exc[tail] <= `FLT_NONE;
|
7645 |
|
|
`ifdef SUPPORT_DBG
|
7646 |
|
|
if (dbg_imatchA)
|
7647 |
|
|
iqentry_exc[tail] <= `FLT_DBG;
|
7648 |
|
|
else if (dbg_ctrl[63])
|
7649 |
|
|
iqentry_exc[tail] <= `FLT_SSM;
|
7650 |
|
|
`endif
|
7651 |
|
|
iqentry_sn [tail] <= seqnum;
|
7652 |
|
|
iqentry_v [tail] <= `VAL;
|
7653 |
|
|
iqentry_thrd [tail] <= 1'b0;
|
7654 |
|
|
iqentry_done [tail] <= `INV;
|
7655 |
|
|
iqentry_cmt [tail] <= `INV;
|
7656 |
|
|
iqentry_pred [tail] <= `VAL;
|
7657 |
|
|
iqentry_out [tail] <= `INV;
|
7658 |
|
|
iqentry_res [tail] <= `ZERO;
|
7659 |
|
|
iqentry_instr[tail] <= IsVLS(fetchbuf0_instr) ? (vm[fnM2(fetchbuf0_instr)] ? fetchbuf0_instr : `NOP_INSN) : fetchbuf0_instr;
|
7660 |
|
|
iqentry_bt [tail] <= (IsBranch(fetchbuf0_instr) && predict_taken0);
|
7661 |
|
|
iqentry_agen [tail] <= `INV;
|
7662 |
|
|
// If the previous instruction was a hardware interrupt and this instruction is a hardware interrupt
|
7663 |
|
|
// inherit the previous pc.
|
7664 |
|
|
//if (IsBrk(fetchbuf0_instr) && !fetchbuf0_instr[15] &&
|
7665 |
|
|
// (IsBrk(iqentry_instr[idm1(tail)]) && !iqentry_instr[idm1(tail1)][15] && iqentry_v[idm1(tail)]))
|
7666 |
|
|
// iqentry_pc [tail] <= iqentry_pc[idm1(tail)];
|
7667 |
|
|
//else
|
7668 |
|
|
iqentry_pc [tail] <= fetchbuf0_pc;
|
7669 |
|
|
iqentry_alu [tail] <= IsALU(fetchbuf0_instr);
|
7670 |
|
|
iqentry_alu0 [tail] <= IsAlu0Only(fetchbuf0_instr);
|
7671 |
|
|
iqentry_fpu [tail] <= IsFPU(fetchbuf0_instr);
|
7672 |
|
|
iqentry_fc [tail] <= IsFlowCtrl(fetchbuf0_instr);
|
7673 |
|
|
iqentry_canex[tail] <= fnCanException(fetchbuf0_instr);
|
7674 |
|
|
iqentry_load [tail] <= IsLoad(fetchbuf0_instr);
|
7675 |
|
|
iqentry_mem [tail] <= fetchbuf0_mem;
|
7676 |
|
|
iqentry_memndx[tail] <= IsMemNdx(fetchbuf0_instr);
|
7677 |
|
|
iqentry_memdb[tail] <= IsMemdb(fetchbuf0_instr);
|
7678 |
|
|
iqentry_memsb[tail] <= IsMemsb(fetchbuf0_instr);
|
7679 |
|
|
iqentry_aq [tail] <= (IsAMO(fetchbuf0_instr)|IsLWRX(fetchbuf0_instr)|IsSWCX(fetchbuf0_instr)) & fetchbuf0_instr[25];
|
7680 |
|
|
iqentry_rl [tail] <= (IsAMO(fetchbuf0_instr)|IsLWRX(fetchbuf0_instr)|IsSWCX(fetchbuf0_instr)) & fetchbuf0_instr[24];
|
7681 |
|
|
iqentry_jmp [tail] <= fetchbuf0_jmp;
|
7682 |
|
|
iqentry_br [tail] <= IsBranch(fetchbuf0_instr);
|
7683 |
|
|
iqentry_sync [tail] <= IsSync(fetchbuf0_instr)||IsBrk(fetchbuf0_instr)||IsRTI(fetchbuf0_instr);
|
7684 |
|
|
iqentry_fsync[tail] <= IsFSync(fetchbuf0_instr);
|
7685 |
|
|
iqentry_rfw [tail] <= fetchbuf0_rfw;
|
7686 |
|
|
iqentry_we [tail] <= fnWe(fetchbuf0_instr);
|
7687 |
|
|
iqentry_tgt [tail] <= Rt0;
|
7688 |
|
|
iqentry_Ra[tail] <= Ra0;
|
7689 |
|
|
iqentry_Rb[tail] <= Rb0;
|
7690 |
|
|
iqentry_Rc[tail] <= Rc0;
|
7691 |
|
|
iqentry_ven [tail] <= venno;
|
7692 |
|
|
iqentry_exc [tail] <= `EXC_NONE;
|
7693 |
|
|
iqentry_imm [tail] <= HasConst(fetchbuf0_instr);
|
7694 |
|
|
iqentry_a0 [tail] <= {{48{fetchbuf0_instr[`INSTRUCTION_SB]}},fetchbuf0_instr[31:16]};
|
7695 |
|
|
iqentry_a1 [tail] <= rfoa0;
|
7696 |
|
|
iqentry_a1_v [tail] <= Source1Valid(fetchbuf0_instr) | regIsValid[Ra0s];
|
7697 |
|
|
iqentry_a1_s [tail] <= rf_source[Ra0s];
|
7698 |
|
|
iqentry_a2 [tail] <= rfob0;
|
7699 |
|
|
iqentry_a2_v [tail] <= Source2Valid(fetchbuf0_instr) | regIsValid[Rb0s];
|
7700 |
|
|
iqentry_a2_s [tail] <= rf_source[Rb0s];
|
7701 |
|
|
iqentry_a3 [tail] <= rfoc0;
|
7702 |
|
|
iqentry_a3_v [tail] <= Source3Valid(fetchbuf0_instr) | regIsValid[Rc0s];
|
7703 |
|
|
iqentry_a3_s [tail] <= rf_source[Rc0s];
|
7704 |
|
|
end
|
7705 |
|
|
endtask
|
7706 |
|
|
|
7707 |
|
|
// Enque fetchbuf1. Fetchbuf1 might be the second instruction to queue so some
|
7708 |
|
|
// of this code checks to see which tail it is being queued on.
|
7709 |
|
|
task enque1;
|
7710 |
|
|
input [`QBITS] tail;
|
7711 |
|
|
input [63:0] seqnum;
|
7712 |
|
|
input [5:0] venno;
|
7713 |
|
|
begin
|
7714 |
|
|
iqentry_exc[tail] <= `FLT_NONE;
|
7715 |
|
|
`ifdef SUPPORT_DBG
|
7716 |
|
|
if (dbg_imatchB)
|
7717 |
|
|
iqentry_exc[tail] <= `FLT_DBG;
|
7718 |
|
|
else if (dbg_ctrl[63])
|
7719 |
|
|
iqentry_exc[tail] <= `FLT_SSM;
|
7720 |
|
|
`endif
|
7721 |
|
|
iqentry_sn [tail] <= seqnum;
|
7722 |
|
|
iqentry_v [tail] <= `VAL;
|
7723 |
|
|
iqentry_thrd [tail] <= thread_en ? 1'b1 : 1'b0;
|
7724 |
|
|
iqentry_done [tail] <= `INV;
|
7725 |
|
|
iqentry_cmt [tail] <= `INV;
|
7726 |
|
|
iqentry_pred [tail] <= `VAL;
|
7727 |
|
|
iqentry_out [tail] <= `INV;
|
7728 |
|
|
iqentry_res [tail] <= `ZERO;
|
7729 |
|
|
iqentry_instr[tail] <= IsVLS(fetchbuf1_instr) ? (vm[fnM2(fetchbuf1_instr)] ? fetchbuf1_instr : `NOP_INSN) : fetchbuf1_instr;
|
7730 |
|
|
iqentry_bt [tail] <= (IsBranch(fetchbuf1_instr) && predict_taken1);
|
7731 |
|
|
iqentry_agen [tail] <= `INV;
|
7732 |
|
|
// If queing 2nd instruction must read from first
|
7733 |
|
|
if (tail==tail1) begin
|
7734 |
|
|
// If the previous instruction was a hardware interrupt and this instruction is a hardware interrupt
|
7735 |
|
|
// inherit the previous pc.
|
7736 |
|
|
// if (IsBrk(fetchbuf1_instr) && !fetchbuf1_instr[15] &&
|
7737 |
|
|
// IsBrk(fetchbuf0_instr) && !fetchbuf0_instr[15])
|
7738 |
|
|
// iqentry_pc [tail] <= fetchbuf0_pc;
|
7739 |
|
|
// else
|
7740 |
|
|
iqentry_pc [tail] <= fetchbuf1_pc;
|
7741 |
|
|
end
|
7742 |
|
|
else begin
|
7743 |
|
|
// If the previous instruction was a hardware interrupt and this instruction is a hardware interrupt
|
7744 |
|
|
// inherit the previous pc.
|
7745 |
|
|
// if (IsBrk(fetchbuf1_instr) && !fetchbuf1_instr[15] &&
|
7746 |
|
|
// (IsBrk(iqentry_instr[idp7(tail)]) && !iqentry_instr[idm1(tail)][15] && iqentry_v[idm1(tail)]))
|
7747 |
|
|
// iqentry_pc [tail] <= iqentry_pc[idm1(tail)];
|
7748 |
|
|
// else
|
7749 |
|
|
iqentry_pc [tail] <= fetchbuf1_pc;
|
7750 |
|
|
end
|
7751 |
|
|
iqentry_alu [tail] <= IsALU(fetchbuf1_instr);
|
7752 |
|
|
iqentry_alu0 [tail] <= IsAlu0Only(fetchbuf1_instr);
|
7753 |
|
|
iqentry_fpu [tail] <= IsFPU(fetchbuf1_instr);
|
7754 |
|
|
iqentry_fc [tail] <= IsFlowCtrl(fetchbuf1_instr);
|
7755 |
|
|
iqentry_canex[tail] <= fnCanException(fetchbuf1_instr);
|
7756 |
|
|
iqentry_load [tail] <= IsLoad(fetchbuf1_instr);
|
7757 |
|
|
iqentry_mem [tail] <= fetchbuf1_mem;
|
7758 |
|
|
iqentry_memndx[tail] <= IsMemNdx(fetchbuf1_instr);
|
7759 |
|
|
iqentry_memdb[tail] <= IsMemdb(fetchbuf1_instr);
|
7760 |
|
|
iqentry_memsb[tail] <= IsMemsb(fetchbuf1_instr);
|
7761 |
|
|
iqentry_aq [tail] <= (IsAMO(fetchbuf1_instr)|IsLWRX(fetchbuf1_instr)|IsSWCX(fetchbuf1_instr)) & fetchbuf1_instr[25];
|
7762 |
|
|
iqentry_rl [tail] <= (IsAMO(fetchbuf1_instr)|IsLWRX(fetchbuf1_instr)|IsSWCX(fetchbuf1_instr)) & fetchbuf1_instr[24];
|
7763 |
|
|
iqentry_jmp [tail] <= fetchbuf1_jmp;
|
7764 |
|
|
iqentry_br [tail] <= IsBranch(fetchbuf1_instr);
|
7765 |
|
|
iqentry_sync [tail] <= IsSync(fetchbuf1_instr)||IsBrk(fetchbuf1_instr)||IsRTI(fetchbuf1_instr);
|
7766 |
|
|
iqentry_fsync[tail] <= IsFSync(fetchbuf1_instr);
|
7767 |
|
|
iqentry_rfw [tail] <= fetchbuf1_rfw;
|
7768 |
|
|
iqentry_we [tail] <= fnWe(fetchbuf1_instr);
|
7769 |
|
|
iqentry_tgt [tail] <= Rt1;
|
7770 |
|
|
iqentry_Ra[tail] <= Ra1;
|
7771 |
|
|
iqentry_Rb[tail] <= Rb1;
|
7772 |
|
|
iqentry_Rc[tail] <= Rc1;
|
7773 |
|
|
iqentry_ven [tail] <= venno;
|
7774 |
|
|
iqentry_exc [tail] <= `EXC_NONE;
|
7775 |
|
|
iqentry_imm [tail] <= HasConst(fetchbuf1_instr);
|
7776 |
|
|
iqentry_a0 [tail] <= {{48{fetchbuf1_instr[`INSTRUCTION_SB]}},fetchbuf1_instr[31:16]};
|
7777 |
|
|
iqentry_a1 [tail] <= rfoa1;
|
7778 |
|
|
iqentry_a1_v [tail] <= Source1Valid(fetchbuf1_instr) | regIsValid[Ra1s];
|
7779 |
|
|
iqentry_a1_s [tail] <= rf_source[Ra1s];
|
7780 |
|
|
iqentry_a2 [tail] <= rfob1;
|
7781 |
|
|
iqentry_a2_v [tail] <= Source2Valid(fetchbuf1_instr) | regIsValid[Rb1s];
|
7782 |
|
|
iqentry_a2_s [tail] <= rf_source[Rb1s];
|
7783 |
|
|
iqentry_a3 [tail] <= rfoc1;
|
7784 |
|
|
iqentry_a3_v [tail] <= Source3Valid(fetchbuf1_instr) | regIsValid[Rc1s];
|
7785 |
|
|
iqentry_a3_s [tail] <= rf_source[Rc1s];
|
7786 |
|
|
end
|
7787 |
|
|
endtask
|
7788 |
|
|
|
7789 |
|
|
function IsOddball;
|
7790 |
|
|
input [`QBITS] head;
|
7791 |
|
|
if (|iqentry_exc[head])
|
7792 |
|
|
IsOddball = TRUE;
|
7793 |
|
|
else
|
7794 |
|
|
case(iqentry_instr[head][`INSTRUCTION_OP])
|
7795 |
|
|
`BRK: IsOddball = TRUE;
|
7796 |
|
|
`VECTOR:
|
7797 |
|
|
case(iqentry_instr[head][`INSTRUCTION_S2])
|
7798 |
|
|
`VSxx: IsOddball = TRUE;
|
7799 |
|
|
default: IsOddball = FALSE;
|
7800 |
|
|
endcase
|
7801 |
|
|
`RR:
|
7802 |
|
|
case(iqentry_instr[head][`INSTRUCTION_S2])
|
7803 |
|
|
`VMOV: IsOddball = TRUE;
|
7804 |
|
|
`SEI,`RTI,`CACHEX: IsOddball = TRUE;
|
7805 |
|
|
default: IsOddball = FALSE;
|
7806 |
|
|
endcase
|
7807 |
|
|
`CSRRW,`REX,`CACHE,`FLOAT: IsOddball = TRUE;
|
7808 |
|
|
default: IsOddball = FALSE;
|
7809 |
|
|
endcase
|
7810 |
|
|
endfunction
|
7811 |
|
|
|
7812 |
|
|
// This task takes care of commits for things other than the register file.
|
7813 |
|
|
task oddball_commit;
|
7814 |
|
|
input v;
|
7815 |
|
|
input [`QBITS] head;
|
7816 |
|
|
reg thread;
|
7817 |
|
|
begin
|
7818 |
|
|
thread = iqentry_thrd[head];
|
7819 |
|
|
if (v) begin
|
7820 |
|
|
if (|iqentry_exc[head]) begin
|
7821 |
|
|
excmiss <= TRUE;
|
7822 |
|
|
excmisspc <= {tvec[3'd0][31:8],ol[thread],5'h00};
|
7823 |
|
|
excthrd <= iqentry_thrd[head];
|
7824 |
|
|
badaddr[{thread,3'd0}] <= iqentry_a1[head];
|
7825 |
|
|
epc0[thread] <= iqentry_pc[head]+ 32'd4;
|
7826 |
|
|
epc1[thread] <= epc0[thread];
|
7827 |
|
|
epc2[thread] <= epc1[thread];
|
7828 |
|
|
epc3[thread] <= epc2[thread];
|
7829 |
|
|
epc4[thread] <= epc3[thread];
|
7830 |
|
|
epc5[thread] <= epc4[thread];
|
7831 |
|
|
epc6[thread] <= epc5[thread];
|
7832 |
|
|
epc7[thread] <= epc6[thread];
|
7833 |
|
|
epc8[thread] <= epc7[thread];
|
7834 |
|
|
im_stack[thread] <= {im_stack[thread][20:0],im};
|
7835 |
|
|
ol_stack[thread] <= {ol_stack[thread][20:0],ol[thread]};
|
7836 |
|
|
pl_stack[thread] <= {pl_stack[thread][55:0],cpl[thread]};
|
7837 |
|
|
rs_stack[thread] <= {rs_stack[thread][55:0],rgs[thread]};
|
7838 |
|
|
cause[{thread,3'd0}] <= {7'd0,iqentry_exc[head]};
|
7839 |
|
|
mstatus[thread][5:3] <= 3'd0;
|
7840 |
|
|
mstatus[thread][13:6] <= 8'h00;
|
7841 |
|
|
sema[0] <= 1'b0;
|
7842 |
|
|
ve_hold <= {vqet1,10'd0,vqe1,10'd0,vqet0,10'd0,vqe0};
|
7843 |
|
|
`ifdef SUPPORT_DBG
|
7844 |
|
|
dbg_ctrl[62:55] <= {dbg_ctrl[61:55],dbg_ctrl[63]};
|
7845 |
|
|
dbg_ctrl[63] <= FALSE;
|
7846 |
|
|
`endif
|
7847 |
|
|
end
|
7848 |
|
|
else
|
7849 |
|
|
case(iqentry_instr[head][`INSTRUCTION_OP])
|
7850 |
|
|
`BRK:
|
7851 |
|
|
// BRK is treated as a nop unless it's a software interrupt or a
|
7852 |
|
|
// hardware interrupt at a higher priority than the current priority.
|
7853 |
|
|
if ((iqentry_instr[head][23:19] > 5'd0) || iqentry_instr[head][18:16] > im) begin
|
7854 |
|
|
excmiss <= TRUE;
|
7855 |
|
|
excmisspc <= {tvec[3'd0][31:8],ol[thread],5'h00};
|
7856 |
|
|
excthrd <= iqentry_thrd[head];
|
7857 |
|
|
epc0[thread] <= iqentry_pc[head] + {iqentry_instr[head][23:19],2'b00};
|
7858 |
|
|
epc1[thread] <= epc0[thread];
|
7859 |
|
|
epc2[thread] <= epc1[thread];
|
7860 |
|
|
epc3[thread] <= epc2[thread];
|
7861 |
|
|
epc4[thread] <= epc3[thread];
|
7862 |
|
|
epc5[thread] <= epc4[thread];
|
7863 |
|
|
epc6[thread] <= epc5[thread];
|
7864 |
|
|
epc7[thread] <= epc6[thread];
|
7865 |
|
|
epc8[thread] <= epc7[thread];
|
7866 |
|
|
im_stack[thread] <= {im_stack[thread][20:0],im};
|
7867 |
|
|
ol_stack[thread] <= {ol_stack[thread][20:0],ol[thread]};
|
7868 |
|
|
pl_stack[thread] <= {pl_stack[thread][55:0],cpl[thread]};
|
7869 |
|
|
rs_stack[thread] <= {rs_stack[thread][55:0],rgs[thread]};
|
7870 |
|
|
mstatus[thread][19:14] <= 6'd32;
|
7871 |
|
|
cause[{thread,3'd0}] <= {7'd0,iqentry_instr[head][14:6]};
|
7872 |
|
|
mstatus[thread][5:3] <= 3'd0;
|
7873 |
|
|
mstatus[thread][13:6] <= 8'h00;
|
7874 |
|
|
// For hardware interrupts only, set a new mask level
|
7875 |
|
|
// Select register set according to interrupt level
|
7876 |
|
|
if (iqentry_instr[head][23:19]==5'd0) begin
|
7877 |
|
|
mstatus[thread][2:0] <= 3'd7;//iqentry_instr[head][18:16];
|
7878 |
|
|
mstatus[thread][42:40] <= iqentry_instr[head][18:16];
|
7879 |
|
|
mstatus[thread][19:14] <= {1'b0,iqentry_instr[head][18:16],2'b00};
|
7880 |
|
|
end
|
7881 |
|
|
sema[0] <= 1'b0;
|
7882 |
|
|
ve_hold <= {vqet1,10'd0,vqe1,10'd0,vqet0,10'd0,vqe0};
|
7883 |
|
|
`ifdef SUPPORT_DBG
|
7884 |
|
|
dbg_ctrl[62:55] <= {dbg_ctrl[61:55],dbg_ctrl[63]};
|
7885 |
|
|
dbg_ctrl[63] <= FALSE;
|
7886 |
|
|
`endif
|
7887 |
|
|
end
|
7888 |
|
|
`VECTOR:
|
7889 |
|
|
casez(iqentry_tgt[head])
|
7890 |
|
|
8'b00100xxx: vm[iqentry_tgt[head][2:0]] <= iqentry_res[head];
|
7891 |
|
|
8'b00101111: vl <= iqentry_res[head];
|
7892 |
|
|
default: ;
|
7893 |
|
|
endcase
|
7894 |
|
|
`RR:
|
7895 |
|
|
case(iqentry_instr[head][`INSTRUCTION_S2])
|
7896 |
|
|
`R1: case(iqentry_instr[head][20:16])
|
7897 |
|
|
`CHAIN_OFF: cr0[18] <= 1'b0;
|
7898 |
|
|
`CHAIN_ON: cr0[18] <= 1'b1;
|
7899 |
|
|
endcase
|
7900 |
|
|
`VMOV: casez(iqentry_tgt[head])
|
7901 |
|
|
12'b1111111_00???: vm[iqentry_tgt[head][2:0]] <= iqentry_res[head];
|
7902 |
|
|
12'b1111111_01111: vl <= iqentry_res[head];
|
7903 |
|
|
endcase
|
7904 |
|
|
`SEI: mstatus[thread][2:0] <= iqentry_res[head][2:0]; // S1
|
7905 |
|
|
`RTI: begin
|
7906 |
|
|
excmiss <= TRUE;
|
7907 |
|
|
excmisspc <= epc0[thread];
|
7908 |
|
|
excthrd <= thread;
|
7909 |
|
|
mstatus[thread][2:0] <= im_stack[thread][2:0];
|
7910 |
|
|
mstatus[thread][5:3] <= ol_stack[thread][2:0];
|
7911 |
|
|
mstatus[thread][13:6] <= pl_stack[thread][7:0];
|
7912 |
|
|
mstatus[thread][19:14] <= rs_stack[thread][5:0];
|
7913 |
|
|
im_stack[thread] <= {3'd7,im_stack[thread][23:3]};
|
7914 |
|
|
ol_stack[thread] <= {3'd0,ol_stack[thread][23:3]};
|
7915 |
|
|
pl_stack[thread] <= {8'h00,pl_stack[thread][63:8]};
|
7916 |
|
|
rs_stack[thread] <= {8'h00,rs_stack[thread][63:8]};
|
7917 |
|
|
epc0[thread] <= epc1[thread];
|
7918 |
|
|
epc1[thread] <= epc2[thread];
|
7919 |
|
|
epc2[thread] <= epc3[thread];
|
7920 |
|
|
epc3[thread] <= epc4[thread];
|
7921 |
|
|
epc4[thread] <= epc5[thread];
|
7922 |
|
|
epc5[thread] <= epc6[thread];
|
7923 |
|
|
epc6[thread] <= epc7[thread];
|
7924 |
|
|
epc7[thread] <= epc8[thread];
|
7925 |
|
|
epc8[thread] <= {tvec[0][31:8], ol[thread], 5'h0};
|
7926 |
|
|
sema[0] <= 1'b0;
|
7927 |
|
|
sema[iqentry_res[head][5:0]] <= 1'b0;
|
7928 |
|
|
vqe0 <= ve_hold[ 5: 0];
|
7929 |
|
|
vqet0 <= ve_hold[21:16];
|
7930 |
|
|
vqe1 <= ve_hold[37:32];
|
7931 |
|
|
vqet1 <= ve_hold[53:48];
|
7932 |
|
|
`ifdef SUPPORT_DBG
|
7933 |
|
|
dbg_ctrl[62:55] <= {FALSE,dbg_ctrl[62:56]};
|
7934 |
|
|
dbg_ctrl[63] <= dbg_ctrl[55];
|
7935 |
|
|
`endif
|
7936 |
|
|
end
|
7937 |
|
|
`CACHEX:
|
7938 |
|
|
case(iqentry_instr[head][20:16])
|
7939 |
|
|
5'h03: invic <= TRUE;
|
7940 |
|
|
5'h10: cr0[30] <= FALSE;
|
7941 |
|
|
5'h11: cr0[30] <= TRUE;
|
7942 |
|
|
default: ;
|
7943 |
|
|
endcase
|
7944 |
|
|
default: ;
|
7945 |
|
|
endcase
|
7946 |
|
|
`CSRRW:
|
7947 |
|
|
begin
|
7948 |
|
|
write_csr(iqentry_instr[head][31:16],iqentry_a1[head],thread);
|
7949 |
|
|
end
|
7950 |
|
|
`REX:
|
7951 |
|
|
// Can only redirect to a lower level
|
7952 |
|
|
if (ol[thread] < iqentry_instr[head][13:11]) begin
|
7953 |
|
|
mstatus[thread][5:3] <= iqentry_instr[head][13:11];
|
7954 |
|
|
badaddr[{thread,iqentry_instr[head][13:11]}] <= badaddr[{thread,ol[thread]}];
|
7955 |
|
|
cause[{thread,iqentry_instr[head][13:11]}] <= cause[{thread,ol[thread]}];
|
7956 |
|
|
mstatus[thread][13:6] <= iqentry_instr[head][23:16] | iqentry_a1[head][7:0];
|
7957 |
|
|
end
|
7958 |
|
|
`CACHE:
|
7959 |
|
|
case(iqentry_instr[head][15:11])
|
7960 |
|
|
5'h03: invic <= TRUE;
|
7961 |
|
|
5'h10: cr0[30] <= FALSE;
|
7962 |
|
|
5'h11: cr0[30] <= TRUE;
|
7963 |
|
|
default: ;
|
7964 |
|
|
endcase
|
7965 |
|
|
`FLOAT:
|
7966 |
|
|
case(iqentry_instr[head][`INSTRUCTION_S2])
|
7967 |
|
|
`FRM: fp_rm <= iqentry_res[head][2:0];
|
7968 |
|
|
`FCX:
|
7969 |
|
|
begin
|
7970 |
|
|
fp_sx <= fp_sx & ~iqentry_res[head][5];
|
7971 |
|
|
fp_inex <= fp_inex & ~iqentry_res[head][4];
|
7972 |
|
|
fp_dbzx <= fp_dbzx & ~(iqentry_res[head][3]|iqentry_res[head][0]);
|
7973 |
|
|
fp_underx <= fp_underx & ~iqentry_res[head][2];
|
7974 |
|
|
fp_overx <= fp_overx & ~iqentry_res[head][1];
|
7975 |
|
|
fp_giopx <= fp_giopx & ~iqentry_res[head][0];
|
7976 |
|
|
fp_infdivx <= fp_infdivx & ~iqentry_res[head][0];
|
7977 |
|
|
fp_zerozerox <= fp_zerozerox & ~iqentry_res[head][0];
|
7978 |
|
|
fp_subinfx <= fp_subinfx & ~iqentry_res[head][0];
|
7979 |
|
|
fp_infzerox <= fp_infzerox & ~iqentry_res[head][0];
|
7980 |
|
|
fp_NaNCmpx <= fp_NaNCmpx & ~iqentry_res[head][0];
|
7981 |
|
|
fp_swtx <= 1'b0;
|
7982 |
|
|
end
|
7983 |
|
|
`FDX:
|
7984 |
|
|
begin
|
7985 |
|
|
fp_inexe <= fp_inexe & ~iqentry_res[head][4];
|
7986 |
|
|
fp_dbzxe <= fp_dbzxe & ~iqentry_res[head][3];
|
7987 |
|
|
fp_underxe <= fp_underxe & ~iqentry_res[head][2];
|
7988 |
|
|
fp_overxe <= fp_overxe & ~iqentry_res[head][1];
|
7989 |
|
|
fp_invopxe <= fp_invopxe & ~iqentry_res[head][0];
|
7990 |
|
|
end
|
7991 |
|
|
`FEX:
|
7992 |
|
|
begin
|
7993 |
|
|
fp_inexe <= fp_inexe | iqentry_res[head][4];
|
7994 |
|
|
fp_dbzxe <= fp_dbzxe | iqentry_res[head][3];
|
7995 |
|
|
fp_underxe <= fp_underxe | iqentry_res[head][2];
|
7996 |
|
|
fp_overxe <= fp_overxe | iqentry_res[head][1];
|
7997 |
|
|
fp_invopxe <= fp_invopxe | iqentry_res[head][0];
|
7998 |
|
|
end
|
7999 |
|
|
default:
|
8000 |
|
|
begin
|
8001 |
|
|
// 31 to 29 is rounding mode
|
8002 |
|
|
// 28 to 24 are exception enables
|
8003 |
|
|
// 23 is nsfp
|
8004 |
|
|
// 22 is a fractie
|
8005 |
|
|
fp_fractie <= iqentry_a0[head][22];
|
8006 |
|
|
fp_raz <= iqentry_a0[head][21];
|
8007 |
|
|
// 20 is a 0
|
8008 |
|
|
fp_neg <= iqentry_a0[head][19];
|
8009 |
|
|
fp_pos <= iqentry_a0[head][18];
|
8010 |
|
|
fp_zero <= iqentry_a0[head][17];
|
8011 |
|
|
fp_inf <= iqentry_a0[head][16];
|
8012 |
|
|
// 15 swtx
|
8013 |
|
|
// 14
|
8014 |
|
|
fp_inex <= fp_inex | (fp_inexe & iqentry_a0[head][14]);
|
8015 |
|
|
fp_dbzx <= fp_dbzx | (fp_dbzxe & iqentry_a0[head][13]);
|
8016 |
|
|
fp_underx <= fp_underx | (fp_underxe & iqentry_a0[head][12]);
|
8017 |
|
|
fp_overx <= fp_overx | (fp_overxe & iqentry_a0[head][11]);
|
8018 |
|
|
//fp_giopx <= fp_giopx | (fp_giopxe & iqentry_res2[head][10]);
|
8019 |
|
|
//fp_invopx <= fp_invopx | (fp_invopxe & iqentry_res2[head][24]);
|
8020 |
|
|
//
|
8021 |
|
|
fp_cvtx <= fp_cvtx | (fp_giopxe & iqentry_a0[head][7]);
|
8022 |
|
|
fp_sqrtx <= fp_sqrtx | (fp_giopxe & iqentry_a0[head][6]);
|
8023 |
|
|
fp_NaNCmpx <= fp_NaNCmpx | (fp_giopxe & iqentry_a0[head][5]);
|
8024 |
|
|
fp_infzerox <= fp_infzerox | (fp_giopxe & iqentry_a0[head][4]);
|
8025 |
|
|
fp_zerozerox <= fp_zerozerox | (fp_giopxe & iqentry_a0[head][3]);
|
8026 |
|
|
fp_infdivx <= fp_infdivx | (fp_giopxe & iqentry_a0[head][2]);
|
8027 |
|
|
fp_subinfx <= fp_subinfx | (fp_giopxe & iqentry_a0[head][1]);
|
8028 |
|
|
fp_snanx <= fp_snanx | (fp_giopxe & iqentry_a0[head][0]);
|
8029 |
|
|
|
8030 |
|
|
end
|
8031 |
|
|
endcase
|
8032 |
|
|
default: ;
|
8033 |
|
|
endcase
|
8034 |
|
|
// Once the flow control instruction commits, NOP it out to allow
|
8035 |
|
|
// pending stores to be issued.
|
8036 |
|
|
iqentry_instr[head][5:0] <= `NOP;
|
8037 |
|
|
end
|
8038 |
|
|
end
|
8039 |
|
|
endtask
|
8040 |
|
|
|
8041 |
|
|
// CSR access tasks
|
8042 |
|
|
task read_csr;
|
8043 |
|
|
input [13:0] csrno;
|
8044 |
|
|
output [63:0] dat;
|
8045 |
|
|
input thread;
|
8046 |
|
|
begin
|
8047 |
|
|
if (csrno[13:11] >= ol[thread])
|
8048 |
|
|
casez(csrno[10:0])
|
8049 |
|
|
`CSR_CR0: dat <= cr0;
|
8050 |
|
|
`CSR_HARTID: dat <= hartid;
|
8051 |
|
|
`CSR_TICK: dat <= tick;
|
8052 |
|
|
`CSR_PCR: dat <= pcr;
|
8053 |
|
|
`CSR_PCR2: dat <= pcr2;
|
8054 |
|
|
`CSR_SEMA: dat <= sema;
|
8055 |
|
|
`CSR_SBL: dat <= sbl;
|
8056 |
|
|
`CSR_SBU: dat <= sbu;
|
8057 |
|
|
`CSR_FSTAT: dat <= fp_status;
|
8058 |
|
|
`ifdef SUPPORT_DBG
|
8059 |
|
|
`CSR_DBAD0: dat <= dbg_adr0;
|
8060 |
|
|
`CSR_DBAD1: dat <= dbg_adr1;
|
8061 |
|
|
`CSR_DBAD2: dat <= dbg_adr2;
|
8062 |
|
|
`CSR_DBAD3: dat <= dbg_adr3;
|
8063 |
|
|
`CSR_DBCTRL: dat <= dbg_ctrl;
|
8064 |
|
|
`CSR_DBSTAT: dat <= dbg_stat;
|
8065 |
|
|
`endif
|
8066 |
|
|
`CSR_CAS: dat <= cas;
|
8067 |
|
|
`CSR_TVEC: dat <= tvec[csrno[2:0]];
|
8068 |
|
|
`CSR_BADADR: dat <= badaddr[{thread,csrno[13:11]}];
|
8069 |
|
|
`CSR_CAUSE: dat <= {48'd0,cause[{thread,csrno[13:11]}]};
|
8070 |
|
|
`CSR_IM_STACK: dat <= im_stack[thread];
|
8071 |
|
|
`CSR_OL_STACK: dat <= ol_stack[thread];
|
8072 |
|
|
`CSR_PL_STACK: dat <= pl_stack[thread];
|
8073 |
|
|
`CSR_RS_STACK: dat <= rs_stack[thread];
|
8074 |
|
|
`CSR_STATUS: dat <= mstatus[thread][63:0];
|
8075 |
|
|
`CSR_EPC0: dat <= epc0[thread];
|
8076 |
|
|
`CSR_EPC1: dat <= epc1[thread];
|
8077 |
|
|
`CSR_EPC2: dat <= epc2[thread];
|
8078 |
|
|
`CSR_EPC3: dat <= epc3[thread];
|
8079 |
|
|
`CSR_EPC4: dat <= epc4[thread];
|
8080 |
|
|
`CSR_EPC5: dat <= epc5[thread];
|
8081 |
|
|
`CSR_EPC6: dat <= epc6[thread];
|
8082 |
|
|
`CSR_EPC7: dat <= epc7[thread];
|
8083 |
|
|
`CSR_CODEBUF: dat <= codebuf[csrno[5:0]];
|
8084 |
|
|
`CSR_INFO:
|
8085 |
|
|
case(csrno[3:0])
|
8086 |
|
|
4'd0: dat <= "Finitron"; // manufacturer
|
8087 |
|
|
4'd1: dat <= " ";
|
8088 |
|
|
4'd2: dat <= "64 bit "; // CPU class
|
8089 |
|
|
4'd3: dat <= " ";
|
8090 |
|
|
4'd4: dat <= "FT64 "; // Name
|
8091 |
|
|
4'd5: dat <= " ";
|
8092 |
|
|
4'd6: dat <= 64'd1; // model #
|
8093 |
|
|
4'd7: dat <= 64'd1; // serial number
|
8094 |
|
|
4'd8: dat <= {32'd16384,32'd16384}; // cache sizes instruction,data
|
8095 |
|
|
4'd9: dat <= 64'd0;
|
8096 |
|
|
default: dat <= 64'd0;
|
8097 |
|
|
endcase
|
8098 |
|
|
default: begin
|
8099 |
|
|
$display("Unsupported CSR:%h",csrno[10:0]);
|
8100 |
|
|
dat <= 64'hEEEEEEEEEEEEEEEE;
|
8101 |
|
|
end
|
8102 |
|
|
endcase
|
8103 |
|
|
else
|
8104 |
|
|
dat <= 64'h0;
|
8105 |
|
|
end
|
8106 |
|
|
endtask
|
8107 |
|
|
|
8108 |
|
|
task write_csr;
|
8109 |
|
|
input [15:0] csrno;
|
8110 |
|
|
input [63:0] dat;
|
8111 |
|
|
input thread;
|
8112 |
|
|
begin
|
8113 |
|
|
if (csrno[13:11] >= ol[thread])
|
8114 |
|
|
case(csrno[15:14])
|
8115 |
|
|
2'd1: // CSRRW
|
8116 |
|
|
casez(csrno[10:0])
|
8117 |
|
|
`CSR_CR0: cr0 <= dat;
|
8118 |
|
|
`CSR_PCR: pcr <= dat[31:0];
|
8119 |
|
|
`CSR_PCR2: pcr2 <= dat;
|
8120 |
|
|
`CSR_SEMA: sema <= dat;
|
8121 |
|
|
`CSR_SBL: sbl <= dat[31:0];
|
8122 |
|
|
`CSR_SBU: sbu <= dat[31:0];
|
8123 |
|
|
`CSR_BADADR: badaddr[{thread,csrno[13:11]}] <= dat;
|
8124 |
|
|
`CSR_CAUSE: cause[{thread,csrno[13:11]}] <= dat[15:0];
|
8125 |
|
|
`ifdef SUPPORT_DBG
|
8126 |
|
|
`CSR_DBAD0: dbg_adr0 <= dat[AMSB:0];
|
8127 |
|
|
`CSR_DBAD1: dbg_adr1 <= dat[AMSB:0];
|
8128 |
|
|
`CSR_DBAD2: dbg_adr2 <= dat[AMSB:0];
|
8129 |
|
|
`CSR_DBAD3: dbg_adr3 <= dat[AMSB:0];
|
8130 |
|
|
`CSR_DBCTRL: dbg_ctrl <= dat;
|
8131 |
|
|
`endif
|
8132 |
|
|
`CSR_CAS: cas <= dat;
|
8133 |
|
|
`CSR_TVEC: tvec[csrno[2:0]] <= dat[31:0];
|
8134 |
|
|
`CSR_IM_STACK: im_stack[thread] <= dat[23:0];
|
8135 |
|
|
`CSR_OL_STACK: ol_stack[thread] <= dat[23:0];
|
8136 |
|
|
`CSR_PL_STACK: pl_stack[thread] <= dat;
|
8137 |
|
|
`CSR_RS_STACK: rs_stack[thread] <= dat;
|
8138 |
|
|
`CSR_STATUS: mstatus[thread][63:0] <= dat;
|
8139 |
|
|
`CSR_EPC0: epc0[thread] <= dat;
|
8140 |
|
|
`CSR_EPC1: epc1[thread] <= dat;
|
8141 |
|
|
`CSR_EPC2: epc2[thread] <= dat;
|
8142 |
|
|
`CSR_EPC3: epc3[thread] <= dat;
|
8143 |
|
|
`CSR_EPC4: epc4[thread] <= dat;
|
8144 |
|
|
`CSR_EPC5: epc5[thread] <= dat;
|
8145 |
|
|
`CSR_EPC6: epc6[thread] <= dat;
|
8146 |
|
|
`CSR_EPC7: epc7[thread] <= dat;
|
8147 |
|
|
`CSR_CODEBUF: codebuf[csrno[5:0]] <= dat;
|
8148 |
|
|
default: ;
|
8149 |
|
|
endcase
|
8150 |
|
|
2'd2: // CSRRS
|
8151 |
|
|
case(csrno[10:0])
|
8152 |
|
|
`CSR_CR0: cr0 <= cr0 | dat;
|
8153 |
|
|
`CSR_PCR: pcr[31:0] <= pcr[31:0] | dat[31:0];
|
8154 |
|
|
`CSR_PCR2: pcr2 <= pcr2 | dat;
|
8155 |
|
|
`ifdef SUPPORT_DBG
|
8156 |
|
|
`CSR_DBCTRL: dbg_ctrl <= dbg_ctrl | dat;
|
8157 |
|
|
`endif
|
8158 |
|
|
`CSR_SEMA: sema <= sema | dat;
|
8159 |
|
|
`CSR_STATUS: mstatus[thread][63:0] <= mstatus[thread][63:0] | dat;
|
8160 |
|
|
default: ;
|
8161 |
|
|
endcase
|
8162 |
|
|
2'd3: // CSRRC
|
8163 |
|
|
case(csrno[10:0])
|
8164 |
|
|
`CSR_CR0: cr0 <= cr0 & ~dat;
|
8165 |
|
|
`CSR_PCR: pcr <= pcr & ~dat;
|
8166 |
|
|
`CSR_PCR2: pcr2 <= pcr2 & ~dat;
|
8167 |
|
|
`ifdef SUPPORT_DBG
|
8168 |
|
|
`CSR_DBCTRL: dbg_ctrl <= dbg_ctrl & ~dat;
|
8169 |
|
|
`endif
|
8170 |
|
|
`CSR_SEMA: sema <= sema & ~dat;
|
8171 |
|
|
`CSR_STATUS: mstatus[thread][63:0] <= mstatus[thread][63:0] & ~dat;
|
8172 |
|
|
default: ;
|
8173 |
|
|
endcase
|
8174 |
|
|
default: ;
|
8175 |
|
|
endcase
|
8176 |
|
|
end
|
8177 |
|
|
endtask
|
8178 |
|
|
|
8179 |
|
|
/*
|
8180 |
|
|
function [63:0] assign_a0;
|
8181 |
|
|
input [31:0] fb_instr;
|
8182 |
|
|
begin
|
8183 |
|
|
if (IsShifti(fb_instr)||IsVShifti(fb_instr)||IsSEI(fb_instr)||IsRTI(fb_instr))
|
8184 |
|
|
assign_a0 = {58'd0,fb_instr[21:16]};
|
8185 |
|
|
// else if (IsBranch(fb_instr))
|
8186 |
|
|
// assign_a0 = {{51{fb_instr[`INSTRUCTION_SB]}},fb_instr[31:22],fb_instr[0],2'b00};
|
8187 |
|
|
// else if (fb_instr[`INSTRUCTION_OP] == `CALL || fb_instr[`INSTRUCTION_OP] == `JMP)
|
8188 |
|
|
// assign_a0 = {{36{fb_instr[31]}},fb_instr[31:6],2'd0};
|
8189 |
|
|
else
|
8190 |
|
|
assign_a0 = {{48{fb_instr[`INSTRUCTION_SB]}},fb_instr[31:16]};
|
8191 |
|
|
end
|
8192 |
|
|
endfunction
|
8193 |
|
|
*/
|
8194 |
|
|
/*
|
8195 |
|
|
task aluissue;
|
8196 |
|
|
input alu_idle;
|
8197 |
|
|
input [QENTRIES-1:0] iq_alu0;
|
8198 |
|
|
input [1:0] slot;
|
8199 |
|
|
begin
|
8200 |
|
|
if (alu_idle) begin
|
8201 |
|
|
if (could_issue[head0] && iqentry_alu[head0]
|
8202 |
|
|
&& !iq_alu0[head0] // alu0only
|
8203 |
|
|
&& !iqentry_issue[head0]) begin
|
8204 |
|
|
iqentry_issue[head0] = `TRUE;
|
8205 |
|
|
iqentry_islot[head0] = slot;
|
8206 |
|
|
end
|
8207 |
|
|
else if (could_issue[head1] && !iqentry_issue[head1] && iqentry_alu[head1]
|
8208 |
|
|
&& !iq_alu0[head1])
|
8209 |
|
|
begin
|
8210 |
|
|
iqentry_issue[head1] = `TRUE;
|
8211 |
|
|
iqentry_islot[head1] = slot;
|
8212 |
|
|
end
|
8213 |
|
|
else if (could_issue[head2] && !iqentry_issue[head2] && iqentry_alu[head2]
|
8214 |
|
|
&& !iq_alu0[head2]
|
8215 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
8216 |
|
|
)
|
8217 |
|
|
begin
|
8218 |
|
|
iqentry_issue[head2] = `TRUE;
|
8219 |
|
|
iqentry_islot[head2] = slot;
|
8220 |
|
|
end
|
8221 |
|
|
else if (could_issue[head3] && !iqentry_issue[head3] && iqentry_alu[head3]
|
8222 |
|
|
&& !iq_alu0[head3]
|
8223 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
8224 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
8225 |
|
|
((!iqentry_v[head0])
|
8226 |
|
|
&& (!iqentry_v[head1]))
|
8227 |
|
|
)
|
8228 |
|
|
) begin
|
8229 |
|
|
iqentry_issue[head3] = `TRUE;
|
8230 |
|
|
iqentry_islot[head3] = slot;
|
8231 |
|
|
end
|
8232 |
|
|
else if (could_issue[head4] && !iqentry_issue[head4] && iqentry_alu[head4]
|
8233 |
|
|
&& !iq_alu0[head4]
|
8234 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
8235 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
8236 |
|
|
((!iqentry_v[head0])
|
8237 |
|
|
&& (!iqentry_v[head1]))
|
8238 |
|
|
)
|
8239 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
8240 |
|
|
((!iqentry_v[head0])
|
8241 |
|
|
&& (!iqentry_v[head1])
|
8242 |
|
|
&& (!iqentry_v[head2]))
|
8243 |
|
|
)
|
8244 |
|
|
) begin
|
8245 |
|
|
iqentry_issue[head4] = `TRUE;
|
8246 |
|
|
iqentry_islot[head4] = slot;
|
8247 |
|
|
end
|
8248 |
|
|
else if (could_issue[head5] && !iqentry_issue[head5] && iqentry_alu[head5]
|
8249 |
|
|
&& !iq_alu0[head5]
|
8250 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
8251 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
8252 |
|
|
((!iqentry_v[head0])
|
8253 |
|
|
&& (!iqentry_v[head1]))
|
8254 |
|
|
)
|
8255 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
8256 |
|
|
((!iqentry_v[head0])
|
8257 |
|
|
&& (!iqentry_v[head1])
|
8258 |
|
|
&& (!iqentry_v[head2]))
|
8259 |
|
|
)
|
8260 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
8261 |
|
|
((!iqentry_v[head0])
|
8262 |
|
|
&& (!iqentry_v[head1])
|
8263 |
|
|
&& (!iqentry_v[head2])
|
8264 |
|
|
&& (!iqentry_v[head3]))
|
8265 |
|
|
)
|
8266 |
|
|
) begin
|
8267 |
|
|
iqentry_issue[head5] = `TRUE;
|
8268 |
|
|
iqentry_islot[head5] = slot;
|
8269 |
|
|
end
|
8270 |
|
|
else if (could_issue[head6] && !iqentry_issue[head6] && iqentry_alu[head6]
|
8271 |
|
|
&& !iq_alu0[head6]
|
8272 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
8273 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
8274 |
|
|
((!iqentry_v[head0])
|
8275 |
|
|
&& (!iqentry_v[head1]))
|
8276 |
|
|
)
|
8277 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
8278 |
|
|
((!iqentry_v[head0])
|
8279 |
|
|
&& (!iqentry_v[head1])
|
8280 |
|
|
&& (!iqentry_v[head2]))
|
8281 |
|
|
)
|
8282 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
8283 |
|
|
((!iqentry_v[head0])
|
8284 |
|
|
&& (!iqentry_v[head1])
|
8285 |
|
|
&& (!iqentry_v[head2])
|
8286 |
|
|
&& (!iqentry_v[head3]))
|
8287 |
|
|
)
|
8288 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
8289 |
|
|
((!iqentry_v[head0])
|
8290 |
|
|
&& (!iqentry_v[head1])
|
8291 |
|
|
&& (!iqentry_v[head2])
|
8292 |
|
|
&& (!iqentry_v[head3])
|
8293 |
|
|
&& (!iqentry_v[head4]))
|
8294 |
|
|
)
|
8295 |
|
|
) begin
|
8296 |
|
|
iqentry_issue[head6] = `TRUE;
|
8297 |
|
|
iqentry_islot[head6] = slot;
|
8298 |
|
|
end
|
8299 |
|
|
else if (could_issue[head7] && !iqentry_issue[head7] && iqentry_alu[head7]
|
8300 |
|
|
&& !iq_alu0[head7]
|
8301 |
|
|
&& (!(iqentry_v[head1] && iqentry_sync[head1]) || !iqentry_v[head0])
|
8302 |
|
|
&& (!(iqentry_v[head2] && iqentry_sync[head2]) ||
|
8303 |
|
|
((!iqentry_v[head0])
|
8304 |
|
|
&& (!iqentry_v[head1]))
|
8305 |
|
|
)
|
8306 |
|
|
&& (!(iqentry_v[head3] && iqentry_sync[head3]) ||
|
8307 |
|
|
((!iqentry_v[head0])
|
8308 |
|
|
&& (!iqentry_v[head1])
|
8309 |
|
|
&& (!iqentry_v[head2]))
|
8310 |
|
|
)
|
8311 |
|
|
&& (!(iqentry_v[head4] && iqentry_sync[head4]) ||
|
8312 |
|
|
((!iqentry_v[head0])
|
8313 |
|
|
&& (!iqentry_v[head1])
|
8314 |
|
|
&& (!iqentry_v[head2])
|
8315 |
|
|
&& (!iqentry_v[head3]))
|
8316 |
|
|
)
|
8317 |
|
|
&& (!(iqentry_v[head5] && iqentry_sync[head5]) ||
|
8318 |
|
|
((!iqentry_v[head0])
|
8319 |
|
|
&& (!iqentry_v[head1])
|
8320 |
|
|
&& (!iqentry_v[head2])
|
8321 |
|
|
&& (!iqentry_v[head3])
|
8322 |
|
|
&& (!iqentry_v[head4]))
|
8323 |
|
|
)
|
8324 |
|
|
&& (!(iqentry_v[head6] && iqentry_sync[head6]) ||
|
8325 |
|
|
((!iqentry_v[head0])
|
8326 |
|
|
&& (!iqentry_v[head1])
|
8327 |
|
|
&& (!iqentry_v[head2])
|
8328 |
|
|
&& (!iqentry_v[head3])
|
8329 |
|
|
&& (!iqentry_v[head4])
|
8330 |
|
|
&& (!iqentry_v[head5]))
|
8331 |
|
|
)
|
8332 |
|
|
) begin
|
8333 |
|
|
iqentry_issue[head7] = `TRUE;
|
8334 |
|
|
iqentry_islot[head7] = slot;
|
8335 |
|
|
end
|
8336 |
|
|
end
|
8337 |
|
|
end
|
8338 |
|
|
endtask
|
8339 |
|
|
|
8340 |
|
|
task fpuissue;
|
8341 |
|
|
input fp_idle;
|
8342 |
|
|
input [1:0] slot;
|
8343 |
|
|
begin
|
8344 |
|
|
if (fp_idle) begin
|
8345 |
|
|
if (could_issue[head0] && iqentry_fpu[head0]) begin
|
8346 |
|
|
iqentry_fpu_issue[head0] = `TRUE;
|
8347 |
|
|
iqentry_fpu_islot[head0] = slot;
|
8348 |
|
|
end
|
8349 |
|
|
else if (could_issue[head1] && iqentry_fpu[head1])
|
8350 |
|
|
begin
|
8351 |
|
|
iqentry_fpu_issue[head1] = `TRUE;
|
8352 |
|
|
iqentry_fpu_islot[head1] = slot;
|
8353 |
|
|
end
|
8354 |
|
|
else if (could_issue[head2] && iqentry_fpu[head2]
|
8355 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
8356 |
|
|
) begin
|
8357 |
|
|
iqentry_fpu_issue[head2] = `TRUE;
|
8358 |
|
|
iqentry_fpu_islot[head2] = slot;
|
8359 |
|
|
end
|
8360 |
|
|
else if (could_issue[head3] && iqentry_fpu[head3]
|
8361 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
8362 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
8363 |
|
|
((!iqentry_v[head0])
|
8364 |
|
|
&& (!iqentry_v[head1]))
|
8365 |
|
|
)
|
8366 |
|
|
) begin
|
8367 |
|
|
iqentry_fpu_issue[head3] = `TRUE;
|
8368 |
|
|
iqentry_fpu_islot[head3] = slot;
|
8369 |
|
|
end
|
8370 |
|
|
else if (could_issue[head4] && iqentry_fpu[head4]
|
8371 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
8372 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
8373 |
|
|
((!iqentry_v[head0])
|
8374 |
|
|
&& (!iqentry_v[head1]))
|
8375 |
|
|
)
|
8376 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
8377 |
|
|
((!iqentry_v[head0])
|
8378 |
|
|
&& (!iqentry_v[head1])
|
8379 |
|
|
&& (!iqentry_v[head2]))
|
8380 |
|
|
)
|
8381 |
|
|
) begin
|
8382 |
|
|
iqentry_fpu_issue[head4] = `TRUE;
|
8383 |
|
|
iqentry_fpu_islot[head4] = slot;
|
8384 |
|
|
end
|
8385 |
|
|
else if (could_issue[head5] && iqentry_fpu[head5]
|
8386 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
8387 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
8388 |
|
|
((!iqentry_v[head0])
|
8389 |
|
|
&& (!iqentry_v[head1]))
|
8390 |
|
|
)
|
8391 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
8392 |
|
|
((!iqentry_v[head0])
|
8393 |
|
|
&& (!iqentry_v[head1])
|
8394 |
|
|
&& (!iqentry_v[head2]))
|
8395 |
|
|
)
|
8396 |
|
|
&& (!(iqentry_v[head4] && (iqentry_sync[head4] || iqentry_fsync[head4])) ||
|
8397 |
|
|
((!iqentry_v[head0])
|
8398 |
|
|
&& (!iqentry_v[head1])
|
8399 |
|
|
&& (!iqentry_v[head2])
|
8400 |
|
|
&& (!iqentry_v[head3]))
|
8401 |
|
|
)
|
8402 |
|
|
) begin
|
8403 |
|
|
iqentry_fpu_issue[head5] = `TRUE;
|
8404 |
|
|
iqentry_fpu_islot[head5] = slot;
|
8405 |
|
|
end
|
8406 |
|
|
else if (could_issue[head6] && iqentry_fpu[head6]
|
8407 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
8408 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
8409 |
|
|
((!iqentry_v[head0])
|
8410 |
|
|
&& (!iqentry_v[head1]))
|
8411 |
|
|
)
|
8412 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
8413 |
|
|
((!iqentry_v[head0])
|
8414 |
|
|
&& (!iqentry_v[head1])
|
8415 |
|
|
&& (!iqentry_v[head2]))
|
8416 |
|
|
)
|
8417 |
|
|
&& (!(iqentry_v[head4] && (iqentry_sync[head4] || iqentry_fsync[head4])) ||
|
8418 |
|
|
((!iqentry_v[head0])
|
8419 |
|
|
&& (!iqentry_v[head1])
|
8420 |
|
|
&& (!iqentry_v[head2])
|
8421 |
|
|
&& (!iqentry_v[head3]))
|
8422 |
|
|
)
|
8423 |
|
|
&& (!(iqentry_v[head5] && (iqentry_sync[head5] || iqentry_fsync[head5])) ||
|
8424 |
|
|
((!iqentry_v[head0])
|
8425 |
|
|
&& (!iqentry_v[head1])
|
8426 |
|
|
&& (!iqentry_v[head2])
|
8427 |
|
|
&& (!iqentry_v[head3])
|
8428 |
|
|
&& (!iqentry_v[head4]))
|
8429 |
|
|
)
|
8430 |
|
|
) begin
|
8431 |
|
|
iqentry_fpu_issue[head6] = `TRUE;
|
8432 |
|
|
iqentry_fpu_islot[head6] = slot;
|
8433 |
|
|
end
|
8434 |
|
|
else if (could_issue[head7] && iqentry_fpu[head7]
|
8435 |
|
|
&& (!(iqentry_v[head1] && (iqentry_sync[head1] || iqentry_fsync[head1])) || !iqentry_v[head0])
|
8436 |
|
|
&& (!(iqentry_v[head2] && (iqentry_sync[head2] || iqentry_fsync[head2])) ||
|
8437 |
|
|
((!iqentry_v[head0])
|
8438 |
|
|
&& (!iqentry_v[head1]))
|
8439 |
|
|
)
|
8440 |
|
|
&& (!(iqentry_v[head3] && (iqentry_sync[head3] || iqentry_fsync[head3])) ||
|
8441 |
|
|
((!iqentry_v[head0])
|
8442 |
|
|
&& (!iqentry_v[head1])
|
8443 |
|
|
&& (!iqentry_v[head2]))
|
8444 |
|
|
)
|
8445 |
|
|
&& (!(iqentry_v[head4] && (iqentry_sync[head4] || iqentry_fsync[head4])) ||
|
8446 |
|
|
((!iqentry_v[head0])
|
8447 |
|
|
&& (!iqentry_v[head1])
|
8448 |
|
|
&& (!iqentry_v[head2])
|
8449 |
|
|
&& (!iqentry_v[head3]))
|
8450 |
|
|
)
|
8451 |
|
|
&& (!(iqentry_v[head5] && (iqentry_sync[head5] || iqentry_fsync[head5])) ||
|
8452 |
|
|
((!iqentry_v[head0])
|
8453 |
|
|
&& (!iqentry_v[head1])
|
8454 |
|
|
&& (!iqentry_v[head2])
|
8455 |
|
|
&& (!iqentry_v[head3])
|
8456 |
|
|
&& (!iqentry_v[head4]))
|
8457 |
|
|
)
|
8458 |
|
|
&& (!(iqentry_v[head6] && (iqentry_sync[head6] || iqentry_fsync[head6])) ||
|
8459 |
|
|
((!iqentry_v[head0])
|
8460 |
|
|
&& (!iqentry_v[head1])
|
8461 |
|
|
&& (!iqentry_v[head2])
|
8462 |
|
|
&& (!iqentry_v[head3])
|
8463 |
|
|
&& (!iqentry_v[head4])
|
8464 |
|
|
&& (!iqentry_v[head5]))
|
8465 |
|
|
)
|
8466 |
|
|
)
|
8467 |
|
|
begin
|
8468 |
|
|
iqentry_fpu_issue[head7] = `TRUE;
|
8469 |
|
|
iqentry_fpu_islot[head7] = slot;
|
8470 |
|
|
end
|
8471 |
|
|
end
|
8472 |
|
|
end
|
8473 |
|
|
endtask
|
8474 |
|
|
*/
|
8475 |
|
|
endmodule
|
8476 |
|
|
|
8477 |
|
|
|
8478 |
|
|
module decoder5 (num, out);
|
8479 |
|
|
input [4:0] num;
|
8480 |
|
|
output [31:1] out;
|
8481 |
|
|
reg [31:1] out;
|
8482 |
|
|
|
8483 |
|
|
always @(num)
|
8484 |
|
|
case (num)
|
8485 |
|
|
5'd0 : out <= 31'b0000000000000000000000000000000;
|
8486 |
|
|
5'd1 : out <= 31'b0000000000000000000000000000001;
|
8487 |
|
|
5'd2 : out <= 31'b0000000000000000000000000000010;
|
8488 |
|
|
5'd3 : out <= 31'b0000000000000000000000000000100;
|
8489 |
|
|
5'd4 : out <= 31'b0000000000000000000000000001000;
|
8490 |
|
|
5'd5 : out <= 31'b0000000000000000000000000010000;
|
8491 |
|
|
5'd6 : out <= 31'b0000000000000000000000000100000;
|
8492 |
|
|
5'd7 : out <= 31'b0000000000000000000000001000000;
|
8493 |
|
|
5'd8 : out <= 31'b0000000000000000000000010000000;
|
8494 |
|
|
5'd9 : out <= 31'b0000000000000000000000100000000;
|
8495 |
|
|
5'd10: out <= 31'b0000000000000000000001000000000;
|
8496 |
|
|
5'd11: out <= 31'b0000000000000000000010000000000;
|
8497 |
|
|
5'd12: out <= 31'b0000000000000000000100000000000;
|
8498 |
|
|
5'd13: out <= 31'b0000000000000000001000000000000;
|
8499 |
|
|
5'd14: out <= 31'b0000000000000000010000000000000;
|
8500 |
|
|
5'd15: out <= 31'b0000000000000000100000000000000;
|
8501 |
|
|
5'd16: out <= 31'b0000000000000001000000000000000;
|
8502 |
|
|
5'd17: out <= 31'b0000000000000010000000000000000;
|
8503 |
|
|
5'd18: out <= 31'b0000000000000100000000000000000;
|
8504 |
|
|
5'd19: out <= 31'b0000000000001000000000000000000;
|
8505 |
|
|
5'd20: out <= 31'b0000000000010000000000000000000;
|
8506 |
|
|
5'd21: out <= 31'b0000000000100000000000000000000;
|
8507 |
|
|
5'd22: out <= 31'b0000000001000000000000000000000;
|
8508 |
|
|
5'd23: out <= 31'b0000000010000000000000000000000;
|
8509 |
|
|
5'd24: out <= 31'b0000000100000000000000000000000;
|
8510 |
|
|
5'd25: out <= 31'b0000001000000000000000000000000;
|
8511 |
|
|
5'd26: out <= 31'b0000010000000000000000000000000;
|
8512 |
|
|
5'd27: out <= 31'b0000100000000000000000000000000;
|
8513 |
|
|
5'd28: out <= 31'b0001000000000000000000000000000;
|
8514 |
|
|
5'd29: out <= 31'b0010000000000000000000000000000;
|
8515 |
|
|
5'd30: out <= 31'b0100000000000000000000000000000;
|
8516 |
|
|
5'd31: out <= 31'b1000000000000000000000000000000;
|
8517 |
|
|
endcase
|
8518 |
|
|
|
8519 |
|
|
endmodule
|
8520 |
|
|
|
8521 |
|
|
module decoder6 (num, out);
|
8522 |
|
|
input [5:0] num;
|
8523 |
|
|
output [63:1] out;
|
8524 |
|
|
|
8525 |
|
|
wire [63:0] out1;
|
8526 |
|
|
|
8527 |
|
|
assign out1 = 64'd1 << num;
|
8528 |
|
|
assign out = out1[63:1];
|
8529 |
|
|
|
8530 |
|
|
endmodule
|
8531 |
|
|
|
8532 |
|
|
module decoder7 (num, out);
|
8533 |
|
|
input [6:0] num;
|
8534 |
|
|
output [127:1] out;
|
8535 |
|
|
|
8536 |
|
|
wire [127:0] out1;
|
8537 |
|
|
|
8538 |
|
|
assign out1 = 128'd1 << num;
|
8539 |
|
|
assign out = out1[127:1];
|
8540 |
|
|
|
8541 |
|
|
endmodule
|
8542 |
|
|
|
8543 |
|
|
module decoder8 (num, out);
|
8544 |
|
|
input [7:0] num;
|
8545 |
|
|
output [255:1] out;
|
8546 |
|
|
|
8547 |
|
|
wire [255:0] out1;
|
8548 |
|
|
|
8549 |
|
|
assign out1 = 256'd1 << num;
|
8550 |
|
|
assign out = out1[255:1];
|
8551 |
|
|
|
8552 |
|
|
endmodule
|
8553 |
|
|
|