digiwleeaLearn
Open the lab →

T flip-flop

One input that flips a bit

8 min read

A T flip-flop is an edge-triggered one-bit memory cell with a single input T that either holds the stored bit (T = 0) or flips it to the opposite value on each clock edge (T = 1), giving the characteristic equation Q+ = T XOR Q; held at T = 1 it divides the clock frequency by two, which makes it the building block of binary counters.

The JK flip-flop has four operations across two inputs: hold, set, reset, and toggle. Often you only want the last one, a bit that flips on command, and for that the two inputs are more than you need. The T (toggle) flip-flop strips it down to a single input T: leave T low and the bit stays put, raise T high and the bit flips on the next clock edge. It is the simplest flip-flop that does something interesting, and it is the seed of every counter.

Hold or toggle

Like the D flip-flop, a T flip-flop is edge-triggered: it reads T only at the clock edge and holds Q steady the rest of the cycle. At that edge, T picks one of just two behaviors:
TQ+ (next state)
0Q (hold)
1Q' (toggle)
The T flip-flop. T = 0 keeps the current value; T = 1 flips it to the opposite (Q'). That is the whole behavior: one input, two outcomes.
Because 'flip to the opposite' is exactly what XOR does with a control bit, the whole cell is captured by one clean characteristic equation:
Q+ = T Q
Check it: with T = 0, Q+ = 0 XOR Q = Q, so it holds; with T = 1, Q+ = 1 XOR Q = Q', so it flips. XOR with 0 passes a value through, XOR with 1 inverts it, and that is precisely hold-versus-toggle.

Toggle means divide by two

Here is why the T flip-flop matters so much. **Hold T = 1 and pulse the clock steadily.** The bit flips on every rising edge: 0, 1, 0, 1, 0, 1, .... It takes two clock edges to complete one full cycle of Q (off, on, and back to off), so Q is a square wave running at exactly half the clock's frequency. A single toggling flip-flop is a divide-by-2 circuit.
edge #TQ beforeQ after
1101
2110
3101
4011
5110
With T held at 1 (edges 1 to 3) the bit flips every edge, so Q cycles at half the clock rate. Drop T to 0 (edge 4) and Q holds; raise it again (edge 5) and it resumes toggling. Hold-then-toggle from one input.
A concrete picture: a T flip-flop is a push-on / push-off light switch, the kind you tap once for on and tap again for off. Each tap (T = 1 at an edge) flips the state; leaving it alone (T = 0) keeps it. Tap it at a steady rhythm and the light blinks at half your tapping rate, which is the divide-by-2 that lets a chain of these switches count in binary.

How it is built

There are two standard ways to build a T flip-flop, and both fall straight out of the characteristic equation:
  1. **From a JK flip-flop:** tie J and K together and use that common wire as T. Then J = K = 0 is the JK hold (T = 0 holds) and J = K = 1 is the JK toggle (T = 1 toggles). Nothing else needed, because a JK with J = K is a T.
  2. **From a D flip-flop:** feed the flip-flop a D equal to T XOR Q, using one XOR gate whose inputs are T and the fed-back output Q. Since a D flip-flop makes Q+ = D = T XOR Q, this is a T flip-flop directly.
The D-plus-XOR version is the easiest to picture: one XOR gate, one flip-flop, and a feedback wire from Q back to the XOR. The loop is safe for the usual reason, the D flip-flop only samples on the edge, so between edges D = T XOR Q is stable and the edge simply rewrites Q.
A T flip-flop built as a D flip-flop with D = T XOR Q: the XOR gate reads T and the fed-back Q, and the flip-flop captures the result on each rising edge of CLK. Before the first edge Q reads Z; open it in the lab, hold T = 1, and pulse the clock to watch Q toggle at half the clock's rate.

Chaining toggles into a counter

The divide-by-2 is the reason T flip-flops build counters. Take several toggling stages (T = 1 on each) and let each stage's output be the clock for the next stage up. Bit 0 flips on every clock, bit 1 flips each time bit 0 rolls from 1 back to 0, bit 2 flips each time bit 1 rolls over, and so on. Read the bits together and they count 0, 1, 2, 3, ... in binary, because in binary a digit flips exactly when the digit below it wraps. That is a ripple counter, and each bit runs at half the frequency of the one beneath it: a chain of T flip-flops is also a chain of frequency dividers.
Common mistakes. T = 1 does not mean 'store a 1'; it means 'flip on every edge'. So while T is held high the output keeps changing (a square wave), it does not settle on 1, that behavior is what a D flip-flop is for. A T flip-flop must be edge-triggered for the toggle to be well behaved; a level-sensitive toggle held with T = 1 would flip repeatedly for as long as the clock was high (the 'race-around' problem). And a T flip-flop only toggles the bit it holds: to count you must chain stages (or add carry logic), because one stage alone just divides by two.
The T flip-flop is where storage meets counting. Its toggle is a divide-by-2, chaining the stages gives a binary counter, and tapping different stages gives a whole set of slower clocks from one fast one (a program counter and every digital timer rest on this). Because tying J = K on a JK flip-flop makes a T, and hard-wiring the front-end XOR on a D flip-flop also makes a T, you now have every standard flip-flop type in hand.
Try it
A single T flip-flop is fed a 1 MHz clock with T tied high. What frequency appears on Q? Now chain three such stages (each stage's Q clocking the next). What frequency comes out of the third stage?

Frequently asked

What is a T flip-flop?

A T (toggle) flip-flop is an edge-triggered one-bit memory cell with a single input T: when T = 0 it holds its stored bit, and when T = 1 it flips the bit to the opposite value on each clock edge. Its characteristic equation is Q+ = T XOR Q.

What is a T flip-flop used for?

Counting and frequency division. Held at T = 1 a T flip-flop toggles every edge, so its output is a square wave at half the clock frequency (a divide-by-2). Chaining T flip-flops, each clocking the next, produces a binary counter, and tapping the stages gives a series of progressively slower clocks.

What is the difference between a T flip-flop and a D flip-flop?

A D flip-flop loads whatever value is on its input (Q+ = D), so it stores a specific bit. A T flip-flop instead flips its existing bit when T = 1 and holds it when T = 0 (Q+ = T XOR Q), so it does not store a value directly, it changes relative to the current one. You build a T flip-flop from a D flip-flop by wiring D = T XOR Q.

How do you build a T flip-flop?

Two standard ways. Tie the J and K inputs of a JK flip-flop together and use that as T (J = K = 0 holds, J = K = 1 toggles). Or take a D flip-flop and feed it D = T XOR Q with a single XOR gate reading T and the fed-back output Q. Both give Q+ = T XOR Q.
You now have all four flip-flop types. Next, chain toggling flip-flops (or bolt an adder onto a register) and you get the counter that a CPU uses as its program counter, stepping through instruction addresses one clock at a time.

Every lesson here builds toward one thing: a working CPU, from the transistor up.

Open the free lab →
Found this useful? Share itShare on X