An 8-way set associative cache of size 64 KB (1 KB = 1024 bytes) is used in a system with 32-bit address. The address is sub-divided into TAG, INDEX, and BLOCK OFFSET.
The number of bits in the TAG is ______.
An 8-way set associative cache of size 64 KB (1 KB = 1024 bytes) is used in a system with 32-bit address. The address is sub-divided into TAG, INDEX, and BLOCK OFFSET.
The number of bits in the TAG is ______.
ANSWER
TAG = 19 bits
Official answer: 19Source: Official answer key, GATE 2023 CS (IIT Kanpur)
Cache capacity = 64 KB = 65536 bytes; it is 8-way set associative; the address is 32 bits wide, split into TAG, INDEX and BLOCK OFFSET.
Let the (unstated) block size be bytes. Number of blocks in the cache . Since the cache is 8-way set associative, number of sets .
, and .
Adding them: — the block size cancels out, so this total is the same for every possible block size, which is exactly why the question can be answered without ever specifying it.
bits.
KEY IDEA
In a set-associative cache, , so , a quantity independent of block size. Since , this sum is fixed even though the block size itself is never stated in the question — only needs to be found, and it comes out the same for every possible block size.
WATCH OUT FOR
Assuming a block/line size must be given and getting stuck, or (wrongly) assuming a specific block size such as 32 or 64 bytes and computing a TAG value that depends on that unstated assumption; also forgetting to divide by the associativity (8-way) when computing the number of sets, which gives INDEX+OFFSET = 16 and TAG = 16 instead of 19.
From the GATE 2023 CS paper. Every question of this paper · Download the full paper · All 22 Memory & cache questions, with notes