Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf ·...

56
Fundamentals of Computer Systems Sequential Logic Martha A. Kim Columbia University Fall 2014 1/1

Transcript of Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf ·...

Page 1: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Fundamentals of Computer SystemsSequential Logic

Martha A. Kim

Columbia University

Fall 2014

1 / 1

Page 2: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

2 / 1

Page 3: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Bistable Elements

Q Q

Q

Q

Equivalent circuits; right is more traditional.

Two stable states:

0

1

1

0

3 / 1

Page 4: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

RS Latch

R

S

Q

Q

Q

Q

R

S

R S Q Q

0 00 11 01 1

4 / 1

Page 5: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

RS Latch

R

S

Q

Q

0

1

1

0

Q

Q

R

S

R S Q Q

0 00 1 1 0 Set (Q = 1)1 01 1

4 / 1

Page 6: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

RS Latch

R

S

Q

Q

1

0

0

1

Q

Q

R

S

R S Q Q

0 00 1 1 0 Set (Q = 1)1 0 0 1 Reset (Q = 0)1 1

4 / 1

Page 7: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

RS Latch

R

S

Q

Q

0

0

Q

Q

(0+Q) = Q

(0+Q) = Q

Q

Q

R

S

R S Q Q

0 0 Q Q Hold previous value0 1 1 0 Set (Q = 1)1 0 0 1 Reset (Q = 0)1 1

4 / 1

Page 8: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

RS Latch

R

S

Q

Q

1

1

0

0

Q

Q

R

S

R S Q Q

0 0 Q Q Hold previous value0 1 1 0 Set (Q = 1)1 0 0 1 Reset (Q = 0)1 1 0 0 Bad. Do not use.

4 / 1

Page 9: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

RS Latch

S

R

Q

Q

Q

Q

S

R

R S Q Q

0 0 1 1 Bad. Do not use.0 1 0 1 Reset (Q = 0)1 0 1 0 Set (Q = 1)1 1 Q Q Hold previous value

5 / 1

Page 10: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

D Latch

Q

Q

D

CQ

Q

D

C

C D Q Q

0 X Q Q1 0 0 11 1 1 0

6 / 1

Page 11: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

A Challenge: Build a traffic light controller

Want the lights to cycle green-yellow-red.

DC

Q

DC

Q

DC

Q

R

Y

G

Does this work?

7 / 1

Page 12: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 13: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 14: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 15: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 16: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 17: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 18: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

8 / 1

Page 19: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

9 / 1

Page 20: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

9 / 1

Page 21: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

9 / 1

Page 22: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

9 / 1

Page 23: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

9 / 1

Page 24: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Positive-Edge-Triggered D Flip-Flop

Master Slave

DC

Q DC

QDD’ Q

CM CS

C

D Q

C

D

CM

D′

CS

Q

transparent

opaque

10 / 1

Page 25: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Positive-Edge-Triggered D Flip-Flop

Master Slave

DC

Q DC

QDD’ Q

CM CS

C

D Q

C

D

CM

D′

CS

Q

transparent

opaque

10 / 1

Page 26: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Positive-Edge-Triggered D Flip-Flop

Master Slave

DC

Q DC

QDD’ Q

CM CS

C

D Q

C

D

CM

D′

CS

Q

transparent

opaque

opaque

transparent

10 / 1

Page 27: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Positive-Edge-Triggered D Flip-Flop

Master Slave

DC

Q DC

QDD’ Q

CM CS

C

D Q

C

D

CM

D′

CS

Q

transparent

opaque

opaque

transparent

10 / 1

Page 28: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Positive-Edge-Triggered D Flip-Flop

Master Slave

DC

Q DC

QDD’ Q

CM CS

C

D Q

C

D

CM

D′

CS

Q

transparent

opaque

opaque

transparent

transparent

opaque

10 / 1

Page 29: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Positive-Edge-Triggered D Flip-Flop

Master Slave

DC

Q DC

QDD’ Q

CM CS

C

D Q

C

D

CM

D′

CS

Q

transparent

opaque

opaque

transparent

transparent

opaque

opaque

transparent

10 / 1

Page 30: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller: A second tryLet’s try this again with D flip-flops.

D Q

D Q

D Q

CLK

R

Y

G

CLK

R

Y

G

11 / 1

Page 31: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller: A second tryLet’s try this again with D flip-flops.

D Q

D Q

D Q

CLK

R

Y

G

CLK

R

Y

G

11 / 1

Page 32: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller: A second tryLet’s try this again with D flip-flops.

D Q

D Q

D Q

CLK

R

Y

G

CLK

R

Y

G

11 / 1

Page 33: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller: A second tryLet’s try this again with D flip-flops.

D Q

D Q

D Q

CLK

R

Y

G

CLK

R

Y

G

11 / 1

Page 34: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller: A second tryLet’s try this again with D flip-flops.

D Q

D Q

D Q

CLK

R

Y

G

CLK

R

Y

G

11 / 1

Page 35: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller with Reset

D Q

D Q

D Q

CLK

RESET

R

Y

G

CLK

RESET

R

Y

G

12 / 1

Page 36: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller with Reset

D Q

D Q

D Q

CLK

RESET

R

Y

G

CLK

RESET

R

Y

G

12 / 1

Page 37: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller with Reset

D Q

D Q

D Q

CLK

RESET

R

Y

G

CLK

RESET

R

Y

G

12 / 1

Page 38: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller with Reset

D Q

D Q

D Q

CLK

RESET

R

Y

G

CLK

RESET

R

Y

G

12 / 1

Page 39: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller with Reset

D Q

D Q

D Q

CLK

RESET

R

Y

G

CLK

RESET

R

Y

G

12 / 1

Page 40: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller with Reset

D Q

D Q

D Q

CLK

RESET

R

Y

G

CLK

RESET

R

Y

G

12 / 1

Page 41: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

D Flip-Flop with Enable

D Q Q01D

C

E

C E D Q

↑ 0 X Q↑ 1 0 0↑ 1 1 10 X X Q1 X X Q

D QEC

DQ

What’s wrong with thissolution?

13 / 1

Page 42: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Asynchronous Preset/Clear

D QPRE

CLR

CLK

D

PRE

CLR

Q

14 / 1

Page 43: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Traffic Light Controller w/ Async. Reset

D QPRE

CLR

D QPRE

CLR

D QPRE

CLR

CLKR

Y

G

RESET

15 / 1

Page 44: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

The Synchronous Digital Logic Paradigm

Gates and Dflip-flops only

Each flip-flopdriven by thesame clock

Every cyclicpath containsat least oneflip-flop

CLSTATE

NEXT STATE

INPUTS OUTPUTS

CLOCK

16 / 1

Page 45: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Cool Sequential Circuits: Shift Registers

A

Q0 Q1 Q2

Q3

CLK

A Q0Q1Q2Q3

0 X X X X1 0 X X X1 1 0 X X0 1 1 0 X1 0 1 1 00 1 0 1 10 0 1 0 10 0 0 1 01 0 0 0 10 1 0 0 0

17 / 1

Page 46: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Universal Shift Register

S1S0

0123

D0Q0

0123

D1Q1

0123

D2Q2

0123

D3Q3

CLK

R

L

S1 S0 Q3 Q2 Q1 Q0

0 0 R Q3 Q2 Q10 1 D3 D2 D1 D01 0 Q3 Q2 Q1 Q01 1 Q2 Q1 Q0 L

S1 S0 Operation

0 0 Shift right0 1 Load1 0 Hold1 1 Shift left

18 / 1

Page 47: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Cool Sequential Circuits: Counters

Cycle through sequences of numbers, e.g.,

00 01 10 11

19 / 1

Page 48: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Flip-Flop Timing

CLK

D

Q

tsu

Setup Time: Time beforethe clock edge after whichthe data may not change

20 / 1

Page 49: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Flip-Flop Timing

CLK

D

Q

tsu th

Setup Time: Time beforethe clock edge after whichthe data may not change

Hold Time: Time after theclock edge after whichthe data may change

20 / 1

Page 50: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Flip-Flop Timing

CLK

D

Q

tsu th

tp(min)

Setup Time: Time beforethe clock edge after whichthe data may not change

Hold Time: Time after theclock edge after whichthe data may change

Minimum PropagationDelay: Time fromclock edge to when Qmight start changing

20 / 1

Page 51: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Flip-Flop Timing

CLK

D

Q

tsu th

tp(min)

tp(max)

Setup Time: Time beforethe clock edge after whichthe data may not change

Hold Time: Time after theclock edge after whichthe data may change

Minimum PropagationDelay: Time fromclock edge to when Qmight start changing

MaximumPropagation Delay:Time from clock edgeto when Qguaranteed stable

20 / 1

Page 52: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Timing in Synchronous Circuits

CL· · · · · ·Q D

CLK

CLK

Q

D

tc

tc: Clock period. E.g., 10 ns for a 100 MHz clock

21 / 1

Page 53: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Timing in Synchronous Circuits

CL· · · · · ·Q D

CLK

CLK

Q

D

tp(min,FF) tp(min,CL)

Sufficient Hold Time?

Hold time constraint: how soon after the clock edge canD start changing? Min. FF delay + min. logic delay

21 / 1

Page 54: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Timing in Synchronous Circuits

CL· · · · · ·Q D

CLK

CLK

Q

D

tp(max,FF)tp(max,CL)

Sufficient Setup Time?

Setup time constraint: when before the clock edge is Dguaranteed stable? Max. FF delay + max. logic delay

21 / 1

Page 55: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Clock Skew: What Really Happens

CL· · · · · ·Q D

CLK1

CLK

CLK2

CLK1

CLK2

Q

Dtp(min,FF) tp(min,CL)

tskew

Sufficient Hold Time?

CLK2 arrives late: clock skew reduces hold time

22 / 1

Page 56: Fundamentals of Computer Systems - Columbia Universitymartha/courses/3827/au14/sequential.pdf · Fall 2014 1/1. 2/1. Bistable Elements Q Q Q Q Equivalent circuits; right is more traditional.

Clock Skew: What Really Happens

CL· · · · · ·Q D

CLK1

CLK

CLK2

CLK1

CLK2

Q

Dtp(max,FF) tp(max,CL)

tskew

Sufficient Setup Time?

CLK2 arrives early: clock skew reduces setup time

22 / 1