RTL Design #28 · 2026-10-21 · LRU tracking · Medium · about 15 min
A pseudo-LRU tree that forgets the other half
plru4 tracks which way of a 4-way cache set to evict, using tree pseudo-LRU. Three bits, reset to 0:
rootpicks the half to evict from: 0 means ways 0 and 1, 1 means ways 2 and 3.leftpicks the victim inside ways 0/1,rightinside ways 2/3 (0 = the lower way).victimis combinational from the bits.- When
accessis 1, the bits on the path towayare updated to point away from it. Bits that aren't on that path don't change.
Run touches ways 0, 2, 1, 3 in turn, and the victim goes wrong straight away. Fix plru.sv.
Write and run your answer in the browser. The hidden tests check it, and it’s free.