mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Possible fix for wfi.
This commit is contained in:
parent
25a3a2f33b
commit
bc877e9ca7
@ -27,6 +27,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
module hazard (
|
module hazard (
|
||||||
|
input logic clk, reset,
|
||||||
// Detect hazards
|
// Detect hazards
|
||||||
input logic BPWrongE, CSRWriteFenceM, RetM, TrapM,
|
input logic BPWrongE, CSRWriteFenceM, RetM, TrapM,
|
||||||
input logic LoadStallD, StoreStallD, MDUStallD, CSRRdStallD,
|
input logic LoadStallD, StoreStallD, MDUStallD, CSRRdStallD,
|
||||||
@ -45,10 +46,12 @@ module hazard (
|
|||||||
logic FlushDCause, FlushECause, FlushMCause, FlushWCause;
|
logic FlushDCause, FlushECause, FlushMCause, FlushWCause;
|
||||||
|
|
||||||
logic WFIStallM, WFIInterruptedM;
|
logic WFIStallM, WFIInterruptedM;
|
||||||
|
logic wfiW;
|
||||||
|
|
||||||
// WFI logic
|
// WFI logic
|
||||||
assign WFIStallM = wfiM & ~IntPendingM; // WFI waiting for an interrupt or timeout
|
flopenrc #(1) wfiWReg(clk, reset, FlushW, ~StallW, wfiM, wfiW);
|
||||||
assign WFIInterruptedM = wfiM & IntPendingM; // WFI detects a pending interrupt. Retire WFI; trap if interrupt is enabled.
|
assign WFIStallM = wfiW & ~IntPendingM; // WFI waiting for an interrupt or timeout
|
||||||
|
assign WFIInterruptedM = wfiW & IntPendingM; // WFI detects a pending interrupt. Retire WFI; trap if interrupt is enabled.
|
||||||
|
|
||||||
// stalls and flushes
|
// stalls and flushes
|
||||||
// loads: stall for one cycle if the subsequent instruction depends on the load
|
// loads: stall for one cycle if the subsequent instruction depends on the load
|
||||||
@ -73,7 +76,8 @@ module hazard (
|
|||||||
assign FlushDCause = TrapM | RetM | CSRWriteFenceM | BPWrongE;
|
assign FlushDCause = TrapM | RetM | CSRWriteFenceM | BPWrongE;
|
||||||
assign FlushECause = TrapM | RetM | CSRWriteFenceM |(BPWrongE & ~(DivBusyE | FDivBusyE));
|
assign FlushECause = TrapM | RetM | CSRWriteFenceM |(BPWrongE & ~(DivBusyE | FDivBusyE));
|
||||||
assign FlushMCause = TrapM | RetM | CSRWriteFenceM;
|
assign FlushMCause = TrapM | RetM | CSRWriteFenceM;
|
||||||
assign FlushWCause = TrapM & ~WFIInterruptedM;
|
//assign FlushWCause = TrapM & ~WFIInterruptedM;
|
||||||
|
assign FlushWCause = TrapM;
|
||||||
|
|
||||||
// Stall causes
|
// Stall causes
|
||||||
// Most data depenency stalls are identified in the decode stage
|
// Most data depenency stalls are identified in the decode stage
|
||||||
@ -86,11 +90,13 @@ module hazard (
|
|||||||
assign StallFCause = '0;
|
assign StallFCause = '0;
|
||||||
assign StallDCause = (LoadStallD | StoreStallD | MDUStallD | CSRRdStallD | FCvtIntStallD | FPUStallD) & ~FlushDCause;
|
assign StallDCause = (LoadStallD | StoreStallD | MDUStallD | CSRRdStallD | FCvtIntStallD | FPUStallD) & ~FlushDCause;
|
||||||
assign StallECause = (DivBusyE | FDivBusyE) & ~FlushECause;
|
assign StallECause = (DivBusyE | FDivBusyE) & ~FlushECause;
|
||||||
assign StallMCause = WFIStallM & ~FlushMCause;
|
//assign StallMCause = WFIStallM & ~FlushMCause;
|
||||||
|
assign StallMCause = '0;
|
||||||
// Need to gate IFUStallF when the equivalent FlushFCause = FlushDCause = 1.
|
// Need to gate IFUStallF when the equivalent FlushFCause = FlushDCause = 1.
|
||||||
// assign StallWCause = ((IFUStallF & ~FlushDCause) | LSUStallM) & ~FlushWCause;
|
// assign StallWCause = ((IFUStallF & ~FlushDCause) | LSUStallM) & ~FlushWCause;
|
||||||
// Because FlushWCause is a strict subset of FlushDCause, FlushWCause is factored out.
|
// Because FlushWCause is a strict subset of FlushDCause, FlushWCause is factored out.
|
||||||
assign StallWCause = (IFUStallF & ~FlushDCause) | (LSUStallM & ~FlushWCause);
|
//assign StallWCause = (IFUStallF & ~FlushDCause) | (LSUStallM & ~FlushWCause);
|
||||||
|
assign StallWCause = (IFUStallF & ~FlushDCause) | ((LSUStallM | WFIStallM) & ~FlushWCause);
|
||||||
|
|
||||||
// Stall each stage for cause or if the next stage is stalled
|
// Stall each stage for cause or if the next stage is stalled
|
||||||
// coverage off: StallFCause is always 0
|
// coverage off: StallFCause is always 0
|
||||||
|
@ -200,9 +200,13 @@ module csr import cvw::*; #(parameter cvw_t P) (
|
|||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
// CSR Write values
|
// CSR Write values
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
|
logic [P.XLEN-1:0] PCW; // *** can optimize out it's just PCM for all now.
|
||||||
|
logic wfiW;
|
||||||
|
flopenr #(P.XLEN) PCWReg(clk, reset, ~StallW, PCM, PCW);
|
||||||
|
flopenrc #(1) wfiWReg(clk, reset, FlushW, ~StallW, wfiM, wfiW);
|
||||||
|
|
||||||
assign CSRAdrM = InstrM[31:20];
|
assign CSRAdrM = InstrM[31:20];
|
||||||
assign UnalignedNextEPCM = TrapM ? ((wfiM & IntPendingM) ? PCM+4 : PCM) : CSRWriteValM;
|
assign UnalignedNextEPCM = TrapM ? ((wfiW & IntPendingM) ? PCW+4 : PCM) : CSRWriteValM;
|
||||||
assign NextEPCM = P.C_SUPPORTED ? {UnalignedNextEPCM[P.XLEN-1:1], 1'b0} : {UnalignedNextEPCM[P.XLEN-1:2], 2'b00}; // 3.1.15 alignment
|
assign NextEPCM = P.C_SUPPORTED ? {UnalignedNextEPCM[P.XLEN-1:1], 1'b0} : {UnalignedNextEPCM[P.XLEN-1:2], 2'b00}; // 3.1.15 alignment
|
||||||
assign NextCauseM = TrapM ? {InterruptM, CauseM}: {CSRWriteValM[P.XLEN-1], CSRWriteValM[3:0]};
|
assign NextCauseM = TrapM ? {InterruptM, CauseM}: {CSRWriteValM[P.XLEN-1], CSRWriteValM[3:0]};
|
||||||
assign NextMtvalM = TrapM ? NextFaultMtvalM : CSRWriteValM;
|
assign NextMtvalM = TrapM ? NextFaultMtvalM : CSRWriteValM;
|
||||||
|
@ -264,7 +264,7 @@ module wallypipelinedcore import cvw::*; #(parameter cvw_t P) (
|
|||||||
end
|
end
|
||||||
|
|
||||||
// global stall and flush control
|
// global stall and flush control
|
||||||
hazard hzu(
|
hazard hzu(.clk, .reset,
|
||||||
.BPWrongE, .CSRWriteFenceM, .RetM, .TrapM,
|
.BPWrongE, .CSRWriteFenceM, .RetM, .TrapM,
|
||||||
.LoadStallD, .StoreStallD, .MDUStallD, .CSRRdStallD,
|
.LoadStallD, .StoreStallD, .MDUStallD, .CSRRdStallD,
|
||||||
.LSUStallM, .IFUStallF,
|
.LSUStallM, .IFUStallF,
|
||||||
|
Loading…
Reference in New Issue
Block a user