在我的任务中,我们有两个问题:我们有一个2路组关联缓存。缓存总共有四个集合。主存储器由4K块组成,每块8个字,并使用字寻址。 部分a)要求演示地址格式,我已经解决了word = 3 bit set = 2 bit和field = 7 bit。我遇到的问题是部分b): 计算从位置8到位置51循环3次的程序的命中率。换句话说,将其视为汇编语言程序,从位置8处的操作码运行到位置51m处的操作码然后循环回位置8它总共进行了三次这样的迭代。
现在根据我的理解,我已经完成了一个标准,通常会给出某种速度或命中率?我想知道我如何计算命中率,如果我不知道未命中率,未命中罚款缓存速度或任何东西?
答案 0 :(得分:0)
我认为我们在同一个班级大声笑我在今晚到期时有完全相同的问题。无论如何,我做了一些研究,并在chegg上找到了类似问题的答案:
a. Given that memory contains 2K blocks of eight words.
2K can be distributed as 2K * 23 = 211* 23 = 214 so we have 14-bit addresses with 9 bits
in the tag field, 2 bits in the set field and 3 in the word field
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 then hits.
→ 40 is a miss, entire block brought into Set 1 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%.
希望这有帮助,祝你好运!