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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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