GATE Computer Science · Digital Logic, Computer Organization, and Discrete Mathematics · hard

A computer has a 32-bit physical address space and a 64 KB, 4-way set-associative cache with a block (line) size of 64 bytes. How many bits are in the Tag, Set Index, and Block Offset fields of the physical address?

Published · Last updated · checked before publication — how we verify questions

Options

  • ATag = 18 bits, Set Index = 8 bits, Block Offset = 6 bitsCorrect answer
  • BTag = 16 bits, Set Index = 10 bits, Block Offset = 6 bits
  • CTag = 20 bits, Set Index = 6 bits, Block Offset = 6 bits
  • DTag = 18 bits, Set Index = 6 bits, Block Offset = 8 bits

Answer: A. Tag = 18 bits, Set Index = 8 bits, Block Offset = 6 bits

A physical address splits into Tag, Set Index and Block Offset. The offset selects a byte within a block, so a 64-byte block needs log2(64) = 6 bits. The number of lines is cache size divided by block size: 64 KB / 64 B = 2^16 / 2^6 = 2^10 = 1024 lines. In a 4-way set-associative cache each set holds 4 lines, so the number of sets is 1024 / 4 = 256 = 2^8, which gives 8 index bits. The tag is whatever remains of the 32-bit address: 32 - 8 - 6 = 18 bits. The three fields must sum to 32, which checks the answer (18 + 8 + 6 = 32). The most common trap is forgetting to divide the line count by the associativity. That gives 10 index bits, which is the direct-mapped figure. Another trap is mixing up the offset and index fields.

Why the other options are wrong

  • B. Tag = 16 bits, Set Index = 10 bits, Block Offset = 6 bits — Tag 16, index 10 and offset 6 describe a direct-mapped cache, where every one of the 1024 lines is its own set. It ignores the 4-way associativity, which groups lines into 256 sets and so needs only 8 index bits.
  • C. Tag = 20 bits, Set Index = 6 bits, Block Offset = 6 bits — Six index bits give only 64 sets. With 4 ways and 64-byte blocks that is a 16 KB cache, not 64 KB. The tag of 20 bits follows from the wrong index width.
  • D. Tag = 18 bits, Set Index = 6 bits, Block Offset = 8 bits — This swaps the roles of the fields by giving 8 bits to the offset and 6 to the index. A 64-byte block needs only 6 offset bits, and the 256 sets need 8 index bits. Its sum of 32 is a coincidence of the numbers, not a correct split.

All Digital Logic, Computer Organization, and Discrete Mathematics questions and the topic overview →

GATE is a mark of the Indian Institute of Science and the Indian Institutes of Technology. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by the GATE Committee.