Memory
description
Transcript of Memory
![Page 1: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/1.jpg)
Hakim WeatherspoonCS 3410, Spring 2011
Computer ScienceCornell University
Memory
See: P&H Appendix C.8, C.9
![Page 2: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/2.jpg)
2
Announcements
HW1 due today
HW2 available later todayHW2 due in one week and a halfWork aloneUse your resources
• FAQ, class notes, book, Sections, office hours, newsgroup, CSUGLab
Make sure you• Registered for class, can access CMS, have a Section, and have a
project partner• Check online syllabus/schedule, review slides and lecture notes,
Office Hours, early homework and programming assignments
![Page 3: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/3.jpg)
3
Announcements
Prelims: Evening of Thursday, March 10 and April 28th
Late Policy1) Each person has a total of four “slip days”2) For projects, slip days are deducted from all partners 3) 10% deducted per day late after slip days are exhausted
![Page 4: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/4.jpg)
4
Critical PathWhich operation is the critical path?• A) AND• B) OR• C) ADD/SUB• D) LT
![Page 5: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/5.jpg)
5
Critical PathWhat is the length of the critical path (in gates)?• A) 3• B) 5• C) 7• D) 9
![Page 6: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/6.jpg)
6
Critical PathWhat is the length of the critical path for a 32-bit
ALU (in gates)?• A) 9• B) 32• C) 64• D) 69
![Page 7: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/7.jpg)
7
Multiplexor
![Page 8: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/8.jpg)
8
Multiplexor
![Page 9: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/9.jpg)
9
Goals for todayReview• SR Latches, D Latches, D Flip Flips, and Registers
Memory• Register Files• Tri-state devices• SRAM (Static RAM—random access memory)• DRAM (Dynamic RAM)
![Page 10: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/10.jpg)
Bistable Devices
A B A Simple Device
• Stable and unstable equilibria?
![Page 11: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/11.jpg)
Bistable Devices
• In stable state, A = B
• How do we change the state?
A B
A B
1
A B
10 0
A Simple Device
• Stable and unstable equilibria?
![Page 12: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/12.jpg)
12
SR Latch
S
R
Q
Q
![Page 13: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/13.jpg)
13
SR Latch
S R Q Q0 0
0 1
1 0
1 1
S
RQ
Q
Set-Reset (SR) LatchStores a value Q and its complement Q
![Page 14: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/14.jpg)
14
SR Latch
Set-Reset (SR) LatchStores a value Q and its complement Q
S R Q Q0 0 Q Q
0 1 0 1
1 0 1 0
1 1 forbidden
S
R
Q
Q
S
RQ
Q
![Page 15: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/15.jpg)
15
Unclocked D Latch
Data (D) Latch
D Q Q
0
1
S
R
D Q
Q
![Page 16: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/16.jpg)
16
Unclocked D Latch
Data (D) Latch
D Q Q
0 0 1
1 1 0
S
R
D Q
Q
Data Latch• Easier to use than an SR latch• No possibility of entering an undefined state
When D changes, Q changes– … immediately (after a delay of 2 Ors and 2 NOTs)
Need to control when the output changes
![Page 17: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/17.jpg)
17
D Latch with Clock
S
R
D
clk
Q
Q
Level Sensitive D LatchClock high: set/reset (according to D)Clock low: keep state (ignore D)
D Q Q
0 0 1
1 1 0
![Page 18: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/18.jpg)
18
D Latch with Clock
S
R
D
clk
Q
Q
S R Q Q0 0 Q Q
0 1 0 1
1 0 1 0
1 1 forbidden
D Q Q
0 0 1
1 1 0
clk D Q Q0 0 Q Q
0 1 Q Q
1 0 0 1
1 1 1 0
![Page 19: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/19.jpg)
19
D Latch with Clock
S
R
D
clk
Q
Q
D Q Q
0 0 1
1 1 0
clk D Q Q0 0 Q Q
0 1 Q Q
1 0 0 1
1 1 1 0
clk
DQ
![Page 20: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/20.jpg)
20
Edge-Triggered D Flip-FlopD Flip-Flop• Edge-Triggered• Data is captured
when clock is high• Outputs change only
on falling edges
D QQ
D QQc
FL L
clk
D
F
Q
c
Q
Q
D
clk
![Page 21: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/21.jpg)
21
RegistersRegister• D flip-flops in parallel • shared clock• extra clocked inputs:
write_enable, reset, …
clk
D0
D3
D1
D2
4 44-bitreg
![Page 22: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/22.jpg)
22
Voting Machine
mux
32
...reg
dete
ct
enc
3
decoder (3-to-8)
32 32
32
LED
dec
3
E
+1
regE
regE
regE
mux
![Page 23: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/23.jpg)
23
Goals for todayReview• SR Latches, D Latches, D Flip Flips, and Registers
Memory• Register Files• Tri-state devices• SRAM (Static RAM—random access memory)• DRAM (Dynamic RAM)
![Page 24: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/24.jpg)
24
Register FileRegister File• N read/write registers• Indexed by
register number
Implementation:• D flip flops to store bits• Decoder for each write port• Mux for each read port
Dual-Read-PortSingle-Write-Port
32 x 32 Register File
QA
QB
DW
RW RA RBW
32
32
32
1 5 5 5
![Page 25: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/25.jpg)
25
Register FileRegister File• N read/write registers• Indexed by
register number
Implementation:• D flip flops to store bits• Decoder for each write port• Mux for each read port
Dual-Read-PortSingle-Write-Port
32 x 32 Register File
QA
QB
DW
RW RA RBW
32
32
32
1 5 5 5
![Page 26: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/26.jpg)
26
Register FileRegister File• N read/write registers• Indexed by
register number
Implementation:• D flip flops to store bits• Decoder for each write port• Mux for each read port
Dual-Read-PortSingle-Write-Port
32 x 32 Register File
QA
QB
DW
RW RA RBW
32
32
32
1 5 5 5
![Page 27: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/27.jpg)
27
TradeoffsRegister File tradeoffs
+ Very fast (a few gate delays for both read and write)+ Adding extra ports is straightforward– Doesn’t scale
![Page 28: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/28.jpg)
28
Building Large MemoriesNeed a shared bus (or shared bit line)• Many FFs/outputs/etc. connected to single wire• Only one output drives the bus at a time
![Page 29: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/29.jpg)
29
Tri-State Devices
DQ
E E Vdd
Gnd
E D Q0 0 z0 1 z1 0 01 1 1
D QD
Tri-State Buffers
![Page 30: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/30.jpg)
30
Shared BusS0D0
shared line
S1D1 S2D2 S3D3 S1023D1023
![Page 31: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/31.jpg)
31
SRAMStatic RAM (SRAM)• Essentially just SR Latches + tri-states buffers
![Page 32: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/32.jpg)
32
SRAM Chip
![Page 33: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/33.jpg)
33
SRAM Chip
row
dec
oder
A21-10 column selector, sense amp, and I/O circuitsA9-0
CSR/W
Shared Data Bus
![Page 34: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/34.jpg)
34
SRAM CellTypical SRAM Cell
BB
word linebit l
ine
Each cell stores one bit, and requires 4 – 8 transistors (6 is typical)Read:• pre-charge B and B to Vdd/2• pull word line high• cell pulls B or B low, sense amp detects voltage differenceWrite:• pull word line high• drive B and B to flip cell
![Page 35: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/35.jpg)
35
SRAM Modules and Arrays
A21-0
Bank 2
Bank 3
Bank 4
1M x 4SRAM
1M x 4SRAM
1M x 4SRAM
1M x 4SRAM
R/W
msb lsb
CS
CS
CS
CS
![Page 36: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/36.jpg)
36
SRAM• A few transistors (~6) per cell• Used for working memory (caches)• But for even higher density…
SRAM Summary
![Page 37: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/37.jpg)
37
Dynamic RAM: DRAM
Dynamic-RAM (DRAM)• Data values require constant refresh
Gnd
word linebit l
ine
Capacitor
![Page 38: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/38.jpg)
38
Single transistor vs. many gates• Denser, cheaper ($30/1GB vs. $30/2MB)• But more complicated, and has analog sensing
Also needs refresh• Read and write back…• …every few milliseconds• Organized in 2D grid, so can do rows at a time• Chip can do refresh internally
Hence… slower and energy inefficient
DRAM vs. SRAM
![Page 39: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/39.jpg)
39
MemoryRegister File tradeoffs
+ Very fast (a few gate delays for both read and write)+ Adding extra ports is straightforward– Expensive, doesn’t scale– Volatile
Volatile Memory alternatives: SRAM, DRAM, …– Slower+ Cheaper, and scales well– Volatile
Non-Volatile Memory (NV-RAM): Flash, EEPROM, …+ Scales well– Limited lifetime; degrades after 100000 to 1M writes
![Page 40: Memory](https://reader035.fdocuments.us/reader035/viewer/2022081604/56816932550346895de08543/html5/thumbnails/40.jpg)
40
SummaryWe now have enough building blocks to build
machines that can perform non-trivial computational tasks
Register File: Tens of words of working memorySRAM: Millions of words of working memoryDRAM: Billions of words of working memoryNVRAM: long term storage
(usb fob, solid state disks, BIOS, …)