retagged by
16,525 views
3 votes
3 votes
How many total bits are required for a direct mapped cache with 16 KB of data and 4-word blocks , assuming a 32-bit address ?
retagged by

1 Answer

Best answer
6 votes
6 votes

We know for direct mapping , CPU generated address is divided into :

a) Tag  field        b)  Line field         c) Word offset 

Given , data memory size of cache             =               16 KB

Assuming the memory to be byte addressable (i.e. 1 word size  = 1 B) ,

No of cache lines              =     Data memory size of cache /  Data size of 1 cache line

                                       =     16 KB / 4 B

                                       =     212 lines

So no of bits needed to represent cache line    =    log2 (212)

                                                                    =    12 bits

No of bits needed to represent a word in a line   =   log24

                                                                      =   2 bits

So no of bits needed for tag                            =    32 - 12 - 2

                                                                     =    18 bits

Now for a given line , we will have the same tag ..

So 1 tag is associated with one line in case of direct mapping and associative mapping and with one set in case of set associative mapping..

So size of tag memory                                   =  No of tag bits * No of lines

                                                                    =  18 * 212 bits

                                                                    =   72 K bits

And size of data memory as mentioned earlier   =  16 KB

                                                                     =   128 K bits

So total memory needed for cache                   =   128 K bits + 72 K bits

                                                                     =   200 K bits

selected by

Related questions

2 votes
2 votes
2 answers
3
rahuldb asked Nov 10, 2016
3,568 views
How many memory refernces are required for fetching and executing each of the following instructions?(a)ADD 50(R­1),R2 b)SUB (R­1)+R­2­
0 votes
0 votes
2 answers
4
Sumiran Agrawal asked May 16, 2019
3,561 views
Is there any multiplexer(s) present in the implementation of Direct Mapped Cache?If yes, then the Hit latency would be Multiplexer latency + Comparator Latency?