cache cleanup

This commit is contained in:
David Harris 2023-01-14 19:43:29 -08:00
parent 08fca1c517
commit 56dac4be7d
4 changed files with 134 additions and 129 deletions

View File

@ -28,21 +28,26 @@
module cacheLRU module cacheLRU
#(parameter NUMWAYS = 4, SETLEN = 9, OFFSETLEN = 5, NUMLINES = 128) ( #(parameter NUMWAYS = 4, SETLEN = 9, OFFSETLEN = 5, NUMLINES = 128) (
input logic clk, reset, CacheEn, FlushStage, input logic clk, reset,
input logic CacheEn,
input logic FlushStage,
input logic [NUMWAYS-1:0] HitWay, input logic [NUMWAYS-1:0] HitWay,
input logic [NUMWAYS-1:0] ValidWay, input logic [NUMWAYS-1:0] ValidWay,
output logic [NUMWAYS-1:0] VictimWay,
input logic [SETLEN-1:0] CAdr, input logic [SETLEN-1:0] CAdr,
input logic [SETLEN-1:0] PAdr, input logic [SETLEN-1:0] PAdr,
input logic LRUWriteEn, SetValid, InvalidateCache, FlushCache); input logic LRUWriteEn,
input logic SetValid,
input logic InvalidateCache,
input logic FlushCache,
output logic [NUMWAYS-1:0] VictimWay
);
localparam LOGNUMWAYS = $clog2(NUMWAYS);
logic [NUMWAYS-2:0] LRUMemory [NUMLINES-1:0]; logic [NUMWAYS-2:0] LRUMemory [NUMLINES-1:0];
logic [NUMWAYS-2:0] CurrLRU; logic [NUMWAYS-2:0] CurrLRU;
logic [NUMWAYS-2:0] NextLRU; logic [NUMWAYS-2:0] NextLRU;
logic [NUMWAYS-1:0] Way; logic [NUMWAYS-1:0] Way;
localparam LOGNUMWAYS = $clog2(NUMWAYS);
logic [LOGNUMWAYS-1:0] WayEncoded; logic [LOGNUMWAYS-1:0] WayEncoded;
logic [NUMWAYS-2:0] WayExpanded; logic [NUMWAYS-2:0] WayExpanded;
logic AllValid; logic AllValid;

View File

@ -26,8 +26,8 @@
`include "wally-config.vh" `include "wally-config.vh"
module cachefsm module cachefsm (
(input logic clk, input logic clk,
input logic reset, input logic reset,
// inputs from IEU // inputs from IEU
input logic FlushStage, input logic FlushStage,
@ -67,7 +67,8 @@ module cachefsm
output logic FlushWayCntEn, output logic FlushWayCntEn,
output logic FlushCntRst, output logic FlushCntRst,
output logic SelFetchBuffer, output logic SelFetchBuffer,
output logic CacheEn); output logic CacheEn
);
logic resetDelay; logic resetDelay;
logic AMO, StoreAMO; logic AMO, StoreAMO;

View File

@ -26,8 +26,8 @@
`include "wally-config.vh" `include "wally-config.vh"
module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26, module cacheway #(parameter NUMLINES=512, LINELEN = 256, TAGLEN = 26,
parameter OFFSETLEN = 5, parameter INDEXLEN = 9, parameter DIRTY_BITS = 1) ( OFFSETLEN = 5, INDEXLEN = 9, DIRTY_BITS = 1) (
input logic clk, input logic clk,
input logic CacheEn, input logic CacheEn,
input logic reset, input logic reset,
@ -44,7 +44,6 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
input logic FlushWay, input logic FlushWay,
input logic InvalidateCache, input logic InvalidateCache,
input logic FlushStage, input logic FlushStage,
// input logic [(`XLEN-1)/8:0] ByteMask,
input logic [LINELEN/8-1:0] LineByteMask, input logic [LINELEN/8-1:0] LineByteMask,
output logic [LINELEN-1:0] ReadDataLineWay, output logic [LINELEN-1:0] ReadDataLineWay,
@ -76,7 +75,6 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
logic SelData; logic SelData;
logic FlushWayEn, VictimWayEn; logic FlushWayEn, VictimWayEn;
// FlushWay and VictimWay are part of a one hot way selection. Must clear them if FlushWay not selected // FlushWay and VictimWay are part of a one hot way selection. Must clear them if FlushWay not selected
// or VictimWay not selected. // or VictimWay not selected.
assign FlushWayEn = FlushWay & SelFlush; assign FlushWayEn = FlushWay & SelFlush;

View File

@ -29,24 +29,25 @@
module subcachelineread #(parameter LINELEN, WORDLEN, MUXINTERVAL)( module subcachelineread #(parameter LINELEN, WORDLEN, MUXINTERVAL)(
input logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1 : 0] PAdr, input logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1 : 0] PAdr,
input logic [LINELEN-1:0] ReadDataLine, input logic [LINELEN-1:0] ReadDataLine,
output logic [WORDLEN-1:0] ReadDataWord); output logic [WORDLEN-1:0] ReadDataWord
);
localparam WORDSPERLINE = LINELEN/MUXINTERVAL; localparam WORDSPERLINE = LINELEN/MUXINTERVAL;
// pad is for icache. Muxing extends over the cacheline boundary.
localparam PADLEN = WORDLEN-MUXINTERVAL; localparam PADLEN = WORDLEN-MUXINTERVAL;
// pad is for icache. Muxing extends over the cacheline boundary.
logic [LINELEN+(WORDLEN-MUXINTERVAL)-1:0] ReadDataLinePad; logic [LINELEN+(WORDLEN-MUXINTERVAL)-1:0] ReadDataLinePad;
logic [WORDLEN-1:0] ReadDataLineSets [(LINELEN/MUXINTERVAL)-1:0]; logic [WORDLEN-1:0] ReadDataLineSets [(LINELEN/MUXINTERVAL)-1:0];
if (PADLEN > 0) begin if (PADLEN > 0) begin
logic [PADLEN-1:0] Pad; assign ReadDataLinePad = {{PADLEN{1'b0}}, ReadDataLine};
assign Pad = '0;
assign ReadDataLinePad = {Pad, ReadDataLine};
end else assign ReadDataLinePad = ReadDataLine; end else assign ReadDataLinePad = ReadDataLine;
genvar index; genvar index;
for (index = 0; index < WORDSPERLINE; index++) begin:readdatalinesetsmux for (index = 0; index < WORDSPERLINE; index++) begin:readdatalinesetsmux
assign ReadDataLineSets[index] = ReadDataLinePad[(index*MUXINTERVAL)+WORDLEN-1 : (index*MUXINTERVAL)]; assign ReadDataLineSets[index] = ReadDataLinePad[(index*MUXINTERVAL)+WORDLEN-1 : (index*MUXINTERVAL)];
end end
// variable input mux // variable input mux
assign ReadDataWord = ReadDataLineSets[PAdr]; assign ReadDataWord = ReadDataLineSets[PAdr];
endmodule endmodule