+12 votes
2.7k views

Consider a direct mapped cache of size $32$ $KB$ with block size $32$ $bytes$. The $CPU$ generates $32$ $bit$ addresses. The number of bits needed for cache indexing and the number of tag bits are respectively,

1. $10, 17$
2. $10, 22$
3. $15, 17$
4. $5, 17$
asked
edited | 2.7k views

2 Answers

+20 votes
Best answer

Number of blocks $= \dfrac{\text{cache size}}{\text{block size}}= \dfrac{32\text{-KB}}{32}=\text{1024-Bytes.}$

So, indexing requires $\text{10-bits}.$ Number of OFFSET bits required to access $\text{32-bit block} = 5.$
So, number of TAG bits $= 32 - 10 - 5 = 17.$

So, answer is (A).

answered by Veteran (367k points)
edited
0
sir if question ask like that " how many bits required to index the words present in cache" than ans would be c option.??
0
@kunal ;

..
+8
Indexing is for arrays. Cache is an array of cache lines/blocks. So, we won't say "index  a word" in cache.
+1
@Arjun sir, This is virtually addressed cache?
(as cpu generates virtual address)
0
but the cache index is equal to line offset plus word offset???
0
I have the same doubt as Sachin's. We usually do these calculations on physical address.
0 votes

In Direct mapped cache:

Address format= Tag + cache index + Offset

Offset  = log(block size)  = log(32B) = log(2^5) =5 bits

index = log(cache size / block size) = log(32KB)/log(32B) = 10 bits

Finally Tag = Total bits - index - offset = 32 - 10 - 5 = 17 bits

NOTE: Base of log is 2

answered by (75 points)
Answer:

+11 votes
1 answer
1
+12 votes
2 answers
2
+32 votes
5 answers
3
+14 votes
2 answers
4
+18 votes
3 answers
5
+16 votes
2 answers
6
+15 votes
2 answers
7