As we know that this is a Direct mapping cache
given : offset bits = w
No of cache lines = m
direct mapping | TAG FIELD | LINE NUMBER | LINE OFFSET|
TAG FIELD + LINE NUMBER = BLOCK NUMBER
now as we know that it's a Direct Mapped cache ,
Xth block of Main Memory is present in the =( X mod 2^m) cache block in the cache memory.
here it's given that . Main memory blocks are referenced by the CPU in a sequential order
Now let's take an example
No of lines in a cache = 4
No of blocks in the memory = 16
as Main memory block are referred by CPU in sequential order ,
=== > MM block 0 is refer
where it's present in the cache = 2S – m = 16 - 4 mod 4 = 0
====> MM block 1 is refer
where it's present in the cache = 2S – m+1 = 16 - (4+1) mod 4 = 1
====> MM block 2 is refer
where it's present in the cache = 2S – m+2 = 16 - (4+2) mod 4 = 2
..........
MM block 15 is refer
where it's present in the cache = 2S – 1 = 16 -1 mod 4 = 3
Option C and A is not correct because if
No of lines in cache = 4
then it should be Mapped as as ( 0 , 1 ,2, 3)
but if you use the formula A and C you can't insert any block into the cache line 0 and it's clearly given in the question that
sequence of the blocks are mapped on the cache lines in sequential order from the initial line
And Option D doesn't mapped on the cache lines in sequential order that's its also wrong
Hope you understand the concept khushtak smartmeet Shubhanshu