Mapping

14
MAPPING

Transcript of Mapping

MAPPING

There are three commonly used methods totranslate main memory addresses to cachememory addresses.

• Direct-Mapping• Associative Mapping• Set-Associative Mapping

Methods of Mapping :

BLOCK: Fixed sized packet of information

that moves back and forth between a cache and main memory.

LINE:Container in a cache that stores

a block as well as other information such as the valid bit and tag bits.

SET:Collection of one or more lines.

Direct-Mappingo Set of Blocks of main

memory mapped onto specific block of cache

• Cache of 64kByte.• Cache block of 4 bytes.• 16MBytes main memory.• Show hexadecimal main memory

address BBBBBB in direct format.

Example:

• The tag memory is much smaller than in associative mapped cache.

• It is less costly compare to other mapping technique.

• It is easy to implement.

• It is not flexible.

Advantages:

Disadvantage:

AssociativeMapping:

o Any main memory blocks can be mapped into each cache slot.

Example:• Cache of 64kByte.• Cache block of 4 bytes.• 16MBytes main memory.• Show hexadecimal main memory

address BBBBBB in associate format.

• Flexibility. Main Memory block can be mapped anywhere in Cache Memory.

• Regardless of how irregular the data and program references are, if a slot is available for the block, it can be stored in the cache.

• Slow or expensive.

Advantage:

Disadvantage:

Set-Associative Mappingo Combines the simplicity of

direct mapping with the flexibility of associative mapping.

o Cache is divided into a number of sets.

o Each set contains a number of lines.

Example:• 2-way set-associative. • Cache of 64kByte.• Cache block of 4 bytes.• 16MBytes main memory.• Show hexadecimal main memory

address BBBBBB in set-associate format.

• Minimize the over-head in Direct and Associate mapping.

• In our example the tag memory increases only slightly from the direct mapping and only two tags need to be searched for each memory reference.

• The set-associative cache is widely used in today’s microprocessors.

Advantages:

• Least Recently used (LRU)e.g. in 2 way set associative   Which of the 2 block

is LRU?• First in first out (FIFO)

replace block that has been in cache longest• Least frequently used

replace block which has had fewest hits• Random

REPLACEMENT ALGORITHMS:

Thank You…