Consider a machine with a byte addressable main memory of bytes, block size of 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 addresses ( in hex) for main memory address ?
View worked solution
Answer: A
In a direct-mapped cache, the physical address is divided into three fields: Tag, Line Index (or Cache Line Address), and Block Offset.
1. Determine the Bit Widths
- Physical Address Size: The main memory is bytes, so the physical address is bits.
- Block Offset: The block size is bytes ( bytes), which requires bits.
- Line Index: The cache has lines, which requires bits.
- Tag:
Thus, the 20-bit physical address format is partitioned as:
| Tag | Line Index | Block Offset |
|---|---|---|
| 4 bits | 12 bits | 4 bits |
2. Analyze the Address
Convert the hexadecimal address into binary:
Now, split the 20-bit binary address according to our fields:
- Tag (MSB 4 bits):
- Line Index (Middle 12 bits):
- Block Offset (LSB 4 bits):
Therefore, the tag is and the cache line address is .
Free practice · Your answers on this page are not saved.
