Question

The size of the physical address space of a processor is 2P2^P bytes. The word length is 2W2^W bytes. The capacity of cache memory is 2N2^N bytes. The size of each cache block is 2M2^M words. For a KK-way set-associative cache memory, the length (in number of bits) of the tag field is

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2018 answer key

Solution

Partition the physical address into tag, set index, and block offset fields.

Determine the widths of each field:

  1. Total physical address bits: Physical address space is 2P2^P bytes, so physical address length is PP bits.
  2. Block size: Each block holds 2M2^M words. With word length 2W2^W bytes, block size is 2M×2W=2M+W2^M \times 2^W = 2^{M+W} bytes. Thus, the block offset field requires M+WM + W bits.
  3. Cache capacity and sets: Total cache capacity is 2N2^N bytes. The total number of cache lines is 2N2M+W=2N−M−W\frac{2^N}{2^{M+W}} = 2^{N - M - W}. For a KK-way set-associative cache, the number of sets is:
Sets=2N−M−WK=2N−M−W2log⁡2K=2N−M−W−log⁡2K\text{Sets} = \frac{2^{N - M - W}}{K} = \frac{2^{N - M - W}}{2^{\log_2 K}} = 2^{N - M - W - \log_2 K}

Thus, the set index field requires N−M−W−log⁡2KN - M - W - \log_2 K bits.

The tag field length is:

Tag=P−(Set index bits)−(Block offset bits)\text{Tag} = P - (\text{Set index bits}) - (\text{Block offset bits})
Tag=P−(N−M−W−log⁡2K)−(M+W)\text{Tag} = P - (N - M - W - \log_2 K) - (M + W)
Tag=P−N+M+W+log⁡2K−M−W=P−N+log⁡2K\text{Tag} = P - N + M + W + \log_2 K - M - W = P - N + \log_2 K
Final answer

B

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2018 Computer Science and Information Technology (CS)
Question
44 of 65, printed as CS Q.34
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.