Skip to content

GATE CS 2012 Q54 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI

A computer has a 256-KByte256\text{-KByte}, 4-way set associative, write back data cache with block size of 32-Bytes32\text{-Bytes}. The processor sends 32-bit32\text{-bit} addresses to the cache controller. Each cache tag directory entry contains, in addition to address tag, 22 valid bits, 11 modified bit and 11 replacement bit.

The number of bits in the tag field of an address is

Choose one option
View worked solution

Answer: C

To find the number of bits in the tag field of the address, we analyze the structure of the physical address for a set-associative cache.

The 3232-bit physical address is divided into three fields:

[ Tag ] [ Set Index ] [ Block Offset ]

Step 1: Calculate the Block Offset

The block size is given as 32 Bytes32\text{ Bytes}.

Block Offset=log⁡2(32)=5 bits\text{Block Offset} = \log_2(32) = 5\text{ bits}

Step 2: Calculate the Set Index

First, find the total number of blocks in the cache:

Total Cache Size=256 KB=218 Bytes\text{Total Cache Size} = 256\text{ KB} = 2^{18}\text{ Bytes}

Number of Blocks=Cache SizeBlock Size=21825=213 blocks\text{Number of Blocks} = \frac{\text{Cache Size}}{\text{Block Size}} = \frac{2^{18}}{2^5} = 2^{13}\text{ blocks}

Since the cache is 44-way set associative (222^2 blocks per set), the number of sets is:

Number of Sets=Number of BlocksAssociativity=21322=211 sets\text{Number of Sets} = \frac{\text{Number of Blocks}}{\text{Associativity}} = \frac{2^{13}}{2^2} = 2^{11}\text{ sets}

Thus, the number of bits required for the set index is:

Set Index Bits=log⁡2(211)=11 bits\text{Set Index Bits} = \log_2(2^{11}) = 11\text{ bits}

Step 3: Calculate the Tag Bits

The total address size is 32 bits32\text{ bits}. Therefore:

Tag Bits=Total Address Bits−Set Index Bits−Block Offset Bits\text{Tag Bits} = \text{Total Address Bits} - \text{Set Index Bits} - \text{Block Offset Bits}

Tag Bits=32−11−5=16 bits\text{Tag Bits} = 32 - 11 - 5 = 16\text{ bits}

Note: The extra bits (valid, modified, and replacement bits) are stored in the cache tag directory entry alongside the tag, but they do not affect the address division.

Hence, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Hierarchy: Cache, Main Memory and Secondary Storage questions