Professional Documents
Culture Documents
• Last lecture:
– Finite State Machines
• This lecture:
– Digital circuits with feedback
– Clocks
– Flip-Flops
S Q'
R
S
Q
\Q
11/12/2004 EE 42 fall 2004 lecture 31 8
Race condition on falling edge of
S/R
• If both set and reset are high, then the
value latched will be whichever falling
edge happens last. If this is controlled by
delays in the logic, then the outcome of
which is first might be random, erratic, or
dependent on other parameters.
Clock
11/12/2004 EE 42 fall 2004 lecture 31 13
Gated R-S Latch
• Control when R and S
R' R
inputs matter Q
– Otherwise, the enable'
slightest glitch on R or Q'
S while enable is low S' S
could cause
change in value stored
Set Reset
100
S'
R'
enable'
Q
Q'
11/12/2004 EE 42 fall 2004 lecture 31 14
R-S latch controlled with clock
• Controlling an R-S latch with a clock
– Can't let R and S change while clock is active (allowing R and S
to pass)
– Only have half of clock period for signal changes to propagate
– Signals must be stable for the other half of clock period
R' R
Q
clock'
Q'
S' S
stable changing stable changing stable
R' and S'
clock
11/12/2004 EE 42 fall 2004 lecture 31 15
active low
Edge Trigger
• Edge Trigger refers to the capture of a
value at a rising or falling edge of a signal.
For example, the data from a memory
might be held valid and sampled at a rising
edge of a clock
Data
Clock
11/12/2004 EE 42 fall 2004 lecture 31 16
Definition: Flip-Flop
• A flip flop is a digital circuit which will
capture a value at a rising (or falling) edge,
and will hold that value. It will only change
the value held at an edge, and will not
pass on transitions from the inputs while
the clock or latch signal is either high or
low.
R R Q' R Q'
S S Q S Q
clock
S S Q S Q
P
CLK
11/12/2004 EE 42 fall 2004 lecture 31 19
The 1s Catching Problem
• In first R-S stage of master-slave FF
– 0-1-0 glitch on R or S while clock is high "caught" by master
stage
– Leads to constraints on logic to be hazard-free
master stage slave stage
R P'
1s R Q' R Q'
Set Reset catch
S S Q S Q
P
S CLK
R
CLK
P Master
P' Outputs
Q Slave
Q' Outputs
D S Q S Q Q
P
CLK
10 gates
11/12/2004 EE 42 fall 2004 lecture 31 21
Edge triggering
• The proceeding slide showed how a flip
flop could be designed by using two
latches which are cascaded in a master-
slave relationship.
• Another way of creating an edge triggered
flip flop is to use logic with feedback, as in
the following slide.
holds D when
clock goes low
characteristic equation
D Q(t+1) = D
11/12/2004 EE 42 fall 2004 lecture 31 23
Edge-Triggered Flip-Flops
(cont’d)
• Step-by-step analysis D’ D
D’ D
D’
D’ R
Q
R
Q
Clk=0
Clk=0
S
S D
D
new D D’
D D’
when clock is low
when clock goes high-to-low new D old D data is held
11/12/2004 data is latched EE 42 fall 2004 lecture 31 24
Edge-Triggered Flip-Flops
(cont’d)
• Positive edge-triggered
– Inputs sampled on rising edge; outputs change after rising edge
• Negative edge-triggered flip-flops
– Inputs sampled on falling edge; outputs change after falling edge
100
D
CLK
Qpos
positive edge-triggered FF
Qpos'
Qneg
negative edge-triggered FF
Qneg'
clock clock
CLK D
positive
edge-triggered
flip-flop CLK
Qedge
D Q
G Qlatch
CLK
transparent
(level-sensitive)
latch behavior is the same unless input changes
while the clock is high
11/12/2004 EE 42 fall 2004 lecture 31 28
Comparison of Latches and
Flip-Flops (cont’d)
Type When inputs are sampled When output is valid
unclocked always propagation delay from input change
latch
CLK Tw 25ns
Tplh Tphl
Q 25ns 40ns
13ns 25ns
all measurements are made from the clocking event that is,
the rising edge of the clock
11/12/2004 EE 42 fall 2004 lecture 31 30
Definition: Metastability
• Metastability is a condition in which a latch
or a Flip-Flop is exactly balanced between
the logic high and logic low states. This
can be caused by an asynchronous data
signal input to a clocked Flip Flop. The
resulting output may stay undefined for
some time.
• Shift register
– New value goes into first stage
– While previous value of first stage goes into second stage
– Consider setup/hold/propagation delays (prop must be > hold)
Q0 Q1
IN D Q D Q OUT
CLK
100
IN
Q0
Q1
CLK
11/12/2004 EE 42 fall 2004 lecture 31 32
Cascading Edge-triggered Flip-
Flops (cont’d)
• Why this works
– Propagation delays exceed hold times
– Clock width constraint exceeds setup time
– This guarantees following stage will latch current value before it
changes to new value
In
Tsu Tsu
timing constraints
4ns 4ns
guarantee proper
Q0
operation of
Tp Tp
3ns 3ns cascaded components
Q1
Th Th
11/12/2004 2ns 2ns
EE 42 fall 2004 lecture 31 33
Clock Skew
• The problem
– Correct behavior assumes next state of all storage elements
determined by all storage elements at the same time
– tThis is difficult in high-performance systems because time for
clock to arrive at flip-flop is comparable to delays through logic
– Effect of skew on cascaded flip-flops:
In 100
Q0
Q1 CLK1 is a delayed
CLK0 version of CLK0
CLK1
original state: IN = 0, Q0 = 1, Q1 = 1
due to skew, next state becomes: Q0 = 0, Q1 = 0, and not Q0 = 0, Q1 = 1
11/12/2004 EE 42 fall 2004 lecture 31 34
Summary of Latches and Flip-
Flops
• Development of D-Flip-Flop
– Level-sensitive used in custom integrated circuits
• can be made with 4 switches
– Edge-triggered used in programmable logic devices
– Good choice for data storage register
• Historically J-K Flip Flop was popular but now never used
– Similar to R-S but with 1-1 being used to toggle output (complement state)
– Can always be implemented using D-FF
• Preset and clear inputs are highly desirable on flip-flops
– Used at start-up or to reset system to a known state