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

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

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [or1200/] [verilog/] [src/] [or1200_ctrl.v] - Blame information for rev 38

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 alirezamon
//////////////////////////////////////////////////////////////////////
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, alu_op2, mac_op,
66
   comp_op, 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, du_flush_pipe,
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
input                                   ex_freeze /* verilator public */;
83
input                                   wb_freeze /* verilator public */;
84
output                                  if_flushpipe;
85
output                                  id_flushpipe;
86
output                                  ex_flushpipe;
87
output                                  wb_flushpipe;
88
input                                   extend_flush;
89
input                                   except_flushpipe;
90
input                           abort_mvspr ;
91
input   [31:0]                   if_insn;
92
output  [31:0]                   id_insn;
93
output  [31:0]                   ex_insn /* verilator public */;
94
output  [`OR1200_BRANCHOP_WIDTH-1:0]             ex_branch_op;
95
output  [`OR1200_BRANCHOP_WIDTH-1:0]             id_branch_op;
96
input                                           ex_branch_taken;
97
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_ALUOP2_WIDTH-1:0]                alu_op2;
104
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
input                                   du_flush_pipe;
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
reg [`OR1200_ALUOP2_WIDTH-1:0]                   alu_op2;
148
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
reg     [31:0]                           id_insn /* verilator public */;
159
reg     [31:0]                           ex_insn /* verilator public */;
160
reg     [31:0]                           wb_insn /* verilator public */;
161
reg     [`OR1200_REGFILE_ADDR_WIDTH-1:0] rf_addrw;
162
reg     [`OR1200_REGFILE_ADDR_WIDTH-1:0] wb_rfaddrw;
163
reg     [`OR1200_RFWBOP_WIDTH-1:0]               rfwb_op;
164
reg     [`OR1200_SEL_WIDTH-1:0]          sel_a;
165
reg     [`OR1200_SEL_WIDTH-1:0]          sel_b;
166
reg                                     sel_imm;
167
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 
198
// load/store instructions
199
//
200
assign force_dslot_fetch = 1'b0;
201
assign no_more_dslot = (|ex_branch_op & !id_void & ex_branch_taken) |
202
                       (ex_branch_op == `OR1200_BRANCHOP_RFE);
203
 
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
// ex_delayslot_nop: (filler) nop insn is in EX stage (before nops 
214
//                   jump/branch was executed)
215
//
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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
222
        if (rst == `OR1200_RST_VALUE) begin
223
                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
                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
        end
242
end
243
 
244
//
245
// Flush pipeline
246
//
247
assign if_flushpipe = except_flushpipe | pc_we | extend_flush | du_flush_pipe;
248
assign id_flushpipe = except_flushpipe | pc_we | extend_flush | du_flush_pipe;
249
assign ex_flushpipe = except_flushpipe | pc_we | extend_flush | du_flush_pipe;
250
assign wb_flushpipe = except_flushpipe | pc_we | extend_flush | du_flush_pipe;
251
 
252
//
253
// EX Sign/Zero extension of immediates
254
//
255
always @(posedge clk or `OR1200_RST_EVENT rst) begin
256
        if (rst == `OR1200_RST_VALUE)
257
                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
        `OR1200_OR32_LWZ, `OR1200_OR32_LWS,
279
   `OR1200_OR32_LBZ, `OR1200_OR32_LBS,
280
        `OR1200_OR32_LHZ, `OR1200_OR32_LHS:
281
                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
                id_simm = {{16{id_insn[15]}}, id_insn[15:0]};
293
        `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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
329
        if (rst == `OR1200_RST_VALUE)
330
                ex_branch_addrtarget <=  0;
331
        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
assign id_macrc_op = (id_insn[31:26] == `OR1200_OR32_MACRC) & id_insn[16];
351
`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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
360
        if (rst == `OR1200_RST_VALUE)
361
                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
assign rfe = (id_branch_op == `OR1200_BRANCHOP_RFE) |
381
             (ex_branch_op == `OR1200_BRANCHOP_RFE);
382
 
383
 
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
//
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
always @(rf_addrw or sel_imm or id_insn or rfwb_op or wbforw_valid or
427
         wb_rfaddrw)
428
        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
    // l.rfe
443
    `OR1200_OR32_RFE,
444
    // 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
     `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
`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
`ifndef OR1200_DC_WRITEHROUGH
489
     // l.mtspr
490
     `OR1200_OR32_MTSPR: begin
491
        wait_on = `OR1200_WAIT_ON_MTSPR;
492
     end
493
`endif
494
     default: begin
495
        wait_on = `OR1200_WAIT_ON_NOTHING;
496
     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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
507
        if (rst == `OR1200_RST_VALUE)
508
                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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
524
        if (rst == `OR1200_RST_VALUE)
525
                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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
534
        if (rst == `OR1200_RST_VALUE)
535
                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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
552
        if (rst == `OR1200_RST_VALUE)
553
                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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
570
        if (rst == `OR1200_RST_VALUE)
571
                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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
584
        if (rst == `OR1200_RST_VALUE)
585
                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
`ifdef OR1200_IMPL_ALU_CUST5
640
            // 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
always @(posedge clk or `OR1200_RST_EVENT rst) begin
667
        if (rst == `OR1200_RST_VALUE)
668
                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
                `OR1200_OR32_LWS,
689
                `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
`ifdef OR1200_IMPL_ALU_ROTATE
702
                `OR1200_OR32_SH_ROTI,
703
`endif
704
                `OR1200_OR32_SFXXI,
705
                `OR1200_OR32_MTSPR,
706
`ifdef OR1200_MAC_IMPLEMENTED
707
                `OR1200_OR32_MACMSB,
708
`endif
709
                `OR1200_OR32_SW,
710
                `OR1200_OR32_SB,
711
                `OR1200_OR32_SH,
712
                `OR1200_OR32_SFXX,
713
`ifdef OR1200_IMPL_ALU_CUST5
714
                `OR1200_OR32_CUST5,
715
`endif
716
        `OR1200_OR32_NOP:
717
                except_illegal <=  1'b0;
718
`ifdef OR1200_FPU_IMPLEMENTED
719
            `OR1200_OR32_FLOAT:
720
                // Check it's not a double precision instruction
721
                except_illegal <=  id_insn[`OR1200_FPUOP_DOUBLE_BIT];
722
`endif
723
 
724
        `OR1200_OR32_ALU:
725
                except_illegal <=  1'b0
726
 
727
`ifdef OR1200_MULT_IMPLEMENTED
728
`ifdef OR1200_DIV_IMPLEMENTED
729
`else
730
                | (id_insn[4:0] == `OR1200_ALUOP_DIV)
731
                | (id_insn[4:0] == `OR1200_ALUOP_DIVU)
732
`endif
733
`else
734
                | (id_insn[4:0] == `OR1200_ALUOP_DIV)
735
                | (id_insn[4:0] == `OR1200_ALUOP_DIVU)
736
                | (id_insn[4:0] == `OR1200_ALUOP_MUL)
737
`endif
738
 
739
`ifdef OR1200_IMPL_ADDC
740
`else
741
                | (id_insn[4:0] == `OR1200_ALUOP_ADDC)
742
`endif
743
 
744
`ifdef OR1200_IMPL_ALU_FFL1
745
`else
746
                | (id_insn[4:0] == `OR1200_ALUOP_FFL1)
747
`endif
748
 
749
`ifdef OR1200_IMPL_ALU_ROTATE
750
`else
751
                | ((id_insn[4:0] == `OR1200_ALUOP_SHROT) &
752
                   (id_insn[9:6] == `OR1200_SHROTOP_ROR))
753
`endif
754
 
755
`ifdef OR1200_IMPL_SUB
756
`else
757
                | (id_insn[4:0] == `OR1200_ALUOP_SUB)
758
`endif
759
`ifdef OR1200_IMPL_ALU_EXT
760
`else
761
                | (id_insn[4:0] == `OR1200_ALUOP_EXTHB)
762
                | (id_insn[4:0] == `OR1200_ALUOP_EXTW)
763
`endif
764
                ;
765
 
766
                // Illegal and OR1200 unsupported instructions
767
        default:
768
                except_illegal <=  1'b1;
769
 
770
        endcase
771
        end // if (!ex_freeze)
772
end
773
 
774
 
775
//
776
// Decode of alu_op
777
//
778
always @(posedge clk or `OR1200_RST_EVENT rst) begin
779
        if (rst == `OR1200_RST_VALUE)
780
                alu_op <=  `OR1200_ALUOP_NOP;
781
        else if (!ex_freeze & id_freeze | ex_flushpipe)
782
                alu_op <=  `OR1200_ALUOP_NOP;
783
        else if (!ex_freeze) begin
784
          case (id_insn[31:26])         // synopsys parallel_case
785
 
786
            // l.movhi
787
            `OR1200_OR32_MOVHI:
788
              alu_op <=  `OR1200_ALUOP_MOVHI;
789
 
790
            // l.addi
791
            `OR1200_OR32_ADDI:
792
              alu_op <=  `OR1200_ALUOP_ADD;
793
 
794
            // l.addic
795
            `OR1200_OR32_ADDIC:
796
              alu_op <=  `OR1200_ALUOP_ADDC;
797
 
798
            // l.andi
799
            `OR1200_OR32_ANDI:
800
              alu_op <=  `OR1200_ALUOP_AND;
801
 
802
            // l.ori
803
            `OR1200_OR32_ORI:
804
              alu_op <=  `OR1200_ALUOP_OR;
805
 
806
            // l.xori
807
            `OR1200_OR32_XORI:
808
              alu_op <=  `OR1200_ALUOP_XOR;
809
 
810
            // l.muli
811
`ifdef OR1200_MULT_IMPLEMENTED
812
            `OR1200_OR32_MULI:
813
              alu_op <=  `OR1200_ALUOP_MUL;
814
`endif
815
`ifdef OR1200_IMPL_ALU_ROTATE
816
            // Shift and rotate insns with immediate
817
            `OR1200_OR32_SH_ROTI:
818
              alu_op <=  `OR1200_ALUOP_SHROT;
819
`endif
820
            // SFXX insns with immediate
821
            `OR1200_OR32_SFXXI:
822
              alu_op <=  `OR1200_ALUOP_COMP;
823
 
824
            // ALU instructions except the one with immediate
825
            `OR1200_OR32_ALU:
826
              alu_op <=  {1'b0,id_insn[3:0]};
827
 
828
            // SFXX instructions
829
            `OR1200_OR32_SFXX:
830
              alu_op <=  `OR1200_ALUOP_COMP;
831
`ifdef OR1200_IMPL_ALU_CUST5
832
            // l.cust5
833
            `OR1200_OR32_CUST5:
834
              alu_op <=  `OR1200_ALUOP_CUST5;
835
`endif
836
            // Default
837
            default: begin
838
              alu_op <=  `OR1200_ALUOP_NOP;
839
            end
840
 
841
          endcase
842
 
843
        end
844
end
845
 
846
 
847
//
848
// Decode of second ALU operation field [9:6]
849
//
850
always @(posedge clk or `OR1200_RST_EVENT rst) begin
851
        if (rst == `OR1200_RST_VALUE)
852
                alu_op2 <=  0;
853
        else if (!ex_freeze & id_freeze | ex_flushpipe)
854
                alu_op2 <= 0;
855
        else if (!ex_freeze) begin
856
                alu_op2 <=  id_insn[`OR1200_ALUOP2_POS];
857
        end
858
end
859
 
860
//
861
// Decode of spr_read, spr_write
862
//
863
always @(posedge clk or `OR1200_RST_EVENT rst) begin
864
        if (rst == `OR1200_RST_VALUE) begin
865
                spr_read <=  1'b0;
866
                spr_write <=  1'b0;
867
        end
868
        else if (!ex_freeze & id_freeze | ex_flushpipe) begin
869
                spr_read <=  1'b0;
870
                spr_write <=  1'b0;
871
        end
872
        else if (!ex_freeze) begin
873
                case (id_insn[31:26])     // synopsys parallel_case
874
 
875
                // l.mfspr
876
                `OR1200_OR32_MFSPR: begin
877
                        spr_read <=  1'b1;
878
                        spr_write <=  1'b0;
879
                end
880
 
881
                // l.mtspr
882
                `OR1200_OR32_MTSPR: begin
883
                        spr_read <=  1'b0;
884
                        spr_write <=  1'b1;
885
                end
886
 
887
                // Default
888
                default: begin
889
                        spr_read <=  1'b0;
890
                        spr_write <=  1'b0;
891
                end
892
 
893
                endcase
894
        end
895
end
896
 
897
//
898
// Decode of mac_op
899
//
900
`ifdef OR1200_MAC_IMPLEMENTED
901
always @(id_insn) begin
902
        case (id_insn[31:26])           // synopsys parallel_case
903
 
904
        // l.maci
905
        `OR1200_OR32_MACI:
906
                id_mac_op =  `OR1200_MACOP_MAC;
907
 
908
        // l.mac, l.msb
909
        `OR1200_OR32_MACMSB:
910
                id_mac_op =  id_insn[2:0];
911
 
912
        // Illegal and OR1200 unsupported instructions
913
        default:
914
                id_mac_op =  `OR1200_MACOP_NOP;
915
 
916
        endcase
917
end
918
 
919
always @(posedge clk or `OR1200_RST_EVENT rst) begin
920
        if (rst == `OR1200_RST_VALUE)
921
                ex_mac_op <=  `OR1200_MACOP_NOP;
922
        else if (!ex_freeze & id_freeze | ex_flushpipe)
923
                ex_mac_op <=  `OR1200_MACOP_NOP;
924
        else if (!ex_freeze)
925
                ex_mac_op <=  id_mac_op;
926
end
927
 
928
assign mac_op = abort_mvspr ? `OR1200_MACOP_NOP : ex_mac_op;
929
`else
930
assign id_mac_op = `OR1200_MACOP_NOP;
931
assign mac_op = `OR1200_MACOP_NOP;
932
`endif
933
 
934
 
935
//
936
// Decode of rfwb_op
937
//
938
always @(posedge clk or `OR1200_RST_EVENT rst) begin
939
        if (rst == `OR1200_RST_VALUE)
940
                rfwb_op <=  `OR1200_RFWBOP_NOP;
941
        else  if (!ex_freeze & id_freeze | ex_flushpipe)
942
                rfwb_op <=  `OR1200_RFWBOP_NOP;
943
        else  if (!ex_freeze) begin
944
                case (id_insn[31:26])           // synopsys parallel_case
945
 
946
                // j.jal
947
                `OR1200_OR32_JAL:
948
                        rfwb_op <=  {`OR1200_RFWBOP_LR, 1'b1};
949
 
950
                // j.jalr
951
                `OR1200_OR32_JALR:
952
                        rfwb_op <=  {`OR1200_RFWBOP_LR, 1'b1};
953
 
954
                // l.movhi
955
                `OR1200_OR32_MOVHI:
956
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
957
 
958
                // l.mfspr
959
                `OR1200_OR32_MFSPR:
960
                        rfwb_op <=  {`OR1200_RFWBOP_SPRS, 1'b1};
961
 
962
                // l.lwz
963
                `OR1200_OR32_LWZ:
964
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
965
 
966
                // l.lws
967
                `OR1200_OR32_LWS:
968
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
969
 
970
                // l.lbz
971
                `OR1200_OR32_LBZ:
972
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
973
 
974
                // l.lbs
975
                `OR1200_OR32_LBS:
976
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
977
 
978
                // l.lhz
979
                `OR1200_OR32_LHZ:
980
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
981
 
982
                // l.lhs
983
                `OR1200_OR32_LHS:
984
                        rfwb_op <=  {`OR1200_RFWBOP_LSU, 1'b1};
985
 
986
                // l.addi
987
                `OR1200_OR32_ADDI:
988
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
989
 
990
                // l.addic
991
                `OR1200_OR32_ADDIC:
992
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
993
 
994
                // l.andi
995
                `OR1200_OR32_ANDI:
996
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
997
 
998
                // l.ori
999
                `OR1200_OR32_ORI:
1000
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
1001
 
1002
                // l.xori
1003
                `OR1200_OR32_XORI:
1004
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
1005
 
1006
                // l.muli
1007
`ifdef OR1200_MULT_IMPLEMENTED
1008
                `OR1200_OR32_MULI:
1009
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
1010
`endif
1011
 
1012
                // Shift and rotate insns with immediate
1013
`ifdef OR1200_IMPL_ALU_ROTATE
1014
                `OR1200_OR32_SH_ROTI:
1015
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
1016
`endif
1017
                // ALU instructions except the one with immediate
1018
                `OR1200_OR32_ALU:
1019
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
1020
 
1021
`ifdef OR1200_ALU_IMPL_CUST5
1022
                // l.cust5 instructions
1023
                `OR1200_OR32_CUST5:
1024
                        rfwb_op <=  {`OR1200_RFWBOP_ALU, 1'b1};
1025
`endif
1026
`ifdef OR1200_FPU_IMPLEMENTED
1027
                  // FPU instructions, lf.XXX.s, except sfxx
1028
                  `OR1200_OR32_FLOAT:
1029
                    rfwb_op <=  {`OR1200_RFWBOP_FPU,!id_insn[3]};
1030
`endif
1031
                // Instructions w/o register-file write-back
1032
                default:
1033
                        rfwb_op <=  `OR1200_RFWBOP_NOP;
1034
 
1035
 
1036
                endcase
1037
        end
1038
end
1039
 
1040
//
1041
// Decode of id_branch_op
1042
//
1043
always @(posedge clk or `OR1200_RST_EVENT rst) begin
1044
        if (rst == `OR1200_RST_VALUE)
1045
                id_branch_op <=  `OR1200_BRANCHOP_NOP;
1046
        else if (id_flushpipe)
1047
                id_branch_op <=  `OR1200_BRANCHOP_NOP;
1048
        else if (!id_freeze) begin
1049
                case (if_insn[31:26])           // synopsys parallel_case
1050
 
1051
                // l.j
1052
                `OR1200_OR32_J:
1053
                        id_branch_op <=  `OR1200_BRANCHOP_J;
1054
 
1055
                // j.jal
1056
                `OR1200_OR32_JAL:
1057
                        id_branch_op <=  `OR1200_BRANCHOP_J;
1058
 
1059
                // j.jalr
1060
                `OR1200_OR32_JALR:
1061
                        id_branch_op <=  `OR1200_BRANCHOP_JR;
1062
 
1063
                // l.jr
1064
                `OR1200_OR32_JR:
1065
                        id_branch_op <=  `OR1200_BRANCHOP_JR;
1066
 
1067
                // l.bnf
1068
                `OR1200_OR32_BNF:
1069
                        id_branch_op <=  `OR1200_BRANCHOP_BNF;
1070
 
1071
                // l.bf
1072
                `OR1200_OR32_BF:
1073
                        id_branch_op <=  `OR1200_BRANCHOP_BF;
1074
 
1075
                // l.rfe
1076
                `OR1200_OR32_RFE:
1077
                        id_branch_op <=  `OR1200_BRANCHOP_RFE;
1078
 
1079
                // Non branch instructions
1080
                default:
1081
                        id_branch_op <=  `OR1200_BRANCHOP_NOP;
1082
 
1083
                endcase
1084
        end
1085
end
1086
 
1087
//
1088
// Generation of ex_branch_op
1089
//
1090
always @(posedge clk or `OR1200_RST_EVENT rst)
1091
        if (rst == `OR1200_RST_VALUE)
1092
                ex_branch_op <=  `OR1200_BRANCHOP_NOP;
1093
        else if (!ex_freeze & id_freeze | ex_flushpipe)
1094
                ex_branch_op <=  `OR1200_BRANCHOP_NOP;
1095
        else if (!ex_freeze)
1096
                ex_branch_op <=  id_branch_op;
1097
 
1098
//
1099
// Decode of id_lsu_op
1100
//
1101
always @(id_insn) begin
1102
        case (id_insn[31:26])           // synopsys parallel_case
1103
 
1104
        // l.lwz
1105
        `OR1200_OR32_LWZ:
1106
                id_lsu_op =  `OR1200_LSUOP_LWZ;
1107
 
1108
        // l.lws
1109
        `OR1200_OR32_LWS:
1110
                id_lsu_op =  `OR1200_LSUOP_LWS;
1111
 
1112
        // l.lbz
1113
        `OR1200_OR32_LBZ:
1114
                id_lsu_op =  `OR1200_LSUOP_LBZ;
1115
 
1116
        // l.lbs
1117
        `OR1200_OR32_LBS:
1118
                id_lsu_op =  `OR1200_LSUOP_LBS;
1119
 
1120
        // l.lhz
1121
        `OR1200_OR32_LHZ:
1122
                id_lsu_op =  `OR1200_LSUOP_LHZ;
1123
 
1124
        // l.lhs
1125
        `OR1200_OR32_LHS:
1126
                id_lsu_op =  `OR1200_LSUOP_LHS;
1127
 
1128
        // l.sw
1129
        `OR1200_OR32_SW:
1130
                id_lsu_op =  `OR1200_LSUOP_SW;
1131
 
1132
        // l.sb
1133
        `OR1200_OR32_SB:
1134
                id_lsu_op =  `OR1200_LSUOP_SB;
1135
 
1136
        // l.sh
1137
        `OR1200_OR32_SH:
1138
                id_lsu_op =  `OR1200_LSUOP_SH;
1139
 
1140
        // Non load/store instructions
1141
        default:
1142
                id_lsu_op =  `OR1200_LSUOP_NOP;
1143
 
1144
        endcase
1145
end
1146
 
1147
//
1148
// Decode of comp_op
1149
//
1150
always @(posedge clk or `OR1200_RST_EVENT rst) begin
1151
        if (rst == `OR1200_RST_VALUE) begin
1152
                comp_op <=  4'd0;
1153
        end else if (!ex_freeze & id_freeze | ex_flushpipe)
1154
                comp_op <=  4'd0;
1155
        else if (!ex_freeze)
1156
                comp_op <=  id_insn[24:21];
1157
end
1158
 
1159
`ifdef OR1200_FPU_IMPLEMENTED
1160
//
1161
// Decode of FPU ops
1162
//
1163
   assign fpu_op = {(id_insn[31:26] == `OR1200_OR32_FLOAT),
1164
                    id_insn[`OR1200_FPUOP_WIDTH-2:0]};
1165
`else
1166
   assign fpu_op = {`OR1200_FPUOP_WIDTH{1'b0}};
1167
`endif
1168
 
1169
 
1170
//
1171
// Decode of l.sys
1172
//
1173
always @(posedge clk or `OR1200_RST_EVENT rst) begin
1174
        if (rst == `OR1200_RST_VALUE)
1175
                sig_syscall <=  1'b0;
1176
        else if (!ex_freeze & id_freeze | ex_flushpipe)
1177
                sig_syscall <=  1'b0;
1178
        else if (!ex_freeze) begin
1179
`ifdef OR1200_VERBOSE
1180
// synopsys translate_off
1181
                if (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b000})
1182
                        $display("Generating sig_syscall");
1183
// synopsys translate_on
1184
`endif
1185
                sig_syscall <=  (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b000});
1186
        end
1187
end
1188
 
1189
//
1190
// Decode of l.trap
1191
//
1192
always @(posedge clk or `OR1200_RST_EVENT rst) begin
1193
        if (rst == `OR1200_RST_VALUE)
1194
                sig_trap <=  1'b0;
1195
        else if (!ex_freeze & id_freeze | ex_flushpipe)
1196
                sig_trap <=  1'b0;
1197
        else if (!ex_freeze) begin
1198
`ifdef OR1200_VERBOSE
1199
// synopsys translate_off
1200
                if (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b010})
1201
                        $display("Generating sig_trap");
1202
// synopsys translate_on
1203
`endif
1204
                sig_trap <=  (id_insn[31:23] == {`OR1200_OR32_XSYNC, 3'b010})
1205
                        | du_hwbkpt;
1206
        end
1207
end
1208
 
1209
// Decode destination register address for data cache to check if store ops
1210
// are being done from the stack register (r1) or frame pointer register (r2)
1211
`ifdef OR1200_DC_NOSTACKWRITETHROUGH
1212
always @(posedge clk or `OR1200_RST_EVENT rst) begin
1213
   if (rst == `OR1200_RST_VALUE)
1214
     dc_no_writethrough <= 0;
1215
   else if (!ex_freeze)
1216
     dc_no_writethrough <= (id_insn[20:16] == 5'd1) | (id_insn[20:16] == 5'd2);
1217
end
1218
`else
1219
 
1220
   assign dc_no_writethrough = 0;
1221
 
1222
`endif
1223
 
1224
endmodule

powered by: WebSVN 2.1.0

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