Only Part B but with as much detail as possible because I do
Only Part B, but with as much detail as possible because I do not understand part B.
A 2-way set associative cache consists of four sets. Main memory contains 2K blocks of eight words each. Show the main memory address format that allows us to map addresses from main memory to cache. Be sure to include the fields as well as their sizes. Compute the hit ratio for a program that loops 3 times from locations 8 to 51 in main memory. You may leave the hit ratio in terms of a fraction.Solution
Answer for part b-
First iteration of the loop:
Address 8 is a miss, then entire block brought into set 1. 9-15 are then hits. 16 is a miss, entire block brought into set 2, 17-23 are hits. 24 is a miss, entire block brought into set 3, 25-31 are hits. 32 is a miss, entire block brought into set 0, 33-39 are hits. 40 is a miss, entire block brought into set 1. (we do not have to throw out the block with address 8 as this is 2-way set associative) 41-47 are hits. 48 is a miss, entire block brought into set 2, 49-51 are hits. For the first iteration of the loop we have 6 misses and 5*7+3 hits or 38 hits. On the remaining iterations we have 5*8+4 hits or 44 hits each, for 88 more hits. Therefore we have 6 misses and 126 hits for a hit ratio of 126/132 or 95.45%
