Digital Electronics

Master Slave Flip Flop

By CourseTron Team ·  7 min read ·  Updated Oct 2026 💬 𝕏 in f
Table of Contents
    ? Print / Save as PDF

    In short: The master-slave flip-flop chains two gated latches that are enabled on opposite clock phases, so exactly one edge-equivalent sampling event occurs per clock period — killing the oscillating "race-around" that plagues a level-triggered JK latch when J=K=1.

    If you have ever built a toggle counter from a simple JK latch and watched the output turn into an unpredictable mess when both inputs are high, you have met the race-around condition. The master-slave configuration is the classic, elegant fix, and understanding it is a rite of passage in every digital-design interview. Let us pull it apart properly.

    Why the race-around condition happens

    A JK latch is level-sensitive: as long as the clock (enable) is high, the output keeps responding to the inputs. When J=K=1 the latch is told to toggle. The trouble is that the toggled output feeds straight back into the gating logic. If the clock stays high for a duration longer than the propagation delay through the feedback loop — typically the sum of two NAND delays, on the order of a few hundred picoseconds in a modern standard cell, but easily tens of nanoseconds in discrete 74-series logic — the output toggles again, and again, for as long as the clock pulse lasts.

    The output therefore oscillates (races) and its final value when the clock falls is indeterminate — it depends on the exact ratio of pulse width to loop delay. For a reliable toggle you would need the clock high-time tpw to satisfy tpd < tpw < 2·tpd, a window that is impossibly tight to guarantee across process, voltage and temperature corners. This is a correctness bug, not a timing nicety.

    Key fact: Race-around is specifically a J=K=1 (toggle) problem of a level-triggered JK latch. A level-triggered SR or D latch with a stable input does not race, because its inputs do not depend on its own output.

    Race-around: Q oscillates while CLK=1 (J=K=1) CLK Q many toggles in one high phase → final value unknown CourseTron · coursetron.com
    During a single wide clock pulse the level-triggered JK output flips repeatedly; whichever value survives at the falling edge is unpredictable.

    The master-slave idea in one sentence

    Split the storage into two cascaded latches and never let them be transparent at the same time. The first latch (the master) listens to the world when the clock is high; the second latch (the slave) copies the master only when the clock is low. Because an inverter drives the slave's enable, the two halves are mutually exclusive, so the feedback path is broken into two non-overlapping segments and the loop can travel only one hop per clock cycle.

    Circuit and operation, step by step

    A JK master-slave is built from two gated SR/JK latches. The external J and K enter the master. The master's outputs Qm, Q̄m feed the slave's S and R. The slave's final outputs Q, Q̄ are fed back to the master's input NANDs — this is what makes it a true JK (it decides toggle direction from the current stored state).

    • CLK = 1 (write master): the master is enabled and samples J, K against the fed-back Q. The slave is disabled and holds, so the external Q does not move — the feedback to the master stays frozen. This is the crucial point: the master can change at most once because Q (its reference) is locked.
    • CLK = 0 (write slave): the master is now disabled and holds whatever it captured. The slave becomes transparent and copies the master to Q. Only now does the external output update.

    The net effect is that the pair behaves as a single negative-edge-equivalent device: the data is captured on the rising edge (into the master) and delivered on the falling edge (out of the slave). One, and only one, output transition can occur per clock period, which is precisely what a clean toggle counter needs.

    JK Master–Slave flip-flop MASTER (latch, en=CLK) SLAVE (latch, en=CLK̄) J K Qm Q CLK 1 CLK̄ feedback Q,Q̄ → master input gates CourseTron · coursetron.com
    Two latches enabled on opposite clock levels. The inverted enable guarantees master and slave are never transparent together, so the feedback loop advances only one stage per period.

    Animated view: the baton passes once per cycle

    Data captured by master (CLK=1), released by slave (CLK=0) MASTER SLAVE 1 CLK=1 master open CLK=0 slave open CourseTron · coursetron.com
    The bit is latched into the master while the clock is high, then released to the output while the clock is low — exactly one handoff per clock period.

    Truth table and timing summary

    JKQ(next)Action
    00QHold
    010Reset
    101Set
    11Q̄Toggle (now race-free)

    Key fact: Because the master is frozen the instant the slave opens, the J=K=1 case produces exactly one clean toggle per clock period regardless of how wide the high phase is — the timing window that doomed the plain latch is gone.

    Where it still bites you: the "1s and 0s catching" gotcha

    Master-slave is not free of hazards. A classic subtlety is ones-catching (and zeros-catching): if J or K glitches high at any moment while the clock is high, the master latches that transient and faithfully passes it to the output on the falling edge, even though the input was low at the actual edge. This is why modern synchronous design overwhelmingly prefers true edge-triggered D flip-flops built from two D latches with no input feedback — the standard DFF cells you see in Synopsys DesignWare, Cadence Genus, or a Siemens Tessent scan chain. Those cells sample at a single instant and are characterised with explicit setup/hold windows in the .lib timing model.

    If you are designing custom cells or just want the intuition that underpins every static timing report, the JK master-slave is the cleanest teaching bridge from latches to edge-triggered flops. For a refresher on the input logic itself, see our deep dive on the JK flip-flop, and compare behaviours with the simpler D flip-flop. Teams building real scan-insertable libraries usually lean on professional VLSI design services to characterise and sign these cells off.

    Want to master sequential logic, setup/hold timing and scan design with hands-on EDA tools? Explore our Digital & VLSI courses on CourseTron and build a real toggle counter in simulation.

    Frequently asked questions

    Does the master-slave flip-flop behave like an edge-triggered device?

    Functionally yes — data is captured on one clock edge and presented on the other, so to the surrounding circuit it looks edge-triggered. Internally, though, both halves are level-sensitive latches, which is why it is vulnerable to ones-catching that a true edge-triggered flop avoids.

    Why does J=K=1 cause oscillation only in the plain latch?

    Because the latch output feeds back into its own toggle logic while it is transparent. Each toggle re-triggers the next after one loop delay, so a clock pulse wider than that delay produces many flips. The master-slave freezes the fed-back value by locking the slave, allowing just one toggle per period.

    Is master-slave still used in modern chips?

    The two-latch topology lives on, but as D-type pairs (master D latch + slave D latch) with no input feedback, forming the standard edge-triggered DFF. Pure JK master-slave cells are rare in modern standard-cell libraries precisely because of ones-catching.

    What delay relationship defines race-around?

    Race-around occurs when the clock high-time exceeds the feedback-loop propagation delay tpd. A reliable single toggle would require tpd < tpw < 2·tpd, an unrealistically tight window — hence the need for the master-slave structure.

    Advertisement