Digital Circuits Cheatsheet

Latches and Flip-Flops

Use this Digital Circuits reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.

Overview

Latches and flip-flops are the fundamental memory elements of sequential logic. Unlike combinational circuits, they store a state bit. The key distinction: a latch is level-sensitive; a flip-flop is edge-triggered.

SR Latch (Set-Reset)

Built from cross-coupled NOR (or NAND) gates. The basic bistable memory element.

NOR-based SR Latch

SRQQ′State
00Q_prevQ′_prevHold (memory)
1010Set
0101Reset
1100Forbidden (invalid)

Q and Q′ are supposed to be complements; S=R=1 violates this.

NAND-based SR̄ Latch (active-LOW inputs)

Q
11Hold
01Set (Q=1)
10Reset (Q=0)
00Forbidden

Gated (Clocked) SR Latch

Adds an enable (EN/CLK) input. Inputs S and R only affect Q while EN=1.

ENSRQ_next
0XXQ (hold)
100Q (hold)
1101 (Set)
1010 (Reset)
111Forbidden

D Latch (Data / Transparent Latch)

Eliminates the forbidden state by tying R = S′.

ENDQ_next
0XQ (hold)
100
111

When EN=1 the output Q follows D (transparent). When EN=0 the last value is held.

Used in: 74HC373 (octal D latch), address latches in microprocessors.

D Flip-Flop (Edge-Triggered)

Q changes only on the active clock edge (rising ↑ or falling ↓), not during the entire clock level.

Positive-edge triggered D flip-flop

CLKDQ_next
00
11
0, 1, ↓XQ (no change)

Setup time (tₛ): D must be stable for tₛ before the clock edge. Hold time (tₕ): D must remain stable for tₕ after the clock edge. Propagation delay (tₚ): time from clock edge to Q settling.

JK Flip-Flop

Like SR but the J=K=1 condition causes Q to toggle instead of being forbidden.

JKQ_next
00Q (hold)
010 (Reset)
101 (Set)
11Q′ (Toggle)

Characteristic equation: Q_next = J·Q′ + K′·Q

Race condition: In a level-triggered JK latch with J=K=1, Q oscillates. Edge triggering eliminates this.

T Flip-Flop (Toggle)

Special case of JK where J=K=T.

TQ_next
0Q (hold)
1Q′ (toggle)

Characteristic equation: Q_next = T ⊕ Q

Primarily used in counters (T=1 → toggles on every clock edge).

Flip-Flop Comparison

TypeInputsForbidden stateCommon use
SRS, RS=R=1Debounce circuits
DDNoneRegisters, pipeline stages
JKJ, KNone (toggle)Versatile, counters
TTNoneCounters, frequency dividers

Flip-Flop Characteristic Equations

FFQ_next
DD
TT ⊕ Q
SRS + R′·Q (subject to the constraint S·R = 0)
JKJ·Q′ + K′·Q

Flip-Flop Excitation Tables

Used in sequential circuit design (what inputs are needed to achieve a desired state transition).

D Flip-Flop

QQ_nextD
000
011
100
111

D = Q_next (simplest — just load what you want)

T Flip-Flop

QQ_nextT
000
011
101
110

T = Q ⊕ Q_next

JK Flip-Flop

QQ_nextJK
000X
011X
10X1
11X0

X = don't care (use to simplify K-map expressions)

Asynchronous Inputs

InputActiveEffect
PRE (Preset)LOWForces Q=1 immediately, ignores clock
CLR (Clear)LOWForces Q=0 immediately, ignores clock

These override synchronous operation and are used for initialization/reset.

Timing Parameters Summary

ParameterSymbolDefinition
Setup timetₛMin time D stable before clock edge
Hold timetₕMin time D stable after clock edge
Clock-to-Q delaytₚ_CQTime from clock edge to Q valid
Min clock periodT_mintₚ_CQ + tₛ + t_combinational
Max frequencyf_max1 / T_min

Setup/hold violationmetastability: output oscillates and may settle to wrong value. Critical in clock-domain crossing circuits.

Master-Slave Construction

Classic edge-triggered flip-flop implementation: 1. Master (D latch, EN = CLK): captures D when CLK=1 2. Slave (D latch, EN = CLK′): transfers to output when CLK=0 (falling edge triggers)

Rising-edge flip-flop swaps the enable polarities.

D ──► [Master latch] ──internal Q_M──► [Slave latch] ──► Q
            CLK                                CLK′