mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
fixed bug with icache miss spill fsm branch.
This commit is contained in:
parent
063e458ff0
commit
fec40a1b75
@ -50,58 +50,16 @@ module globalHistoryPredictor
|
|||||||
.d(GHRFNext),
|
.d(GHRFNext),
|
||||||
.q(GHRF));
|
.q(GHRF));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logic [1:0] PredictionMemory;
|
|
||||||
logic DoForwarding, DoForwardingF;
|
|
||||||
logic [1:0] UpdatePredictionF;
|
|
||||||
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// GHRE refers to the address that the past k branches points to in the exectution stage
|
|
||||||
SRAM2P1R1W #(k, 2) PHT(.clk(clk),
|
SRAM2P1R1W #(k, 2) PHT(.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.RA1(GHRF),
|
.RA1(GHRF),
|
||||||
.RD1(PredictionMemory),
|
.RD1(Prediction),
|
||||||
.REN1(~StallF),
|
.REN1(~StallF),
|
||||||
.WA1(GHRFNext),
|
.WA1(GHRF),
|
||||||
.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.
|
|
||||||
// first we compare to see if the update and lookup addreses are the same
|
|
||||||
assign DoForwarding = GHRF == GHRFNext;
|
|
||||||
|
|
||||||
// register the update value and the forwarding signal into the Fetch stage
|
|
||||||
// TODO: add stall logic ***
|
|
||||||
flopr #(1) DoForwardingReg(.clk(clk),
|
|
||||||
.reset(reset),
|
|
||||||
.d(DoForwarding),
|
|
||||||
.q(DoForwardingF));
|
|
||||||
|
|
||||||
flopr #(2) UpdatePredictionReg(.clk(clk),
|
|
||||||
.reset(reset),
|
|
||||||
.d(UpdatePrediction),
|
|
||||||
.q(UpdatePredictionF));
|
|
||||||
|
|
||||||
assign Prediction = DoForwardingF ? UpdatePredictionF : PredictionMemory;
|
|
||||||
|
|
||||||
//pipeline for GHR
|
|
||||||
/*flopenrc #(k) GHRDReg(.clk(clk),
|
|
||||||
.reset(reset),
|
|
||||||
.en(~StallD),
|
|
||||||
.clear(FlushD),
|
|
||||||
.d(GHRF),
|
|
||||||
.q(GHRD));
|
|
||||||
|
|
||||||
flopenrc #(k) GHREReg(.clk(clk),
|
|
||||||
.reset(reset),
|
|
||||||
.en(~StallE),
|
|
||||||
.clear(FlushE),
|
|
||||||
.d(GHRD),
|
|
||||||
.q(GHRE));
|
|
||||||
*/
|
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -154,15 +154,16 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
localparam STATE_MISS_SPILL_FETCH_DONE = 10; // write data into SRAM/LUT
|
localparam STATE_MISS_SPILL_FETCH_DONE = 10; // write data into SRAM/LUT
|
||||||
localparam STATE_MISS_SPILL_READ1 = 11; // read block 0 from SRAM/LUT
|
localparam STATE_MISS_SPILL_READ1 = 11; // read block 0 from SRAM/LUT
|
||||||
localparam STATE_MISS_SPILL_2 = 12; // return to ready if hit or do second block update.
|
localparam STATE_MISS_SPILL_2 = 12; // return to ready if hit or do second block update.
|
||||||
localparam STATE_MISS_SPILL_MISS_FETCH_WDV = 13; // miss on block 1, issue read to AHB and wait
|
localparam STATE_MISS_SPILL_2_START = 13; // return to ready if hit or do second block update.
|
||||||
localparam STATE_MISS_SPILL_MISS_FETCH_DONE = 14; // write data to SRAM/LUT
|
localparam STATE_MISS_SPILL_MISS_FETCH_WDV = 14; // miss on block 1, issue read to AHB and wait
|
||||||
localparam STATE_MISS_SPILL_MERGE = 15; // read block 0 of CPU access,
|
localparam STATE_MISS_SPILL_MISS_FETCH_DONE = 15; // write data to SRAM/LUT
|
||||||
|
localparam STATE_MISS_SPILL_MERGE = 16; // read block 0 of CPU access,
|
||||||
|
|
||||||
localparam STATE_MISS_SPILL_FINAL = 16; // this state replicates STATE_READY's replay of the
|
localparam STATE_MISS_SPILL_FINAL = 17; // this state replicates STATE_READY's replay of the
|
||||||
// spill access but does nto consider spill. It also does not do another operation.
|
// spill access but does nto consider spill. It also does not do another operation.
|
||||||
|
|
||||||
|
|
||||||
localparam STATE_INVALIDATE = 17; // *** not sure if invalidate or evict? invalidate by cache block or address?
|
localparam STATE_INVALIDATE = 18; // *** not sure if invalidate or evict? invalidate by cache block or address?
|
||||||
|
|
||||||
localparam AHBByteLength = `XLEN / 8;
|
localparam AHBByteLength = `XLEN / 8;
|
||||||
localparam AHBOFFETWIDTH = $clog2(AHBByteLength);
|
localparam AHBOFFETWIDTH = $clog2(AHBByteLength);
|
||||||
@ -380,11 +381,20 @@ module icachecontroller #(parameter LINESIZE = 256) (
|
|||||||
PCMux = 2'b10;
|
PCMux = 2'b10;
|
||||||
UnalignedSelect = 1'b1;
|
UnalignedSelect = 1'b1;
|
||||||
spillSave = 1'b1; /// *** Could pipeline these to make it clearer in the fsm.
|
spillSave = 1'b1; /// *** Could pipeline these to make it clearer in the fsm.
|
||||||
|
ICacheReadEn = 1'b1;
|
||||||
|
NextState = STATE_MISS_SPILL_2_START;
|
||||||
|
end
|
||||||
|
STATE_MISS_SPILL_2_START: begin
|
||||||
if (~hit) begin
|
if (~hit) begin
|
||||||
CntReset = 1'b1;
|
CntReset = 1'b1;
|
||||||
NextState = STATE_MISS_SPILL_MISS_FETCH_WDV;
|
NextState = STATE_MISS_SPILL_MISS_FETCH_WDV;
|
||||||
end else begin
|
end else begin
|
||||||
NextState = STATE_MISS_SPILL_FINAL;
|
NextState = STATE_READY;
|
||||||
|
ICacheReadEn = 1'b1;
|
||||||
|
PCMux = 2'b00;
|
||||||
|
UnalignedSelect = 1'b1;
|
||||||
|
SavePC = 1'b1;
|
||||||
|
ICacheStallF = 1'b0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
STATE_MISS_SPILL_MISS_FETCH_WDV: begin
|
STATE_MISS_SPILL_MISS_FETCH_WDV: begin
|
||||||
|
Loading…
Reference in New Issue
Block a user