Partial fix to RAS prediction accurracy.

This commit is contained in:
Ross Thompson 2023-01-13 18:05:47 -06:00
parent 53c8042276
commit 17aebb8a3b
2 changed files with 16 additions and 8 deletions

View File

@ -35,6 +35,8 @@ module RASPredictor
input logic reset,
input logic PopF,
output logic [`XLEN-1:0] RASPCF,
input logic [3:0] WrongPredInstrClassD,
input logic [3:0] InstrClassD,
input logic PushE,
input logic incr,
input logic [`XLEN-1:0] PCLinkE
@ -50,9 +52,9 @@ module RASPredictor
logic [StackSize-1:0] [`XLEN-1:0] memory;
integer index;
assign CounterEn = PopF | PushE | incr;
assign CounterEn = PopF | PushE | incr | WrongPredInstrClassD[2];
assign PtrD = PopF ? PtrM1 : PtrP1;
assign PtrD = PopF | InstrClassD[2] ? PtrM1 : PtrP1;
assign PtrM1 = PtrQ - 1'b1;
assign PtrP1 = PtrQ + 1'b1;

View File

@ -79,6 +79,7 @@ module bpred (
logic BPPredWrongM;
logic [`XLEN-1:0] PCNext0F;
logic [`XLEN-1:0] PCCorrectE;
logic [3:0] WrongPredInstrClassD;
// Part 1 branch direction prediction
// look into the 2 port Sram model. something is wrong.
@ -157,6 +158,8 @@ module bpred (
RASPredictor RASPredictor(.clk(clk),
.reset(reset),
.PopF(PredInstrClassF[2] & ~StallF),
.WrongPredInstrClassD,
.InstrClassD,
.RASPCF,
.PushE(InstrClassE[3] & ~StallE),
.incr(1'b0),
@ -214,6 +217,9 @@ module bpred (
// Finally if the real instruction class is non CFI but the predictor said it was we need to count.
assign BPPredClassNonCFIWrongE = PredictionInstrClassWrongE & ~|InstrClassE;
// branch class prediction wrong.
assign WrongPredInstrClassD = PredInstrClassD ^ InstrClassD;
// Selects the BP or PC+2/4.
mux2 #(`XLEN) pcmux0(PCPlus2or4F, BPPredPCF, SelBPPredF, PCNext0F);