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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_except.v] - Blame information for rev 852

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Exception logic                                    ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6 185 julius
////  http://www.opencores.org/project,or1k                       ////
7 10 unneback
////                                                              ////
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 151 marcus.erl
// $Log: or1200_except.v,v $
45 10 unneback
//
46 141 marcus.erl
// Revision 2.0  2010/06/30 11:00:00  ORSoC
47
// Major update: 
48
// Structure reordered and bugs fixed. 
49 10 unneback
 
50
// synopsys translate_off
51
`include "timescale.v"
52
// synopsys translate_on
53
`include "or1200_defines.v"
54
 
55
`define OR1200_EXCEPTFSM_WIDTH 3
56
`define OR1200_EXCEPTFSM_IDLE   `OR1200_EXCEPTFSM_WIDTH'd0
57
`define OR1200_EXCEPTFSM_FLU1   `OR1200_EXCEPTFSM_WIDTH'd1
58
`define OR1200_EXCEPTFSM_FLU2   `OR1200_EXCEPTFSM_WIDTH'd2
59
`define OR1200_EXCEPTFSM_FLU3   `OR1200_EXCEPTFSM_WIDTH'd3
60
`define OR1200_EXCEPTFSM_FLU4   `OR1200_EXCEPTFSM_WIDTH'd4
61
`define OR1200_EXCEPTFSM_FLU5   `OR1200_EXCEPTFSM_WIDTH'd5
62
 
63
//
64
// Exception recognition and sequencing
65
//
66
 
67 185 julius
module or1200_except
68
  (
69
   // Clock and reset
70
   clk, rst,
71
 
72
   // Internal i/f
73
   sig_ibuserr, sig_dbuserr, sig_illegal, sig_align, sig_range, sig_dtlbmiss,
74
   sig_dmmufault, sig_int, sig_syscall, sig_trap, sig_itlbmiss, sig_immufault,
75
   sig_tick, ex_branch_taken, genpc_freeze, id_freeze, ex_freeze, wb_freeze,
76
   if_stall,  if_pc, id_pc, ex_pc, wb_pc, id_flushpipe, ex_flushpipe,
77
   extend_flush, except_flushpipe, except_type, except_start, except_started,
78
   except_stop, except_trig, ex_void, abort_mvspr, branch_op, spr_dat_ppc,
79
   spr_dat_npc, datain, du_dsr, epcr_we, eear_we, esr_we, pc_we, epcr, eear,
80
   du_dmr1, du_hwbkpt, du_hwbkpt_ls_r, esr, sr_we, to_sr, sr, lsu_addr,
81 808 julius
   abort_ex, icpu_ack_i, icpu_err_i, dcpu_ack_i, dcpu_err_i, sig_fp, fpcsr_fpee,
82
   dsx
83 185 julius
 
84 10 unneback
);
85
 
86
//
87
// I/O
88
//
89
input                           clk;
90
input                           rst;
91
input                           sig_ibuserr;
92
input                           sig_dbuserr;
93
input                           sig_illegal;
94
input                           sig_align;
95
input                           sig_range;
96
input                           sig_dtlbmiss;
97
input                           sig_dmmufault;
98
input                           sig_int;
99
input                           sig_syscall;
100
input                           sig_trap;
101
input                           sig_itlbmiss;
102
input                           sig_immufault;
103
input                           sig_tick;
104 185 julius
input                           sig_fp;
105
input                           fpcsr_fpee;
106 141 marcus.erl
input                           ex_branch_taken;
107 10 unneback
input                           genpc_freeze;
108
input                           id_freeze;
109
input                           ex_freeze;
110
input                           wb_freeze;
111
input                           if_stall;
112 141 marcus.erl
input   [31:0]           if_pc;
113
output  [31:0]           id_pc;
114
output  [31:0]      ex_pc;
115
output  [31:0]      wb_pc;
116
input   [31:0]           datain;
117 10 unneback
input   [`OR1200_DU_DSR_WIDTH-1:0]     du_dsr;
118 141 marcus.erl
input   [24:0]                       du_dmr1;
119
input                   du_hwbkpt;
120
input                   du_hwbkpt_ls_r;
121 10 unneback
input                           epcr_we;
122
input                           eear_we;
123
input                           esr_we;
124
input                           pc_we;
125
output  [31:0]                   epcr;
126
output  [31:0]                   eear;
127
output  [`OR1200_SR_WIDTH-1:0]   esr;
128
input   [`OR1200_SR_WIDTH-1:0]   to_sr;
129
input                           sr_we;
130
input   [`OR1200_SR_WIDTH-1:0]   sr;
131
input   [31:0]                   lsu_addr;
132 141 marcus.erl
input                   id_flushpipe;
133
input                   ex_flushpipe;
134
output                          except_flushpipe;
135 10 unneback
output                          extend_flush;
136
output  [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
137
output                          except_start;
138
output                          except_started;
139 185 julius
output  [13:0]           except_stop;
140
output  [13:0]           except_trig;
141 10 unneback
input                           ex_void;
142 141 marcus.erl
input   [`OR1200_BRANCHOP_WIDTH-1:0]    branch_op;
143 10 unneback
output  [31:0]                   spr_dat_ppc;
144
output  [31:0]                   spr_dat_npc;
145
output                          abort_ex;
146 141 marcus.erl
output              abort_mvspr;
147 10 unneback
input                           icpu_ack_i;
148
input                           icpu_err_i;
149
input                           dcpu_ack_i;
150
input                           dcpu_err_i;
151 808 julius
output                          dsx;
152
 
153 10 unneback
//
154
// Internal regs and wires
155
//
156 353 julius
reg     [`OR1200_EXCEPT_WIDTH-1:0]       except_type /* verilator public */;
157
reg     [31:0]                   id_pc /* verilator public */;
158 141 marcus.erl
reg                 id_pc_val;
159 353 julius
reg     [31:0]                   ex_pc /* verilator public */;
160 141 marcus.erl
reg                 ex_pc_val;
161 353 julius
reg     [31:0]                   wb_pc /* verilator public */;
162 141 marcus.erl
reg [31:0]          dl_pc;
163 10 unneback
reg     [31:0]                   epcr;
164
reg     [31:0]                   eear;
165
reg     [`OR1200_SR_WIDTH-1:0]           esr;
166
reg     [2:0]                    id_exceptflags;
167
reg     [2:0]                    ex_exceptflags;
168
reg     [`OR1200_EXCEPTFSM_WIDTH-1:0]    state;
169
reg                             extend_flush;
170
reg                             extend_flush_last;
171 353 julius
reg                             ex_dslot /* verilator public */;
172 10 unneback
reg                             delayed1_ex_dslot;
173
reg                             delayed2_ex_dslot;
174
wire                            except_started;
175 353 julius
wire                            except_flushpipe /* verilator public */;
176 10 unneback
reg     [2:0]                    delayed_iee;
177
reg     [2:0]                    delayed_tee;
178
wire                            int_pending;
179
wire                            tick_pending;
180 185 julius
wire                            fp_pending;
181 642 julius
wire                            range_pending;
182 808 julius
reg                             dsx;
183 642 julius
 
184 141 marcus.erl
reg trace_trap      ;
185
reg ex_freeze_prev;
186
reg sr_ted_prev;
187
reg dsr_te_prev;
188
reg dmr1_st_prev    ;
189
reg dmr1_bt_prev    ;
190
wire dsr_te = ex_freeze_prev ? dsr_te_prev : du_dsr[`OR1200_DU_DSR_TE];
191
wire sr_ted = ex_freeze_prev ? sr_ted_prev : sr[`OR1200_SR_TED];
192
wire dmr1_st = ex_freeze_prev ? dmr1_st_prev: du_dmr1[`OR1200_DU_DMR1_ST] ;
193
wire dmr1_bt = ex_freeze_prev ? dmr1_bt_prev: du_dmr1[`OR1200_DU_DMR1_BT] ;
194 10 unneback
 
195
//
196
// Simple combinatorial logic
197
//
198
assign except_started = extend_flush & except_start;
199 185 julius
 
200 141 marcus.erl
assign except_start = (except_type != `OR1200_EXCEPT_NONE) & extend_flush;
201 185 julius
 
202
assign int_pending = sig_int & (sr[`OR1200_SR_IEE] |
203
                                (sr_we & to_sr[`OR1200_SR_IEE]))
204
                    & id_pc_val & delayed_iee[2] & ~ex_freeze & ~ex_branch_taken
205
                     & ~ex_dslot & ~(sr_we & ~to_sr[`OR1200_SR_IEE]);
206
 
207
assign tick_pending = sig_tick & (sr[`OR1200_SR_TEE] |
208
                                  (sr_we & to_sr[`OR1200_SR_TEE])) & id_pc_val
209
                      & delayed_tee[2] & ~ex_freeze & ~ex_branch_taken
210
                      & ~ex_dslot & ~(sr_we & ~to_sr[`OR1200_SR_TEE]);
211
 
212
assign fp_pending = sig_fp & fpcsr_fpee & ~ex_freeze & ~ex_branch_taken
213
                    & ~ex_dslot;
214 642 julius
 
215
`ifdef OR1200_IMPL_OVE
216
assign range_pending =  sig_range & sr[`OR1200_SR_OVE] & ~ex_freeze &
217
                       ~ex_branch_taken & ~ex_dslot;
218
`else
219
assign range_pending = 0;
220
`endif
221 185 julius
 
222
// Abort write into RF by load & other instructions   
223
assign abort_ex = sig_dbuserr | sig_dmmufault | sig_dtlbmiss | sig_align |
224
                  sig_illegal | ((du_hwbkpt | trace_trap) & ex_pc_val
225
                                 & !sr_ted & !dsr_te);
226
 
227
// abort spr read/writes   
228
assign abort_mvspr  = sig_illegal | ((du_hwbkpt | trace_trap) & ex_pc_val
229
                                     & !sr_ted & !dsr_te) ;
230 10 unneback
assign spr_dat_ppc = wb_pc;
231 185 julius
 
232 10 unneback
assign spr_dat_npc = ex_void ? id_pc : ex_pc;
233
 
234
//
235
// Order defines exception detection priority
236
//
237
assign except_trig = {
238 151 marcus.erl
                      ex_exceptflags[1] & ~du_dsr[`OR1200_DU_DSR_IME],
239
                      ex_exceptflags[0]  & ~du_dsr[`OR1200_DU_DSR_IPFE],
240
                      ex_exceptflags[2] & ~du_dsr[`OR1200_DU_DSR_BUSEE],
241 185 julius
                      sig_illegal       & ~du_dsr[`OR1200_DU_DSR_IIE],
242 151 marcus.erl
                      sig_align         & ~du_dsr[`OR1200_DU_DSR_AE],
243 185 julius
                      sig_dtlbmiss      & ~du_dsr[`OR1200_DU_DSR_DME],
244 151 marcus.erl
                      sig_trap          & ~du_dsr[`OR1200_DU_DSR_TE],
245 185 julius
                      sig_syscall       & ~du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
246
                      sig_dmmufault     & ~du_dsr[`OR1200_DU_DSR_DPFE],
247
                      sig_dbuserr       & ~du_dsr[`OR1200_DU_DSR_BUSEE],
248 642 julius
                      range_pending     & ~du_dsr[`OR1200_DU_DSR_RE],
249 185 julius
                      fp_pending        & ~du_dsr[`OR1200_DU_DSR_FPE],
250
                      int_pending       & ~du_dsr[`OR1200_DU_DSR_IE],
251
                      tick_pending      & ~du_dsr[`OR1200_DU_DSR_TTE]
252 151 marcus.erl
                      };
253 185 julius
 
254 141 marcus.erl
wire    trace_cond  = !ex_freeze && !ex_void && (1'b0
255
`ifdef OR1200_DU_DMR1_ST
256
    ||  dmr1_st
257
`endif
258
`ifdef OR1200_DU_DMR1_BT
259
    ||  ((branch_op != `OR1200_BRANCHOP_NOP) && (branch_op != `OR1200_BRANCHOP_RFE) && dmr1_bt)
260
`endif
261
    );
262
 
263 10 unneback
assign except_stop = {
264
                        tick_pending            & du_dsr[`OR1200_DU_DSR_TTE],
265
                        int_pending             & du_dsr[`OR1200_DU_DSR_IE],
266
                        ex_exceptflags[1]       & du_dsr[`OR1200_DU_DSR_IME],
267
                        ex_exceptflags[0]        & du_dsr[`OR1200_DU_DSR_IPFE],
268
                        ex_exceptflags[2]       & du_dsr[`OR1200_DU_DSR_BUSEE],
269
                        sig_illegal             & du_dsr[`OR1200_DU_DSR_IIE],
270
                        sig_align               & du_dsr[`OR1200_DU_DSR_AE],
271
                        sig_dtlbmiss            & du_dsr[`OR1200_DU_DSR_DME],
272
                        sig_dmmufault           & du_dsr[`OR1200_DU_DSR_DPFE],
273
                        sig_dbuserr             & du_dsr[`OR1200_DU_DSR_BUSEE],
274 642 julius
                        range_pending           & du_dsr[`OR1200_DU_DSR_RE],
275 141 marcus.erl
                        sig_trap                & du_dsr[`OR1200_DU_DSR_TE],
276 185 julius
                        fp_pending              & du_dsr[`OR1200_DU_DSR_FPE],
277 10 unneback
                        sig_syscall             & du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze
278
                };
279
 
280 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst) begin
281
        if (rst == `OR1200_RST_VALUE) begin
282 258 julius
                trace_trap  <=  1'b0 ;
283 141 marcus.erl
        end
284
        else if (!(trace_trap && !ex_pc_val)) begin
285 258 julius
                trace_trap  <=  trace_cond & !dsr_te & !sr_ted ;
286 141 marcus.erl
        end
287
end
288
 
289 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst) begin
290
        if (rst == `OR1200_RST_VALUE) begin
291 258 julius
        ex_freeze_prev  <=  1'b0 ;
292
        sr_ted_prev     <=  1'b0 ;
293
        dsr_te_prev     <=  1'b0 ;
294
        dmr1_st_prev    <=  1'b0 ;
295
        dmr1_bt_prev    <=  1'b0 ;
296 141 marcus.erl
    end
297
    else begin
298 258 julius
        ex_freeze_prev  <=  ex_freeze ;
299 141 marcus.erl
        if (!ex_freeze_prev || ex_void) begin
300 258 julius
            sr_ted_prev     <=  sr     [`OR1200_SR_TED    ] ;
301
            dsr_te_prev     <=  du_dsr [`OR1200_DU_DSR_TE ] ;
302
            dmr1_st_prev    <=  du_dmr1[`OR1200_DU_DMR1_ST] ;
303
            dmr1_bt_prev    <=  du_dmr1[`OR1200_DU_DMR1_BT] ;
304 141 marcus.erl
        end
305
    end
306
end
307
 
308 353 julius
`ifdef verilator
309
   // Function to access wb_pc (for Verilator). Have to hide this from
310
   // simulator, since functions with no inputs are not allowed in IEEE
311
   // 1364-2001.
312
   function [31:0] get_wb_pc;
313
      // verilator public
314
      get_wb_pc = wb_pc;
315
   endfunction // get_wb_pc
316
 
317
   // Function to access id_pc (for Verilator). Have to hide this from
318
   // simulator, since functions with no inputs are not allowed in IEEE
319
   // 1364-2001.
320
   function [31:0] get_id_pc;
321
      // verilator public
322
      get_id_pc = id_pc;
323
   endfunction // get_id_pc
324
 
325
   // Function to access ex_pc (for Verilator). Have to hide this from
326
   // simulator, since functions with no inputs are not allowed in IEEE
327
   // 1364-2001.
328
   function [31:0] get_ex_pc;
329
      // verilator public
330
      get_ex_pc = ex_pc;
331
   endfunction // get_ex_pc
332
   // Function to access except_type[3:0] (for Verilator). Have to hide this from
333
   // simulator, since functions with no inputs are not allowed in IEEE
334
   // 1364-2001.
335
   function [3:0] get_except_type;
336
      // verilator public
337
      get_except_type = except_type;
338
   endfunction // get_except_type
339
 
340
`endif
341
 
342
 
343 10 unneback
//
344
// PC and Exception flags pipelines
345
//
346 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst) begin
347
        if (rst == `OR1200_RST_VALUE) begin
348 258 julius
                id_pc <=  32'd0;
349
        id_pc_val <=  1'b0 ;
350
                id_exceptflags <=  3'b000;
351 10 unneback
        end
352 141 marcus.erl
        else if (id_flushpipe) begin
353 258 julius
        id_pc_val <=  1'b0 ;
354
                id_exceptflags <=  3'b000;
355 10 unneback
        end
356
        else if (!id_freeze) begin
357 258 julius
                id_pc <=  if_pc;
358
        id_pc_val <=  1'b1 ;
359
                id_exceptflags <=  { sig_ibuserr, sig_itlbmiss, sig_immufault };
360 10 unneback
        end
361
end
362
 
363
//
364
// delayed_iee
365
//
366
// SR[IEE] should not enable interrupts right away
367
// when it is restored with l.rfe. Instead delayed_iee
368
// together with SR[IEE] enables interrupts once
369
// pipeline is again ready.
370
//
371 358 julius
always @(`OR1200_RST_EVENT rst or posedge clk)
372
        if (rst == `OR1200_RST_VALUE)
373 258 julius
                delayed_iee <=  3'b000;
374 10 unneback
        else if (!sr[`OR1200_SR_IEE])
375 258 julius
                delayed_iee <=  3'b000;
376 10 unneback
        else
377 258 julius
                delayed_iee <=  {delayed_iee[1:0], 1'b1};
378 10 unneback
 
379
//
380
// delayed_tee
381
//
382
// SR[TEE] should not enable tick exceptions right away
383
// when it is restored with l.rfe. Instead delayed_tee
384
// together with SR[TEE] enables tick exceptions once
385
// pipeline is again ready.
386
//
387 358 julius
always @(`OR1200_RST_EVENT rst or posedge clk)
388
        if (rst == `OR1200_RST_VALUE)
389 258 julius
                delayed_tee <=  3'b000;
390 10 unneback
        else if (!sr[`OR1200_SR_TEE])
391 258 julius
                delayed_tee <=  3'b000;
392 10 unneback
        else
393 258 julius
                delayed_tee <=  {delayed_tee[1:0], 1'b1};
394 10 unneback
 
395
//
396
// PC and Exception flags pipelines
397
//
398 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst) begin
399
        if (rst == `OR1200_RST_VALUE) begin
400 258 julius
                ex_dslot <=  1'b0;
401
                ex_pc <=  32'd0;
402
                ex_pc_val <=  1'b0 ;
403
                ex_exceptflags <=  3'b000;
404
                delayed1_ex_dslot <=  1'b0;
405
                delayed2_ex_dslot <=  1'b0;
406 10 unneback
        end
407 141 marcus.erl
        else if (ex_flushpipe) begin
408 258 julius
                ex_dslot <=  1'b0;
409
                ex_pc_val <=  1'b0 ;
410
                ex_exceptflags <=  3'b000;
411
                delayed1_ex_dslot <=  1'b0;
412
                delayed2_ex_dslot <=  1'b0;
413 10 unneback
        end
414
        else if (!ex_freeze & id_freeze) begin
415 258 julius
                ex_dslot <=  1'b0;
416
                ex_pc <=  id_pc;
417
                ex_pc_val <=  id_pc_val ;
418
                ex_exceptflags <=  3'b000;
419
                delayed1_ex_dslot <=  ex_dslot;
420
                delayed2_ex_dslot <=  delayed1_ex_dslot;
421 10 unneback
        end
422
        else if (!ex_freeze) begin
423 258 julius
                ex_dslot <=  ex_branch_taken;
424
                ex_pc <=  id_pc;
425
                ex_pc_val <=  id_pc_val ;
426
                ex_exceptflags <=  id_exceptflags;
427
                delayed1_ex_dslot <=  ex_dslot;
428
                delayed2_ex_dslot <=  delayed1_ex_dslot;
429 10 unneback
        end
430
end
431
 
432
//
433
// PC and Exception flags pipelines
434
//
435 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst) begin
436
        if (rst == `OR1200_RST_VALUE) begin
437 258 julius
                wb_pc <=  32'd0;
438
        dl_pc <=  32'd0;
439 10 unneback
        end
440
        else if (!wb_freeze) begin
441 258 julius
                wb_pc <=  ex_pc;
442
        dl_pc <=  wb_pc;
443 10 unneback
        end
444
end
445
 
446
//
447
// We have started execution of exception handler:
448
//  1. Asserted for 3 clock cycles
449
//  2. Don't execute any instruction that is still in pipeline and is not part of exception handler
450
//
451
assign except_flushpipe = |except_trig & ~|state;
452
 
453
//
454
// Exception FSM that sequences execution of exception handler
455
//
456
// except_type signals which exception handler we start fetching in:
457
//  1. Asserted in next clock cycle after exception is recognized
458
//
459 358 julius
   always @(posedge clk or `OR1200_RST_EVENT rst) begin
460
      if (rst == `OR1200_RST_VALUE) begin
461 258 julius
         state <=  `OR1200_EXCEPTFSM_IDLE;
462
         except_type <=  `OR1200_EXCEPT_NONE;
463
         extend_flush <=  1'b0;
464
         epcr <=  32'b0;
465
         eear <=  32'b0;
466
         esr <=  {2'h1, {`OR1200_SR_WIDTH-3{1'b0}}, 1'b1};
467
         extend_flush_last <=  1'b0;
468 808 julius
         dsx <= 1'b0;
469 185 julius
      end
470
      else begin
471 10 unneback
`ifdef OR1200_CASE_DEFAULT
472 185 julius
         case (state)   // synopsys parallel_case
473 10 unneback
`else
474 185 julius
           case (state) // synopsys full_case parallel_case
475 10 unneback
`endif
476 185 julius
             `OR1200_EXCEPTFSM_IDLE:
477
               if (except_flushpipe) begin
478 258 julius
                  state <=  `OR1200_EXCEPTFSM_FLU1;
479
                  extend_flush <=  1'b1;
480
                  esr <=  sr_we ? to_sr : sr;
481 364 julius
                  casez (except_trig)
482 151 marcus.erl
`ifdef OR1200_EXCEPT_ITLBMISS
483 364 julius
                    14'b1?_????_????_????: begin
484 258 julius
                       except_type <=  `OR1200_EXCEPT_ITLBMISS;
485
                       eear <=  ex_dslot ?
486 185 julius
                               ex_pc : ex_pc;
487 258 julius
                       epcr <=  ex_dslot ?
488 185 julius
                               wb_pc : ex_pc;
489 808 julius
                       dsx <= ex_dslot;
490 185 julius
                    end
491 10 unneback
`endif
492
`ifdef OR1200_EXCEPT_IPF
493 364 julius
                    14'b01_????_????_????: begin
494 258 julius
                       except_type <=  `OR1200_EXCEPT_IPF;
495
                       eear <=  ex_dslot ?
496 185 julius
                               ex_pc : delayed1_ex_dslot ?
497
                               id_pc : delayed2_ex_dslot ?
498
                               id_pc : id_pc;
499 258 julius
                       epcr <=  ex_dslot ?
500 185 julius
                               wb_pc : delayed1_ex_dslot ?
501
                               id_pc : delayed2_ex_dslot ?
502
                               id_pc : id_pc;
503 808 julius
                       dsx <= ex_dslot;
504 185 julius
                    end
505 10 unneback
`endif
506
`ifdef OR1200_EXCEPT_BUSERR
507 364 julius
                    14'b00_1???_????_????: begin        // Insn. Bus Error
508 258 julius
                       except_type <=  `OR1200_EXCEPT_BUSERR;
509
                       eear <=  ex_dslot ?
510 185 julius
                               wb_pc : ex_pc;
511 258 julius
                       epcr <=  ex_dslot ?
512 185 julius
                               wb_pc : ex_pc;
513 808 julius
                       dsx <= ex_dslot;
514 185 julius
                    end
515 10 unneback
`endif
516
`ifdef OR1200_EXCEPT_ILLEGAL
517 364 julius
                    14'b00_01??_????_????: begin
518 258 julius
                       except_type <=  `OR1200_EXCEPT_ILLEGAL;
519
                       eear <=  ex_pc;
520
                       epcr <=  ex_dslot ?
521 185 julius
                               wb_pc : ex_pc;
522 808 julius
                       dsx <= ex_dslot;
523 185 julius
                    end
524 10 unneback
`endif
525
`ifdef OR1200_EXCEPT_ALIGN
526 364 julius
                    14'b00_001?_????_????: begin
527 258 julius
                       except_type <=  `OR1200_EXCEPT_ALIGN;
528
                       eear <=  lsu_addr;
529
                       epcr <=  ex_dslot ?
530 185 julius
                               wb_pc : ex_pc;
531 808 julius
                       dsx <= ex_dslot;
532 185 julius
                    end
533 10 unneback
`endif
534
`ifdef OR1200_EXCEPT_DTLBMISS
535 364 julius
                    14'b00_0001_????_????: begin
536 258 julius
                       except_type <=  `OR1200_EXCEPT_DTLBMISS;
537
                       eear <=  lsu_addr;
538
                       epcr <=  ex_dslot ?
539 185 julius
                               wb_pc : delayed1_ex_dslot ?
540
                               dl_pc : ex_pc;
541 808 julius
                       dsx <= ex_dslot;
542 185 julius
                    end
543 10 unneback
`endif
544 185 julius
`ifdef OR1200_EXCEPT_TRAP
545 364 julius
                    14'b00_0000_1???_????: begin
546 258 julius
                       except_type <=  `OR1200_EXCEPT_TRAP;
547
                       epcr <=  ex_dslot ?
548 185 julius
                               wb_pc : delayed1_ex_dslot ?
549
                               id_pc : ex_pc;
550 808 julius
                       dsx <= ex_dslot;
551 185 julius
                    end
552 151 marcus.erl
`endif
553
`ifdef OR1200_EXCEPT_SYSCALL
554 364 julius
                    14'b00_0000_01??_????: begin
555 258 julius
                       except_type <=  `OR1200_EXCEPT_SYSCALL;
556
                       epcr <=  ex_dslot ?
557 185 julius
                               wb_pc : delayed1_ex_dslot ?
558
                               id_pc : delayed2_ex_dslot ?
559
                               id_pc : id_pc;
560 808 julius
                       dsx <= ex_dslot;
561 185 julius
                    end
562 151 marcus.erl
`endif
563 10 unneback
`ifdef OR1200_EXCEPT_DPF
564 364 julius
                    14'b00_0000_001?_????: begin
565 258 julius
                       except_type <=  `OR1200_EXCEPT_DPF;
566
                       eear <=  lsu_addr;
567
                       epcr <=  ex_dslot ?
568 185 julius
                               wb_pc : delayed1_ex_dslot ?
569
                               dl_pc : ex_pc;
570 808 julius
                       dsx <= ex_dslot;
571 185 julius
                    end
572 10 unneback
`endif
573
`ifdef OR1200_EXCEPT_BUSERR
574 364 julius
                    14'b00_0000_0001_????: begin        // Data Bus Error
575 258 julius
                       except_type <=  `OR1200_EXCEPT_BUSERR;
576
                       eear <=  lsu_addr;
577
                       epcr <=  ex_dslot ?
578 185 julius
                               wb_pc : delayed1_ex_dslot ?
579
                               dl_pc : ex_pc;
580 808 julius
                       dsx <= ex_dslot;
581 185 julius
                    end
582 10 unneback
`endif
583
`ifdef OR1200_EXCEPT_RANGE
584 364 julius
                    14'b00_0000_0000_1???: begin
585 258 julius
                       except_type <=  `OR1200_EXCEPT_RANGE;
586
                       epcr <=  ex_dslot ?
587 185 julius
                               wb_pc : delayed1_ex_dslot ?
588 806 julius
                               dl_pc : delayed2_ex_dslot ?
589
                               id_pc : ex_pc;
590 808 julius
                       dsx <= ex_dslot;
591 185 julius
                    end
592 10 unneback
`endif
593 185 julius
`ifdef OR1200_EXCEPT_FLOAT
594 364 julius
                    14'b00_0000_0000_01??: begin
595 258 julius
                       except_type <=  `OR1200_EXCEPT_FLOAT;
596
                       epcr <=  id_pc;
597 808 julius
                       dsx <= ex_dslot;
598 185 julius
                    end
599
`endif
600 151 marcus.erl
`ifdef OR1200_EXCEPT_INT
601 364 julius
                    14'b00_0000_0000_001?: begin
602 258 julius
                       except_type <=  `OR1200_EXCEPT_INT;
603
                       epcr <=  id_pc;
604 808 julius
                       dsx <= ex_dslot;
605 185 julius
                    end
606 10 unneback
`endif
607 151 marcus.erl
`ifdef OR1200_EXCEPT_TICK
608 185 julius
                    14'b00_0000_0000_0001: begin
609 258 julius
                       except_type <=  `OR1200_EXCEPT_TICK;
610
                       epcr <=  id_pc;
611 808 julius
                       dsx <= ex_dslot;
612 185 julius
                    end
613 10 unneback
`endif
614 185 julius
                    default:
615 258 julius
                      except_type <=  `OR1200_EXCEPT_NONE;
616 185 julius
                  endcase
617
               end
618
               else if (pc_we) begin
619 258 julius
                  state <=  `OR1200_EXCEPTFSM_FLU1;
620
                  extend_flush <=  1'b1;
621 185 julius
               end
622
               else begin
623
                  if (epcr_we)
624 258 julius
                    epcr <=  datain;
625 185 julius
                  if (eear_we)
626 258 julius
                    eear <=  datain;
627 185 julius
                  if (esr_we)
628 258 julius
                    esr <=  {datain[`OR1200_SR_WIDTH-1], 1'b1, datain[`OR1200_SR_WIDTH-3:0]};
629 185 julius
               end
630
             `OR1200_EXCEPTFSM_FLU1:
631
               if (icpu_ack_i | icpu_err_i | genpc_freeze)
632 258 julius
                 state <=  `OR1200_EXCEPTFSM_FLU2;
633 185 julius
             `OR1200_EXCEPTFSM_FLU2:
634 10 unneback
`ifdef OR1200_EXCEPT_TRAP
635 185 julius
               if (except_type == `OR1200_EXCEPT_TRAP) begin
636 258 julius
                  state <=  `OR1200_EXCEPTFSM_IDLE;
637
                  extend_flush <=  1'b0;
638
                  extend_flush_last <=  1'b0;
639
                  except_type <=  `OR1200_EXCEPT_NONE;
640 185 julius
               end
641
               else
642 10 unneback
`endif
643 258 julius
                 state <=  `OR1200_EXCEPTFSM_FLU3;
644 185 julius
             `OR1200_EXCEPTFSM_FLU3:
645
               begin
646 258 julius
                  state <=  `OR1200_EXCEPTFSM_FLU4;
647 185 julius
               end
648
             `OR1200_EXCEPTFSM_FLU4: begin
649 258 julius
                state <=  `OR1200_EXCEPTFSM_FLU5;
650
                extend_flush <=  1'b0;
651
                extend_flush_last <=  1'b0; // damjan
652 185 julius
             end
653 10 unneback
`ifdef OR1200_CASE_DEFAULT
654 185 julius
             default: begin
655 10 unneback
`else
656 185 julius
                `OR1200_EXCEPTFSM_FLU5: begin
657 10 unneback
`endif
658 185 julius
                   if (!if_stall && !id_freeze) begin
659 258 julius
                      state <=  `OR1200_EXCEPTFSM_IDLE;
660
                      except_type <=  `OR1200_EXCEPT_NONE;
661
                      extend_flush_last <=  1'b0;
662 185 julius
                   end
663
                end
664
           endcase
665
         end
666
   end
667 10 unneback
 
668
endmodule

powered by: WebSVN 2.1.0

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