From 1d9b5badee24de798cbfbc455573b115f8b9e51a Mon Sep 17 00:00:00 2001 From: Ross Thompson Date: Thu, 1 Dec 2022 17:32:58 -0600 Subject: [PATCH] Properly flush cacheLRU. --- pipelined/src/cache/cache.sv | 2 +- pipelined/src/cache/cacheLRU.sv | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pipelined/src/cache/cache.sv b/pipelined/src/cache/cache.sv index 325fcd7b..cdbb8eb3 100644 --- a/pipelined/src/cache/cache.sv +++ b/pipelined/src/cache/cache.sv @@ -131,7 +131,7 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE .FlushWay, .SelFlush, .ReadDataLineWay, .HitWay, .ValidWay, .VictimDirtyWay, .VictimTagWay, .FlushStage, .InvalidateCache); if(NUMWAYS > 1) begin:vict cacheLRU #(NUMWAYS, SETLEN, OFFSETLEN, NUMLINES) cacheLRU( - .clk, .reset, .ce, .HitWay, .ValidWay, .VictimWay, .CAdr, .LRUWriteEn(LRUWriteEn & ~FlushStage), + .clk, .reset, .ce, .FlushStage, .HitWay, .ValidWay, .VictimWay, .CAdr, .LRUWriteEn(LRUWriteEn & ~FlushStage), .SetValid, .PAdr(PAdr[SETTOP-1:OFFSETLEN]), .InvalidateCache); end else assign VictimWay = 1'b1; // one hot. assign CacheHit = | HitWay; diff --git a/pipelined/src/cache/cacheLRU.sv b/pipelined/src/cache/cacheLRU.sv index d8177bfe..9a7038f4 100644 --- a/pipelined/src/cache/cacheLRU.sv +++ b/pipelined/src/cache/cacheLRU.sv @@ -32,7 +32,7 @@ module cacheLRU #(parameter NUMWAYS = 4, SETLEN = 9, OFFSETLEN = 5, NUMLINES = 128)( - input logic clk, reset, ce, + input logic clk, reset, ce, FlushStage, input logic [NUMWAYS-1:0] HitWay, input logic [NUMWAYS-1:0] ValidWay, output logic [NUMWAYS-1:0] VictimWay, @@ -121,8 +121,8 @@ module cacheLRU always_ff @(posedge clk) begin if (reset) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0; if(ce) begin - if(InvalidateCache) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0; - else if (LRUWriteEn) begin + if(InvalidateCache & ~FlushStage) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0; + else if (LRUWriteEn & ~FlushStage) begin LRUMemory[PAdr] <= NextLRU; CurrLRU <= #1 NextLRU; end else begin