The problem I'm trying to solve is:
A set-associative cache consists of 64 lines, or slots, divided into four-line sets. Main memory contains 4K blocks of 128 words each. Show the format of main memory addresses.
Main memory size= 128 words/block x 4K block = 2^19 byte //assumptions. 1K=2^10, 1 word=1 byte
This means, we need 19 bits for memory addressing.
Further assuming, that this cache is operated in blocks of memory, each block needs (128 byte= 2^7 byte) 7 bits out of 19 bits.
Since we can have 64 line / (4 line/set) = 16 sets = 2^4 sets. we need 4 bits to identify the sets.
This leaves 19-7-4=8 bits.
However, my confusion starts when I try to find out how many bits needed for tag.
Option A: If I assume, each block will occupy in a single line (or slot) of the cache, then we need 2 bits for identifying a line within a set. This leaves 8-2=6 bits for tag.
Option B: However, if we assume, a block will filly occupy a set (i.e. 4 lines) in the cache, then we don't need to spare any bits for identifying lines. This leaves whole 8 bits for tag.
Can anyone help me understand which option is the right way of reasoning. My reasoning goes for option A as the question indicates lines.