Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

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.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “D flip-flop from a T flip-flop”, https://digiwleea.wleeaf.dev/tools/build/d-flip-flop-from-t/

What you need

Step by step

  1. Place a clock CLK, inputs D and CLR, a T flip-flop and probes Q and Qbar.
  2. XOR D with the flip-flop's own Q and wire the result to T.
  3. Turn CLR on for a clock to start at Q = 0, then turn it off.
  4. 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

DQT = D XOR QT flip-flop doesQ next
000hold0
011toggle0
101toggle1
110hold1

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.