Question

Consider a machine with a byte addressable main memory of 2202^{20} bytes, block size of 16 bytes and a direct mapped cache having 2122^{12} cache lines. Let the addresses of two consecutive bytes in main memory be (E201F)16(\text{E201F})_{16} and (E2020)16(\text{E2020})_{16}. What are the tag and cache line address (in hex) for main memory address (E201F)16(\text{E201F})_{16}?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2015 answer key

Solution

Deconstruct the physical memory address into Tag, Line Index, and Block Offset fields for a direct-mapped cache.

Given parameters:

  • Byte addressable main memory size =220 bytes= 2^{20}\text{ bytes}, which requires log⁡2(220)=20\log_2(2^{20}) = 20 address bits.
  • Cache block (line) size =16 bytes=24 bytes= 16\text{ bytes} = 2^4\text{ bytes}, so the block offset takes 44 bits.
  • Direct-mapped cache has 2122^{12} cache lines, so the cache line index takes 1212 bits.
  • Tag bits =20−(12+4)=4= 20 - (12 + 4) = 4 bits.

Bit layout of a 20-bit address (5 hexadecimal digits):

  • Tag: bits 19-16 (1 hexadecimal digit)
  • Cache Line Index: bits 15-4 (3 hexadecimal digits)
  • Block Offset: bits 3-0 (1 hexadecimal digit)

For the main memory address (E201F)16(\text{E201F})_{16}:

  • The 5 hex digits are E 2 0 1 F.
  • Tag =E= \text{E}
  • Cache line address =201= 201
  • Block offset =F= \text{F}

Thus, the tag and cache line address are E, 201 (Option A).

Final answer

A

Common trap

Assigning 8 bits to the tag instead of calculating the exact tag width from total address bits minus line and offset bits.

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

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 3
Question
24 of 65, printed as CS Q.14
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.