Victim Cache Design
A team project that added a victim cache to a RISC-V system in Chipyard. I worked on the C workloads and the cache performance measurements meant to evaluate it.
The idea
ECE 462 ends with a research-style group project, and my team of six picked one that sounds small on paper: add a victim cache to a RISC-V system built with Chipyard, the open-source framework for generating systems-on-chip.
At a glance
- Course
- ECE 462, Fall 2025
- Team
- Six students
- Built on
- A RISC-V system in Chipyard
- Outcome
- Still being debugged at semester's end; never measured
A direct-mapped cache gives every block exactly one line it can live in. Two blocks that map to the same line keep evicting each other, even while the rest of the cache sits empty. A victim cache is a small, fully associative buffer that catches whatever was just thrown out, so when the program asks for it again it comes back from the buffer instead of from L2.
The design
A teammate led the hardware: a Chisel module on the TileLink bus between L1 and L2 that intercepts requests on their way down. Its size is a parameter. Each entry holds a valid bit, a tag, the data and a dirty bit, and an incoming tag is compared against every valid entry at once. A pointer register picks the next entry to replace, and a two-state machine (idle, or waiting on a response) handles storing, forwarding and inserting.
The module itself is short. Fitting it into a real SoC's bus protocol was the hard part, and it was still being debugged when the semester ended, so we never measured the finished cache.
My part: workloads and measurement
I worked on the other half of the project: proving whether the cache helped. I wrote pseudocode testbenches for a range of workloads, reviewed them with the team, and converted them to C with two teammates.
Getting numbers out turned out to be its own project. Our first runs reported all zeros. With a TA's help we got cycle counts and L1 metrics working, and the L2 metrics a week after that. A native Chipyard install also failed on my machine, so I ran everything in Docker. At the end I set up the team's report on Overleaf and helped finish it.
What I took from it
Build the measurement before the thing you want to measure. We treated performance counters as a final step and lost weeks to them; if they had worked in week one, every hardware change could have been checked as it landed.
The other lesson is about where the difficulty in hardware projects lives. The victim cache's logic fits on one slide. Integrating it with an existing bus, its handshakes and the caches on either side is where the time went, and that is worth planning for from the start.
If I picked it back up, I would get the module passing a single conflict-heavy workload first, then sweep its size against our C workloads to find the point where extra entries stop paying for themselves.
Want the details behind this one, or to talk about similar work?
