Memory Organisation and Cache Design Flashcards
What are the components of a memory block in cache
Block Address (higher-order bits), Block Offset (lower-order bits), Index Field, Tag Field.
What does the index field do in a cache
Selects the set (or entry) in the cache. A cache with 2^n sets requires an n-bit index
What does the tag field do in a cache
It is compared for a cache hit. if the tag matches, the entry contains the correct data
What are the three types of cache mapping
Direct mapped, fully associative, set-associative
What is direct mapped cache
Each memory location maps to exactly one location in the cache.
What is fully Associative Cache
Each memory location can be placed anywhere in the cache.
What is set-associative cache
Each memory location is mapped to a specific set in the cache, then placed anywhere within that set.
How is a block placed in direct mapped cache
block address mod number of blocks in cache
How is a block placed in set-associative cache
block address mod number of sets in cache
What is the formula for cache organisation
m=s×n, where:
m = total blocks in cache
s = number of sets in cache
n = blocks per set
What are the conditions for fully associative and direct mapped caches
Fully associative: n = m, s = 1
Direct Mapped: n = 1, s = m
How is a block identified in cache
Using the Block Address, Block Offset, Index Field, and Tag Field
What happens if cache associativity increases while keeping total size the same?
Number of Blocks per Set: Increases.
Index Size: Decreases.
Tag Size: Increases.
What are the three block replacement strategies?
Random Replacement, Least Recently Used (LRU), First In, First Out (FIFO).
How does Random Replacement work?
A block is randomly selected for replacement.
How does Least Recently Used (LRU) work?
The block that hasn’t been used for the longest time is replaced.
How does First In, First Out (FIFO) work?
The oldest block in the set is replaced.
What are the two main cache write strategies?
Write-Through and Write-Back.
What is Write-Through?
Data is written only to the cache and updated in lower memory only when replaced.
What are the advantages of Write-Back?
Saves power, reduces memory usage, and is efficient for multiprocessors.