Draw the inputs on the timing diagram and see how Q and Q' respond
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.
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.
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.
| D | Qn+1 |
|---|---|
| 0 | 0 |
| 1 | 1 |
Copies D on every edge. Qn+1 = D
| J | K | Qn+1 |
|---|---|---|
| 0 | 0 | Qn (hold) |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | Q'n (toggle) |
Like the SR but with no forbidden state. Qn+1 = J·Q' + K'·Q
| T | Qn+1 |
|---|---|
| 0 | Qn |
| 1 | Q'n |
Toggles on every edge if T = 1. Qn+1 = T ⊕ Q
| S | R | Qn+1 |
|---|---|---|
| 0 | 0 | Qn |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | forbidden |
Qn+1 = S + R'·Q, with S·R = 0
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+1 | D | J | K | T | S | R |
|---|---|---|---|---|---|---|
| 0 → 0 | 0 | 0 | X | 0 | 0 | X |
| 0 → 1 | 1 | 1 | X | 1 | 1 | 0 |
| 1 → 0 | 0 | X | 1 | 1 | 0 | 1 |
| 1 → 1 | 1 | X | 0 | 0 | X | 0 |
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.
| IC | Contents |
|---|---|
| 74HC74 | 2 rising-edge D flip-flops with preset and clear |
| 74HC112 | 2 falling-edge JK flip-flops with preset and clear |
| 74HC75 | 4 D latches (transparent bistables) |
| 74HC273 / 74HC574 | 8 D flip-flops (8-bit register); the 574 with three-state outputs |
| 74HC573 | 8 D latches with three-state outputs |
| CD4013 | 2 D flip-flops (4000 series) |
| CD4027 | 2 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).