Answers
- Byte addressable
- 8 bytes per word
- 8 GB primary memory
- 2-way set associative cache
- 8 words per cache line
- 2 MB cache capacity
- cache access time is 500 psec
- miss penalty time is 5 nsec
Questions
- Number of blocks of primary memory
total bytes ÷ bytes per block = total blocks
(23 × 230) ÷ (23 × 23) = 233 ÷ 26 = 227 blocks. - Number of cache lines
cache capacity ÷ bytes per line = number of lines
(21 × 220) ÷ (23 × 23) = (221 ÷ 26) = 215 lines. - Number of cache sets
Number of lines ÷ lines per set = number of sets
215 ÷ 21 = 214 = 16,384 sets. - Primary memory address size
log2(number of addressable bytes) = 33 bits
- Size of byte offset field
log2(bytes per word) = 3 bits
- Size of block offset field
log2(words per block|line) = 3 bits
-
Size of index field
log2(number of sets = 14 bits
- Size of tag field
Address width - (index + block offset + byte offset) = 13 bits
- p(hit) if the CPU were to access memory totally randomly
Proportion of main memory that fits in cache = 221 233 = 22−12 = 0.0002441.
- Average access time if the CPU were to access memory totally randomly
p(hit) × 500 psec + p(miss) × (500 psec + 5 nsec) = 0.0002441 × 500 + .9997559 × 5500 = 5.4987794 nsec
This is correct: the hit time has to be added to the miss penalty on a miss. Other semesters, the “miss time” = was used, which would have been given as 5.5 nsec for this example. You will not have to worry about which number to use on the final: both values will be given to avoid confusion. - Average access time if p(hit) is 0.97
0.97 × 500 + 0.03 × 5,500 = 650 psec.