Professional Documents
Culture Documents
Lec9-10 Memory
Lec9-10 Memory
• Main Memory
– Memory access time
– Memory cycle time
• Types of Memory Unit
– RAM
– ROM
• Memory System
• Cache Memory
– Associative mapping
– Direct mapping
– Set-associative mapping
– Replacement algorithm
• Memory Interleaving
Main Memory ( 1 )
• The basic unit of memory is the binary digit “bit”. A bit contains a “0” or “1”.
• The most common definition of the word length of a computer is the number of
bits actually stored or retrieved in one memory access.
• Word length and address length are independent.
Processor k-bit
Memory
address bus
MAR
n-bit
data bus
Up to 2k addressable
MDR locations
Control lines
( R / W , MFC, etc.)
– Flash memory
• similar to EEPROM technology
• it is possible to read the contents of a single cell, but it is
only possible to write an entire block of cells
• greater density, higher capacity, lower cost per bit, low
power consumption
• typical applications: hand-held computers, digital cameras,
MP3 music players
• large memory modules implementation: flash cards and
flash drives
Types of Memory Unit ( 5 )
Memmory Systems (1)
• Implement a 64K X 8
memory using 16K X 1
16K X 8 memory chip
memory chips
• Number of rows = 64K/16K =
4 Data input
• Number of columns =
8/1 = 8. 14-bit
address
• 64K = 16 bit address. Data output
• Each small chip needs 14 bit
(16K) address
• 16-14 = 2 bits for selecting
one of the four rows.
Chip select
Memory Systems (2)
16-bit
addresses 14-bit internal chip address
A
A0
1
A
1
A1
4
5
2-bit
decoder
512K ´ 8
memory chip
D31-24 D23-16 D 15-8 D7-0
Chip select
Memory Systems ( 2 )
• Each chip has a control input called Chip Select (CS) used
to enable the chip.
Main
Processor Cache memory
Number of hits
hit ratio =
Total number of memory references
Cache Memory ( 4 )
Block 4095
Tag Word
12 4 Main memory address
Associative Mapping ( 2 )
• 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.
• A cache that has k blocks per set is referred to as a k-way set-
associative cache.
• The contention problem of the direct method is eased.
• The hardware cost of the associative method is reduced.
Set-Associative Mapping ( 2 )
Main
memory
tag Block 64
Block 2
• The tag field is associatively Set 1
tag
Block 3
Block 65
Block 4095
28 / 19
Replacement Algorithms
CPU A B C A D E A D C F
Reference
Miss Miss Miss Hit Miss Miss Miss Hit Hit Miss
Cache A A A A A E E E E E
FIFO B B B B B A A A A
C C C C C C C F
D D D D D D
29 / 19
Replacement Algorithms
CPU A B C A D E A D C F
Reference
Miss Miss Miss Hit Miss Miss Hit Hit Hit Miss
Cache A B C A D E A D C F
LRU A B C A D E A D C
A B C A D E A D
B C C C E A
30 / 19
Memory Interleaving ( 1 )
k bits m bits
Module Address in module MM address
m bits k bits
Address in module Module MM address