Question:medium

Consider a set-associative cache of size 2KB with cache block size of 64 bytes. If the width of the tag field is 22 bits, the associativity of the cache is \(\underline{\hspace{2cm}}\).

Show Hint

Associativity equals total blocks divided by the number of sets.
Updated On: Feb 2, 2026
Show Solution

Correct Answer: 2

Solution and Explanation

To determine the associativity of a set-associative cache, we need to find the number of sets and the number of cache lines per set. The cache size is 2KB, which is equivalent to 2048 bytes.

Step 1: Calculate the number of cache blocks.
Each cache block is 64 bytes. Therefore, the total number of cache blocks is:

\[\text{Number of blocks} = \frac{\text{Cache Size}}{\text{Block Size}} = \frac{2048 \text{ bytes}}{64 \text{ bytes/block}} = 32 \text{ blocks}\]

Step 2: Determine the number of sets.
The number of sets can be calculated if we know the associativity (which is our target). Since the tag field is 22 bits and assuming a typical address:

The address is divided into three parts: tag, index, and block offset.
The block offset size is determined by the block size:

The block offset has: \(\log_2(64) = 6\) bits.

Step 3: Calculate index size.
Considering an address size of, for instance, 32 bits (since it is typical):

\[ \text{Index size} = 32 \text{ bits} - 22 \text{ bits (tag)} - 6 \text{ bits (block offset)} \]

\[\text{Index size} = 4 \text{ bits}\]

The number of index entries, or the number of sets, is:

\[\text{Number of sets} = 2^{\text{Index size}} = 2^4 = 16 \text{ sets}\]

Step 4: Calculate the cache associativity.
We use the relationship:

\[\text{Associativity} = \frac{\text{Number of blocks}}{\text{Number of sets}} = \frac{32}{16} = 2\]

The associativity of the cache is 2-way set-associative.

The calculated value (2) falls within the given range of 2,2, confirming the solution is correct.

Was this answer helpful?
0

Top Questions on Memory hierarchy