mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Finally have the cbo way muxing controls reduced to something sane.
This commit is contained in:
parent
efcd09c6cd
commit
23e05cb8b2
5
src/cache/cache.sv
vendored
5
src/cache/cache.sv
vendored
@ -98,6 +98,7 @@ module cache import cvw::*; #(parameter cvw_t P,
|
|||||||
logic [LINELEN-1:0] ReadDataLine, ReadDataLineCache;
|
logic [LINELEN-1:0] ReadDataLine, ReadDataLineCache;
|
||||||
logic SelFetchBuffer;
|
logic SelFetchBuffer;
|
||||||
logic CacheEn;
|
logic CacheEn;
|
||||||
|
logic SelWay;
|
||||||
logic [LINELEN/8-1:0] LineByteMask;
|
logic [LINELEN/8-1:0] LineByteMask;
|
||||||
logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1:0] WordOffsetAddr;
|
logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1:0] WordOffsetAddr;
|
||||||
logic ZeroCacheLine;
|
logic ZeroCacheLine;
|
||||||
@ -119,7 +120,7 @@ module cache import cvw::*; #(parameter cvw_t P,
|
|||||||
|
|
||||||
// Array of cache ways, along with victim, hit, dirty, and read merging logic
|
// Array of cache ways, along with victim, hit, dirty, and read merging logic
|
||||||
cacheway #(P, PA_BITS, XLEN, NUMLINES, LINELEN, TAGLEN, OFFSETLEN, SETLEN, READ_ONLY_CACHE) CacheWays[NUMWAYS-1:0](
|
cacheway #(P, PA_BITS, XLEN, NUMLINES, LINELEN, TAGLEN, OFFSETLEN, SETLEN, READ_ONLY_CACHE) CacheWays[NUMWAYS-1:0](
|
||||||
.clk, .reset, .CacheEn, .CMOp, .CacheSet, .PAdr, .LineWriteData, .LineByteMask,
|
.clk, .reset, .CacheEn, .CMOp, .CacheSet, .PAdr, .LineWriteData, .LineByteMask, .SelWay,
|
||||||
.SetValid, .ClearValid, .SetDirty, .ClearDirty, .CMOZeroHit, .SelWriteback, .SelCMOWriteback, .VictimWay,
|
.SetValid, .ClearValid, .SetDirty, .ClearDirty, .CMOZeroHit, .SelWriteback, .SelCMOWriteback, .VictimWay,
|
||||||
.FlushWay, .SelFlush, .ReadDataLineWay, .HitWay, .ValidWay, .DirtyWay, .TagWay, .FlushStage, .InvalidateCache);
|
.FlushWay, .SelFlush, .ReadDataLineWay, .HitWay, .ValidWay, .DirtyWay, .TagWay, .FlushStage, .InvalidateCache);
|
||||||
|
|
||||||
@ -231,7 +232,7 @@ module cache import cvw::*; #(parameter cvw_t P,
|
|||||||
cachefsm #(P, READ_ONLY_CACHE) cachefsm(.clk, .reset, .CacheBusRW, .CacheBusAck,
|
cachefsm #(P, READ_ONLY_CACHE) cachefsm(.clk, .reset, .CacheBusRW, .CacheBusAck,
|
||||||
.FlushStage, .CacheRW, .CacheAtomic, .Stall,
|
.FlushStage, .CacheRW, .CacheAtomic, .Stall,
|
||||||
.CacheHit, .LineDirty, .CacheStall, .CacheCommitted,
|
.CacheHit, .LineDirty, .CacheStall, .CacheCommitted,
|
||||||
.CacheMiss, .CacheAccess, .SelAdr,
|
.CacheMiss, .CacheAccess, .SelAdr, .SelWay,
|
||||||
.ClearDirty, .SetDirty, .SetValid, .ClearValid, .ZeroCacheLine, .CMOZeroHit, .SelWriteback, .SelCMOWriteback, .SelFlush,
|
.ClearDirty, .SetDirty, .SetValid, .ClearValid, .ZeroCacheLine, .CMOZeroHit, .SelWriteback, .SelCMOWriteback, .SelFlush,
|
||||||
.FlushAdrCntEn, .FlushWayCntEn, .FlushCntRst,
|
.FlushAdrCntEn, .FlushWayCntEn, .FlushCntRst,
|
||||||
.FlushAdrFlag, .FlushWayFlag, .FlushCache, .SelFetchBuffer,
|
.FlushAdrFlag, .FlushWayFlag, .FlushCache, .SelFetchBuffer,
|
||||||
|
8
src/cache/cachefsm.sv
vendored
8
src/cache/cachefsm.sv
vendored
@ -65,6 +65,7 @@ module cachefsm import cvw::*; #(parameter cvw_t P,
|
|||||||
output logic SelCMOWriteback, // Overrides cached tag check to select a specific way and set for writeback for both data and tag
|
output logic SelCMOWriteback, // Overrides cached tag check to select a specific way and set for writeback for both data and tag
|
||||||
output logic LRUWriteEn, // Update the LRU state
|
output logic LRUWriteEn, // Update the LRU state
|
||||||
output logic SelFlush, // [0] Use SelAdr, [1] SRAM reads/writes from FlushAdr
|
output logic SelFlush, // [0] Use SelAdr, [1] SRAM reads/writes from FlushAdr
|
||||||
|
output logic SelWay, // Controls which way to select a way data and tag, 00 = hitway, 10 = victimway, 11 = flushway
|
||||||
output logic FlushAdrCntEn, // Enable the counter for Flush Adr
|
output logic FlushAdrCntEn, // Enable the counter for Flush Adr
|
||||||
output logic FlushWayCntEn, // Enable the way counter during a flush
|
output logic FlushWayCntEn, // Enable the way counter during a flush
|
||||||
output logic FlushCntRst, // Reset both flush counters
|
output logic FlushCntRst, // Reset both flush counters
|
||||||
@ -166,7 +167,7 @@ module cachefsm import cvw::*; #(parameter cvw_t P,
|
|||||||
// write enables internal to cache
|
// write enables internal to cache
|
||||||
assign CMOZeroHit = CurrState == STATE_READY & CMOp[3] & CacheHit ;
|
assign CMOZeroHit = CurrState == STATE_READY & CMOp[3] & CacheHit ;
|
||||||
assign SetValid = CurrState == STATE_WRITE_LINE |
|
assign SetValid = CurrState == STATE_WRITE_LINE |
|
||||||
(CurrState == STATE_READY & CMOZeroNoEviction) |
|
(P.ZICBOZ_SUPPORTED & CurrState == STATE_READY & CMOZeroNoEviction) |
|
||||||
(P.ZICBOZ_SUPPORTED & CurrState == STATE_WRITEBACK & CacheBusAck & CMOp[3]);
|
(P.ZICBOZ_SUPPORTED & CurrState == STATE_WRITEBACK & CacheBusAck & CMOp[3]);
|
||||||
assign ClearValid = P.ZICBOM_SUPPORTED & ((CurrState == STATE_READY & CMOp[0] & CacheHit) |
|
assign ClearValid = P.ZICBOM_SUPPORTED & ((CurrState == STATE_READY & CMOp[0] & CacheHit) |
|
||||||
(CurrState == STATE_CMO_WRITEBACK & CMOp[2] & CacheBusAck));
|
(CurrState == STATE_CMO_WRITEBACK & CMOp[2] & CacheBusAck));
|
||||||
@ -182,6 +183,11 @@ module cachefsm import cvw::*; #(parameter cvw_t P,
|
|||||||
(CurrState == STATE_FLUSH & LineDirty) | // This is wrong in a multicore snoop cache protocal. Dirty must be cleared concurrently and atomically with writeback. For single core cannot clear after writeback on bus ack and change flushadr. Clears the wrong set.
|
(CurrState == STATE_FLUSH & LineDirty) | // This is wrong in a multicore snoop cache protocal. Dirty must be cleared concurrently and atomically with writeback. For single core cannot clear after writeback on bus ack and change flushadr. Clears the wrong set.
|
||||||
// Flush and eviction controls
|
// Flush and eviction controls
|
||||||
(P.ZICBOM_SUPPORTED & CurrState == STATE_CMO_WRITEBACK & (CMOp[1] | CMOp[2]) & CacheBusAck);
|
(P.ZICBOM_SUPPORTED & CurrState == STATE_CMO_WRITEBACK & (CMOp[1] | CMOp[2]) & CacheBusAck);
|
||||||
|
assign SelWay = SelWriteback | (CurrState == STATE_WRITE_LINE) |
|
||||||
|
// This is almost the same as setvalid, but on cachehit we don't want to select
|
||||||
|
// the nonhit way, but instead want to force this to zero
|
||||||
|
(P.ZICBOZ_SUPPORTED & CurrState == STATE_READY & CMOZeroNoEviction & ~CacheHit) |
|
||||||
|
(P.ZICBOZ_SUPPORTED & CurrState == STATE_WRITEBACK & CacheBusAck & CMOp[3]);
|
||||||
assign ZeroCacheLine = P.ZICBOZ_SUPPORTED & ((CurrState == STATE_READY & CMOZeroNoEviction) |
|
assign ZeroCacheLine = P.ZICBOZ_SUPPORTED & ((CurrState == STATE_READY & CMOZeroNoEviction) |
|
||||||
(CurrState == STATE_WRITEBACK & (CMOp[3] & CacheBusAck)));
|
(CurrState == STATE_WRITEBACK & (CMOp[3] & CacheBusAck)));
|
||||||
assign SelWriteback = (CurrState == STATE_WRITEBACK & ~CacheBusAck) |
|
assign SelWriteback = (CurrState == STATE_WRITEBACK & ~CacheBusAck) |
|
||||||
|
19
src/cache/cacheway.sv
vendored
19
src/cache/cacheway.sv
vendored
@ -41,7 +41,8 @@ module cacheway import cvw::*; #(parameter cvw_t P,
|
|||||||
input logic SetValid, // Set the valid bit in the selected way and set
|
input logic SetValid, // Set the valid bit in the selected way and set
|
||||||
input logic ClearValid, // Clear the valid bit in the selected way and set
|
input logic ClearValid, // Clear the valid bit in the selected way and set
|
||||||
input logic SetDirty, // Set the dirty bit in the selected way and set
|
input logic SetDirty, // Set the dirty bit in the selected way and set
|
||||||
input logic CMOZeroHit, // Write zeros to all bytes of a cache line
|
input logic SelWay, // Controls which way to select a way data and tag, 00 = hitway, 10 = victimway, 11 = flushway
|
||||||
|
input logic CMOZeroHit, // Write zeros to all bytes of a cache line
|
||||||
input logic ClearDirty, // Clear the dirty bit in the selected way and set
|
input logic ClearDirty, // Clear the dirty bit in the selected way and set
|
||||||
input logic SelWriteback, // Overrides cached tag check to select a specific way and set for writeback
|
input logic SelWriteback, // Overrides cached tag check to select a specific way and set for writeback
|
||||||
input logic SelCMOWriteback,// Overrides cached tag check to select a specific way and set for writeback for both data and tag
|
input logic SelCMOWriteback,// Overrides cached tag check to select a specific way and set for writeback for both data and tag
|
||||||
@ -80,30 +81,18 @@ module cacheway import cvw::*; #(parameter cvw_t P,
|
|||||||
logic SelData;
|
logic SelData;
|
||||||
logic SelNotHit2;
|
logic SelNotHit2;
|
||||||
|
|
||||||
if (P.ZICBOZ_SUPPORTED) begin : cbologic
|
|
||||||
assign SelNotHit2 = SetValid & ~CMOZeroHit;
|
|
||||||
//assign SelNotHit2 = SetValid;
|
|
||||||
|
|
||||||
end else begin : cbologic
|
|
||||||
assign SelNotHit2 = SetValid;
|
|
||||||
end
|
|
||||||
|
|
||||||
if (!READ_ONLY_CACHE) begin:flushlogic
|
if (!READ_ONLY_CACHE) begin:flushlogic
|
||||||
logic FlushWayEn;
|
logic FlushWayEn;
|
||||||
|
|
||||||
mux2 #(1) seltagmux(VictimWay, FlushWay, SelFlush, SelTag);
|
mux2 #(1) seltagmux(VictimWay, FlushWay, SelFlush, SelTag);
|
||||||
|
|
||||||
// FlushWay is part of a one hot way selection. Must clear it if FlushWay not selected.
|
// FlushWay is part of a one hot way selection. Must clear it if FlushWay not selected.
|
||||||
// coverage off -item e 1 -fecexprrow 3
|
// coverage off -item e 1 -fecexprrow 3
|
||||||
// nonzero ways will never see SelFlush=0 while FlushWay=1 since FlushWay only advances on a subset of SelFlush assertion cases.
|
// nonzero ways will never see SelFlush=0 while FlushWay=1 since FlushWay only advances on a subset of SelFlush assertion cases.
|
||||||
assign FlushWayEn = FlushWay & SelFlush;
|
assign FlushWayEn = FlushWay & SelFlush;
|
||||||
// *** RT: This is slopy. I should refactor to have the fsm issue two types of writeback commands
|
assign SelNonHit = FlushWayEn | SelWay;
|
||||||
assign SelNonHit = FlushWayEn | SelNotHit2 | SelWriteback; // *** this is not correct
|
|
||||||
|
|
||||||
//assign SelNonHit = FlushWayEn | SelNotHit2 | SelWriteback;
|
|
||||||
end else begin:flushlogic // no flush operation for read-only caches.
|
end else begin:flushlogic // no flush operation for read-only caches.
|
||||||
assign SelTag = VictimWay;
|
assign SelTag = VictimWay;
|
||||||
assign SelNonHit = SelNotHit2;
|
assign SelNonHit = SelWay;
|
||||||
end
|
end
|
||||||
|
|
||||||
mux2 #(1) selectedwaymux(HitWay, SelTag, SelNonHit , SelData);
|
mux2 #(1) selectedwaymux(HitWay, SelTag, SelNonHit , SelData);
|
||||||
|
Loading…
Reference in New Issue
Block a user