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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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