Worked examples — Edge-triggered D flip-flop
Before anything else, one reminder so no symbol appears un-earned:
The scenario matrix
Think of a table where each row is a distinct kind of situation a problem can throw at you. Every cell must be covered by at least one worked example below.
| Cell | Scenario class | What's tricky about it | Covered by |
|---|---|---|---|
| A | Positive-edge waveform read | wiggles between edges — must be ignored | Ex 1 |
| B | Negative-edge device | Active edge is the falling one — opposite sign | Ex 2 |
| C | Degenerate input: held constant | No output change ever | Ex 3 |
| D | Feedback: (toggle) | Output depends on itself → ÷2 | Ex 4 |
| E | Timing: setup/hold satisfied | Compute , verify margin | Ex 5 |
| F | Timing: setup violated (limiting case) | Metastability — the failure boundary | Ex 6 |
| G | Real-world word problem | Turnstile / counter framing | Ex 7 |
| H | Exam twist: asynchronous reset overrides clock | Clear beats the edge | Ex 8 |
| I | Multi-stage shift register | One hop per edge, all stages together | Ex 9 |
The signs/quadrant analogue here is which clock edge is active (rising vs falling) — cells A and B. The zero/degenerate case is cell C. The limiting behaviour is cell F (the setup boundary where the device breaks). Let's hit them all.
Ex 1 — Positive-edge waveform read (Cell A)
Forecast: guess the four values of after before reading on.

- At ↑: read . Right at , (we're inside the – window). So . Why this step? The law says sample only at the edge. The edge is at ; nothing before or after matters.
- Between and : stays even though drops to at . Why? No edge occurs between them, so is frozen. The drop at is invisible to .
- At ↑: now (we're in the – window). So . Why? Same law — the edge samples the current , which is .
- At ↑: (in the – window). So . The glitch near is after the edge → ignored. Why? The edge already passed; the flap has snapped shut.
- At ↑: ( window). So .
Answer: after edges .
Verify: Sanity check — each output equals the value of at its edge, never a between-edge value. The glitch at changed nothing, exactly as edge-triggering promises. ✓
Ex 2 — Negative-edge device (Cell B)
Forecast: the active instant is now the falling edge — a different sign of the clock transition. Guess the outputs.
- At ↓: what is right at ? It is the boundary . Take the value in the window we're entering: for a clean read the device sees the settled value . So . Why this step? A negative-edge device's active edge is ; we sample there, not at any rising edge.
- At ↓: (window –). So . Why? Same rule, next falling edge.
- At ↓: . So .
Answer: after edges .
Verify: Contrast with Ex 1 — same waveform, different edge polarity, different captured sequence. This proves the sign of the edge genuinely changes the result, just as quadrant sign changes an angle. ✓
Ex 3 — Degenerate input: held constant (Cell C)
Forecast: does oscillate, count, or settle?
- Edge 1: sample → . Why? .
- Edge 2: sample again → stays . Why? never changes, so every edge loads the same value.
- Edges 3–10: identical — each time.
Answer: after edge 1, and after edge 10 (and forever after).
Verify: This is the degenerate / zero-variation case. The characteristic equation has no dependence on , so a constant produces a constant from edge 1 onward. If your model instead toggled or held the initial , it would be wrong — check against directly. ✓
Ex 4 — Feedback toggle (÷2) (Cell D)
Forecast: with the output feeding its own input, what pattern emerges?

- Before edge 1: , so , so . Why this step? is wired to ; we must compute from the current before the edge.
- Edge 1: sample → . Now , so becomes . Why? : the new is the opposite of the old one.
- Edge 2: → . Then .
- Edge 3: → .
- Edge 4: .
Answer: after edges . It takes two clock edges for to complete one full cycle, so 's frequency is half the clock's: .
Verify: The general rule gives the sequence , period edges output cycle per input cycles divide-by-2. This is the toggle/T-flip-flop behaviour behind Synchronous counters. ✓
Ex 5 — Timing satisfied: compute (Cell E)
Forecast: which numbers add, and which one is a lower constraint not part of the sum?
- Identify the data-path chain in one period: the edge fires, data leaves the first FF after , crosses logic in , and must be stable before the next edge. Why this step? All three events happen in series along one clock cycle, so their times add.
- Sum them: Why? The next edge cannot arrive until the receiving FF's setup is met.
- Invert to get frequency: Why? Frequency is one over period; smaller period ⇒ higher speed.
- What about ns? It does not enter . Hold time is a constraint on fast paths (data arriving too early), fixed by ensuring : here ✓, so no hold violation. Why? Hold sets a minimum delay, not a maximum period.
Answer: ns, MHz, hold satisfied.
Verify: Units: s gives Hz on inversion. Hz. ✓ Hold check ✓. See Setup and hold time.
Ex 6 — Setup violated: the limiting failure case (Cell F)
Forecast: we computed ns in Ex 5. What does running at ns do?
- Compute the data arrival time (relative to the launching edge): Why this step? This is when valid data reaches the receiving FF's pin.
- Compute the required arrival time — data must be stable before the next edge at : Why? Setup means "settled this long before the edge."
- Setup slack = required − arrive: Why? Positive slack = margin to spare; negative slack = data is late.
- Interpret the negative slack: data changes inside the keep-out window . The FF may enter metastability — hovers between 0 and 1 and resolves after an unpredictable delay. Why? This is the limiting boundary of Ex 5: at exactly slack ; below it the device breaks.
Answer: slack ns (violated) → risk of Metastability. Must raise to ns.
Verify: At : slack , the exact edge of correctness — consistent with from Ex 5. At : slack ✓ violation. The sign of the slack is the whole story. ✓
Ex 7 — Real-world word problem (Cell G)
Forecast: the car arrives between edges — which edge notices it?
- Edge at s: car not yet on pad (arrives ) → → (lamp off). Why this step? Sample at the edge; the car's future arrival is invisible.
- Edge at s: car is on pad (since ) → → (lamp ON). Why? First edge that sees the car.
- Edge at s: car still on pad (leaves at ) → → lamp stays on.
- Edge at s: car left at → → (lamp OFF).
Answer: lamp turns on at s, off at s.
Verify: The lamp lags the physical car by up to one clock (car arrived , lamp on at ; car left , lamp off at ). This "up to one tick of delay" is exactly the D = Delay behaviour — a sanity check that the model behaves like a sampled system. ✓
Ex 8 — Exam twist: asynchronous reset overrides the clock (Cell H)
Forecast: the clear pulse happens between edges — but it's asynchronous. Does change?
- At ↑: (normal), → . Why this step? Clear inactive, so ordinary edge behaviour applies.
- During : → forced to right away, with no edge needed. Why? "Asynchronous" means the clear does not wait for a clock edge — it overrides everything.
- After : back to ; stays at (frozen, no edge yet). Why? Clearing released, but nothing re-loads until the next edge.
- At ↑: , → again.
Answer: : (at ) (during clear) (at ).
Verify: The key exam trap is step 2: a synchronous clear would wait for and never show the mid-interval drop. Because ours is asynchronous, dips to between edges. The output visited once more than a naïve edge-only trace predicts — the twist is doing its job. ✓
Ex 9 — Multi-stage shift register (Cell I)
Forecast: does the first bit reach in one edge or three?

- Edge 1 (input ): each FF loads the value that was on its just before the edge. Before edge 1: , , . So . Why this step? Edge-triggering makes every stage sample the old upstream value simultaneously → one hop per edge, no racing.
- Edge 2 (input ): before edge: , , . → . Why? The from stage 1 moves to stage 2; the new enters stage 1.
- Edge 3 (input ): before: , , . → .
- Edge 4 (input ): before: , , . → .
Answer:
| After edge | |||
|---|---|---|---|
| 1 | 1 | 0 | 0 |
| 2 | 0 | 1 | 0 |
| 3 | 1 | 0 | 1 |
| 4 | 1 | 1 | 0 |
Verify: The first input bit (, injected before edge 1) appears at after edge 1, at after edge 2, at after edge 3 — exactly one stage per edge, three edges to traverse three stages. If it had raced to in a single edge, we'd have transparent-latch behaviour, which the edge forbids (see Registers and shift registers). ✓
Recall Rapid self-test
Positive vs negative edge — which clock transition is active for each? ::: Positive = rising ; negative = falling . With tied to constant 1, what is after many edges? ::: 1 (constant), since is independent of . produces what output frequency? ::: Half the clock — divide-by-2 toggle. ns → ? ::: MHz. If setup slack is ns, what may happen? ::: Metastability — hovers between 0 and 1. Asynchronous clear vs synchronous clear — difference? ::: Async forces immediately (no edge needed); sync waits for the next active edge. In a 3-stage shift register, how many edges for a bit to reach the last stage? ::: Three — one hop per edge.
Connections
- Edge-triggered D flip-flop — the parent (rules these examples apply)
- SR latch · Gated D latch · Master-slave configuration — how the edge is built
- Setup and hold time · Metastability — Ex 5 & Ex 6
- Registers and shift registers — Ex 9
- Synchronous counters · T flip-flop · JK flip-flop — Ex 4 toggle
- Clock distribution and skew — why one shared clock keeps stages in step