retagged by
313 views

1 Answer

1 votes
1 votes

Let's assume we have a main memory of 16 bytes($2^{4},m=4$)(16 memory locations each of 1 byte)  and a cache of 4(or $2^{k}$,k=2 )bytes(4 locations each 1 byte).Also,assume that block size is 1 byte for the sake of simplicity.

Now, we know lower k bits of the main memory is used to index the block in which the cache should be placed(k=2).Following example will illustrate how it works out:-

Main Memory to Cache mapping

Suppose,contents of Main Memory address(1110) is to be mapped to location "10",as it's lower k(2) bits are "10".Also, contents of Main Memory address(0010,0110,1010,1110) all will be mapped to the same location.Or, in general anything with lower order k bits as "10 in this case" will be mapped to the same cache block.Now,the only way to identify which memory address has been mapped is to know the higher (m-k or 4-2=2 bits of the address of MM).Tag bits store upper (m-k) bits of the main memory address and when it's concatenated with the lower "k" bits we get the actual address which has been mapped.In the above example, "11 is the upper m-k(2) bits"or tag bits and when it is concatenated with lower "10" bits or index bits we get the address.

 

edited by

Related questions

0 votes
0 votes
1 answer
1
Anuranjan asked Mar 17, 2019
243 views
How to improve cache hit rate in case of transfer of element from 2-D array to matrix.? (Consider the column major order in 2D array)
1 votes
1 votes
1 answer
2
Anuranjan asked Mar 13, 2019
262 views
What is meant by cache index? Please state by example.
0 votes
0 votes
0 answers
3
DIYA BASU asked Feb 17, 2019
553 views
Memory is word addressable with 16 bit addressesWord size=16 bitsEach block is of size 16 bits.The cache contains 8 blocks.What is the address division for:1>direct.2>as...
1 votes
1 votes
1 answer
4
DIYA BASU asked Feb 3, 2019
315 views
Main memory=512 words.block size=8 words.cache size =32 wordsThere is an array A[100] and each element is 4 words then what is the hit ratio for the following loop.for...