0% found this document useful (0 votes)
5 views

Cache Memory

The document discusses computer organization focusing on memory types, particularly cache memory, which includes primary (L1) and secondary (L2) caches. It explains the concept of 'Locality of Reference' and details various mapping functions for cache memory, including Direct, Associative, and Set-Associative Mapping, along with their advantages and disadvantages. Additionally, it covers cache control mechanisms, write and read operations, and the importance of valid and dirty bits in maintaining cache coherence.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Cache Memory

The document discusses computer organization focusing on memory types, particularly cache memory, which includes primary (L1) and secondary (L2) caches. It explains the concept of 'Locality of Reference' and details various mapping functions for cache memory, including Direct, Associative, and Set-Associative Mapping, along with their advantages and disadvantages. Additionally, it covers cache control mechanisms, write and read operations, and the importance of valid and dirty bits in maintaining cache coherence.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

COMPUTER ORGANIZATION

SPEED, SIZE COST

I
R
YS
• The main-memory can be built with DRAM (Figure 8.14)
• Thus, SRAM‟s are used in smaller units where speed is of essence.
• The Cache-memory is of 2 types:
1) Primary/Processor Cache (Level1 or L1 cache)
 It is always located on the processor-chip.
2) Secondary Cache (Level2 or L2 cache)
SB
 It is placed between the primary-cache and the rest of the memory.
• The memory is implemented using the dynamic components (SIMM, RIMM, DIMM).
• The access time for main-memory is about 10 times longer than the access time for L1 cache.
TE
O
N
U
VT

3-12
COMPUTER ORGANIZATION
CACHE MEMORIES
• The effectiveness of cache mechanism is based on the property of „Locality of Reference’.
Locality of Reference
• Many instructions in the localized areas of program are executed repeatedly during some time period
• Remainder of the program is accessed relatively infrequently (Figure 8.15).
• There are 2 types:
1) Temporal
 The recently executed instructions are likely to be executed again very soon.
2) Spatial
 Instructions in close proximity to recently executed instruction are also likely to be executed soon.
• If active segment of program is placed in cache-memory, then total execution time can be reduced.

I
• Block refers to the set of contiguous address locations of some size.

R
• The cache-line is used to refer to the cache-block.

YS




SB
The Cache-memory stores a reasonable number of blocks at a given time.
This number of blocks is small compared to the total number of blocks available in main-memory.
Correspondence b/w main-memory-block & cache-memory-block is specified by mapping-function.
Cache control hardware decides which block should be removed to create space for the new block.
• The collection of rule for making this decision is called the Replacement Algorithm.
• The cache control-circuit determines whether the requested-word currently exists in the cache.
TE
• The write-operation is done in 2 ways: 1) Write-through protocol & 2) Write-back protocol.
Write-Through Protocol
 Here the cache-location and the main-memory-locations are updated simultaneously.
Write-Back Protocol
 This technique is to
→ update only the cache-location &
→ mark the cache-location with associated flag bit called Dirty/Modified Bit.
O

 The word in memory will be updated later, when the marked-block is removed from cache.
During Read-operation
• If the requested-word currently not exists in the cache, then read-miss will occur.
N

• To overcome the read miss, Load–through/Early restart protocol is used.


Load–Through Protocol
 The block of words that contains the requested-word is copied from the memory into cache.
 After entire block is loaded into cache, the requested-word is forwarded to processor.
U

During Write-operation
• If the requested-word not exists in the cache, then write-miss will occur.
1) If Write Through Protocol is used, the information is written directly into main-memory.
2) If Write Back Protocol is used,
VT

→ then block containing the addressed word is first brought into the cache &
→ then the desired word in the cache is over-written with the new information.

MAPPING-FUNCTION
• Here we discuss about 3 different mapping-function:
1) Direct Mapping
2) Associative Mapping
3) Set-Associative Mapping

3-13
COMPUTER ORGANIZATION
DIRECT MAPPING
• The block-j of the main-memory maps onto block-j modulo-128 of the cache (Figure 8.16).
• When the memory-blocks 0, 128, & 256 are loaded into cache, the block is stored in cache-block 0.
Similarly, memory-blocks 1, 129, 257 are stored in cache-block 1.
• The contention may arise when
1) When the cache is full.
2) When more than one memory-block is mapped onto a given cache-block position.
• The contention is resolved by
allowing the new blocks to overwrite the currently resident-block.
• Memory-address determines placement of block in the cache.

I
R
YS
SB
TE
O
N
U

• The memory-address is divided into 3 fields:


1) Low Order 4 bit field
 Selects one of 16 words in a block.
VT

2) 7 bit cache-block field


 7-bits determine the cache-position in which new block must be stored.
3) 5 bit Tag field
 5-bits memory-address of block is stored in 5 tag-bits associated with cache-location.
• As execution proceeds,
5-bit tag field of memory-address is compared with tag-bits associated with cache-location.
If they match, then the desired word is in that block of the cache.
Otherwise, the block containing required word must be first read from the memory.
And then the word must be loaded into the cache.

3-14
COMPUTER ORGANIZATION
ASSOCIATIVE MAPPING
• The memory-block can be placed into any cache-block position. (Figure 8.17).
• 12 tag-bits will identify a memory-block when it is resolved in the cache.
• Tag-bits of an address received from processor are compared to the tag-bits of each block of cache.
• This comparison is done to see if the desired block is present.

I
R
YS
SB
TE
O

• It gives complete freedom in choosing the cache-location.


• A new block that has to be brought into the cache has to replace an existing block if the cache is full.
N

• The memory has to determine whether a given block is in the cache.


• Advantage: It is more flexible than direct mapping technique.
• Disadvantage: Its cost is high.
U
VT

3-15
COMPUTER ORGANIZATION
SET-ASSOCIATIVE MAPPING
• It is the combination of direct and associative mapping. (Figure 8.18).
• The blocks of the cache are grouped into sets.
• The mapping allows a block of the main-memory to reside in any block of the specified set.
• The cache has 2 blocks per set, so the memory-blocks 0, 64, 128…….. 4032 maps into cache set „0‟.
• The cache can occupy either of the two block position within the set.
6 bit set field
 Determines which set of cache contains the desired block.
6 bit tag field
 The tag field of the address is compared to the tags of the two blocks of the set.
 This comparison is done to check if the desired block is present.

I
R
YS
SB
TE
O
N
U

• The cache which contains 1 block per set is called direct mapping.
• A cache that has „k‟ blocks per set is called as “k-way set associative cache‟.
VT

• Each block contains a control-bit called a valid-bit.


• The Valid-bit indicates that whether the block contains valid-data.
• The dirty bit indicates that whether the block has been modified during its cache residency.
Valid-bit=0  When power is initially applied to system.
Valid-bit=1  When the block is loaded from main-memory at first time.
• If the main-memory-block is updated by a source & if the block in the source is already exists in the
cache, then the valid-bit will be cleared to “0‟.
• If Processor & DMA uses the same copies of data then it is called as Cache Coherence Problem.
• Advantages:
1) Contention problem of direct mapping is solved by having few choices for block placement.
2) The hardware cost is decreased by reducing the size of associative search.

3-16

You might also like