Академический Документы
Профессиональный Документы
Культура Документы
Latches
o Objectives o Problem: Design a network to control a lamp from two
pushbutton switches labeled S and R. If we push switch S the
This section is the first dealing with sequential circuits. It light should turn on. If we then release S, the light should stay
introduces Flip-Flops, an important building block for most on. If we push switch R, the lamp should turn off and stay off
sequential circuits. after releasing R. Assume that both S and R are not pushed at
the same time. +
n First it defines the most basic sequential building block, the
RS latch, and investigates some of its properties.
S + Q
n Then, it introduces clocks and shows how they can be used ? Lamp
o Reading Assignment
Q
n Chapter 7, sections 7.1 through 7.7, in Brown & Vranesic.
1
o Unstable latch behavior (Oscillation)
n Assume that all gates have a fixed delay d modeled as n Now set S = R = 1, so that both Q and X are equal to 0 after
follows: at most a delay of d. Then change both R and S to 0 at
X d Y
X exactly the same time. Then
Y Q(t+d) = X(t)' and X(t+d) = Q(t)'
Y(t+d) = X(t) d
R S
d Q(t)
X(t) Q
S d
X(t+d)
X
n Then Q(t+d) = (R(t) + X(t))' = R(t)' • X(t)', and
X(t+d) = (S(t) + Q(t))' = S(t)' • Q(t)'
o Unstable latch behavior (Metastable state) n Now consider the behavior of the following circuit:
vi1 vo1 vi2 vo2
n Equivalent circuit for the latch when R = S = 0
vi1 vo1 vi2 vo2
Inverter 2
vin vi1,vo2
2
n Now consider connecting v02 to vi1
vo1 = vi2 vo2 = vi1
d d o Avoiding unstable behavior of SR latches
n Since both the oscillation and the metastable state are
u The dots on the graph represent points where the input outputs of undesirable behavior, we should try to avoid them. this can
the delays are equal.
u The dots on the two ends represent the two stable states of the
be done with the following rules:
system. Small changes in any of the signals are damped out u Do not change R and S from 1 to 0 at the same time.
quickly.
l This is necessary to avoid the oscillation behavior seen above
u The dot in the middle represents a metastable state. Small changes
in any of the signals are amplified and the circuit leaves the l One way to guarantee that this will not happen is to never allow them to both
metastable state. be 1 at the same time.
n The hill analogy: u Once you change an input, do not change it again until the circuit
has had time to complete all its signal transitions and reach a stable
n The latch could get in the metastable state in the following state.
way:
l This is necessary to avoid the metastable behavior illustrated above
R
S
Q
endmodule
o Propagation Delay of Ungated Latches module srlatch2 (s, r, q); module srlatch3 (s, r, q);
tPRQ - Delay from the R input to the Q output input s, r; input s, r;
output q; output q;
tPSQ - Delay from the S input to the Q output reg q; reg q;
tPRQ_L - Delay from the R input to the Q_L output
always @(s or r) always @(s or r)
tPSQ_L - Delay from the S input to the Q_L output if (s & r) q = 0; case ({s,r})
else if (~s & r) q = 0; 3: q = 0;
S else if (s & ~r) q = 1; 2: q = 1;
Q
1: q = 0;
tPSQ endmodule endcase
endmodule
3
9.2. Gated Latches o Gated SR Latch
o Clock Signals R
Q_L R Q
u Note that when CK is 0, the simple latch has both inputs 0 and the
inputs S and R have no effect
4
n Alternative Design of the gated D Latch o Propagation Delay of Gated Latches
n Since changes in the data inputs of a gated latch have no
CK effect unless the clock is asserted, propagation delay is not
D Q measured from the data inputs.
n Propagation delay is measured from the clock input to the
outputs.
tPCQ (or tPQ) - delay from time clock is asserted until the Q output changes
5
n Draw a timing diagram for this circuit assuming that the 9.3. Flip-Flops
propagation delay of the latch is greater than the clock
pulse width. o Dynamic Clock Inputs
CLK
n The gated latch only looks at its data inputs while the clock
DIN=1
is asserted; it ignores them at other times
Q1=0 u The window of time when the latch is looking at and reacting to its
Q2=0
inputs is the duration of the time that the clock is asserted
Q3=0 n It is easier to design the circuits that generate a latch’s data
Q4=0 inputs if the window when the latch is looking at the data
inputs is small.
n Draw a timing diagram for this circuit assuming that the u We could only assert the clock for a short time, but this creates
propagation delay of the latch is less than the clock pulse other problems
width. n Dynamic clock inputs and the latches that use them reduce
CLK the window to a very small time around an edge of the
DIN=1 clock
Q1=0 n There are two types of dynamic clock inputs, edge-
Q2=0 triggered and master-slave.
Q3=0
n Latches that use dynamic clocks are called flip-flop
Q4=0
n Note that Brown & Vranesic call this a master-slave flip- n The edge-triggered flip-flop behaves as if it samples its input during
rising edges of the clock, and that is the only time its output can change.
flop.
n The sampling window is very short, and that is the only time during
which the input signal must be held constant.
6
o Negative Edge-Triggered D Flip-Flops o Edge-Triggered JK Flip-Flops
Q1 Q2 n The JK Flip-Flop has two inputs J and K. All four possible
D D Q D Q Q
Q_L
input configurations are valid. The J acts like S and the K
CK Q CK Q
CK
acts like R, when there is only one input with value 1.
When both J and K are 1, the flip-flop toggles.
o Asynchronous Inputs
JK
Q 00 01 11 10
CLR_L
D R Q R Q Q D
PR
Q 0 0 0 1 1 J D Q Q
S Q S Q Q_L K
Q 1 1 0 0 1 Q Q_L
PR_L CLR CK
CK Q*
Logic Diagram Symbol Q* = J•Q’ + K’•Q
n If CLK is held at 0, the D flip-flop acts like an SR latch n What would happen if we used a gated D latch instead of
with PR the set input and CLR the reset input an edge triggered flip-flop?
7
n Pulse Catching n Verilog description of master-slave flip-flops
CK
module flipflopms (Ck, S, R, Q, master);
J input Ck, S, R;
output Q, master;
K reg master, Q;
QM
always @(Ck or S or R)
QS if (Ck) begin
if (S & ~R) master = 1;
else if (~S & R) master = 0;
n Comparison of flip-flop types else if (S & R) master = 0;
end
QL QMS QET else
S Q = master;
S Q S Q S Q
CK CK endmodule
R Q R Q R Q
R
CK
CK
S
R
QL
QMS
QET
OE
D Q
Combinational PAL
D Q n Sequential PLD Timing Specifications
tPD Input or feedback to combinational output delay
CK
tCO Clock to flip-flop output
tCF Clock to feedback signals (may not be given)
u Typical Characteristics tSU Setup time for input, or feedback signals
Common clock
l
l Common OE
tH Hold time for input signals
l Flip-flops feedback to combinational array
8
9.5. Tips & Tricks 9.7. Review
o Designing with flip-flops is much easier than with o The behavior of latches
gated latches. n Metastability
o Avoid the use of master-slave (pulse triggered) flip-
flops. o Adding clocks to latches - gated latches
o Latches can be used to debounce switches in the o The properties of dynamic clocks - flip-flops
following way: +
n Edge-triggering
RQ
o Types of flip-flops:
S Q n SR, D and JK
9. 6. Pitfalls o The transition table model for flip-flop behavior
o Ignoring flip-flop timing parameters.