State Hakim Weatherspoon CS 3410 Computer Science Cornell

  • Slides: 41
Download presentation
State Hakim Weatherspoon CS 3410 Computer Science Cornell University The slides are the product

State Hakim Weatherspoon CS 3410 Computer Science Cornell University The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, and Sirer.

Announcements Make sure you are • Registered for class, can access CMS • Have

Announcements Make sure you are • Registered for class, can access CMS • Have a Section you can go to. • Lab Sections are required. • • “Make up” lab sections only Friday 11: 40 am or 1: 25 pm Bring laptop to Labs • Project partners are required for projects starting w/ project 2 • • Have project partner in same Lab Section, if possible WICC hosting a partner finding event Feb 12 @ 6 pm in 3 rd floor lounge of Gates

Announcements Make sure to go to your Lab Section this week Completed Proj 1

Announcements Make sure to go to your Lab Section this week Completed Proj 1 due before winter break, Friday, Feb 16 th Note, a Design Document is due when you submit Proj 1 final circuit Work alone, BUT use your resources • Lab Section, Piazza. com, Office Hours • Class notes, book, Sections, CSUGLab

Announcements Check online syllabus/schedule • http: //www. cs. cornell. edu/Courses/CS 3410/2018 sp/schedule • •

Announcements Check online syllabus/schedule • http: //www. cs. cornell. edu/Courses/CS 3410/2018 sp/schedule • • • Slides and Reading for lectures Office Hours Pictures of all TAs Project and Reading Assignments Dates to keep in Mind • • Prelims: Thur Mar 15 th and Thur May 3 rd Proj 1: Due next Friday, Feb 16 th before Winter break Proj 3: Due before Spring break Final Project: May 15 th Schedule is subject to change

Collaboration, Late, Re-grading Policies “White Board” Collaboration Policy • Can discuss approach together on

Collaboration, Late, Re-grading Policies “White Board” Collaboration Policy • Can discuss approach together on a “white board” • Leave , watch a movie (e. g. Strange Things), 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 regrade within a week of receiving score

State Goals for Today • How do we store one bit? • Attempts at

State Goals for Today • How do we store one bit? • Attempts at storing (and changing) one bit – Set-Reset Latch – D Flip-Flops – Master-Slave Flip-Flops • Register: storing more than one bit, N-bits Basic Building Blocks • Decoders and Encoders

Goal How do we store one bit?

Goal How do we store one bit?

First Attempt: Unstable Devices B C A

First Attempt: Unstable Devices B C A

Second Attempt: Bistable Devices • Stable and unstable equilibria? A B A Simple Device

Second Attempt: Bistable Devices • Stable and unstable equilibria? A B A Simple Device

Third Attempt: Set-Reset Latch S A Q B R

Third Attempt: Set-Reset Latch S A Q B R

Third Attempt: Set-Reset Latch S Q S R 0 0 0 1 1 Q

Third Attempt: Set-Reset Latch S Q S R 0 0 0 1 1 Q A B OR NOR 0 0 0 1 1 0 1 0 1 1 1 Set-Reset (S-R) Latch Stores a value Q and its complement 0 R

Third Attempt: Set-Reset Latch S R S Q S R 0 0 0 1

Third Attempt: Set-Reset Latch S R S Q S R 0 0 0 1 1 Q R Set-Reset (S-R) Latch Stores a value Q and its complement Q

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state.

Next Goal How do we avoid the forbidden state of S-R Latch?

Next Goal How do we avoid the forbidden state of S-R Latch?

Fourth Attempt: (Unclocked) D Latch D D S Q Fill in the truth table?

Fourth Attempt: (Unclocked) D Latch D D S Q Fill in the truth table? R S Q R Q D Q 0 1 A B OR NOR 0 0 0 1 1 0 1 0 1 1 1 0

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state. (Unclocked) D Latch can store and change a bit like an SR Latch while avoiding the forbidden state.

Next Goal How do we coordinate state changes to a D Latch?

Next Goal How do we coordinate state changes to a D Latch?

Aside: Clocks Clock helps coordinate state changes • Usually generated by an oscillating crystal

Aside: Clocks Clock helps coordinate state changes • Usually generated by an oscillating crystal • Fixed period • Frequency = 1/period clock high falling edge 1 0 clock period clock low rising edge

Level sensitive Clock Disciplines • State changes when clock is high (or low) Edge

Level sensitive Clock Disciplines • State changes when clock is high (or low) Edge triggered • State changes at clock edge positive edge-triggered negative edge-triggered

Clock Methodology • Negative edge, synchronous tsetup thold clk tcombinational compute save compute Edge-Triggered

Clock Methodology • Negative edge, synchronous tsetup thold clk tcombinational compute save compute Edge-Triggered signals must be stable near falling edge “near” = before and after tsetup thold 20

Round 2: D Latch (1) D S Q • Inverter prevents SR Latch from

Round 2: D Latch (1) D S Q • Inverter prevents SR Latch from entering 1, 1 state R D C Q C D Q 0 0 Reset 0 1 Set 1 0 1 1 21

Round 2: D Latch (1) D S C R • Level sensitive • Inverter

Round 2: D Latch (1) D S C R • Level sensitive • Inverter prevents SR Latch from entering 1, 1 state • C enables changes Q C = 1, D Latch transparent: set/reset (according to D) C = 0, D Latch opaque: keep state (ignore D) D C Q C D Q 0 0 0 1 1 0 Reset 1 1 Set No Change 22

Round 2: D Latch (1) D S C R • Level sensitive • Inverter

Round 2: D Latch (1) D S C R • Level sensitive • Inverter prevents SR Latch from entering 1, 1 state • C enables changes Q C = 1, D Latch transparent: set/reset (according to D) C = 0, D Latch opaque: keep state (ignore D) S R Q 0 0 Q 0 1 reset 1 0 set 1 1 hold forbidden D C Q C D Q 0 0 0 1 1 0 Reset 1 1 Set No Change 23

Round 2: D Latch (1) D clk D Q Q Level Sensitive D Latch

Round 2: D Latch (1) D clk D Q Q Level Sensitive D Latch Clock high: set/reset (according to D) Clock low: keep state (ignore D) clk D 0 0 0 1 1 Q

Round 3: D Flip-Flop D D clk C Q L 1 D X C

Round 3: D Flip-Flop D D clk C Q L 1 D X C Q L 2 • Edge-Triggered Q • Data captured when clock high • Output changes only on falling edges 25

Round 3: D Flip-Flop D passes through L 1 to X Clock = 1:

Round 3: D Flip-Flop D passes through L 1 to X Clock = 1: L 1 transparent L 2 opaque D clk L 1 opaque L 2 transparent 1 Q C X XD 0 Q Q C L 1 When CLK rises (0 1), now X can change, Q does not change Clock = 0: D L 2 X passes through L 2 to Q D clk XD 0 Q C L 1 When CLK falls (1 0), Q gets X, X cannot change X D 1 C Q L 2 26 Q

Edge-Triggered D Flip-Flop D D clk C Q L 1 X D 1 C

Edge-Triggered D Flip-Flop D D clk C Q L 1 X D 1 C Q L 2 Q • Edge-Triggered • Data captured when clock is high • Output changes only on falling edges clk D X Q 27

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state. (Unclocked) D Latch can store and change a bit like an SR Latch while avoiding a forbidden state. An Edge-Triggered D Flip-Flip (aka Master-Slave D Flip) stores one bit. The bit can be changed in a synchronized fashion on the edge of a clock signal.

Next Goal How do we store more than one bit, N bits?

Next Goal How do we store more than one bit, N bits?

Registers D 0 D 1 D 2 Register • D flip-flops in parallel •

Registers D 0 D 1 D 2 Register • D flip-flops in parallel • shared clock • extra clocked inputs: write_enable, reset, … D 3 4 clk 4 -bit reg 4 clk

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value

Takeaway Set-Reset (SR) Latch can store one bit and we can change the value of the stored bit. But, SR Latch has a forbidden state. (Unclocked) D Latch can store and change a bit like an SR Latch while avoiding a forbidden state. An Edge-Triggered D Flip-Flip (aka Master-Slave D Flip) stores one bit. The bit can be changed in a synchronized fashion on the edge of a clock signal. An N-bit register stores N-bits. It is created with N DFlip-Flops in parallel along with a shared clock.

An Example: What will this circuit do? 4 16 Decoder 4 4 -bit reg

An Example: What will this circuit do? 4 16 Decoder 4 4 -bit reg Clk 4 +1 4

Decoder Example: 7 -Segment LED d 7 d 6 d 5 d 4 d

Decoder Example: 7 -Segment LED d 7 d 6 d 5 d 4 d 3 d 2 d 1 d 0 • photons emitted when electrons fall into holes

7 LED decode Decoder Example: 7 -Segment LED Decoder 3 inputs • encode 0

7 LED decode Decoder Example: 7 -Segment LED Decoder 3 inputs • encode 0 – 7 in binary 7 outputs • one for each LED

7 Segment LED Decoder Implementation b 2 b 1 b 0 d 6 d

7 Segment LED Decoder Implementation b 2 b 1 b 0 d 6 d 5 d 4 d 3 d 2 d 1 d 0 0 0 1 1 1 0 0 1 1 1 d 2 d 4 d 1 d 0 d 3 d 5 d 6

Basic Building Blocks We have Seen 2 N N binary decoder . . .

Basic Building Blocks We have Seen 2 N N binary decoder . . . binary encoder N 2 N N 0 1 2 Multiplexor N 2 M-1 M N

Encoders 0 1 3 4 5 6 7 . . . N Input wires

Encoders 0 1 3 4 5 6 7 . . . N Input wires encoder 2 Log 2(N) outputs wires e. g. Voting: Can only vote for one out of N candidates, so N inputs. But can encode vote efficiently with binary encoding.

Example Encoder Truth Table a b 1 o 0 2 o 1 c 3

Example Encoder Truth Table a b 1 o 0 2 o 1 c 3 d 4 o 2 A 3 -bit encoder with 4 inputs for simplicity a b c d 0 0 0 0 1

detect Basic Building Blocks Example: Voting Ballots 8 enc 3 7 LED decode The

detect Basic Building Blocks Example: Voting Ballots 8 enc 3 7 LED decode The 3410 optical scan vote reader machine 7

Recap We can now build interesting devices with sensors • Using combinationial logic We

Recap We can now build interesting devices with sensors • Using combinationial logic We can also store data values (aka Sequential Logic) • In state-holding elements • Coupled with clocks

Summary We can now build interesting devices with sensors • Using combinational logic We

Summary We can now build interesting devices with sensors • Using combinational logic We can also store data values • Stateful circuit elements (D Flip Flops, Registers, …) • Clock to synchronize state changes