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 363

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

powered by: WebSVN 2.1.0

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