[英]Why don't we need to subtract byte offset bits in this problem?
In the following question: How to find tag bit in cache given word address在以下问题中: How to find tag bit in cache given word address
They have found the number of tag bits by 32 - number of index bits - word offset
.他们通过32 - number of index bits - word offset
。 But in the book, they also mentioned the following:但在书中,他们还提到了以下内容:
enter image description here在此处输入图像描述
Why are we not subtracting 2 here in the problem?为什么我们不在问题中减去 2?
For anyone who is getting confused like me, it is as follows as far as I know.对于任何像我一样感到困惑的人,据我所知如下。
Given word address 3
, we can convert it to by address which is one of address between 12
and 15
inclusive because word is 4 bytes and thus you have to multiply word address by 4.给定字地址3
,我们可以将其转换为 by 地址,该地址是12
到15
之间的地址之一,因为字是 4 个字节,因此您必须将字地址乘以 4。
If you convert 12
and 15
to binary it will be ...001100
and ...001111
and you have to get least 2
significant bits for byte offset and the next 1
bit for word( block) offset which leaves 001
in both cases.如果将12
和15
转换为二进制,它将是...001100
001100 和...001111
并且您必须为字节偏移获得至少2
有效位,并为字(块)偏移获得下一个1
位,这在两种情况下都为001
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.