mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Merge pull request #48 from ross144/main
Fixed bug #47, ecall and ebreak don't commit
This commit is contained in:
commit
bc0ca38b2f
@ -68,7 +68,7 @@ module hazard (
|
|||||||
assign FlushDCause = TrapM | RetM | CSRWriteFenceM | BPPredWrongE;
|
assign FlushDCause = TrapM | RetM | CSRWriteFenceM | BPPredWrongE;
|
||||||
assign FlushECause = TrapM | RetM | CSRWriteFenceM |(BPPredWrongE & ~(DivBusyE | FDivBusyE));
|
assign FlushECause = TrapM | RetM | CSRWriteFenceM |(BPPredWrongE & ~(DivBusyE | FDivBusyE));
|
||||||
assign FlushMCause = TrapM | RetM | CSRWriteFenceM;
|
assign FlushMCause = TrapM | RetM | CSRWriteFenceM;
|
||||||
assign FlushWCause = TrapM & ~(BreakpointFaultM | EcallFaultM);
|
assign FlushWCause = TrapM;
|
||||||
|
|
||||||
// Stall causes
|
// Stall causes
|
||||||
// Most data depenency stalls are identified in the decode stage
|
// Most data depenency stalls are identified in the decode stage
|
||||||
|
@ -116,7 +116,7 @@ module bpred (
|
|||||||
|
|
||||||
end else if (`BPRED_TYPE == "BPSPECULATIVEGSHARE") begin:Predictor
|
end else if (`BPRED_TYPE == "BPSPECULATIVEGSHARE") begin:Predictor
|
||||||
speculativegshare #(`BPRED_SIZE) DirPredictor(.clk, .reset, .StallF, .StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW,
|
speculativegshare #(`BPRED_SIZE) DirPredictor(.clk, .reset, .StallF, .StallD, .StallE, .StallM, .StallW, .FlushD, .FlushE, .FlushM, .FlushW,
|
||||||
.PCNextF, .PCF, .PCD, .PCE, .PCM, .DirPredictionF, .DirPredictionWrongE,
|
.PCNextF, .PCF, .PCD, .PCE, .DirPredictionF, .DirPredictionWrongE,
|
||||||
.PredInstrClassF, .InstrClassD, .InstrClassE, .WrongPredInstrClassD, .PCSrcE);
|
.PredInstrClassF, .InstrClassD, .InstrClassE, .WrongPredInstrClassD, .PCSrcE);
|
||||||
|
|
||||||
end else if (`BPRED_TYPE == "BPLOCALPAg") begin:Predictor
|
end else if (`BPRED_TYPE == "BPLOCALPAg") begin:Predictor
|
||||||
@ -149,6 +149,7 @@ module bpred (
|
|||||||
.PredValidF,
|
.PredValidF,
|
||||||
.PredictionInstrClassWrongE,
|
.PredictionInstrClassWrongE,
|
||||||
.IEUAdrE,
|
.IEUAdrE,
|
||||||
|
.InstrClassD,
|
||||||
.InstrClassE);
|
.InstrClassE);
|
||||||
|
|
||||||
// the branch predictor needs a compact decoding of the instruction class.
|
// the branch predictor needs a compact decoding of the instruction class.
|
||||||
@ -179,12 +180,14 @@ module bpred (
|
|||||||
assign PredInstrClassF = InstrClassF;
|
assign PredInstrClassF = InstrClassF;
|
||||||
assign SelBPPredF = (PredInstrClassF[0] & DirPredictionF[1]) |
|
assign SelBPPredF = (PredInstrClassF[0] & DirPredictionF[1]) |
|
||||||
PredInstrClassF[2] |
|
PredInstrClassF[2] |
|
||||||
(PredInstrClassF[1]) ;
|
PredInstrClassF[1] |
|
||||||
|
PredInstrClassF[3];
|
||||||
end else begin
|
end else begin
|
||||||
assign PredInstrClassF = BTBPredInstrClassF;
|
assign PredInstrClassF = BTBPredInstrClassF;
|
||||||
assign SelBPPredF = (PredInstrClassF[0] & DirPredictionF[1] & PredValidF) |
|
assign SelBPPredF = (PredInstrClassF[0] & DirPredictionF[1] & PredValidF) |
|
||||||
PredInstrClassF[2] |
|
PredInstrClassF[2] |
|
||||||
(PredInstrClassF[1] & PredValidF) ;
|
(PredInstrClassF[1] & PredValidF) |
|
||||||
|
(PredInstrClassF[3] & PredValidF);
|
||||||
end
|
end
|
||||||
|
|
||||||
// Part 3 RAS
|
// Part 3 RAS
|
||||||
|
@ -41,6 +41,7 @@ module btb #(parameter int Depth = 10 ) (
|
|||||||
// update
|
// update
|
||||||
input logic PredictionInstrClassWrongE, // BTB's instruction class guess was wrong
|
input logic PredictionInstrClassWrongE, // BTB's instruction class guess was wrong
|
||||||
input logic [`XLEN-1:0] IEUAdrE, // Branch/jump target address to insert into btb
|
input logic [`XLEN-1:0] IEUAdrE, // Branch/jump target address to insert into btb
|
||||||
|
input logic [3:0] InstrClassD, // Instruction class to insert into btb
|
||||||
input logic [3:0] InstrClassE // Instruction class to insert into btb
|
input logic [3:0] InstrClassE // Instruction class to insert into btb
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -49,12 +50,12 @@ module btb #(parameter int Depth = 10 ) (
|
|||||||
logic [Depth-1:0] PCNextFIndex, PCFIndex, PCDIndex, PCEIndex;
|
logic [Depth-1:0] PCNextFIndex, PCFIndex, PCDIndex, PCEIndex;
|
||||||
logic [`XLEN-1:0] ResetPC;
|
logic [`XLEN-1:0] ResetPC;
|
||||||
logic MatchF, MatchD, MatchE, MatchNextX, MatchXF;
|
logic MatchF, MatchD, MatchE, MatchNextX, MatchXF;
|
||||||
logic [`XLEN+3:0] ForwardBTBPrediction, ForwardBTBPredictionF;
|
logic [`XLEN+4:0] ForwardBTBPrediction, ForwardBTBPredictionF;
|
||||||
logic [`XLEN+3:0] TableBTBPredictionF;
|
logic [`XLEN+3:0] TableBTBPredictionF;
|
||||||
logic [`XLEN-1:0] PredPCD;
|
logic [`XLEN-1:0] PredPCD;
|
||||||
logic [3:0] PredInstrClassD; // *** copy of reg outside module
|
logic [3:0] PredInstrClassD; // *** copy of reg outside module
|
||||||
logic UpdateEn;
|
logic UpdateEn;
|
||||||
logic TablePredValidF;
|
logic TablePredValidF, PredValidD;
|
||||||
|
|
||||||
// hashing function for indexing the PC
|
// hashing function for indexing the PC
|
||||||
// We have Depth bits to index, but XLEN bits as the input.
|
// We have Depth bits to index, but XLEN bits as the input.
|
||||||
@ -78,13 +79,13 @@ module btb #(parameter int Depth = 10 ) (
|
|||||||
|
|
||||||
flopenr #(1) MatchReg(clk, reset, ~StallF, MatchNextX, MatchXF);
|
flopenr #(1) MatchReg(clk, reset, ~StallF, MatchNextX, MatchXF);
|
||||||
|
|
||||||
assign ForwardBTBPrediction = MatchF ? {BTBPredInstrClassF, PredPCF} :
|
assign ForwardBTBPrediction = MatchF ? {PredValidF, BTBPredInstrClassF, PredPCF} :
|
||||||
MatchD ? {PredInstrClassD, PredPCD} :
|
MatchD ? {PredValidD, InstrClassD, PredPCD} :
|
||||||
{InstrClassE, IEUAdrE} ;
|
{1'b1, InstrClassE, IEUAdrE} ;
|
||||||
|
|
||||||
flopenr #(`XLEN+4) ForwardBTBPredicitonReg(clk, reset, ~StallF, ForwardBTBPrediction, ForwardBTBPredictionF);
|
flopenr #(`XLEN+5) ForwardBTBPredicitonReg(clk, reset, ~StallF, ForwardBTBPrediction, ForwardBTBPredictionF);
|
||||||
|
|
||||||
assign {BTBPredInstrClassF, PredPCF} = MatchXF ? ForwardBTBPredictionF : TableBTBPredictionF;
|
assign {PredValidF, BTBPredInstrClassF, PredPCF} = MatchXF ? ForwardBTBPredictionF : {TablePredValidF, TableBTBPredictionF};
|
||||||
|
|
||||||
always_ff @ (posedge clk) begin
|
always_ff @ (posedge clk) begin
|
||||||
if (reset) begin
|
if (reset) begin
|
||||||
@ -95,7 +96,7 @@ module btb #(parameter int Depth = 10 ) (
|
|||||||
if(~StallF | reset) TablePredValidF = ValidBits[PCNextFIndex];
|
if(~StallF | reset) TablePredValidF = ValidBits[PCNextFIndex];
|
||||||
end
|
end
|
||||||
|
|
||||||
assign PredValidF = MatchXF ? 1'b1 : TablePredValidF;
|
//assign PredValidF = MatchXF ? 1'b1 : TablePredValidF;
|
||||||
|
|
||||||
assign UpdateEn = |InstrClassE | PredictionInstrClassWrongE;
|
assign UpdateEn = |InstrClassE | PredictionInstrClassWrongE;
|
||||||
|
|
||||||
@ -104,6 +105,6 @@ module btb #(parameter int Depth = 10 ) (
|
|||||||
.clk, .ce1(~StallF | reset), .ra1(PCNextFIndex), .rd1(TableBTBPredictionF),
|
.clk, .ce1(~StallF | reset), .ra1(PCNextFIndex), .rd1(TableBTBPredictionF),
|
||||||
.ce2(~StallM & ~FlushM), .wa2(PCEIndex), .wd2({InstrClassE, IEUAdrE}), .we2(UpdateEn), .bwe2('1));
|
.ce2(~StallM & ~FlushM), .wa2(PCEIndex), .wd2({InstrClassE, IEUAdrE}), .we2(UpdateEn), .bwe2('1));
|
||||||
|
|
||||||
flopenrc #(`XLEN+4) BTBD(clk, reset, FlushD, ~StallD, {BTBPredInstrClassF, PredPCF}, {PredInstrClassD, PredPCD});
|
flopenrc #(`XLEN+1) BTBD(clk, reset, FlushD, ~StallD, {PredValidF, PredPCF}, {PredValidD, PredPCD});
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -36,7 +36,7 @@ module speculativegshare #(parameter int k = 10 ) (
|
|||||||
output logic [1:0] DirPredictionF,
|
output logic [1:0] DirPredictionF,
|
||||||
output logic DirPredictionWrongE,
|
output logic DirPredictionWrongE,
|
||||||
// update
|
// update
|
||||||
input logic [`XLEN-1:0] PCNextF, PCF, PCD, PCE, PCM,
|
input logic [`XLEN-1:0] PCNextF, PCF, PCD, PCE,
|
||||||
input logic [3:0] PredInstrClassF, InstrClassD, InstrClassE,
|
input logic [3:0] PredInstrClassF, InstrClassD, InstrClassE,
|
||||||
input logic [3:0] WrongPredInstrClassD,
|
input logic [3:0] WrongPredInstrClassD,
|
||||||
input logic PCSrcE
|
input logic PCSrcE
|
||||||
|
Loading…
Reference in New Issue
Block a user