A computer system has a 4-way set associative cache with one-word blocks. The…
A computer system has a 4-way set associative cache with one-word blocks. The total cache capacity is 256 bytes. The sequence of byte addresses accessed by the CPU is:
8, 64, 96, 128, 64, 96, 256, 192, 24
Answer the following:
Determine the number of sets in the cache.
Identify the set number for each memory reference.
Show the step-by-step cache contents after each access.
Calculate the total number of cache hits and misses.
Write the final cache state.
Attempted by 5 students.
Show answer & explanation
Given parameters
Cache size = 256 bytes
Block size = 1 word = 4 bytes
Associativity = 4-wayNumber of blocks in cache
Cache blocks = Cache size / Block size
= 256 / 4
= 64 blocks
Number of sets
Sets = Blocks / Associativity
= 64 / 4
= 16 sets
Mapping rule
Set number = Block number mod Number of sets
Address breakdown diagram
Main Memory Address
| Block Number | Word Offset |Access sequence analysis
Address Block Set Result
8 2 2 Miss
64 16 0 Miss
96 24 8 Miss
128 32 0 Miss
64 16 0 Hit
96 24 8 Hit
256 64 0 Miss
192 48 0 Miss
24 6 6 MissFinal cache state (only filled sets)
Set 0 : m[64], m[128], m[256], m[192]
Set 2 : m[8]
Set 6 : m[24]
Set 8 : m[96]Cache behavior explanation
The cache allows four blocks per set, which reduces conflict misses compared to direct mapping.Results
Total hits = 2
Total misses = 7
Conclusion
Set associative mapping improves cache utilization because multiple blocks mapping to the same set can coexist, reducing replacement conflicts and improving performance.