For a 32-bit physical address and a 16KB direct-mapped cache with a 64-byte block size, how many bits are used for the tag, index, and offset fields respectively?
To determine the bit allocation for a 32-bit physical address with this specific cache configuration, we need to calculate the bits required for each field starting from the smallest unit (the block) and moving up.
The offset bits identify a specific byte within a cache block.
Block Size: 64 bytes.
Since 64 = 2^6, we need 6 bits to address every byte within a single block.
In a direct-mapped cache, each memory block maps to exactly one specific line in the cache. The index bits identify which line that is.
Total Cache Size: 16 KB = 16 * 1024 bytes = 16,384 bytes.
Number of Lines: Cache Size/ Block Size = 16,384/64 = 256 lines.
Since 256 = 2^8, we need 8 bits for the index.
The tag bits represent the remaining part of the address used to distinguish between different memory blocks that could map to the same cache line.
Total Address Bits: 32 bits.
Tag Bits: {Total Bits} - (Index Bits + Offset Bits)
32 - (8 + 6) = 32 - 14 = 18 bits