OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [mor1kx-3.1/] [rtl/] [verilog/] [mor1kx_decode.v] - Blame information for rev 38

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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