From 8235042ba2c8595326f790a39951b2a20e054006 Mon Sep 17 00:00:00 2001 From: Ross Thompson Date: Thu, 4 May 2023 14:11:34 -0500 Subject: [PATCH] Maybe I finally have the ahead pipelined local history predictor working. --- src/ifu/bpred/bpred.sv | 2 +- src/ifu/bpred/localaheadbp.sv | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ifu/bpred/bpred.sv b/src/ifu/bpred/bpred.sv index f7cec5be7..cb7dc7fbd 100644 --- a/src/ifu/bpred/bpred.sv +++ b/src/ifu/bpred/bpred.sv @@ -135,7 +135,7 @@ module bpred ( end else if (`BPRED_TYPE == "BP_LOCAL_AHEAD") begin:Predictor localaheadbp #(`BPRED_NUM_LHR, `BPRED_SIZE) DirPredictor(.clk, .reset, .StallF, .StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW, - .PCNextF, .PCM, .BPDirPredD(BPDirPredF), .BPDirPredWrongE, + .PCNextF, .PCM, .BPDirPredF(BPDirPredF), .BPDirPredWrongE, .BranchE, .BranchM, .PCSrcE); end diff --git a/src/ifu/bpred/localaheadbp.sv b/src/ifu/bpred/localaheadbp.sv index e6577770b..80b1c12d1 100644 --- a/src/ifu/bpred/localaheadbp.sv +++ b/src/ifu/bpred/localaheadbp.sv @@ -35,7 +35,7 @@ module localaheadbp #(parameter m = 6, // 2^m = number of local history branches input logic reset, input logic StallF, StallD, StallE, StallM, StallW, input logic FlushD, FlushE, FlushM, FlushW, - output logic [1:0] BPDirPredD, + output logic [1:0] BPDirPredF, output logic BPDirPredWrongE, // update input logic [`XLEN-1:0] PCNextF, PCM, @@ -43,8 +43,8 @@ module localaheadbp #(parameter m = 6, // 2^m = number of local history branches ); logic [k-1:0] IndexNextF, IndexM; - //logic [1:0] BPDirPredD, BPDirPredE; - logic [1:0] BPDirPredE; + logic [1:0] BPDirPredD, BPDirPredE; + //logic [1:0] BPDirPredE; logic [1:0] NewBPDirPredE, NewBPDirPredM; logic [k-1:0] LHRF, LHRD, LHRE, LHRM, LHRW, LHRNextF; @@ -58,18 +58,18 @@ module localaheadbp #(parameter m = 6, // 2^m = number of local history branches logic UpdateM; //assign IndexNextF = LHR; - assign IndexM = LHRM; + assign IndexM = LHRW; ram2p1r1wbe #(2**k, 2) PHT(.clk(clk), .ce1(~StallF), .ce2(~StallW & ~FlushW), .ra1(LHRF), - .rd1(BPDirPredD), + .rd1(BPDirPredF), .wa2(IndexM), .wd2(NewBPDirPredM), .we2(BranchM), .bwe2(1'b1)); - //flopenrc #(2) PredictionRegD(clk, reset, FlushD, ~StallD, BPDirPredF, BPDirPredD); + flopenrc #(2) PredictionRegD(clk, reset, FlushD, ~StallD, BPDirPredF, BPDirPredD); flopenrc #(2) PredictionRegE(clk, reset, FlushE, ~StallE, BPDirPredD, BPDirPredE); satCounter2 BPDirUpdateE(.BrDir(PCSrcE), .OldState(BPDirPredE), .NewState(NewBPDirPredE)); @@ -83,7 +83,7 @@ module localaheadbp #(parameter m = 6, // 2^m = number of local history branches // GHR is both read and update in M. GHR is still pipelined so that the PHT is updated with the correct // GHR. Local history in contrast must pipeline the specific history register read during F and then update // that same one in M. This implementation does not forward if a branch matches in the D, E, or M stages. - assign LHRNextW = BranchM ? {PCSrcM, LHRM[k-1:1]} : LHRM; + assign LHRNextW = BranchM ? {PCSrcM, LHRW[k-1:1]} : LHRW; // this is local history //genvar index; @@ -107,7 +107,7 @@ module localaheadbp #(parameter m = 6, // 2^m = number of local history branches flopenrc #(k) LHRDReg(clk, reset, FlushD, ~StallD, LHRF, LHRD); flopenrc #(k) LHREReg(clk, reset, FlushE, ~StallE, LHRD, LHRE); flopenrc #(k) LHRMReg(clk, reset, FlushM, ~StallM, LHRE, LHRM); - flopenrc #(k) LHRWReg(clk, reset, FlushW, ~StallW, LHRNextW, LHRW); + flopenrc #(k) LHRWReg(clk, reset, FlushW, ~StallW, LHRM, LHRW); flopenr #(`XLEN) PCWReg(clk, reset, ~StallW, PCM, PCW);