Question
Consider a machine with a byte addressable main memory of bytes, block size of 16 bytes and a direct mapped cache having cache lines. Let the addresses of two consecutive bytes in main memory be and . What are the tag and cache line address (in hex) for main memory address ?
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 , which requires address bits.
- Cache block (line) size , so the block offset takes bits.
- Direct-mapped cache has cache lines, so the cache line index takes bits.
- Tag bits 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 :
- The 5 hex digits are
E 2 0 1 F. - Tag
- Cache line address
- Block offset
Thus, the tag and cache line address are E, 201 (Option A).
A
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.