○Tag和数据阵列串行访问的流水线模式 Address calcul ati on, Disambiguation ⊥ a9 acces Data access Result drive D Address Tag calculati on Array FIGURE 2.4: Serial tag and data array access pipeline 2021/2/11 计算机体系结构 27
Tag 和数据阵列串行访问的流水线模式 2021/2/11 计算机体系结构 27
直接映像 Cache查找过程 Data-in byte offset word select Alic gner write Tag O Data block o Tag 1 Data block 1 oxoom Tag 2-1 Block 2K-1 enable Aligner byte offset Data-out Enable write access to Hit Aligner shifts data within data block if cache hit word according to byte offset 2021/2/11 计算机体系结构 28
直接映像Cache查找过程 2021/2/11 计算机体系结构 28
全相联 Cache查找过程 Data-in byte offset b Ali laner write word select Data block o enable Tag 1 Data Block 1 enable Tag m-1 Data Block(m-1) enable byte offset / Aligner m-way associative Hit Data-out 2021/2/11 计算机体系结构 29
全相联Cache查找过程 2021/2/11 计算机体系结构 29
Example: 1 KB Direct Mapped Cache with 32 B Blocks 对于容量为2N字节的 cache: 最高32N位部分为 Cache Tag 最低M位为字节选择位( Block size=2M) Block address 31 4 Cache Index Byte Select Ex: OxO Ex: 0x00 Stored as part of the cache“ state” Valid bit cache tag Cache data Byte 31 Byte 1 Bytd00 0x50 Byte Byte 33 Byte 321 Bte102∴Bt21n 2021/2/11 计算机体系结构
Example: 1 KB Direct Mapped Cache with 32 B Blocks • 对于容量为 2 N 字节的cache: – 最高(32-N)位部分为 Cache Tag – 最低M位为字节选择位(Block Size = 2 M) 2021/2/11 计算机体系结构 30 Cache Index 0 1 2 3 : Cache Data Byte 0 31 4 0 : Cache Tag Example: 0x50 Ex: 0x01 0x50 Stored as part of the cache “state” Valid Bit : 31 Byte 31 Byte 1 : Byte 63 Byte 33 Byte 32 : Byte 1023 Byte 992 : Cache Tag Byte Select Ex: 0x00 9 Block address
Example: Set Associative Cache N- way set associative:每一个 cache索引对应N个 cache entries 这N个 cache项并行操作 Example: Two-way set associative cache Cache index选择 cache中的一组 这一组中的两块对应的Tags与输入的地址同时比较 根据比较结果选择数据 Cache Index Valid Cache tag Cache data Cache data Cache ta g Valid Cache block Cache block o Adr Ta Compare- Sell Mux 0 selo CI ompare OR Cache block 2021/2/11 计算机体系结构
Example: Set Associative Cache • N-way set associative: 每一个cache索引对应N个cache entries – 这N个cache项并行操作 • Example: Two-way set associative cache – Cache index 选择cache中的一组 – 这一组中的两块对应的Tags与输入的地址同时比较 – 根据比较结果选择数据 2021/2/11 计算机体系结构 31 Cache Data Cache Block 1 Valid Cache Tag : : : Cache Data Cache Block 0 Cache Tag Valid : : : Cache Index Mux 1 0 Sel1 Sel0 Cache Block Compare Adr Tag Compare OR Hit