//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// OR1200's Exception logic ////
|
//// OR1200's Exception logic ////
|
//// ////
|
//// ////
|
//// This file is part of the OpenRISC 1200 project ////
|
//// This file is part of the OpenRISC 1200 project ////
|
//// http://www.opencores.org/project,or1k ////
|
//// http://www.opencores.org/project,or1k ////
|
//// ////
|
//// ////
|
//// Description ////
|
//// Description ////
|
//// Handles all OR1K exceptions inside CPU block. ////
|
//// Handles all OR1K exceptions inside CPU block. ////
|
//// ////
|
//// ////
|
//// To Do: ////
|
//// To Do: ////
|
//// - make it smaller and faster ////
|
//// - make it smaller and faster ////
|
//// ////
|
//// ////
|
//// Author(s): ////
|
//// Author(s): ////
|
//// - Damjan Lampret, lampret@opencores.org ////
|
//// - Damjan Lampret, lampret@opencores.org ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// the original copyright notice and the associated disclaimer. ////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// Public License as published by the Free Software Foundation; ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// either version 2.1 of the License, or (at your option) any ////
|
//// later version. ////
|
//// later version. ////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
//// details. ////
|
//// details. ////
|
//// ////
|
//// ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// You should have received a copy of the GNU Lesser General ////
|
//// Public License along with this source; if not, download it ////
|
//// Public License along with this source; if not, download it ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// from http://www.opencores.org/lgpl.shtml ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// $Log: or1200_except.v,v $
|
// $Log: or1200_except.v,v $
|
//
|
//
|
// Revision 2.0 2010/06/30 11:00:00 ORSoC
|
// Revision 2.0 2010/06/30 11:00:00 ORSoC
|
// Major update:
|
// Major update:
|
// Structure reordered and bugs fixed.
|
// Structure reordered and bugs fixed.
|
|
|
// synopsys translate_off
|
// synopsys translate_off
|
`include "timescale.v"
|
`include "timescale.v"
|
// synopsys translate_on
|
// synopsys translate_on
|
`include "or1200_defines.v"
|
`include "or1200_defines.v"
|
|
|
`define OR1200_EXCEPTFSM_WIDTH 3
|
`define OR1200_EXCEPTFSM_WIDTH 3
|
`define OR1200_EXCEPTFSM_IDLE `OR1200_EXCEPTFSM_WIDTH'd0
|
`define OR1200_EXCEPTFSM_IDLE `OR1200_EXCEPTFSM_WIDTH'd0
|
`define OR1200_EXCEPTFSM_FLU1 `OR1200_EXCEPTFSM_WIDTH'd1
|
`define OR1200_EXCEPTFSM_FLU1 `OR1200_EXCEPTFSM_WIDTH'd1
|
`define OR1200_EXCEPTFSM_FLU2 `OR1200_EXCEPTFSM_WIDTH'd2
|
`define OR1200_EXCEPTFSM_FLU2 `OR1200_EXCEPTFSM_WIDTH'd2
|
`define OR1200_EXCEPTFSM_FLU3 `OR1200_EXCEPTFSM_WIDTH'd3
|
`define OR1200_EXCEPTFSM_FLU3 `OR1200_EXCEPTFSM_WIDTH'd3
|
`define OR1200_EXCEPTFSM_FLU4 `OR1200_EXCEPTFSM_WIDTH'd4
|
`define OR1200_EXCEPTFSM_FLU4 `OR1200_EXCEPTFSM_WIDTH'd4
|
`define OR1200_EXCEPTFSM_FLU5 `OR1200_EXCEPTFSM_WIDTH'd5
|
`define OR1200_EXCEPTFSM_FLU5 `OR1200_EXCEPTFSM_WIDTH'd5
|
|
|
//
|
//
|
// Exception recognition and sequencing
|
// Exception recognition and sequencing
|
//
|
//
|
|
|
module or1200_except
|
module or1200_except
|
(
|
(
|
// Clock and reset
|
// Clock and reset
|
clk, rst,
|
clk, rst,
|
|
|
// Internal i/f
|
// Internal i/f
|
sig_ibuserr, sig_dbuserr, sig_illegal, sig_align, sig_range, sig_dtlbmiss,
|
sig_ibuserr, sig_dbuserr, sig_illegal, sig_align, sig_range, sig_dtlbmiss,
|
sig_dmmufault, sig_int, sig_syscall, sig_trap, sig_itlbmiss, sig_immufault,
|
sig_dmmufault, sig_int, sig_syscall, sig_trap, sig_itlbmiss, sig_immufault,
|
sig_tick, ex_branch_taken, genpc_freeze, id_freeze, ex_freeze, wb_freeze,
|
sig_tick, ex_branch_taken, genpc_freeze, id_freeze, ex_freeze, wb_freeze,
|
if_stall, if_pc, id_pc, ex_pc, wb_pc, id_flushpipe, ex_flushpipe,
|
if_stall, if_pc, id_pc, ex_pc, wb_pc, id_flushpipe, ex_flushpipe,
|
extend_flush, except_flushpipe, except_type, except_start, except_started,
|
extend_flush, except_flushpipe, except_type, except_start, except_started,
|
except_stop, except_trig, ex_void, abort_mvspr, branch_op, spr_dat_ppc,
|
except_stop, except_trig, ex_void, abort_mvspr, branch_op, spr_dat_ppc,
|
spr_dat_npc, datain, du_dsr, epcr_we, eear_we, esr_we, pc_we, epcr, eear,
|
spr_dat_npc, datain, du_dsr, epcr_we, eear_we, esr_we, pc_we, epcr, eear,
|
du_dmr1, du_hwbkpt, du_hwbkpt_ls_r, esr, sr_we, to_sr, sr, lsu_addr,
|
du_dmr1, du_hwbkpt, du_hwbkpt_ls_r, esr, sr_we, to_sr, sr, lsu_addr,
|
abort_ex, icpu_ack_i, icpu_err_i, dcpu_ack_i, dcpu_err_i, sig_fp, fpcsr_fpee
|
abort_ex, icpu_ack_i, icpu_err_i, dcpu_ack_i, dcpu_err_i, sig_fp, fpcsr_fpee
|
|
|
);
|
);
|
|
|
//
|
//
|
// I/O
|
// I/O
|
//
|
//
|
input clk;
|
input clk;
|
input rst;
|
input rst;
|
input sig_ibuserr;
|
input sig_ibuserr;
|
input sig_dbuserr;
|
input sig_dbuserr;
|
input sig_illegal;
|
input sig_illegal;
|
input sig_align;
|
input sig_align;
|
input sig_range;
|
input sig_range;
|
input sig_dtlbmiss;
|
input sig_dtlbmiss;
|
input sig_dmmufault;
|
input sig_dmmufault;
|
input sig_int;
|
input sig_int;
|
input sig_syscall;
|
input sig_syscall;
|
input sig_trap;
|
input sig_trap;
|
input sig_itlbmiss;
|
input sig_itlbmiss;
|
input sig_immufault;
|
input sig_immufault;
|
input sig_tick;
|
input sig_tick;
|
input sig_fp;
|
input sig_fp;
|
input fpcsr_fpee;
|
input fpcsr_fpee;
|
input ex_branch_taken;
|
input ex_branch_taken;
|
input genpc_freeze;
|
input genpc_freeze;
|
input id_freeze;
|
input id_freeze;
|
input ex_freeze;
|
input ex_freeze;
|
input wb_freeze;
|
input wb_freeze;
|
input if_stall;
|
input if_stall;
|
input [31:0] if_pc;
|
input [31:0] if_pc;
|
output [31:0] id_pc;
|
output [31:0] id_pc;
|
output [31:0] ex_pc;
|
output [31:0] ex_pc;
|
output [31:0] wb_pc;
|
output [31:0] wb_pc;
|
input [31:0] datain;
|
input [31:0] datain;
|
input [`OR1200_DU_DSR_WIDTH-1:0] du_dsr;
|
input [`OR1200_DU_DSR_WIDTH-1:0] du_dsr;
|
input [24:0] du_dmr1;
|
input [24:0] du_dmr1;
|
input du_hwbkpt;
|
input du_hwbkpt;
|
input du_hwbkpt_ls_r;
|
input du_hwbkpt_ls_r;
|
input epcr_we;
|
input epcr_we;
|
input eear_we;
|
input eear_we;
|
input esr_we;
|
input esr_we;
|
input pc_we;
|
input pc_we;
|
output [31:0] epcr;
|
output [31:0] epcr;
|
output [31:0] eear;
|
output [31:0] eear;
|
output [`OR1200_SR_WIDTH-1:0] esr;
|
output [`OR1200_SR_WIDTH-1:0] esr;
|
input [`OR1200_SR_WIDTH-1:0] to_sr;
|
input [`OR1200_SR_WIDTH-1:0] to_sr;
|
input sr_we;
|
input sr_we;
|
input [`OR1200_SR_WIDTH-1:0] sr;
|
input [`OR1200_SR_WIDTH-1:0] sr;
|
input [31:0] lsu_addr;
|
input [31:0] lsu_addr;
|
input id_flushpipe;
|
input id_flushpipe;
|
input ex_flushpipe;
|
input ex_flushpipe;
|
output except_flushpipe;
|
output except_flushpipe;
|
output extend_flush;
|
output extend_flush;
|
output [`OR1200_EXCEPT_WIDTH-1:0] except_type;
|
output [`OR1200_EXCEPT_WIDTH-1:0] except_type;
|
output except_start;
|
output except_start;
|
output except_started;
|
output except_started;
|
output [13:0] except_stop;
|
output [13:0] except_stop;
|
output [13:0] except_trig;
|
output [13:0] except_trig;
|
input ex_void;
|
input ex_void;
|
input [`OR1200_BRANCHOP_WIDTH-1:0] branch_op;
|
input [`OR1200_BRANCHOP_WIDTH-1:0] branch_op;
|
output [31:0] spr_dat_ppc;
|
output [31:0] spr_dat_ppc;
|
output [31:0] spr_dat_npc;
|
output [31:0] spr_dat_npc;
|
output abort_ex;
|
output abort_ex;
|
output abort_mvspr;
|
output abort_mvspr;
|
input icpu_ack_i;
|
input icpu_ack_i;
|
input icpu_err_i;
|
input icpu_err_i;
|
input dcpu_ack_i;
|
input dcpu_ack_i;
|
input dcpu_err_i;
|
input dcpu_err_i;
|
|
|
//
|
//
|
// Internal regs and wires
|
// Internal regs and wires
|
//
|
//
|
reg [`OR1200_EXCEPT_WIDTH-1:0] except_type /* verilator public */;
|
reg [`OR1200_EXCEPT_WIDTH-1:0] except_type /* verilator public */;
|
reg [31:0] id_pc /* verilator public */;
|
reg [31:0] id_pc /* verilator public */;
|
reg id_pc_val;
|
reg id_pc_val;
|
reg [31:0] ex_pc /* verilator public */;
|
reg [31:0] ex_pc /* verilator public */;
|
reg ex_pc_val;
|
reg ex_pc_val;
|
reg [31:0] wb_pc /* verilator public */;
|
reg [31:0] wb_pc /* verilator public */;
|
reg [31:0] dl_pc;
|
reg [31:0] dl_pc;
|
reg [31:0] epcr;
|
reg [31:0] epcr;
|
reg [31:0] eear;
|
reg [31:0] eear;
|
reg [`OR1200_SR_WIDTH-1:0] esr;
|
reg [`OR1200_SR_WIDTH-1:0] esr;
|
reg [2:0] id_exceptflags;
|
reg [2:0] id_exceptflags;
|
reg [2:0] ex_exceptflags;
|
reg [2:0] ex_exceptflags;
|
reg [`OR1200_EXCEPTFSM_WIDTH-1:0] state;
|
reg [`OR1200_EXCEPTFSM_WIDTH-1:0] state;
|
reg extend_flush;
|
reg extend_flush;
|
reg extend_flush_last;
|
reg extend_flush_last;
|
reg ex_dslot /* verilator public */;
|
reg ex_dslot /* verilator public */;
|
reg delayed1_ex_dslot;
|
reg delayed1_ex_dslot;
|
reg delayed2_ex_dslot;
|
reg delayed2_ex_dslot;
|
wire except_started;
|
wire except_started;
|
wire except_flushpipe /* verilator public */;
|
wire except_flushpipe /* verilator public */;
|
reg [2:0] delayed_iee;
|
reg [2:0] delayed_iee;
|
reg [2:0] delayed_tee;
|
reg [2:0] delayed_tee;
|
wire int_pending;
|
wire int_pending;
|
wire tick_pending;
|
wire tick_pending;
|
wire fp_pending;
|
wire fp_pending;
|
|
wire range_pending;
|
|
|
reg trace_trap ;
|
reg trace_trap ;
|
reg ex_freeze_prev;
|
reg ex_freeze_prev;
|
reg sr_ted_prev;
|
reg sr_ted_prev;
|
reg dsr_te_prev;
|
reg dsr_te_prev;
|
reg dmr1_st_prev ;
|
reg dmr1_st_prev ;
|
reg dmr1_bt_prev ;
|
reg dmr1_bt_prev ;
|
wire dsr_te = ex_freeze_prev ? dsr_te_prev : du_dsr[`OR1200_DU_DSR_TE];
|
wire dsr_te = ex_freeze_prev ? dsr_te_prev : du_dsr[`OR1200_DU_DSR_TE];
|
wire sr_ted = ex_freeze_prev ? sr_ted_prev : sr[`OR1200_SR_TED];
|
wire sr_ted = ex_freeze_prev ? sr_ted_prev : sr[`OR1200_SR_TED];
|
wire dmr1_st = ex_freeze_prev ? dmr1_st_prev: du_dmr1[`OR1200_DU_DMR1_ST] ;
|
wire dmr1_st = ex_freeze_prev ? dmr1_st_prev: du_dmr1[`OR1200_DU_DMR1_ST] ;
|
wire dmr1_bt = ex_freeze_prev ? dmr1_bt_prev: du_dmr1[`OR1200_DU_DMR1_BT] ;
|
wire dmr1_bt = ex_freeze_prev ? dmr1_bt_prev: du_dmr1[`OR1200_DU_DMR1_BT] ;
|
|
|
//
|
//
|
// Simple combinatorial logic
|
// Simple combinatorial logic
|
//
|
//
|
assign except_started = extend_flush & except_start;
|
assign except_started = extend_flush & except_start;
|
|
|
assign except_start = (except_type != `OR1200_EXCEPT_NONE) & extend_flush;
|
assign except_start = (except_type != `OR1200_EXCEPT_NONE) & extend_flush;
|
|
|
assign int_pending = sig_int & (sr[`OR1200_SR_IEE] |
|
assign int_pending = sig_int & (sr[`OR1200_SR_IEE] |
|
(sr_we & to_sr[`OR1200_SR_IEE]))
|
(sr_we & to_sr[`OR1200_SR_IEE]))
|
& id_pc_val & delayed_iee[2] & ~ex_freeze & ~ex_branch_taken
|
& id_pc_val & delayed_iee[2] & ~ex_freeze & ~ex_branch_taken
|
& ~ex_dslot & ~(sr_we & ~to_sr[`OR1200_SR_IEE]);
|
& ~ex_dslot & ~(sr_we & ~to_sr[`OR1200_SR_IEE]);
|
|
|
assign tick_pending = sig_tick & (sr[`OR1200_SR_TEE] |
|
assign tick_pending = sig_tick & (sr[`OR1200_SR_TEE] |
|
(sr_we & to_sr[`OR1200_SR_TEE])) & id_pc_val
|
(sr_we & to_sr[`OR1200_SR_TEE])) & id_pc_val
|
& delayed_tee[2] & ~ex_freeze & ~ex_branch_taken
|
& delayed_tee[2] & ~ex_freeze & ~ex_branch_taken
|
& ~ex_dslot & ~(sr_we & ~to_sr[`OR1200_SR_TEE]);
|
& ~ex_dslot & ~(sr_we & ~to_sr[`OR1200_SR_TEE]);
|
|
|
assign fp_pending = sig_fp & fpcsr_fpee & ~ex_freeze & ~ex_branch_taken
|
assign fp_pending = sig_fp & fpcsr_fpee & ~ex_freeze & ~ex_branch_taken
|
& ~ex_dslot;
|
& ~ex_dslot;
|
|
|
|
`ifdef OR1200_IMPL_OVE
|
|
assign range_pending = sig_range & sr[`OR1200_SR_OVE] & ~ex_freeze &
|
|
~ex_branch_taken & ~ex_dslot;
|
|
`else
|
|
assign range_pending = 0;
|
|
`endif
|
|
|
// Abort write into RF by load & other instructions
|
// Abort write into RF by load & other instructions
|
assign abort_ex = sig_dbuserr | sig_dmmufault | sig_dtlbmiss | sig_align |
|
assign abort_ex = sig_dbuserr | sig_dmmufault | sig_dtlbmiss | sig_align |
|
sig_illegal | ((du_hwbkpt | trace_trap) & ex_pc_val
|
sig_illegal | ((du_hwbkpt | trace_trap) & ex_pc_val
|
& !sr_ted & !dsr_te);
|
& !sr_ted & !dsr_te);
|
|
|
// abort spr read/writes
|
// abort spr read/writes
|
assign abort_mvspr = sig_illegal | ((du_hwbkpt | trace_trap) & ex_pc_val
|
assign abort_mvspr = sig_illegal | ((du_hwbkpt | trace_trap) & ex_pc_val
|
& !sr_ted & !dsr_te) ;
|
& !sr_ted & !dsr_te) ;
|
assign spr_dat_ppc = wb_pc;
|
assign spr_dat_ppc = wb_pc;
|
|
|
assign spr_dat_npc = ex_void ? id_pc : ex_pc;
|
assign spr_dat_npc = ex_void ? id_pc : ex_pc;
|
|
|
//
|
//
|
// Order defines exception detection priority
|
// Order defines exception detection priority
|
//
|
//
|
assign except_trig = {
|
assign except_trig = {
|
ex_exceptflags[1] & ~du_dsr[`OR1200_DU_DSR_IME],
|
ex_exceptflags[1] & ~du_dsr[`OR1200_DU_DSR_IME],
|
ex_exceptflags[0] & ~du_dsr[`OR1200_DU_DSR_IPFE],
|
ex_exceptflags[0] & ~du_dsr[`OR1200_DU_DSR_IPFE],
|
ex_exceptflags[2] & ~du_dsr[`OR1200_DU_DSR_BUSEE],
|
ex_exceptflags[2] & ~du_dsr[`OR1200_DU_DSR_BUSEE],
|
sig_illegal & ~du_dsr[`OR1200_DU_DSR_IIE],
|
sig_illegal & ~du_dsr[`OR1200_DU_DSR_IIE],
|
sig_align & ~du_dsr[`OR1200_DU_DSR_AE],
|
sig_align & ~du_dsr[`OR1200_DU_DSR_AE],
|
sig_dtlbmiss & ~du_dsr[`OR1200_DU_DSR_DME],
|
sig_dtlbmiss & ~du_dsr[`OR1200_DU_DSR_DME],
|
sig_trap & ~du_dsr[`OR1200_DU_DSR_TE],
|
sig_trap & ~du_dsr[`OR1200_DU_DSR_TE],
|
sig_syscall & ~du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
|
sig_syscall & ~du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
|
sig_dmmufault & ~du_dsr[`OR1200_DU_DSR_DPFE],
|
sig_dmmufault & ~du_dsr[`OR1200_DU_DSR_DPFE],
|
sig_dbuserr & ~du_dsr[`OR1200_DU_DSR_BUSEE],
|
sig_dbuserr & ~du_dsr[`OR1200_DU_DSR_BUSEE],
|
sig_range & ~du_dsr[`OR1200_DU_DSR_RE],
|
range_pending & ~du_dsr[`OR1200_DU_DSR_RE],
|
fp_pending & ~du_dsr[`OR1200_DU_DSR_FPE],
|
fp_pending & ~du_dsr[`OR1200_DU_DSR_FPE],
|
int_pending & ~du_dsr[`OR1200_DU_DSR_IE],
|
int_pending & ~du_dsr[`OR1200_DU_DSR_IE],
|
tick_pending & ~du_dsr[`OR1200_DU_DSR_TTE]
|
tick_pending & ~du_dsr[`OR1200_DU_DSR_TTE]
|
};
|
};
|
|
|
wire trace_cond = !ex_freeze && !ex_void && (1'b0
|
wire trace_cond = !ex_freeze && !ex_void && (1'b0
|
`ifdef OR1200_DU_DMR1_ST
|
`ifdef OR1200_DU_DMR1_ST
|
|| dmr1_st
|
|| dmr1_st
|
`endif
|
`endif
|
`ifdef OR1200_DU_DMR1_BT
|
`ifdef OR1200_DU_DMR1_BT
|
|| ((branch_op != `OR1200_BRANCHOP_NOP) && (branch_op != `OR1200_BRANCHOP_RFE) && dmr1_bt)
|
|| ((branch_op != `OR1200_BRANCHOP_NOP) && (branch_op != `OR1200_BRANCHOP_RFE) && dmr1_bt)
|
`endif
|
`endif
|
);
|
);
|
|
|
assign except_stop = {
|
assign except_stop = {
|
tick_pending & du_dsr[`OR1200_DU_DSR_TTE],
|
tick_pending & du_dsr[`OR1200_DU_DSR_TTE],
|
int_pending & du_dsr[`OR1200_DU_DSR_IE],
|
int_pending & du_dsr[`OR1200_DU_DSR_IE],
|
ex_exceptflags[1] & du_dsr[`OR1200_DU_DSR_IME],
|
ex_exceptflags[1] & du_dsr[`OR1200_DU_DSR_IME],
|
ex_exceptflags[0] & du_dsr[`OR1200_DU_DSR_IPFE],
|
ex_exceptflags[0] & du_dsr[`OR1200_DU_DSR_IPFE],
|
ex_exceptflags[2] & du_dsr[`OR1200_DU_DSR_BUSEE],
|
ex_exceptflags[2] & du_dsr[`OR1200_DU_DSR_BUSEE],
|
sig_illegal & du_dsr[`OR1200_DU_DSR_IIE],
|
sig_illegal & du_dsr[`OR1200_DU_DSR_IIE],
|
sig_align & du_dsr[`OR1200_DU_DSR_AE],
|
sig_align & du_dsr[`OR1200_DU_DSR_AE],
|
sig_dtlbmiss & du_dsr[`OR1200_DU_DSR_DME],
|
sig_dtlbmiss & du_dsr[`OR1200_DU_DSR_DME],
|
sig_dmmufault & du_dsr[`OR1200_DU_DSR_DPFE],
|
sig_dmmufault & du_dsr[`OR1200_DU_DSR_DPFE],
|
sig_dbuserr & du_dsr[`OR1200_DU_DSR_BUSEE],
|
sig_dbuserr & du_dsr[`OR1200_DU_DSR_BUSEE],
|
sig_range & du_dsr[`OR1200_DU_DSR_RE],
|
range_pending & du_dsr[`OR1200_DU_DSR_RE],
|
sig_trap & du_dsr[`OR1200_DU_DSR_TE],
|
sig_trap & du_dsr[`OR1200_DU_DSR_TE],
|
fp_pending & du_dsr[`OR1200_DU_DSR_FPE],
|
fp_pending & du_dsr[`OR1200_DU_DSR_FPE],
|
sig_syscall & du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze
|
sig_syscall & du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze
|
};
|
};
|
|
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
trace_trap <= 1'b0 ;
|
trace_trap <= 1'b0 ;
|
end
|
end
|
else if (!(trace_trap && !ex_pc_val)) begin
|
else if (!(trace_trap && !ex_pc_val)) begin
|
trace_trap <= trace_cond & !dsr_te & !sr_ted ;
|
trace_trap <= trace_cond & !dsr_te & !sr_ted ;
|
end
|
end
|
end
|
end
|
|
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
ex_freeze_prev <= 1'b0 ;
|
ex_freeze_prev <= 1'b0 ;
|
sr_ted_prev <= 1'b0 ;
|
sr_ted_prev <= 1'b0 ;
|
dsr_te_prev <= 1'b0 ;
|
dsr_te_prev <= 1'b0 ;
|
dmr1_st_prev <= 1'b0 ;
|
dmr1_st_prev <= 1'b0 ;
|
dmr1_bt_prev <= 1'b0 ;
|
dmr1_bt_prev <= 1'b0 ;
|
end
|
end
|
else begin
|
else begin
|
ex_freeze_prev <= ex_freeze ;
|
ex_freeze_prev <= ex_freeze ;
|
if (!ex_freeze_prev || ex_void) begin
|
if (!ex_freeze_prev || ex_void) begin
|
sr_ted_prev <= sr [`OR1200_SR_TED ] ;
|
sr_ted_prev <= sr [`OR1200_SR_TED ] ;
|
dsr_te_prev <= du_dsr [`OR1200_DU_DSR_TE ] ;
|
dsr_te_prev <= du_dsr [`OR1200_DU_DSR_TE ] ;
|
dmr1_st_prev <= du_dmr1[`OR1200_DU_DMR1_ST] ;
|
dmr1_st_prev <= du_dmr1[`OR1200_DU_DMR1_ST] ;
|
dmr1_bt_prev <= du_dmr1[`OR1200_DU_DMR1_BT] ;
|
dmr1_bt_prev <= du_dmr1[`OR1200_DU_DMR1_BT] ;
|
end
|
end
|
end
|
end
|
end
|
end
|
|
|
`ifdef verilator
|
`ifdef verilator
|
// Function to access wb_pc (for Verilator). Have to hide this from
|
// Function to access wb_pc (for Verilator). Have to hide this from
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// 1364-2001.
|
// 1364-2001.
|
function [31:0] get_wb_pc;
|
function [31:0] get_wb_pc;
|
// verilator public
|
// verilator public
|
get_wb_pc = wb_pc;
|
get_wb_pc = wb_pc;
|
endfunction // get_wb_pc
|
endfunction // get_wb_pc
|
|
|
// Function to access id_pc (for Verilator). Have to hide this from
|
// Function to access id_pc (for Verilator). Have to hide this from
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// 1364-2001.
|
// 1364-2001.
|
function [31:0] get_id_pc;
|
function [31:0] get_id_pc;
|
// verilator public
|
// verilator public
|
get_id_pc = id_pc;
|
get_id_pc = id_pc;
|
endfunction // get_id_pc
|
endfunction // get_id_pc
|
|
|
// Function to access ex_pc (for Verilator). Have to hide this from
|
// Function to access ex_pc (for Verilator). Have to hide this from
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// 1364-2001.
|
// 1364-2001.
|
function [31:0] get_ex_pc;
|
function [31:0] get_ex_pc;
|
// verilator public
|
// verilator public
|
get_ex_pc = ex_pc;
|
get_ex_pc = ex_pc;
|
endfunction // get_ex_pc
|
endfunction // get_ex_pc
|
// Function to access except_type[3:0] (for Verilator). Have to hide this from
|
// Function to access except_type[3:0] (for Verilator). Have to hide this from
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// simulator, since functions with no inputs are not allowed in IEEE
|
// 1364-2001.
|
// 1364-2001.
|
function [3:0] get_except_type;
|
function [3:0] get_except_type;
|
// verilator public
|
// verilator public
|
get_except_type = except_type;
|
get_except_type = except_type;
|
endfunction // get_except_type
|
endfunction // get_except_type
|
|
|
`endif
|
`endif
|
|
|
|
|
//
|
//
|
// PC and Exception flags pipelines
|
// PC and Exception flags pipelines
|
//
|
//
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
id_pc <= 32'd0;
|
id_pc <= 32'd0;
|
id_pc_val <= 1'b0 ;
|
id_pc_val <= 1'b0 ;
|
id_exceptflags <= 3'b000;
|
id_exceptflags <= 3'b000;
|
end
|
end
|
else if (id_flushpipe) begin
|
else if (id_flushpipe) begin
|
id_pc_val <= 1'b0 ;
|
id_pc_val <= 1'b0 ;
|
id_exceptflags <= 3'b000;
|
id_exceptflags <= 3'b000;
|
end
|
end
|
else if (!id_freeze) begin
|
else if (!id_freeze) begin
|
id_pc <= if_pc;
|
id_pc <= if_pc;
|
id_pc_val <= 1'b1 ;
|
id_pc_val <= 1'b1 ;
|
id_exceptflags <= { sig_ibuserr, sig_itlbmiss, sig_immufault };
|
id_exceptflags <= { sig_ibuserr, sig_itlbmiss, sig_immufault };
|
end
|
end
|
end
|
end
|
|
|
//
|
//
|
// delayed_iee
|
// delayed_iee
|
//
|
//
|
// SR[IEE] should not enable interrupts right away
|
// SR[IEE] should not enable interrupts right away
|
// when it is restored with l.rfe. Instead delayed_iee
|
// when it is restored with l.rfe. Instead delayed_iee
|
// together with SR[IEE] enables interrupts once
|
// together with SR[IEE] enables interrupts once
|
// pipeline is again ready.
|
// pipeline is again ready.
|
//
|
//
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
if (rst == `OR1200_RST_VALUE)
|
if (rst == `OR1200_RST_VALUE)
|
delayed_iee <= 3'b000;
|
delayed_iee <= 3'b000;
|
else if (!sr[`OR1200_SR_IEE])
|
else if (!sr[`OR1200_SR_IEE])
|
delayed_iee <= 3'b000;
|
delayed_iee <= 3'b000;
|
else
|
else
|
delayed_iee <= {delayed_iee[1:0], 1'b1};
|
delayed_iee <= {delayed_iee[1:0], 1'b1};
|
|
|
//
|
//
|
// delayed_tee
|
// delayed_tee
|
//
|
//
|
// SR[TEE] should not enable tick exceptions right away
|
// SR[TEE] should not enable tick exceptions right away
|
// when it is restored with l.rfe. Instead delayed_tee
|
// when it is restored with l.rfe. Instead delayed_tee
|
// together with SR[TEE] enables tick exceptions once
|
// together with SR[TEE] enables tick exceptions once
|
// pipeline is again ready.
|
// pipeline is again ready.
|
//
|
//
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
if (rst == `OR1200_RST_VALUE)
|
if (rst == `OR1200_RST_VALUE)
|
delayed_tee <= 3'b000;
|
delayed_tee <= 3'b000;
|
else if (!sr[`OR1200_SR_TEE])
|
else if (!sr[`OR1200_SR_TEE])
|
delayed_tee <= 3'b000;
|
delayed_tee <= 3'b000;
|
else
|
else
|
delayed_tee <= {delayed_tee[1:0], 1'b1};
|
delayed_tee <= {delayed_tee[1:0], 1'b1};
|
|
|
//
|
//
|
// PC and Exception flags pipelines
|
// PC and Exception flags pipelines
|
//
|
//
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
ex_dslot <= 1'b0;
|
ex_dslot <= 1'b0;
|
ex_pc <= 32'd0;
|
ex_pc <= 32'd0;
|
ex_pc_val <= 1'b0 ;
|
ex_pc_val <= 1'b0 ;
|
ex_exceptflags <= 3'b000;
|
ex_exceptflags <= 3'b000;
|
delayed1_ex_dslot <= 1'b0;
|
delayed1_ex_dslot <= 1'b0;
|
delayed2_ex_dslot <= 1'b0;
|
delayed2_ex_dslot <= 1'b0;
|
end
|
end
|
else if (ex_flushpipe) begin
|
else if (ex_flushpipe) begin
|
ex_dslot <= 1'b0;
|
ex_dslot <= 1'b0;
|
ex_pc_val <= 1'b0 ;
|
ex_pc_val <= 1'b0 ;
|
ex_exceptflags <= 3'b000;
|
ex_exceptflags <= 3'b000;
|
delayed1_ex_dslot <= 1'b0;
|
delayed1_ex_dslot <= 1'b0;
|
delayed2_ex_dslot <= 1'b0;
|
delayed2_ex_dslot <= 1'b0;
|
end
|
end
|
else if (!ex_freeze & id_freeze) begin
|
else if (!ex_freeze & id_freeze) begin
|
ex_dslot <= 1'b0;
|
ex_dslot <= 1'b0;
|
ex_pc <= id_pc;
|
ex_pc <= id_pc;
|
ex_pc_val <= id_pc_val ;
|
ex_pc_val <= id_pc_val ;
|
ex_exceptflags <= 3'b000;
|
ex_exceptflags <= 3'b000;
|
delayed1_ex_dslot <= ex_dslot;
|
delayed1_ex_dslot <= ex_dslot;
|
delayed2_ex_dslot <= delayed1_ex_dslot;
|
delayed2_ex_dslot <= delayed1_ex_dslot;
|
end
|
end
|
else if (!ex_freeze) begin
|
else if (!ex_freeze) begin
|
ex_dslot <= ex_branch_taken;
|
ex_dslot <= ex_branch_taken;
|
ex_pc <= id_pc;
|
ex_pc <= id_pc;
|
ex_pc_val <= id_pc_val ;
|
ex_pc_val <= id_pc_val ;
|
ex_exceptflags <= id_exceptflags;
|
ex_exceptflags <= id_exceptflags;
|
delayed1_ex_dslot <= ex_dslot;
|
delayed1_ex_dslot <= ex_dslot;
|
delayed2_ex_dslot <= delayed1_ex_dslot;
|
delayed2_ex_dslot <= delayed1_ex_dslot;
|
end
|
end
|
end
|
end
|
|
|
//
|
//
|
// PC and Exception flags pipelines
|
// PC and Exception flags pipelines
|
//
|
//
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
wb_pc <= 32'd0;
|
wb_pc <= 32'd0;
|
dl_pc <= 32'd0;
|
dl_pc <= 32'd0;
|
end
|
end
|
else if (!wb_freeze) begin
|
else if (!wb_freeze) begin
|
wb_pc <= ex_pc;
|
wb_pc <= ex_pc;
|
dl_pc <= wb_pc;
|
dl_pc <= wb_pc;
|
end
|
end
|
end
|
end
|
|
|
//
|
//
|
// We have started execution of exception handler:
|
// We have started execution of exception handler:
|
// 1. Asserted for 3 clock cycles
|
// 1. Asserted for 3 clock cycles
|
// 2. Don't execute any instruction that is still in pipeline and is not part of exception handler
|
// 2. Don't execute any instruction that is still in pipeline and is not part of exception handler
|
//
|
//
|
assign except_flushpipe = |except_trig & ~|state;
|
assign except_flushpipe = |except_trig & ~|state;
|
|
|
//
|
//
|
// Exception FSM that sequences execution of exception handler
|
// Exception FSM that sequences execution of exception handler
|
//
|
//
|
// except_type signals which exception handler we start fetching in:
|
// except_type signals which exception handler we start fetching in:
|
// 1. Asserted in next clock cycle after exception is recognized
|
// 1. Asserted in next clock cycle after exception is recognized
|
//
|
//
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
always @(posedge clk or `OR1200_RST_EVENT rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
state <= `OR1200_EXCEPTFSM_IDLE;
|
state <= `OR1200_EXCEPTFSM_IDLE;
|
except_type <= `OR1200_EXCEPT_NONE;
|
except_type <= `OR1200_EXCEPT_NONE;
|
extend_flush <= 1'b0;
|
extend_flush <= 1'b0;
|
epcr <= 32'b0;
|
epcr <= 32'b0;
|
eear <= 32'b0;
|
eear <= 32'b0;
|
esr <= {2'h1, {`OR1200_SR_WIDTH-3{1'b0}}, 1'b1};
|
esr <= {2'h1, {`OR1200_SR_WIDTH-3{1'b0}}, 1'b1};
|
extend_flush_last <= 1'b0;
|
extend_flush_last <= 1'b0;
|
end
|
end
|
else begin
|
else begin
|
`ifdef OR1200_CASE_DEFAULT
|
`ifdef OR1200_CASE_DEFAULT
|
case (state) // synopsys parallel_case
|
case (state) // synopsys parallel_case
|
`else
|
`else
|
case (state) // synopsys full_case parallel_case
|
case (state) // synopsys full_case parallel_case
|
`endif
|
`endif
|
`OR1200_EXCEPTFSM_IDLE:
|
`OR1200_EXCEPTFSM_IDLE:
|
if (except_flushpipe) begin
|
if (except_flushpipe) begin
|
state <= `OR1200_EXCEPTFSM_FLU1;
|
state <= `OR1200_EXCEPTFSM_FLU1;
|
extend_flush <= 1'b1;
|
extend_flush <= 1'b1;
|
esr <= sr_we ? to_sr : sr;
|
esr <= sr_we ? to_sr : sr;
|
casez (except_trig)
|
casez (except_trig)
|
`ifdef OR1200_EXCEPT_ITLBMISS
|
`ifdef OR1200_EXCEPT_ITLBMISS
|
14'b1?_????_????_????: begin
|
14'b1?_????_????_????: begin
|
except_type <= `OR1200_EXCEPT_ITLBMISS;
|
except_type <= `OR1200_EXCEPT_ITLBMISS;
|
eear <= ex_dslot ?
|
eear <= ex_dslot ?
|
ex_pc : ex_pc;
|
ex_pc : ex_pc;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : ex_pc;
|
wb_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_IPF
|
`ifdef OR1200_EXCEPT_IPF
|
14'b01_????_????_????: begin
|
14'b01_????_????_????: begin
|
except_type <= `OR1200_EXCEPT_IPF;
|
except_type <= `OR1200_EXCEPT_IPF;
|
eear <= ex_dslot ?
|
eear <= ex_dslot ?
|
ex_pc : delayed1_ex_dslot ?
|
ex_pc : delayed1_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : id_pc;
|
id_pc : id_pc;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : id_pc;
|
id_pc : id_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_BUSERR
|
`ifdef OR1200_EXCEPT_BUSERR
|
14'b00_1???_????_????: begin // Insn. Bus Error
|
14'b00_1???_????_????: begin // Insn. Bus Error
|
except_type <= `OR1200_EXCEPT_BUSERR;
|
except_type <= `OR1200_EXCEPT_BUSERR;
|
eear <= ex_dslot ?
|
eear <= ex_dslot ?
|
wb_pc : ex_pc;
|
wb_pc : ex_pc;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : ex_pc;
|
wb_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_ILLEGAL
|
`ifdef OR1200_EXCEPT_ILLEGAL
|
14'b00_01??_????_????: begin
|
14'b00_01??_????_????: begin
|
except_type <= `OR1200_EXCEPT_ILLEGAL;
|
except_type <= `OR1200_EXCEPT_ILLEGAL;
|
eear <= ex_pc;
|
eear <= ex_pc;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : ex_pc;
|
wb_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_ALIGN
|
`ifdef OR1200_EXCEPT_ALIGN
|
14'b00_001?_????_????: begin
|
14'b00_001?_????_????: begin
|
except_type <= `OR1200_EXCEPT_ALIGN;
|
except_type <= `OR1200_EXCEPT_ALIGN;
|
eear <= lsu_addr;
|
eear <= lsu_addr;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : ex_pc;
|
wb_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_DTLBMISS
|
`ifdef OR1200_EXCEPT_DTLBMISS
|
14'b00_0001_????_????: begin
|
14'b00_0001_????_????: begin
|
except_type <= `OR1200_EXCEPT_DTLBMISS;
|
except_type <= `OR1200_EXCEPT_DTLBMISS;
|
eear <= lsu_addr;
|
eear <= lsu_addr;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
dl_pc : ex_pc;
|
dl_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_TRAP
|
`ifdef OR1200_EXCEPT_TRAP
|
14'b00_0000_1???_????: begin
|
14'b00_0000_1???_????: begin
|
except_type <= `OR1200_EXCEPT_TRAP;
|
except_type <= `OR1200_EXCEPT_TRAP;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
id_pc : ex_pc;
|
id_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_SYSCALL
|
`ifdef OR1200_EXCEPT_SYSCALL
|
14'b00_0000_01??_????: begin
|
14'b00_0000_01??_????: begin
|
except_type <= `OR1200_EXCEPT_SYSCALL;
|
except_type <= `OR1200_EXCEPT_SYSCALL;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : id_pc;
|
id_pc : id_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_DPF
|
`ifdef OR1200_EXCEPT_DPF
|
14'b00_0000_001?_????: begin
|
14'b00_0000_001?_????: begin
|
except_type <= `OR1200_EXCEPT_DPF;
|
except_type <= `OR1200_EXCEPT_DPF;
|
eear <= lsu_addr;
|
eear <= lsu_addr;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
dl_pc : ex_pc;
|
dl_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_BUSERR
|
`ifdef OR1200_EXCEPT_BUSERR
|
14'b00_0000_0001_????: begin // Data Bus Error
|
14'b00_0000_0001_????: begin // Data Bus Error
|
except_type <= `OR1200_EXCEPT_BUSERR;
|
except_type <= `OR1200_EXCEPT_BUSERR;
|
eear <= lsu_addr;
|
eear <= lsu_addr;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
dl_pc : ex_pc;
|
dl_pc : ex_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_RANGE
|
`ifdef OR1200_EXCEPT_RANGE
|
14'b00_0000_0000_1???: begin
|
14'b00_0000_0000_1???: begin
|
except_type <= `OR1200_EXCEPT_RANGE;
|
except_type <= `OR1200_EXCEPT_RANGE;
|
epcr <= ex_dslot ?
|
epcr <= ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
wb_pc : delayed1_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : delayed2_ex_dslot ?
|
id_pc : id_pc;
|
id_pc : id_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_FLOAT
|
`ifdef OR1200_EXCEPT_FLOAT
|
14'b00_0000_0000_01??: begin
|
14'b00_0000_0000_01??: begin
|
except_type <= `OR1200_EXCEPT_FLOAT;
|
except_type <= `OR1200_EXCEPT_FLOAT;
|
epcr <= id_pc;
|
epcr <= id_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_INT
|
`ifdef OR1200_EXCEPT_INT
|
14'b00_0000_0000_001?: begin
|
14'b00_0000_0000_001?: begin
|
except_type <= `OR1200_EXCEPT_INT;
|
except_type <= `OR1200_EXCEPT_INT;
|
epcr <= id_pc;
|
epcr <= id_pc;
|
end
|
end
|
`endif
|
`endif
|
`ifdef OR1200_EXCEPT_TICK
|
`ifdef OR1200_EXCEPT_TICK
|
14'b00_0000_0000_0001: begin
|
14'b00_0000_0000_0001: begin
|
except_type <= `OR1200_EXCEPT_TICK;
|
except_type <= `OR1200_EXCEPT_TICK;
|
epcr <= id_pc;
|
epcr <= id_pc;
|
end
|
end
|
`endif
|
`endif
|
default:
|
default:
|
except_type <= `OR1200_EXCEPT_NONE;
|
except_type <= `OR1200_EXCEPT_NONE;
|
endcase
|
endcase
|
end
|
end
|
else if (pc_we) begin
|
else if (pc_we) begin
|
state <= `OR1200_EXCEPTFSM_FLU1;
|
state <= `OR1200_EXCEPTFSM_FLU1;
|
extend_flush <= 1'b1;
|
extend_flush <= 1'b1;
|
end
|
end
|
else begin
|
else begin
|
if (epcr_we)
|
if (epcr_we)
|
epcr <= datain;
|
epcr <= datain;
|
if (eear_we)
|
if (eear_we)
|
eear <= datain;
|
eear <= datain;
|
if (esr_we)
|
if (esr_we)
|
esr <= {datain[`OR1200_SR_WIDTH-1], 1'b1, datain[`OR1200_SR_WIDTH-3:0]};
|
esr <= {datain[`OR1200_SR_WIDTH-1], 1'b1, datain[`OR1200_SR_WIDTH-3:0]};
|
end
|
end
|
`OR1200_EXCEPTFSM_FLU1:
|
`OR1200_EXCEPTFSM_FLU1:
|
if (icpu_ack_i | icpu_err_i | genpc_freeze)
|
if (icpu_ack_i | icpu_err_i | genpc_freeze)
|
state <= `OR1200_EXCEPTFSM_FLU2;
|
state <= `OR1200_EXCEPTFSM_FLU2;
|
`OR1200_EXCEPTFSM_FLU2:
|
`OR1200_EXCEPTFSM_FLU2:
|
`ifdef OR1200_EXCEPT_TRAP
|
`ifdef OR1200_EXCEPT_TRAP
|
if (except_type == `OR1200_EXCEPT_TRAP) begin
|
if (except_type == `OR1200_EXCEPT_TRAP) begin
|
state <= `OR1200_EXCEPTFSM_IDLE;
|
state <= `OR1200_EXCEPTFSM_IDLE;
|
extend_flush <= 1'b0;
|
extend_flush <= 1'b0;
|
extend_flush_last <= 1'b0;
|
extend_flush_last <= 1'b0;
|
except_type <= `OR1200_EXCEPT_NONE;
|
except_type <= `OR1200_EXCEPT_NONE;
|
end
|
end
|
else
|
else
|
`endif
|
`endif
|
state <= `OR1200_EXCEPTFSM_FLU3;
|
state <= `OR1200_EXCEPTFSM_FLU3;
|
`OR1200_EXCEPTFSM_FLU3:
|
`OR1200_EXCEPTFSM_FLU3:
|
begin
|
begin
|
state <= `OR1200_EXCEPTFSM_FLU4;
|
state <= `OR1200_EXCEPTFSM_FLU4;
|
end
|
end
|
`OR1200_EXCEPTFSM_FLU4: begin
|
`OR1200_EXCEPTFSM_FLU4: begin
|
state <= `OR1200_EXCEPTFSM_FLU5;
|
state <= `OR1200_EXCEPTFSM_FLU5;
|
extend_flush <= 1'b0;
|
extend_flush <= 1'b0;
|
extend_flush_last <= 1'b0; // damjan
|
extend_flush_last <= 1'b0; // damjan
|
end
|
end
|
`ifdef OR1200_CASE_DEFAULT
|
`ifdef OR1200_CASE_DEFAULT
|
default: begin
|
default: begin
|
`else
|
`else
|
`OR1200_EXCEPTFSM_FLU5: begin
|
`OR1200_EXCEPTFSM_FLU5: begin
|
`endif
|
`endif
|
if (!if_stall && !id_freeze) begin
|
if (!if_stall && !id_freeze) begin
|
state <= `OR1200_EXCEPTFSM_IDLE;
|
state <= `OR1200_EXCEPTFSM_IDLE;
|
except_type <= `OR1200_EXCEPT_NONE;
|
except_type <= `OR1200_EXCEPT_NONE;
|
extend_flush_last <= 1'b0;
|
extend_flush_last <= 1'b0;
|
end
|
end
|
end
|
end
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|