A Direct-Mapped Cache


The figure shows a direct-mapped cache structure where
  • The block size is 1 word (or 4 bytes),
  • Block number is 1024 (or 210), and
  • The valid bit (V) is off initially.
To find the unique cache entry for each possible 32-bit address, the address is divided into three fields:
Index
It is used to select the block. A block is the minimum unit of information that can be either present or not present in a cache. Because the cache has 210 (or 1024) blocks and a block size of one word, 10 bits are used to index the cache.

Tag
The tag from the cache is compared against the upper portion of the address to determine whether the entry in the cache corresponds to the requested address. Because 10 bits are used to index the cache and 2 bits are for the offset field, leave 32-10-2=20 bits to be compared against the tag.

Offset
It is used to select the byte address in a block. This field is 2 bits for this cache because it has blocks with a size of 1 word (or 4=22 bytes).
If the tag and upper 20 bits of the address are equal and the valid bit is on, then the request hits in the cache, and the word is supplied to the processor. Otherwise, a miss occurs.




      I just finished my last exam.    
      Let’s go out and paint the town red! (go out drinking and partying).