mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Signal renames to reflect figures.
This commit is contained in:
parent
a3ec829b80
commit
09dcb56217
16
pipelined/src/cache/cache.sv
vendored
16
pipelined/src/cache/cache.sv
vendored
@ -94,14 +94,14 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
logic [NUMWAYS-1:0] NextFlushWay;
|
logic [NUMWAYS-1:0] NextFlushWay;
|
||||||
logic FlushWayCntEn;
|
logic FlushWayCntEn;
|
||||||
logic FlushWayCntRst;
|
logic FlushWayCntRst;
|
||||||
logic SelEvict;
|
logic SelWriteback;
|
||||||
logic LRUWriteEn;
|
logic LRUWriteEn;
|
||||||
logic SelFlush;
|
logic SelFlush;
|
||||||
logic ResetOrFlushAdr, ResetOrFlushWay;
|
logic ResetOrFlushAdr, ResetOrFlushWay;
|
||||||
logic [LINELEN-1:0] ReadDataLine, ReadDataLineCache;
|
logic [LINELEN-1:0] ReadDataLine, ReadDataLineCache;
|
||||||
logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1:0] WordOffsetAddr;
|
logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1:0] WordOffsetAddr;
|
||||||
logic SelFetchBuffer;
|
logic SelFetchBuffer;
|
||||||
logic ce;
|
logic CacheEn;
|
||||||
|
|
||||||
localparam LOGLLENBYTES = $clog2(WORDLEN/8);
|
localparam LOGLLENBYTES = $clog2(WORDLEN/8);
|
||||||
localparam CACHEWORDSPERLINE = `DCACHE_LINELENINBITS/WORDLEN;
|
localparam CACHEWORDSPERLINE = `DCACHE_LINELENINBITS/WORDLEN;
|
||||||
@ -124,12 +124,12 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
|
|
||||||
// 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 #(NUMLINES, LINELEN, TAGLEN, OFFSETLEN, SETLEN, DCACHE)
|
cacheway #(NUMLINES, LINELEN, TAGLEN, OFFSETLEN, SETLEN, DCACHE)
|
||||||
CacheWays[NUMWAYS-1:0](.clk, .reset, .ce, .CAdr, .PAdr, .LineWriteData, .LineByteMask,
|
CacheWays[NUMWAYS-1:0](.clk, .reset, .CacheEn, .CAdr, .PAdr, .LineWriteData, .LineByteMask,
|
||||||
.SetValid, .ClearValid, .SetDirty, .ClearDirty, .SelEvict, .VictimWay,
|
.SetValid, .ClearValid, .SetDirty, .ClearDirty, .SelWriteback, .VictimWay,
|
||||||
.FlushWay, .SelFlush, .ReadDataLineWay, .HitWay, .ValidWay, .DirtyWay, .TagWay, .FlushStage, .InvalidateCache);
|
.FlushWay, .SelFlush, .ReadDataLineWay, .HitWay, .ValidWay, .DirtyWay, .TagWay, .FlushStage, .InvalidateCache);
|
||||||
if(NUMWAYS > 1) begin:vict
|
if(NUMWAYS > 1) begin:vict
|
||||||
cacheLRU #(NUMWAYS, SETLEN, OFFSETLEN, NUMLINES) cacheLRU(
|
cacheLRU #(NUMWAYS, SETLEN, OFFSETLEN, NUMLINES) cacheLRU(
|
||||||
.clk, .reset, .ce, .FlushStage, .HitWay, .ValidWay, .VictimWay, .CAdr, .LRUWriteEn(LRUWriteEn & ~FlushStage),
|
.clk, .reset, .CacheEn, .FlushStage, .HitWay, .ValidWay, .VictimWay, .CAdr, .LRUWriteEn(LRUWriteEn & ~FlushStage),
|
||||||
.SetValid, .PAdr(PAdr[SETTOP-1:OFFSETLEN]), .InvalidateCache, .FlushCache);
|
.SetValid, .PAdr(PAdr[SETTOP-1:OFFSETLEN]), .InvalidateCache, .FlushCache);
|
||||||
end else assign VictimWay = 1'b1; // one hot.
|
end else assign VictimWay = 1'b1; // one hot.
|
||||||
assign CacheHit = | HitWay;
|
assign CacheHit = | HitWay;
|
||||||
@ -174,7 +174,7 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
mux3 #(`PA_BITS) CacheBusAdrMux(.d0({PAdr[`PA_BITS-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
mux3 #(`PA_BITS) CacheBusAdrMux(.d0({PAdr[`PA_BITS-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
||||||
.d1({Tag, PAdr[SETTOP-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
.d1({Tag, PAdr[SETTOP-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
||||||
.d2({Tag, FlushAdr, {OFFSETLEN{1'b0}}}),
|
.d2({Tag, FlushAdr, {OFFSETLEN{1'b0}}}),
|
||||||
.s({SelFlush, SelEvict}), .y(CacheBusAdr));
|
.s({SelFlush, SelWriteback}), .y(CacheBusAdr));
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Flush address and way generation during flush
|
// Flush address and way generation during flush
|
||||||
@ -199,10 +199,10 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
.CacheHit, .LineDirty, .CacheStall, .CacheCommitted,
|
.CacheHit, .LineDirty, .CacheStall, .CacheCommitted,
|
||||||
.CacheMiss, .CacheAccess, .SelAdr,
|
.CacheMiss, .CacheAccess, .SelAdr,
|
||||||
.ClearValid, .ClearDirty, .SetDirty,
|
.ClearValid, .ClearDirty, .SetDirty,
|
||||||
.SetValid, .SelEvict, .SelFlush,
|
.SetValid, .SelWriteback, .SelFlush,
|
||||||
.FlushAdrCntEn, .FlushWayCntEn, .FlushAdrCntRst,
|
.FlushAdrCntEn, .FlushWayCntEn, .FlushAdrCntRst,
|
||||||
.FlushWayCntRst, .FlushAdrFlag, .FlushWayFlag, .FlushCache, .SelFetchBuffer,
|
.FlushWayCntRst, .FlushAdrFlag, .FlushWayFlag, .FlushCache, .SelFetchBuffer,
|
||||||
.InvalidateCache,
|
.InvalidateCache,
|
||||||
.ce,
|
.CacheEn,
|
||||||
.LRUWriteEn);
|
.LRUWriteEn);
|
||||||
endmodule
|
endmodule
|
||||||
|
4
pipelined/src/cache/cacheLRU.sv
vendored
4
pipelined/src/cache/cacheLRU.sv
vendored
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
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, ce, FlushStage,
|
input logic clk, reset, CacheEn, 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,
|
output logic [NUMWAYS-1:0] VictimWay,
|
||||||
@ -120,7 +120,7 @@ module cacheLRU
|
|||||||
// LRU storage must be reset for modelsim to run. However the reset value does not actually matter in practice.
|
// LRU storage must be reset for modelsim to run. However the reset value does not actually matter in practice.
|
||||||
always_ff @(posedge clk) begin
|
always_ff @(posedge clk) begin
|
||||||
if (reset) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0;
|
if (reset) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0;
|
||||||
if(ce) begin
|
if(CacheEn) begin
|
||||||
if((InvalidateCache | FlushCache) & ~FlushStage) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0;
|
if((InvalidateCache | FlushCache) & ~FlushStage) for (int set = 0; set < NUMLINES; set++) LRUMemory[set] <= '0;
|
||||||
else if (LRUWriteEn & ~FlushStage) begin
|
else if (LRUWriteEn & ~FlushStage) begin
|
||||||
LRUMemory[CAdr] <= NextLRU; ///***** RT: This is not right. Logically should be PAdr, but it breaks linux.
|
LRUMemory[CAdr] <= NextLRU; ///***** RT: This is not right. Logically should be PAdr, but it breaks linux.
|
||||||
|
8
pipelined/src/cache/cachefsm.sv
vendored
8
pipelined/src/cache/cachefsm.sv
vendored
@ -64,7 +64,7 @@ module cachefsm
|
|||||||
output logic ClearDirty,
|
output logic ClearDirty,
|
||||||
output logic SetDirty,
|
output logic SetDirty,
|
||||||
output logic SetValid,
|
output logic SetValid,
|
||||||
output logic SelEvict,
|
output logic SelWriteback,
|
||||||
output logic LRUWriteEn,
|
output logic LRUWriteEn,
|
||||||
output logic SelFlush,
|
output logic SelFlush,
|
||||||
output logic FlushAdrCntEn,
|
output logic FlushAdrCntEn,
|
||||||
@ -72,7 +72,7 @@ module cachefsm
|
|||||||
output logic FlushAdrCntRst,
|
output logic FlushAdrCntRst,
|
||||||
output logic FlushWayCntRst,
|
output logic FlushWayCntRst,
|
||||||
output logic SelFetchBuffer,
|
output logic SelFetchBuffer,
|
||||||
output logic ce);
|
output logic CacheEn);
|
||||||
|
|
||||||
logic resetDelay;
|
logic resetDelay;
|
||||||
logic AMO, StoreAMO;
|
logic AMO, StoreAMO;
|
||||||
@ -170,7 +170,7 @@ module cachefsm
|
|||||||
assign LRUWriteEn = (CurrState == STATE_READY & AnyHit) |
|
assign LRUWriteEn = (CurrState == STATE_READY & AnyHit) |
|
||||||
(CurrState == STATE_MISS_WRITE_CACHE_LINE);
|
(CurrState == STATE_MISS_WRITE_CACHE_LINE);
|
||||||
// Flush and eviction controls
|
// Flush and eviction controls
|
||||||
assign SelEvict = (CurrState == STATE_MISS_EVICT_DIRTY & ~CacheBusAck) |
|
assign SelWriteback = (CurrState == STATE_MISS_EVICT_DIRTY & ~CacheBusAck) |
|
||||||
(CurrState == STATE_READY & AnyMiss & LineDirty);
|
(CurrState == STATE_READY & AnyMiss & LineDirty);
|
||||||
assign SelFlush = (CurrState == STATE_FLUSH) | (CurrState == STATE_FLUSH_CHECK) |
|
assign SelFlush = (CurrState == STATE_FLUSH) | (CurrState == STATE_FLUSH_CHECK) |
|
||||||
(CurrState == STATE_FLUSH_INCR) | (CurrState == STATE_FLUSH_WRITE_BACK);
|
(CurrState == STATE_FLUSH_INCR) | (CurrState == STATE_FLUSH_WRITE_BACK);
|
||||||
@ -201,6 +201,6 @@ module cachefsm
|
|||||||
resetDelay;
|
resetDelay;
|
||||||
|
|
||||||
assign SelFetchBuffer = CurrState == STATE_MISS_WRITE_CACHE_LINE | CurrState == STATE_MISS_READ_DELAY;
|
assign SelFetchBuffer = CurrState == STATE_MISS_WRITE_CACHE_LINE | CurrState == STATE_MISS_READ_DELAY;
|
||||||
assign ce = (CurrState == STATE_READY & ~Stall | CacheStall) | (CurrState != STATE_READY) | reset;
|
assign CacheEn = (CurrState == STATE_READY & ~Stall | CacheStall) | (CurrState != STATE_READY) | reset;
|
||||||
|
|
||||||
endmodule // cachefsm
|
endmodule // cachefsm
|
||||||
|
35
pipelined/src/cache/cacheway.sv
vendored
35
pipelined/src/cache/cacheway.sv
vendored
@ -33,7 +33,7 @@
|
|||||||
module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
||||||
parameter OFFSETLEN = 5, parameter INDEXLEN = 9, parameter DIRTY_BITS = 1) (
|
parameter OFFSETLEN = 5, parameter INDEXLEN = 9, parameter DIRTY_BITS = 1) (
|
||||||
input logic clk,
|
input logic clk,
|
||||||
input logic ce,
|
input logic CacheEn,
|
||||||
input logic reset,
|
input logic reset,
|
||||||
input logic [$clog2(NUMLINES)-1:0] CAdr,
|
input logic [$clog2(NUMLINES)-1:0] CAdr,
|
||||||
input logic [`PA_BITS-1:0] PAdr,
|
input logic [`PA_BITS-1:0] PAdr,
|
||||||
@ -42,7 +42,7 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
input logic ClearValid,
|
input logic ClearValid,
|
||||||
input logic SetDirty,
|
input logic SetDirty,
|
||||||
input logic ClearDirty,
|
input logic ClearDirty,
|
||||||
input logic SelEvict,
|
input logic SelWriteback,
|
||||||
input logic SelFlush,
|
input logic SelFlush,
|
||||||
input logic VictimWay,
|
input logic VictimWay,
|
||||||
input logic FlushWay,
|
input logic FlushWay,
|
||||||
@ -76,8 +76,7 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
logic ClearValidWay;
|
logic ClearValidWay;
|
||||||
logic SetDirtyWay;
|
logic SetDirtyWay;
|
||||||
logic ClearDirtyWay;
|
logic ClearDirtyWay;
|
||||||
logic SelectedWay;
|
logic SelNonHit;
|
||||||
logic SelWriteback;
|
|
||||||
logic SelData;
|
logic SelData;
|
||||||
logic FlushWayEn, VictimWayEn;
|
logic FlushWayEn, VictimWayEn;
|
||||||
|
|
||||||
@ -85,28 +84,28 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
// 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;
|
||||||
assign VictimWayEn = VictimWay & SelEvict;
|
assign VictimWayEn = VictimWay & SelWriteback;
|
||||||
|
|
||||||
assign SelWriteback = FlushWayEn | SetValid | SelEvict;
|
assign SelNonHit = FlushWayEn | SetValid | SelWriteback;
|
||||||
|
|
||||||
mux2 #(1) seltagmux(VictimWay, FlushWay, SelFlush, SelTag);
|
mux2 #(1) seltagmux(VictimWay, FlushWay, SelFlush, SelTag);
|
||||||
//assign SelTag = VictimWay | FlushWay;
|
//assign SelTag = VictimWay | FlushWay;
|
||||||
assign SelData = HitWay | FlushWayEn | VictimWayEn;
|
//assign SelData = HitWay | FlushWayEn | VictimWayEn;
|
||||||
|
|
||||||
mux2 #(1) selectedwaymux(HitWay, SelTag, SelWriteback , SelectedWay);
|
mux2 #(1) selectedwaymux(HitWay, SelTag, SelNonHit , SelData);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Write Enable demux
|
// Write Enable demux
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// RT: Can we merge these two muxes? This is also shared in cacheLRU.
|
// RT: Can we merge these two muxes? This is also shared in cacheLRU.
|
||||||
//mux3 #(1) selectwaymux(HitWay, VictimWay, FlushWay, {SelFlush, SetValid}, SelectedWay);
|
//mux3 #(1) selectwaymux(HitWay, VictimWay, FlushWay, {SelFlush, SetValid}, SelData);
|
||||||
//mux3 #(1) selecteddatamux(HitWay, VictimWay, FlushWay, {SelFlush, SelEvict}, SelData);
|
//mux3 #(1) selecteddatamux(HitWay, VictimWay, FlushWay, {SelFlush, SelNonHit}, SelData);
|
||||||
|
|
||||||
assign SetValidWay = SetValid & SelectedWay;
|
assign SetValidWay = SetValid & SelData;
|
||||||
assign ClearValidWay = ClearValid & SelectedWay;
|
assign ClearValidWay = ClearValid & SelData;
|
||||||
assign SetDirtyWay = SetDirty & SelectedWay;
|
assign SetDirtyWay = SetDirty & SelData;
|
||||||
assign ClearDirtyWay = ClearDirty & SelectedWay;
|
assign ClearDirtyWay = ClearDirty & SelData;
|
||||||
|
|
||||||
// If writing the whole line set all write enables to 1, else only set the correct word.
|
// If writing the whole line set all write enables to 1, else only set the correct word.
|
||||||
assign SelectedWriteWordEn = (SetValidWay | SetDirtyWay) & ~FlushStage;
|
assign SelectedWriteWordEn = (SetValidWay | SetDirtyWay) & ~FlushStage;
|
||||||
@ -117,7 +116,7 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
// Tag Array
|
// Tag Array
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
sram1p1rw #(.DEPTH(NUMLINES), .WIDTH(TAGLEN)) CacheTagMem(.clk, .ce,
|
sram1p1rw #(.DEPTH(NUMLINES), .WIDTH(TAGLEN)) CacheTagMem(.clk, .ce(CacheEn),
|
||||||
.addr(CAdr), .dout(ReadTag), .bwe('1),
|
.addr(CAdr), .dout(ReadTag), .bwe('1),
|
||||||
.din(PAdr[`PA_BITS-1:OFFSETLEN+INDEXLEN]), .we(SetValidEN));
|
.din(PAdr[`PA_BITS-1:OFFSETLEN+INDEXLEN]), .we(SetValidEN));
|
||||||
|
|
||||||
@ -140,7 +139,7 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
localparam integer LOGNUMSRAM = $clog2(NUMSRAM);
|
localparam integer LOGNUMSRAM = $clog2(NUMSRAM);
|
||||||
|
|
||||||
for(words = 0; words < NUMSRAM; words++) begin: word
|
for(words = 0; words < NUMSRAM; words++) begin: word
|
||||||
sram1p1rw #(.DEPTH(NUMLINES), .WIDTH(SRAMLEN)) CacheDataMem(.clk, .ce, .addr(CAdr),
|
sram1p1rw #(.DEPTH(NUMLINES), .WIDTH(SRAMLEN)) CacheDataMem(.clk, .ce(CacheEn), .addr(CAdr),
|
||||||
.dout(ReadDataLine[SRAMLEN*(words+1)-1:SRAMLEN*words]),
|
.dout(ReadDataLine[SRAMLEN*(words+1)-1:SRAMLEN*words]),
|
||||||
.din(LineWriteData[SRAMLEN*(words+1)-1:SRAMLEN*words]),
|
.din(LineWriteData[SRAMLEN*(words+1)-1:SRAMLEN*words]),
|
||||||
.we(SelectedWriteWordEn), .bwe(FinalByteMask[SRAMLENINBYTES*(words+1)-1:SRAMLENINBYTES*words]));
|
.we(SelectedWriteWordEn), .bwe(FinalByteMask[SRAMLENINBYTES*(words+1)-1:SRAMLENINBYTES*words]));
|
||||||
@ -155,7 +154,7 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
|
|
||||||
always_ff @(posedge clk) begin // Valid bit array,
|
always_ff @(posedge clk) begin // Valid bit array,
|
||||||
if (reset) ValidBits <= #1 '0;
|
if (reset) ValidBits <= #1 '0;
|
||||||
if(ce) begin
|
if(CacheEn) begin
|
||||||
ValidWay <= #1 ValidBits[CAdr];
|
ValidWay <= #1 ValidBits[CAdr];
|
||||||
if(InvalidateCache & ~FlushStage) ValidBits <= #1 '0;
|
if(InvalidateCache & ~FlushStage) ValidBits <= #1 '0;
|
||||||
else if (SetValidEN | (ClearValidWay & ~FlushStage)) ValidBits[CAdr] <= #1 SetValidWay;
|
else if (SetValidEN | (ClearValidWay & ~FlushStage)) ValidBits[CAdr] <= #1 SetValidWay;
|
||||||
@ -171,7 +170,7 @@ module cacheway #(parameter NUMLINES=512, parameter LINELEN = 256, TAGLEN = 26,
|
|||||||
always_ff @(posedge clk) begin
|
always_ff @(posedge clk) begin
|
||||||
// reset is optional. Consider merging with TAG array in the future.
|
// reset is optional. Consider merging with TAG array in the future.
|
||||||
//if (reset) DirtyBits <= #1 {NUMLINES{1'b0}};
|
//if (reset) DirtyBits <= #1 {NUMLINES{1'b0}};
|
||||||
if(ce) begin
|
if(CacheEn) begin
|
||||||
Dirty <= #1 DirtyBits[CAdr];
|
Dirty <= #1 DirtyBits[CAdr];
|
||||||
if((SetDirtyWay | ClearDirtyWay) & ~FlushStage) DirtyBits[CAdr] <= #1 SetDirtyWay;
|
if((SetDirtyWay | ClearDirtyWay) & ~FlushStage) DirtyBits[CAdr] <= #1 SetDirtyWay;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user