forked from Github_Repos/cvw
Possible fix for the incorrect behavior of the pseudo LRU replacement policy for 4 ways set associative caches.
This commit is contained in:
parent
35fcadbe7f
commit
41dbb59e24
@ -84,6 +84,30 @@ module cachereplacementpolicy
|
||||
|
||||
end else if (NUMWAYS == 4) begin : FourWay
|
||||
|
||||
|
||||
// VictimWay is a function only of the current value of the LRU.
|
||||
// binary encoding
|
||||
//assign VictimWay[0] = BlockReplacementBits[2] ? BlockReplacementBits[1] : BlockReplacementBits[0];
|
||||
//assign VictimWay[1] = BlockReplacementBits[2];
|
||||
|
||||
// 1 hot encoding
|
||||
assign VictimWay[0] = ~BlockReplacementBits[2] & ~BlockReplacementBits[0];
|
||||
assign VictimWay[1] = ~BlockReplacementBits[2] & BlockReplacementBits[0];
|
||||
assign VictimWay[2] = BlockReplacementBits[2] & ~BlockReplacementBits[1];
|
||||
assign VictimWay[3] = BlockReplacementBits[2] & BlockReplacementBits[1];
|
||||
|
||||
// New LRU bits which are updated is function only of the WayHit.
|
||||
// However the not updated bits come from the old LRU.
|
||||
assign LRUEn[2] = |WayHit;
|
||||
assign LRUEn[1] = WayHit[3] | WayHit[2];
|
||||
assign LRUEn[0] = WayHit[1] | WayHit[0];
|
||||
|
||||
assign LRUMask[2] = WayHit[1] | WayHit[0];
|
||||
assign LRUMask[1] = WayHit[2];
|
||||
assign LRUMask[0] = WayHit[0];
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
|
||||
// selects
|
||||
assign LRUEn[2] = 1'b1;
|
||||
assign LRUEn[1] = WayHit[3];
|
||||
@ -93,16 +117,19 @@ module cachereplacementpolicy
|
||||
assign LRUMask[0] = WayHit[1];
|
||||
assign LRUMask[1] = WayHit[3];
|
||||
assign LRUMask[2] = WayHit[3] | WayHit[2];
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
for(index = 0; index < NUMWAYS-1; index++)
|
||||
assign NewReplacement[index] = LRUEn[index] ? LRUMask[index] : BlockReplacementBits[index];
|
||||
|
||||
/* -----\/----- EXCLUDED -----\/-----
|
||||
assign EncVicWay[1] = BlockReplacementBits[2];
|
||||
assign EncVicWay[0] = BlockReplacementBits[2] ? BlockReplacementBits[0] : BlockReplacementBits[1];
|
||||
|
||||
onehotdecoder #(2)
|
||||
waydec(.bin(EncVicWay),
|
||||
.decoded({VictimWay[0], VictimWay[1], VictimWay[2], VictimWay[3]}));
|
||||
-----/\----- EXCLUDED -----/\----- */
|
||||
|
||||
end else if (NUMWAYS == 8) begin : EightWay
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user