memory - 缓存设计中如何知道 "section/offset" block 的大小?

标签 memory cpu-architecture cpu-cache

我无法理解如何确定标签/索引/偏移位,因为问题的措辞让我感到困惑。澄清一下,架构中的一个字是 64 位。 这是第一个问题:

Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 64-bit memory address references, given as word addresses. 0x03, 0xb4, 0x2b, 0x02, 0xbf, 0x58, 0xbe, 0x0e, 0xb5, 0x2c, 0xba, 0xfd

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

该解表明偏移量由 1 位组成,因为需要 1 位来表示 2 个不同的 block “字”。所以我试图将 block 可视化为分成两个部分(偏移)。我怎么知道你应该将 block 分割成单词(为什么不是字节)?显然, block 中的部分决定了表示 block 部分所需的偏移位数。但是 2 个字就是 16 个字节,那么为什么不将 block 分成 16 个部分来表示字节,而不是分成 2 个部分来表示字呢?如果 block 被分成 16 个部分(对于 2 个字的所有字节),是否不需要 4 个偏移位来确定 block 中的 16 个不同字节部分?我很难知道如何计算出 block 部分应该有多大。 “两个单词 block ”的问题是否意味着我应该将这些 block 想象成单词? 2 字 block 与 16 字节 block 相同吗? (一个字为8个字节)

下面的问题提到了字节寻址,这让我感到困惑。它有什么关系?:

By convention, a cache is named according to the amount of data it contains (i.e., a 4 KiB cache can hold 4 KiB of data); however, caches also require SRAM to store metadata such as tags and valid bits. For this exercise, you will examine how a cache’s configuration affects the total amount of SRAM needed to implement it as well as the performance of the cache. For all parts, assume that the caches are byte addressable, and that addresses and words are 64 bits.

Calculate the total number of bits required to implement a 32 KiB cache with two- word blocks.

这两个问题均来自 David Patterson 和 John L Hennessy 的计算机组织与设计

最佳答案

How do I know that you are supposed to split the blocks into words (why not bytes)?

因为你有字地址,而不是字节地址。也就是说,您的内存可以使用这种形式的地址进行字寻址。

要从字地址获取字节地址,您需要附加 3 个零。

Is a 2-word block the same as a 16-byte block?

是的,缓存行大小为 16 字节。

关于memory - 缓存设计中如何知道 "section/offset" block 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40830583/

相关文章:

performance - 即使 RS 未完全充满,RESOURCE_STALLS.RS 事件是否也可能发生?

c++ - 按位非运算哪个更快 : precalculated table or `~`

c++ - 如果对象大小 > 缓存行,空间局部性对缓存性能有影响吗?

c++ - 如何在运行时获取对象的总大小?

caching - 如何查找缓存模拟器中的冲突未命中数

delphi - TBitmap 到 TPngImage 和内存使用情况

caching - 为什么现代处理器中的集合缓存关联性是 8 路集合关联性?

ios - 当我在 Swift 中使用 PHAsset 时,我总是收到内存警告

assembly - 如何动态地将分支目标提示到 x64 CPU?

caching - 英特尔酷睿 i7 的缓存规范