Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Flip-flops: SR, JK, D and T

Clear, exam-focused notes on SR, JK, D and T flip-flops: definitions, characteristic equations, excitation tables, timing, conversions, worked examples and common mistakes.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Flip-flops are the basic memory element in digital systems. Engineers use SR, JK, D and T flip-flops to store one bit, build registers, shift registers and synchronous counters, and to implement state memory in finite-state machines.

Key ideas

  • Flip-flop: an edge-triggered storage element. It updates its output only on a clock edge (rising or falling). Draw as a rectangle labelled FF with a clock input symbol (triangle) at its side or top.
  • State: the stored bit value Q. Q+ or Q(next) denotes the value after the active clock edge.
  • Characteristic equation: gives Q+ in terms of inputs and present Q. Universities expect exact characteristic equations for each flip-flop.
  • Excitation table: tells which input values are needed to make a transition from present Q to desired Q+. It is used for synthesis (designing inputs to cause required transitions). Standard excitation summaries (present Q → next Q+, X = don't care): D: 0→0: D=0; 0→1: D=1; 1→0: D=0; 1→1: D=1. JK: 0→0: J=0,K=X; 0→1: J=1,K=X; 1→0: J=X,K=1; 1→1: J=X,K=0. SR (active-high): 0→0: S=0,R=X; 0→1: S=1,R=0; 1→0: S=0,R=1; 1→1: S=X,R=0 (avoid S=R=1). T: same (Q+=Q): T=0; toggle (Q+≠Q): T=1.
  • Setup time (t_su): minimum time before the clock edge that inputs must be stable. Define by writing: "t_su: input must be stable during interval [t_clk - t_su, t_clk)."
  • Hold time (t_h): minimum time after the clock edge that inputs must remain stable. Define by writing: "t_h: input must be stable during interval (t_clk, t_clk + t_h]."
  • Propagation delay (t_pd): time from clock edge to valid output change. State in diagrams and timing calculations.

Characteristic equations (exact statements to memorise and derive):

  • For the SR flip-flop (active-high S and R, undefined when S=R=1):
    • Characteristic: Q+ = S + Q·¬R.
    • Explain: If S=1 then Q+ =1; if R=1 then Q+ =0; if S=R=0 Q+ = Q.
  • For the JK flip-flop (a universal flip-flop, resolves SR=1 case by toggling):
    • Characteristic: Q+ = J·¬Q + ¬K·Q.
    • Explain: J sets (makes Q+=1) when J=1 and Q=0; K resets when K=1 and Q=1; J=K=1 gives toggle because expression reduces to ¬Q·1 + ¬1·Q = ¬Q.
  • For the D (data) flip-flop:
    • Characteristic: Q+ = D.
    • Explain: output simply follows input at the triggering edge. In a gated SR implementation, D behavior is obtained by deriving S and R as S = D·EN and R = ¬D·EN (or equivalent edge-triggered gating), which prevents S=R=1 while enabled.
  • For the T (toggle) flip-flop:
    • Characteristic: Q+ = T·¬Q + ¬T·Q = Q ⊕ T.
    • Explain: if T=1 output toggles, if T=0 output holds.

How to draw the common diagrams universities expect:

  • SR latch (NOR type): draw two cross-coupled NOR gates. Label inputs S and R to each NOR, outputs Q and Q'. Label feedback lines. Next to it, draw truth table with S,R,Q and Q+.
  • Edge-triggered master–slave JK: draw two latches in series, the first labelled MASTER driven by clock, second labelled SLAVE driven by inverted clock. Show J,K inputs feeding master. Label the active edge and show when master follows inputs. Note: Master–slave or true edge-triggering prevents the race-around problem of level-sensitive JK (when J=K=1 and the active level is long, Q may toggle multiple times).
  • Timing diagram for a positive-edge triggered FF: draw clock waveform with a rising edge marked t=0, draw input (e.g., D) showing stable before t=0 and valid after t=0 + t_pd. Mark t_su before edge and t_h after edge.

Assumptions to state in answers: assume active-high inputs unless problem states active-low; assume ideal gates unless propagation delays given; assume synchronous edge-triggered FF unless latch explicitly specified. Also mention if present: asynchronous preset/clear (often active-low, PRE̅/CLR̅) override synchronous inputs — asserting PRE̅ forces Q=1 and asserting CLR̅ forces Q=0 regardless of clock.

Formulas

Q+ = S + Q·¬R where Q+ is next state (dimensionless logic 0/1), S and R are set and reset inputs (logic), Q is present state. Applies to active-high SR flip-flop (undefined when S=R=1).

Q+ = J·¬Q + ¬K·Q where J,K are JK inputs, Q present state. Applies to JK flip-flop (resolves S=R case by toggle when J=K=1).

Q+ = D where D is data input. Applies to D flip-flop (edge-triggered).

Q+ = T·¬Q + ¬T·Q = Q ⊕ T where T is toggle input, ⊕ denotes XOR. Applies to T flip-flop.

D = J·¬Q + ¬K·Q relation used when converting JK to D (same form as JK characteristic). Units: logic values.

J = D·¬Q and K = ¬D·Q (one valid mapping to implement D using JK if gates allow; see worked example). Units: logic values. Use if synthesis requires.

Timing definitions (units seconds): t_su setup time (s) — min time input must be stable before clock edge.

t_h hold time (s) — min time input must be stable after clock edge.

t_pd propagation delay (s) — time from clock edge to output valid.

Worked examples

  1. Simple state update (numerical logic trace) Question: For a JK flip-flop, present Q=0. Inputs J=1, K=0. What is Q+? Show steps. Solution: Step 1: Use characteristic Q+ = J·¬Q + ¬K·Q. Step 2: Substitute Q=0, J=1, K=0: ¬Q=1, ¬K=1. Step 3: Q+ = 1·1 + 1·0 = 1 + 0 = 1. Final answer: Q+ = 1.

  2. Convert D flip-flop behaviour into J and K inputs (design problem) Question: You have a D flip-flop defined by Q+ = D. Design J and K expressions so a JK flip-flop behaves like D (i.e., same Q+ for any Q). Model answer (step-by-step): Step 1: Start from JK characteristic: Q+ = J·¬Q + ¬K·Q. We want this equal to D for all Q. Step 2: For Q=0: Q+ should equal D. When Q=0, expression becomes Q+ = J·1 + ¬K·0 = J. So J must equal D when Q=0; thus J = D·¬Q + (something that is 0 when Q=0) but we can pick J = D. Step 3: For Q=1: Q+ = J·0 + ¬K·1 = ¬K, must equal D. So ¬K = D => K = ¬D when Q=1. Choose K = ¬D. Step 4: Combined simple solution: J = D, K = ¬D. Verify both Q cases: if Q=0, J=D => Q+ = D; if Q=1, K=¬D => Q+ = ¬K = D. Works. Final answer: J = D, K = ¬D. (Alternate valid mapping also exists: J = D·¬Q, K = ¬D·Q; both produce correct transitions when used carefully with gating.)

  3. Implementing T with D (synthesis trace) Question: Given a T flip-flop you must implement using a D flip-flop. Give the expression for D. Solution: Step 1: Characteristic of T: Q+ = Q ⊕ T. Step 2: D must equal Q+ (for D flip-flop), so D = Q ⊕ T. Step 3: Alternative expression: D = T·¬Q + ¬T·Q. Final answer: D = Q ⊕ T.

Common mistakes

  • Forgetting the forbidden/undefined SR case (S=R=1) for basic SR flip-flop; mention it in answers unless using gated SR that defines behaviour.
  • Not checking active-high vs active-low notation. If inputs are active-low (S̅, R̅), equations change.
  • Missing setup and hold constraints in timing questions; sketch a timing diagram and label t_su and t_h.
  • When converting flip-flop types, not supplying expressions that work for both Q=0 and Q=1 — use excitation table or algebraic derivation.

For your exam

Kinds of questions you will see:

  • Definitions and differences: define latch vs flip-flop, setup/hold times.
  • Short notes: explain SR, JK, D, T flip-flops, draw NOR-based SR latch, master–slave JK diagram.
  • Derivation: derive characteristic equation from gate-level diagram (e.g., show algebra from cross-coupled NOR to Q+ = S + Q·¬R).
  • Synthesis/Conversion: convert D to JK or T to D using algebra or excitation table.
  • Timing problems: given t_pd, t_su, t_h and clock period, check if system meets timing. Use the setup check T_clk ≥ t_pd(clk→Q of source FF) + t_pd(comb) + t_su of destination FF, and verify hold by ensuring the minimum path delay to the destination FF input is ≥ t_h.
  • Truth-table and excitation-table style numericals.

What a full-marks answer includes:

  • Precise definitions (bold key terms), correct characteristic equations, and clearly labelled diagrams (draw gates, cross-coupled structure, or master–slave latches). For conversions, show algebraic steps for both Q=0 and Q=1 cases or a complete excitation table. For timing, draw the timing diagram and mark t_su, t_h and t_pd.

Quick check

  1. What is the characteristic equation of a JK flip-flop?
  2. How do you implement a T flip-flop using a D flip-flop? Give D in terms of Q and T.
  3. For SR flip-flop (active-high), what is Q+ when S=0 and R=0? Answers: 1) Q+ = J·¬Q + ¬K·Q. 2) D = Q ⊕ T. 3) Q+ = Q (no change).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?