All labs › Learn › Digital Logic Design
All articlesAll labs

Latches and Flip-Flops: SR, D and JK Explained

Learn how SR latches, gated D latches, edge triggered D flip-flops and JK flip-flops work, with tables and equations, and the toggle and debounce uses.

Updated 28 November 2026 · 4 min read · Designed by Fasih Ullah Saleem

01Circuits with memory02The SR latch03Debouncing a switch04The gated D latch and the D flip-flop05The JK flip-flop and the T flip-flop06Latch or flip-flop07Try it in the virtual lab08Questions and answers09Related topics
01

Circuits with memory

The gates of earlier articles have no memory. Their output depends only on the present input. A latch or a flip-flop stores one bit. It keeps its output after the input has gone. These are the building blocks of registers, counters and every computer memory.

A memory element uses feedback. Its output goes back to its input, so it can hold either of two stable states. Q is the stored bit and Q' is its opposite.

02

The SR latch

The simplest latch is two NOR gates cross coupled. It has a Set input and a Reset input. Set makes Q equal to 1. Reset makes Q equal to 0. When both are 0 the latch keeps its value.

SRNext QAction
00Qhold
010reset
101set
11not allowedboth outputs forced 0, undefined on release

A latch of two NAND gates works the same way but with active low inputs, so the forbidden case is both inputs low. The characteristic equation is Q next = S + R' Q, with the rule that S and R must not both be 1.

03

Debouncing a switch

A mechanical switch does not close cleanly. The contacts bounce for a few milliseconds and make many on and off pulses. A counter would count every one. A NAND SR latch with a single pole double throw switch removes the bounce. The first touch of the switch contact sets or resets the latch, and later bounces cannot change it, because a bounce only returns the input to the hold state.

04

The gated D latch and the D flip-flop

The D latch has a data input D and an enable input. While the enable is active, Q follows D. When the enable ends, Q keeps the last value. It is transparent while enabled, so changes of D during that time pass through to Q.

The D flip-flop avoids transparency. It copies D to Q only at the moment of a clock edge, usually the rising edge, and ignores D the rest of the time. Its equation is Q next = D. D must be steady for a short time before the edge, the setup time, and after it, the hold time. The 7474 holds two D flip-flops, each with a clock, a preset and a clear. Preset and clear are active low and act at once, with no clock.

05

The JK flip-flop and the T flip-flop

The JK flip-flop is an SR flip-flop with the forbidden case replaced by a useful one. When J and K are both 1, the output toggles at each clock.

Q next = J · Q' + K' · Q  (JK)
Q next = T ⊕ Q  (T flip-flop, JK with J = K = T)
Q next = D  (D flip-flop)
JKNext QAction
00Qhold
010reset
101set
11Q'toggle

Tying J and K together makes a T flip-flop. With T = 1 the output toggles on each clock, so the output frequency is half the clock frequency. This is the basis of counters. A JK flip-flop with level triggering would race around while the clock is high, which is why practical chips such as the 7476 or 74112 are edge or pulse triggered.

06

Latch or flip-flop

  • A latch is level sensitive. It responds for as long as its enable is active.
  • A flip-flop is edge sensitive. It samples its input only at the clock edge.
  • Flip-flops make designs predictable, because everything changes at the same instant.
  • Use a latch for simple storage and for debouncing. Use flip-flops for registers and counters.

When you test a flip-flop on a bench, give it a slow, clean clock from a debounced switch. Then preset it to a known state before you start, because a flip-flop powers up in a random state.

07

Try it in the virtual lab

SinBench has free 3D benches and interactive demos for this topic. Open one to try the ideas above with real instruments, no sign up needed.

Lab 11

Latches and Flip-Flops

Open the lab →Concepts and demos
Lab 12

Sequential Circuit Design on a Free Bench

Open the lab →Concepts and demos
08

Questions and answers

What is the difference between a latch and a flip-flop?

A latch responds as long as its enable is active. A flip-flop changes only at a clock edge. This makes flip-flops easier to use in synchronous designs.

Why is S = R = 1 not allowed in an SR latch?

In a NOR latch both outputs are forced to 0. When both inputs return to 0 together, the final state is unpredictable.

What does a JK flip-flop do when J and K are both 1?

It toggles. The output changes to its opposite at each clock edge.

How do you debounce a switch?

Use a changeover switch to set and reset an SR latch. The first contact sets the latch and later bounces leave it unchanged.

09

Related topics

Digital Logic Design

Shift Registers: Serial In, Parallel Out and More

Learn how shift registers work: SISO, SIPO, PISO and PIPO types, the universal 74194, ring and Johnson counters and serial to parallel conversion.

Digital Logic Design

Counters: Ripple, Synchronous and the 74192

Compare ripple and synchronous counters, find the maximum clock rate, build a mod N counter by resetting, and meet the 74192 up down counter.

Digital Logic Design

Logic Gates and Truth Tables: AND, OR, NOT, NAND, NOR, XOR

Learn the seven basic logic gates with truth tables, symbols and expressions, the common TTL chips that hold them and how to read a gate level circuit.

SinBench SinBench · Free virtual labsDesigned by Fasih Ullah Saleem
© 2026 Fasih Ullah Saleem. All rights reserved. fasihullahsaleem.com · About · Terms of Use · Privacy