720 likes | 872 Views
Memory. Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University. Big Picture: Building a Processor. memory. register file. inst. alu. +4. +4. addr. =?. PC. d in. d out. control. cmp. offset. memory. new pc. target. imm. extend.
E N D
Memory Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University
Big Picture: Building a Processor memory registerfile inst alu +4 +4 addr =? PC din dout control cmp offset memory new pc target imm extend A Single cycle processor
Goals for today Review • Finite State Machines Memory • Register Files • Tri-state devices • SRAM (Static RAM—random access memory) • DRAM (Dynamic RAM)
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
Mealy Machine • General Case: Mealy Machine • Outputs and next state depend on bothcurrent state and input Current State Comb.Logic Registers Output Input Next State
Moore Machine • Special Case: Moore Machine • Outputs depend only on current state Current State Comb.Logic Registers Output Comb.Logic Input Next State
Example #2: Digital Door Lock • Digital Door Lock • Inputs: • keycodes from keypad • clock • Outputs: • “unlock” signal • display how many keys pressed so far
Door Lock: Inputs • Assumptions: • signals are synchronized to clock • Password is B-A-B K A B
Door Lock: Outputs • Assumptions: • High pulse on U unlocks door LEDdec 4 8 D3D2D1D0 U 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
Door Lock: Simplified State Diagram Ø Ø “A” “B” G3 G1 G2 ”3”, U ”1” ”2” else else “B” any Idle ”0” Ø else any else else B1 B2 B3 ”1” ”2” ”3” Ø Ø (1) Draw a state diagram (e.g. Moore Machine)
Door Lock: Simplified State Diagram Ø Ø “A” “B” G3 G1 G2 ”3”, U ”1” ”2” else else “B” any Idle ”0” else Ø else else B1 B2 ”1” ”2” Ø Ø (1) Draw a state diagram (e.g. Moore Machine)
Door Lock: Simplified State Diagram Ø Ø “A” “B” G3 G1 G2 ”3”, U ”1” ”2” else else “B” any Idle ”0” else Ø else else B1 B2 ”1” ”2” Ø Ø (2) Write output and next-state tables
Door Lock: Simplified State Diagram Ø Ø “A” “B” G3 G1 G2 ”3”, U ”1” ”2” else else “B” any Idle ”0” else Ø else else B1 B2 ”1” ”2” Ø Ø (2) Write output and next-state tables
Door Lock: Simplified State Diagram Ø Ø “A” “B” G3 G1 G2 ”3”, U ”1” ”2” else else “B” any Idle ”0” else Ø else else B1 B2 ”1” ”2” Ø Ø (2) Write output and next-state tables
Door Lock: Simplified State Diagram Ø Ø “A” “B” G3 G1 G2 ”3”, U ”1” ”2” else else “B” any Idle ”0” else Ø else else B1 B2 ”1” ”2” Ø Ø (2) Write output and next-state tables
State Table Encoding K A 4 8 D3D2D1D0 B dec U (3) Encode states, inputs, and outputs as bits
Door Lock: Implementation 4 D3-0 dec S2-0 3bitReg U clk S2-0 K S’2-0 A B U = S1S0 D0 = S0 + S1S0 + S2 D1 = S1S0 + S1S0 + S1S0 (4) Determine logic equations for next state and outputs
Door Lock: Implementation 4 D3-0 dec S2-0 3bitReg U clk S2-0 K S’2-0 A B S0’ = ? S1’ = ? S2’ = KA + S0KB + S2 + S1S0K + S2 S0
Door Lock: Implementation 4 D3-0 dec S2-0 3bitReg U clk S2-0 K S’2-0 A B 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
Administrivia • Make sure to go to your Lab Section this week • Find project partners this week (for upcoming project1 next week) • Lab2due 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
Administrivia Check online syllabus/schedule • http://www.cs.cornell.edu/Courses/CS3410/2013sp/schedule.html • Slides and Reading for lectures • Office Hours • Homework and Programming Assignments • Prelims (in evenings): • Tuesday, February 26th • Thursday, March 28th • Thursday, April 25th Schedule is subject to change
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.
Lab1: Thoughts thus far • Great 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
Goals for today Memory • 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)
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?
Big Picture: Building a Processor memory registerfile inst alu +4 +4 addr =? PC din dout control cmp offset memory new pc target imm extend A Single cycle processor
Register File • Register File • N read/write registers • Indexed by register number Dual-Read-PortSingle-Write-Port 32 x 32 Register File QA 32 DW 32 QB 32 W RW RA RB 1 5 5 5
Register File • Recall: Register • D flip-flops in parallel • shared clock • extra clocked inputs:write_enable, reset, … D0 D1 D2 D3 4-bit reg 4 4 clk clk
Register File 32 • Register File • N read/write registers • Indexed by register number • How to write to one register in the register file? • Need a decoder D …. Reg30 Reg31 Reg 1 Reg 0 5-to-32 decoder 5 RW W
Activity# write truth table for 3-to-8 decoder 32 • Register File • N read/write registers • Indexed by register number • How to write to one register in the register file? • Need a decoder D …. Reg30 Reg31 Reg 1 Reg 0 5-to-32 decoder 5 RW W
Register File • Register File • N read/write registers • Indexed by register number • How to read from two registers? • Need a multiplexor 32 …. Reg 0 Reg 1 32 M U X …. QA Reg30 Reg31 M U X 32 …. QB 5 5 RA RB
Register File 32 • Register 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 32 D …. Reg30 Reg31 Reg 1 Reg 0 32 M U X …. QA 5-to-32 decoder M U X 32 …. QB 5 5 5 RA W RW RB
Register File • Register 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 32 DW 32 QB 32 W RW RA RB 1 5 5 5
Register File • Register 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?
Tradeoffs 8-to-1 mux a • Register File tradeoffs + Very fast (a few gate delays for both read and write) + Adding extra ports is straightforward – Doesn’t scale e.g. 32MB register file with 32 bit registers Need 32x 1M-to-1 multiplexor and 32x 10-to-1M decoder How many logic gates/transistors? b c d e f g h s2 s1 s0
Takeway • Register files are very fast storage (only a few gate delays), but does not scale to large memory sizes.
Goals for today Memory • 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)
Next Goal • How do we scale/build larger memories?
Building Large Memories • Need 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? D0 S0 D1 S1 D2 S2 D3 S3 D1023 S1023 shared line
Tri-State Devices • Tri-State Buffers • If enabled (E=1), then Q = D • Otherwise, Q is not connected (z = high impedance) E D Q
Activity#2: Tri-State Buffer from an Inverter • Tri-State Buffers • If enabled (E=1), then Q = D • Otherwise, Q is not connected (z = high impedance) E Vsupply D Q D Q Gnd
Tri-State Devices • Tri-State Buffers • If enabled (E=1), then Q = D • Otherwise, Q is not connected (z = high impedance) E Vsupply E D Q D D Q Gnd
Tri-State Devices • Tri-State Buffers • If enabled (E=1), then Q = D • Otherwise, Q is not connected (z = high impedance) E Vsupply E D Q 0 1 off D Q z 0 0 off Gnd
Tri-State Devices • Tri-State Buffers • If enabled (E=1), then Q = D • Otherwise, Q is not connected (z = high impedance) E Vsupply E D Q 1 1 off D 0 0 Q 0 1 1 on 0 Gnd
Tri-State Devices • Tri-State Buffers • If enabled (E=1), then Q = D • Otherwise, Q is not connected (z = high impedance) E Vsupply E D Q 1 0 on D 1 1 Q 1 1 0 off 1 Gnd
Shared Bus D0 S0 D1 S1 D2 S2 D3 S3 D1023 S1023 shared line
Takeway • Register 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.
Goals for today Memory • 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)
Next Goal • How 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.
SRAM • 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 Data Address Decoder