OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_ctrl.v] - Blame information for rev 335

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Instruction decode                                 ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6 185 julius
////  http://www.opencores.org/project,or1k                       ////
7 10 unneback
////                                                              ////
8
////  Description                                                 ////
9
////  Majority of instruction decoding is performed here.         ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
//
45 141 marcus.erl
// $Log: or1200_ctrl.v,v $
46
// Revision 2.0  2010/06/30 11:00:00  ORSoC
47
// Major update: 
48
// Structure reordered and bugs fixed. 
49 10 unneback
 
50
// synopsys translate_off
51
`include "timescale.v"
52
// synopsys translate_on
53
`include "or1200_defines.v"
54
 
55 185 julius
module or1200_ctrl
56
  (
57
   // Clock and reset
58
   clk, rst,
59
 
60
   // Internal i/f
61
   except_flushpipe, extend_flush, if_flushpipe, id_flushpipe, ex_flushpipe,
62
   wb_flushpipe,
63
   id_freeze, ex_freeze, wb_freeze, if_insn, id_insn, ex_insn, abort_mvspr,
64
   id_branch_op, ex_branch_op, ex_branch_taken, pc_we,
65
   rf_addra, rf_addrb, rf_rda, rf_rdb, alu_op, mac_op, shrot_op, comp_op,
66
   rf_addrw, rfwb_op, fpu_op,
67
   wb_insn, id_simm, ex_simm, id_branch_addrtarget, ex_branch_addrtarget, sel_a,
68
   sel_b, id_lsu_op,
69
   cust5_op, cust5_limm, id_pc, ex_pc, du_hwbkpt,
70 258 julius
   multicycle, wait_on, wbforw_valid, sig_syscall, sig_trap,
71 185 julius
   force_dslot_fetch, no_more_dslot, id_void, ex_void, ex_spr_read,
72
   ex_spr_write,
73 258 julius
   id_mac_op, id_macrc_op, ex_macrc_op, rfe, except_illegal, dc_no_writethrough
74 185 julius
   );
75 10 unneback
 
76
//
77
// I/O
78
//
79
input                                   clk;
80
input                                   rst;
81
input                                   id_freeze;
82
input                                   ex_freeze;
83
input                                   wb_freeze;
84 141 marcus.erl
output                                  if_flushpipe;
85
output                                  id_flushpipe;
86
output                                  ex_flushpipe;
87
output                                  wb_flushpipe;
88
input                                   extend_flush;
89
input                                   except_flushpipe;
90
input                           abort_mvspr ;
91
input   [31:0]                   if_insn;
92
output  [31:0]                   id_insn;
93
output  [31:0]                   ex_insn;
94
output  [`OR1200_BRANCHOP_WIDTH-1:0]             ex_branch_op;
95
output  [`OR1200_BRANCHOP_WIDTH-1:0]             id_branch_op;
96
input                                           ex_branch_taken;
97 10 unneback
output  [`OR1200_REGFILE_ADDR_WIDTH-1:0] rf_addrw;
98
output  [`OR1200_REGFILE_ADDR_WIDTH-1:0] rf_addra;
99
output  [`OR1200_REGFILE_ADDR_WIDTH-1:0] rf_addrb;
100
output                                  rf_rda;
101
output                                  rf_rdb;
102
output  [`OR1200_ALUOP_WIDTH-1:0]                alu_op;
103
output  [`OR1200_MACOP_WIDTH-1:0]                mac_op;
104
output  [`OR1200_SHROTOP_WIDTH-1:0]              shrot_op;
105
output  [`OR1200_RFWBOP_WIDTH-1:0]               rfwb_op;
106 258 julius
output  [`OR1200_FPUOP_WIDTH-1:0]                fpu_op;
107 141 marcus.erl
input                                   pc_we;
108 10 unneback
output  [31:0]                           wb_insn;
109 141 marcus.erl
output  [31:2]                          id_branch_addrtarget;
110
output  [31:2]                          ex_branch_addrtarget;
111 10 unneback
output  [`OR1200_SEL_WIDTH-1:0]          sel_a;
112
output  [`OR1200_SEL_WIDTH-1:0]          sel_b;
113 141 marcus.erl
output  [`OR1200_LSUOP_WIDTH-1:0]                id_lsu_op;
114 10 unneback
output  [`OR1200_COMPOP_WIDTH-1:0]               comp_op;
115
output  [`OR1200_MULTICYCLE_WIDTH-1:0]           multicycle;
116 258 julius
output  [`OR1200_WAIT_ON_WIDTH-1:0]              wait_on;
117 10 unneback
output  [4:0]                            cust5_op;
118
output  [5:0]                            cust5_limm;
119 141 marcus.erl
input   [31:0]                          id_pc;
120
input   [31:0]                          ex_pc;
121
output  [31:0]                           id_simm;
122
output  [31:0]                           ex_simm;
123 10 unneback
input                                   wbforw_valid;
124
input                                   du_hwbkpt;
125
output                                  sig_syscall;
126
output                                  sig_trap;
127
output                                  force_dslot_fetch;
128
output                                  no_more_dslot;
129 141 marcus.erl
output                                  id_void;
130 10 unneback
output                                  ex_void;
131 141 marcus.erl
output                                  ex_spr_read;
132
output                                  ex_spr_write;
133
output  [`OR1200_MACOP_WIDTH-1:0]        id_mac_op;
134 10 unneback
output                                  id_macrc_op;
135
output                                  ex_macrc_op;
136
output                                  rfe;
137
output                                  except_illegal;
138 258 julius
output                                  dc_no_writethrough;
139
 
140
 
141 10 unneback
//
142
// Internal wires and regs
143
//
144 141 marcus.erl
reg     [`OR1200_BRANCHOP_WIDTH-1:0]             id_branch_op;
145
reg     [`OR1200_BRANCHOP_WIDTH-1:0]             ex_branch_op;
146 10 unneback
reg     [`OR1200_ALUOP_WIDTH-1:0]                alu_op;
147 141 marcus.erl
wire                                    if_maci_op;
148 10 unneback
`ifdef OR1200_MAC_IMPLEMENTED
149 141 marcus.erl
reg     [`OR1200_MACOP_WIDTH-1:0]                ex_mac_op;
150
reg     [`OR1200_MACOP_WIDTH-1:0]                id_mac_op;
151
wire    [`OR1200_MACOP_WIDTH-1:0]                mac_op;
152 10 unneback
reg                                     ex_macrc_op;
153
`else
154
wire    [`OR1200_MACOP_WIDTH-1:0]                mac_op;
155
wire                                    ex_macrc_op;
156
`endif
157
reg     [`OR1200_SHROTOP_WIDTH-1:0]              shrot_op;
158
reg     [31:0]                           id_insn;
159
reg     [31:0]                           ex_insn;
160
reg     [31:0]                           wb_insn;
161
reg     [`OR1200_REGFILE_ADDR_WIDTH-1:0] rf_addrw;
162
reg     [`OR1200_REGFILE_ADDR_WIDTH-1:0] wb_rfaddrw;
163
reg     [`OR1200_RFWBOP_WIDTH-1:0]               rfwb_op;
164
reg     [`OR1200_SEL_WIDTH-1:0]          sel_a;
165
reg     [`OR1200_SEL_WIDTH-1:0]          sel_b;
166
reg                                     sel_imm;
167 141 marcus.erl
reg     [`OR1200_LSUOP_WIDTH-1:0]                id_lsu_op;
168 10 unneback
reg     [`OR1200_COMPOP_WIDTH-1:0]               comp_op;
169
reg     [`OR1200_MULTICYCLE_WIDTH-1:0]           multicycle;
170 258 julius
reg     [`OR1200_WAIT_ON_WIDTH-1:0]              wait_on;
171 141 marcus.erl
reg     [31:0]                           id_simm;
172
reg     [31:0]                           ex_simm;
173 10 unneback
reg                                     sig_syscall;
174
reg                                     sig_trap;
175
reg                                     except_illegal;
176
wire                                    id_void;
177 141 marcus.erl
wire                                    ex_void;
178
wire                                    wb_void;
179
reg                                     ex_delayslot_dsi;
180
reg                                     ex_delayslot_nop;
181
reg                                     spr_read;
182
reg                                     spr_write;
183
reg     [31:2]                          ex_branch_addrtarget;
184 258 julius
`ifdef OR1200_DC_NOSTACKWRITETHROUGH
185
reg                                     dc_no_writethrough;
186
`endif
187
 
188 10 unneback
//
189
// Register file read addresses
190
//
191
assign rf_addra = if_insn[20:16];
192
assign rf_addrb = if_insn[15:11];
193 141 marcus.erl
assign rf_rda = if_insn[31] || if_maci_op;
194 10 unneback
assign rf_rdb = if_insn[30];
195
 
196
//
197
// Force fetch of delay slot instruction when jump/branch is preceeded by load/store
198
// instructions
199
//
200
assign force_dslot_fetch = 1'b0;
201 141 marcus.erl
assign no_more_dslot = (|ex_branch_op & !id_void & ex_branch_taken) | (ex_branch_op == `OR1200_BRANCHOP_RFE);
202
 
203 10 unneback
assign id_void = (id_insn[31:26] == `OR1200_OR32_NOP) & id_insn[16];
204
assign ex_void = (ex_insn[31:26] == `OR1200_OR32_NOP) & ex_insn[16];
205 141 marcus.erl
assign wb_void = (wb_insn[31:26] == `OR1200_OR32_NOP) & wb_insn[16];
206 10 unneback
 
207 141 marcus.erl
assign ex_spr_write = spr_write && !abort_mvspr;
208
assign ex_spr_read = spr_read && !abort_mvspr;
209
 
210 10 unneback
//
211 141 marcus.erl
// ex_delayslot_dsi: delay slot insn is in EX stage
212
// ex_delayslot_nop: (filler) nop insn is in EX stage (before nops jump/branch was executed)
213 10 unneback
//
214 141 marcus.erl
//  ex_delayslot_dsi & !ex_delayslot_nop - DS insn in EX stage
215
//  !ex_delayslot_dsi & ex_delayslot_nop - NOP insn in EX stage, 
216
//       next different is DS insn, previous different was Jump/Branch
217
//  !ex_delayslot_dsi & !ex_delayslot_nop - normal insn in EX stage
218
//
219
always @(posedge clk or posedge rst) begin
220
        if (rst) begin
221 258 julius
                ex_delayslot_nop <=  1'b0;
222
                ex_delayslot_dsi <=  1'b0;
223 141 marcus.erl
        end
224
        else if (!ex_freeze & !ex_delayslot_dsi & ex_delayslot_nop) begin
225 258 julius
                ex_delayslot_nop <=  id_void;
226
                ex_delayslot_dsi <=  !id_void;
227 141 marcus.erl
        end
228
        else if (!ex_freeze & ex_delayslot_dsi & !ex_delayslot_nop) begin
229 258 julius
                ex_delayslot_nop <=  1'b0;
230
                ex_delayslot_dsi <=  1'b0;
231 141 marcus.erl
        end
232
        else if (!ex_freeze) begin
233 258 julius
                ex_delayslot_nop <=  id_void && ex_branch_taken && (ex_branch_op != `OR1200_BRANCHOP_NOP) &&
234 141 marcus.erl
                                                                (ex_branch_op != `OR1200_BRANCHOP_RFE);
235 258 julius
                ex_delayslot_dsi <=  !id_void && ex_branch_taken && (ex_branch_op != `OR1200_BRANCHOP_NOP) &&
236 141 marcus.erl
                                                                 (ex_branch_op != `OR1200_BRANCHOP_RFE);
237
        end
238
end
239 10 unneback
 
240
//
241 141 marcus.erl
// Flush pipeline
242 10 unneback
//
243 141 marcus.erl
assign if_flushpipe = except_flushpipe | pc_we | extend_flush;
244
assign id_flushpipe = except_flushpipe | pc_we | extend_flush;
245
assign ex_flushpipe = except_flushpipe | pc_we | extend_flush;
246
assign wb_flushpipe = except_flushpipe | pc_we | extend_flush;
247 10 unneback
 
248
//
249 141 marcus.erl
// EX Sign/Zero extension of immediates
250
//
251
always @(posedge clk or posedge rst) begin
252
        if (rst)
253 258 julius
                ex_simm <=  32'h0000_0000;
254 141 marcus.erl
        else if (!ex_freeze) begin
255 258 julius
                ex_simm <=  id_simm;
256 141 marcus.erl
        end
257
end
258
 
259
//
260
// ID Sign/Zero extension of immediate
261
//
262
always @(id_insn) begin
263
        case (id_insn[31:26])     // synopsys parallel_case
264
 
265
        // l.addi
266
        `OR1200_OR32_ADDI:
267
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
268
 
269
        // l.addic
270
        `OR1200_OR32_ADDIC:
271
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
272
 
273
        // l.lxx (load instructions)
274
        `OR1200_OR32_LWZ, `OR1200_OR32_LBZ, `OR1200_OR32_LBS, `OR1200_OR32_LHZ, `OR1200_OR32_LHS:
275
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
276
 
277
        // l.muli
278
        `ifdef OR1200_MULT_IMPLEMENTED
279
        `OR1200_OR32_MULI:
280
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
281
        `endif
282
 
283
        // l.maci
284
        `ifdef OR1200_MAC_IMPLEMENTED
285
        `OR1200_OR32_MACI:
286
                id_simm = {{16{id_insn[25]}}, id_insn[25:21], id_insn[10:0]};
287
        `endif
288
 
289
        // l.mtspr
290
        `OR1200_OR32_MTSPR:
291
                id_simm = {16'b0, id_insn[25:21], id_insn[10:0]};
292
 
293
        // l.sxx (store instructions)
294
        `OR1200_OR32_SW, `OR1200_OR32_SH, `OR1200_OR32_SB:
295
                id_simm = {{16{id_insn[25]}}, id_insn[25:21], id_insn[10:0]};
296
 
297
        // l.xori
298
        `OR1200_OR32_XORI:
299
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
300
 
301
        // l.sfxxi (SFXX with immediate)
302
        `OR1200_OR32_SFXXI:
303
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
304
 
305
        // Instructions with no or zero extended immediate
306
        default:
307
                id_simm = {{16'b0}, id_insn[15:0]};
308
 
309
        endcase
310
end
311
 
312
//
313
// ID Sign extension of branch offset
314
//
315
assign id_branch_addrtarget = {{4{id_insn[25]}}, id_insn[25:0]} + id_pc[31:2];
316
 
317
//
318
// EX Sign extension of branch offset
319
//
320
 
321
// pipeline ID and EX branch target address 
322
always @(posedge clk or posedge rst) begin
323
        if (rst)
324 258 julius
                ex_branch_addrtarget <=  32'h00000000;
325 141 marcus.erl
        else if (!ex_freeze)
326 258 julius
                ex_branch_addrtarget <=  id_branch_addrtarget;
327 141 marcus.erl
end
328
// not pipelined
329
//assign ex_branch_addrtarget = {{4{ex_insn[25]}}, ex_insn[25:0]} + ex_pc[31:2];
330
 
331
//
332
// l.maci in IF stage
333
//
334
`ifdef OR1200_MAC_IMPLEMENTED
335
assign if_maci_op = (if_insn[31:26] == `OR1200_OR32_MACI);
336
`else
337
assign if_maci_op = 1'b0;
338
`endif
339
 
340
//
341 10 unneback
// l.macrc in ID stage
342
//
343
`ifdef OR1200_MAC_IMPLEMENTED
344
assign id_macrc_op = (id_insn[31:26] == `OR1200_OR32_MOVHI) & id_insn[16];
345
`else
346
assign id_macrc_op = 1'b0;
347
`endif
348
 
349
//
350 141 marcus.erl
// l.macrc in EX stage
351
//
352
`ifdef OR1200_MAC_IMPLEMENTED
353
always @(posedge clk or posedge rst) begin
354
        if (rst)
355 258 julius
                ex_macrc_op <=  1'b0;
356 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
357 258 julius
                ex_macrc_op <=  1'b0;
358 141 marcus.erl
        else if (!ex_freeze)
359 258 julius
                ex_macrc_op <=  id_macrc_op;
360 141 marcus.erl
end
361
`else
362
assign ex_macrc_op = 1'b0;
363
`endif
364
 
365
//
366 10 unneback
// cust5_op, cust5_limm (L immediate)
367
//
368
assign cust5_op = ex_insn[4:0];
369
assign cust5_limm = ex_insn[10:5];
370
 
371
//
372
//
373
//
374 141 marcus.erl
assign rfe = (id_branch_op == `OR1200_BRANCHOP_RFE) | (ex_branch_op == `OR1200_BRANCHOP_RFE);
375 10 unneback
 
376
//
377
// Generation of sel_a
378
//
379
always @(rf_addrw or id_insn or rfwb_op or wbforw_valid or wb_rfaddrw)
380
        if ((id_insn[20:16] == rf_addrw) && rfwb_op[0])
381
                sel_a = `OR1200_SEL_EX_FORW;
382
        else if ((id_insn[20:16] == wb_rfaddrw) && wbforw_valid)
383
                sel_a = `OR1200_SEL_WB_FORW;
384
        else
385
                sel_a = `OR1200_SEL_RF;
386
 
387
//
388
// Generation of sel_b
389
//
390
always @(rf_addrw or sel_imm or id_insn or rfwb_op or wbforw_valid or wb_rfaddrw)
391
        if (sel_imm)
392
                sel_b = `OR1200_SEL_IMM;
393
        else if ((id_insn[15:11] == rf_addrw) && rfwb_op[0])
394
                sel_b = `OR1200_SEL_EX_FORW;
395
        else if ((id_insn[15:11] == wb_rfaddrw) && wbforw_valid)
396
                sel_b = `OR1200_SEL_WB_FORW;
397
        else
398
                sel_b = `OR1200_SEL_RF;
399
 
400
//
401
// Decode of multicycle
402
//
403
always @(id_insn) begin
404
  case (id_insn[31:26])         // synopsys parallel_case
405
`ifdef UNUSED
406
    // l.lwz
407
    `OR1200_OR32_LWZ:
408
      multicycle = `OR1200_TWO_CYCLES;
409
 
410
    // l.lbz
411
    `OR1200_OR32_LBZ:
412
      multicycle = `OR1200_TWO_CYCLES;
413
 
414
    // l.lbs
415
    `OR1200_OR32_LBS:
416
      multicycle = `OR1200_TWO_CYCLES;
417
 
418
    // l.lhz
419
    `OR1200_OR32_LHZ:
420
      multicycle = `OR1200_TWO_CYCLES;
421
 
422
    // l.lhs
423
    `OR1200_OR32_LHS:
424
      multicycle = `OR1200_TWO_CYCLES;
425
 
426
    // l.sw
427
    `OR1200_OR32_SW:
428
      multicycle = `OR1200_TWO_CYCLES;
429
 
430
    // l.sb
431
    `OR1200_OR32_SB:
432
      multicycle = `OR1200_TWO_CYCLES;
433
 
434
    // l.sh
435
    `OR1200_OR32_SH:
436
      multicycle = `OR1200_TWO_CYCLES;
437
`endif
438 141 marcus.erl
    // l.mfspr
439
    `OR1200_OR32_MFSPR:
440
      multicycle = `OR1200_TWO_CYCLES;  // to read from ITLB/DTLB (sync RAMs)
441
 
442 10 unneback
    // ALU instructions except the one with immediate
443
    `OR1200_OR32_ALU:
444 141 marcus.erl
        case (id_insn[3:0]) // synopsys parallel_case
445
        4'h6: multicycle = 2'b11; // l.mul
446
        4'h9: multicycle = 2'b10; // l.div
447
        4'hA: multicycle = 2'b10; // l.divu
448
        4'hB: multicycle = 2'b11; // l.mulu
449
        default: multicycle = 2'b00;
450
        endcase
451 10 unneback
 
452 141 marcus.erl
    `OR1200_OR32_MULI:
453
      multicycle = 2'h3;
454
 
455 10 unneback
    // Single cycle instructions
456
    default: begin
457
      multicycle = `OR1200_ONE_CYCLE;
458 258 julius
    end
459 10 unneback
  endcase
460 258 julius
end // always @ (id_insn)
461 10 unneback
 
462
//
463 258 julius
// Encode wait_on signal
464
//    
465
always @(id_insn) begin
466
   case (id_insn[31:26])                // synopsys parallel_case
467
`ifdef OR1200_FPU_IMPLEMENTED
468
       `OR1200_OR32_FLOAT: begin
469
         wait_on = id_insn[`OR1200_FPUOP_DOUBLE_BIT] ? 0 : `OR1200_WAIT_ON_FPU;
470
       end
471
`endif
472
`ifndef OR1200_DC_WRITHROUGH
473
     // l.mtspr
474
     `OR1200_OR32_MTSPR: begin
475
        wait_on = `OR1200_WAIT_ON_MTSPR;
476
     end
477
`endif
478
     default: begin
479
        wait_on = 0;
480
     end
481
   endcase // case (id_insn[31:26])
482
end // always @ (id_insn)
483
 
484
 
485
 
486
 
487
//
488 10 unneback
// Register file write address
489
//
490
always @(posedge clk or posedge rst) begin
491
        if (rst)
492 258 julius
                rf_addrw <=  5'd0;
493 10 unneback
        else if (!ex_freeze & id_freeze)
494 258 julius
                rf_addrw <=  5'd00;
495 10 unneback
        else if (!ex_freeze)
496 141 marcus.erl
                case (id_insn[31:26])   // synopsys parallel_case
497
                        `OR1200_OR32_JAL, `OR1200_OR32_JALR:
498 258 julius
                                rf_addrw <=  5'd09;     // link register r9
499 10 unneback
                        default:
500 258 julius
                                rf_addrw <=  id_insn[25:21];
501 10 unneback
                endcase
502
end
503
 
504
//
505
// rf_addrw in wb stage (used in forwarding logic)
506
//
507
always @(posedge clk or posedge rst) begin
508
        if (rst)
509 258 julius
                wb_rfaddrw <=  5'd0;
510 10 unneback
        else if (!wb_freeze)
511 258 julius
                wb_rfaddrw <=  rf_addrw;
512 10 unneback
end
513
 
514
//
515
// Instruction latch in id_insn
516
//
517
always @(posedge clk or posedge rst) begin
518
        if (rst)
519 258 julius
                id_insn <=  {`OR1200_OR32_NOP, 26'h041_0000};
520 141 marcus.erl
        else if (id_flushpipe)
521 258 julius
                id_insn <=  {`OR1200_OR32_NOP, 26'h041_0000};        // NOP -> id_insn[16] must be 1
522 10 unneback
        else if (!id_freeze) begin
523 258 julius
                id_insn <=  if_insn;
524 10 unneback
`ifdef OR1200_VERBOSE
525
// synopsys translate_off
526
                $display("%t: id_insn <= %h", $time, if_insn);
527
// synopsys translate_on
528
`endif
529
        end
530
end
531
 
532
//
533
// Instruction latch in ex_insn
534
//
535
always @(posedge clk or posedge rst) begin
536
        if (rst)
537 258 julius
                ex_insn <=  {`OR1200_OR32_NOP, 26'h041_0000};
538 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
539 258 julius
                ex_insn <=  {`OR1200_OR32_NOP, 26'h041_0000};   // NOP -> ex_insn[16] must be 1
540 10 unneback
        else if (!ex_freeze) begin
541 258 julius
                ex_insn <=  id_insn;
542 10 unneback
`ifdef OR1200_VERBOSE
543
// synopsys translate_off
544
                $display("%t: ex_insn <= %h", $time, id_insn);
545
// synopsys translate_on
546
`endif
547
        end
548
end
549 258 julius
 
550 10 unneback
//
551
// Instruction latch in wb_insn
552
//
553
always @(posedge clk or posedge rst) begin
554
        if (rst)
555 258 julius
                wb_insn <=  {`OR1200_OR32_NOP, 26'h041_0000};
556 141 marcus.erl
        // wb_insn should not be changed by exceptions due to correct 
557
        // recording of display_arch_state in the or1200_monitor! 
558
        // wb_insn changed by exception is not used elsewhere! 
559 10 unneback
        else if (!wb_freeze) begin
560 258 julius
                wb_insn <=  ex_insn;
561 10 unneback
        end
562
end
563
 
564
//
565
// Decode of sel_imm
566
//
567
always @(posedge clk or posedge rst) begin
568
        if (rst)
569 258 julius
                sel_imm <=  1'b0;
570 10 unneback
        else if (!id_freeze) begin
571
          case (if_insn[31:26])         // synopsys parallel_case
572
 
573
            // j.jalr
574
            `OR1200_OR32_JALR:
575 258 julius
              sel_imm <=  1'b0;
576 10 unneback
 
577
            // l.jr
578
            `OR1200_OR32_JR:
579 258 julius
              sel_imm <=  1'b0;
580 10 unneback
 
581
            // l.rfe
582
            `OR1200_OR32_RFE:
583 258 julius
              sel_imm <=  1'b0;
584 10 unneback
 
585
            // l.mfspr
586
            `OR1200_OR32_MFSPR:
587 258 julius
              sel_imm <=  1'b0;
588 10 unneback
 
589
            // l.mtspr
590
            `OR1200_OR32_MTSPR:
591 258 julius
              sel_imm <=  1'b0;
592 10 unneback
 
593
            // l.sys, l.brk and all three sync insns
594
            `OR1200_OR32_XSYNC:
595 258 julius
              sel_imm <=  1'b0;
596 10 unneback
 
597
            // l.mac/l.msb
598
`ifdef OR1200_MAC_IMPLEMENTED
599
            `OR1200_OR32_MACMSB:
600 258 julius
              sel_imm <=  1'b0;
601 10 unneback
`endif
602
 
603
            // l.sw
604
            `OR1200_OR32_SW:
605 258 julius
              sel_imm <=  1'b0;
606 10 unneback
 
607
            // l.sb
608
            `OR1200_OR32_SB:
609 258 julius
              sel_imm <=  1'b0;
610 10 unneback
 
611
            // l.sh
612
            `OR1200_OR32_SH:
613 258 julius
              sel_imm <=  1'b0;
614 10 unneback
 
615
            // ALU instructions except the one with immediate
616
            `OR1200_OR32_ALU:
617 258 julius
              sel_imm <=  1'b0;
618 10 unneback
 
619
            // SFXX instructions
620
            `OR1200_OR32_SFXX:
621 258 julius
              sel_imm <=  1'b0;
622 10 unneback
 
623
`ifdef OR1200_OR32_CUST5
624
            // l.cust5 instructions
625
            `OR1200_OR32_CUST5:
626 258 julius
              sel_imm <=  1'b0;
627 10 unneback
`endif
628 185 julius
`ifdef OR1200_FPU_IMPLEMENTED
629
            // FPU instructions
630
            `OR1200_OR32_FLOAT:
631 258 julius
              sel_imm <=  1'b0;
632 185 julius
`endif
633 10 unneback
            // l.nop
634
            `OR1200_OR32_NOP:
635 258 julius
              sel_imm <=  1'b0;
636 10 unneback
 
637
            // All instructions with immediates
638
            default: begin
639 258 julius
              sel_imm <=  1'b1;
640 10 unneback
            end
641
 
642
          endcase
643
 
644
        end
645
end
646
 
647
//
648
// Decode of except_illegal
649
//
650
always @(posedge clk or posedge rst) begin
651
        if (rst)
652 258 julius
                except_illegal <=  1'b0;
653 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
654 258 julius
                except_illegal <=  1'b0;
655 10 unneback
        else if (!ex_freeze) begin
656 141 marcus.erl
                case (id_insn[31:26])           // synopsys parallel_case
657 10 unneback
 
658 141 marcus.erl
                `OR1200_OR32_J,
659
                `OR1200_OR32_JAL,
660
                `OR1200_OR32_JALR,
661
                `OR1200_OR32_JR,
662
                `OR1200_OR32_BNF,
663
                `OR1200_OR32_BF,
664
                `OR1200_OR32_RFE,
665
                `OR1200_OR32_MOVHI,
666
                `OR1200_OR32_MFSPR,
667
                `OR1200_OR32_XSYNC,
668 10 unneback
`ifdef OR1200_MAC_IMPLEMENTED
669 141 marcus.erl
                `OR1200_OR32_MACI,
670 10 unneback
`endif
671 141 marcus.erl
                `OR1200_OR32_LWZ,
672
                `OR1200_OR32_LBZ,
673
                `OR1200_OR32_LBS,
674
                `OR1200_OR32_LHZ,
675
                `OR1200_OR32_LHS,
676
                `OR1200_OR32_ADDI,
677
                `OR1200_OR32_ADDIC,
678
                `OR1200_OR32_ANDI,
679
                `OR1200_OR32_ORI,
680
                `OR1200_OR32_XORI,
681 10 unneback
`ifdef OR1200_MULT_IMPLEMENTED
682 141 marcus.erl
                `OR1200_OR32_MULI,
683 10 unneback
`endif
684 141 marcus.erl
                `OR1200_OR32_SH_ROTI,
685
                `OR1200_OR32_SFXXI,
686
                `OR1200_OR32_MTSPR,
687 10 unneback
`ifdef OR1200_MAC_IMPLEMENTED
688 141 marcus.erl
                `OR1200_OR32_MACMSB,
689 10 unneback
`endif
690 141 marcus.erl
                `OR1200_OR32_SW,
691
                `OR1200_OR32_SB,
692
                `OR1200_OR32_SH,
693
                `OR1200_OR32_SFXX,
694 10 unneback
`ifdef OR1200_OR32_CUST5
695 141 marcus.erl
                `OR1200_OR32_CUST5,
696 10 unneback
`endif
697 141 marcus.erl
        `OR1200_OR32_NOP:
698 258 julius
                        except_illegal <=  1'b0;
699 185 julius
`ifdef OR1200_FPU_IMPLEMENTED
700
            `OR1200_OR32_FLOAT:
701
                        // Check it's not a double precision instruction
702 258 julius
                        except_illegal <=  id_insn[`OR1200_FPUOP_DOUBLE_BIT];
703 185 julius
`endif
704 10 unneback
 
705 141 marcus.erl
        `OR1200_OR32_ALU:
706 258 julius
                        except_illegal <=  1'b0
707 10 unneback
 
708 141 marcus.erl
`ifdef OR1200_MULT_IMPLEMENTED
709 258 julius
`ifdef OR1200_DIV_IMPLEMENTED
710 141 marcus.erl
`else
711
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_DIV)
712
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_DIVU)
713
`endif
714
`else
715
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_DIV)
716
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_DIVU)
717
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_MUL)
718
`endif
719
 
720
`ifdef OR1200_IMPL_ADDC
721
`else
722
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_ADDC)
723
`endif
724
 
725
`ifdef OR1200_IMPL_ALU_ROTATE
726
`else
727
                                | (({1'b0, id_insn[3:0]} == `OR1200_ALUOP_SHROT) && (id_insn[7:6] == `OR1200_SHROTOP_ROR))
728
`endif
729
 
730
`ifdef OR1200_IMPL_SUB
731
`else
732
                                | ({1'b0, id_insn[3:0]} == `OR1200_ALUOP_SUB)
733
`endif
734
                                ;
735
 
736
                // Illegal and OR1200 unsupported instructions
737
                default:
738 258 julius
                        except_illegal <=  1'b1;
739 141 marcus.erl
 
740
                endcase
741 10 unneback
 
742
        end
743
end
744
 
745
//
746
// Decode of alu_op
747
//
748
always @(posedge clk or posedge rst) begin
749
        if (rst)
750 258 julius
                alu_op <=  `OR1200_ALUOP_NOP;
751 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
752 258 julius
                alu_op <=  `OR1200_ALUOP_NOP;
753 10 unneback
        else if (!ex_freeze) begin
754
          case (id_insn[31:26])         // synopsys parallel_case
755
 
756
            // l.movhi
757
            `OR1200_OR32_MOVHI:
758 258 julius
              alu_op <=  `OR1200_ALUOP_MOVHI;
759 10 unneback
 
760
            // l.addi
761
            `OR1200_OR32_ADDI:
762 258 julius
              alu_op <=  `OR1200_ALUOP_ADD;
763 10 unneback
 
764
            // l.addic
765
            `OR1200_OR32_ADDIC:
766 258 julius
              alu_op <=  `OR1200_ALUOP_ADDC;
767 10 unneback
 
768
            // l.andi
769
            `OR1200_OR32_ANDI:
770 258 julius
              alu_op <=  `OR1200_ALUOP_AND;
771 10 unneback
 
772
            // l.ori
773
            `OR1200_OR32_ORI:
774 258 julius
              alu_op <=  `OR1200_ALUOP_OR;
775 10 unneback
 
776
            // l.xori
777
            `OR1200_OR32_XORI:
778 258 julius
              alu_op <=  `OR1200_ALUOP_XOR;
779 10 unneback
 
780
            // l.muli
781
`ifdef OR1200_MULT_IMPLEMENTED
782
            `OR1200_OR32_MULI:
783 258 julius
              alu_op <=  `OR1200_ALUOP_MUL;
784 10 unneback
`endif
785
 
786
            // Shift and rotate insns with immediate
787
            `OR1200_OR32_SH_ROTI:
788 258 julius
              alu_op <=  `OR1200_ALUOP_SHROT;
789 10 unneback
 
790
            // SFXX insns with immediate
791
            `OR1200_OR32_SFXXI:
792 258 julius
              alu_op <=  `OR1200_ALUOP_COMP;
793 10 unneback
 
794
            // ALU instructions except the one with immediate
795
            `OR1200_OR32_ALU:
796 258 julius
              alu_op <=  id_insn[3:0];
797 10 unneback
 
798
            // SFXX instructions
799
            `OR1200_OR32_SFXX:
800 258 julius
              alu_op <=  `OR1200_ALUOP_COMP;
801 10 unneback
 
802
`ifdef OR1200_OR32_CUST5
803
            // l.cust5 instructions
804
            `OR1200_OR32_CUST5:
805 258 julius
              alu_op <=  `OR1200_ALUOP_CUST5;
806 10 unneback
`endif
807
 
808
            // Default
809
            default: begin
810 258 julius
              alu_op <=  `OR1200_ALUOP_NOP;
811 10 unneback
            end
812
 
813
          endcase
814
 
815
        end
816
end
817
 
818
//
819 141 marcus.erl
// Decode of spr_read, spr_write
820
//
821
always @(posedge clk or posedge rst) begin
822
        if (rst) begin
823 258 julius
                spr_read <=  1'b0;
824
                spr_write <=  1'b0;
825 141 marcus.erl
        end
826
        else if (!ex_freeze & id_freeze | ex_flushpipe) begin
827 258 julius
                spr_read <=  1'b0;
828
                spr_write <=  1'b0;
829 141 marcus.erl
        end
830
        else if (!ex_freeze) begin
831
                case (id_insn[31:26])     // synopsys parallel_case
832
 
833
                // l.mfspr
834
                `OR1200_OR32_MFSPR: begin
835 258 julius
                        spr_read <=  1'b1;
836
                        spr_write <=  1'b0;
837 141 marcus.erl
                end
838
 
839
                // l.mtspr
840
                `OR1200_OR32_MTSPR: begin
841 258 julius
                        spr_read <=  1'b0;
842
                        spr_write <=  1'b1;
843 141 marcus.erl
                end
844
 
845
                // Default
846
                default: begin
847 258 julius
                        spr_read <=  1'b0;
848
                        spr_write <=  1'b0;
849 141 marcus.erl
                end
850
 
851
                endcase
852
        end
853
end
854
 
855
//
856 10 unneback
// Decode of mac_op
857
//
858
`ifdef OR1200_MAC_IMPLEMENTED
859 141 marcus.erl
always @(id_insn) begin
860
        case (id_insn[31:26])           // synopsys parallel_case
861 10 unneback
 
862 141 marcus.erl
        // l.maci
863
        `OR1200_OR32_MACI:
864 258 julius
                id_mac_op <=  `OR1200_MACOP_MAC;
865 10 unneback
 
866 141 marcus.erl
        // l.mac, l.msb
867
        `OR1200_OR32_MACMSB:
868 258 julius
                id_mac_op <=  id_insn[2:0];
869 10 unneback
 
870 141 marcus.erl
        // Illegal and OR1200 unsupported instructions
871
        default:
872 258 julius
                id_mac_op <=  `OR1200_MACOP_NOP;
873 10 unneback
 
874 141 marcus.erl
        endcase
875 10 unneback
end
876 141 marcus.erl
 
877
always @(posedge clk or posedge rst) begin
878
        if (rst)
879 258 julius
                ex_mac_op <=  `OR1200_MACOP_NOP;
880 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
881 258 julius
                ex_mac_op <=  `OR1200_MACOP_NOP;
882 141 marcus.erl
        else if (!ex_freeze)
883 258 julius
                ex_mac_op <=  id_mac_op;
884 141 marcus.erl
end
885
 
886
assign mac_op = abort_mvspr ? `OR1200_MACOP_NOP : ex_mac_op;
887 10 unneback
`else
888 141 marcus.erl
assign id_mac_op = `OR1200_MACOP_NOP;
889 10 unneback
assign mac_op = `OR1200_MACOP_NOP;
890
`endif
891
 
892
//
893
// Decode of shrot_op
894
//
895
always @(posedge clk or posedge rst) begin
896
        if (rst)
897 258 julius
                shrot_op <=  `OR1200_SHROTOP_NOP;
898 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
899 258 julius
                shrot_op <=  `OR1200_SHROTOP_NOP;
900 10 unneback
        else if (!ex_freeze) begin
901 258 julius
                shrot_op <=  id_insn[`OR1200_SHROTOP_POS];
902 10 unneback
        end
903
end
904
 
905
//
906
// Decode of rfwb_op
907
//
908
always @(posedge clk or posedge rst) begin
909
        if (rst)
910 258 julius
                rfwb_op <=  `OR1200_RFWBOP_NOP;
911 141 marcus.erl
        else  if (!ex_freeze & id_freeze | ex_flushpipe)
912 258 julius
                rfwb_op <=  `OR1200_RFWBOP_NOP;
913 10 unneback
        else  if (!ex_freeze) begin
914
                case (id_insn[31:26])           // synopsys parallel_case
915
 
916 141 marcus.erl
                // j.jal
917
                `OR1200_OR32_JAL:
918 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LR, 1'b1};
919 10 unneback
 
920 141 marcus.erl
                // j.jalr
921
                `OR1200_OR32_JALR:
922 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LR, 1'b1};
923 10 unneback
 
924 141 marcus.erl
                // l.movhi
925
                `OR1200_OR32_MOVHI:
926 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
927 10 unneback
 
928 141 marcus.erl
                // l.mfspr
929
                `OR1200_OR32_MFSPR:
930 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_SPRS, 1'b1};
931 10 unneback
 
932 141 marcus.erl
                // l.lwz
933
                `OR1200_OR32_LWZ:
934 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
935 10 unneback
 
936 141 marcus.erl
                // l.lbz
937
                `OR1200_OR32_LBZ:
938 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
939 10 unneback
 
940 141 marcus.erl
                // l.lbs
941
                `OR1200_OR32_LBS:
942 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
943 10 unneback
 
944 141 marcus.erl
                // l.lhz
945
                `OR1200_OR32_LHZ:
946 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
947 10 unneback
 
948 141 marcus.erl
                // l.lhs
949
                `OR1200_OR32_LHS:
950 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
951 10 unneback
 
952 141 marcus.erl
                // l.addi
953
                `OR1200_OR32_ADDI:
954 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
955 10 unneback
 
956 141 marcus.erl
                // l.addic
957
                `OR1200_OR32_ADDIC:
958 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
959 10 unneback
 
960 141 marcus.erl
                // l.andi
961
                `OR1200_OR32_ANDI:
962 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
963 10 unneback
 
964 141 marcus.erl
                // l.ori
965
                `OR1200_OR32_ORI:
966 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
967 10 unneback
 
968 141 marcus.erl
                // l.xori
969
                `OR1200_OR32_XORI:
970 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
971 10 unneback
 
972 141 marcus.erl
                // l.muli
973 10 unneback
`ifdef OR1200_MULT_IMPLEMENTED
974 141 marcus.erl
                `OR1200_OR32_MULI:
975 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
976 10 unneback
`endif
977
 
978 141 marcus.erl
                // Shift and rotate insns with immediate
979
                `OR1200_OR32_SH_ROTI:
980 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
981 10 unneback
 
982 141 marcus.erl
                // ALU instructions except the one with immediate
983
                `OR1200_OR32_ALU:
984 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
985 10 unneback
 
986
`ifdef OR1200_OR32_CUST5
987 141 marcus.erl
                // l.cust5 instructions
988
                `OR1200_OR32_CUST5:
989 258 julius
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
990 10 unneback
`endif
991 185 julius
`ifdef OR1200_FPU_IMPLEMENTED
992
                  // FPU instructions, lf.XXX.s, except sfxx
993
                  `OR1200_OR32_FLOAT:
994 258 julius
                    rfwb_op <=  {`OR1200_RFWBOP_FPU,!id_insn[3]};
995 185 julius
`endif
996 141 marcus.erl
                // Instructions w/o register-file write-back
997
                default:
998 258 julius
                        rfwb_op <=  `OR1200_RFWBOP_NOP;
999 10 unneback
 
1000 141 marcus.erl
 
1001 10 unneback
                endcase
1002
        end
1003
end
1004
 
1005
//
1006 141 marcus.erl
// Decode of id_branch_op
1007 10 unneback
//
1008
always @(posedge clk or posedge rst) begin
1009
        if (rst)
1010 258 julius
                id_branch_op <=  `OR1200_BRANCHOP_NOP;
1011 141 marcus.erl
        else if (id_flushpipe)
1012 258 julius
                id_branch_op <=  `OR1200_BRANCHOP_NOP;
1013 10 unneback
        else if (!id_freeze) begin
1014
                case (if_insn[31:26])           // synopsys parallel_case
1015 141 marcus.erl
 
1016
                // l.j
1017
                `OR1200_OR32_J:
1018 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_J;
1019 10 unneback
 
1020 141 marcus.erl
                // j.jal
1021
                `OR1200_OR32_JAL:
1022 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_J;
1023 10 unneback
 
1024 141 marcus.erl
                // j.jalr
1025
                `OR1200_OR32_JALR:
1026 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_JR;
1027 10 unneback
 
1028 141 marcus.erl
                // l.jr
1029
                `OR1200_OR32_JR:
1030 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_JR;
1031 10 unneback
 
1032 141 marcus.erl
                // l.bnf
1033
                `OR1200_OR32_BNF:
1034 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_BNF;
1035 10 unneback
 
1036 141 marcus.erl
                // l.bf
1037
                `OR1200_OR32_BF:
1038 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_BF;
1039 10 unneback
 
1040 141 marcus.erl
                // l.rfe
1041
                `OR1200_OR32_RFE:
1042 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_RFE;
1043 10 unneback
 
1044 141 marcus.erl
                // Non branch instructions
1045
                default:
1046 258 julius
                        id_branch_op <=  `OR1200_BRANCHOP_NOP;
1047 141 marcus.erl
 
1048 10 unneback
                endcase
1049
        end
1050
end
1051
 
1052
//
1053 141 marcus.erl
// Generation of ex_branch_op
1054 10 unneback
//
1055
always @(posedge clk or posedge rst)
1056
        if (rst)
1057 258 julius
                ex_branch_op <=  `OR1200_BRANCHOP_NOP;
1058 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
1059 258 julius
                ex_branch_op <=  `OR1200_BRANCHOP_NOP;
1060 10 unneback
        else if (!ex_freeze)
1061 258 julius
                ex_branch_op <=  id_branch_op;
1062 10 unneback
 
1063
//
1064 141 marcus.erl
// Decode of id_lsu_op
1065 10 unneback
//
1066 141 marcus.erl
always @(id_insn) begin
1067
        case (id_insn[31:26])           // synopsys parallel_case
1068
 
1069
        // l.lwz
1070
        `OR1200_OR32_LWZ:
1071 258 julius
                id_lsu_op <=  `OR1200_LSUOP_LWZ;
1072 141 marcus.erl
 
1073
        // l.lbz
1074
        `OR1200_OR32_LBZ:
1075 258 julius
                id_lsu_op <=  `OR1200_LSUOP_LBZ;
1076 141 marcus.erl
 
1077
        // l.lbs
1078
        `OR1200_OR32_LBS:
1079 258 julius
                id_lsu_op <=  `OR1200_LSUOP_LBS;
1080 141 marcus.erl
 
1081
        // l.lhz
1082
        `OR1200_OR32_LHZ:
1083 258 julius
                id_lsu_op <=  `OR1200_LSUOP_LHZ;
1084 141 marcus.erl
 
1085
        // l.lhs
1086
        `OR1200_OR32_LHS:
1087 258 julius
                id_lsu_op <=  `OR1200_LSUOP_LHS;
1088 141 marcus.erl
 
1089
        // l.sw
1090
        `OR1200_OR32_SW:
1091 258 julius
                id_lsu_op <=  `OR1200_LSUOP_SW;
1092 141 marcus.erl
 
1093
        // l.sb
1094
        `OR1200_OR32_SB:
1095 258 julius
                id_lsu_op <=  `OR1200_LSUOP_SB;
1096 141 marcus.erl
 
1097
        // l.sh
1098
        `OR1200_OR32_SH:
1099 258 julius
                id_lsu_op <=  `OR1200_LSUOP_SH;
1100 141 marcus.erl
 
1101
        // Non load/store instructions
1102
        default:
1103 258 julius
                id_lsu_op <=  `OR1200_LSUOP_NOP;
1104 141 marcus.erl
 
1105
        endcase
1106 10 unneback
end
1107
 
1108
//
1109
// Decode of comp_op
1110
//
1111
always @(posedge clk or posedge rst) begin
1112
        if (rst) begin
1113 258 julius
                comp_op <=  4'd0;
1114 141 marcus.erl
        end else if (!ex_freeze & id_freeze | ex_flushpipe)
1115 258 julius
                comp_op <=  4'd0;
1116 10 unneback
        else if (!ex_freeze)
1117 258 julius
                comp_op <=  id_insn[24:21];
1118 10 unneback
end
1119
 
1120 185 julius
`ifdef OR1200_FPU_IMPLEMENTED
1121 10 unneback
//
1122 185 julius
// Decode of FPU ops
1123
//
1124 258 julius
   assign fpu_op = {(id_insn[31:26] == `OR1200_OR32_FLOAT),
1125
                    id_insn[`OR1200_FPUOP_WIDTH-2:0]};
1126 185 julius
`else
1127
   assign fpu_op = {`OR1200_FPUOP_WIDTH{1'b0}};
1128
`endif
1129
 
1130
 
1131
//
1132 10 unneback
// Decode of l.sys
1133
//
1134
always @(posedge clk or posedge rst) begin
1135
        if (rst)
1136 258 julius
                sig_syscall <=  1'b0;
1137 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
1138 258 julius
                sig_syscall <=  1'b0;
1139 10 unneback
        else if (!ex_freeze) begin
1140
`ifdef OR1200_VERBOSE
1141
// synopsys translate_off
1142
                if (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b000})
1143
                        $display("Generating sig_syscall");
1144
// synopsys translate_on
1145
`endif
1146 258 julius
                sig_syscall <=  (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b000});
1147 10 unneback
        end
1148
end
1149
 
1150
//
1151
// Decode of l.trap
1152
//
1153
always @(posedge clk or posedge rst) begin
1154
        if (rst)
1155 258 julius
                sig_trap <=  1'b0;
1156 141 marcus.erl
        else if (!ex_freeze & id_freeze | ex_flushpipe)
1157 258 julius
                sig_trap <=  1'b0;
1158 10 unneback
        else if (!ex_freeze) begin
1159
`ifdef OR1200_VERBOSE
1160
// synopsys translate_off
1161
                if (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b010})
1162
                        $display("Generating sig_trap");
1163
// synopsys translate_on
1164
`endif
1165 258 julius
                sig_trap <=  (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b010})
1166 10 unneback
                        | du_hwbkpt;
1167
        end
1168
end
1169
 
1170 258 julius
// Decode destination register address for data cache to check if store ops
1171
// are being done from the stack register (r1) or frame pointer register (r2)
1172
`ifdef OR1200_DC_NOSTACKWRITETHROUGH
1173
always @(posedge clk or posedge rst) begin
1174
   if (rst)
1175
     dc_no_writethrough <= 0;
1176
   else if (!ex_freeze)
1177
     dc_no_writethrough <= (id_insn[20:16] == 5'd1) | (id_insn[20:16] == 5'd2);
1178
end
1179
`else
1180
 
1181
   assign dc_no_writethrough = 0;
1182
 
1183
`endif
1184
 
1185 10 unneback
endmodule

powered by: WebSVN 2.1.0

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