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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_7/] [or1200/] [rtl/] [verilog/] [or1200_except.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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