In: Computer Science
Suppose a computer using direct mapped cache has 224 bytes of byte-addressable main memory, and a cache of 128 blocks, where each cache block contains 8 bytes. For fully associative cache, to which block of cache the address 0x189B5A maps?
Group of answer choices
Block 6
Block 75
Not enough information
Block 10
Solution:
Given,
=>Main memory size = 2^24 bytes
=>Number of blocks in the cache = 128 blocks
=>Size of one block = 8 bytes
=>Direct mapped cache
=>Address = 0x189B5A
The answer will be an option,
(c) Not enough information.
Explanation:
Tag | Cache index | Block offset |
14 bits 7 bits 3 bits
=>Number of bits for main memory = log2(2^24 B)
=>Number of bits for main memory = 24 bits
=>Number of bits for cache index = log2(number of blocks)
=>Number of bits for cache index = log2(128)
=>Number of bits for cache index = 7 bits
=>Number of bits for block offset = log2(block size)
=>Number of bits for block offset = log2(8 B)
=>Number of bits for block offset = 3 bits
=>Number of bits for tag = 24 - 3 - 7
=>Number of bits for tag = 14 bits
Finding cache index bits from address:
=>Address = 0x189B5A in hexadecimal
=>Address = 0001 1000 1001 1011 0101 1010 in binary
=>Cache index bits = 1101011 in binary
=>Cache index value in decimal = 107
=>Hence address 0x189B5A will be mapped to the 107 block number in the direct mapped cache.
Fully associative cache:
Tag | Block offset |
21 bits 3 bits
=>In fully associative cache a main memory block address can be mapped to any of the block of the cache memory if the cache memory has empty blocks.
=>As nothing is told about the cache content of the cache memory so we can not predict exactly to what block number the given address will be mapped in fully associative cache.