EN

Latches and flip-flops

Draw the inputs on the timing diagram and see how Q and Q' respond

Timing diagram simulator

Flip-flop

Click on the blue rows to change the input at that instant. The orange lines mark the rising edges of the clock; a flip-flop samples its inputs just before each edge. Red hatched areas are undefined states.

What a bistable is

A bistable is the smallest memory circuit: it stores one bit. It has two stable states, Q = 1 (set) and Q = 0 (reset), and keeps the last one indefinitely while powered. Its output depends not only on the current inputs but also on what happened before, which makes it the foundation of sequential circuits: registers, counters, memories and state machines. It almost always provides the inverted output Q' (or Q̅) too.

The simplest one is two NOR gates cross-coupled:

With S = 1 the output Q goes to 1; with R = 1 it goes to 0; with both at 0 it holds. With S = R = 1 both outputs go to 0 (Q and Q' are no longer complementary) and, if both inputs then return to 0 at the same time, the final state depends on which gate is faster: this is the forbidden combination. The simulator marks it in red.

Latch or flip-flop: level or edge

Compare the D latch and the D flip-flop in the simulator with the same signal: the latch copies the changes of D while EN = 1; the flip-flop only looks at D on the edges marked in orange.

Flip-flop tables

D flip-flop

DQn+1
00
11

Copies D on every edge. Qn+1 = D

JK flip-flop

JKQn+1
00Qn (hold)
010
101
11Q'n (toggle)

Like the SR but with no forbidden state. Qn+1 = J·Q' + K'·Q

T flip-flop

TQn+1
0Qn
1Q'n

Toggles on every edge if T = 1. Qn+1 = T ⊕ Q

SR latch

SRQn+1
00Qn
010
101
11forbidden

Qn+1 = S + R'·Q, with S·R = 0

Excitation table: for designing counters

When designing a sequential circuit you know the change you want (from Qn to Qn+1) and need to know what to apply to the inputs. That is the excitation table (X = don't care):

Qn → Qn+1DJKTSR
0 → 000X00X
0 → 111X110
1 → 00X1101
1 → 11X00X0

The X entries make it possible to simplify the equations a lot with a Karnaugh map. A T flip-flop, or a JK with J = K = 1, divides the clock frequency by two: chaining several gives a binary counter.

Asynchronous inputs, timing and bounce

ICContents
74HC742 rising-edge D flip-flops with preset and clear
74HC1122 falling-edge JK flip-flops with preset and clear
74HC754 D latches (transparent bistables)
74HC273 / 74HC5748 D flip-flops (8-bit register); the 574 with three-state outputs
74HC5738 D latches with three-state outputs
CD40132 D flip-flops (4000 series)
CD40272 JK flip-flops (4000 series)

Related: logic gate simulator, Boolean algebra, push button debouncing and ladder simulator (the SET/RESET latching coils of a PLC work like an SR latch).