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 522

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

powered by: WebSVN 2.1.0

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