From "what is" to "what was"

Every circuit you've studied so far โ€” gates, adders, multiplexers โ€” is combinational: its output depends only on the current inputs. But computers need memory. They need to remember a value even after the inputs that produced it disappear. That's where flip-flops and latches come in.

Big idea: A flip-flop is built from ordinary gates wired into a feedback loop. The output feeds back into the input, creating a circuit that can "hold" a state indefinitely.

Latches vs Flip-Flops

Almost all modern digital systems use edge-triggered flip-flops because they make timing predictable โ€” every component updates in lockstep with the clock.

SR Latch โ€” Interactive Demo

The simplest memory element is the SR (Set-Reset) latch, built from two NOR gates wired so each gate's output feeds the other's input. Press SET to store a 1, press RESET to store a 0. Notice the output holds its value even when you're not pressing anything.

๐Ÿ”ง SR Latch Simulator

0
Q
1
Qฬ„

Initial state: Q = 0 (reset). Try pressing SET.

SRQ (next)Meaning
00Q (no change)Hold current state
101Set
010Reset
11InvalidForbidden state โ€” avoid!

D Flip-Flop โ€” Interactive Demo

The D (Data) flip-flop is the workhorse of digital memory. It has one data input (D) and a clock input. On a clock pulse (rising edge), whatever value is on D gets copied to the output Q โ€” and stays there until the next clock pulse.

๐Ÿ• D Flip-Flop Simulator

0
0
Q

Toggle D, then press the clock to latch the value into Q.

Types of Flip-Flops

SR

Set-Reset

The most basic. S sets Q to 1, R resets Q to 0. Both-1 is forbidden. Foundation for all other types.

D

Data / Delay

One input. Q copies D on each clock edge. Used for registers, pipelines, and memory cells.

JK

JK Flip-Flop

Like SR but the "both inputs 1" case is defined โ€” it toggles the output. Eliminates the forbidden state.

T

Toggle

Single input. When T=1, output flips on each clock edge. Perfect building block for binary counters.

Why Clocks Matter

In a real circuit, signals don't change instantaneously โ€” gates have tiny propagation delays. Without a clock, flip-flops could read inconsistent or "in-flux" values. A clock signal provides a synchronized rhythm: all flip-flops in a system update at the same moment (the clock edge), ensuring the whole system moves forward in well-defined, predictable steps.

Analogy: Think of a clock as a conductor's baton in an orchestra. Without it, musicians (flip-flops) might play (update) at slightly different times, causing chaos. The baton keeps everyone synchronized.

From Flip-Flops to Registers

A register is simply a row of flip-flops sharing a common clock โ€” each one storing a single bit. An 8-bit register stores one byte. Registers are the fastest memory in a CPU, directly accessible by the arithmetic logic unit (ALU).

Chain registers with counting logic and you get counters โ€” circuits that increment with every clock pulse. These are essential for timers, program counters, and clock dividers. We'll build these in the next course.