mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Modified branch predictor to use InstrValidE and InstrValidD rather than the more complex InstrClassE | WrongClassE logic.
This commit is contained in:
parent
a1bdd9daa7
commit
ca0eb5a591
@ -62,7 +62,8 @@ module controller(
|
|||||||
output logic [2:0] Funct3M, // Instruction's funct3 field
|
output logic [2:0] Funct3M, // Instruction's funct3 field
|
||||||
output logic RegWriteM, // Instruction writes a register (needed for Hazard unit)
|
output logic RegWriteM, // Instruction writes a register (needed for Hazard unit)
|
||||||
output logic InvalidateICacheM, FlushDCacheM, // Invalidate I$, flush D$
|
output logic InvalidateICacheM, FlushDCacheM, // Invalidate I$, flush D$
|
||||||
output logic InstrValidM, // Instruction is valid
|
output logic InstrValidD, InstrValidE, InstrValidM, // Instruction is valid
|
||||||
|
|
||||||
output logic FWriteIntM, // FPU controller writes integer register file
|
output logic FWriteIntM, // FPU controller writes integer register file
|
||||||
// Writeback stage control signals
|
// Writeback stage control signals
|
||||||
input logic StallW, FlushW, // Stall, flush Writeback stage
|
input logic StallW, FlushW, // Stall, flush Writeback stage
|
||||||
@ -96,7 +97,6 @@ module controller(
|
|||||||
logic FenceXD; // Fence instruction
|
logic FenceXD; // Fence instruction
|
||||||
logic InvalidateICacheD, FlushDCacheD;// Invalidate I$, flush D$
|
logic InvalidateICacheD, FlushDCacheD;// Invalidate I$, flush D$
|
||||||
logic CSRWriteD, CSRWriteE; // CSR write
|
logic CSRWriteD, CSRWriteE; // CSR write
|
||||||
logic InstrValidD, InstrValidE; // Instruction is valid
|
|
||||||
logic PrivilegedD, PrivilegedE; // Privileged instruction
|
logic PrivilegedD, PrivilegedE; // Privileged instruction
|
||||||
logic InvalidateICacheE, FlushDCacheE;// Invalidate I$, flush D$
|
logic InvalidateICacheE, FlushDCacheE;// Invalidate I$, flush D$
|
||||||
logic [`CTRLW-1:0] ControlsD; // Main Instruction Decoder control signals
|
logic [`CTRLW-1:0] ControlsD; // Main Instruction Decoder control signals
|
||||||
|
@ -54,7 +54,7 @@ module ieu (
|
|||||||
output logic [4:0] RdM, // Destination register
|
output logic [4:0] RdM, // Destination register
|
||||||
input logic [`XLEN-1:0] FIntResM, // Integer result from FPU (fmv, fclass, fcmp)
|
input logic [`XLEN-1:0] FIntResM, // Integer result from FPU (fmv, fclass, fcmp)
|
||||||
output logic InvalidateICacheM, FlushDCacheM, // Invalidate I$, flush D$
|
output logic InvalidateICacheM, FlushDCacheM, // Invalidate I$, flush D$
|
||||||
output logic InstrValidM, // Instruction is valid
|
output logic InstrValidD, InstrValidE, InstrValidM,// Instruction is valid
|
||||||
// Writeback stage signals
|
// Writeback stage signals
|
||||||
input logic [`XLEN-1:0] FIntDivResultW, // Integer divide result from FPU fdivsqrt)
|
input logic [`XLEN-1:0] FIntDivResultW, // Integer divide result from FPU fdivsqrt)
|
||||||
input logic [`XLEN-1:0] CSRReadValW, // CSR read value,
|
input logic [`XLEN-1:0] CSRReadValW, // CSR read value,
|
||||||
@ -97,7 +97,7 @@ module ieu (
|
|||||||
.PCSrcE, .ALUControlE, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .MemReadE, .CSRReadE,
|
.PCSrcE, .ALUControlE, .ALUSrcAE, .ALUSrcBE, .ALUResultSrcE, .MemReadE, .CSRReadE,
|
||||||
.Funct3E, .IntDivE, .MDUE, .W64E, .JumpE, .SCE, .BranchSignedE, .StallM, .FlushM, .MemRWM,
|
.Funct3E, .IntDivE, .MDUE, .W64E, .JumpE, .SCE, .BranchSignedE, .StallM, .FlushM, .MemRWM,
|
||||||
.CSRReadM, .CSRWriteM, .PrivilegedM, .AtomicM, .Funct3M,
|
.CSRReadM, .CSRWriteM, .PrivilegedM, .AtomicM, .Funct3M,
|
||||||
.RegWriteM, .InvalidateICacheM, .FlushDCacheM, .InstrValidM, .FWriteIntM,
|
.RegWriteM, .InvalidateICacheM, .FlushDCacheM, .InstrValidM, .InstrValidE, .InstrValidD, .FWriteIntM,
|
||||||
.StallW, .FlushW, .RegWriteW, .IntDivW, .ResultSrcW, .CSRWriteFenceM, .StoreStallD);
|
.StallW, .FlushW, .RegWriteW, .IntDivW, .ResultSrcW, .CSRWriteFenceM, .StoreStallD);
|
||||||
|
|
||||||
datapath dp(
|
datapath dp(
|
||||||
|
@ -51,6 +51,7 @@ module bpred (
|
|||||||
input logic [31:0] PostSpillInstrRawF, // Instruction
|
input logic [31:0] PostSpillInstrRawF, // Instruction
|
||||||
|
|
||||||
// Branch and jump outcome
|
// Branch and jump outcome
|
||||||
|
input logic InstrValidD, InstrValidE,
|
||||||
input logic PCSrcE, // Executation stage branch is taken
|
input logic PCSrcE, // Executation stage branch is taken
|
||||||
input logic [`XLEN-1:0] IEUAdrE, // The branch/jump target address
|
input logic [`XLEN-1:0] IEUAdrE, // The branch/jump target address
|
||||||
input logic [`XLEN-1:0] PCLinkE, // The address following the branch instruction. (AKA Fall through address)
|
input logic [`XLEN-1:0] PCLinkE, // The address following the branch instruction. (AKA Fall through address)
|
||||||
@ -220,8 +221,8 @@ module bpred (
|
|||||||
assign WrongPredInstrClassD = PredInstrClassD ^ InstrClassD;
|
assign WrongPredInstrClassD = PredInstrClassD ^ InstrClassD;
|
||||||
assign AnyWrongPredInstrClassD = |WrongPredInstrClassD;
|
assign AnyWrongPredInstrClassD = |WrongPredInstrClassD;
|
||||||
|
|
||||||
// Finally indicate if the branch predictor was wrong
|
// branch is wrong only if the PC does not match and both the Decode and Fetch stages have valid instructions.
|
||||||
assign BPPredWrongE = PredictionPCWrongE & (|InstrClassE | AnyWrongPredInstrClassE);
|
assign BPPredWrongE = PredictionPCWrongE & InstrValidE & InstrValidD;
|
||||||
|
|
||||||
// Output the predicted PC or corrected PC on miss-predict.
|
// Output the predicted PC or corrected PC on miss-predict.
|
||||||
// Selects the BP or PC+2/4.
|
// Selects the BP or PC+2/4.
|
||||||
@ -236,7 +237,6 @@ module bpred (
|
|||||||
if(`INSTR_CLASS_PRED) mux2 #(`XLEN) pcmuxBPWrongInvalidateFlush(PCE, PCF, BPPredWrongM, NextValidPCE);
|
if(`INSTR_CLASS_PRED) mux2 #(`XLEN) pcmuxBPWrongInvalidateFlush(PCE, PCF, BPPredWrongM, NextValidPCE);
|
||||||
else assign NextValidPCE = PCE;
|
else assign NextValidPCE = PCE;
|
||||||
|
|
||||||
|
|
||||||
// performance counters
|
// performance counters
|
||||||
// 1. class (class wrong / minstret) (PredictionInstrClassWrongM / csr) // Correct now
|
// 1. class (class wrong / minstret) (PredictionInstrClassWrongM / csr) // Correct now
|
||||||
// 2. target btb (btb target wrong / class[0,1,3]) (btb target wrong / (br + j + jal)
|
// 2. target btb (btb target wrong / class[0,1,3]) (btb target wrong / (br + j + jal)
|
||||||
|
@ -35,6 +35,7 @@ module ifu (
|
|||||||
// Command from CPU
|
// Command from CPU
|
||||||
input logic InvalidateICacheM, // Clears all instruction cache valid bits
|
input logic InvalidateICacheM, // Clears all instruction cache valid bits
|
||||||
input logic CSRWriteFenceM, // CSR write or fence instruction, PCNextF = the next valid PC (typically PCE)
|
input logic CSRWriteFenceM, // CSR write or fence instruction, PCNextF = the next valid PC (typically PCE)
|
||||||
|
input logic InstrValidD, InstrValidE, InstrValidM,
|
||||||
// Bus interface
|
// Bus interface
|
||||||
output logic [`PA_BITS-1:0] IFUHADDR, // Bus address from IFU to EBU
|
output logic [`PA_BITS-1:0] IFUHADDR, // Bus address from IFU to EBU
|
||||||
input logic [`XLEN-1:0] HRDATA, // Bus read data from IFU to EBU
|
input logic [`XLEN-1:0] HRDATA, // Bus read data from IFU to EBU
|
||||||
@ -322,7 +323,7 @@ module ifu (
|
|||||||
if (`BPRED_SUPPORTED) begin : bpred
|
if (`BPRED_SUPPORTED) begin : bpred
|
||||||
bpred bpred(.clk, .reset,
|
bpred bpred(.clk, .reset,
|
||||||
.StallF, .StallD, .StallE, .StallM, .StallW,
|
.StallF, .StallD, .StallE, .StallM, .StallW,
|
||||||
.FlushD, .FlushE, .FlushM, .FlushW,
|
.FlushD, .FlushE, .FlushM, .FlushW, .InstrValidD, .InstrValidE,
|
||||||
.InstrD, .PCNextF, .PCPlus2or4F, .PCNext1F, .PCE, .PCM, .PCSrcE, .IEUAdrE, .PCF, .NextValidPCE,
|
.InstrD, .PCNextF, .PCPlus2or4F, .PCNext1F, .PCE, .PCM, .PCSrcE, .IEUAdrE, .PCF, .NextValidPCE,
|
||||||
.PCD, .PCLinkE, .InstrClassM, .BPPredWrongE, .PostSpillInstrRawF, .JumpOrTakenBranchM, .BPPredWrongM,
|
.PCD, .PCLinkE, .InstrClassM, .BPPredWrongE, .PostSpillInstrRawF, .JumpOrTakenBranchM, .BPPredWrongM,
|
||||||
.DirPredictionWrongM, .BTBPredPCWrongM, .RASPredPCWrongM, .PredictionInstrClassWrongM);
|
.DirPredictionWrongM, .BTBPredPCWrongM, .RASPredPCWrongM, .PredictionInstrClassWrongM);
|
||||||
|
@ -68,7 +68,7 @@ module wallypipelinedcore (
|
|||||||
logic [`XLEN-1:0] CSRReadValW, MDUResultW;
|
logic [`XLEN-1:0] CSRReadValW, MDUResultW;
|
||||||
logic [`XLEN-1:0] UnalignedPCNextF, PCNext2F;
|
logic [`XLEN-1:0] UnalignedPCNextF, PCNext2F;
|
||||||
logic [1:0] MemRWM;
|
logic [1:0] MemRWM;
|
||||||
logic InstrValidM;
|
logic InstrValidD, InstrValidE, InstrValidM;
|
||||||
logic InstrMisalignedFaultM;
|
logic InstrMisalignedFaultM;
|
||||||
logic IllegalBaseInstrFaultD, IllegalIEUInstrFaultD;
|
logic IllegalBaseInstrFaultD, IllegalIEUInstrFaultD;
|
||||||
logic InstrPageFaultF, LoadPageFaultM, StoreAmoPageFaultM;
|
logic InstrPageFaultF, LoadPageFaultM, StoreAmoPageFaultM;
|
||||||
@ -166,6 +166,7 @@ module wallypipelinedcore (
|
|||||||
// instruction fetch unit: PC, branch prediction, instruction cache
|
// instruction fetch unit: PC, branch prediction, instruction cache
|
||||||
ifu ifu(.clk, .reset,
|
ifu ifu(.clk, .reset,
|
||||||
.StallF, .StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW,
|
.StallF, .StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW,
|
||||||
|
.InstrValidM, .InstrValidE, .InstrValidD,
|
||||||
// Fetch
|
// Fetch
|
||||||
.HRDATA, .PCFSpill, .IFUHADDR, .PCNext2F,
|
.HRDATA, .PCFSpill, .IFUHADDR, .PCNext2F,
|
||||||
.IFUStallF, .IFUHBURST, .IFUHTRANS, .IFUHSIZE, .IFUHREADY, .IFUHWRITE,
|
.IFUStallF, .IFUHBURST, .IFUHTRANS, .IFUHSIZE, .IFUHREADY, .IFUHWRITE,
|
||||||
@ -201,7 +202,7 @@ module wallypipelinedcore (
|
|||||||
.RdE, .RdM, .FIntResM, .InvalidateICacheM, .FlushDCacheM,
|
.RdE, .RdM, .FIntResM, .InvalidateICacheM, .FlushDCacheM,
|
||||||
// Writeback stage
|
// Writeback stage
|
||||||
.CSRReadValW, .MDUResultW, .FIntDivResultW, .RdW, .ReadDataW(ReadDataW[`XLEN-1:0]),
|
.CSRReadValW, .MDUResultW, .FIntDivResultW, .RdW, .ReadDataW(ReadDataW[`XLEN-1:0]),
|
||||||
.InstrValidM, .FCvtIntResW, .FCvtIntW,
|
.InstrValidM, .InstrValidE, .InstrValidD, .FCvtIntResW, .FCvtIntW,
|
||||||
// hazards
|
// hazards
|
||||||
.StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW,
|
.StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW,
|
||||||
.FCvtIntStallD, .LoadStallD, .MDUStallD, .CSRRdStallD, .PCSrcE,
|
.FCvtIntStallD, .LoadStallD, .MDUStallD, .CSRRdStallD, .PCSrcE,
|
||||||
|
Loading…
Reference in New Issue
Block a user