MODULE 4 Memory System
MODULE 4 Memory System
Module 4
Speed, size and cost of memory system
Memory Hierarchy
Cache Memories
Cache Memories
Processor is much faster than the main memory.
As a result, the processor has to spend much of its time
waiting while instructions and data are being fetched
from the main memory.
Major obstacle towards achieving good performance.
Speed of the main memory cannot be increased
beyond a certain point.
Cache memory is an architectural arrangement which
makes the main memory appear faster to the processor
than it really is.
Cache memory is based on the property of computer
programs known as “locality of reference”.
Locality of Reference
Analysis of programs shows that most of their
execution time is spent on routines in which
many instructions are executed repeatedly.
These instructions may constitute a simple loop,
nested loops, or a few procedures that repeatedly
call each other.
Many instructions in localized areas of the program
are executed repeatedly during some time period,
and the remainder of the program is accessed
relatively infrequently.
This is called “locality of reference”.
Locality of Reference..
Temporal locality of reference
Recently executed instruction is likely to be
executed again very soon.
Spatial locality of reference
Instructions with addresses close to a recently
executed instruction are likely to be executed
soon.
Operation of Cache Memories
If the active segments of a program can be placed in a fast
cache memory, then the total execution time can be reduced
significantly.
The memory control circuitry is designed to take
advantage of the property of locality of reference.
The temporal aspect of the locality of reference suggests that whenever an
information item (instruction or data) is first needed, this item should be
brought into the cache where it will hopefully remain until it is needed again.
The spatial aspect suggests that instead of fetching just one item from the
main memory to the cache, it is useful to fetch several items that reside at
adjacent addresses as well.
The term block refers to a set of contiguous address
locations of some size.
The term Cache line refers to a cache block.
Operation of Cache Memories..
Operation of Cache Memories..
Processor issues a Read request, a block of words is
transferred from the main memory to the cache, one word
at a time.
Subsequent references to the data in this block of words are
found in the cache.
At any given time, only some blocks in the main memory are
held in the cache.
Which blocks in the main memory are in the cache is determined
by a “mapping function”.
When the cache is full, and a block of words needs to be
transferred from the main memory, some block of words in
the cache must be replaced.
This is determined by a “replacement algorithm”.
Cache Hit
Processor simply issues Read and Write requests
using addresses that refer to locations in the
memory.
The cache control circuitry determines whether the
requested word currently exists in the cache.
If it does, the Read or Write operation is performed on the
appropriate cache location.
In this case, a read hit or write hit is said to have occurred.
In a Read operation, the main memory is not involved.
Data is obtained from the cache.
Read Operation with Cache: ‘Hits’
and ‘Misses’
Data found in cache = ‘Hit’
Cache
Read
Request