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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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