Computer Organization & Embedded System — Computer Arithmetic and Memory System, NEC licence examination syllabus (Nepal Engineering Council).
Cache size, mapping, replacement, write policy, number of caches — every cache design question is really about one of these five.
Mapping decides where a block of main memory can go inside cache.
DirectEach memory block maps to exactly ONE cache line (line = block number mod number of lines). Simple and fast, but causes more conflict misses if two frequently-used blocks map to the same line.
Fully associativeAny block can go into any cache line. No conflict misses, but needs to compare the address against every line simultaneously — expensive hardware.
Set-associative(k-way) Cache is divided into sets, each holding k lines; a block maps to one specific set but can occupy any of the k lines within it. Practically the most common — balances speed and flexibility.
LRUEvicts the block unused for the longest time. Best performance, but needs extra tracking hardware.
FIFOEvicts the oldest-loaded block, regardless of use.
LFUEvicts the least frequently used block.
RandomJust picks one at random — surprisingly not much worse than LRU in practice, and much cheaper to implement.
Write-throughEvery write updates both cache AND main memory immediately. Simple, always consistent, but slower writes.
Write-backWrites only update cache; main memory is updated later (when the block is evicted). Faster, but needs a "dirty bit" to track which lines have unwritten changes.
Modern CPUs use multilevel caches: L1 (smallest, fastest, per-core), L2 (bigger, a bit slower), L3 (shared across cores, biggest). Many CPUs also use a split cache — separate I-cache (instructions) and D-cache (data) at L1, letting both be fetched simultaneously; a unified cache stores both together.
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Loading…