0) 首先讨论一下 cache line 索引定位的方式。
给定一个 32 位虚拟地址,怎么定位 cache line 呢?
答案是 VIPT (virtual indexed, physical taged), 即以虚拟地址作为 cache line 的 set 的索引,物理地址作为 tag 进行比较。
比如 : 32k cache 8 way 组相联, cache line 大小是 64 bytes。所以共有 64 个 set(32k/(8 * 64))。
物理地址 31 12 5 0 |<----- 20 bits ---->|<- 12 bits ->| |<--- page frame --->| page offset | [ TAG |index |offset] TAG : RAT (real address tag) index : set