1 |
48 |
alirezamon |
/* ****************************************************************************
|
2 |
|
|
This Source Code Form is subject to the terms of the
|
3 |
|
|
Open Hardware Description License, v. 1.0. If a copy
|
4 |
|
|
of the OHDL was not distributed with this file, You
|
5 |
|
|
can obtain one at http://juliusbaxter.net/ohdl/ohdl.txt
|
6 |
|
|
|
7 |
|
|
Description: mor1kx decode unit
|
8 |
|
|
|
9 |
|
|
Completely combinatorial.
|
10 |
|
|
|
11 |
|
|
Outputs:
|
12 |
|
|
- ALU operation
|
13 |
|
|
- indication of other type of op - LSU/SPR
|
14 |
|
|
- immediates
|
15 |
|
|
- register file addresses
|
16 |
|
|
- exception decodes: illegal, system call
|
17 |
|
|
|
18 |
|
|
Copyright (C) 2012 Julius Baxter <juliusbaxter@gmail.com>
|
19 |
|
|
Copyright (C) 2013 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
|
20 |
|
|
|
21 |
|
|
***************************************************************************** */
|
22 |
|
|
|
23 |
|
|
`include "mor1kx-defines.v"
|
24 |
|
|
|
25 |
|
|
module mor1kx_decode
|
26 |
|
|
#(
|
27 |
|
|
parameter OPTION_OPERAND_WIDTH = 32,
|
28 |
|
|
parameter OPTION_RESET_PC = {{(OPTION_OPERAND_WIDTH-13){1'b0}},
|
29 |
|
|
`OR1K_RESET_VECTOR,8'd0},
|
30 |
|
|
parameter OPTION_RF_ADDR_WIDTH = 5,
|
31 |
|
|
|
32 |
|
|
parameter FEATURE_SYSCALL = "ENABLED",
|
33 |
|
|
parameter FEATURE_TRAP = "ENABLED",
|
34 |
|
|
parameter FEATURE_RANGE = "ENABLED",
|
35 |
|
|
parameter FEATURE_MAC = "NONE",
|
36 |
|
|
parameter FEATURE_MULTIPLIER = "PARALLEL",
|
37 |
|
|
parameter FEATURE_DIVIDER = "NONE",
|
38 |
|
|
|
39 |
|
|
parameter FEATURE_ADDC = "NONE",
|
40 |
|
|
parameter FEATURE_SRA = "ENABLED",
|
41 |
|
|
parameter FEATURE_ROR = "NONE",
|
42 |
|
|
parameter FEATURE_EXT = "NONE",
|
43 |
|
|
parameter FEATURE_CMOV = "NONE",
|
44 |
|
|
parameter FEATURE_FFL1 = "NONE",
|
45 |
|
|
parameter FEATURE_ATOMIC = "ENABLED",
|
46 |
|
|
parameter FEATURE_MSYNC = "ENABLED",
|
47 |
|
|
parameter FEATURE_PSYNC = "NONE",
|
48 |
|
|
parameter FEATURE_CSYNC = "NONE",
|
49 |
|
|
|
50 |
|
|
parameter FEATURE_FPU = "NONE", // ENABLED|NONE
|
51 |
|
|
|
52 |
|
|
parameter FEATURE_CUST1 = "NONE",
|
53 |
|
|
parameter FEATURE_CUST2 = "NONE",
|
54 |
|
|
parameter FEATURE_CUST3 = "NONE",
|
55 |
|
|
parameter FEATURE_CUST4 = "NONE",
|
56 |
|
|
parameter FEATURE_CUST5 = "NONE",
|
57 |
|
|
parameter FEATURE_CUST6 = "NONE",
|
58 |
|
|
parameter FEATURE_CUST7 = "NONE",
|
59 |
|
|
parameter FEATURE_CUST8 = "NONE"
|
60 |
|
|
)
|
61 |
|
|
(
|
62 |
|
|
input clk,
|
63 |
|
|
input rst,
|
64 |
|
|
|
65 |
|
|
// input from fetch stage
|
66 |
|
|
input [`OR1K_INSN_WIDTH-1:0] decode_insn_i,
|
67 |
|
|
|
68 |
|
|
// ALU opcodes
|
69 |
|
|
output [`OR1K_ALU_OPC_WIDTH-1:0] decode_opc_alu_o,
|
70 |
|
|
output [`OR1K_ALU_OPC_WIDTH-1:0] decode_opc_alu_secondary_o,
|
71 |
|
|
|
72 |
|
|
output [`OR1K_IMM_WIDTH-1:0] decode_imm16_o,
|
73 |
|
|
output [OPTION_OPERAND_WIDTH-1:0] decode_immediate_o,
|
74 |
|
|
output decode_immediate_sel_o,
|
75 |
|
|
|
76 |
|
|
// Upper 10 bits of immediate for jumps and branches
|
77 |
|
|
output [9:0] decode_immjbr_upper_o,
|
78 |
|
|
|
79 |
|
|
// GPR numbers
|
80 |
|
|
output [OPTION_RF_ADDR_WIDTH-1:0] decode_rfd_adr_o,
|
81 |
|
|
output [OPTION_RF_ADDR_WIDTH-1:0] decode_rfa_adr_o,
|
82 |
|
|
output [OPTION_RF_ADDR_WIDTH-1:0] decode_rfb_adr_o,
|
83 |
|
|
|
84 |
|
|
output decode_rf_wb_o,
|
85 |
|
|
|
86 |
|
|
output decode_op_jbr_o,
|
87 |
|
|
output decode_op_jr_o,
|
88 |
|
|
output decode_op_jal_o,
|
89 |
|
|
output decode_op_bf_o,
|
90 |
|
|
output decode_op_bnf_o,
|
91 |
|
|
output decode_op_brcond_o,
|
92 |
|
|
output decode_op_branch_o,
|
93 |
|
|
|
94 |
|
|
output decode_op_alu_o,
|
95 |
|
|
|
96 |
|
|
output decode_op_lsu_load_o,
|
97 |
|
|
output decode_op_lsu_store_o,
|
98 |
|
|
output decode_op_lsu_atomic_o,
|
99 |
|
|
output reg [1:0] decode_lsu_length_o,
|
100 |
|
|
output decode_lsu_zext_o,
|
101 |
|
|
|
102 |
|
|
output decode_op_mfspr_o,
|
103 |
|
|
output decode_op_mtspr_o,
|
104 |
|
|
|
105 |
|
|
output decode_op_rfe_o,
|
106 |
|
|
output decode_op_setflag_o,
|
107 |
|
|
output decode_op_add_o,
|
108 |
|
|
output decode_op_mul_o,
|
109 |
|
|
output decode_op_mul_signed_o,
|
110 |
|
|
output decode_op_mul_unsigned_o,
|
111 |
|
|
output decode_op_div_o,
|
112 |
|
|
output decode_op_div_signed_o,
|
113 |
|
|
output decode_op_div_unsigned_o,
|
114 |
|
|
output decode_op_shift_o,
|
115 |
|
|
output decode_op_ffl1_o,
|
116 |
|
|
output decode_op_movhi_o,
|
117 |
|
|
output decode_op_ext_o,
|
118 |
|
|
|
119 |
|
|
// Sync operations
|
120 |
|
|
output decode_op_msync_o,
|
121 |
|
|
output [`OR1K_FPUOP_WIDTH-1:0] decode_op_fpu_o,
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
// Adder control logic
|
125 |
|
|
output decode_adder_do_sub_o,
|
126 |
|
|
output decode_adder_do_carry_o,
|
127 |
|
|
|
128 |
|
|
// exception output -
|
129 |
|
|
output reg decode_except_illegal_o,
|
130 |
|
|
output decode_except_syscall_o,
|
131 |
|
|
output decode_except_trap_o,
|
132 |
|
|
|
133 |
|
|
output [`OR1K_OPCODE_WIDTH-1:0] decode_opc_insn_o
|
134 |
|
|
);
|
135 |
|
|
|
136 |
|
|
wire [`OR1K_OPCODE_WIDTH-1:0] opc_insn;
|
137 |
|
|
wire [`OR1K_ALU_OPC_WIDTH-1:0] opc_alu;
|
138 |
|
|
|
139 |
|
|
wire [OPTION_OPERAND_WIDTH-1:0] imm_sext;
|
140 |
|
|
wire imm_sext_sel;
|
141 |
|
|
wire [OPTION_OPERAND_WIDTH-1:0] imm_zext;
|
142 |
|
|
wire imm_zext_sel;
|
143 |
|
|
wire [OPTION_OPERAND_WIDTH-1:0] imm_high;
|
144 |
|
|
wire imm_high_sel;
|
145 |
|
|
|
146 |
|
|
wire decode_except_ibus_align;
|
147 |
|
|
|
148 |
|
|
// Insn opcode
|
149 |
|
|
assign opc_insn = decode_insn_i[`OR1K_OPCODE_SELECT];
|
150 |
|
|
assign decode_opc_insn_o = opc_insn;
|
151 |
|
|
|
152 |
|
|
// load opcodes are 6'b10_0000 to 6'b10_0110, 0 to 6, so check for 7 and up
|
153 |
|
|
assign decode_op_lsu_load_o = (decode_insn_i[31:30] == 2'b10) &
|
154 |
|
|
!(&decode_insn_i[28:26]) &
|
155 |
|
|
!decode_insn_i[29] ||
|
156 |
|
|
((opc_insn == `OR1K_OPCODE_LWA) &
|
157 |
|
|
(FEATURE_ATOMIC!="NONE"));
|
158 |
|
|
|
159 |
|
|
// Detect when instruction is store
|
160 |
|
|
assign decode_op_lsu_store_o = (opc_insn == `OR1K_OPCODE_SW) ||
|
161 |
|
|
(opc_insn == `OR1K_OPCODE_SB) ||
|
162 |
|
|
(opc_insn == `OR1K_OPCODE_SH) ||
|
163 |
|
|
((opc_insn == `OR1K_OPCODE_SWA) &
|
164 |
|
|
(FEATURE_ATOMIC!="NONE"));
|
165 |
|
|
|
166 |
|
|
assign decode_op_lsu_atomic_o = ((opc_insn == `OR1K_OPCODE_LWA) ||
|
167 |
|
|
(opc_insn == `OR1K_OPCODE_SWA)) &
|
168 |
|
|
(FEATURE_ATOMIC!="NONE");
|
169 |
|
|
|
170 |
|
|
// Decode length of load/store operation
|
171 |
|
|
always @(*)
|
172 |
|
|
case (opc_insn)
|
173 |
|
|
`OR1K_OPCODE_SB,
|
174 |
|
|
`OR1K_OPCODE_LBZ,
|
175 |
|
|
`OR1K_OPCODE_LBS:
|
176 |
|
|
decode_lsu_length_o = 2'b00;
|
177 |
|
|
|
178 |
|
|
`OR1K_OPCODE_SH,
|
179 |
|
|
`OR1K_OPCODE_LHZ,
|
180 |
|
|
`OR1K_OPCODE_LHS:
|
181 |
|
|
decode_lsu_length_o = 2'b01;
|
182 |
|
|
|
183 |
|
|
`OR1K_OPCODE_SW,
|
184 |
|
|
`OR1K_OPCODE_SWA,
|
185 |
|
|
`OR1K_OPCODE_LWZ,
|
186 |
|
|
`OR1K_OPCODE_LWS,
|
187 |
|
|
`OR1K_OPCODE_LWA:
|
188 |
|
|
decode_lsu_length_o = 2'b10;
|
189 |
|
|
|
190 |
|
|
default:
|
191 |
|
|
decode_lsu_length_o = 2'b10;
|
192 |
|
|
endcase
|
193 |
|
|
|
194 |
|
|
assign decode_lsu_zext_o = opc_insn[0];
|
195 |
|
|
|
196 |
|
|
assign decode_op_msync_o = FEATURE_MSYNC!="NONE" &&
|
197 |
|
|
opc_insn == `OR1K_OPCODE_SYSTRAPSYNC &&
|
198 |
|
|
decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
199 |
|
|
`OR1K_SYSTRAPSYNC_OPC_MSYNC;
|
200 |
|
|
|
201 |
|
|
assign decode_op_mtspr_o = opc_insn == `OR1K_OPCODE_MTSPR;
|
202 |
|
|
|
203 |
|
|
// Detect when setflag instruction
|
204 |
|
|
assign decode_op_setflag_o = opc_insn == `OR1K_OPCODE_SF ||
|
205 |
|
|
opc_insn == `OR1K_OPCODE_SFIMM;
|
206 |
|
|
|
207 |
|
|
assign decode_op_alu_o = opc_insn == `OR1K_OPCODE_ALU ||
|
208 |
|
|
opc_insn == `OR1K_OPCODE_ORI ||
|
209 |
|
|
opc_insn == `OR1K_OPCODE_ANDI ||
|
210 |
|
|
opc_insn == `OR1K_OPCODE_XORI;
|
211 |
|
|
|
212 |
|
|
// Bottom 4 opcodes branch against an immediate
|
213 |
|
|
assign decode_op_jbr_o = opc_insn < `OR1K_OPCODE_NOP;
|
214 |
|
|
|
215 |
|
|
assign decode_op_jr_o = opc_insn == `OR1K_OPCODE_JR |
|
216 |
|
|
opc_insn == `OR1K_OPCODE_JALR;
|
217 |
|
|
|
218 |
|
|
assign decode_op_jal_o = opc_insn == `OR1K_OPCODE_JALR |
|
219 |
|
|
opc_insn == `OR1K_OPCODE_JAL;
|
220 |
|
|
|
221 |
|
|
assign decode_op_bf_o = opc_insn == `OR1K_OPCODE_BF;
|
222 |
|
|
assign decode_op_bnf_o = opc_insn == `OR1K_OPCODE_BNF;
|
223 |
|
|
assign decode_op_brcond_o = decode_op_bf_o | decode_op_bnf_o;
|
224 |
|
|
|
225 |
|
|
// All branch instructions combined
|
226 |
|
|
assign decode_op_branch_o = decode_op_jbr_o |
|
227 |
|
|
decode_op_jr_o |
|
228 |
|
|
decode_op_jal_o;
|
229 |
|
|
|
230 |
|
|
assign decode_op_mfspr_o = opc_insn == `OR1K_OPCODE_MFSPR;
|
231 |
|
|
|
232 |
|
|
assign decode_op_rfe_o = opc_insn == `OR1K_OPCODE_RFE;
|
233 |
|
|
|
234 |
|
|
assign decode_op_add_o = (opc_insn == `OR1K_OPCODE_ALU &&
|
235 |
|
|
(opc_alu == `OR1K_ALU_OPC_ADDC ||
|
236 |
|
|
opc_alu == `OR1K_ALU_OPC_ADD ||
|
237 |
|
|
opc_alu == `OR1K_ALU_OPC_SUB)) ||
|
238 |
|
|
opc_insn == `OR1K_OPCODE_ADDIC ||
|
239 |
|
|
opc_insn == `OR1K_OPCODE_ADDI;
|
240 |
|
|
|
241 |
|
|
assign decode_op_mul_signed_o = (opc_insn == `OR1K_OPCODE_ALU &&
|
242 |
|
|
opc_alu == `OR1K_ALU_OPC_MUL) ||
|
243 |
|
|
opc_insn == `OR1K_OPCODE_MULI;
|
244 |
|
|
|
245 |
|
|
assign decode_op_mul_unsigned_o = opc_insn == `OR1K_OPCODE_ALU &&
|
246 |
|
|
opc_alu == `OR1K_ALU_OPC_MULU;
|
247 |
|
|
|
248 |
|
|
assign decode_op_mul_o = decode_op_mul_signed_o | decode_op_mul_unsigned_o;
|
249 |
|
|
|
250 |
|
|
assign decode_op_div_signed_o = opc_insn == `OR1K_OPCODE_ALU &&
|
251 |
|
|
opc_alu == `OR1K_ALU_OPC_DIV;
|
252 |
|
|
|
253 |
|
|
assign decode_op_div_unsigned_o = opc_insn == `OR1K_OPCODE_ALU &&
|
254 |
|
|
opc_alu == `OR1K_ALU_OPC_DIVU;
|
255 |
|
|
|
256 |
|
|
assign decode_op_div_o = decode_op_div_signed_o | decode_op_div_unsigned_o;
|
257 |
|
|
|
258 |
|
|
assign decode_op_shift_o = opc_insn == `OR1K_OPCODE_ALU &&
|
259 |
|
|
opc_alu == `OR1K_ALU_OPC_SHRT ||
|
260 |
|
|
opc_insn == `OR1K_OPCODE_SHRTI;
|
261 |
|
|
|
262 |
|
|
/* check bit 9 to verify valid l.fl1/l.ff1 instruction */
|
263 |
|
|
assign decode_op_ffl1_o = opc_insn == `OR1K_OPCODE_ALU &&
|
264 |
|
|
(decode_insn_i[9:8] == 2'b00 || decode_insn_i[9:8] == 2'b01) &&
|
265 |
|
|
opc_alu == `OR1K_ALU_OPC_FFL1;
|
266 |
|
|
|
267 |
|
|
assign decode_op_movhi_o = opc_insn == `OR1K_OPCODE_MOVHI;
|
268 |
|
|
|
269 |
|
|
assign decode_op_ext_o = opc_insn == `OR1K_OPCODE_ALU &&
|
270 |
|
|
(opc_alu == `OR1K_ALU_OPC_EXTBH ||
|
271 |
|
|
opc_alu == `OR1K_ALU_OPC_EXTW) &&
|
272 |
|
|
(FEATURE_EXT!="NONE");
|
273 |
|
|
|
274 |
|
|
// FPU related
|
275 |
|
|
generate
|
276 |
|
|
/* verilator lint_off WIDTH */
|
277 |
|
|
if (FEATURE_FPU!="NONE") begin : fpu_decode_ena
|
278 |
|
|
/* verilator lint_on WIDTH */
|
279 |
|
|
// Only single precision FP-instructions are supported
|
280 |
|
|
assign decode_op_fpu_o = { ((opc_insn == `OR1K_OPCODE_FPU) &
|
281 |
|
|
~decode_insn_i[`OR1K_FPUOP_DOUBLE_BIT]),
|
282 |
|
|
decode_insn_i[`OR1K_FPUOP_WIDTH-2:0] };
|
283 |
|
|
end
|
284 |
|
|
else begin : fpu_decode_none
|
285 |
|
|
assign decode_op_fpu_o = {`OR1K_FPUOP_WIDTH{1'b0}};
|
286 |
|
|
end
|
287 |
|
|
endgenerate // FPU related
|
288 |
|
|
|
289 |
|
|
// Which instructions cause writeback?
|
290 |
|
|
assign decode_rf_wb_o = (opc_insn == `OR1K_OPCODE_JAL |
|
291 |
|
|
opc_insn == `OR1K_OPCODE_MOVHI |
|
292 |
|
|
opc_insn == `OR1K_OPCODE_JALR |
|
293 |
|
|
opc_insn == `OR1K_OPCODE_LWA) |
|
294 |
|
|
// All '10????' opcodes except l.sfxxi
|
295 |
|
|
(decode_insn_i[31:30] == 2'b10 &
|
296 |
|
|
!(opc_insn == `OR1K_OPCODE_SFIMM)) |
|
297 |
|
|
// All '11????' opcodes except l.sfxx and l.mtspr and lf.sfxx.s
|
298 |
|
|
(decode_insn_i[31:30] == 2'b11 &
|
299 |
|
|
!(opc_insn == `OR1K_OPCODE_SF |
|
300 |
|
|
decode_op_mtspr_o | decode_op_lsu_store_o) &
|
301 |
|
|
!(decode_op_fpu_o[`OR1K_FPUOP_WIDTH-1] & decode_insn_i[3]));
|
302 |
|
|
|
303 |
|
|
// Register file addresses
|
304 |
|
|
assign decode_rfa_adr_o = decode_insn_i[`OR1K_RA_SELECT];
|
305 |
|
|
assign decode_rfb_adr_o = decode_insn_i[`OR1K_RB_SELECT];
|
306 |
|
|
|
307 |
|
|
assign decode_rfd_adr_o = decode_op_jal_o ? 5'd9 :
|
308 |
|
|
decode_insn_i[`OR1K_RD_SELECT];
|
309 |
|
|
|
310 |
|
|
// Immediate in l.mtspr is broken up, reassemble
|
311 |
|
|
assign decode_imm16_o = (decode_op_mtspr_o | decode_op_lsu_store_o) ?
|
312 |
|
|
{decode_insn_i[25:21],decode_insn_i[10:0]} :
|
313 |
|
|
decode_insn_i[`OR1K_IMM_SELECT];
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
// Upper 10 bits for jump/branch instructions
|
317 |
|
|
assign decode_immjbr_upper_o = decode_insn_i[25:16];
|
318 |
|
|
|
319 |
|
|
assign imm_sext = {{16{decode_imm16_o[15]}}, decode_imm16_o[15:0]};
|
320 |
|
|
assign imm_sext_sel = ((opc_insn[5:4] == 2'b10) &
|
321 |
|
|
~(opc_insn == `OR1K_OPCODE_ORI) &
|
322 |
|
|
~(opc_insn == `OR1K_OPCODE_ANDI)) |
|
323 |
|
|
(opc_insn == `OR1K_OPCODE_SWA) |
|
324 |
|
|
(opc_insn == `OR1K_OPCODE_LWA) |
|
325 |
|
|
(opc_insn == `OR1K_OPCODE_SW) |
|
326 |
|
|
(opc_insn == `OR1K_OPCODE_SH) |
|
327 |
|
|
(opc_insn == `OR1K_OPCODE_SB);
|
328 |
|
|
|
329 |
|
|
assign imm_zext = {{16{1'b0}}, decode_imm16_o[15:0]};
|
330 |
|
|
assign imm_zext_sel = ((opc_insn[5:4] == 2'b10) &
|
331 |
|
|
((opc_insn == `OR1K_OPCODE_ORI) |
|
332 |
|
|
(opc_insn == `OR1K_OPCODE_ANDI))) |
|
333 |
|
|
(opc_insn == `OR1K_OPCODE_MTSPR);
|
334 |
|
|
|
335 |
|
|
assign imm_high = {decode_imm16_o, 16'd0};
|
336 |
|
|
assign imm_high_sel = decode_op_movhi_o;
|
337 |
|
|
|
338 |
|
|
assign decode_immediate_o = imm_sext_sel ? imm_sext :
|
339 |
|
|
imm_zext_sel ? imm_zext : imm_high;
|
340 |
|
|
|
341 |
|
|
assign decode_immediate_sel_o = imm_sext_sel | imm_zext_sel | imm_high_sel;
|
342 |
|
|
|
343 |
|
|
// ALU opcode
|
344 |
|
|
assign opc_alu = decode_insn_i[`OR1K_ALU_OPC_SELECT];
|
345 |
|
|
assign decode_opc_alu_o = opc_insn == `OR1K_OPCODE_ORI ? `OR1K_ALU_OPC_OR :
|
346 |
|
|
opc_insn == `OR1K_OPCODE_ANDI ? `OR1K_ALU_OPC_AND :
|
347 |
|
|
opc_insn == `OR1K_OPCODE_XORI ? `OR1K_ALU_OPC_XOR :
|
348 |
|
|
opc_alu;
|
349 |
|
|
|
350 |
|
|
assign decode_opc_alu_secondary_o = decode_op_setflag_o ?
|
351 |
|
|
decode_insn_i[`OR1K_COMP_OPC_SELECT]:
|
352 |
|
|
{1'b0,
|
353 |
|
|
decode_insn_i[`OR1K_ALU_OPC_SECONDARY_SELECT]};
|
354 |
|
|
|
355 |
|
|
assign decode_except_syscall_o = opc_insn == `OR1K_OPCODE_SYSTRAPSYNC &&
|
356 |
|
|
decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
357 |
|
|
`OR1K_SYSTRAPSYNC_OPC_SYSCALL;
|
358 |
|
|
|
359 |
|
|
assign decode_except_trap_o = opc_insn == `OR1K_OPCODE_SYSTRAPSYNC &&
|
360 |
|
|
decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
361 |
|
|
`OR1K_SYSTRAPSYNC_OPC_TRAP;
|
362 |
|
|
|
363 |
|
|
// Illegal instruction decode
|
364 |
|
|
always @*
|
365 |
|
|
case (opc_insn)
|
366 |
|
|
`OR1K_OPCODE_J,
|
367 |
|
|
`OR1K_OPCODE_JAL,
|
368 |
|
|
`OR1K_OPCODE_BNF,
|
369 |
|
|
`OR1K_OPCODE_BF,
|
370 |
|
|
`OR1K_OPCODE_MOVHI,
|
371 |
|
|
`OR1K_OPCODE_RFE,
|
372 |
|
|
`OR1K_OPCODE_JR,
|
373 |
|
|
`OR1K_OPCODE_JALR,
|
374 |
|
|
`OR1K_OPCODE_LWZ,
|
375 |
|
|
`OR1K_OPCODE_LWS,
|
376 |
|
|
`OR1K_OPCODE_LBZ,
|
377 |
|
|
`OR1K_OPCODE_LBS,
|
378 |
|
|
`OR1K_OPCODE_LHZ,
|
379 |
|
|
`OR1K_OPCODE_LHS,
|
380 |
|
|
`OR1K_OPCODE_ADDI,
|
381 |
|
|
`OR1K_OPCODE_ANDI,
|
382 |
|
|
`OR1K_OPCODE_ORI,
|
383 |
|
|
`OR1K_OPCODE_XORI,
|
384 |
|
|
`OR1K_OPCODE_MFSPR,
|
385 |
|
|
/*
|
386 |
|
|
`OR1K_OPCODE_SLLI,
|
387 |
|
|
`OR1K_OPCODE_SRLI,
|
388 |
|
|
`OR1K_OPCODE_SRAI,
|
389 |
|
|
`OR1K_OPCODE_RORI,
|
390 |
|
|
*/
|
391 |
|
|
`OR1K_OPCODE_SFIMM,
|
392 |
|
|
`OR1K_OPCODE_MTSPR,
|
393 |
|
|
`OR1K_OPCODE_SW,
|
394 |
|
|
`OR1K_OPCODE_SB,
|
395 |
|
|
`OR1K_OPCODE_SH,
|
396 |
|
|
/*
|
397 |
|
|
`OR1K_OPCODE_SFEQ,
|
398 |
|
|
`OR1K_OPCODE_SFNE,
|
399 |
|
|
`OR1K_OPCODE_SFGTU,
|
400 |
|
|
`OR1K_OPCODE_SFGEU,
|
401 |
|
|
`OR1K_OPCODE_SFLTU,
|
402 |
|
|
`OR1K_OPCODE_SFLEU,
|
403 |
|
|
`OR1K_OPCODE_SFGTS,
|
404 |
|
|
`OR1K_OPCODE_SFGES,
|
405 |
|
|
`OR1K_OPCODE_SFLTS,
|
406 |
|
|
`OR1K_OPCODE_SFLES,
|
407 |
|
|
*/
|
408 |
|
|
`OR1K_OPCODE_SF,
|
409 |
|
|
`OR1K_OPCODE_NOP:
|
410 |
|
|
decode_except_illegal_o = 1'b0;
|
411 |
|
|
|
412 |
|
|
`OR1K_OPCODE_SWA,
|
413 |
|
|
`OR1K_OPCODE_LWA:
|
414 |
|
|
decode_except_illegal_o = (FEATURE_ATOMIC=="NONE");
|
415 |
|
|
|
416 |
|
|
`OR1K_OPCODE_CUST1:
|
417 |
|
|
decode_except_illegal_o = (FEATURE_CUST1=="NONE");
|
418 |
|
|
`OR1K_OPCODE_CUST2:
|
419 |
|
|
decode_except_illegal_o = (FEATURE_CUST2=="NONE");
|
420 |
|
|
`OR1K_OPCODE_CUST3:
|
421 |
|
|
decode_except_illegal_o = (FEATURE_CUST3=="NONE");
|
422 |
|
|
`OR1K_OPCODE_CUST4:
|
423 |
|
|
decode_except_illegal_o = (FEATURE_CUST4=="NONE");
|
424 |
|
|
`OR1K_OPCODE_CUST5:
|
425 |
|
|
decode_except_illegal_o = (FEATURE_CUST5=="NONE");
|
426 |
|
|
`OR1K_OPCODE_CUST6:
|
427 |
|
|
decode_except_illegal_o = (FEATURE_CUST6=="NONE");
|
428 |
|
|
`OR1K_OPCODE_CUST7:
|
429 |
|
|
decode_except_illegal_o = (FEATURE_CUST7=="NONE");
|
430 |
|
|
`OR1K_OPCODE_CUST8:
|
431 |
|
|
decode_except_illegal_o = (FEATURE_CUST8=="NONE");
|
432 |
|
|
`OR1K_OPCODE_FPU:
|
433 |
|
|
decode_except_illegal_o = (FEATURE_FPU=="NONE") |
|
434 |
|
|
decode_insn_i[`OR1K_FPUOP_DOUBLE_BIT];
|
435 |
|
|
|
436 |
|
|
`OR1K_OPCODE_LD,
|
437 |
|
|
`OR1K_OPCODE_SD:
|
438 |
|
|
decode_except_illegal_o = !(OPTION_OPERAND_WIDTH==64);
|
439 |
|
|
|
440 |
|
|
`OR1K_OPCODE_ADDIC:
|
441 |
|
|
decode_except_illegal_o = (FEATURE_ADDC=="NONE");
|
442 |
|
|
|
443 |
|
|
//`OR1K_OPCODE_MACRC, // Same as movhi - check!
|
444 |
|
|
`OR1K_OPCODE_MACI,
|
445 |
|
|
`OR1K_OPCODE_MAC:
|
446 |
|
|
decode_except_illegal_o = (FEATURE_MAC=="NONE");
|
447 |
|
|
|
448 |
|
|
`OR1K_OPCODE_MULI:
|
449 |
|
|
decode_except_illegal_o = (FEATURE_MULTIPLIER=="NONE");
|
450 |
|
|
|
451 |
|
|
`OR1K_OPCODE_SHRTI:
|
452 |
|
|
case(decode_insn_i[`OR1K_ALU_OPC_SECONDARY_SELECT])
|
453 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_SLL,
|
454 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_SRL:
|
455 |
|
|
decode_except_illegal_o = 1'b0;
|
456 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_SRA:
|
457 |
|
|
decode_except_illegal_o = (FEATURE_SRA=="NONE");
|
458 |
|
|
|
459 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_ROR:
|
460 |
|
|
decode_except_illegal_o = (FEATURE_ROR=="NONE");
|
461 |
|
|
default:
|
462 |
|
|
decode_except_illegal_o = 1'b1;
|
463 |
|
|
endcase // case (decode_insn_i[`OR1K_ALU_OPC_SECONDARY_SELECT])
|
464 |
|
|
|
465 |
|
|
`OR1K_OPCODE_ALU:
|
466 |
|
|
case(decode_insn_i[`OR1K_ALU_OPC_SELECT])
|
467 |
|
|
`OR1K_ALU_OPC_ADD,
|
468 |
|
|
`OR1K_ALU_OPC_SUB,
|
469 |
|
|
`OR1K_ALU_OPC_OR,
|
470 |
|
|
`OR1K_ALU_OPC_XOR,
|
471 |
|
|
`OR1K_ALU_OPC_AND:
|
472 |
|
|
decode_except_illegal_o = 1'b0;
|
473 |
|
|
`OR1K_ALU_OPC_CMOV:
|
474 |
|
|
decode_except_illegal_o = (FEATURE_CMOV=="NONE");
|
475 |
|
|
`OR1K_ALU_OPC_FFL1:
|
476 |
|
|
decode_except_illegal_o = (FEATURE_FFL1=="NONE");
|
477 |
|
|
`OR1K_ALU_OPC_DIV,
|
478 |
|
|
`OR1K_ALU_OPC_DIVU:
|
479 |
|
|
decode_except_illegal_o = (FEATURE_DIVIDER=="NONE");
|
480 |
|
|
`OR1K_ALU_OPC_ADDC:
|
481 |
|
|
decode_except_illegal_o = (FEATURE_ADDC=="NONE");
|
482 |
|
|
`OR1K_ALU_OPC_MUL,
|
483 |
|
|
`OR1K_ALU_OPC_MULU:
|
484 |
|
|
decode_except_illegal_o = (FEATURE_MULTIPLIER=="NONE");
|
485 |
|
|
`OR1K_ALU_OPC_EXTBH,
|
486 |
|
|
`OR1K_ALU_OPC_EXTW:
|
487 |
|
|
decode_except_illegal_o = (FEATURE_EXT=="NONE");
|
488 |
|
|
`OR1K_ALU_OPC_SHRT:
|
489 |
|
|
case(decode_insn_i[`OR1K_ALU_OPC_SECONDARY_SELECT])
|
490 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_SLL,
|
491 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_SRL:
|
492 |
|
|
decode_except_illegal_o = 1'b0;
|
493 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_SRA:
|
494 |
|
|
decode_except_illegal_o = (FEATURE_SRA=="NONE");
|
495 |
|
|
`OR1K_ALU_OPC_SECONDARY_SHRT_ROR:
|
496 |
|
|
decode_except_illegal_o = (FEATURE_ROR=="NONE");
|
497 |
|
|
default:
|
498 |
|
|
decode_except_illegal_o = 1'b1;
|
499 |
|
|
endcase // case (decode_insn_i[`OR1K_ALU_OPC_SECONDARY_SELECT])
|
500 |
|
|
default:
|
501 |
|
|
decode_except_illegal_o = 1'b1;
|
502 |
|
|
endcase // case (decode_insn_i[`OR1K_ALU_OPC_SELECT])
|
503 |
|
|
|
504 |
|
|
`OR1K_OPCODE_SYSTRAPSYNC: begin
|
505 |
|
|
if ((decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
506 |
|
|
`OR1K_SYSTRAPSYNC_OPC_SYSCALL &&
|
507 |
|
|
FEATURE_SYSCALL=="ENABLED") ||
|
508 |
|
|
(decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
509 |
|
|
`OR1K_SYSTRAPSYNC_OPC_TRAP &&
|
510 |
|
|
FEATURE_TRAP=="ENABLED") ||
|
511 |
|
|
(decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
512 |
|
|
`OR1K_SYSTRAPSYNC_OPC_MSYNC) ||
|
513 |
|
|
(decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
514 |
|
|
`OR1K_SYSTRAPSYNC_OPC_PSYNC &&
|
515 |
|
|
FEATURE_PSYNC!="NONE") ||
|
516 |
|
|
(decode_insn_i[`OR1K_SYSTRAPSYNC_OPC_SELECT] ==
|
517 |
|
|
`OR1K_SYSTRAPSYNC_OPC_CSYNC &&
|
518 |
|
|
FEATURE_CSYNC!="NONE"))
|
519 |
|
|
decode_except_illegal_o = 1'b0;
|
520 |
|
|
else
|
521 |
|
|
decode_except_illegal_o = 1'b1;
|
522 |
|
|
end // case: endcase...
|
523 |
|
|
default:
|
524 |
|
|
decode_except_illegal_o = 1'b1;
|
525 |
|
|
|
526 |
|
|
endcase // case (decode_insn_i[`OR1K_OPCODE_SELECT])
|
527 |
|
|
|
528 |
|
|
// Adder control logic
|
529 |
|
|
// Subtract when comparing to check if equal
|
530 |
|
|
assign decode_adder_do_sub_o = (opc_insn == `OR1K_OPCODE_ALU &
|
531 |
|
|
opc_alu == `OR1K_ALU_OPC_SUB) |
|
532 |
|
|
decode_op_setflag_o;
|
533 |
|
|
|
534 |
|
|
// Generate carry-in select
|
535 |
|
|
assign decode_adder_do_carry_o = (FEATURE_ADDC!="NONE") &&
|
536 |
|
|
((opc_insn == `OR1K_OPCODE_ALU &
|
537 |
|
|
opc_alu == `OR1K_ALU_OPC_ADDC) ||
|
538 |
|
|
(opc_insn == `OR1K_OPCODE_ADDIC));
|
539 |
|
|
|
540 |
|
|
endmodule // mor1kx_decode
|