如何在给定字地址的高速缓存中查找标记位

How to find tag bit in cache given word address

Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address references, given as word addresses.

3, 180, 43, 2, 191, 88, 190, 14, 181, 44, 186, 253

For each of these references, identify the binary address, the tag, and the index given a direct-mapped cache with two-word blocks and a total size of 8 blocks. Also list if each reference is a hit or a miss, assuming the cache is initially empty.

答案是:

我理解是从32位的内存地址值中找到tag、index、offset值,在缓存中使用table,但是我不太理解,内存地址以单词形式给出。例如,单词地址 3 实际上是指 0000 0000 0000 0000 0000 0000 0000 0011 吗?给定一个字地址,怎么能认为是下图中的32位地址呢?

对于字地址3(0000 0000 0000 0000 0000 0000 0000 0011),偏移量为1,索引为001,标签为0000 0000 0000 0000 0000 0000 0000。

  • 块中的 2 个字 = 1 位 偏移量 (2^1).
  • 高速缓存中的 8 个块 = 3 位索引 (2^3)。
  • 32 - 4 = 28 位标签。