Exercises — Edge-triggered D flip-flop
Before we start, three symbols we will lean on constantly:
The timing exercises (Levels 2, 3, 5) need four more symbols. Here they are once, up front, in plain words — every later use refers back to these:
Level 1 — Recognition
L1.1 — Which one can change right now?
Two boxes both store one bit. Box A is transparent while its enable is high; Box B changes only at the rising edge. It is the middle of a clock's high level and just flipped from 0 to 1. Which box's output can change this instant?
Recall Solution
Box A (the latch).
- What decides: ask "when is the door open?"
- Box A is a level-triggered latch: while enable is high it is transparent, so a change in passes straight to its output — even mid-level. So Box A's output can change now.
- Box B is the edge-triggered flip-flop: it only samples at the rising edge. We are in the middle of the high level, not at an edge, so Box B ignores the flip. Its output stays put. Answer: Box A can change; Box B cannot.
L1.2 — Read one edge
A positive-edge D flip-flop currently outputs . At the next rising edge, . What is ?
Recall Solution
Use the characteristic equation . The old value does not matter for a D flip-flop — it just loads . Answer: .
L1.3 — Name the trigger
For a positive-edge device, exactly which clock event copies into : the high level, the low level, the rising edge, or the falling edge?
Recall Solution
The rising edge — the transition. "Positive edge" means the upward transition. During the high or low level, and at the falling edge, is frozen. Answer: the rising () edge.
Level 2 — Application
L2.1 — Read a whole waveform
Positive-edge FF, starting at . Rising edges occur at . The input is: at ; at ; at ; at ; at . (Between edges may wiggle — ignore it.) Give after each edge.

Recall Solution
Apply at each edge; hold in between.
| edge | sampled | after |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 1 | 1 |
| 3 | 0 | 0 |
| 4 | 0 | 0 |
| 5 | 1 | 1 |
| What it looks like (figure): is a "staircase" that only ever steps at a dotted edge line, copying 's height there. | ||
| Answer sequence: . |
L2.2 — Toggle wiring (divide-by-2)
You connect back into (so always). Start . Write after edges 1,2,3,4.
Recall Solution
Since , the characteristic equation becomes — each edge inverts the output.
- Start .
- Edge 1: sampled → .
- Edge 2: → .
- Edge 3: .
- Edge 4: . The output completes one full cycle () every two clock edges, so its frequency is half the clock's — a divide-by-2. Answer: .
L2.3 — Max clock frequency
A single FF→logic→FF path has ns (clock-to-Q delay), ns (logic delay), ns (setup time). Find the minimum clock period and the maximum frequency . (All four timing symbols were defined up front; here we use three of them.)
Recall Solution
All three delays happen in series inside one clock period: the edge fires (), data crawls through logic (), then must be steady before the next edge (). Answer: ns, MHz.
Level 3 — Analysis
L3.1 — Setup/hold keep-out window
Recall from the timing definitions up front: setup time = how long must be stable before the edge; hold time = how long must stay stable after the edge. Here ns and ns, and a rising edge occurs at ns. State the exact time interval during which must not change. If changes at ns, is that legal?

Recall Solution
- Setup ( ns) means must be stable before the edge → from ns.
- Hold ( ns) means must stay stable after the edge → until ns.
- Keep-out window = . A change at ns is inside this window → illegal. It risks pushing the FF into metastability (see Metastability), where hovers between 0 and 1. Answer: forbidden interval ns; the ns change is illegal.
L3.2 — Latch chain race vs. flip-flop chain
Three storage stages are chained: output of stage 1 → input of stage 2 → input of stage 3, all sharing one clock. Case A: all three are transparent latches. Case B: all three are edge-triggered flip-flops. During a single clock's high level, how many stages can a brand-new value at stage 1's input reach in Case A vs Case B?
Recall Solution
Case A (latches): while the clock is high, all three latches are transparent — the door is open on every stage at once. A new value at stage 1 races through all three in one high phase. You lose control of "one hop per clock". This is the transparency problem. Case B (flip-flops): each FF samples only at the edge and then locks. At one edge, stage 1 captures the new input; stage 2 captures whatever stage 1 held before this edge; stage 3 likewise. So the value moves exactly one stage per edge. Answer: Case A → all 3 (race); Case B → exactly 1. This is why Registers and shift registers use flip-flops.
L3.3 — Master–slave state at each moment
In a master–slave FF the master latch is enabled by and the slave by . For each of these moments, say which latch is open (transparent) and which is closed (holding): (a) , (b) exactly at rising edge , (c) .
Recall Solution
Opposite enables mean exactly one is ever open.
- (a) : → master open (tracks ), slave closed (holds old ).
- (b) rising edge: falls, master snaps shut freezing the value it just held; rises, slave opens and copies that frozen value to . This handover is the edge event.
- (c) : master closed (ignores new ), slave open but its input (master output) is frozen, so is stable. Answer: master open at ; handover at the edge; slave open (but fed a frozen value) at . See Master-slave configuration.
Level 4 — Synthesis
L4.1 — Build a T (toggle) flip-flop from a D-FF
First, one piece of notation: is the exclusive-OR (XOR) operation. equals 1 when the two bits differ, and 0 when they are the same. In words: "output 1 if exactly one input is 1." (So , , , .) It is the natural "toggle detector": XOR-ing a bit with 1 flips it, XOR-ing with 0 leaves it.
Now design logic so a D flip-flop behaves like a T flip-flop: when control input it toggles on each edge, when it holds. Give the equation for in terms of and , and verify all four rows.
Recall Solution
A T flip-flop's target behaviour: (using = XOR defined above: toggle when , hold when ). Since a D-FF just loads (i.e. ), we must feed that target into : (Recall: the overline means NOT, so and are the flipped bits.) Wire an XOR gate: inputs and current ; output → . Verify:
| 0 | 0 | 0 | 0 (hold) |
| 0 | 1 | 1 | 1 (hold) |
| 1 | 0 | 1 | 1 (toggle) |
| 1 | 1 | 0 | 0 (toggle) |
| Every row matches the desired T behaviour. See T flip-flop. | |||
| Answer: . |
L4.2 — Build a JK from a D-FF
A JK flip-flop obeys (the overlines are logical NOT, as defined up front). Realise it using a D flip-flop plus gates: give the expression for .
Recall Solution
Again, whatever we want to be, we simply drive onto (because ): Check the four JK cases:
- : → hold ✓
- : → reset ✓
- : → set ✓
- : → toggle ✓ All four JK modes reproduced. See JK flip-flop. Answer: .
L4.3 — Two-bit shift register output
Two positive-edge D-FFs chained: (external input), . Both start at 0. The input stream on (sampled at edges 1..4) is . Give after each of the four edges.
Recall Solution
At every edge: (the input at that edge), and (the value held just before the edge). Order matters — both use pre-edge values, captured simultaneously.
| edge | old | new | new old | |
|---|---|---|---|---|
| 1 | 1 | 0 | 1 | 0 |
| 2 | 0 | 1 | 0 | 1 |
| 3 | 1 | 0 | 1 | 0 |
| 4 | 1 | 1 | 1 | 1 |
| So = . The bit entered at edge 1 appears at one edge later — the classic one-hop-per-clock delay. | ||||
| Answer: . |
Level 5 — Mastery
L5.1 — Pipeline retiming for speed
A path has ns, ns, and a block of combinational logic taking ns. First find . Then you split the logic into two equal halves ( ns each) and insert a flip-flop between them (a pipeline register). Find the new . By what factor did throughput improve?
Recall Solution
Before: one big path. After pipelining: the worst stage now spans one FF, ns of logic, and the next FF: Speed-up factor: . Why less than : each stage still pays the fixed overhead that does not shrink when you halve the logic. Only the part gets divided; the ns of overhead is paid once per stage regardless. If overhead were zero the period would drop from ns to ns — a full — but the stubborn ns caps the real gain at . Takeaway: pipelining's payoff is limited by the per-stage overhead. See Synchronous counters and clocking in Registers and shift registers. Answer: MHz → MHz, about faster.
L5.2 — Clock skew eats your margin
Two flip-flops share a clock, but the wire to the receiving FF is longer, so its edge arrives ns later than the sender's. Path values: ns, ns, ns. The skew adds time to the receiver's deadline, so the setup constraint becomes . Find the new minimum period and compare to the zero-skew case.
Recall Solution
Zero-skew baseline: ns. With late receiver clock: the receiver's edge arrives later, effectively lengthening the allowed period: So this particular skew direction helps the setup path (period can be as low as ns). But beware — the same skew hurts the hold constraint (data can arrive too early at the receiver's now-later edge), which is why real designers treat skew as dangerous. See Clock distribution and skew. Answer: setup allows ns (vs ns) — but this skew direction jeopardises hold time.
L5.3 — Metastability probability intuition
A D-FF that just went metastable resolves toward a valid 0/1 with the probability of still being stuck decaying exponentially with waiting time : , with time constant ns. How long must you wait so the chance of remaining metastable is below ?
Recall Solution
Why exponential: metastability resolution is a memoryless escape from an unstable balance point — like a pencil balanced on its tip, the longer it survives the rarer that becomes, at a constant fractional rate. That constant-rate decay is exactly . Set . Take natural log (which undoes ): So wait about ns (roughly ). See Metastability. Answer: ns.
Recall Self-test recap (cover the answers)
D flip-flop characteristic equation ::: To toggle a D-FF, set ::: (or for a T-FF) Keep-out window around an edge at ::: of one FF→logic→FF path ::: In a shift register, receives the old or new? at each edge ::: the old (pre-edge) value
Connections
- Parent: Edge-triggered D flip-flop
- SR latch · Gated D latch · Master-slave configuration — the build layers used in L3.3
- T flip-flop · JK flip-flop — synthesised from a D-FF in L4
- Setup and hold time · Metastability — timing correctness (L3, L5)
- Registers and shift registers · Synchronous counters — L3.2, L4.3, L5.1
- Clock distribution and skew — L5.2