41
© Egemen K. Çetinkaya Introduction to Digital Logic Missouri S&T University CPE 2210 Flip-Flops Egemen K. Çetinkaya Department of Electrical & Computer Engineering Missouri University of Science and Technology [email protected] http://web.mst.edu/~cetinkayae/teaching/CPE2210Fall2016 7 October 2015 rev. 16.0 © 20142016 Egemen K. Çetinkaya

Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Introduction to Digital Logic Missouri S&T University CPE 2210

Flip-Flops

Egemen K. Çetinkaya

Department of Electrical & Computer Engineering

Missouri University of Science and Technology

[email protected]

http://web.mst.edu/~cetinkayae/teaching/CPE2210Fall2016

7 October 2015 rev. 16.0 © 2014–2016 Egemen K. Çetinkaya

Page 2: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Flip-Flops Outline

• Introduction

• Flip-flops and types

• Summary

MST CPE2210 – Flip-Flops 7 October 2016 2

Page 3: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Digital Logic Circuit Types

• What are the type of digital circuits?

MST CPE2210 – Flip-Flops 7 October 2016 3

Page 4: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Digital Logic Circuit Types

• What are the type of digital circuits?

• Combinatorial

– output solely depends on present values of input(s)

• no memory

– basic blocks of circuits

– e.g.: lamp with light sensor

• Sequential

– output depends on present and past values of input(s)

• output depends on present state

– e.g.: calculator

MST CPE2210 – Flip-Flops 7 October 2016 4

Page 5: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Sequential Logic Circuits Examples

• What are examples of sequential circuit elements?

MST CPE2210 – Flip-Flops 7 October 2016 5

Page 6: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Sequential Logic Circuits Examples

• Examples of sequential logic elements:

• Latches

• Flip-flops

• Registers

• Controllers

• Counters

MST CPE2210 – Flip-Flops 7 October 2016 6

Page 7: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Basic SR Latch Using NOR Gates

• We can change state of simple memory using latch

• NOR gates are connected cross-coupled style

MST CPE2210 – Flip-Flops 7 October 2016 7

Q

S (set) SR latch

R (reset)

S R t (𝑸 ) 𝑸

0 0 1/0 0/1

0 1 1 0

1 0 0 1

1 1 0 0

→ no change

Page 8: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Level-Sensitive SR Latch Circuit and Symbol

• SR latch with enable input is a level-sensitive SR latch

• C is the enable input

MST CPE2210 – Flip-Flops 7 October 2016 8

R1

S1 S

C

R

Level-sensitive SR latch

Q

S

C Q ’

Q R

Level-sensitive

SR latch symbol

C S R 𝑸(t+1)

0 x x no change

1 0 0 no change

1 0 1 0

1 1 0 1

1 1 1 x

Page 9: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Level-Sensitive D Latch Circuit and Symbol

• SR latch with enable input and inverter is a D latch

• C is the enable input

MST CPE2210 – Flip-Flops 7 October 2016 9

D latch symbol

R1

S1D

C

D latch

Q

S

R

D Q ’

Q C

C D 𝑸(t+1)

0 x no change

1 0 0

1 1 1

Page 10: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Review Question Overview

• Can we do latch functions using NAND gates?

– instead of NOR gates

MST CPE2210 – Flip-Flops 7 October 2016 10

Page 11: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Review Question Overview

MST CPE2210 – Flip-Flops 7 October 2016 11

Page 12: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Review Question Overview

MST CPE2210 – Flip-Flops 7 October 2016 12

Page 13: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Latch Problem Delay

• When C is 1, how many latches will the signal travel?

MST CPE2210 – Flip-Flops 7 October 2016 13

1 1? 1? 1? D1 Q1 D2 Q2 D3 Q3 D4

C4 C3 C2 C1

Q4 Y

Clk

Page 14: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Latch Problem Delay

• When C is 1, how many latches will the signal travel?

• Depends on clk signal:

– Clk_A: signal may travel through multiple latches

– Clk_B: signal may travel through fewer latches

MST CPE2210 – Flip-Flops 7 October 2016 14

D1 Q1 D2 Q2 D3 Q3 D4

C4C3C2C1

Q4Y

Clk

Clk_A Clk_B

1 1? 1? 1?

Page 15: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Latch Problem Delay

MST CPE2210 – Flip-Flops 7 October 2016 15

R2

S2 D2

C2

D latch

Q2

D4

C4

Q4

R1

S1 D1

C1

Clk

D latch

Q1

0–>1 0–>1

0–>1

1–>0

0–>1

1–>0 0–>1

D3

C3

Q3

Clk

D1

Q1/D2

S2

R2

Q2 2nd latch set

Clk

D1

Q1/D2

S2

R2

Q2

Short clock

Q1 doesn't change

Long clock

0–>1

Page 16: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Latch Problem Delay

• Issue: how to adjust clock cycle for right timing?

• Can we design bit storage that only stores a value on the rising edge of the clock signal?

MST CPE2210 – Flip-Flops 7 October 2016 16

Page 17: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Latch Problem Delay

• Issue: how to adjust clock cycle for right timing?

• Can we design bit storage that only stores a value on the rising edge of the clock signal?

• Level-sensitive vs. edge-triggered:

– level-sensitive: sensitive to signal level

– edge-triggered: sensitive to rise/fall of the signal

MST CPE2210 – Flip-Flops 7 October 2016 17

Clk

rising edges

Page 18: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Edge-Triggered D Flip-Flop Master-Servant Design

• Flip-flop: stores 1 bit on clock edge

• D flip-flop uses two D latches

• Master-servant is one design, there are others

MST CPE2210 – Flip-Flops 7 October 2016 18

D latch

master

D latch

se r v ant

D Dm Ds

Cs

Qm Qs

Qs Q

Q

Cm

Clk

D flip-flop

Page 19: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Edge-Triggered D Flip-Flop Timing Diagram

• Clk=0

– master enabled, loads D, appears at Qm, servant disabled

• Clk=1

– master disabled, Qm stays same

– servant latch enabled, loads Qm, appears at Qs

MST CPE2210 – Flip-Flops 7 October 2016 19

D latch

master

D latch

se r v ant

D Dm Ds

Cs

Qm Qs

Qs Q

Q

Cm

Clk

D flip-flop Clk

D/Dm

Qm/Ds

Cm

Cs

Qs

Page 20: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Edge-Triggered D Flip-Flop Symbols

MST CPE2210 – Flip-Flops 7 October 2016 20

D Q ’

Q

Q ’ D

Q

Symbol for rising-edge

triggered D flip-flop

Symbol for falling-edge

triggered D flip-flop

Clk

rising edges

Clk

falling edges

Page 21: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Edge-Triggered D Flip-Flop Timing Diagram

• Solves problem of not knowing through how many latches a signal travels when C=1

• How many flip-flops does signal travel in each cycle

MST CPE2210 – Flip-Flops 7 October 2016 21

Two latches inside

each flip-flop

D1 Q1 D2 Q2 D3 Q3 D4 Q4 Y

Clk

Clk_A Clk_B

Page 22: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Edge-Triggered D Flip-Flop Timing Diagram

• Solves problem of not knowing through how many latches a signal travels when C=1

• How many flip-flops does signal travel in each cycle?

• Signal travels exactly one flip-flop per cycle

MST CPE2210 – Flip-Flops 7 October 2016 22

Two latches inside

each flip-flop

D1 Q1 D2 Q2 D3 Q3 D4 Q4 Y

Clk

Clk_A Clk_B

Page 23: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Latch vs. D Flip-Flop Comparison

• Latch is level-sensitive, stores D when C=1

• Flip-flop is edge triggered, stores D when C 01

MST CPE2210 – Flip-Flops 7 October 2016 23

Clk

D

Q (D latch)

Q (D flip-flop) 10

8 7

6 5 4

9

3

1 2

Latch follows D

while Clk is 1

Flip-flop only loads D

during Clk rising edge

Page 24: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Review Question Overview

• Construct the timing diagram for the following

MST CPE2210 – Flip-Flops 7 October 2016 24

D Q

Q

D Q

Q

D Q

Q

D

Clock Q a

Q b

Q c

Q c

Q b

Q a

Clk

D

Clock

Q a

Q b

Q c

Page 25: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Review Question Overview

• Construct the timing diagram for the following

MST CPE2210 – Flip-Flops 7 October 2016 25

D

Clock

Q a

Q b

Q c

D Q

Q

D Q

Q

D Q

Q

D

Clock Q a

Q b

Q c

Q c

Q b

Q a

Clk

Page 26: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

SR Flip-Flop Overview

• Similar to SR latch

• However, instead of changing state with level change

• It changes state with edge rise/fall

MST CPE2210 – Flip-Flops 7 October 2016 26

Page 27: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

SR Flip-Flop Symbol and Characteristic Table

• SR flip-flop: Similar to SR latch, edge-triggered

MST CPE2210 – Flip-Flops 7 October 2016 27

S Q

Q R

S R 𝑸(t+1)

0 0 no change Q(t)

0 1 0

1 0 1

1 1 X

Page 28: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

T Flip-Flop Overview

• T flip-flop: toggle flip-flop

• The output toggles on the rising edge of clock

• The circuit diagram:

MST CPE2210 – Flip-Flops 7 October 2016 28

D Q

Q

Q

Q T

Clock

Page 29: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

T Flip-Flop Symbol and Characteristic Table

• T flip-flop: toggle flip-flop

• The output toggles on the rising edge of clock

MST CPE2210 – Flip-Flops 7 October 2016 29

T Q

Q

T 𝑸(t+1)

0 Q(t)

1 Q’(t)

Page 30: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

T Flip-Flop Timing Diagram

• T flip-flop: toggle flip-flop

• The output toggles on the rising edge of clock

MST CPE2210 – Flip-Flops 7 October 2016 30

Clock

T

Q

T Q

Q

T 𝑸(t+1)

0 Q(t)

1 Q’(t)

Page 31: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

T Flip-Flop Timing Diagram

• T flip-flop: toggle flip-flop

• The output toggles on the rising edge of clock

MST CPE2210 – Flip-Flops 7 October 2016 31

Clock

T

Q

T Q

Q

T 𝑸(t+1)

0 Q(t)

1 Q’(t)

Page 32: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

JK Flip-Flop Overview

• JK flip-flop: combines features of SR and T flip-flops

• Instead of T only, we use J and K inputs

• D = JQ’+K’Q

• The circuit:

MST CPE2210 – Flip-Flops 7 October 2016 32

D Q

Q

Q

Q

J

Clock

K

Page 33: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

JK Flip-Flop Symbol and Characteristic Table

• JK flip-flop: toggle flip-flop

MST CPE2210 – Flip-Flops 7 October 2016 33

J Q

Q K

J K 𝑸(t+1)

0 0 no change Q(t)

0 1 0

1 0 1

1 1 toggle Q’(t)

Page 34: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

D Flip-Flops Clear and Preset

• It might be needed to have clear and preset button

• If clear is 0, Q is forced to be in 0 – e.g. clear counter to be initial state to be 0

• If preset is 0, Q is forced to be in 1

– e.g. insert specific value as initial value of a counter

MST CPE2210 – Flip-Flops 7 October 2016 34

Clear

D Q

Q

Preset

Page 35: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Clock Signals Overview

• Clock input is connected to clock signal

• It is from an oscillator signal

• Generates pulsing signal

• What is the period?

• What is the frequency?

• How many cycles are there?

MST CPE2210 – Flip-Flops 7 October 2016 35

Osc.Clk

0 ns Time :

Clk

10 ns 20 ns 30 ns 40 ns

0 0 0

0

1

0 1 1 1

50 ns 60 ns

Page 36: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Clock Signals Overview

• Clock input is connected to clock signal

• It is from an oscillator signal

• Generates pulsing signal

• What is the period? 20 ns

• What is the frequency? 1/20 ns=50 MHz

• How many cycles are there? 3.5

MST CPE2210 – Flip-Flops 7 October 2016 36

Osc.Clk

0 ns Time :

Clk

10 ns 20 ns 30 ns 40 ns

0 0 0

0

1

0 1 1 1

50 ns 60 ns

Page 37: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Clock Signals Overview

• Clock input is connected to clock signal

• It is from an oscillator signal

• Generates pulsing signal

• T=1/f

• Synchronous circuit:

– storage elements change with clock

• Asynchronous circuit:

– storage elements that does not use clock

MST CPE2210 – Flip-Flops 7 October 2016 37

Page 38: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Storing Multiple Bits Registers

• Register: multiple flip-flops sharing common clock

• More about registers later

MST CPE2210 – Flip-Flops 7 October 2016 38

DQ

DQ

DQ

DQ

I2I3

Q2Q3 Q1 Q0

I1 I0

clk

4-bit register

I3 I2 I1 I0

Q3 Q2 Q1Q0

reg(4)

Page 39: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

Flip-Flops Summary

• Flip-flops store one bit

• Latches are level-sensitive

• Flip-flops are edge-triggered

• Signal travels one cycle per flip-flop

• D-flip-flops are most commonly used

• Flip-flop types: SR, JK, D, T

• Two types of flip-flops:

– edge-triggered: active edge of the clock impacts the state

– master-slave: with two gated latches

MST CPE2210 – Flip-Flops 7 October 2016 39

Page 40: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

References and Further Reading

• [V2011] Frank Vahid, Digital Design with RTL Design, VHDL, and Verilog, 2nd edition, Wiley, 2011.

• [BV2009] Stephen Brown and Zvonko Vranesic, Fundamentals of Digital Logic with VHDL Design, 3rd edition, McGraw-Hill, 2009.

MST CPE2210 – Flip-Flops 7 October 2016 40

Page 41: Introduction to Digital Logic - uok.ac.ir · Flip-Flops Summary • Flip-flops store one bit • Latches are level-sensitive • Flip-flops are edge-triggered • Signal travels one

© Egemen K. Çetinkaya

End of Foils

MST CPE2210 – Flip-Flops 7 October 2016 41