Transcript
Page 1: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 43

Sequential Logic

§  Output depends on sequence of previous inputs •  “Sequence of previous” – this is history •  History is a state that captures how you got here

"   E.g., 35 cents vending = 10 cents + 10 cents + 10 cents + 5 cents "   Or, 25 cents + 10 cents = 35 cents. Multiple ways are possible.

•  State requires memory – remembering the past...

§  Memory in logic •  Smallest element is 1 bit of memory •  Use logic gates to create a 1-bit memory •  Yet, combinational logic (using gates) depends only on present inputs!

§  Fundamental building block: “RS Latch” •  1-bit of history through feedback of gates

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 44

RS latch

§  Beware of the feedback!

Two NOR gates With feedback

Output Current state (0 or 1)

Complement of current state

Input R,S control writing

a 0 or 1 in state

Page 2: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

2

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 45

RS latch

§  Let’s see how it operates! Write a value into the 1-bit state.

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 46

RS latch

§  When R=0, S=1, Q(t)=0

1

0 1

0

Page 3: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

3

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 47

RS latch

§  When R=0, S=1, Q(t)=0

0

1 1

0 1

0

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 48

RS latch

§  When R=0, S=1, Q(t)=0

0

1 1

0 1

0 0

0

Page 4: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

4

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 49

RS latch

§  When R=0, S=1, Q(t)=0

0

1 1

0 1

0 0

0 1

1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 50

RS latch

§  When R=0, S=1, Q(t)=1

0

1 0

1 1

0

Page 5: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

5

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 51

RS latch

§  When R=1, S=0

1

0 1

0 1

0

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 52

RS latch

§  When R=0, S=0, and Q(t)=1

0

0 0

1 0

1

Page 6: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

6

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 53

RS latch

§  When R=0, S=0, and Q(t)=0

0

0 1

0 1

0

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 54

RS latch

§  What happens if R=S=1

1

1

Page 7: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

7

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 55

RS latch

1

1

R S Q(t) Q(t+1) Q’(t+1) 1 1 0 0 0 1 1 1

0

1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 56

RS latch

1

1

R S Q(t) Q(t+1) Q’(t+1) 1 1 0 0 0 1 1 1 0 0

1

0

Page 8: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

8

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 57

RS latch truth table Inputs Outputs R S Q(t) Q(t+1) 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 Invalid 1 1 1 Invalid

Storage (R=0, S=0)

Set to 1 (S=1)

Reset to 0 (R=0)

Outputs will track any changes in the inputs! R=1, S=1 must be avoided. Desirable to control when to capture input state.

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 58

Consider RS latch over time

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

Page 9: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

9

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 59

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 60

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

Page 10: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

10

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 61

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 62

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

Page 11: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

11

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 63

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 64

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

Page 12: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

12

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 65

Time (t) R S Q(t) Q(t+1) 0 1 0 1 0 1 0 1 0 1 2 0 0 1 1 3 0 0 1 1 4 1 0 1 0 5 1 0 0 0 6 0 0 0 0 7 0 0 0 0 8 0 1 0 1 9 0 0 1 1 10 0 0 1 1

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 66

D latch

One signal (bit) for data input

Controls when to “capture” data input

Same data outputs as the RS latch

Page 13: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

13

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 67

D latch

§  Note that we have an RS latch in the back-end of this design

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 68

D latch

§  Note that R, S inputs always get opposite values when C=1 §  When C=0, S=R=0 ⇒ RS latch remembers the previous value

S

R

Inverter for D input with C

Page 14: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

14

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 69

D latch

§  Note that R, S inputs always get opposite values when C=1 §  When C=0, S=R=0 ⇒ RS latch remembers the previous value

S

R 1

0

1

0

0

C=1, D=0

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 70

D latch

§  Note that R, S inputs always get opposite values when C=1 §  When C=0, S=R=0 ⇒ RS latch remembers the previous value

S

R 1

1

0

1

1

C=1, D=1

Page 15: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

15

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 71

D latch

§  Note that R, S inputs always get opposite values when C=1 §  When C=0, S=R=0 ⇒ RS latch remembers the previous value

S

R 0

0

0

0

0

C=0, D=0 Q(t)=0

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 72

D latch

§  Note that R, S inputs always get opposite values when C=1 §  When C=0, S=R=0 ⇒ RS latch remembers the previous value

S

R 0

0

0

0

1

C=0, D=0 Q(t)=1

Page 16: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

16

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 73

D latch

S

R C D Q(t)

0 0 Q(t-1)

0 1 Q(t-1)

1 0 0

1 1 1

“transparent mode”

“latched mode”

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 74

D latch

D

C

Q

Q’

D Latch

Page 17: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

17

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 75

D latch

D

C

Q

Q’

D Latch

C

D

Q

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 76

D flip-flop (D-FF)

§  Two cascaded D latches; C input of the second is inverted §  This is a negative edge (aka “falling edge”) triggered D-FF

Page 18: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

18

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 77

D flip-flop

D

C

Q

Q’

D-FF

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 78

D flip-flop

D

C

Q

Q’

D-FF

C

D

Q

data value at falling edge

Q0

Q0

storage transparent storage transparent

Page 19: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

19

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

State Elements

RS latch R,S control mode (reset, set, storage) Q,Q’ track R and S R=1, S=1 invalid

D latch C controls mode (0=latched, 1=transparent) D is data input (“copied” during transparent) Signal value triggered: Q,Q’ track D when C=1 Guarantees R=1,S=1 can not be done

D flip-flop (falling or negative edge triggered) Two cascaded D latches C=1 means 1st latch transparent, 2nd latched C=0 means 1st latch latched, 2nd transparent Output changes on falling edge (C: 1=>0)

D flip-flop (rising or positive edge triggered) Same as falling edge triggered Output changes on rising edge (C: 0=>1)

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 84

Example circuits and clocking

§  Suppose we want to: •  1-bit value A stored in a D flip-flop •  1-bit value B stored in a D flip-flop •  1-bit value C stored in a D flip-flip •  Do 1-bit addition of A and B, producing C

§  C = A + B •  What is the circuit? •  Need three D flip-flops •  Need one 1 bit adder

Page 20: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

20

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

Example circuits and clocking

A

B

C

How quickly can this produce a new sum C=A+B? Suppose… •  D flip-flop: Each latch is 2ns •  Adder: With ripple carries is 4ns

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

Example circuits and clocking

Page 21: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

21

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

Example circuits and clocking

Read A,B Compute A+B Write C

Propagation delay = 2ns + 4ns + 2ns = 8ns

How often can a new sum be produced? Every 8ns! How do we control when to write C? Clock!

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

Example circuits and clocking

Read A,B Compute A+B Write C

falling edge

Page 22: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

22

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

Example circuits and clocking

Read A,B Compute A+B Write C

falling edge falling edge

8ns between falling edges

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 90

Clock Frequency

§  Clock frequency is how many edges (falling) per second

§  In our example, how many edges per second? clock frequency = 1 second / 8ns between edges = 109ns per second / 8ns = 125,000,000 edges per second

§  Convenient unit of measurements Hertz = Hz = Cycles Per Second MegaHertz = MHz = Millions of Cycles Per Second GigaHertz = GHz = Billions of Cycles Per Second

§  For our example, it’s 125 MHz clock frequency

Page 23: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

23

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 91

Clock Frequency

§  Suppose delay between edges was 0.5ns §  What is the clock frequency?

Clock frequency = 1second / time between edges = 1second / 0.5ns = 109ns per second / 0.5ns = 2,000,000,000 edges per second = 2000 MHz clock frequency = 2.0 GHz clock frequency

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 92

Example circuits and clocking

§  Is there any difference in the delay with this one?

§  In fact, sequential logic often looks like this….

Page 24: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

24

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 93

Example circuits and clocking

§  Now, suppose we want to build a 4-bit counter? •  Counter increments by 1 for a clock pulse (falling edge event) •  4 1-bit adders •  4 1-bit D flip-flops

§  What’s the circuit? §  How often to “pulse” the clock (increment counter)?

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh

Example circuits and clocking

Recall: The flip-flops are edge triggered -- assuming falling edge (negative) How often can an edge event happen?

No more frequent than the maximum propagation delay Let’s compute the delay -- assume 2ns for latch to stabilize and 4ns for adder

Page 25: Sequential Logic - people.cs.pitt.edupeople.cs.pitt.edu/~childers/CS0447/lectures/logic3.pdf · 1 CS/CoE 447: Computer Organization and Assembly Language Programming University of

25

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 95

Example circuits and clocking

§  Values of output bits must all be stable •  I.e., can’t pulse the clock (increment) until all four bits are computed

§  Adder circuit is ripple-carry: Must wait for carries •  4ns per adder •  4-bit adder •  thus, 4 * 4ns = 16ns for the adder

§  Flip-flops •  Must wait for 1st latch of last bit to stabilize (others done in parallel) •  Must wait for 2nd latch of all bits to stabilize (all done in parallel) •  thus, 2ns + 2ns = 4ns

§  Overall delay = 16ns + 4ns = 20ns. Clock pulse is 20ns.

CS/CoE 447: Computer Organization and Assembly Language Programming University of Pittsburgh 96

Example circuits and clocking

Can we build a counter with just flip-flops?

What’s the propagation delay?


Recommended