mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Switched to gshare from global history.
Fixed a few minor bugs.
This commit is contained in:
parent
181a28e875
commit
9386e6a524
@ -89,4 +89,4 @@
|
|||||||
|
|
||||||
`define TWO_BIT_PRELOAD "../config/busybear/twoBitPredictor.txt"
|
`define TWO_BIT_PRELOAD "../config/busybear/twoBitPredictor.txt"
|
||||||
`define BTB_PRELOAD "../config/busybear/BTBPredictor.txt"
|
`define BTB_PRELOAD "../config/busybear/BTBPredictor.txt"
|
||||||
`define BPTYPE "BPGLOBAL" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
||||||
|
@ -92,4 +92,4 @@
|
|||||||
|
|
||||||
`define TWO_BIT_PRELOAD "../config/coremark/twoBitPredictor.txt"
|
`define TWO_BIT_PRELOAD "../config/coremark/twoBitPredictor.txt"
|
||||||
`define BTB_PRELOAD "../config/coremark/BTBPredictor.txt"
|
`define BTB_PRELOAD "../config/coremark/BTBPredictor.txt"
|
||||||
`define BPTYPE "BPGLOBAL" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
||||||
|
@ -88,4 +88,4 @@
|
|||||||
|
|
||||||
`define TWO_BIT_PRELOAD "../config/rv32ic/twoBitPredictor.txt"
|
`define TWO_BIT_PRELOAD "../config/rv32ic/twoBitPredictor.txt"
|
||||||
`define BTB_PRELOAD "../config/rv32ic/BTBPredictor.txt"
|
`define BTB_PRELOAD "../config/rv32ic/BTBPredictor.txt"
|
||||||
`define BPTYPE "BPGLOBAL" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
||||||
|
@ -91,4 +91,4 @@
|
|||||||
|
|
||||||
`define TWO_BIT_PRELOAD "../config/rv64ic/twoBitPredictor.txt"
|
`define TWO_BIT_PRELOAD "../config/rv64ic/twoBitPredictor.txt"
|
||||||
`define BTB_PRELOAD "../config/rv64ic/BTBPredictor.txt"
|
`define BTB_PRELOAD "../config/rv64ic/BTBPredictor.txt"
|
||||||
`define BPTYPE "BPGLOBAL" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
||||||
|
@ -91,4 +91,4 @@
|
|||||||
|
|
||||||
`define TWO_BIT_PRELOAD "../config/rv64icfd/twoBitPredictor.txt"
|
`define TWO_BIT_PRELOAD "../config/rv64icfd/twoBitPredictor.txt"
|
||||||
`define BTB_PRELOAD "../config/rv64icfd/BTBPredictor.txt"
|
`define BTB_PRELOAD "../config/rv64icfd/BTBPredictor.txt"
|
||||||
`define BPTYPE "BPGLOBAL" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
`define BPTYPE "BPGSHARE" // BPGLOBAL or BPTWOBIT or BPGSHARE
|
||||||
|
@ -66,43 +66,43 @@ module bpred
|
|||||||
|
|
||||||
// Part 1 branch direction prediction
|
// Part 1 branch direction prediction
|
||||||
|
|
||||||
generate
|
generate
|
||||||
if (`BPTYPE == "BPTWOBIT") begin:Predictor
|
if (`BPTYPE == "BPTWOBIT") begin:Predictor
|
||||||
twoBitPredictor DirPredictor(.clk(clk),
|
twoBitPredictor DirPredictor(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.LookUpPC(PCNextF),
|
.LookUpPC(PCNextF),
|
||||||
.Prediction(BPPredF),
|
.Prediction(BPPredF),
|
||||||
// update
|
// update
|
||||||
.UpdatePC(PCE),
|
.UpdatePC(PCE),
|
||||||
.UpdateEN(InstrClassE[0]),
|
.UpdateEN(InstrClassE[0]),
|
||||||
.UpdatePrediction(UpdateBPPredE));
|
.UpdatePrediction(UpdateBPPredE));
|
||||||
|
|
||||||
end else if (`BPTYPE == "BPGLOBAL") begin:Predictor
|
end else if (`BPTYPE == "BPGLOBAL") begin:Predictor
|
||||||
|
|
||||||
globalHistoryPredictor DirPredictor(.clk(clk),
|
globalHistoryPredictor DirPredictor(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.*, // Stalls and flushes
|
.*, // Stalls and flushes
|
||||||
.LookUpPC(PCNextF),
|
.LookUpPC(PCNextF),
|
||||||
.Prediction(BPPredF),
|
.Prediction(BPPredF),
|
||||||
// update
|
// update
|
||||||
.UpdatePC(PCE),
|
.UpdatePC(PCE),
|
||||||
.UpdateEN(InstrClassE[0]),
|
.UpdateEN(InstrClassE[0]),
|
||||||
.PCSrcE(PCSrcE),
|
.PCSrcE(PCSrcE),
|
||||||
.UpdatePrediction(UpdateBPPredE));
|
.UpdatePrediction(UpdateBPPredE));
|
||||||
end else if (`BPTYPE == "BPGSHARE") begin:Predictor
|
end else if (`BPTYPE == "BPGSHARE") begin:Predictor
|
||||||
|
|
||||||
globalHistoryPredictor DirPredictor(.clk(clk),
|
gsharePredictor DirPredictor(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.*, // Stalls and flushes
|
.*, // Stalls and flushes
|
||||||
.LookUpPC(PCNextF),
|
.LookUpPC(PCNextF),
|
||||||
.Prediction(BPPredF),
|
.Prediction(BPPredF),
|
||||||
// update
|
// update
|
||||||
.UpdatePC(PCE),
|
.UpdatePC(PCE),
|
||||||
.UpdateEN(InstrClassE[0]),
|
.UpdateEN(InstrClassE[0]),
|
||||||
.PCSrcE(PCSrcE),
|
.PCSrcE(PCSrcE),
|
||||||
.UpdatePrediction(UpdateBPPredE));
|
.UpdatePrediction(UpdateBPPredE));
|
||||||
end
|
end
|
||||||
endgenerate
|
endgenerate
|
||||||
|
|
||||||
|
|
||||||
// this predictor will have two pieces of data,
|
// this predictor will have two pieces of data,
|
||||||
|
@ -32,7 +32,7 @@ module gsharePredictor
|
|||||||
)
|
)
|
||||||
(input logic clk,
|
(input logic clk,
|
||||||
input logic reset,
|
input logic reset,
|
||||||
input logic StallF, StallD, StallE, FlushF, FlushD, FlushE,
|
input logic StallF, StallD, StallE, FlushF, FlushD, FlushE,
|
||||||
input logic [`XLEN-1:0] LookUpPC,
|
input logic [`XLEN-1:0] LookUpPC,
|
||||||
output logic [1:0] Prediction,
|
output logic [1:0] Prediction,
|
||||||
// update
|
// update
|
||||||
@ -41,36 +41,36 @@ module gsharePredictor
|
|||||||
input logic [1:0] UpdatePrediction
|
input logic [1:0] UpdatePrediction
|
||||||
|
|
||||||
);
|
);
|
||||||
localparam int Depth = 2^k;
|
|
||||||
logic [k-1:0] GHRF, GHRD, GHRE;
|
|
||||||
|
|
||||||
flopenr #(k) GlobalHistoryRegister(.clk(clk),
|
|
||||||
.reset(reset),
|
|
||||||
.en(UpdateEN),
|
|
||||||
.d({PCSrcE, GHRF[k-1:1] }),
|
|
||||||
.q(GHRF));
|
|
||||||
|
|
||||||
|
|
||||||
|
logic [k-1:0] GHRF, GHRD, GHRE;
|
||||||
|
logic [k-1:0] LookUpPCIndexD, LookUpPCIndexE;
|
||||||
logic [k-1:0] LookUpPCIndex, UpdatePCIndex;
|
logic [k-1:0] LookUpPCIndex, UpdatePCIndex;
|
||||||
logic [1:0] PredictionMemory;
|
logic [1:0] PredictionMemory;
|
||||||
logic DoForwarding, DoForwardingF;
|
logic DoForwarding, DoForwardingF;
|
||||||
logic [1:0] UpdatePredictionF;
|
logic [1:0] UpdatePredictionF;
|
||||||
|
|
||||||
|
flopenr #(k) GlobalHistoryRegister(.clk(clk),
|
||||||
|
.reset(reset),
|
||||||
|
.en(UpdateEN),
|
||||||
|
.d({PCSrcE, GHRF[k-1:1] }),
|
||||||
|
.q(GHRF));
|
||||||
|
|
||||||
|
|
||||||
// for gshare xor the PC with the GHR
|
// for gshare xor the PC with the GHR
|
||||||
assign UpdatePCIndex = GHRE ^ UpdatePC[k-1:0];
|
assign UpdatePCIndex = GHRE ^ UpdatePC[k:1];
|
||||||
assign LookUpPCIndex = LookUpPC ^ GHRF[k-1:0];
|
assign LookUpPCIndex = GHRF ^ LookUpPC[k:1];
|
||||||
// Make Prediction by reading the correct address in the PHT and also update the new address in the PHT
|
// Make Prediction by reading the correct address in the PHT and also update the new address in the PHT
|
||||||
// GHR referes to the address that the past k branches points to in the prediction stage
|
// GHR referes to the address that the past k branches points to in the prediction stage
|
||||||
// GHRE refers to the address that the past k branches points to in the exectution stage
|
// GHRE refers to the address that the past k branches points to in the exectution stage
|
||||||
SRAM2P1R1W #(Depth, 2) PHT(.clk(clk),
|
SRAM2P1R1W #(k, 2) PHT(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.RA1(LookUpPCIndex),
|
.RA1(LookUpPCIndex),
|
||||||
.RD1(PredictionMemory),
|
.RD1(PredictionMemory),
|
||||||
.REN1(1'b1),
|
.REN1(1'b1),
|
||||||
.WA1(UpdatePCIndex),
|
.WA1(UpdatePCIndex),
|
||||||
.WD1(UpdatePrediction),
|
.WD1(UpdatePrediction),
|
||||||
.WEN1(UpdateEN),
|
.WEN1(UpdateEN),
|
||||||
.BitWEN1(2'b11));
|
.BitWEN1(2'b11));
|
||||||
|
|
||||||
|
|
||||||
// need to forward when updating to the same address as reading.
|
// need to forward when updating to the same address as reading.
|
||||||
@ -93,17 +93,17 @@ module gsharePredictor
|
|||||||
|
|
||||||
//pipeline for GHR
|
//pipeline for GHR
|
||||||
flopenrc #(k) LookUpDReg(.clk(clk),
|
flopenrc #(k) LookUpDReg(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.en(~StallD),
|
.en(~StallD),
|
||||||
.clear(FlushD),
|
.clear(FlushD),
|
||||||
.d(LookUpPCIndex),
|
.d(LookUpPCIndex),
|
||||||
.q(LookUpPCIndexD));
|
.q(LookUpPCIndexD));
|
||||||
|
|
||||||
flopenrc #(k) LookUpEReg(.clk(clk),
|
flopenrc #(k) LookUpEReg(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.en(~StallE),
|
.en(~StallE),
|
||||||
.clear(FlushE),
|
.clear(FlushE),
|
||||||
.d(LookUpPCIndexD),
|
.d(LookUpPCIndexD),
|
||||||
.q(LookUpPCIndexE));
|
.q(LookUpPCIndexE));
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user