Master the fundamental concepts of memory hierarchy through this focused micro-challenge.
A direct-mapped cache splits physical addresses into tag, index, and offset. Each index maps to exactly one cache line; conflicts evict even if other lines sit idle.
cLoading…
On access:
index with computed tagFor example, with 64-byte lines and 256 lines, index is 8 bits and two addresses that agree on those bits contend for the same slot.
For this exercise, you will simulate loads and stores, counting hits and misses. This task asks you to implement tag compare and line fill, the same mechanics perf indirectly observes when LLC miss rate spikes.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Implement direct-mapped cache simulator.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github