memory - cornell university...big picture: building a processor pc imm memory target offset control...
TRANSCRIPT
![Page 1: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/1.jpg)
Memory
Hakim WeatherspoonCS 3410, Spring 2013Computer ScienceCornell University
![Page 2: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/2.jpg)
Big Picture: Building a Processor
PC
imm
memory
target
offset cmpcontrol
=?
new pc
memory
din dout
addr
registerfile
inst
extend
+4 +4
A Single cycle processor
alu
![Page 3: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/3.jpg)
Goals for todayReview
• Finite State Machines
Memory• Register Files• Tri‐state devices• SRAM (Static RAM—random access memory)• DRAM (Dynamic RAM)
![Page 4: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/4.jpg)
Which statement(s) is true(A) In a Moore Machine output depends on both current state and input(B) In a Mealy Machine output depends on current state and input(C) In a Mealy Machine output depends on next state and input(D) All the above are true(E) None are true
![Page 5: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/5.jpg)
General Case: Mealy Machine
Outputs and next state depend on bothcurrent state and input
Mealy Machine
Next State
Current State
Input
OutputRe
gistersComb.Logic
![Page 6: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/6.jpg)
Moore Machine
Special Case: Moore Machine
Outputs depend only on current state
Next State
Current State
Input
OutputRe
gisters Comb.Logic
Comb.Logic
![Page 7: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/7.jpg)
Example #2: Digital Door Lock
Digital Door LockInputs:
• keycodes from keypad• clock
Outputs: • “unlock” signal• display how many keys pressed so far
![Page 8: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/8.jpg)
Door Lock: InputsAssumptions:
• signals are synchronized to clock• Password is B‐A‐B
KAB
K A B Meaning0 0 0 Ø (no key)1 1 0 ‘A’ pressed1 0 1 ‘B’ pressed
![Page 9: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/9.jpg)
Door Lock: OutputsAssumptions:
• High pulse on U unlocks door
UD3D2D1D0
4 LEDdec
8
Strategy:(1) Draw a state diagram (e.g. Moore Machine)(2) Write output and next‐state tables(3) Encode states, inputs, and outputs as bits(4) Determine logic equations for next state and outputs
![Page 10: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/10.jpg)
Door Lock: Simplified State Diagram
Idle
G1
”0”
Ø
G2 G3
B1 B2
”1” ”2” ”3”, U
”1” ”2”
Ø Ø
Ø Ø
“B”
“A” “B”
else
else
any
anyelse else
B3”3”
else
(1) Draw a state diagram (e.g. Moore Machine)
![Page 11: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/11.jpg)
Door Lock: Simplified State Diagram
Idle
G1
”0”
Ø
G2 G3
B1 B2
”1” ”2” ”3”, U
”1” ”2”
Ø Ø
Ø Ø
“B”
“A” “B”
else
else
else
anyelse else
(1) Draw a state diagram (e.g. Moore Machine)
![Page 12: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/12.jpg)
Door Lock: Simplified State Diagram
Idle
G1
”0”
Ø
G2 G3
B1 B2
”1” ”2” ”3”, U
”1” ”2”
Ø Ø
Ø Ø
“B”
“A” “B”
else
else
else
anyelse else Cur.State Output
(2) Write output and next‐state tables
![Page 13: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/13.jpg)
Door Lock: Simplified State Diagram
Idle
G1
”0”
Ø
G2 G3
B1 B2
”1” ”2” ”3”, U
”1” ”2”
Ø Ø
Ø Ø
“B”
“A” “B”
else
else
else
anyelse else Cur.State OutputCur.State Output
Idle “0”G1 “1”G2 “2”G3 “3”, UB1 “1”B2 “2”
(2) Write output and next‐state tables
![Page 14: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/14.jpg)
Door Lock: Simplified State Diagram
Idle
G1
”0”
Ø
G2 G3
B1 B2
”1” ”2” ”3”, U
”1” ”2”
Ø Ø
Ø Ø
“B”
“A” “B”
else
else
else
anyelse else
Cur. State Input Next StateCur. State Input Next State
(2) Write output and next‐state tables
![Page 15: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/15.jpg)
Door Lock: Simplified State Diagram
Idle
G1
”0”
Ø
G2 G3
B1 B2
”1” ”2” ”3”, U
”1” ”2”
Ø Ø
Ø Ø
“B”
“A” “B”
else
else
else
anyelse else
Cur. State Input Next StateCur. State Input Next StateIdle Ø IdleIdle “B” G1Idle “A” B1G1 Ø G1G1 “A” G2G1 “B” B2G2 Ø B2G2 “B” G3G2 “A” IdleG3 any IdleB1 Ø B1B1 K B2B2 Ø B2B2 K Idle
(2) Write output and next‐state tables
![Page 16: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/16.jpg)
(3) Encode states, inputs, and outputs as bits
State Table EncodingCur. State Output
Idle “0”G1 “1”G2 “2”G3 “3”, UB1 “1”B2 “2”
UD3D2D1D0
4dec
8
D3 D2 D1 D0 U0 0 0 0 00 0 0 1 00 0 1 0 00 0 1 1 10 0 0 1 00 0 1 0 0
KAB
S2 S1 S00 0 00 0 10 1 00 1 11 0 01 0 1
K A B Meaning0 0 0 Ø (no key)1 1 0 ‘A’ pressed1 0 1 ‘B’ pressed
State S2 S1 S0Idle 0 0 0G1 0 0 1G2 0 1 0G3 0 1 1B1 1 0 0B2 1 0 1
Cur. State Input Next StateIdle Ø IdleIdle “B” G1Idle “A” B1G1 Ø G1G1 “A” G2G1 “B” B2G2 Ø B2G2 “B” G3G2 “A” IdleG3 any IdleB1 Ø B1B1 K B2B2 Ø B2B2 K Idle
S2 S1 S0 S’2 S’1 S’00 0 0 0 0 00 0 0 0 0 10 0 0 1 0 00 0 1 0 0 10 0 1 0 1 00 0 1 1 0 10 1 0 0 1 00 1 0 0 1 10 1 0 0 0 00 1 1 0 0 01 0 0 1 0 01 0 0 1 0 11 0 1 1 0 11 0 1 0 0 0
K A B0 0 01 0 11 1 00 0 01 1 01 0 10 0 01 0 11 1 0x x x0 0 01 x x0 0 01 x x
![Page 17: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/17.jpg)
Door Lock: Implementation4
dec
3bitReg
clk
UD3‐0S2‐0
S’2‐0S2‐0
KAB
D3 D2 D1 D0 U0 0 0 0 00 0 0 1 00 0 1 0 00 0 1 1 10 0 0 1 00 0 1 0 0
S2 S1 S00 0 00 0 10 1 00 1 11 0 01 0 1
(4) Determine logic equations for next state and outputs
U = 2S1S0D0 = 2 1S0 + 2S1S0 + S2 1 0D1 = 2S1S0 + 2S1S0 + 2S1S0
![Page 18: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/18.jpg)
Door Lock: Implementation4
dec
3bitReg
clk
UD3‐0S2‐0
S’2‐0S2‐0
KAB
S2 S1 S0 S’2 S’1 S’00 0 0 0 0 00 0 0 0 0 10 0 0 1 0 00 0 1 0 0 10 0 1 0 1 00 0 1 1 0 10 1 0 0 1 00 1 0 0 1 10 1 0 0 0 00 1 1 0 0 01 0 0 1 0 01 0 0 1 0 11 0 1 1 0 11 0 1 0 0 0
K A B0 0 01 0 11 1 00 0 01 1 01 0 10 0 01 0 11 1 0x x x0 0 01 x x0 0 01 x x
S0’ = ?S1’ = ?S2’ = S2S1S0KAB + S2S1S0KAB + S2S1S2KAB + S2S1S0K + S2 S1S0 KAB
![Page 19: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/19.jpg)
Door Lock: Implementation4
dec
3bitReg
clk
UD3‐0S2‐0
S’2‐0S2‐0
KAB
Strategy:(1) Draw a state diagram (e.g. Moore Machine)(2) Write output and next‐state tables(3) Encode states, inputs, and outputs as bits(4) Determine logic equations for next state and outputs
![Page 20: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/20.jpg)
AdministriviaMake sure partner in same Lab Section this week
Lab2 is outDue in one week, next Monday, start earlyWork aloneSave your work!
• Save often. Verify file is non‐zero. Periodically save to Dropbox, email.• Beware of MacOSX 10.5 (leopard) and 10.6 (snow‐leopard)
Use your resources• Lab Section, Piazza.com, Office Hours, Homework Help Session,• Class notes, book, Sections, CSUGLab
No Homework this week
![Page 21: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/21.jpg)
AdministriviaMake sure to go to your Lab Section this week
• Find project partners this week (for upcoming project1 next week)• Lab2 due in class this week (it is not homework)• Design Doc for Lab1 due yesterday, Monday, Feb 4th • Completed Lab1 due next week, Monday, Feb 11th• Work alone
Homework1 is due Wednesday• Work alone• Academic Integrity
BUT, use your resources• Lab Section, Piazza.com, Office Hours, Homework Help Session,• Class notes, book, Sections, CSUGLab
Second C Primer: Thursday, B14 Hollister, 6‐8pm
![Page 22: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/22.jpg)
Administrivia
Check online syllabus/schedule • http://www.cs.cornell.edu/Courses/CS3410/2013sp/schedule.htmlSlides and Reading for lecturesOffice HoursHomework and Programming AssignmentsPrelims (in evenings):
• Tuesday, February 26th
• Thursday, March 28th
• Thursday, April 25th
Schedule is subject to change
![Page 23: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/23.jpg)
Collaboration, Late, Re‐grading Policies“Black Board” Collaboration Policy• Can discuss approach together on a “black board”• Leave and write up solution independently• Do not copy solutions
Late Policy• Each person has a total of four “slip days”• Max of two slip days for any individual assignment• Slip days deducted first for any late assignment, cannot selectively apply slip days
• For projects, slip days are deducted from all partners • 25% deducted per day late after slip days are exhausted
Regrade policy• Submit written request to lead TA,
and lead TA will pick a different grader • Submit another written request,
lead TA will regrade directly • Submit yet another written request for professor to regrade.
![Page 24: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/24.jpg)
Lab1: Thoughts thus farGreat experience!
But, read all instructions (multiple times)!
Sign up for design doc meetings early• We were very lenient for Lab1• In future, CMS will lock the Friday after release• lose points for not signing up before lock, canceling last minute,
and/or not showing up
Design doc meeting• Not the same as office hours
You are presenting your current design during design doc meeting• Bring printout of your design document• TA will grade and give feedback based on your presentation of your
design
![Page 25: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/25.jpg)
Goals for todayMemory
• CPU: Register Files (i.e. Memory w/in the CPU)• Scaling Memory: Tri‐state devices• Cache: SRAM (Static RAM—random access memory)• Memory: DRAM (Dynamic RAM)
![Page 26: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/26.jpg)
Goal:How do we store results from ALU computations?
How do we use stored results in subsequent operations?
Register File
How does a Register File work? How do we design it?
![Page 27: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/27.jpg)
Goals for Today
Memory: Various technologies• S‐RAM, D‐RAM, NV‐RAM
Non‐Volatile RAM• Data remains valid even through power outages• More expensive• Limited lifetime; after 100000 to 1M writes, NV‐RAM degrades
• Flash cards
![Page 28: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/28.jpg)
Memory
Various technologies• S‐RAM, D‐RAM, NV‐RAM
Static‐RAM• So called because once stored, data values are stable as long as
electricity is supplied• Based on regular flip‐flops with gates
Dynamic‐RAM• Data values require constant refresh• Internal circuitry keeps capacitor charges
Non‐Volatile RAM• Data remains valid even through power outages• More expensive• Limited lifetime; after 100000 to 1M writes, NV‐RAM degrades
![Page 29: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/29.jpg)
Big Picture: Building a Processor
PC
imm
memory
target
offset cmpcontrol
=?
new pc
memory
din dout
addr
registerfile
inst
extend
+4 +4
A Single cycle processor
alu
![Page 30: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/30.jpg)
Register FileRegister File
• N read/write registers• Indexed by register number
Dual‐Read‐PortSingle‐Write‐Port
32 x 32 Register File
QA
QB
DW
RW RA RBW
32
32
32
1 5 5 5
![Page 31: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/31.jpg)
Register FileRecall: Register•D flip‐flops in parallel •shared clock•extra clocked inputs:write_enable, reset, …
clk
D0
D3
D1
D2
4 44‐bitreg
clk
![Page 32: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/32.jpg)
Register File• N read/write registers• Indexed by register number
How to write to one register in the register file?• Need a decoder
Register File
Reg 0
….Reg 30Reg 31
Reg 15‐to‐32decoder
5RW W
D32
![Page 33: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/33.jpg)
Register File• N read/write registers• Indexed by register number
How to write to one register in the register file?• Need a decoder
Activity# write truth table for 3‐to‐8 decoder
Reg 0
….Reg 30Reg 31
Reg 15‐to‐32decoder
5RW W
D32
![Page 34: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/34.jpg)
Register File• N read/write registers• Indexed by register number
How to read from two registers?• Need a multiplexor
Register File32
Reg 0Reg 1….Reg 30Reg 31
MUX
MUX
32QA
32QB
55RBRA
….
….
![Page 35: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/35.jpg)
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
32Reg 0Reg 1….Reg 30Reg 31
MUX
MUX
32QA
32QB
55RBRA
….
….
5‐to‐32decoder
5RWW
D32
![Page 36: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/36.jpg)
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 37: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/37.jpg)
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
What happens if same register read and written during same clock cycle?
![Page 38: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/38.jpg)
Register File tradeoffs+ Very fast (a few gate delays for
both read and write)+ Adding extra ports is
straightforward– Doesn’t scalee.g. 32MB register file with 32 bit registersNeed 32x 1M‐to‐1 multiplexor and 32x 10‐to‐1M decoderHow many logic gates/transistors?
Tradeoffsa
b
c
d
e
f
g
h
s2s1s0
8‐to‐1 mux
![Page 39: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/39.jpg)
TakewayRegister files are very fast storage (only a few gate delays), but does not scale to large memory sizes.
![Page 40: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/40.jpg)
Goals for todayMemory
• CPU: Register Files (i.e. Memory w/in the CPU)• Scaling Memory: Tri‐state devices• Cache: SRAM (Static RAM—random access memory)• Memory: DRAM (Dynamic RAM)
![Page 41: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/41.jpg)
Next GoalHow do we scale/build larger memories?
![Page 42: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/42.jpg)
Building Large MemoriesNeed a shared bus (or shared bit line)
• Many FlipFlops/outputs/etc. connected to single wire• Only one output drives the bus at a time
• How do we build such a device?
S0D0
shared line
S1D1 S2D2 S3D3 S1023D1023
![Page 43: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/43.jpg)
Tri‐State Devices
E
E D Q0 0 z0 1 z1 0 01 1 1
D Q
Tri‐State Buffers• If enabled (E=1), then Q = D• Otherwise, Q is not connected (z = high impedance)
![Page 44: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/44.jpg)
Activity#2: Tri‐State Buffer from an Inverter
Q
Vsupply
Gnd
D
E
E D Q0 0 z0 1 z1 0 01 1 1
D Q
Tri‐State Buffers• If enabled (E=1), then Q = D• Otherwise, Q is not connected (z = high impedance)
![Page 45: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/45.jpg)
Tri‐State Devices
DQ
E Vsupply
Gnd
D
E
E D Q0 0 z0 1 z1 0 01 1 1
D Q
Tri‐State Buffers• If enabled (E=1), then Q = D• Otherwise, Q is not connected (z = high impedance)
![Page 46: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/46.jpg)
Tri‐State Devices
DQ
E Vsupply
Gnd
E
E D Q0 0 z0 1 z1 0 01 1 1
D Q
Tri‐State Buffers• If enabled (E=1), then Q = D• Otherwise, Q is not connected (z = high impedance)
0
0
1
0
off
offz
A B OR NOR
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0
A B AND NAND
0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0
![Page 47: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/47.jpg)
Tri‐State Devices
DQ
E Vsupply
Gnd
E
E D Q0 0 z0 1 z1 0 01 1 1
D Q
Tri‐State Buffers• If enabled (E=1), then Q = D• Otherwise, Q is not connected (z = high impedance)
1
1
1
1
off
on0
0
0A B OR NOR
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0
A B AND NAND
0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0
0
![Page 48: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/48.jpg)
Tri‐State Devices
DQ
E Vsupply
Gnd
E
E D Q0 0 z0 1 z1 0 01 1 1
D Q
Tri‐State Buffers• If enabled (E=1), then Q = D• Otherwise, Q is not connected (z = high impedance)
1
1
0
0 off
on1
1
1A B OR NOR
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0
A B AND NAND
0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0
1
![Page 49: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/49.jpg)
Shared BusS0D0
shared line
S1D1 S2D2 S3D3 S1023D1023
![Page 50: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/50.jpg)
TakewayRegister files are very fast storage (only a few gate delays), but does not scale to large memory sizes.
Tri‐state Buffers allow scaling since multiple registers can be connected to a single output, while only one register actually drives the output.
![Page 51: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/51.jpg)
Goals for todayMemory
• CPU: Register Files (i.e. Memory w/in the CPU)• Scaling Memory: Tri‐state devices• Cache: SRAM (Static RAM—random access memory)• Memory: DRAM (Dynamic RAM)
![Page 52: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/52.jpg)
Next GoalHow do we build large memories?
Use similar designs as Tri‐state Buffers to connect multiple registers to output line. Only one register will drive output line.
![Page 53: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/53.jpg)
Static RAM (SRAM)—Static Random Access Memory• Essentially just D‐Latches plus Tri‐State Buffers• A decoder selects which line of memory to access
(i.e. word line)• A R/W selector determines the
type of access• That line is then coupled to
the data lines
SRAM
Data
Address
Decode
r
![Page 54: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/54.jpg)
Static RAM (SRAM)—Static Random Access Memory• Essentially just D‐Latches plus Tri‐State Buffers• A decoder selects which line of memory to access
(i.e. word line)• A R/W selector determines the
type of access• That line is then coupled to
the data lines
SRAM
Din
8
Dout
8
22Address
Chip SelectWrite EnableOutput Enable
SRAM4M x 8
![Page 55: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/55.jpg)
E.g. How do we design a 4 x 2 SRAM Module?
(i.e. 4 word lines that areeach 2 bits wide)?
SRAM
2‐to‐4decoder
2Address
D Q D Q
D Q D Q
D Q D Q
D Q D Q
Dout[1] Dout[2]
Din[1] Din[2]
enable enable
enable enable
enable enable
enable enable
0
1
2
3Write Enable
Output Enable
4 x 2 SRAM
![Page 56: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/56.jpg)
SRAM
2‐to‐4decoder
2Address
D Q D Q
D Q D Q
D Q D Q
D Q D Q
Dout[1] Dout[2]
Din[1] Din[2]
enable enable
enable enable
enable enable
enable enable
0
1
2
3Write Enable
Output Enable
E.g. How do we design a 4 x 2 SRAM Module?
(i.e. 4 word lines that areeach 2 bits wide)?
![Page 57: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/57.jpg)
SRAM
2‐to‐4decoder
2Address
D Q D Q
D Q D Q
D Q D Q
D Q D Q
Dout[1] Dout[2]
Din[1] Din[2]
enable enable
enable enable
enable enable
enable enable
0
1
2
3Write Enable
Output Enable
Bit line
Word lineE.g. How do we design a 4 x 2 SRAM Module?
(i.e. 4 word lines that areeach 2 bits wide)?
![Page 58: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/58.jpg)
SRAM CellTypical SRAM Cell
B
word linebit line
Each cell stores one bit, and requires 4 – 8 transistors (6 is typical)
Pass‐ThroughTransistors
![Page 59: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/59.jpg)
Disabled (wordline = 0)
SRAM CellTypical SRAM Cell
B
word linebit line
Each cell stores one bit, and requires 4 – 8 transistors (6 is typical)Read:• pre‐charge B and B to Vsupply/2• pull word line high• cell pulls B or B low, sense amp detects voltage difference
1 0
onon
2) Enable (wordline = 1)
1) Pre‐chargeB = Vsupply/2
offoff 3) Cell pulls B lowi.e. B = 0
1) Pre‐charge B = Vsupply/2
3) Cell pulls B highi.e. B = 1
![Page 60: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/60.jpg)
Disabled (wordline = 0)
SRAM CellTypical SRAM Cell
B
word linebit line
Each cell stores one bit, and requires 4 – 8 transistors (6 is typical)Read:• pre‐charge B and B to Vsupply/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
1 0
onon
1) Enable (wordline = 1)
offoff 2) Drive B highi.e. B = 1
2) Drive B lowi.e. B = 0
10→ →
![Page 61: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/61.jpg)
SRAM
2‐to‐4decoder
2Address
D Q D Q
D Q D Q
D Q D Q
D Q D Q
Dout[1] Dout[2]
Din[1] Din[2]
enable enable
enable enable
enable enable
enable enable
0
1
2
3Write Enable
Output Enable
Bit line
Word lineE.g. How do we design a 4 x 2 SRAM Module?
(i.e. 4 word lines that areeach 2 bits wide)?
![Page 62: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/62.jpg)
SRAM
2‐to‐4decoder
2Address
D Q D Q
D Q D Q
D Q D Q
D Q D Q
Dout[1] Dout[2]
Din[1] Din[2]
enable enable
enable enable
enable enable
enable enable
0
1
2
3Write Enable
Output Enable
4 x 2 SRAM
E.g. How do we design a 4 x 2 SRAM Module?
(i.e. 4 word lines that areeach 2 bits wide)?
![Page 63: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/63.jpg)
SRAM
22Address
Dout
Din
Write EnableOutput Enable
4M x 8 SRAM
8
8
E.g. How do we design a 4M x 8 SRAM Module?
(i.e. 4M word lines that are each 8 bits wide)?
Chip Select
![Page 64: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/64.jpg)
SRAM
12Address [21‐10]
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
12 x 4096decoder
mux
1024
mux
1024
mux
1024
mux
1024
mux mux
1024 1024
mux
1024
mux
1024
Dout[7]1
Dout[6]1
Dout[5]1
Dout[4]1
Dout[3]1
Dout[2]1
Dout[1]1
Dout[0]1
Address [9‐0] 10
4M x 8 SRAM
E.g. How do we design a 4M x 8 SRAM Module?
![Page 65: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/65.jpg)
SRAM
12Address [21‐10]
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
4k x 1024SRAM
Row decoder
1024 1024 1024 1024 1024 1024 1024 1024Address [9‐0] 10
4M x 8 SRAM
column selector, sense amp, and I/O circuits
Shared Data Bus
Chip Select (CS)R/W Enable
8
E.g. How do we design a 4M x 8 SRAM Module?
![Page 66: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/66.jpg)
SRAM Modules and Arrays
A21‐0
Bank 2
Bank 3
Bank 4
4M x 8SRAM
4M x 8SRAM
4M x 8SRAM
4M x 8SRAM
R/W
msb lsb
CS
CS
CS
CS
![Page 67: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/67.jpg)
SRAM•A few transistors (~6) per cell•Used for working memory (caches)
•But for even higher density…
SRAM Summary
![Page 68: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/68.jpg)
Dynamic RAM: DRAM
Dynamic‐RAM (DRAM)• Data values require constant refresh
Gnd
word linebit line
Capacitor
Each cell stores one bit, and requires 1 transistors
![Page 69: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/69.jpg)
Dynamic RAM: DRAM
Dynamic‐RAM (DRAM)• Data values require constant refresh
Gnd
word linebit line
Capacitor
Pass‐ThroughTransistors
Each cell stores one bit, and requires 1 transistors
![Page 70: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/70.jpg)
on
Dynamic RAM: DRAM
Dynamic‐RAM (DRAM)
Gnd
word linebit line
Capacitor
Disabled (wordline = 0)
Each cell stores one bit, and requires 1 transistorsRead:• pre‐charge B and B to Vsupply/2• pull word line high• cell pulls B low, sense amp detects voltage difference
0
2) Enable (wordline = 1)
1) Pre‐chargeB = Vsupply/2
off 3) Cell pulls B lowi.e. B = 0
![Page 71: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/71.jpg)
Dynamic‐RAM (DRAM)
on
Dynamic RAM: DRAM
Gnd
word linebit line
Capacitor
Disabled (wordline = 0)
Each cell stores one bit, and requires 4 – 8 transistors (6 is typical)Read:• pre‐charge B and B to Vsupply/2• pull word line high• cell pulls B or B low, sense amp detects voltage differenceWrite:• pull word line high• drive B charges capacitor
0
1) Enable (wordline = 1)
off 2) Drive B highi.e. B = 1Charges capacitor
1→
![Page 72: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/72.jpg)
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 73: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/73.jpg)
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 74: Memory - Cornell University...Big Picture: Building a Processor PC imm memory target offset control cmp new pc memory d in d out addr register file inst extend +4 +4 A Single cycle](https://reader033.vdocuments.site/reader033/viewer/2022041923/5e6cef1487023520bd142a04/html5/thumbnails/74.jpg)
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, …)
Next time we will build a simple processor!