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=1E=1 makes the latch transparent: its output QQ follows data input DD, after propagation delay. When E=0E=0, the latch holds its stored value even if DD changes.


Writing Q+Q^+ for the next stored state gives the ideal rule


Q+={D,E=1Q,E=0.Q^+=\begin{cases}D,&E=1\\Q,&E=0.\end{cases}


A flip-flop is an edge-triggered storage device. A rising-edge D flip-flop samples DD 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.


Q+=D sampled at the active clock edge.Q^+=D\text{ sampled at the active clock edge.}


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.


Clock and data waveforms are compared with the outputs of a transparent D latch and a rising-edge D flip-flop.


At 15 ns15\ \text{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 ns40\ \text{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 SS and reset RR. The JK column applies to inputs sampled at a flip-flop's active edge.


Input pair

NOR SR latch: S,RS,R

JK flip-flop: J,KJ,K

0,00,0

Hold the stored state

Hold the stored state

0,10,1

Reset: Q=0Q=0

Reset: Q+=0Q^+=0

1,01,0

Set: Q=1Q=1

Set: Q+=1Q^+=1

1,11,1

Forbidden operating condition

Toggle: Q+=Q‾Q^+=\overline{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=0T=0 and toggles when T=1T=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=0Q=0 without waiting for a clock edge, after its specified delay. An asserted preset forces Q=1Q=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 tct_c, setup time tsut_{su} and hold time tht_h require


tlast change≤tc−tsu,tnext change≥tc+th.t_{\text{last change}}\leq t_c-t_{su},\qquad t_{\text{next change}}\geq t_c+t_h.


Clock-to-Q propagation delay describes how long the output takes to respond after a valid capture. A maximum delay tpcq,max⁡t_{pcq,\max} means the specified new output is valid by tc+tpcq,max⁡t_c+t_{pcq,\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=0t=0, Q=0Q=0. The device has:

  • Setup time tsu=3 nst_{su}=3\ \text{ns}.
  • Hold time th=2 nst_h=2\ \text{ns}.
  • Maximum clock-to-Q delay tpcq,max⁡=4 nst_{pcq,\max}=4\ \text{ns} for valid captures.
  • Active-low asynchronous clear, CLR‾\overline{\text{CLR}}, with a maximum assertion-to-Q delay of 2 ns2\ \text{ns}.

The clock has rising edges at 20 ns20\ \text{ns} and 50 ns50\ \text{ns}. Data is 0 until 16 ns16\ \text{ns}, then 1 until 49 ns49\ \text{ns}, then 0. Clear remains high until 62 ns62\ \text{ns}, when it is asserted low and held low. Assume clear dominates ordinary data capture and satisfies its pulse-width requirement.


Clock, data, and active-low clear waveforms show two sampling edges followed by clear assertion.


a) Check setup and hold at the 20 ns20\ \text{ns} edge. Determine the captured value and the latest time it is guaranteed valid at QQ.


Before the edge, data has been stable at 1 since 16 ns16\ \text{ns}. The available setup interval and its margin are


tbefore=20−16=4 ns,msu=4−3=1 ns.t_{\text{before}}=20-16=4\ \text{ns},\qquad m_{su}=4-3=1\ \text{ns}.


After the edge, data remains unchanged until 49 ns49\ \text{ns}. Thus,


tafter=49−20=29 ns,mh=29−2=27 ns.t_{\text{after}}=49-20=29\ \text{ns},\qquad m_h=29-2=27\ \text{ns}.


Both margins are ________, and clear is inactive. The flip-flop reliably captures D=1D=1. Its output is guaranteed to have reached that value by


tQ,valid=20+4=24 ns.t_{Q,\text{valid}}=20+4=24\ \text{ns}.


Therefore, Q=1Q=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 ns50\ \text{ns} edge. Can you guarantee the captured value from the given specifications?


Data falls to 0 at 49 ns49\ \text{ns}, only 1 ns1\ \text{ns} before the edge. The setup margin is


msu=(50−49)−3=1−3=−2 ns.m_{su}=(50-49)-3=1-3=-2\ \text{ns}.


The latest permitted data transition was


tlatest=50−3=47 ns.t_{\text{latest}}=50-3=47\ \text{ns}.


The actual transition at 49 ns49\ \text{ns} is 2 ns2\ \text{ns} ________. Data stays low beyond 52 ns52\ \text{ns}, so the 2 ns2\ \text{ns} hold requirement is ________.


Nevertheless, setup is violated. Although D=0D=0 at the edge, the captured bit is not guaranteed. The output may capture either value or become metastable. The ordinary 4 ns4\ \text{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 ns62\ \text{ns} asserts it. Because clear is asynchronous and dominant, it forces Q=0Q=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:


tQ,cleared=62+2=64 ns.t_{Q,\text{cleared}}=62+2=64\ \text{ns}.


Thus, Q=0Q=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.

An active-high D latch stores Q=0Q=0. Its enable input remains at E=0E=0 while DD changes from 0 to 1. There are no asynchronous controls. After all propagation delays have passed, what is the output?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

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.

Match each term
A.

Holds, resets, sets or complements the stored output at a rising clock edge according to its two control inputs

B.

Forces the stored output to 0 while asserted, independently of clock edges

C.

Copies its data input to the stored output at each rising clock edge

D.

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

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

An ideal SR latch consists of two cross-coupled NOR gates with active-high inputs SS and RR, 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?


Two cross-coupled NOR gates form an SR latch with inputs S and R and outputs Q and Q bar.


Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice