mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Reformatting cachefsm.
This commit is contained in:
parent
d3df8e062e
commit
3d202ed2fd
2
pipelined/src/cache/cache.sv
vendored
2
pipelined/src/cache/cache.sv
vendored
@ -55,7 +55,7 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
input logic SelBusBeat, // Word in cache line comes from BeatCount
|
input logic SelBusBeat, // Word in cache line comes from BeatCount
|
||||||
input logic [LOGBWPL-1:0] BeatCount, // Beat in burst
|
input logic [LOGBWPL-1:0] BeatCount, // Beat in burst
|
||||||
input logic [LINELEN-1:0] FetchBuffer, // Buffer long enough to hold entire cache line arriving from bus
|
input logic [LINELEN-1:0] FetchBuffer, // Buffer long enough to hold entire cache line arriving from bus
|
||||||
output logic [1:0] CacheBusRW, // [1] Read or [0] write bus
|
output logic [1:0] CacheBusRW, // [1] Read (cache line fetch) or [0] write bus (cache line writeback)
|
||||||
output logic [`PA_BITS-1:0] CacheBusAdr // Address for bus access
|
output logic [`PA_BITS-1:0] CacheBusAdr // Address for bus access
|
||||||
);
|
);
|
||||||
|
|
||||||
|
56
pipelined/src/cache/cachefsm.sv
vendored
56
pipelined/src/cache/cachefsm.sv
vendored
@ -29,30 +29,28 @@
|
|||||||
module cachefsm (
|
module cachefsm (
|
||||||
input logic clk,
|
input logic clk,
|
||||||
input logic reset,
|
input logic reset,
|
||||||
|
// hazard and privilege unit
|
||||||
|
input logic Stall, // Stall the cache, preventing new accesses. In-flight access finished but does not return to READY
|
||||||
|
input logic FlushStage, // Pipeline flush of second stage (prevent writes and bus operations)
|
||||||
|
output logic CacheCommitted, // Cache has started bus operation that shouldn't be interrupted
|
||||||
|
output logic CacheStall, // Cache stalls pipeline during multicycle operation
|
||||||
// inputs from IEU
|
// inputs from IEU
|
||||||
input logic FlushStage,
|
input logic [1:0] CacheRW, // [1] Read, [0] Write
|
||||||
input logic [1:0] CacheRW,
|
input logic [1:0] CacheAtomic, // Atomic operation
|
||||||
input logic [1:0] CacheAtomic,
|
input logic FlushCache, // Flush all dirty lines back to memory
|
||||||
input logic FlushCache,
|
input logic InvalidateCache, // Clear all valid bits
|
||||||
input logic InvalidateCache,
|
// cache internals
|
||||||
// hazard inputs
|
input logic CacheHit, // Exactly 1 way hits
|
||||||
input logic Stall,
|
input logic LineDirty, // The selected line and way is dirty
|
||||||
// Bus inputs
|
input logic FlushAdrFlag, // On last set of a cache flush
|
||||||
input logic CacheBusAck,
|
input logic FlushWayFlag, // On the last way for any set of a cache flush
|
||||||
// dcache internals
|
// Bus controls
|
||||||
input logic CacheHit,
|
input logic CacheBusAck, // Bus operation completed
|
||||||
input logic LineDirty,
|
output logic [1:0] CacheBusRW, // [1] Read (cache line fetch) or [0] write bus (cache line writeback)
|
||||||
input logic FlushAdrFlag,
|
// performance counter outputs
|
||||||
input logic FlushWayFlag,
|
output logic CacheMiss, // Cache miss
|
||||||
|
output logic CacheAccess, // Cache access
|
||||||
// hazard outputs
|
|
||||||
output logic CacheStall,
|
|
||||||
// counter outputs
|
|
||||||
output logic CacheMiss,
|
|
||||||
output logic CacheAccess,
|
|
||||||
// Bus outputs
|
// Bus outputs
|
||||||
output logic CacheCommitted,
|
|
||||||
output logic [1:0] CacheBusRW,
|
|
||||||
|
|
||||||
// dcache internals
|
// dcache internals
|
||||||
output logic SelAdr,
|
output logic SelAdr,
|
||||||
@ -114,8 +112,6 @@ module cachefsm (
|
|||||||
case (CurrState)
|
case (CurrState)
|
||||||
STATE_READY: if(InvalidateCache) NextState = STATE_READY;
|
STATE_READY: if(InvalidateCache) NextState = STATE_READY;
|
||||||
else if(FlushCache) NextState = STATE_FLUSH;
|
else if(FlushCache) NextState = STATE_FLUSH;
|
||||||
// Delayed LRU update. Cannot check if victim line is dirty on this cycle.
|
|
||||||
// To optimize do the fetch first, then eviction if necessary.
|
|
||||||
else if(AnyMiss & ~LineDirty) NextState = STATE_FETCH;
|
else if(AnyMiss & ~LineDirty) NextState = STATE_FETCH;
|
||||||
else if(AnyMiss & LineDirty) NextState = STATE_WRITEBACK;
|
else if(AnyMiss & LineDirty) NextState = STATE_WRITEBACK;
|
||||||
else NextState = STATE_READY;
|
else NextState = STATE_READY;
|
||||||
@ -128,11 +124,11 @@ module cachefsm (
|
|||||||
else NextState = STATE_WRITEBACK;
|
else NextState = STATE_WRITEBACK;
|
||||||
// eviction needs a delay as the bus fsm does not correctly handle sending the write command at the same time as getting back the bus ack.
|
// eviction needs a delay as the bus fsm does not correctly handle sending the write command at the same time as getting back the bus ack.
|
||||||
STATE_FLUSH: if(LineDirty) NextState = STATE_FLUSH_WRITEBACK;
|
STATE_FLUSH: if(LineDirty) NextState = STATE_FLUSH_WRITEBACK;
|
||||||
else if (FlushFlag) NextState = STATE_READ_HOLD;
|
else if (FlushFlag) NextState = STATE_READ_HOLD;
|
||||||
else NextState = STATE_FLUSH;
|
else NextState = STATE_FLUSH;
|
||||||
STATE_FLUSH_WRITEBACK: if(CacheBusAck & ~FlushFlag) NextState = STATE_FLUSH;
|
STATE_FLUSH_WRITEBACK: if(CacheBusAck & ~FlushFlag) NextState = STATE_FLUSH;
|
||||||
else if(CacheBusAck) NextState = STATE_READ_HOLD;
|
else if(CacheBusAck) NextState = STATE_READ_HOLD;
|
||||||
else NextState = STATE_FLUSH_WRITEBACK;
|
else NextState = STATE_FLUSH_WRITEBACK;
|
||||||
default: NextState = STATE_READY;
|
default: NextState = STATE_READY;
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
@ -174,7 +170,7 @@ module cachefsm (
|
|||||||
assign CacheBusRW[0] = (CurrState == STATE_READY & AnyMiss & LineDirty) |
|
assign CacheBusRW[0] = (CurrState == STATE_READY & AnyMiss & LineDirty) |
|
||||||
(CurrState == STATE_WRITEBACK & ~CacheBusAck) |
|
(CurrState == STATE_WRITEBACK & ~CacheBusAck) |
|
||||||
(CurrState == STATE_FLUSH_WRITEBACK & ~CacheBusAck);
|
(CurrState == STATE_FLUSH_WRITEBACK & ~CacheBusAck);
|
||||||
// **** can this be simplified?
|
|
||||||
assign SelAdr = (CurrState == STATE_READY & (StoreAMO | AnyMiss)) | // changes if store delay hazard removed
|
assign SelAdr = (CurrState == STATE_READY & (StoreAMO | AnyMiss)) | // changes if store delay hazard removed
|
||||||
(CurrState == STATE_FETCH) |
|
(CurrState == STATE_FETCH) |
|
||||||
(CurrState == STATE_WRITEBACK) |
|
(CurrState == STATE_WRITEBACK) |
|
||||||
|
Loading…
Reference in New Issue
Block a user