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

@ -32,12 +32,14 @@ module RASPredictor
#(parameter int StackSize = 16 #(parameter int StackSize = 16
) )
(input logic clk, (input logic clk,
input logic reset, input logic reset,
input logic PopF, input logic PopF,
output logic [`XLEN-1:0] RASPCF, output logic [`XLEN-1:0] RASPCF,
input logic PushE, input logic [3:0] WrongPredInstrClassD,
input logic incr, input logic [3:0] InstrClassD,
input logic [`XLEN-1:0] PCLinkE input logic PushE,
input logic incr,
input logic [`XLEN-1:0] PCLinkE
); );
// *** need to update so it either doesn't push until the memory stage // *** need to update so it either doesn't push until the memory stage
@ -50,9 +52,9 @@ module RASPredictor
logic [StackSize-1:0] [`XLEN-1:0] memory; logic [StackSize-1:0] [`XLEN-1:0] memory;
integer index; 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 PtrM1 = PtrQ - 1'b1;
assign PtrP1 = PtrQ + 1'b1; assign PtrP1 = PtrQ + 1'b1;

View File

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