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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_except.v] - Blame information for rev 22

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

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

powered by: WebSVN 2.1.0

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