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

Subversion Repositories or1k

[/] [or1k/] [branches/] [branch_qmem/] [or1200/] [rtl/] [verilog/] [or1200_except.v] - Blame information for rev 895

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

powered by: WebSVN 2.1.0

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