2021 Chapter 4 Memory Lecture 1
2021 Chapter 4 Memory Lecture 1
2021 Chapter 4 Memory Lecture 1
MEMORY
UNIT
1
OUTLINE
Introduction
Computer Memory System Overview
Characteristics of Memory Systems
The Memory Hierarchy
Cache Memory
Cache Memory Principles
Elements of Cache Design
Semiconductor Main Memory
Organization
Types of Semiconductor Memories
Error Correction
External Memory
Magnetic Disk
Optical Memory
Magnetic Tape 2
Solid State Drives
PART 1
Introduction
Cache Memory
Cache Memory Principles
Capacity
Unit of transfer
Access method
Performance
Physical type
Physical characteristics
Organisation
5
CHARACTERISTICS OF MEMORY …
Location
Refers to whether memory is internal or external to
computer system
Internal memory
directly accessible by the processor
Types of internal memory
Cache
CPU registers
Control memory
External memory
Accessible via the I/O module/controller
Also called secondary memory
6
CHARACTERISTICS OF MEMORY …
Capacity
the amount of information that can be contained in a
memory unit
For internal memory
expressed in terms of bytes or words
For external memory
expressed in terms of bytes
Terminologies
Word
natural unit of organization of memory
Typical size
instruction length
Addressable unit
Smallest location which can be uniquely addressed
It could be
A word
7
Byte level
CHARACTERISTICS OF MEMORY …
Unit of Transfer
For internal memory
Usually governed by data bus width
May be equal to a word
Often larger : 64 ,128, or 256 bits
Associative Access
Data is located by a comparison with contents of a
portion of the store
access time is independent of location or previous
access
e.g. Some cache memory units
10
CHARACTERISTICS OF MEMORY …
Performance
Access time (latency)
Time between presenting an address and getting
access to a valid data
For Random Access Memory
It is the time it takes to perform a read or write operation
Where
Tn average time to read or write N bits
Ta average access time
N number of bits
12
R transfer rate (bps)
CHARACTERISTICS OF MEMORY …
Physical Types
Semiconductor
RAM
Magnetic
Disk & Tape
Optical
CD & DVD
13
Magneto-optical
CHARACTERISTICS OF MEMORY …
Physical Characteristics
Volatility
Volatile memory
Information is lost when electrical power is switched off
Some semiconductor memories
E.g RAM
Non Volatile memory
Information once recorded remains without deterioration
Electrical power not needed to retain information
E.g magnetic storage unit
Non erasable memory
cannot be altered
ROM
14
CHARACTERISTICS OF MEMORY …
Organisation
Memory Modules
Physical arrangement of bits to form words
Not always obvious
15
MEMORY HIERARCHY
Memory hierarchy
diagram 16
MEMORY HIERARCHY...
Memory hierarchy characteristics, going down the
diagram
Decreasing cost per bit
Increasing capacity
Increasing access time
Decreasing frequency of access of the memory by the
processor
• Fasteraccess time, greater cost per bit
• Greater capacity, smaller cost per bit 17
• Greater capacity, slower access time
MEMORY HIERARCHY...
Hierarchy List
Registers L1 CacheL2 Cache Main
memory Disk Optical Tape
Locality of Reference Principle
during the course of the execution of a program,
memory references by the processor tend to cluster
e.g. Loops, tables and arrays
18
4.3 CACHE MEMORY
PRINCIPLES
19
4.3 CACHE MEMORY
PRINCIPLES
Cache memory
Small amount of fast memory
Sits between main memory and CPU
May be located on CPU chip or module
Contains copies of sections of main memory
20
CACHE MEMORY PRINCIPLES...
Cache operation – overview
CPU requests contents of memory location
Cache checked for this data
If present, get from cache (fast)
If not present, read required block from main
memory to cache
Then deliver from cache to CPU
Cache includes tags to identify which block of main memory
is in each cache slot
21
CACHE MEMORY PRINCIPLES...
Typical Cache Organization
22
CACHE MEMORY PRINCIPLES...
Cache/Main Memory Structure
23
CACHE READ OPERATION - FLOWCHART
24
ELEMENTS OF CACHE DESIGN
Basic elements used to classify cache design architectures:
# Size
# Mapping Function
# Replacement Algorithm
# Write Policy
# Line/Block Size
# Number of Caches
# Unified and Split
25
ELEMENTS OF CACHE DESIGN...
Cache Size
Small enough ---not to be costly or expensive
Large enough so overall average access time is small
Affected by the available chip and board area
26
ELEMENTS OF CACHE DESIGN...
Mapping Function
No of cache lines <<< No of blocks in main memory
Mapping function needed
A method to map main memory blocks into cache lines
Three mapping techniques used
Direct
Associative
Set Associative
Typical memory-cache organization
Cache of 64 kBytes
Organized as 16k lines of 4 bytes
Cache block of 4 bytes
16 MBytes main memory
Byte addressable memory
27
24 bit address
(224=16M)
ELEMENTS OF CACHE DESIGN
DIRECT MAPPING...
Each block of main memory maps to only one cache
line
i=j modulo m
i=cache line number,
j=main memory block number
m=number of lines in the cache
24 bit address
2 bit word identifier (4 byte block)
22 bit block identifier
8 bit tag (=22-14)
14 bit slot or line
No two blocks in the same line have the same Tag field
30
ELEMENTS OF CACHE DESIGN
DIRECT MAPPING...
Direct Mapping Cache Organization
31
ELEMENTS OF CACHE DESIGN
DIRECT MAPPING...
Direct Mapping Summary
Address length = (s + w) bits
Number of addressable units = 2(s+w) words / bytes
Block size = line size = 2w words or bytes
Number of blocks in main memory = 2(s+ w)/2w = 2s
Number of lines in cache = m = 2r
Size of tag = (s – r) bits
32
ELEMENTS OF CACHE DESIGN
DIRECT MAPPING...
Direct Mapping Advantage and Disadvantage
Advantage
Easy to implement
Inexpensive to implement
Easy to determine the right cache line
Disadvantage
Fixed location for given block
If a program accesses 2 blocks that map to the same
line repeatedly, cache misses are very high 33
ELEMENTS OF CACHE DESIGN
ASSOCIATIVE MAPPING
Associative Mapping
A main memory block can loaded into any line of
cache
Memory address is interpreted as tag and word
Tag field uniquely identifies a block of memory
Every cache line’s tag is examined for a match
simultaneously
34
ELEMENTS OF CACHE DESIGN
ASSOCIATIVE MAPPING...
Associative Cache Organization
35
ELEMENTS OF CACHE DESIGN
ASSOCIATIVE MAPPING...
Address Structure
Wor
Tag 22 bit
d 2
bit
22 bit tag stored with each 32 bit block of data
Compare tag field with tag entry in cache to check for hit
Least significant 2 bits of address identify which 8 bit word
is required from 32 bit data block
36
ELEMENTS OF CACHE DESIGN
ASSOCIATIVE MAPPING...
Associative Mapping Summary
Address length = (s + w) bits
Number of addressable units = 2(s+w) words / bytes
Block size = line size = 2w words or bytes
Number of blocks in main memory = 2(s+ w)/2w = 2s
Number of lines in cache = undetermined
Size of tag = s bits
40
ELEMENTS OF CACHE DESIGN
SET ASSOCIATIVE MAPPING...
Set Associative Mapping Summary
Address length = (s + w) bits
Number of addressable units = 2s+w words / bytes
Block size = line size = 2w words or bytes
Number of blocks in main memory = 2s
Number of lines in set = k
Number of sets = v = 2d
Number of lines in cache = kv = k * 2d
Size of tag = (s – d) bits 41
ELEMENTS OF CACHE DESIGN...
REPLACEMENT ALGORITHMS
Replacement Algorithms
determine which existing block should be replaced when a
new block is brought into the cache
There are a number of algorithms
LRU, FIFO, LFU…
Direct mapping
No choice, no algorithm needed
Each block only maps to one line
Replace that line 42
ELEMENTS OF CACHE DESIGN
REPLACEMENT ALGORITHMS...
Least Recently used (LRU)
Most effective
Replaces a block not used recently
For a 2 way set associative
Which of the 2 blocks
Each line includes a USE bit
Line Size
Howmuch data should be transferred from main
memory to the cache in a single memory reference
Complex relationship between
Block size
Hit ratio
46
ELEMENTS OF CACHE DESIGN...
NUMBER , UNIFIED AND SPLIT
Number of Caches
Single versus 2 level
L1 provides best performance gains
L2 off-chip cache
L3 cache
Split cache 47
Uses 2 caches
CACHE MEMORY
EXAMPLE
Pentium 4 Cache
80386 – no on chip cache
L2 cache
Feeding both L1 caches
256k
47
128 byte lines
L3 cache on chip
4.4 SEMICONDUCTOR MAIN MEMORY
ORGANIZATION
Organization
Basic element of a semiconductor memory
A memory cell
49
SEMICONDUCTOR MAIN MEMORY
ORGANIZATION…
Control terminal
50
SEMICONDUCTOR MAIN MEMORY
ORGANIZATION…
Operation of a memory cell
For writing
the third terminal provides an electrical signal that
sets the state of the cell to 1 or 0
For reading
The third terminal is used to output the cell’s state
51
SEMICONDUCTOR MEMORY TYPES
RAM
Misnamed as all semiconductor memory is random
access
What should be its name?
Possible to Read/Write
Volatile
Can be used only as a temporary storage
55
SEMICONDUCTOR MEMORY TYPES
RAM...
DRAM Operation
Address line active when bit read or written
Transistor switch closed (current flows)
Write
Voltage to bit line
High for 1, low for 0
Then signal address line
Transfers charge to capacitor
Read
Address line selected
transistor turns on
Charge from capacitor fed via bit line to sense amplifier
Compares with reference value to determine 0 or 1
58
SEMICONDUCTOR MEMORY TYPES
RAM...
Static RAM Operation
Transistor arrangement gives stable logic state
State 1
C1 high, C2 low
T1 T4 off, T2 T3 on
State 0
C2 high, C1 low
T2 T3 off, T1 T4 on
Less expensive
Needs refresh
Static
Faster
Cache
60
SEMICONDUCTOR MEMORY TYPES...
TYPES OF ROM
Flash memory 61
Can erase selected block rather than the entire memory
SEMICONDUCTOR MEMORY TYPES…
ERROR CORRECTION
Errors in semiconductor memory categorized as
Hard Failure
Permanent physical defect
Soft Error
Random, non-destructive
No permanent damage to memory
Caused by power supply problems
63
SEMICONDUCTOR MEMORY TYPES
ERROR CORRECTION…
Error Correcting Code Function
64
End
of P
a rt
1
65