Consider a machine with byte addressable main memory of 2^16 btes assume that a direct mapped data cache consisting of 32 lines of 64 bytes each is used in the system a 50x50 byte 2d array of bytes is stored in the main memory starting from laocation 1100h. Assume that the data cache is initially empty. The complete arrat is accessed twice, assume that the content of the data cache donot change in the two access. What will be the total no. Of hit reference occur during the above
Answers
Answer:
Bits used to represent the address = log2216=16
Each cache line size =64 bytes; means offset requires 6-bits
Total number of lines in cache =32; means line # requires 5-bits
So, tag bits =16−6−5=5
We have a 2D-array each of its element is of size =1 Byte;
Total size of this array =50×50×1 Byte=2500 Bytes
So, total number of lines it will require to get contain in cache
=2500B64B=39.0625≈40
Starting address of array =1100H=00010 00100 000000
The group of bits in middle represents Cache Line number ⟹ array starts from cache line number 4,
We require 40 cache lines to hold all array elements, but we have only 32 cache lines
Lets group/partition our 2500 array elements in those 40 array lines, we call this first array line as A0 which will have 64 of its elements.
This line(group of 64 elements) of array will be mapped to cache line number 4 as found by analysis of starting address of array above.
This all means that among those 40 array lines some array lines will be mapped to same cache line, coz there are just 32 cache lines but 40 of array lines.
This is how mapping is:
0123456789101112⋮3031A28A29A30A31A0A1A2A3A4A5A6A7A8A26A27A32A33A34A35A36A37A38A39
So, if we access complete array twice we get =32+8+8+8=56 miss because only 8 lines from cache line number 4 to 11 are miss operation, rest are Hits(not counted) or Compulsory misses(first 32).