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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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