1
$\begingroup$

I know that the offset is based off of the line size for a cache. I have seen the example: "32-btye line size would use the last 5-bits (i.e. $2^5$) off the address as the offset into the line" but I do not understand the process used to determine this.

$\endgroup$
1
  • 1
    $\begingroup$ 1) write the address in binary. 2) take the last five bits. $\endgroup$
    – user16034
    Commented Feb 23, 2023 at 14:51

2 Answers 2

0
$\begingroup$

If you need to address a space consisting of $2^N$ values, then you need $N$ address bits.

In your example, $2^N = 32$ and $N = 5$.

$\endgroup$
0
$\begingroup$

The 32 addresses mapped to the cache line could be for instance

0b00100000010111100101100111000000
0b00100000010111100101100111000001
0b00100000010111100101100111000010
0b00100000010111100101100111000011
0b00100000010111100101100111000100
...
0b00100000010111100101100111011101
0b00100000010111100101100111011110
0b00100000010111100101100111011111

Only the last five bits differ, from all zeroes to all ones.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.