如何从 2 路设置关联缓存计算缓存命中率



在我的作业中,我们有 2 个问题:我们有一个 2 路集关联缓存。缓存总共有四组。主存储器由 4K 块组成,每个块 8 个单词,并使用单词寻址。a)部分要求演示地址格式,我已经解决了单词= 3位设置= 2位和字段= 7位。我遇到的问题在b部分):计算从位置 8 到位置 51 循环 3 次的程序的命中率。换句话说,将其视为一个汇编语言程序,它从位置 8 的操作码运行到位置 51m 的操作码,然后循环回位置 8。它总共进行了三次这样的迭代。

现在据我了解,在我完成的研究之后,有一个标准通常是某种速度或命中率?我想知道如果我不知道失误率、失误惩罚、缓存速度或其他任何东西,如何计算命中率?

我想

我们在同一个班级,哈哈,我今晚的作业问题完全相同。无论如何,我做了一些研究,并在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%.

希望这有帮助,祝你好运!

最新更新