in CO and Architecture recategorized by
2,326 views
7 votes
7 votes

A two-way set associative cache memory unit with a capacity of $16\, KB$ is built using a block size of
$8\, words.$ The word length is $32-bits.$ The physical address space is $4\, GB.$
The number of bits in the TAG, SET fields are

  1. $20,7$
  2. $19,8$
  3. $20,8$
  4. $21,9$
in CO and Architecture recategorized by
by
2.3k views

1 Answer

9 votes
9 votes
Best answer

Given, 

Total cache size = 16 KB = $2^{14}$ bytes

word length = 32 bits, i.e. 4 bytes or $2^2$ bytes.

Since, the word length is given, I am assuming memory to be word-addressable, and not byte-addressable.

So, we have $2^{12}$ words cache size.

1 block is 8 words, so block offset = $\log 8 = 3$ bits.

cache size(in terms of blocks) = $2^{12} / 8$ = $2^9$ blocks.

Given the cache is 2-way set associative. So, 

2 blocks - 1 set

$2^9$ blocks - $2^8$ sets. 

so, we need 8 bits to identify the set.

The physical address space is 4GB,i.e. $2^{32}$ bytes, or in terms of words, $2^{30}$ words.

So, the physical address will be of 30 bits.

Out of 30, 3 bits are used for offset, and 8 bits for the set field. 

Therefore, tag bits are 30 - 3 - 8 

= 19 bits.

Option (B) 19, 8

selected by

7 Comments

here block offset = number of words in block * number of Bytes for word

 = 8* 4B = 32 B

hence bits = log 32= 5 bits

set offset = 214 / 32 * 2 =  28 = log 256 = 8bits

Now tag bits = 32 - (8+ 5) = 19 bits

B will be answer

4
4
@Anu sir, that means the memory is byte addressable???
0
0
Physical address is given as 4GB (2^32 bytes). Word length is 4 bytes. Hence, physical address (in words) is 2^30.

Hence,

block offset = 3 bits

set = 8 bits

tag = 30-3-8 = 19

Option B
1
1

Thanks @Sumaiya23 . Corrected

0
0

Can we calculate tag bits using this formula ... ?

No.of Blocks competing per set (B)= No. of Blocks in Main Memory / No. of sets in Cache

No.of Tag bits = log2(B) 

using this I'm getting 18 bits, which is not there in the options ... 

0
0

@David

No.of Blocks competing per set (X)= No. of Blocks in Main Memory / No. of sets in Cache

#Blocks in MM=4GB/32B =232/25=227

#Sets in cache=28

X=227/28=219

No.of Tag bits = log2(X) = log2(219) =19 bits

1
1
Thanks VS ..

Got  it now :)
1
1
Answer:

Related questions