Partial cleanup of unused signals in caches and bpred.

This commit is contained in:
Ross Thompson 2021-10-24 15:04:20 -05:00
parent c0a7b12f94
commit 8a51fe76c1
11 changed files with 40 additions and 89 deletions

View File

@ -54,7 +54,8 @@ module cacheway #(parameter NUMLINES=512, parameter BLOCKLEN = 256, TAGLEN = 26,
output logic [TAGLEN-1:0] VictimTagWay output logic [TAGLEN-1:0] VictimTagWay
); );
logic [NUMLINES-1:0] ValidBits, DirtyBits; logic [NUMLINES-1:0] ValidBits;
logic [NUMLINES-1:0] DirtyBits;
logic [BLOCKLEN-1:0] ReadDataBlockWay; logic [BLOCKLEN-1:0] ReadDataBlockWay;
logic [TAGLEN-1:0] ReadTag; logic [TAGLEN-1:0] ReadTag;
logic Valid; logic Valid;
@ -117,21 +118,18 @@ module cacheway #(parameter NUMLINES=512, parameter BLOCKLEN = 256, TAGLEN = 26,
generate generate
if(DIRTY_BITS) begin if(DIRTY_BITS) begin
always_ff @(posedge clk, posedge reset) begin always_ff @(posedge clk, posedge reset) begin
if (reset) if (reset)
DirtyBits <= {NUMLINES{1'b0}}; DirtyBits <= {NUMLINES{1'b0}};
else if (SetDirty & (WriteEnable | VDWriteEnable)) DirtyBits[WAdr] <= 1'b1; else if (SetDirty & (WriteEnable | VDWriteEnable)) DirtyBits[WAdr] <= 1'b1;
else if (ClearDirty & (WriteEnable | VDWriteEnable)) DirtyBits[WAdr] <= 1'b0; else if (ClearDirty & (WriteEnable | VDWriteEnable)) DirtyBits[WAdr] <= 1'b0;
end end
end
endgenerate
// Since this is always updated on a clock edge we cannot include reset.
generate
if(DIRTY_BITS) begin
always_ff @(posedge clk) begin always_ff @(posedge clk) begin
Dirty <= DirtyBits[RAdr]; Dirty <= DirtyBits[RAdr];
end end
end else begin end else begin
assign Dirty = 1'b0; assign Dirty = 1'b0;
end end

View File

@ -70,14 +70,9 @@ module dcache
output logic [2:0] DCtoAHBSizeM output logic [2:0] DCtoAHBSizeM
); );
/* localparam integer BLOCKLEN = 256;
localparam integer NUMLINES = 64;
localparam integer NUMWAYS = 4;
localparam integer NUMREPL_BITS = 3;*/
localparam integer BLOCKLEN = `DCACHE_BLOCKLENINBITS; localparam integer BLOCKLEN = `DCACHE_BLOCKLENINBITS;
localparam integer NUMLINES = `DCACHE_WAYSIZEINBYTES*8/BLOCKLEN; localparam integer NUMLINES = `DCACHE_WAYSIZEINBYTES*8/BLOCKLEN;
localparam integer NUMWAYS = `DCACHE_NUMWAYS; localparam integer NUMWAYS = `DCACHE_NUMWAYS;
localparam integer NUMREPL_BITS = `DCACHE_REPLBITS; // *** not used
localparam integer BLOCKBYTELEN = BLOCKLEN/8; localparam integer BLOCKBYTELEN = BLOCKLEN/8;
localparam integer OFFSETLEN = $clog2(BLOCKBYTELEN); localparam integer OFFSETLEN = $clog2(BLOCKBYTELEN);
@ -170,7 +165,7 @@ module dcache
.reset, .reset,
.RAdr, .RAdr,
.WAdr, .WAdr,
.PAdr(MemPAdrM[`PA_BITS-1:0]), .PAdr(MemPAdrM),
.WriteEnable(SRAMWayWriteEnable), .WriteEnable(SRAMWayWriteEnable),
.VDWriteEnable, .VDWriteEnable,
.WriteWordEnable(SRAMWordEnable), .WriteWordEnable(SRAMWordEnable),

View File

@ -65,16 +65,12 @@ module icache
localparam LOGWPL = $clog2(WORDSPERLINE); localparam LOGWPL = $clog2(WORDSPERLINE);
localparam FetchCountThreshold = WORDSPERLINE - 1; localparam FetchCountThreshold = WORDSPERLINE - 1;
localparam BlockByteLength = BLOCKLEN / 8;
localparam OFFSETWIDTH = $clog2(BlockByteLength);
localparam integer PA_WIDTH = `PA_BITS - 2; localparam integer PA_WIDTH = `PA_BITS - 2;
localparam integer NUMWAYS = `ICACHE_NUMWAYS; localparam integer NUMWAYS = `ICACHE_NUMWAYS;
// Input signals to cache memory // Input signals to cache memory
logic FlushMem;
logic ICacheMemWriteEnable; logic ICacheMemWriteEnable;
logic [BLOCKLEN-1:0] ICacheMemWriteData; logic [BLOCKLEN-1:0] ICacheMemWriteData;
logic [`PA_BITS-1:0] PCTagF; logic [`PA_BITS-1:0] PCTagF;
@ -91,7 +87,7 @@ module icache
logic FetchCountFlag; logic FetchCountFlag;
logic CntEn; logic CntEn;
logic [1:0] SelAdr_q; logic [1:1] SelAdr_q;
logic [LOGWPL-1:0] FetchCount, NextFetchCount; logic [LOGWPL-1:0] FetchCount, NextFetchCount;
@ -252,11 +248,11 @@ module icache
// this mux needs to be delayed 1 cycle as it occurs 1 pipeline stage later. // this mux needs to be delayed 1 cycle as it occurs 1 pipeline stage later.
// *** read enable may not be necessary. // *** read enable may not be necessary.
flopenr #(2) SelAdrReg(.clk(clk), flopenr #(1) SelAdrReg(.clk(clk),
.reset(reset), .reset(reset),
.en(ICacheReadEn), .en(ICacheReadEn),
.d(SelAdr), .d(SelAdr[1]),
.q(SelAdr_q)); .q(SelAdr_q[1]));
assign PCTagF = SelAdr_q[1] ? PCPSpillF : PCPF; assign PCTagF = SelAdr_q[1] ? PCPSpillF : PCPF;
@ -281,29 +277,25 @@ module icache
assign SRAMWayWriteEnable = ICacheMemWriteEnable ? VictimWay : '0; assign SRAMWayWriteEnable = ICacheMemWriteEnable ? VictimWay : '0;
icachefsm #(.BLOCKLEN(BLOCKLEN)) icachefsm controller(.clk,
controller(.clk, .reset,
.reset, .StallF,
.StallF, .ICacheReadEn,
.ICacheReadEn, .ICacheMemWriteEnable,
.ICacheMemWriteEnable, .ICacheStallF,
.ICacheStallF, .ITLBMissF,
.ITLBMissF, .ITLBWriteF,
.ITLBWriteF, .WalkerInstrPageFaultF,
.WalkerInstrPageFaultF, .InstrAckF,
.InstrAckF, .InstrReadF,
.InstrReadF, .hit,
.hit, .FetchCountFlag,
.FetchCountFlag, .spill,
.spill, .spillSave,
.spillSave, .CntEn,
.CntEn, .CntReset,
.CntReset, .SelAdr,
.SelAdr, .LRUWriteEn);
.LRUWriteEn
);
// For now, assume no writes to executable memory
assign FlushMem = 1'b0;
endmodule endmodule

View File

@ -25,9 +25,8 @@
`include "wally-config.vh" `include "wally-config.vh"
module icachefsm #(parameter BLOCKLEN = 256) module icachefsm
( (// Inputs from pipeline
// Inputs from pipeline
input logic clk, reset, input logic clk, reset,
input logic StallF, input logic StallF,
@ -115,8 +114,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
statetype CurrState, NextState; statetype CurrState, NextState;
logic PreCntEn; logic PreCntEn;
logic UnalignedSelect;
logic SavePC; // unused right now *** consider deleting
// the FSM is always runing, do not stall. // the FSM is always runing, do not stall.
always_ff @(posedge clk, posedge reset) always_ff @(posedge clk, posedge reset)
@ -125,7 +122,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
// Next state logic // Next state logic
always_comb begin always_comb begin
UnalignedSelect = 1'b0;
CntReset = 1'b0; CntReset = 1'b0;
PreCntEn = 1'b0; PreCntEn = 1'b0;
//InstrReadF = 1'b0; //InstrReadF = 1'b0;
@ -133,7 +129,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
spillSave = 1'b0; spillSave = 1'b0;
SelAdr = 2'b00; SelAdr = 2'b00;
ICacheReadEn = 1'b0; ICacheReadEn = 1'b0;
SavePC = 1'b0;
ICacheStallF = 1'b1; ICacheStallF = 1'b1;
LRUWriteEn = 1'b0; LRUWriteEn = 1'b0;
case (CurrState) case (CurrState)
@ -143,7 +138,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
if (ITLBMissF) begin if (ITLBMissF) begin
NextState = STATE_TLB_MISS; NextState = STATE_TLB_MISS;
end else if (hit & ~spill) begin end else if (hit & ~spill) begin
SavePC = 1'b1;
ICacheStallF = 1'b0; ICacheStallF = 1'b0;
LRUWriteEn = 1'b1; LRUWriteEn = 1'b1;
if(StallF) begin if(StallF) begin
@ -176,7 +170,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
// branch 1, hit spill and 2, miss spill hit // branch 1, hit spill and 2, miss spill hit
STATE_HIT_SPILL: begin STATE_HIT_SPILL: begin
SelAdr = 2'b10; SelAdr = 2'b10;
UnalignedSelect = 1'b1;
ICacheReadEn = 1'b1; ICacheReadEn = 1'b1;
if (hit) begin if (hit) begin
NextState = STATE_HIT_SPILL_FINAL; NextState = STATE_HIT_SPILL_FINAL;
@ -202,15 +195,12 @@ module icachefsm #(parameter BLOCKLEN = 256)
end end
STATE_HIT_SPILL_MERGE: begin STATE_HIT_SPILL_MERGE: begin
SelAdr = 2'b10; SelAdr = 2'b10;
UnalignedSelect = 1'b1;
ICacheReadEn = 1'b1; ICacheReadEn = 1'b1;
NextState = STATE_HIT_SPILL_FINAL; NextState = STATE_HIT_SPILL_FINAL;
end end
STATE_HIT_SPILL_FINAL: begin STATE_HIT_SPILL_FINAL: begin
ICacheReadEn = 1'b1; ICacheReadEn = 1'b1;
SelAdr = 2'b00; SelAdr = 2'b00;
UnalignedSelect = 1'b1;
SavePC = 1'b1;
ICacheStallF = 1'b0; ICacheStallF = 1'b0;
LRUWriteEn = 1'b1; LRUWriteEn = 1'b1;
@ -280,7 +270,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
end end
STATE_MISS_SPILL_2: begin STATE_MISS_SPILL_2: begin
SelAdr = 2'b10; SelAdr = 2'b10;
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; ICacheReadEn = 1'b1;
NextState = STATE_MISS_SPILL_2_START; NextState = STATE_MISS_SPILL_2_START;
@ -292,8 +281,6 @@ module icachefsm #(parameter BLOCKLEN = 256)
end else begin end else begin
ICacheReadEn = 1'b1; ICacheReadEn = 1'b1;
SelAdr = 2'b00; SelAdr = 2'b00;
UnalignedSelect = 1'b1;
SavePC = 1'b1;
ICacheStallF = 1'b0; ICacheStallF = 1'b0;
LRUWriteEn = 1'b1; LRUWriteEn = 1'b1;
if(StallF) begin if(StallF) begin
@ -321,15 +308,12 @@ module icachefsm #(parameter BLOCKLEN = 256)
end end
STATE_MISS_SPILL_MERGE: begin STATE_MISS_SPILL_MERGE: begin
SelAdr = 2'b10; SelAdr = 2'b10;
UnalignedSelect = 1'b1;
ICacheReadEn = 1'b1; ICacheReadEn = 1'b1;
NextState = STATE_MISS_SPILL_FINAL; NextState = STATE_MISS_SPILL_FINAL;
end end
STATE_MISS_SPILL_FINAL: begin STATE_MISS_SPILL_FINAL: begin
ICacheReadEn = 1'b1; ICacheReadEn = 1'b1;
SelAdr = 2'b00; SelAdr = 2'b00;
UnalignedSelect = 1'b1;
SavePC = 1'b1;
ICacheStallF = 1'b0; ICacheStallF = 1'b0;
LRUWriteEn = 1'b1; LRUWriteEn = 1'b1;
if(StallF) begin if(StallF) begin

View File

@ -33,7 +33,7 @@ module BTBPredictor
) )
(input logic clk, (input logic clk,
input logic reset, input logic reset,
input logic StallF, StallD, StallE, FlushF, FlushD, FlushE, input logic StallF, StallE,
input logic [`XLEN-1:0] LookUpPC, input logic [`XLEN-1:0] LookUpPC,
output logic [`XLEN-1:0] TargetPC, output logic [`XLEN-1:0] TargetPC,
output logic [4:0] InstrClass, output logic [4:0] InstrClass,
@ -77,17 +77,6 @@ module BTBPredictor
end end
assign Valid = ValidBits[LookUpPCIndexQ]; assign Valid = ValidBits[LookUpPCIndexQ];
/* -----\/----- EXCLUDED -----\/-----
regfile2p1r1w #(10, 1) validMem(.clk(clk),
.reset(reset),
.RA1(LookUpPCIndexQ),
.RD1(Valid),
.REN1(1'b1),
.WA1(UpdatePCIndexQ),
.WD1(1'b1),
.WEN1(UpdateEN));
-----/\----- EXCLUDED -----/\----- */
flopenr #(1) UpdateENReg(.clk(clk), flopenr #(1) UpdateENReg(.clk(clk),
.reset(reset), .reset(reset),

View File

@ -30,8 +30,8 @@
module bpred module bpred
(input logic clk, reset, (input logic clk, reset,
input logic StallF, StallD, StallE, StallM, StallW, input logic StallF, StallD, StallE,
input logic FlushF, FlushD, FlushE, FlushM, FlushW, input logic FlushF, FlushD, FlushE,
// Fetch stage // Fetch stage
// the prediction // the prediction
input logic [`XLEN-1:0] PCNextF, // *** forgot to include this one on the I/O list input logic [`XLEN-1:0] PCNextF, // *** forgot to include this one on the I/O list
@ -67,8 +67,6 @@ module bpred
logic PredictionPCWrongE; logic PredictionPCWrongE;
logic PredictionInstrClassWrongE; logic PredictionInstrClassWrongE;
logic [`XLEN-1:0] CorrectPCE;
// Part 1 branch direction prediction // Part 1 branch direction prediction
@ -171,10 +169,6 @@ module bpred
.UpdateInvalid(PredictionInstrClassWrongE), .UpdateInvalid(PredictionInstrClassWrongE),
.UpdateInstrClass(InstrClassE)); .UpdateInstrClass(InstrClassE));
// need to forward when updating to the same address as reading.
//assign CorrectPCE = PCSrcE ? PCTargetE : PCLinkE;
//assign TargetPC = (PCE == PCNextF) ? CorrectPCE : BTBPredPCF;
// Part 3 RAS // Part 3 RAS
// *** need to add the logic to restore RAS on flushes. We will use incr for this. // *** need to add the logic to restore RAS on flushes. We will use incr for this.
RASPredictor RASPredictor(.clk(clk), RASPredictor RASPredictor(.clk(clk),

View File

@ -32,7 +32,7 @@ module globalHistoryPredictor
) )
(input logic clk, (input logic clk,
input logic reset, input logic reset,
input logic StallF, StallD, StallE, FlushF, FlushD, FlushE, input logic StallF, StallE,
input logic [`XLEN-1:0] PCNextF, input logic [`XLEN-1:0] PCNextF,
output logic [1:0] BPPredF, output logic [1:0] BPPredF,
// update // update

View File

@ -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, StallE,
input logic [`XLEN-1:0] PCNextF, input logic [`XLEN-1:0] PCNextF,
output logic [1:0] BPPredF, output logic [1:0] BPPredF,
// update // update

View File

@ -33,7 +33,7 @@ module localHistoryPredictor
) )
(input logic clk, (input logic clk,
input logic reset, input logic reset,
input logic StallF, StallD, StallE, FlushF, FlushD, FlushE, input logic StallF, StallE, FlushF,
input logic [`XLEN-1:0] LookUpPC, input logic [`XLEN-1:0] LookUpPC,
output logic [1:0] Prediction, output logic [1:0] Prediction,
// update // update

View File

@ -157,7 +157,6 @@ module lsu
// arbiter between IEU and hptw // arbiter between IEU and hptw
lsuArb arbiter(.clk(clk), lsuArb arbiter(.clk(clk),
.reset(reset),
// HPTW connection // HPTW connection
.SelPTW(SelPTW), .SelPTW(SelPTW),
.HPTWRead(HPTWRead), .HPTWRead(HPTWRead),
@ -168,7 +167,7 @@ module lsu
.Funct3M(Funct3M), .Funct3M(Funct3M),
.AtomicM(AtomicM), .AtomicM(AtomicM),
.MemAdrM(MemAdrM), .MemAdrM(MemAdrM),
.MemAdrE(MemAdrE), .MemAdrE(MemAdrE[11:0]),
.CommittedM(CommittedM), .CommittedM(CommittedM),
.PendingInterruptM(PendingInterruptM), .PendingInterruptM(PendingInterruptM),
.StallW(StallW), .StallW(StallW),

View File

@ -27,7 +27,7 @@
`include "wally-config.vh" `include "wally-config.vh"
module lsuArb module lsuArb
(input logic clk, reset, (input logic clk,
// from page table walker // from page table walker
input logic SelPTW, input logic SelPTW,
@ -40,7 +40,7 @@ module lsuArb
input logic [2:0] Funct3M, input logic [2:0] Funct3M,
input logic [1:0] AtomicM, input logic [1:0] AtomicM,
input logic [`XLEN-1:0] MemAdrM, input logic [`XLEN-1:0] MemAdrM,
input logic [`XLEN-1:0] MemAdrE, input logic [11:0] MemAdrE,
input logic StallW, input logic StallW,
input logic PendingInterruptM, input logic PendingInterruptM,
// to CPU // to CPU