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:

  • root picks the half to evict from: 0 means ways 0 and 1, 1 means ways 2 and 3.
  • left picks the victim inside ways 0/1, right inside ways 2/3 (0 = the lower way).
  • victim is combinational from the bits.
  • When access is 1, the bits on the path to way are 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.