We have a standard 32-bit byte-addressed MIPS machine with 4 GiB RAM, a 4-way set-associative CPU data cache that uses 32 byte blocks, a LRU replacement policy, and has a total capacity of 16 KiB. Consider the following C code and answer the questions below. (size of int type variable is 4 byte)
How many bits are used for the tag, index, and offset?
Tag | Index | Offset |
Expert Answer
Then you work from the bottom up. Let’s assume the system is byte addressable.
Then each cache block contains 8 words*(4 bytes/word)=32=25 bytes, so the offset is 5 bits.
The index for a direct mapped cache is the number of blocks in the cache is 7
Then the tag is all the bits that are left, as you have indicated. that is 20.
Tag=20
index=7
offset=5