direct mapped cache
Summary
Bit allocation
- cache index - which cache block the block would get mapped to
- tag - used to match for the specific memory address when checking the cache
Cache structure
- valid bit - indicate whether the block contains valid data
when talking about the size of the cache, only the space for data is counted, the valid bit and tags are ignored
Concept
Direct mapped cache
- each block is mapped to a corresponding block in cache
- hash table that can store a subset of memory
- has compulsory and conflict misses
cache_idx = block_num % num_cache_blocks
Compulsory/cold miss
- when the block is first accessed, it must be brought into a cache
- a miss that will happen regardless
Conflict miss
- when something else is currently occupying the cache block that the target was previously cached to
- collision
if something else is occupying the cache block, but this is the first time accessing the address, its still a cold miss
Write miss
- when the target to be written to is not in the cache
- write allocate
- load block from memory into cache
- change the word in cache
- write to memory following write policy
- write around
- write directly to memory without loading to cache
Application
Memory accesses
- 8 byte blocks -> 3 bit offset
- 4GB memory -> 2³² bytes -> 32-bit memory addresses
- 32B cache -> 2⁵ bytes -> 4 blocks -> 2 bit cache index