Introduction

Latches and flip-flops are bistable memory elements. A latch is level-sensitive: while the enable is asserted it follows the input. A flip-flop is edge-triggered: it samples on a clock edge. Characteristic tables say what the next state is; excitation tables say what inputs are needed to force a desired transition.

GATE tests SR latch behaviour (including the forbidden input), the characteristic and excitation tables, conversions between flip-flop types, the race-around condition, sequences of states under given inputs, and setup, hold and maximum clock frequency.

Prerequisites

Core concepts

SR latch (NOR or NAND)

Cross-coupled NOR: Q=R+Q‾‾Q = \overline{R + \overline{Q}}, Q‾=S+Q‾\overline{Q}=\overline{S+Q}.

SSRRNOR latch result
00hold QQ
01reset, Q=0Q = 0
10set, Q=1Q = 1
11forbidden: Q=Q‾=0Q = \overline{Q} = 0

With S=R=1S = R = 1 both outputs are 0, so they are no longer complements. If both inputs then return to 0 together, the final state depends on which gate is faster (a race). Under the constraint SR=0SR = 0, the characteristic equation is Q+=S+R′QQ^+ = S + R'Q.

The cross-coupled NAND latch has active-low inputs S‾,R‾\overline{S},\overline{R}: S‾ R‾=11\overline{S}\,\overline{R} = 11 holds, 0101 sets Q=1Q = 1, 1010 resets Q=0Q = 0, and 0000 is forbidden, driving both outputs to 1.

Gated (enable) latch

AND (or NAND) gates qualify S,RS,R or DD with enable. Transparent when enable =1=1 (for active-high).

D latch

DD input with S=DS=D, R=D′R=D'. No forbidden combination; QQ follows DD while enabled and holds the last value when the enable drops.

Edge-triggered flip-flops

Built from master-slave latches or pulse-triggered designs so the output changes only on the active clock edge (rising or falling). Types:

TypeCharacteristic Q+Q^+Excitation (to get Q→Q+Q\to Q^+)
DQ+=DQ^+ = DD=Q+D = Q^+
TQ+=Q⊕TQ^+ = Q\oplus TT=Q⊕Q+T = Q\oplus Q^+
JKQ+=JQ′+K′QQ^+ = JQ' + K'Qsee table below
SR (FF)like latch; forbid S=R=1S=R=1S=1S=1 to set, R=1R=1 to reset

JK excitation.

QQQ+Q^+JJKK
000X
011X
10X1
11X0

SR and T excitation.

QQQ+Q^+SSRRTT
000X0
01101
10011
11X00

JK characteristic table. JK=00JK = 00 holds, 0101 resets, 1010 sets, 1111 toggles. The JK flip-flop is an SR flip-flop in which the forbidden input becomes "toggle". Every JK excitation row has one don't-care, because two input pairs reach each next state: from Q=0Q = 0, both JK=10JK = 10 (set) and JK=11JK = 11 (toggle) give Q+=1Q^+ = 1.

Setup and hold times

  • Setup time tsut_{su}: data must be stable at least tsut_{su} before the active clock edge.
  • Hold time tht_h: data must remain stable at least tht_h after the edge.
  • Clock-to-Q tcQt_{cQ}: delay from the edge to the new output.
  • Violation risks metastability. Minimum clock period also needs combinational delay between FFs: T≥tcQ+tlogic+tsuT \ge t_{cQ} + t_{logic} + t_{su} (plus skew terms in fuller models).
SR, D, JK and T characteristic and excitation tables
Figure 1. Side-by-side characteristic equations and excitation tables for D, T, JK and SR flip-flops.
Edge-triggered timing: setup, hold and clock-to-Q
Figure 2. Timing diagram of a rising-edge D flip-flop showing tsut_{su}, tht_h, and tcQt_{cQ} relative to the clock edge and data window.

How it works

Master-slave intuition

Master latch samples while clock is high (or low); slave updates on the opposite phase, yielding overall edge behaviour. Modern FFs use more robust edge circuits; exam diagrams still show master-slave.

Race-around in a level-triggered JK

Build a JK from a gated SR latch by feeding back the outputs: S=JQ′S = JQ' and R=KQR = KQ, enabled while the clock is high. With J=K=1J = K = 1 the latch toggles, the new output feeds back, and it toggles again, as long as the clock stays high. The output oscillates whenever the clock pulse width exceeds the loop's propagation delay; the final value when the clock falls is unpredictable. This is the race-around condition. The cures are a master-slave JK (the master is closed while the slave changes) or an edge-triggered JK. A very narrow clock pulse also avoids it but is fragile.

Conversions

Procedure: write the characteristic table of the target flip-flop (inputs and QQ to Q+Q^+); for each row, read from the available flip-flop's excitation table the inputs that produce that Q→Q+Q \to Q^+; minimise those inputs as functions of the target inputs and QQ.

Target from availableWiring
D from JKJ=DJ=D, K=D′K=D'
T from JKJ=K=TJ=K=T
JK from DD=JQ′+K′QD = JQ' + K'Q
T from DD=T⊕QD = T \oplus Q
D from TT=D⊕QT = D \oplus Q
JK from TT=JQ′+KQT = JQ' + KQ
JK from SRS=JQ′S = JQ', R=KQR = KQ
SR from JKJ=SJ = S, K=RK = R (valid while SR=0SR = 0)

Check of T from JK: Q+=TQ′+T′Q=T⊕QQ^+=TQ'+T'Q=T\oplus Q. Check of D from JK: Q+=DQ′+DQ=DQ^+=DQ'+DQ=D.

Timing

For a path from flip-flop 1 through logic to flip-flop 2, both on the same clock:

T≥tcQ,max⁡+tlogic,max+tsu,fmax⁡=1tcQ,max⁡+tlogic,max+tsu,T \ge t_{cQ,\max}+t_{\mathrm{logic,max}}+t_{su},\qquad f_{\max}=\frac1{t_{cQ,\max}+t_{\mathrm{logic,max}}+t_{su}},
tcQ,min⁡+tlogic,min≥th.t_{cQ,\min}+t_{\mathrm{logic,min}}\ge t_h .

The setup check uses the slowest path and depends on TT. The hold check uses the fastest path and does not involve the clock period at all, so slowing the clock never fixes a hold violation. With clock skew tskewt_{\mathrm{skew}} (positive when the receiving FF sees the clock later):

T≥tcQ,max⁡+tlogic,max+tsu−tskew,tcQ,min⁡+tlogic,min≥th+tskew.T\ge t_{cQ,\max}+t_{\mathrm{logic,max}}+t_{su}-t_{\mathrm{skew}},\qquad t_{cQ,\min}+t_{\mathrm{logic,min}}\ge t_h+t_{\mathrm{skew}} .

Positive skew helps setup and hurts hold. Many timing problems ignore skew; include it only when the stem names it.

Algorithms and pseudocode

Next-state functions for a bank of FFs use the characteristic equations. EXCITE inverts any characteristic function by trying every input combination.

Text
D-NEXT(D)
1  return D

T-NEXT(Q, T)
1  return Q XOR T

JK-NEXT(Q, J, K)
1  return (J AND NOT Q) OR ((NOT K) AND Q)

EXCITE(NEXT, Q, Qplus, inputs)   // which inputs drive Q to Qplus
1  ok <- empty list
2  for each assignment x of inputs
3      if NEXT(Q, x) = Qplus then append x to ok
4  return ok    // an input is X if it varies across ok while the others are fixed

For a flip-flop with kk inputs, EXCITE does 2k2^k evaluations per row, 4 rows in all.

Cost of a conversion. Best, average and worst case are the same, because no step depends on the data. A target flip-flop with tt inputs has a characteristic table of 2t+12^{t+1} rows (its inputs and QQ). Each row needs one excitation lookup for the available flip-flop, or 2k2^k EXCITE evaluations if it has kk inputs. JK from T has 8 rows and 16 evaluations; D from JK has 4 rows and 16 evaluations. Minimisation is then a K-map on t+1≤3t + 1 \le 3 variables.

Mathematical explanation

A flip-flop is a finite automaton with two states {0,1}\{0,1\} and inputs that determine the transition function Q+=δ(Q,inputs)Q^+=\delta(Q,\textit{inputs}). Excitation tables invert δ\delta (with don't-cares where two inputs work).

Why the JK equation has that form. Q+=1Q^+ = 1 when Q=0Q = 0 and J=1J = 1 (set or toggle), or when Q=1Q = 1 and K=0K = 0 (hold or set). That is JQ′+K′QJQ' + K'Q. In the same way, Q+=S+R′QQ^+ = S + R'Q for SR: set, or stay at 1 unless reset.

Worked examples

Example 1: JK with J=1,K=0,Q=0J=1,K=0,Q=0

Q+=1⋅1+1⋅0=1Q^+ = 1\cdot 1 + 1\cdot 0 = 1 (set).

Example 2: toggle

T FF with T=1T=1 each cycle: state sequence 0,1,0,1,…0,1,0,1,\ldots (divide-by-2). A D flip-flop with D=Q′D = Q' behaves the same way, as does a JK with J=K=1J = K = 1.

Example 3: excitation for Q→Q+=1→0Q\to Q^+ = 1\to 0 with JK

Need K=1K=1, JJ don't-care: JK=01JK = 01 resets and JK=11JK = 11 toggles, and both give 0.

Example 4: period constraint

If tcQ=1 nst_{cQ}=1\,\mathrm{ns}, tlogic=3 nst_{logic}=3\,\mathrm{ns}, tsu=0.5 nst_{su}=0.5\,\mathrm{ns}, then T≥4.5 nsT\ge 4.5\,\mathrm{ns} (ignore skew) and fmax⁡=1/4.5 ns≈222.2 MHzf_{\max} = 1/4.5\,\mathrm{ns} \approx 222.2\,\mathrm{MHz}.

Example 5: setup, hold and skew together

Take tcQ=2t_{cQ} = 2, tlogic,max=5t_{\mathrm{logic,max}} = 5, tlogic,min=1t_{\mathrm{logic,min}} = 1, tsu=1t_{su} = 1, th=2t_h = 2 (all ns).

  • No skew: T≥2+5+1=8 nsT \ge 2 + 5 + 1 = 8\,\mathrm{ns}, so fmax⁡=125 MHzf_{\max} = 125\,\mathrm{MHz}. Hold: 2+1=3≥22 + 1 = 3 \ge 2, met with 1 ns of margin.
  • Skew +1 ns+1\,\mathrm{ns}: T≥7 nsT \ge 7\,\mathrm{ns} (fmax⁡≈142.9 MHzf_{\max} \approx 142.9\,\mathrm{MHz}); hold needs 3≥33 \ge 3, met with no margin.
  • Skew +2 ns+2\,\mathrm{ns}: T≥6 nsT \ge 6\,\mathrm{ns}, but hold needs 3≥43 \ge 4, which fails at every clock frequency.

Example 6: a JK sequence

Start at Q=0Q = 0 and apply (J,K)=(1,0),(1,1),(0,0),(1,1),(0,1)(J,K) = (1,0), (1,1), (0,0), (1,1), (0,1) on successive edges. The states after each edge are 11 (set), 00 (toggle), 00 (hold), 11 (toggle), 00 (reset).

Example 7: convert a T flip-flop into JK

Target JK, available T, so T=Q⊕Q+T = Q \oplus Q^+ row by row. With Q=0Q = 0, Q+=JQ^+ = J, so T=JT = J. With Q=1Q = 1, Q+=K′Q^+ = K', so T=KT = K. Together T=JQ′+KQT = JQ' + KQ. Check the toggle row J=K=1J = K = 1: T=Q′+Q=1T = Q' + Q = 1.

Example 8: SR latch sequence

A NOR latch starts with Q=0Q = 0. Inputs SR=10,00,01,00,10SR = 10, 00, 01, 00, 10 in turn give Q=1,1,0,0,1Q = 1, 1, 0, 0, 1. Applying SR=11SR = 11 would give Q=Q‾=0Q = \overline{Q} = 0, and a following SR=00SR = 00 would leave the result to the race.

Important properties and observations

  • Latch vs FF: level vs edge; never clock a latch with the same policy as an edge FF without analysing transparency races.
  • Asynchronous preset/clear override the clocked path when asserted.
  • Metastability: resolving time is unbounded in theory; practical synchronizers cascade FFs.
  • D is the simplest to design with (excitation equals the next state); JK gives the most don't-cares in excitation maps and often the simplest input logic.

Common misconceptions.

  • "SR=11 stores 1." Forbidden; undefined/race.
  • "Hold time is always zero." Not true for all libraries; still examined conceptually.
  • "A T flip-flop needs T=1T = 1 on every edge." T=1T = 1 toggles; to hold, set T=0T = 0.
  • "A hold violation can be fixed by slowing the clock." The hold check does not contain TT; only more delay on the short path (or less skew) helps.
  • "Master-slave JK has race-around." The master-slave structure is what removes it.

GATE examination perspective

  • CHARACTERISTIC VS EXCITATION. Do not swap the tables.
  • FORBIDDEN SR. Spot S=R=1S=R=1 (NOR) or S‾=R‾=0\overline{S} = \overline{R} = 0 (NAND).
  • CONVERSION. Target characteristic, then available excitation, then minimise.
  • RACE-AROUND. Level-triggered JK with J=K=1J = K = 1 and a wide clock pulse.
  • TIMING. Setup uses maximum propagation delays; hold uses minimum contamination delays and is independent of TT. Apply skew with the stated sign convention.
  • SEQUENCES. Apply the characteristic equation edge by edge.

All numerical timing examples that give only one tcQt_{cQ} use an idealised fixed-delay model: tcQ,min⁡=tcQ,max⁡=tcQt_{cQ,\min}=t_{cQ,\max}=t_{cQ}. In a real timing analysis, use maximum propagation delay for setup and minimum clock-to-Q contamination delay for hold. If capture clock arrival minus launch clock arrival is ss, setup requires T≥tcQ,max⁡+tlogic,max+tsu−sT\ge t_{cQ,\max}+t_{\mathrm{logic,max}}+t_{su}-s, while hold requires tcQ,min⁡+tlogic,min≥th+st_{cQ,\min}+t_{\mathrm{logic,min}}\ge t_h+s.

Summary

Sources

  1. M. Morris Mano, M. D. Ciletti, Digital Design, 5th ed., Pearson, 2013: Chapter 5, Sections 5.3 and 5.4 (latches; flip-flops).

Next steps