Module-5
Module-5
Memory Unit
1.Direct Mapping
1.Direct Mapping
• The low-order 4 bits select one of 16 words in a block.
• When a new block enters the cache, the 7-bit cache block field
determines the cache position in which this block must be
stored.
• The high-order 5 bits of the memory address of the block are
stored in 5 tag bits associated with its location in the cache.
• They identify which of the 32 blocks that are mapped into this
cache position are currently resident in the cache.
• As execution proceeds, the 7-bit cache block field of each
address generated by the processor points to a particular block
location in the cache..
• As execution proceeds, the 7-bit cache block field of
each address generated by the processor points to a
particular block location in the cache.
• The high-order 5 bits of the address are compared
with the tag bits associated with that cache location.
If they match, then the desired word is in that block
of the cache.
• If there is no match, then the block containing the
required word must first be read from the main
memory and loaded into the cache.
• The direct-mapping technique is easy to implement,
but it is not very flexible.
Mapping Function
2. Associative Mapping
1. Associative Mapping
• This shows a much more flexible mapping method, in which
a main memory block can be placed into any cache bloc
• 12 tag bits are required to identify a memory block when it is
resident in the cache. The tag bits of an address received
from the processor are compared to the tag bits of each block
of the cache to see if the desired block is present.
• It gives complete freedom in choosing the cache location in
which to place the memory block.
• A new block that has to be brought into the cache has to
replace (eject) an existing block only if the cache is full.
• The cost of an associative cache is higher than the cost of a
direct-mapped cache because of the need to search all 128tag
patterns to determine whether given block is in the cache.
Mapping Function
3. Set-Associative Mapping
Set-Associative Mapping- Blocks of the cache are
grouped into sets, and the mapping allows a block of
the main memory to reside in any block of a specific
set.
1. Hence, the contention problem of the direct
method is eased by having a few choices for block
placement. At the same time, the hardware cost is
reduced by decreasing the size of the associative
search.
2. In this case, memory blocks 0, 64, 128, ..., 4032
map into cache set 0, and they can occupy either of
the two block positions within this set.
3. Having 64 sets means that the 6-bit set field of the
address determines which set of the cache might
contain the desired block. The tag field of the address
must then be associatively compared to the tags of the
two blocks of the set to check if the desired block is
present. This two-way associative search is simple to
implement.