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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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