mirror of
https://github.com/openhwgroup/cvw
synced 2025-01-30 16:34:28 +00:00
Make AdrSelMux and CacheBusAdrMux mux2 if READ_ONLY_CACHE
Some address options are only used in the D$ case.
This commit is contained in:
parent
7c9f68e984
commit
5b8c6f070e
28
src/cache/cache.sv
vendored
28
src/cache/cache.sv
vendored
@ -73,7 +73,6 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
|
|
||||||
|
|
||||||
logic SelAdr;
|
logic SelAdr;
|
||||||
logic [1:0] AdrSelMuxSel;
|
|
||||||
logic [SETLEN-1:0] CacheSet;
|
logic [SETLEN-1:0] CacheSet;
|
||||||
logic [LINELEN-1:0] LineWriteData;
|
logic [LINELEN-1:0] LineWriteData;
|
||||||
logic ClearDirty, SetDirty, SetValid;
|
logic ClearDirty, SetDirty, SetValid;
|
||||||
@ -109,10 +108,18 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
// and FlushAdr when handling D$ flushes
|
// and FlushAdr when handling D$ flushes
|
||||||
// The icache must update to the newest PCNextF on flush as it is probably a trap. Trap
|
// The icache must update to the newest PCNextF on flush as it is probably a trap. Trap
|
||||||
// sets PCNextF to XTVEC and the icache must start reading the instruction.
|
// sets PCNextF to XTVEC and the icache must start reading the instruction.
|
||||||
assign AdrSelMuxSel = {SelFlush, ((SelAdr | SelHPTW) & ~((READ_ONLY_CACHE == 1) & FlushStage))};
|
if (!READ_ONLY_CACHE) begin
|
||||||
mux3 #(SETLEN) AdrSelMux(NextSet[SETTOP-1:OFFSETLEN], PAdr[SETTOP-1:OFFSETLEN], FlushAdr,
|
logic [1:0] AdrSelMuxSel;
|
||||||
|
assign AdrSelMuxSel = {SelFlush, SelAdr | SelHPTW};
|
||||||
|
mux3 #(SETLEN) AdrSelMux(NextSet[SETTOP-1:OFFSETLEN], PAdr[SETTOP-1:OFFSETLEN], FlushAdr,
|
||||||
AdrSelMuxSel, CacheSet);
|
AdrSelMuxSel, CacheSet);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
logic AdrSelMuxSel;
|
||||||
|
assign AdrSelMuxSel = ((SelAdr | SelHPTW) & ~FlushStage);
|
||||||
|
mux2 #(SETLEN) AdrSelMux(NextSet[SETTOP-1:OFFSETLEN], PAdr[SETTOP-1:OFFSETLEN],
|
||||||
|
AdrSelMuxSel, CacheSet);
|
||||||
|
end
|
||||||
// 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, READ_ONLY_CACHE) CacheWays[NUMWAYS-1:0](
|
cacheway #(NUMLINES, LINELEN, TAGLEN, OFFSETLEN, SETLEN, READ_ONLY_CACHE) CacheWays[NUMWAYS-1:0](
|
||||||
.clk, .reset, .CacheEn, .CacheSet, .PAdr, .LineWriteData, .LineByteMask,
|
.clk, .reset, .CacheEn, .CacheSet, .PAdr, .LineWriteData, .LineByteMask,
|
||||||
@ -152,11 +159,14 @@ module cache #(parameter LINELEN, NUMLINES, NUMWAYS, LOGBWPL, WORDLEN, MUXINTE
|
|||||||
.PAdr(WordOffsetAddr), .ReadDataLine, .ReadDataWord);
|
.PAdr(WordOffsetAddr), .ReadDataLine, .ReadDataWord);
|
||||||
|
|
||||||
// Bus address for fetch, writeback, or flush writeback
|
// Bus address for fetch, writeback, or flush writeback
|
||||||
mux3 #(`PA_BITS) CacheBusAdrMux(.d0({PAdr[`PA_BITS-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
if (!READ_ONLY_CACHE)
|
||||||
.d1({Tag, PAdr[SETTOP-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
mux3 #(`PA_BITS) CacheBusAdrMux(.d0({PAdr[`PA_BITS-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
||||||
.d2({Tag, FlushAdr, {OFFSETLEN{1'b0}}}),
|
.d1({Tag, PAdr[SETTOP-1:OFFSETLEN], {OFFSETLEN{1'b0}}}),
|
||||||
.s({SelFlush, SelWriteback}), .y(CacheBusAdr));
|
.d2({Tag, FlushAdr, {OFFSETLEN{1'b0}}}),
|
||||||
|
.s({SelFlush, SelWriteback}), .y(CacheBusAdr));
|
||||||
|
else
|
||||||
|
assign CacheBusAdr = {PAdr[`PA_BITS-1:OFFSETLEN], {OFFSETLEN{1'b0}}};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Write Path
|
// Write Path
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user