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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orp/] [orp_soc/] [rtl/] [verilog/] [or1200.old/] [or1200_except.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Exception logic                                    ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Handles all OR1K exceptions inside CPU block.               ////
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
// $Log: not supported by cvs2svn $
47
// Revision 1.9  2002/02/11 04:33:17  lampret
48
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
49
//
50
// Revision 1.8  2002/01/28 01:16:00  lampret
51
// 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.
52
//
53
// Revision 1.7  2002/01/23 07:52:36  lampret
54
// Changed default reset values for SR and ESR to match or1ksim's. Fixed flop model in or1200_dpram_32x32 when OR1200_XILINX_RAM32X1D is defined.
55
//
56
// Revision 1.6  2002/01/18 14:21:43  lampret
57
// Fixed 'the NPC single-step fix'.
58
//
59
// Revision 1.5  2002/01/18 07:56:00  lampret
60
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
61
//
62
// Revision 1.4  2002/01/14 21:11:50  lampret
63
// Changed alignment exception EPCR. Not tested yet.
64
//
65
// Revision 1.3  2002/01/14 19:09:57  lampret
66
// Fixed order of syscall and range exceptions.
67
//
68
// Revision 1.2  2002/01/14 06:18:22  lampret
69
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
70
//
71
// Revision 1.1  2002/01/03 08:16:15  lampret
72
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
73
//
74
// Revision 1.15  2001/11/27 23:13:11  lampret
75
// Fixed except_stop width and fixed EX PC for 1400444f no-ops.
76
//
77
// Revision 1.14  2001/11/23 08:38:51  lampret
78
// Changed DSR/DRR behavior and exception detection.
79
//
80
// Revision 1.13  2001/11/20 18:46:15  simons
81
// Break point bug fixed
82
//
83
// Revision 1.12  2001/11/18 09:58:28  lampret
84
// Fixed some l.trap typos.
85
//
86
// Revision 1.11  2001/11/18 08:36:28  lampret
87
// For GDB changed single stepping and disabled trap exception.
88
//
89
// Revision 1.10  2001/11/13 10:02:21  lampret
90
// Added 'setpc'. Renamed some signals (except_flushpipe into flushpipe etc)
91
//
92
// Revision 1.9  2001/11/10 03:43:57  lampret
93
// Fixed exceptions.
94
//
95
// Revision 1.8  2001/10/21 17:57:16  lampret
96
// 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.
97
//
98
// Revision 1.7  2001/10/14 13:12:09  lampret
99
// MP3 version.
100
//
101
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
102
// no message
103
//
104
// Revision 1.2  2001/08/09 13:39:33  lampret
105
// Major clean-up.
106
//
107
// Revision 1.1  2001/07/20 00:46:03  lampret
108
// Development version of RTL. Libraries are missing.
109
//
110
//
111
 
112
// synopsys translate_off
113
`include "timescale.v"
114
// synopsys translate_on
115
`include "or1200_defines.v"
116
 
117
`define OR1200_EXCEPTFSM_WIDTH 3
118
`define OR1200_EXCEPTFSM_IDLE   `OR1200_EXCEPTFSM_WIDTH'd0
119
`define OR1200_EXCEPTFSM_FLU1   `OR1200_EXCEPTFSM_WIDTH'd1
120
`define OR1200_EXCEPTFSM_FLU2   `OR1200_EXCEPTFSM_WIDTH'd2
121
`define OR1200_EXCEPTFSM_FLU3   `OR1200_EXCEPTFSM_WIDTH'd3
122
`define OR1200_EXCEPTFSM_FLU4   `OR1200_EXCEPTFSM_WIDTH'd4
123
`define OR1200_EXCEPTFSM_FLU5   `OR1200_EXCEPTFSM_WIDTH'd5
124
 
125
//
126
// Exception recognition and sequencing
127
//
128
 
129
module or1200_except(
130
        // Clock and reset
131
        clk, rst,
132
 
133
        // Internal i/f
134
        sig_ibuserr, sig_dbuserr, sig_illegal, sig_align, sig_range, sig_dtlbmiss, sig_dmmufault,
135
        sig_int, sig_syscall, sig_trap, sig_itlbmiss, sig_immufault, sig_tick,
136
        branch_taken, id_freeze, ex_freeze, wb_freeze, if_stall,
137
        if_pc, lr_sav, flushpipe, extend_flush, except_type, except_start,
138
        except_started, except_stop, ex_void,
139
        spr_dat_ppc, spr_dat_npc, datain, du_dsr, epcr_we, eear_we, esr_we, pc_we, epcr, eear,
140
        esr, sr, lsu_addr, abort_ex
141
);
142
 
143
//
144
// I/O
145
//
146
input                           clk;
147
input                           rst;
148
input                           sig_ibuserr;
149
input                           sig_dbuserr;
150
input                           sig_illegal;
151
input                           sig_align;
152
input                           sig_range;
153
input                           sig_dtlbmiss;
154
input                           sig_dmmufault;
155
input                           sig_int;
156
input                           sig_syscall;
157
input                           sig_trap;
158
input                           sig_itlbmiss;
159
input                           sig_immufault;
160
input                           sig_tick;
161
input                           branch_taken;
162
input                           id_freeze;
163
input                           ex_freeze;
164
input                           wb_freeze;
165
input                           if_stall;
166
input   [31:0]                   if_pc;
167
output  [31:2]                  lr_sav;
168
input   [31:0]                   datain;
169
input   [`OR1200_DU_DSR_WIDTH-1:0]     du_dsr;
170
input                           epcr_we;
171
input                           eear_we;
172
input                           esr_we;
173
input                           pc_we;
174
output  [31:0]                   epcr;
175
output  [31:0]                   eear;
176
output  [`OR1200_SR_WIDTH-1:0]           esr;
177
input   [`OR1200_SR_WIDTH-1:0]           sr;
178
input   [31:0]                   lsu_addr;
179
output                          flushpipe;
180
output                          extend_flush;
181
output  [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
182
output                          except_start;
183
output                          except_started;
184
output  [12:0]                   except_stop;
185
input                           ex_void;
186
output  [31:0]                   spr_dat_ppc;
187
output  [31:0]                   spr_dat_npc;
188
output                          abort_ex;
189
 
190
//
191
// Internal regs and wires
192
//
193
reg     [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
194
reg     [31:0]                   id_pc;
195
reg     [31:0]                   ex_pc;
196
reg     [31:0]                   wb_pc;
197
reg     [31:0]                   epcr;
198
reg     [31:0]                   eear;
199
reg     [`OR1200_SR_WIDTH-1:0]           esr;
200
reg     [2:0]                    id_exceptflags;
201
reg     [2:0]                    ex_exceptflags;
202
reg     [`OR1200_EXCEPTFSM_WIDTH-1:0]    state;
203
reg                             extend_flush;
204
reg                             extend_flush_last;
205
reg                             ex_dslot;
206
reg                             delayed1_ex_dslot;
207
reg                             delayed2_ex_dslot;
208
wire                            except_started;
209
wire    [12:0]                   except_trig;
210
wire                            except_flushpipe;
211
reg     [2:0]                    delayed_iee;
212
reg     [2:0]                    delayed_tee;
213
wire                            int_pending;
214
wire                            tick_pending;
215
 
216
//
217
// Simple combinatorial logic
218
//
219
assign except_started = extend_flush & except_start;
220
assign lr_sav = ex_pc[31:2];
221
assign spr_dat_ppc = wb_pc;
222
assign spr_dat_npc = ex_void ? id_pc : ex_pc;
223
//assign except_start = (except_type != `OR1200_EXCEPT_NONE);  // damjan
224
assign except_start = (except_type != `OR1200_EXCEPT_NONE) & extend_flush;
225
assign int_pending = sig_int & sr[`OR1200_SR_IEE] & delayed_iee[2] & ~ex_freeze & ~branch_taken & ~ex_dslot;
226
//assign tick_pending = sig_tick & sr[`OR1200_SR_TEE] & delayed_tee[2] & ~ex_freeze & ~branch_taken & ~ex_dslot; // works with uclinux. except_test fails
227
//assign tick_pending = sig_tick & sr[`OR1200_SR_TEE] & ~ex_freeze & ~branch_taken & ~ex_dslot; // works with uclinux, except_tets almost works (priority fails)
228
assign tick_pending = sig_tick & sr[`OR1200_SR_TEE] & ~ex_freeze & ~branch_taken & ~ex_dslot;
229
assign abort_ex = sig_dbuserr | sig_dmmufault | sig_dtlbmiss | sig_align | sig_illegal;         // Abort write into RF by load & other instructions
230
 
231
//
232
// Order defines exception detection priority
233
//
234
assign except_trig = {
235
                        tick_pending            & ~du_dsr[`OR1200_DU_DSR_TTE],
236
                        int_pending             & ~du_dsr[`OR1200_DU_DSR_IE],
237
                        ex_exceptflags[1]       & ~du_dsr[`OR1200_DU_DSR_IME],
238
                        ex_exceptflags[0]        & ~du_dsr[`OR1200_DU_DSR_IPFE],
239
                        ex_exceptflags[2]       & ~du_dsr[`OR1200_DU_DSR_BUSEE],
240
                        sig_illegal             & ~du_dsr[`OR1200_DU_DSR_IIE],
241
                        sig_align               & ~du_dsr[`OR1200_DU_DSR_AE],
242
                        sig_dtlbmiss            & ~du_dsr[`OR1200_DU_DSR_DME],
243
                        sig_dmmufault           & ~du_dsr[`OR1200_DU_DSR_DPFE],
244
                        sig_dbuserr             & ~du_dsr[`OR1200_DU_DSR_BUSEE],
245
                        sig_range               & ~du_dsr[`OR1200_DU_DSR_RE],
246
                        sig_trap                & ~du_dsr[`OR1200_DU_DSR_TE] & ~ex_freeze,
247
                        sig_syscall             & ~du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze
248
                };
249
assign except_stop = {
250
                        tick_pending            & du_dsr[`OR1200_DU_DSR_TTE],
251
                        int_pending             & du_dsr[`OR1200_DU_DSR_IE],
252
                        ex_exceptflags[1]       & du_dsr[`OR1200_DU_DSR_IME],
253
                        ex_exceptflags[0]        & du_dsr[`OR1200_DU_DSR_IPFE],
254
                        ex_exceptflags[2]       & du_dsr[`OR1200_DU_DSR_BUSEE],
255
                        sig_illegal             & du_dsr[`OR1200_DU_DSR_IIE],
256
                        sig_align               & du_dsr[`OR1200_DU_DSR_AE],
257
                        sig_dtlbmiss            & du_dsr[`OR1200_DU_DSR_DME],
258
                        sig_dmmufault           & du_dsr[`OR1200_DU_DSR_DPFE],
259
                        sig_dbuserr             & du_dsr[`OR1200_DU_DSR_BUSEE],
260
                        sig_range               & du_dsr[`OR1200_DU_DSR_RE],
261
                        sig_trap                & du_dsr[`OR1200_DU_DSR_TE] & ~ex_freeze,
262
                        sig_syscall             & du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze
263
                };
264
 
265
//
266
// PC and Exception flags pipelines
267
//
268
always @(posedge clk or posedge rst) begin
269
        if (rst) begin
270
                id_pc <= #1 32'd0;
271
                id_exceptflags <= #1 3'b000;
272
        end
273
        else if (flushpipe) begin
274
                id_pc <= #1 32'h0000_0000;
275
                id_exceptflags <= #1 3'b000;
276
        end
277
        else if (!id_freeze) begin
278
                id_pc <= #1 if_pc;
279
                id_exceptflags <= #1 { sig_ibuserr, sig_itlbmiss, sig_immufault };
280
        end
281
end
282
 
283
//
284
// delayed_iee
285
//
286
// SR[IEE] should not enable interrupts right away
287
// when it is restored with l.rfe. Instead delayed_iee
288
// together with SR[IEE] enables interrupts once
289
// pipeline is again ready.
290
//
291
always @(posedge rst or posedge clk)
292
        if (rst)
293
                delayed_iee <= #1 3'b000;
294
        else if (!sr[`OR1200_SR_IEE])
295
                delayed_iee <= #1 3'b000;
296
        else
297
                delayed_iee <= #1 {delayed_iee[1:0], 1'b1};
298
 
299
//
300
// delayed_tee
301
//
302
// SR[TEE] should not enable tick exceptions right away
303
// when it is restored with l.rfe. Instead delayed_tee
304
// together with SR[TEE] enables tick exceptions once
305
// pipeline is again ready.
306
//
307
always @(posedge rst or posedge clk)
308
        if (rst)
309
                delayed_tee <= #1 3'b000;
310
        else if (!sr[`OR1200_SR_TEE])
311
                delayed_tee <= #1 3'b000;
312
        else
313
                delayed_tee <= #1 {delayed_tee[1:0], 1'b1};
314
 
315
//
316
// PC and Exception flags pipelines
317
//
318
always @(posedge clk or posedge rst) begin
319
        if (rst) begin
320
                ex_dslot <= #1 1'b0;
321
                ex_pc <= #1 32'd0;
322
                ex_exceptflags <= #1 3'b000;
323
                delayed1_ex_dslot <= #1 1'b0;
324
                delayed2_ex_dslot <= #1 1'b0;
325
        end
326
        else if (flushpipe) begin
327
                ex_dslot <= #1 1'b0;
328
                ex_pc <= #1 32'h0000_0000;
329
                ex_exceptflags <= #1 3'b000;
330
                delayed1_ex_dslot <= #1 1'b0;
331
                delayed2_ex_dslot <= #1 1'b0;
332
        end
333
        else if (!ex_freeze & id_freeze) begin
334
                ex_dslot <= #1 1'b0;
335
                ex_pc <= #1 id_pc;
336
                ex_exceptflags <= #1 3'b000;
337
                delayed1_ex_dslot <= #1 ex_dslot;
338
                delayed2_ex_dslot <= #1 delayed1_ex_dslot;
339
        end
340
        else if (!ex_freeze) begin
341
`ifdef OR1200_VERBOSE
342
// synopsys translate_off
343
                $display("%t: ex_pc <= %h", $time, id_pc);
344
// synopsys translate_on
345
`endif
346
                ex_dslot <= #1 branch_taken;
347
                ex_pc <= #1 id_pc;
348
                ex_exceptflags <= #1 id_exceptflags;
349
                delayed1_ex_dslot <= #1 ex_dslot;
350
                delayed2_ex_dslot <= #1 delayed1_ex_dslot;
351
        end
352
end
353
 
354
//
355
// PC and Exception flags pipelines
356
//
357
always @(posedge clk or posedge rst) begin
358
        if (rst) begin
359
                wb_pc <= #1 32'd0;
360
        end
361
        else if (!wb_freeze) begin
362
                wb_pc <= #1 ex_pc;
363
        end
364
end
365
 
366
//
367
// Flush pipeline
368
//
369
assign flushpipe = except_flushpipe | pc_we | extend_flush;
370
 
371
//
372
// We have started execution of exception handler:
373
//  1. Asserted for 3 clock cycles
374
//  2. Don't execute any instruction that is still in pipeline and is not part of exception handler
375
//
376
assign except_flushpipe = |except_trig & !state;
377
 
378
//
379
// Exception FSM that sequences execution of exception handler
380
//
381
// except_type signals which exception handler we start fetching in:
382
//  1. Asserted in next clock cycle after exception is recognized
383
//
384
always @(posedge clk or posedge rst) begin
385
        if (rst) begin
386
                state <= #1 `OR1200_EXCEPTFSM_IDLE;
387
                except_type <= #1 `OR1200_EXCEPT_NONE;
388
                extend_flush <= #1 1'b0;
389
                epcr <= #1 32'b0;
390
                eear <= #1 32'b0;
391
                esr <= #1 {1'b1, {`OR1200_SR_WIDTH-2{1'b0}}, 1'b1};
392
                extend_flush_last <= #1 1'b0;
393
        end
394
        else begin
395
                case (state)    // synopsys full_case parallel_case
396
                        `OR1200_EXCEPTFSM_IDLE:
397
                                if (except_flushpipe) begin
398
                                        state <= #1 `OR1200_EXCEPTFSM_FLU1;
399
                                        extend_flush <= #1 1'b1;
400
                                        if (ex_dslot) begin
401
`ifdef OR1200_VERBOSE
402
// synopsys translate_off
403
                                                $display(" INFO: Exception during first delay slot instruction.");
404
// synopsys translate_on
405
`endif
406
                                        end
407
                                        else if (delayed1_ex_dslot) begin
408
`ifdef OR1200_VERBOSE
409
// synopsys translate_off
410
                                                $display(" INFO: Exception during second (NOP) delay slot instruction.");
411
// synopsys translate_on
412
`endif
413
                                        end
414
                                        else if (delayed2_ex_dslot) begin
415
`ifdef OR1200_VERBOSE
416
// synopsys translate_off
417
                                                $display(" INFO: Exception during third delay slot (SHOULD NOT HAPPEN).");
418
// synopsys translate_on
419
`endif
420
                                        end
421
                                        else begin
422
`ifdef OR1200_VERBOSE
423
// synopsys translate_off
424
                                                $display(" INFO: Exception during normal (no delay slot) instruction.");
425
// synopsys translate_on
426
`endif
427
                                        end
428
 
429
                                        esr <= #1 sr;
430
                                        casex (except_trig)
431
                                                13'b1_xxxx_xxxx_xxxx: begin
432
                                                        except_type <= #1 `OR1200_EXCEPT_TICK;
433
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
434
                                                end
435
                                                13'b0_1xxx_xxxx_xxxx: begin
436
                                                        except_type <= #1 `OR1200_EXCEPT_INT;
437
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
438
                                                end
439
                                                13'b0_01xx_xxxx_xxxx: begin
440
                                                        except_type <= #1 `OR1200_EXCEPT_ITLBMISS;
441
                                                        eear <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
442
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
443
                                                end
444
                                                13'b0_001x_xxxx_xxxx: begin
445
                                                        except_type <= #1 `OR1200_EXCEPT_IPF;
446
                                                        eear <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
447
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
448
                                                end
449
                                                13'b0_0001_xxxx_xxxx: begin
450
                                                        except_type <= #1 `OR1200_EXCEPT_BUSERR;
451
                                                        eear <= #1 ex_dslot ? wb_pc : ex_pc;
452
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
453
                                                end
454
                                                13'b0_0000_1xxx_xxxx: begin
455
                                                        except_type <= #1 `OR1200_EXCEPT_ILLEGAL;
456
                                                        eear <= #1 ex_pc;
457
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
458
                                                end
459
                                                13'b0_0000_01xx_xxxx: begin
460
                                                        except_type <= #1 `OR1200_EXCEPT_ALIGN;
461
                                                        eear <= #1 lsu_addr;
462
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
463
                                                end
464
                                                13'b0_0000_001x_xxxx: begin
465
                                                        except_type <= #1 `OR1200_EXCEPT_DTLBMISS;
466
                                                        eear <= #1 lsu_addr;
467
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
468
                                                end
469
                                                13'b0_0000_0001_xxxx: begin
470
                                                        except_type <= #1 `OR1200_EXCEPT_DPF;
471
                                                        eear <= #1 lsu_addr;
472
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
473
                                                end
474
                                                13'b0_0000_0000_1xxx: begin     // Data Bus Error
475
                                                        except_type <= #1 `OR1200_EXCEPT_BUSERR;
476
                                                        eear <= #1 lsu_addr;
477
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
478
                                                end
479
                                                13'b0_0000_0000_01xx: begin
480
                                                        except_type <= #1 `OR1200_EXCEPT_RANGE;
481
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
482
                                                end
483
                                                13'b0_0000_0000_001x: begin
484
                                                        except_type <= #1 `OR1200_EXCEPT_TRAP;
485
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
486
                                                end
487
                                                13'b0_0000_0000_0001: begin
488
                                                        except_type <= #1 `OR1200_EXCEPT_SYSCALL;
489
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
490
                                                end
491
                                                default:
492
                                                        except_type <= #1 `OR1200_EXCEPT_NONE;
493
                                        endcase
494
                                end
495
                                else if (pc_we) begin
496
                                        state <= #1 `OR1200_EXCEPTFSM_FLU1;
497
                                        extend_flush <= #1 1'b1;
498
                                end
499
                                else begin
500
                                        if (epcr_we)
501
                                                epcr <= #1 datain;
502
                                        if (eear_we)
503
                                                eear <= #1 datain;
504
                                        if (esr_we)
505
                                                esr <= #1 {1'b1, datain[`OR1200_SR_WIDTH-2:0]};
506
                                end
507
                        `OR1200_EXCEPTFSM_FLU1:
508
//                              if (!if_stall & !id_freeze)
509
                                        state <= #1 `OR1200_EXCEPTFSM_FLU2;
510
                        `OR1200_EXCEPTFSM_FLU2:
511
                                if (except_type == `OR1200_EXCEPT_TRAP) begin
512
                                        state <= #1 `OR1200_EXCEPTFSM_IDLE;
513
                                        extend_flush <= #1 1'b0;
514
                                        extend_flush_last <= #1 1'b0;
515
                                        except_type <= #1 `OR1200_EXCEPT_NONE;
516
                                end
517
                                else
518
//                              if (!if_stall & !id_freeze)
519
                                        state <= #1 `OR1200_EXCEPTFSM_FLU3;
520
                        `OR1200_EXCEPTFSM_FLU3:
521
//                              if (!if_stall && !id_freeze)
522
                                        begin
523
`ifdef OR1200_VERBOSE
524
// synopsys translate_off
525
                                                if (except_flushpipe)
526
                                                        $display(" INFO: EPCR0 %h  EEAR %h  ESR %h", epcr, eear, esr);
527
// synopsys translate_on
528
`endif
529
                                                state <= #1 `OR1200_EXCEPTFSM_FLU4;
530
                                        end
531
                        `OR1200_EXCEPTFSM_FLU4: begin
532
                                        state <= #1 `OR1200_EXCEPTFSM_FLU5;
533
                                        extend_flush <= #1 1'b0;
534
                                        extend_flush_last <= #1 1'b0; // damjan
535
                                end
536
                        `OR1200_EXCEPTFSM_FLU5: begin
537
                                if (!if_stall && !id_freeze) begin
538
`ifdef OR1200_VERBOSE
539
// synopsys translate_off
540
                                $display(" INFO: Just finished flushing pipeline.");
541
// synopsys translate_on
542
`endif
543
                                state <= #1 `OR1200_EXCEPTFSM_IDLE;
544
                                except_type <= #1 `OR1200_EXCEPT_NONE;
545
                                extend_flush_last <= #1 1'b0;
546
                        end
547
                        end
548
                endcase
549
        end
550
end
551
 
552
endmodule

powered by: WebSVN 2.1.0

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