Unit 9 Latches and Flip-Flops - National Chiao Tung …moblie123.cm.nctu.edu.tw/101 logical...
Transcript of Unit 9 Latches and Flip-Flops - National Chiao Tung …moblie123.cm.nctu.edu.tw/101 logical...
Department of Communication Engineering, NCTU 1
Unit 9 Latches and Flip-Flops
Department of Communication Engineering, NCTU 2
9.1 Introduction
Department of Communication Engineering, NCTU 3
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
What is the characteristic of sequential circuits in contrastto combinational circuits? The output of a sequential circuit depends not only on the
present input, but also on the past sequence of inputs In effect, sequential circuits are able to remember the past
history of inputs
Two of the commonly used memory devices in sequentialcircuits are latches and flip-flops
Flip-flops change states in response to a clock input,however latches change states in response to data inputs
Either latches of flip-flops are formed through feedbacks
Department of Communication Engineering, NCTU 4
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
A unstable feedback
A bi-stable feedback
How do we control stable outputs?
Department of Communication Engineering, NCTU 5
9.2 Set-Reset Latch
Department of Communication Engineering, NCTU 6
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
Introducing control inputs to a feedback circuit
0101
1010
Pn-1Qn-100
0/10/111
PQRS
Unstable when S and R bothswitch from 1 to 0 simultaneously
Department of Communication Engineering, NCTU 7
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The response time of a latch
The duration of the S (or R) input pulse must be longerthan in order for a change in the state of Q to occur
Department of Communication Engineering, NCTU 8
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
0 1
We use the term present state to mean the state of Q atthe time the inputs are applied, and the term next state tomean the state of Q after the latch or flip-flop has reactedto the inputs
Characteristic EquationQ(t +ε) =S(t) + R(t)’Q(t)
Department of Communication Engineering, NCTU 9
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
Debouncing circuit with a S-R latch When a mechanical switch is opened or closed, the switch
contacts tend to vibrate or bounce open or closed severaltimes before settling down to their final positions
Department of Communication Engineering, NCTU 10
9.3 Gated D Latch
Department of Communication Engineering, NCTU 11
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
A gated D latch has two inputs- a data input (D) and agate input (G).
When G = 0, the output Q doesn’t change. When G=1, theQ output follows the D input
Department of Communication Engineering, NCTU 12
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The symbol and the truth table for gated D-latch
Department of Communication Engineering, NCTU 13
9.4 Edge-Trigged D Flip-Flop
Department of Communication Engineering, NCTU 14
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The output of a D flip-flop (FF) changes only in responseto a clock, not a change in D
A D flip-flop has two inputs, D (data) and Ck (clock) A D-FF is said to be triggered on the rising edge of the
clock if the output can change in response to the 0-to-1transition on the clock input
If the output can change upon the 1-to-0 clock transition,then the D-FF is said to be triggered on the falling edge
Department of Communication Engineering, NCTU 15
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The time diagram for a falling-edge-triggered D-FF
Department of Communication Engineering, NCTU 16
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
A rising-edge-triggered D-FF
Department of Communication Engineering, NCTU 17
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
In order to function properly, the D input to a edge-triggered FF must be held constant for a period of timebefore and after the active edge of the clock
If D changes at the same time as the active edge, thebehavior is unpredictable
Setup time Hold time
Propagation delay
Department of Communication Engineering, NCTU 18
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The minimum clock period
Department of Communication Engineering, NCTU 19
9.5 S-R Flip-Flop
Department of Communication Engineering, NCTU 20
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
A S-R FF is similar to a S-R latch in that S=1 sets Q to 1,and R=1 set Q to 0. The difference is that the flip-flop hasa clock input
Department of Communication Engineering, NCTU 21
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The master-slave S-R FF
Department of Communication Engineering, NCTU 22
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
There is a subtle difference between the master-slave andthe edge-trigged flip-flop For a rising-edge-triggered flip-flop, the value of the input
is sensed at the rising edge of the clock, and the input canchange while the clock is low
For the master-slave flip-flop, if the input change while theclock is low, the flip-flop output may be incorrect See an example at the previous page The problem can be solved if we only allow the S and R
inputs to change while the clock is high
Department of Communication Engineering, NCTU 23
9.6 J-K Flip-Flop
Department of Communication Engineering, NCTU 24
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
J-K flip-flop is an extended version of the S-R flip-flop The J-K FF has three inputs, J, K and clock:
J corresponds to S and K corresponds to K
Unlike the S-R FF, a 1 input may be appliedsimultaneously to J and K. Q →Q’when J=K=1
Department of Communication Engineering, NCTU 25
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The timing diagram of J-K FF
Department of Communication Engineering, NCTU 26
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The master-slave J-K FF Because S= JQ’Clk’and R=KQClk’, only one of S and R
inputs to the first latch can be 1 at any given time Notice that a master-slave FF is different from the edge-
trigged FF
Department of Communication Engineering, NCTU 27
9.7 T Flip-Flop
Department of Communication Engineering, NCTU 28
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The T flip-flop is also called the toggle flip-flop When T=1, the flip-flop changes state after the active
edge of the clock. When T=0, no state change occurs
Department of Communication Engineering, NCTU 29
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
Two common methods to implement a T-FF (a) Conversion of J-K to T (b) Conversion of D to T , D=T⊕Q
Department of Communication Engineering, NCTU 30
9.8 Flip-Flops with AdditionalInputs
Department of Communication Engineering, NCTU 31
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
Flip-flop with clear and preset inputs A logic 0 applied to ClrN will reset Q to 0 A logic o applied to PreN will set Q to 1 ClrN and PreN are often referred to as asynchronous clear
and preset inputs
Department of Communication Engineering, NCTU 32
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
The operation of the clear and preset inputs
Department of Communication Engineering, NCTU 33
Logic Design Unit 9 Latches and Flip-Flops Sau-Hsuan Wu
When designing a synchronous system, we frequentlyencounter situations where we want some flip-flops tohold existing data even if the data input to the flip-flopsmay be changing. There are two approaches: Gating the clock → may results in loss of synchronization A flip-flop with clock enable → cost extra power