CH04 Cache Memory
CH04 Cache Memory
William Stallings
Computer Organization
and Architecture
9th Edition
+
Chapter 4
Cache Memory
Key Characteristics of Computer
Memory Systems
Location
Refers to whether memory is internal and external to the computer
Internal memory is often equated with main memory
Processor requires its own local memory, in the form of registers
Cache is another form of internal memory
External memory consists of peripheral storage devices that are accessible to the
processor via I/O controllers
Capacity
Memory is typically expressed in terms of bytes
Unit of transfer
For internal memory the unit of transfer is equal to the number of electrical lines
into and out of the memory module
Method of Accessing Units of Data
Sequential Random
Direct access Associative
access access
Logical
and
Physical
Caches
Table 4.3
Cache Sizes
of Some
Processors
a
Two values
separated by a slash
refer to instruction
and data caches.
b
Both caches are
instruction only; no
data caches.
Mapping Function
Because there are fewer cache lines than main memory blocks, an
algorithm is needed for mapping main memory blocks into cache
lines
Direct
Mapping
+
Direct Mapping Cache Organization
+
Direct
Mapping
Example
+
Direct Mapping Summary
Mapping
Example
+
Associative Mapping Summary
k-Way
Set Associative
+
k-Way
Set
Associative
Cache
Organization
+
Set Associative Mapping Summary
Number of sets = v = 2d
Once the cache has been filled, when a new block is brought into the
cache, one of the existing blocks must be replaced
For direct mapping there is only one possible line for any particular
block and no choice is possible
First-in-first-out (FIFO)
Replace that block in the set that has been in the cache longest
Easily implemented as a round-robin or circular buffer technique
If the old block in the cache has not been altered then it may be
overwritten with a new block without first writing out the old block
Write back
Minimizes memory writes
Updates are made only in the cache
Portions of main memory are invalid and hence accesses by I/O modules can be
allowed only through the cache
This makes for complex circuitry and a potential bottleneck
Line Size
The on-chip cache reduces the processor’s external bus activity and speeds up
execution time and increases overall system performance
When the requested instruction or data is found in the on-chip cache, the bus access is
eliminated
On-chip cache accesses will complete appreciably faster than would even zero-wait state
bus cycles
During this period the bus is free to support other transfers
Two-level cache:
Internal cache designated as level 1 (L1)
External cache designated as level 2 (L2)
Potential savings due to the use of an L2 cache depends on the hit rates in both the
L1 and L2 caches
The use of multilevel caches complicates all of the design issues related to caches,
including size, replacement algorithm, and write policy
Hit Ratio (L1 & L2)
For 8 Kbyte and 16 Kbyte L1
+
Unified Versus Split Caches
Trend is toward split caches at the L1 and unified caches for higher levels