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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_except.v] - Diff between revs 504 and 562

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 504 Rev 562
Line 42... Line 42...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.1  2002/01/03 08:16:15  lampret
 
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
 
//
// Revision 1.15  2001/11/27 23:13:11  lampret
// Revision 1.15  2001/11/27 23:13:11  lampret
// Fixed except_stop width and fixed EX PC for 1400444f no-ops.
// Fixed except_stop width and fixed EX PC for 1400444f no-ops.
//
//
// Revision 1.14  2001/11/23 08:38:51  lampret
// Revision 1.14  2001/11/23 08:38:51  lampret
// Changed DSR/DRR behavior and exception detection.
// Changed DSR/DRR behavior and exception detection.
Line 107... Line 110...
        sig_ibuserr, sig_dbuserr, sig_illegal, sig_align, sig_range, sig_dtlbmiss, sig_dmmufault,
        sig_ibuserr, sig_dbuserr, sig_illegal, sig_align, sig_range, sig_dtlbmiss, sig_dmmufault,
        sig_inthigh, sig_syscall, sig_trap, sig_itlbmiss, sig_immufault, sig_intlow,
        sig_inthigh, sig_syscall, sig_trap, sig_itlbmiss, sig_immufault, sig_intlow,
        branch_taken, id_freeze, ex_freeze, wb_freeze, if_stall,
        branch_taken, id_freeze, ex_freeze, wb_freeze, if_stall,
        if_pc, lr_sav, flushpipe, extend_flush, except_type, except_start,
        if_pc, lr_sav, flushpipe, extend_flush, except_type, except_start,
        except_started, except_stop,
        except_started, except_stop,
        wb_pc, ex_pc, datain, du_dsr, epcr_we, eear_we, esr_we, pc_we, epcr, eear,
        wb_pc, ex_pc, id_pc, datain, du_dsr, epcr_we, eear_we, esr_we, pc_we, epcr, eear,
        esr, sr, lsu_addr
        esr, sr, lsu_addr
);
);
 
 
//
//
// I/O
// I/O
Line 155... Line 158...
output                          except_start;
output                          except_start;
output                          except_started;
output                          except_started;
output  [12:0]                   except_stop;
output  [12:0]                   except_stop;
output  [31:0]                   wb_pc;
output  [31:0]                   wb_pc;
output  [31:0]                   ex_pc;
output  [31:0]                   ex_pc;
 
output  [31:0]                   id_pc;
 
 
//
//
// Internal regs and wires
// Internal regs and wires
//
//
reg     [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
reg     [`OR1200_EXCEPT_WIDTH-1:0]       except_type;
Line 186... Line 190...
//
//
// Simple combinatorial logic
// Simple combinatorial logic
//
//
assign except_started = extend_flush & except_start;
assign except_started = extend_flush & except_start;
assign lr_sav = ex_pc[31:2];
assign lr_sav = ex_pc[31:2];
assign except_start = (except_type != `OR1200_EXCEPT_NONE);
//assign except_start = (except_type != `OR1200_EXCEPT_NONE);  // damjan
assign inthigh_pending = sig_inthigh & sr[`OR1200_SR_EIR] & delayed_eir[2] & ~ex_freeze & ~branch_taken & ~ex_dslot & ~delayed1_ex_dslot & ~delayed2_ex_dslot;
assign except_start = (except_type != `OR1200_EXCEPT_NONE) & extend_flush;
 
assign inthigh_pending = sig_inthigh & sr[`OR1200_SR_EIR] & delayed_eir[2] & ~ex_freeze & ~branch_taken & ~ex_dslot;
assign intlow_pending = sig_intlow & sr[`OR1200_SR_EIR] & delayed_eir[2] & ~ex_freeze & ~branch_taken & ~ex_dslot & ~delayed1_ex_dslot & ~delayed2_ex_dslot;
assign intlow_pending = sig_intlow & sr[`OR1200_SR_EIR] & delayed_eir[2] & ~ex_freeze & ~branch_taken & ~ex_dslot & ~delayed1_ex_dslot & ~delayed2_ex_dslot;
 
 
//
//
// Order defines exception detection priority
// Order defines exception detection priority
//
//
Line 205... Line 210...
                        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],
                        ex_exceptflags[0]        & ~du_dsr[`OR1200_DU_DSR_LPINTE],
                        ex_exceptflags[0]        & ~du_dsr[`OR1200_DU_DSR_LPINTE],
                        sig_syscall             & ~du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
                        sig_syscall             & ~du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
                        sig_trap                & ~du_dsr[`OR1200_DU_DSR_TE],
                        sig_trap                & ~du_dsr[`OR1200_DU_DSR_TE] & ~ex_freeze,
                        sig_range               & ~du_dsr[`OR1200_DU_DSR_RE]
                        sig_range               & ~du_dsr[`OR1200_DU_DSR_RE]
                };
                };
assign except_stop = {
assign except_stop = {
                        inthigh_pending         & du_dsr[`OR1200_DU_DSR_HPINTE],
                        inthigh_pending         & du_dsr[`OR1200_DU_DSR_HPINTE],
                        ex_exceptflags[2]       & du_dsr[`OR1200_DU_DSR_IME],
                        ex_exceptflags[2]       & du_dsr[`OR1200_DU_DSR_IME],
Line 220... Line 225...
                        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],
                        ex_exceptflags[0]        & du_dsr[`OR1200_DU_DSR_LPINTE],
                        ex_exceptflags[0]        & du_dsr[`OR1200_DU_DSR_LPINTE],
                        sig_syscall             & du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
                        sig_syscall             & du_dsr[`OR1200_DU_DSR_SCE] & ~ex_freeze,
                        sig_trap                & du_dsr[`OR1200_DU_DSR_TE],
                        sig_trap                & du_dsr[`OR1200_DU_DSR_TE] & ~ex_freeze,
                        sig_range               & du_dsr[`OR1200_DU_DSR_RE]
                        sig_range               & du_dsr[`OR1200_DU_DSR_RE]
                };
                };
 
 
//
//
// PC and Exception flags pipelines
// PC and Exception flags pipelines
Line 232... Line 237...
always @(posedge clk or posedge rst) begin
always @(posedge clk or posedge rst) begin
        if (rst) begin
        if (rst) begin
                id_pc <= #1 32'd0;
                id_pc <= #1 32'd0;
                id_exceptflags <= #1 4'b0000;
                id_exceptflags <= #1 4'b0000;
        end
        end
 
        else if (flushpipe) begin
 
                id_pc <= #1 32'h0000_0000;
 
                id_exceptflags <= #1 4'b0000;
 
        end
        else if (!id_freeze) begin
        else if (!id_freeze) begin
`ifdef OR1200_VERBOSE
 
// synopsys translate_off
 
                $display("%t: id_pc <= %h", $time, if_pc);
 
// synopsys translate_on
 
`endif
 
                id_pc <= #1 if_pc;
                id_pc <= #1 if_pc;
                id_exceptflags <= #1 { sig_ibuserr, sig_itlbmiss, sig_immufault, intlow_pending };
                id_exceptflags <= #1 { sig_ibuserr, sig_itlbmiss, sig_immufault, intlow_pending };
        end
        end
end
end
 
 
Line 270... Line 274...
                ex_pc <= #1 32'd0;
                ex_pc <= #1 32'd0;
                ex_exceptflags <= #1 4'b0000;
                ex_exceptflags <= #1 4'b0000;
                delayed1_ex_dslot <= #1 1'b0;
                delayed1_ex_dslot <= #1 1'b0;
                delayed2_ex_dslot <= #1 1'b0;
                delayed2_ex_dslot <= #1 1'b0;
        end
        end
 
        else if (flushpipe) begin
 
                ex_dslot <= #1 1'b0;
 
                ex_pc <= #1 32'h0000_0000;
 
                ex_exceptflags <= #1 4'b0000;
 
                delayed1_ex_dslot <= #1 1'b0;
 
                delayed2_ex_dslot <= #1 1'b0;
 
        end
        else if (!ex_freeze & id_freeze) begin
        else if (!ex_freeze & id_freeze) begin
                ex_dslot <= #1 1'b0;
                ex_dslot <= #1 1'b0;
                ex_pc <= #1 id_pc;
                ex_pc <= #1 id_pc;
                ex_exceptflags <= #1 4'b0000;
                ex_exceptflags <= #1 4'b0000;
                delayed1_ex_dslot <= #1 ex_dslot;
                delayed1_ex_dslot <= #1 ex_dslot;
Line 306... Line 317...
end
end
 
 
//
//
// Flush pipeline
// Flush pipeline
//
//
assign flushpipe = except_flushpipe | pc_we | extend_flush | extend_flush_last;
assign flushpipe = except_flushpipe | pc_we | extend_flush;
 
 
//
//
// 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;
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:
Line 409... Line 420...
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
                                                end
                                                end
                                                13'b0_0000_0001_xxxx: begin
                                                13'b0_0000_0001_xxxx: begin
                                                        except_type <= #1 `OR1200_EXCEPT_BUSERR;
                                                        except_type <= #1 `OR1200_EXCEPT_BUSERR;
                                                        eear <= #1 lsu_addr;
                                                        eear <= #1 lsu_addr;
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
                                                        epcr <= #1 ex_dslot ? wb_pc : ex_pc;
                                                end
                                                end
                                                13'b0_0000_0000_1xxx: begin
                                                13'b0_0000_0000_1xxx: begin
                                                        except_type <= #1 `OR1200_EXCEPT_LPINT;
                                                        except_type <= #1 `OR1200_EXCEPT_LPINT;
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
                                                        epcr <= #1 ex_dslot ? wb_pc : delayed1_ex_dslot ? id_pc : delayed2_ex_dslot ? id_pc : id_pc;
                                                end
                                                end
Line 444... Line 455...
                                                eear <= #1 datain;
                                                eear <= #1 datain;
                                        if (esr_we)
                                        if (esr_we)
                                                esr <= #1 {datain[`OR1200_SR_WIDTH-1:2], 1'b1, datain[0]};
                                                esr <= #1 {datain[`OR1200_SR_WIDTH-1:2], 1'b1, datain[0]};
                                end
                                end
                        `OR1200_EXCEPTFSM_FLU1:
                        `OR1200_EXCEPTFSM_FLU1:
                                if (!if_stall & !id_freeze)
//                              if (!if_stall & !id_freeze)
                                        state <= #1 `OR1200_EXCEPTFSM_FLU2;
                                        state <= #1 `OR1200_EXCEPTFSM_FLU2;
                        `OR1200_EXCEPTFSM_FLU2:
                        `OR1200_EXCEPTFSM_FLU2:
                                if (except_type == `OR1200_EXCEPT_TRAP) begin
                                if (except_type == `OR1200_EXCEPT_TRAP) begin
                                        state <= #1 `OR1200_EXCEPTFSM_IDLE;
                                        state <= #1 `OR1200_EXCEPTFSM_IDLE;
                                        extend_flush <= #1 1'b0;
                                        extend_flush <= #1 1'b0;
                                        extend_flush_last <= #1 1'b0;
                                        extend_flush_last <= #1 1'b0;
                                        except_type <= #1 `OR1200_EXCEPT_NONE;
                                        except_type <= #1 `OR1200_EXCEPT_NONE;
                                end
                                end
                                else if (!if_stall & !id_freeze)
                                else
 
//                              if (!if_stall & !id_freeze)
                                        state <= #1 `OR1200_EXCEPTFSM_FLU3;
                                        state <= #1 `OR1200_EXCEPTFSM_FLU3;
                        `OR1200_EXCEPTFSM_FLU3:
                        `OR1200_EXCEPTFSM_FLU3:
                                if (!if_stall && !id_freeze)
//                              if (!if_stall && !id_freeze)
                                        begin
                                        begin
`ifdef OR1200_VERBOSE
`ifdef OR1200_VERBOSE
// synopsys translate_off
// synopsys translate_off
                                                if (except_flushpipe)
                                                if (except_flushpipe)
                                                        $display(" INFO: EPCR0 %h  EEAR %h  ESR %h", epcr, eear, esr);
                                                        $display(" INFO: EPCR0 %h  EEAR %h  ESR %h", epcr, eear, esr);
Line 469... Line 481...
                                                state <= #1 `OR1200_EXCEPTFSM_FLU4;
                                                state <= #1 `OR1200_EXCEPTFSM_FLU4;
                                        end
                                        end
                        `OR1200_EXCEPTFSM_FLU4: begin
                        `OR1200_EXCEPTFSM_FLU4: begin
                                state <= #1 `OR1200_EXCEPTFSM_FLU5;
                                state <= #1 `OR1200_EXCEPTFSM_FLU5;
                                extend_flush <= #1 1'b0;
                                extend_flush <= #1 1'b0;
                                extend_flush_last <= #1 1'b1;
                                        extend_flush_last <= #1 1'b0; // damjan
                        end
                        end
                        `OR1200_EXCEPTFSM_FLU5: begin
                        `OR1200_EXCEPTFSM_FLU5: begin
 
                                if (!if_stall && !id_freeze) begin
`ifdef OR1200_VERBOSE
`ifdef OR1200_VERBOSE
// synopsys translate_off
// synopsys translate_off
                                $display(" INFO: Just finished flushing pipeline.");
                                $display(" INFO: Just finished flushing pipeline.");
// synopsys translate_on
// synopsys translate_on
`endif
`endif
                                state <= #1 `OR1200_EXCEPTFSM_IDLE;
                                state <= #1 `OR1200_EXCEPTFSM_IDLE;
                                except_type <= #1 `OR1200_EXCEPT_NONE;
                                except_type <= #1 `OR1200_EXCEPT_NONE;
                                extend_flush_last <= #1 1'b0;
                                extend_flush_last <= #1 1'b0;
                        end
                        end
 
                        end
                endcase
                endcase
        end
        end
end
end
 
 
endmodule
endmodule

powered by: WebSVN 2.1.0

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