设置关联缓存:计算标签的大小?

jan*_*son 9 caching

我正在努力解决这个问题,我环顾四周,但所有类似的问题都比我的更先进,利用日志,它比我们在课堂上做的更先进.这是问题:

Suppose you have a 4-way set associative cache which has in total 4096 bytes of cache memory and each cache line is 128 bytes. How many sets are there is this cache? If memory is byte addressable and addresses are 16 bits then how many bytes are used for the tag?

这是我到目前为止所拥有的:

4096/128 = num lines

4096/128/4 = 8 = num sets (each set is 4 lines in 4-way set assoiative)

So, need 3 bits to choose set (2^3=8)

We have 16-3 = 13 bits left for the tag and word.

因为问题是存储器是字节可寻址的,我认为这意味着该字长为8位(= 1字节),因此标签长度为16-3-8 = 5位.

虽然我对此并不十分肯定.有没有人有这个问题的解决方案?

谢谢.

小智 10

如果内存是字节可寻址的

这个陈述只是告诉我们主存储器是字节可寻址的,即,无论数据和地址总线的宽度如何,数据都可以一次8位访问的架构.

这不会影响标签的位数.

解:

4路组关联

总高速缓存= 4096字节

块大小(缓存行)= 128字节

高速缓存行数= 4096/128 = 32行

缓存中的集合数= 32/4 = 8集

??????????????????????????????
?       16 bit address       ?
??????????????????????????????
? tag bit? ? 3 bits ? 7 bits ?
??????????????????????????????
Run Code Online (Sandbox Code Playgroud)

字偏移= log 2 8 = 3位

设置offset = log 2 128 = 7位

回答:

标记位= 16 - (3 + 7)= 6位

????????????????????????????
?      16 bit address      ?
????????????????????????????
? 6 bits ? 3 bits ? 7 bits ?
????????????????????????????
Run Code Online (Sandbox Code Playgroud)