1

I've read several topics about this theme but I could not get the answer. So my question is:

1) How is the block offset calculated?

I want to know not the formula but the concept of it. As I know it is quantity of cases which a block can store the address. For example If there is a block with 8 byte storage and has to store 2 byte addresses. Does its block offset is 2 bit?(So there is 4 cases to store the address (the diagram below might make easier to see what I am saying).

enter image description here

Gabriel Southern
  • 9,602
  • 12
  • 56
  • 95
Ojs
  • 924
  • 1
  • 12
  • 26

1 Answers1

0

The block offset is simply calculated as log2 cache_line_size.

The reason is that all system that I know of are byte addressable. So you need enough bits to index any byte in the block. Although most systems have a word size that is larger than a single byte, they still support offsets of a single byte gradulatrity, even if that is not the common case.

So for the example you mentioned of an 8-byte block size with 2-byte word, you would still need 3 bits in order to allow accessing any byte. If you had a system that was not byte addressable then you could use just 2 bits for the block offset. But in practice all systems that I know of are byte addressable.

Gabriel Southern
  • 9,602
  • 12
  • 56
  • 95