Cache Problem Solution
Cache Problem Solution
Ans.
Block size = 64 bytes = 26 bytes = 26 words (since 1 word = 1 byte)
Therefore, Number of bits in the Offset field = 6
For a given 16-bit address, the 5 most significant bits represent the Tag, the next 5 bits represent the
Index (Block), and the 6 least significant bits represent the Offset (Word).
Access # 1:
Address = (128)10 = (0000000010000000)2
(Note: Address is shown as a 16-bit number, because the processor uses 16-bit addresses)
For this address, Tag = 00000, Block = 00010, Word = 000000
Since the cache is empty before this access, this will be a cache miss
After this access, Tag field for cache block 00010 is set to 00000
Access # 2:
Address = (144)10 = (0000000010010000)2
For this address, Tag = 00000, Block = 00010, Word = 010000
Since tag field for cache block 00010 is 00000 before this access, this will be a cache hit (because
address tag = block tag)
Q. Caches are important to providing a high-performance memory hierarchy to ARM processors.
Below is a list of 64-bit memory address references, given as word addresses. 0xFFAA0003,
0xFFAA00B4, 0xFFAA002B, 0xFFAA0002, 0xFFAA00BF, 0xDDCC00BE, 0xDDCC00B5.
For each of these references, identify the binary word address, the tag, the index, and the offset given
a direct-mapped cache with two-word blocks and a total size of eight blocks. Also list if each reference
is a hit or a miss, assuming the cache is initially empty. [7]
Ans.
As cache has two word blocks, require offset 1 bit.
Total size is 8 blocks, index is 3 bits.
Remaining bits are Tag bits 64-3-1 = 60 bits.
At first time Tag=0xFFAA000 and Index =1 then it is miss but for second time it matches address tag
and index bit, so it is hit. (address tag = block tag)