Latches and Flip-Flops
Latches and flip-flops store one binary digit, or bit. Their output depends on both their inputs and a previously stored state. You encounter them when a digital system needs to remember a switch setting or capture a signal at a chosen instant. To predict their behavior, identify when the device accepts data, what its inputs request, and whether the timing requirements are satisfied.
When storage accepts data
A latch is a level-sensitive storage device. For an active-high D latch, enable E=1 makes the latch transparent: its output Q follows data input D, after propagation delay. When E=0, the latch holds its stored value even if D changes.
Writing Q+ for the next stored state gives the ideal rule
A flip-flop is an edge-triggered storage device. A rising-edge D flip-flop samples D at a low-to-high clock transition. A falling-edge device samples at a high-to-low transition. Between active edges, ordinary data changes do not update its stored state.
The figure compares an active-high D latch and a rising-edge D flip-flop driven by the same timing signal. Higher trace levels represent logic 1; lower levels represent logic 0.
At 15 ns, the latch accepts the rising data while enable is high. The flip-flop waits until an active edge samples a high input at 40 ns.
What the inputs request
Different input types describe different state-change rules. The following table uses an active-high, cross-coupled NOR SR latch. Its inputs are set S and reset R. The JK column applies to inputs sampled at a flip-flop's active edge.
Input pair | NOR SR latch: S,R | JK flip-flop: J,K |
|---|---|---|
0,0 | Hold the stored state | Hold the stored state |
0,1 | Reset: Q=0 | Reset: Q+=0 |
1,0 | Set: Q=1 | Set: Q+=1 |
1,1 | Forbidden operating condition | Toggle: Q+=Q |
For this NOR SR convention, asserting both inputs forces both latch outputs low. They are then no longer complements, and simultaneous release does not guarantee which state will remain. A NAND SR latch commonly uses active-low inputs, so its input convention differs.
A D input directly requests the stored bit. A T flip-flop holds when T=0 and toggles when T=1 at the active edge. Toggle means complementing the previous state, not continuously oscillating while an input remains high.
Asynchronous controls
Some devices also have asynchronous preset or clear inputs. An asserted asynchronous clear forces Q=0 without waiting for a clock edge, after its specified delay. An asserted preset forces Q=1.
Check polarity: an active-low control is asserted at logic 0. On a symbol, a small input bubble commonly indicates active-low operation; a clock-input triangle indicates edge triggering. A bubble together with the clock triangle indicates falling-edge triggering.
Do not assume a power-up state or a priority between simultaneously asserted preset and clear. Use the device specification. Releasing asynchronous controls also has timing requirements relative to the clock.
Setup, hold, and output delay
Reliable capture requires data to remain stable around the sampling event. For a rising-edge flip-flop with edge time tc, setup time tsu and hold time th require
Clock-to-Q propagation delay describes how long the output takes to respond after a valid capture. A maximum delay tpcq,max means the specified new output is valid by tc+tpcq,max. It does not shift the sampling instant. A D latch similarly requires valid data timing around the event that closes its transparent interval.
What to remember
- A latch accepts data during its enabled level; a flip-flop samples at its active edge.
- Input type determines whether the device holds, sets, resets, captures, or toggles.
- Check asynchronous controls before applying ordinary clocked behavior.
- Setup and hold govern reliable capture; propagation delay governs output response.
Example: Capturing a controller input
A controller samples a digital sensor using a rising-edge D flip-flop. At t=0, Q=0. The device has:
- Setup time tsu=3 ns.
- Hold time th=2 ns.
- Maximum clock-to-Q delay tpcq,max=4 ns for valid captures.
- Active-low asynchronous clear, CLR, with a maximum assertion-to-Q delay of 2 ns.
The clock has rising edges at 20 ns and 50 ns. Data is 0 until 16 ns, then 1 until 49 ns, then 0. Clear remains high until 62 ns, when it is asserted low and held low. Assume clear dominates ordinary data capture and satisfies its pulse-width requirement.
a) Check setup and hold at the 20 ns edge. Determine the captured value and the latest time it is guaranteed valid at Q.
Before the edge, data has been stable at 1 since 16 ns. The available setup interval and its margin are
After the edge, data remains unchanged until 49 ns. Thus,
Both margins are ________, and clear is inactive. The flip-flop reliably captures D=1. Its output is guaranteed to have reached that value by
Therefore, Q=1 is guaranteed by 24 ns. A maximum delay gives a deadline; the actual transition may occur earlier.
b) Check setup and hold at the 50 ns edge. Can you guarantee the captured value from the given specifications?
Data falls to 0 at 49 ns, only 1 ns before the edge. The setup margin is
The latest permitted data transition was
The actual transition at 49 ns is 2 ns ________. Data stays low beyond 52 ns, so the 2 ns hold requirement is ________.
Nevertheless, setup is violated. Although D=0 at the edge, the captured bit is not guaranteed. The output may capture either value or become metastable. The ordinary 4 ns maximum clock-to-Q delay cannot establish a valid output deadline for this violated capture.
c) What value does clear force, and by what time is that value guaranteed?
The clear input is active-low, so its transition from ________ at 62 ns asserts it. Because clear is asynchronous and dominant, it forces Q=0 without waiting for another rising clock edge, regardless of the uncertain preceding capture.
Add the maximum clear-to-Q delay to the assertion time:
Thus, Q=0 is guaranteed by 64 ns and remains forced low while clear stays asserted. The clear timing uses its own specified delay rather than the clock-to-Q delay.
A technician is choosing storage devices for a digital controller. Match each device or control to its behaviour. The flip-flops are rising-edge triggered, and asynchronous controls are inactive except when the description explicitly asserts one.
Holds, resets, sets or complements the stored output at a rising clock edge according to its two control inputs
Forces the stored output to 0 while asserted, independently of clock edges
Copies its data input to the stored output at each rising clock edge
Holds when its control input is 0 and complements the stored output when that input is 1 at a rising clock edge
Asynchronous clear
T flip-flop
D flip-flop
JK flip-flop
An ideal SR latch consists of two cross-coupled NOR gates with active-high inputs S and R, as shown. It has no added priority logic. Both inputs are held at 1 long enough for the outputs to settle, then both are returned to 0 simultaneously. Which statement correctly describes the outputs while both inputs are 1 and the stored state after release?