Search code examples
cachingcpu-wordmemory-address

How to find tag bit in cache given word address


Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address references, given as word addresses.

3, 180, 43, 2, 191, 88, 190, 14, 181, 44, 186, 253

For each of these references, identify the binary address, the tag, and the index given a direct-mapped cache with two-word blocks and a total size of 8 blocks. Also list if each reference is a hit or a miss, assuming the cache is initially empty.

the answer is : enter image description here

I understood that it was to find tag, index, and offset values ​​from the 32-bit memory address value and use it in the cache table, but I do not understand well that the memory address is given as a word. For example, does the word address 3 actually mean 0000 0000 0000 0000 0000 0000 0000 0011? Given a word address, how can it be thought of as a 32-bit address in the figure below? enter image description here


Solution

  • For the word address 3 (0000 0000 0000 0000 0000 0000 0000 0011), the offset would be 1, the index would be 001, and the tag would be 0000 0000 0000 0000 0000 0000 0000.

    • 2 words in block = 1 bit for offset (2^1).
    • 8 blocks in cache = 3 bits for index (2^3).
    • 32 - 4 = 28 bits for tag.