Skip to content
Official PYQ · 2021

GATE CS 2021 Set 2 Q19 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI
Consider a set-associative cache of size 2KB (1KB=210\text{2KB (1KB} =2^{10} bytes)\text{)} with cache block size of 6464 bytes. Assume that the cache is byte-addressable and a 3232 -bit address is used for accessing the cache. If the width of the tag field is 2222 bits, the associativity of the cache is _________
View worked solution

Answer: 2 : 2

In a set-associative cache, a 3232-bit physical address is divided into three fields:

[ Tag | Set Index | Block Offset ]

Let's calculate the size of each field based on the given parameters:

  1. Block Offset:

    The cache is byte-addressable and the block size is 6464 bytes (262^6 bytes).

    Block Offset bits=log⁡2(64)=6 bits\text{Block Offset bits} = \log_2(64) = 6\text{ bits}
  2. Tag Field:

    The width of the tag field is given as 2222 bits.

  3. Set Index:

    Since the total address length is 3232 bits:

    Set Index bits=32−(Tag bits+Block Offset bits)\text{Set Index bits} = 32 - (\text{Tag bits} + \text{Block Offset bits}) Set Index bits=32−(22+6)=4 bits\text{Set Index bits} = 32 - (22 + 6) = 4\text{ bits}

    Therefore, the number of sets in the cache is:

    Number of Sets=24=16\text{Number of Sets} = 2^4 = 16

Now, we calculate the total number of blocks in the cache:

Total Cache Size=2 KB=2048 bytes\text{Total Cache Size} = 2\text{ KB} = 2048\text{ bytes} Number of Blocks=Cache SizeBlock Size=204864=32 blocks\text{Number of Blocks} = \frac{\text{Cache Size}}{\text{Block Size}} = \frac{2048}{64} = 32\text{ blocks}

For a PP-way set-associative cache, the number of blocks per set is PP (associativity):

Associativity (P)=Total BlocksNumber of Sets=3216=2\text{Associativity } (P) = \frac{\text{Total Blocks}}{\text{Number of Sets}} = \frac{32}{16} = 2

Thus, the associativity of the cache is 2 (i.e., it is a 2-way set-associative cache).

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