Академический Документы
Профессиональный Документы
Культура Документы
Lecture 15
CS252/Culler
2/5/02
Lec 5.1
Main Memory Background
• Random Access Memory (vs. Serial Access Memory)
• Different flavors at different levels
– Physical Makeup (CMOS, DRAM)
– Low Level Architectures (FPM,EDO,BEDO,SDRAM)
• Cache uses SRAM: Static Random Access Memory
– No refresh (6 transistors/bit vs. 1 transistor
Size: DRAM/SRAM 4-8,
Cost/Cycle time: SRAM/DRAM 8-16
• Main Memory is DRAM: Dynamic Random Access Memory
– Dynamic since needs to be refreshed periodically
– Addresses divided into 2 halves (Memory as a 2D matrix):
» RAS or Row Access Strobe
» CAS or Column Access Strobe
CS252/Culler
2/5/02
Lec 5.2
Static RAM (SRAM)
• Six transistors in cross connected fashion
– Provides regular AND inverted outputs
– Implemented in CMOS process
Bit Line
.
.
.
Sense Amp
CS252/Culler
2/5/02
Lec 5.4
DRAM logical organization (4 Mbit)
•Access time of DRAM = Row access time + column
access time + refreshing
Column Decoder D
…
11 Sense Amps & I/O
Q
Row Decoder
A0…A10
… Memory Array
(2,048 x 2,048)
Storage
Word Line Cell
CS252/Culler
2/5/02
Lec 5.5
Other Types of DRAM
• Synchronous DRAM (SDRAM): Ability to transfer a burst
of data given a starting address and a burst length – suitable for
transferring a block of data from main memory to cache.
• Page Mode DRAM: All bits on the same ROW
(Spatial Locality)
– Don’t need to wait for wordline to recharge
– Toggle CAS with new column address
• Extended Data Out (EDO)
– Overlap Data output w/ CAS toggle
– Later brother: Burst EDO (CAS toggle used to get next addr)
CS252/Culler
2/5/02
Lec 5.6
Main Memory Organizations
CPU CPU CPU
Multiplexor
Cache Cache
Cache
one-word wide
memory organization DRAM access time >> bus transfer time
CS252/Culler
2/5/02
Lec 5.7
Memory Interleaving
Module accessed
Addresses that
0
are 0 mod 4
1
Addresses that 2
Add- are 1 mod 4 Data
ress Dispatch out 3
(based on Return
2 LSBs of data 0
Data address) Addresses that
in are 2 mod 4 1
2
Bus cycle
Addresses that
3
are 3 mod 4 Memory cycle Time
CS252/Culler
2/5/02
Lec 5.8
Memory Access Time Example
CS252/Culler
2/5/02
Lec 5.9
Virtual Memory
• Idea 1: Many Programs sharing DRAM Memory so that
context switches can occur
• Idea 2: Allow program to be written without memory
constraints – program can exceed the size of the main
memory
• Idea 3: Relocation: Parts of the program can be
placed at different locations in the memory instead of a
big chunk.
• Virtual Memory:
(1) DRAM Memory holds many programs running
at same time (processes)
(2) use DRAM Memory as a kind of “cache” for
disk
CS252/Culler
2/5/02
Lec 5.10
Memory Hierarchy: The Big Picture
Virtual
memory
Main memory
Cache
Registers
Words
Lines
(transferred Pages
explicitly (transferred
via load/store) automatically (transferred
upon cache miss) automatically
upon page fault)
CS252/Culler
2/5/02
Lec 5.11
Virtual Memory has own terminology
• Each process has its own private “virtual address space” (e.g.,
232 Bytes); CPU actually generates “virtual addresses”
• Each computer has a “physical address space” (e.g., 128
MegaBytes DRAM); also called “real memory”
• Address translation: mapping virtual addresses to physical
addresses
– Allows multiple programs to use (different chunks of physical)
memory at same time
– Also allows some chunks of virtual memory to be represented on
disk, not in main memory (to exploit memory hierarchy)
CS252/Culler
2/5/02
Lec 5.12
Mapping Virtual Memory to Physical Memory
• Divide Memory into equal sized
∞
Virtual Memory
“chunks” (say, 4KB each)
Physical Memory
64 MB Single
Process
Heap
Heap
Static
Code
0 0 CS252/Culler
2/5/02
Lec 5.13
Handling Page Faults
• A page fault is like a cache miss
– Must find page in lower level of hierarchy
• If valid bit is zero, the Physical Page Number
points to a page on disk
• When OS starts new process, it creates space
on disk for all the pages of the process, sets all
valid bits in page table to zero, and all Physical
Page Numbers to point to disk
– called Demand Paging - pages of the process are loaded from
disk only as needed
CS252/Culler
2/5/02
Lec 5.14
Comparing the 2 levels of
hierarchy
• Cache Virtual Memory
• Block or Line Page
• Miss Page Fault
• Block Size: 32-64B Page Size: 4K-16KB
• Placement: Fully Associative
Direct Mapped,
N-way Set Associative
• Replacement: Least Recently Used
LRU or Random (LRU) approximation
• Write Thru or Back Write Back
• How Managed: Hardware + Software
Hardware (Operating System)
CS252/Culler
2/5/02
Lec 5.15
How to Perform Address
Translation?
• VM divides memory into equal sized pages
• Address translation relocates entire pages
– offsets within the pages do not change
– if make page size a power of two, the virtual address
separates into two fields:
CS252/Culler
2/5/02
Lec 5.16
Mapping Virtual to Physical Address
Virtual Address
31 30 29 28 27 .………………….12 11 10 9 8 ……..……. 3 2 1 0
1KB page
Translation size
29 28 27 .………………….12 11 10 9 8 ……..……. 3 2 1 0
CS252/Culler
2/5/02
Lec 5.18
Address Translation: Page Table
Virtual Address (VA):
virtual page nbr offset
Page Table
Page Table ...
Register V A.R. P. P. N.
index Val Access Physical +
into -id Rights Page
page Number Physical
table V A.R. P. P. N. Memory
0 A.R. Address (PA)
Page Table
...
is located Access Rights: None, Read Only,
in physical Read/Write, Executable
memory
2/5/02 disk CS252/Culler
Lec 5.19
Page Tables and Address Translation
Page table
register Page table
Virtual
page
number
Valid
bits
Other
flags
Main memory
Pointer
Flags
Per mission bits
To disk memory Main memory
CS252/Culler
2/5/02
Lec 5.22
How Translate Fast?
• Problem: Virtual Memory requires two memory accesses!
– one to translate Virtual Address into Physical Address (page table
lookup)
– one to transfer the actual data (cache hit)
– But Page Table is in physical memory! => 2 main memory accesses!
• Observation: since there is locality in pages of data, must
be locality in virtual addresses of those pages!
• Why not create a cache of virtual to physical address
translations to make translation fast? (smaller is faster)
• For historical reasons, such a “page table cache” is called
a Translation Lookaside Buffer, or TLB
CS252/Culler
2/5/02
Lec 5.23
Typical TLB Format
Virtual Physical Valid Ref Dirty Access
Page Nbr Page Nbr Rights
“tag” “data”
•TLB just a cache of the page table mappings
TLB tags
Translation
Tags match
and ent ry
is valid
Physical
page number Physical
Other
flags address
CS252/Culler
2/5/02
Lec 5.26
31 30 29 15 14 13 12 11 10 9 8 3210 DECStation 3100/
Virtual Address Virtual page number Page offset MIPS R2000
20 12
TLB
TLB hit
64 entries,
fully 20
associative
Cache
16K entries,
direct 32
mapped
Data CS252/Culler
2/5/02 Cache hit Lec 5.27
Test 2, Dec 5 (Tuesday)
Topics:
1. Compiler+VLIW: Sections 4.1-4.3, Lectures 9 and
paper 9a
2. multithreading and multimedia: Lecture 10
3. Network Processors: Lectures 11, 11a and 12
4. Cache Memory: Sections Sections 5.1-5.7 and
Lectures 13,14
5. Memory Organization and Virtual Memory:
Sections 5.8-5.10 and Lecture 15
CS252/Culler
2/5/02
Lec 5.28