2.2 CU Memory System Design
2.2 CU Memory System Design
Jayashree Mohanty
E15737
Assistant Professor DISCOVER . LEARN . EMPOWER
1
CSE(AIT), CU
About Course
This course is introduced to 4th semester students of
BE
This course offers a good understanding of the various
functional units of a computer system and prepares the
students to be in a position to design a basic computer
system
In addition to this students will be exposed to the recent
trends in parallel and distributed computing and
multithreaded application
Basic Organization
Memory Cell Operation
• Represent two stable/semi-stable states representing
1 and 0
• Capable of being written to at least once
• Capable of being read multiple times
Semiconductor Memory Types
• Random Access Memory (RAM)
• Read Only Memory (ROM)
• Programmable Read Only Memory (PROM)
• Eraseable Programmable Read Only Memory (EPROM)
• Electronically Eraseable Programmable Read Only Memory (EEPROM)
• Flash Memory
Random Access Memory
• ^RAS (row address select) strobes the row address in to its buffer or
latch while ^CAS (column address select) strobes the column address
into its buffer or latch.
• Note: one more pin on the address quadruples the size of the matrix
(doubles rows and doubles columns for an increase by factor of four)
• To make 16 bit wide data bus, you'll need four of these example
modules
DRAM Refresh
• Two things discharge a DRAM capacitor
• Data read
• Leakage current
• Need refreshing even when powered and idle (once every
few milliseconds)
• Refresh circuit included on chip – Even with added cost,
still cheaper than SRAM cost
• Refresh process involves disabling chip, then reading data
and writing it back
• Performed by counting through “rows”
• Takes time – Slows down apparent performance
DRAM Organization Example
Module
Organization:
Using multiple
memories in
parallel to
increase data
bus width
Module Organization: Using chip selects to
increase the number of words
Advanced DRAM Organization
• Memory Hierarchy
• Main Memory
• Auxiliary Memory
• Associative Memory
• Cache Memory
• Virtual Memory
• Memory Management
Hardware
MEMORY HIERARCHY
CPU Cach
memory
e
Registe
r
Cach
e
Main Memory
Magnetic Disk
Magnetic Tape
Main Memory
MAIN MEMORY
RAM and ROM
Chips
Typical RAM chip
Chip select CS1
1
Chip select CS
2 Rea 2
RD 128 x 8-bit data
d 8RAM bus
Write WR
7-bit AD 7
address
Decoder
3 2 1 0
CS1
CS2
Data
RD 128 x 8
RAM 1
WR
AD7
CS1
CS2
Data
RD 128 x 8
RAM 2
WR
AD7
CS1
CS2
Data
RD 128 x 8
RAM 3
WR
AD7
CS1
CS2
Data
RD 128 x 8
RAM 4
WR
AD7
CS1
CS2
Data
1- 7 512 x 8
8
9 } AD
9
ROM
Auxiliary Memory
AUXILIARY MEMORY
Auxiliary memory units are among computer peripheral equipment. They trade
slower access rates for greater storage capacity and data stability. Auxiliary
memory holds programs and data for future use, and, because it is nonvolatile
(like ROM), it is used to store inactive programs and to archive data.
Organization of Disk
Hardware
Track
Associative Memory
ASSOCIATIVE MEMORY
- Accessed by the content of the data rather than by an address
Hardware
- Also called Content Addressable Memory (CAM)
Organization
Argument register(A)
Input Associative
memory
array and
logic M
Rea m words
d
Write n bits per word
ORGANIZATION OF CAM
A1 Aj An
K1 Kj Kn
Word m Cm Cm Cm Mm
1 j n
Bit 1 Bit j Bit n
Write
R S
F ij Match To M i
Rea logic
d
Output
Associative Memory
MATCH LOGIC
K1 A1 K2 A2 Kn An
Mi
Cache Memory
CACHE MEMORY
Locality of Reference
- The references to memory at any given time
interval tend to be confined within a localized areas
- This area contains a set of information and
the membership changes gradually as time goes by
- Temporal Locality
The information which will be used in near future
is likely to be in use already( e.g. Reuse of information in loops)
- Spatial Locality
If a word is accessed, adjacent(near) words are likely accessed soon
(e.g. Related data items (arrays) are usually stored together;
instructions are executed sequentially)
Cache
- The property of Locality of Reference makes the
Cache memory systems work
- Cache is a fast small capacity memory that should hold those information
which are most likely to be accessed
Main memory
CPU
Cache
memory
Cache Memory
PERFORMANCE OF CACHE
Memory Access
All the memory accesses are directed first to Cache
If the word is in Cache; Access cache to provide it to CPU
If the word is not in Cache; Bring a block (or a line)
including
that word to replace a block now in Cache
Te = Tc + (1 - h) Tm
Argument register
Address Dat
01000 3a4 5 0
CAM 0277 671
7
2223 0
1234
5
Cache Memory
01777 4560
02000 5670
777 02 6710
02777 6710
Cache Memory
DIRECT MAPPING
Operation
Block 63 77 0
0
77 2
0 671
7 2 0
Cache Memory
Operation
- CPU generates a memory address(TAG; INDEX)
- Access Cache with INDEX, (Cache word = (tag 0, data 0); (tag 1, data
1))
- Compare TAG and tag 0 and then tag 1
- If tag i = TAG -> Hit, CPU <- data i
- If tag i TAG -> Miss,
Replace either (tag 0, data 0) or (tag 1, data 1),
Assume (tag 0, data 0) is selected for replacement,
(Why (tag 0, data 0) instead of (tag 1, data 1) ?)
M[tag 0, INDEX] <- Cache[INDEX](data 0)
Cache[INDEX](tag 0, data 0) <- (TAG, M[TAG,INDEX]),
CPU <- Cache[INDEX](data 0)
Cache Memory
Modifications
Initially all U0 = U1 = 1
When Hit to (tag 0, data 0, U0), U1 <- 1(least recently used)
(When Hit to (tag 1, data 1, U1), U0 <- 1(least recently used))
When Miss, find the least recently used one(Ui=1)
If U0 = 1, and U1 = 0, then replace (tag 0, data 0)
M[tag 0, INDEX] <- Cache[INDEX](data 0)
Cache[INDEX](tag 0, data 0, U0) <- (TAG,M[TAG,INDEX], 0); U1 <-
1
If U0 = 0, and U1 = 1, then replace (tag 1, data 1)
Similar to above; U0 <- 1
If U0 = U1 = 0, this condition does not exist
If U0 = U1 = 1, Both of them are candidates,
Take arbitrary selection
Cache Memory
CACHE WRITE
Write Through
When writing into memory
If Hit, both Cache and memory is written in parallel
If Miss, Memory is written
For a read miss, missing block may be
overloaded onto a cache block
Memory is always updated
-> Important when CPU and DMA I/O are both executing
Slow, due to the memory access time
Write-Back (Copy-Back)
When writing into memory
If Hit, only Cache is written
If Miss, missing block is brought to Cache and write into Cache
For a read miss, candidate block must be
written back to the memory
Memory is not up-to-date, i.e., the same item in
Cache and memory may have different value
Virtual Memory
VIRTUAL MEMORY
Give the programmer the illusion that the system has a very large memory,
even though the computer actually has a relatively small main memory
Address Mapping
Memory Mapping Table for Virtual Address -> Physical Address
Virtual address
Physical
Address
Memory table Main memory
buffer register buffer register
Virtual Memory
ADDRESS MAPPING
Address Space and Memory Space are each divided
into fixed size group of words called blocks or
pages
Page 0
Page 1
1K words group Page 2
Address Memory space Block 0
Page 3
space M = 4K = 212 Block 1
N = 8K = 213 Page 4
Block 2
Page 5
Block 3
Page 6
Page 7
Organization of memory Mapping Table in a paged system
Page Line number
no.
1 0 1 0 1 0 1 0 1 0 0 1 1 Virtual address
Table Presenc
addres bit
e
s 000 0 Main memory
001 11 1 Block 0
010 00 1 Block 1
011 0 01 0101010011 Block 2
100 0 Block 3
Main memory
101 01 1 address
Memory page 110 10 1 register
table 111 0 MBR
01 1
Virtual Memory
1 0 1 0 0 Key register
0 0 1 1 1
0 1 0 0 0 Associative memory
1 0 1 0 1
1 1 0 1 0
Page no.Block no.
Page Fault
Page number cannot be found in the Page
Table
Virtual Memory
PAGE FAULT
3 Page is on backing
1. Trap to the OS store
O
2. Save the user registers and program state S
PAGE REPLACEMENT
Decision on which page to displace to make room
for
an incoming page when no free frame is available
Modified page fault service
1. Find the location of the desired page on the backing store
routine
2. Find a free frame
- If there is a free frame, use it
- Otherwise, use a page-replacement algorithm to select a victim
frame
- Write the victim page to the backing store
3. Read the desired page into the (newly) free frame
valid
4. Restart the user process
frame / invalid swap
bit out
1 victi
p
mage
2 change to
f 0 v i invali victi
m 3
4 d swap
f v reset page
table for desired
new page page in
backing store
page table
physical memory
Virtual Memory
FIFO algorithm selects the page that has been in memory the longest
time
Using a-queue - every time a page is loaded, its
identification is inserted in the queue
Easy to implement
May result in a frequent page fault
Optimal Replacement (OPT) - Lowest page fault rate of all
algorithms
Replace that page which will not be used for the longest period of
time
Reference
7string
0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 2 2 2 7
0 0 0 0 4 0 0 0
1 1 3 3 3 1 1
Page
frames
Virtual Memory
Reference
7string
0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
7 7 7 2 2 4 4 4 0 1 1 1
0 0 0 0 0 0 3 3 3 0 0
1 1 3 3 2 2 2 2 2 7
Page
frames
2 7
1 2
0 1
7 0
LRU Approximation 4 4
SEGMENTATION
- A memory management scheme which supports
user's view of memory
- A logical address space is a collection of segments
- Each segment has a name and a length
- Address specify both the segment name and the
offset within the segment.
- For simplicity of implementations, segments are
numbered.
Segmentation Segment Table
Hardware
s
limi base
t
CPU (s,d)
Memory
y
< +
n
error
Memory Management Hardware
SEGMENTATION EXAMPLE
1400
Subroutine Stac Segment
k
Segment 0
Segment 3 2400
0
Symbol
Table 3200
SHARING OF SEGMENTS
Editor
limit 43062
base
0 25286
Segment 1 43062
4425 68348 Editor
0
Data 1 Segment Table
(User 1) 6834
Segment Data 1 8
7277
1 3
Logical Memory
(User 1)
90003
Data
2 9855
6
limit
Editor base
0 25286
1 43062
8550 90003 Physical Memory
Segment
0 Segment Table
Data (User 2)
2
Segment
1
Logical Memory
(User 2)
Memory Management Hardware
Logical
address
Segmen Pag Word
t e
Segment Page
table table
Block Word
Physical
address
Memory Management Hardware
EXAMPLE
Logical and Physical Addresses
Logical address format: 16 segments of 256 pages
each, each page has 256words
4 8 8
Segment Page Word
20
2 x 32
Physical Physical address format: 4096 blocks of 256 words
memory each, each word has 32bits
12 8
Block Word
Associative memory
mapping Segment Page Block
6 02 019
6 04 A61
Memory Management Hardware
MEMORY PROTECTION
Hash
Function Real Address Data
TLB
Cache
S S
Cache Entry
Cache Set
Cache Operation Flow Chart
Read Out
Virtual Address Format - Example
31 21 20 17 12 11 10 4 3 2 1 0
Byte within
Select set Select set word
in TLB in cache
Map through Word within
page directory Map through
page table Line number line
• Text Books:
• Computer System Architecture M. M. Mano:, 3rd ed., Prentice Hall of India,
New Delhi, 1993.
• Computer Organization and Design: The Hardware/Software Interface, David
A. Patterson and John L. Hennessy.
• Computer Organization and Embedded Systems, Carl Hamacher.
74
Please Send Your Queries on:
e-Mail: jayashree.e15737@cumail.in
75