lecture 23: latches & flip-flops
TRANSCRIPT
![Page 1: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/1.jpg)
CSE115: Digital Design
Lecture 23:
Latches & Flip-Flops
Faculty of EngineeringFaculty of EngineeringFaculty of EngineeringFaculty of Engineering
![Page 2: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/2.jpg)
Suggested Reading
– Sections 7.1-7.2
![Page 3: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/3.jpg)
MEMORY
DATAPATH
CONTROL
INPUT -OUTPUT
RAM, ROM, Registers, …
Finite state machine:
PLA, Counters, Flip-
flops, Latches, …Interconnect:
Switches, Arbiters,
Bus, …Arithmetic Unit:
Adder, Multiplier, Shifter,
Comparator, …
Building Blocks for Digital Architectures
CPU
A Generic Digital Processor
![Page 4: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/4.jpg)
![Page 5: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/5.jpg)
![Page 6: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/6.jpg)
Logic Devices
• Combinational Logic: Current output depends on current input
only
⇒ Gates
⇒ Decoders
⇒ Multiplexers
⇒ ALUs
• Sequential Logic: Current output depends on past inputs as well
as current input; thus has a memory (state).
⇒ Latches and Flip-Flops
⇒ State Machines
⇒ Counters
⇒ Shift Registers
Combinational
Logic
Memory
Sequential
Logic
![Page 7: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/7.jpg)
• STATE: – A collection of state variables whose values contain all the
information about the past values necessary to account for
future behavior. (e.g. a TV tuner with up/down button)
– Circuit with n binary state variables has 2n possible states
– Changes usually synchronized with a system clock
• Digital sequential logic– Also known as a finite state machine (FSM).
Sequential Logic Definitions
![Page 8: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/8.jpg)
PeriodtH
tL
State change
Active High
Period
tH
tL
State change
Active Low
Clock Characteristics
Frequency= 1/Period
Duty Cycle= tH/Period
Clock - the master timing element behind the state changes.
Period: time between successive transitions in the same direction
Duty Cycle: the percentage of time that a clock is at its assertion level. = tL/Period
![Page 9: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/9.jpg)
Types of Sequential Logic
• A Feedback Sequential Circuit uses gates with
feedback to form memory elements (latches and
flip/flops) used in state machines.
• A Clocked Synchronous State Machine uses clocked
flip-flops to form useful sequential logic functions or
application.
![Page 10: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/10.jpg)
Bistable Element
• The simplest possible feedback sequential logic circuit:
It is bistable because it has two stable states:
• State 1: If Q (Q=Vout1=Vin2) is high, the bottom inverter output(/Q =Vout2=Vin1) is low, which keeps the top inverter output Q high.
• State 2: If Q is low, the bottom inverter output /Q is high, which keeps the top inverter output Q low.
![Page 11: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/11.jpg)
Bistable Element
• The simplest sequential circuit
• Two states
– One state variable, Q
HIGH LOW
LOWHIGH
![Page 12: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/12.jpg)
Analog Analysis of Bistable
Q Vout1
Vin1
Top Inverter aloneVin2
Vout2 /Q
Bottom Inverter alone
Vout1=Vin2
Complete Bistable
Vin1=Vout2
Stable High
Stable Low
Metastable
![Page 13: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/13.jpg)
There are not two stable states, but 3 states (a problem!)
Metastable point occurs when both outputs are halfway between high and low
•not a valid logic level!!!
Could last forever, but noise pushes towards a stable state.
Bistable and Metastability
![Page 14: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/14.jpg)
Metastability
![Page 15: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/15.jpg)
• Common feedback sequential circuits
• Latch– Single-bit storage (memory)
– Changes state at any time due to input change
• Flip-flop– Also single-bit storage
– Changes state ONLY when a clock edge or pulse is applied
Latches and Flip-flops
![Page 16: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/16.jpg)
• Latches– S-R Latch
– /S-/R Latch
– S-R Latch with Enable
– D Latch
• Flip-flops– Edge-Triggered D Flip-Flop
– Master/Slave S-R Flip-Flop
– Master/Slave J-K Flip-Flop
– Edge-Triggered J-K Flip-Flop
– T Flip-Flop
Types of Latches and Flip-flops
![Page 17: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/17.jpg)
• How to control it?
– Screwdriver
– Control inputs
• S-R latch (set-reset)
Back to the Bistable….
![Page 18: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/18.jpg)
S-R Latch
S
RQ
/Q
Schematic
S
R
Q
Q
Symbol
Q
/Q
Set
Reset
Consider:
1. Timing Diagram
2. Propagation delay
3. Minimum pulse width
4. Oscillation
Function Table
S R Q /Q
Hold 0 0 Last Q Last /Q
Reset 0 1 0 1
Set 1 0 1 0
ILLEGAL 1 1 0 0
![Page 19: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/19.jpg)
S-R latch Operation
Metastability is possibleif S and R are negated simultaneously.
S
RQ
/Q
Schematic
1
1
0
0
0
0
0
0
?
?
0
0
![Page 20: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/20.jpg)
S-R latch Timing Parameters
Minimum pulse widthPropagation delay
![Page 21: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/21.jpg)
S-R latch Symbols
![Page 22: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/22.jpg)
S-R latch using NAND gates:/S-/R Latch
Function Table
/S /R Q /Q
Illegal 0 0 1 1
Set 0 1 1 0
Reset 1 0 0 1
Hold 1 1 Last Q Last /Q
![Page 23: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/23.jpg)
S-R Latch with Enable
S
R
Q
Q
C
Only sensitive to S and Rwhen enabled (C=1)
Same oscillation problem
/S /R C Q /Q
0 0 1 Last Q Last /Q
0 1 1 0 1
1 0 1 1 0
1 1 1 1 1
x x 0 Last Q Last /Q
![Page 24: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/24.jpg)
D Latch
D
C
Q
Q
Store a data bit, not set/reset
‘Transparent latch’
Setup and Hold time
![Page 25: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/25.jpg)
D-latch Timing Parameters
Setup time Hold time
D should not change during:
tsetup (before C edge)+thold (after C edge)
Propagation delay from C or D
![Page 26: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/26.jpg)
Positive-Edge-Triggered D Flip-Flop
![Page 27: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/27.jpg)
D Flip-Flop Timing Parameters
Setup time Hold time
D should not change during:
tsetup (before C edge)+thold (after C edge)
Propagation delay from CLK
![Page 28: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/28.jpg)
D flip-flop Versus Latch
![Page 29: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/29.jpg)
Other D flip-flop Variations
Negative-edge
triggered
Clock Enable
Scan
![Page 30: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/30.jpg)
Scan Flip-Flops -- for testing
TE = 0 � normal operation
TE = 1 � test operation
�All of the flip-flops are hooked together in a daisy chain from external test input TI.
�Load up (“scan in”) a test pattern, do one normal operation, shift out (“scan out”) result on TO.
![Page 31: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/31.jpg)
Asynchronous Inputs
• Most flip-flops have two asynchronous inputs
• Preset and Reset (or Clear)
• Directly set or reset the /S-/R latches
• Operate independent of clock
• USE asynchronous inputs for logic functions ONLY for
system INITIALIZATION to a known state
![Page 32: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/32.jpg)
Master/Slave S-R Flip-Flop
S
R
Q
Q
C
“Pulse-triggered” S-R flip-flopPulse-catching behavior
S
R
Q
Q
C
S
R
Q
Q
C
S R C Q /Q
x x 0 Last Q Last /Q
0 0 Last Q Last /Q
0 1 0 1
1 0 1 0
1 1 Undef undef
![Page 33: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/33.jpg)
J-K Flip-flops
• Not used much anymore
![Page 34: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/34.jpg)
T (toggle) Flip-Flop
• T flip-flop changes state on every clock tick.
• Important for counters
![Page 35: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/35.jpg)
Sequential PALs
![Page 36: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/36.jpg)
Analysis of State Machines
Characteristic Equations
Describe the next state (QN) of a flip-flop as function of current state (Q) and inputs:
QN = f (Q, inputs) [or Q* = f (Q, inputs)]
Derived from basic function table for a given flip-flop type
![Page 37: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/37.jpg)
Characteristic Equations
Input Present
state
Next
state
D Q Q*
0 0 0
0 1 0
1 0 1
1 1 1
Q* = D
Q* = S + R’ Q
State Machine Analysis
Input Present
state
Next
state
S R Q Q*
0 0 0 0
0 0 1 1
0 1 x 0
1 0 x 1
1 1 x x
![Page 38: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/38.jpg)
hold
reset
set
toggle
Q* = J Q’ + K’ Q
Characteristic Equations
EN Q Q*
0 0 0
0 1 1
1 0 1
1 1 0
Q* = EN Q’ + EN’ Q
J K Q Q*
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0
![Page 39: Lecture 23: Latches & Flip-Flops](https://reader030.vdocuments.mx/reader030/viewer/2022032610/623940a435a2f901cf1c56d3/html5/thumbnails/39.jpg)
Characteristic Equations Summary
Device Type Characteristic Eq.
• S-R latch Q* = S + R’ Q
• D latch Q* = D
• Edge-triggered D flip-flop Q* = D
• Master/slave S-R flip-flop Q* = S + R’ Q
• Master/slave J-K flip-flop Q* = J Q’ + K’ Q
• Edge-triggered J-K flip-flop Q* = J Q’ + K’ Q
• T flip-flop Q* = Q’
• T flip-flop with enable Q* = EN Q’ + EN’ Q