Results (
Thai) 2:
[Copy]Copied!
Suppose we generate the main memory address 9. We can see from the mapping
listing above that address 9 is in main memory block 4 and should map to
cache block 0 (which means the contents of main memory block 4 should be
copied into cache block 0). The computer, however, uses the actual main memory
address to determine the cache mapping block. This address, in binary, is represented
in Figure 6.7.
When the CPU generates this address, it first takes the block field bits 00 and
uses these to direct it to the proper block in cache. 00 indicates that cache block 0
should be checked. If the cache block is valid, it then compares the tag field value
of 1 (in the main memory address) to the tag associated with cache block 0. If the
cache tag is 1, then block 4 currently resides in cache block 0. If the tag is 0, then
block 0 from main memory is located in block 0 of cache. (To see this, compare
main memory address 9 = 10012, which is in block 4, to main memory address
1 = 00012, which is in block 0. These two addresses differ only in the leftmost bit,
which is the bit used as the tag by the cache.) Assuming the tags match, which
means that block 4 from main memory (with addresses 8 and 9) resides in cache
block 0, the word field value of 1 is used to select one of the two words residing
in the block. Because the bit is 1, we select the word with offset 1, which results
in retrieving the data copied from main memory address 9.
Let’s do one more example in this context. Suppose the CPU now generates
address 4 = 01002. The middle two bits (10) direct the search to cache block 2. If
the block is valid, the leftmost tag bit (0) would be compared to the tag bit stored
with the cache block. If they match, the first word in that block (of offset 0)
would be returned to the CPU. To make sure you understand this process, perform
a similar exercise with the main memory address 12 = 11002.
Let’s move on to a larger example. Suppose we have a system using 15-bit
main memory addresses and 64 blocks of cache. If each block contains 8 words, we
know that the main memory 15-bit address is divided into a 3-bit word field, a 6-bit
block field, and a 6-bit tag field. If the CPU generates the main memory address:
Being translated, please wait..