user7649927
user7649927

Reputation:

Offset in cache Mips

I know that offset is : block size=2^n (offset=n). But i have seen that when block size = 8 bytes we do : 8=2^n so offset=n=3 bits, which is correct, but when block size = 1 word, i have seen 1=2^n (offset=n=0). Dont we need to convert word to bytes if we know that cache has 32-bit memory address? (So we have 32bit=4bytes, 4=2^n offset is 2 in that case).

Upvotes: 0

Views: 1199

Answers (1)

Adam
Adam

Reputation: 846

Your did right, It's intuitive that one should know that a word is 4 byte in 32 bit processor and 8 byte in 64 bit.

The byte offset can also can be find in this way, Assume you have address size 32 bits then byte_offset = 32-tag_bits-set_bits.

In order to solve problem of this kind it's good to know some useful parameter and equation.

Parameter to know

C = cache capacity
b = block size
B = number of blocks
N = degree of associativity
S = number of set
tag_bits
set_bits (also called index)
byte_offset
v = valid bits

Equations to know

B = C/b
S = B/N
b = 2^(byte_offset)
S = 2^(set_bits)

Memory Address

|___tag________|____set___|___byte offset_|

Upvotes: 1

Related Questions