D flip-flop using a T flip-flop: T = D XOR Q, live
To make a D flip-flop from a T flip-flop, feed it T = D XOR Q. When D already equals Q, T = 0 and the flip-flop holds; when they differ, T = 1 and it toggles, which turns Q into D. Either way Q equals D after the clock edge.
This is the standard conversion recipe. The D flip-flop's characteristic table says Q next = D. The T flip-flop's excitation table says the input must be T = 1 for a change of Q and T = 0 for no change, so T is 1 exactly when Q next differs from Q, that is, when D differs from Q: T = D XOR Q. One XOR gate does it. The T flip-flop here is the T flip-flop made from a JK flip-flop, saved as a part, and the JK inside is the master-slave JK from NAND gates, so Q changes on the falling clock edge and CLR forces Q to 0 to start. The reverse conversion, a T flip-flop from a D flip-flop, uses the same XOR the other way round: D = T XOR Q. The flip-flop conversion page lists every pairing.
Open this circuit in the lab →
What you need
- 1× T flip-flop: the JK-based T flip-flop part, falling edge, with clear
- 1× XOR: T = D XOR Q
Step by step
- Place a clock
CLK, inputsDandCLR, a T flip-flop and probesQandQbar. - XOR D with the flip-flop's own Q and wire the result to T.
- Turn CLR on for a clock to start at Q = 0, then turn it off.
- Set D and watch Q: after the next falling clock edge it equals D, and it stays there while D stays the same.
D from T: conversion table
| D | Q | T = D XOR Q | T flip-flop does | Q next |
|---|---|---|---|---|
| 0 | 0 | 0 | hold | 0 |
| 0 | 1 | 1 | toggle | 0 |
| 1 | 0 | 1 | toggle | 1 |
| 1 | 1 | 0 | hold | 1 |
Q next always equals D, which is the D flip-flop. Before the page is built, the live circuit runs 12 clocks after a clear with D changing between 0 and 1, and Q and Qbar are checked after every edge.
You can also read the full theory in the lesson on flip-flop types and excitation tables. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Memory: latches and flip-flops
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the D flip-flop from a T flip-flop in the lab →Frequently asked
How do you convert a T flip-flop to a D flip-flop?
Feed T = D XOR Q. If D equals Q the flip-flop holds, and if D differs from Q it toggles, so after every clock edge Q equals D.
Why is an XOR gate used to make a D flip-flop from a T flip-flop?
Because T must be 1 exactly when Q has to change, and Q has to change exactly when D differs from Q. D XOR Q is 1 in exactly those cases.
How do you convert a D flip-flop to a T flip-flop?
Feed D = T XOR Q. With T = 0, D = Q and the flip-flop holds; with T = 1, D = NOT Q and it toggles.
What is the excitation table of a T flip-flop?
Q to Q next of 0 to 0 or 1 to 1 needs T = 0; 0 to 1 or 1 to 0 needs T = 1. In short, T = Q XOR Q next.