by the tag previously described. If we take a closer look at cache, we see that it
stores more than just that data copied from main memory, as indicated in Figure
6.3. In this figure, there are two valid cache blocks. Block 0 contains multiple
words from main memory, identified using the tag “00000000”. Block 1 contains
words identified using tag “11110101”. The other two cache blocks are not valid.
To perform direct mapping, the binary main memory address is partitioned
into the fields shown in Figure 6.4.
The size of each field depends on the physical characteristics of main memory
and cache. The word field (sometimes called the offset field) uniquely identifies
a word from a specific block; therefore, it must contain the appropriate
number of bits to do this. This is also true of the block field—it must select a
unique block of cache. The tag field is whatever is left over. When a block of
main memory is copied to cache, this tag is stored with the block and uniquely
identifies this block. The total of all three fields must, of course, add up to the
number of bits in a main memory address.
Consider the following example: Assume memory consists of 214 words,
cache has 16 blocks, and each block has 8 words. From this we determine that
memory has
214
23
= 211 blocks. We know that each main memory address requires
14 bits. Of this 14-bit address field, the rightmost 3 bits reflect the word field (we
need 3 bits to uniquely identify one of 8 words in a block). We need 4 bits to
select a specific block in cache, so the block field consists of the middle 4 bits.
The remaining 7 bits make up the tag field. The fields with sizes are illustrated in
Figure 6.5.
As mentioned previously, the tag for each block is stored with that block in
the cache. In this example, because main memory blocks 0 and 16 both map to
cache block 0, the tag field would allow the system to differentiate between block