Home › Practice › RTL Design › Which way to evict?

Which way to evict?

EasyRTLsequentialarchitecture

A cache set has four slots (ways) for memory blocks. When all four are full and a new block arrives, one old block must be thrown out. Which one?

Concept first. The best victim is the least recently used way (LRU), but tracking the exact order of four ways needs extra state and a lot of update logic. Tree pseudo-LRU is a cheap approximation that uses only 3 bits arranged as a small binary tree. The root bit says which half to evict from (ways 0-1 or ways 2-3). One leaf bit per half says which of the two ways inside that half. Every time a way is used, the bits along its path are set to point away from it, so recently used ways are protected. Draw the tree, use way 1, then way 2, and follow the arrows to see who becomes the victim.

What to build.

Solve in your browser →

No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.

More in this track

← 2-bit branch predictorPipeline register: stall and flush →