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

Subversion Repositories openrisc_me

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

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

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

powered by: WebSVN 2.1.0

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