How to build a 4-bit Johnson counter from logic gates
A Johnson counter (twisted ring counter) is a shift register whose inverted last output feeds its first input, so a 4-bit Johnson counter fills with 1s and then empties: 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001, then repeats, 8 states from 4 flip-flops.
It is one twist away from a ring counter: feed back NOT Q3 instead of Q3. That one inverter doubles the number of states to 2n, and adjacent states always differ in exactly one bit, so decoding any state needs only a single 2-input gate and produces no glitches. This build has a synchronous CLR; in the live circuit, turn CLR on for one clock tick and off again, then watch it count.
Open this circuit in the lab →
What you need
- 4× D flip-flop: the four stages on one shared clock (each is two gated D latches plus a clock inverter)
- 1× NOT: the twist: inverting Q3 before it feeds back to D0
- 4× AND: masking every D input with NOT CLR so CLR loads 0000
- 1× NOT: inverting CLR
Step by step
- Start from a 4-bit shift register: four D flip-flops on one clock
CLK, each Q feeding the next D. - Add the twist: pass
Q3through aNOTgate and feed that back to the first stage. - Add the clear:
ANDevery D input (including the fed-back NOT Q3) withNOT CLR, so while CLR is 1 the next edge loads 0000. - Probe
Q0toQ3. Pulse CLR for one clock edge, then let it run: 1s shift in from the left until the register is full, then 0s shift in until it is empty, and around again.
Johnson counter sequence
| Clock edge | Q0 | Q1 | Q2 | Q3 |
|---|---|---|---|---|
| CLR | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 |
| 2 | 1 | 1 | 0 | 0 |
| 3 | 1 | 1 | 1 | 0 |
| 4 | 1 | 1 | 1 | 1 |
| 5 | 0 | 1 | 1 | 1 |
| 6 | 0 | 0 | 1 | 1 |
| 7 | 0 | 0 | 0 | 1 |
| 8 | 0 | 0 | 0 | 0 |
Eight states from four flip-flops, and each step changes exactly one bit. To detect a state, look at the boundary between the 1s and 0s: for example Q0 AND NOT Q1 is 1 only in state 1000. Each output is a square wave at one eighth of the clock frequency, and each output lags the one before it by exactly one clock (an eighth of that period).
You can also read the full theory in the lesson on the Johnson counter. 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.
Build more parts from gates
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 4-bit Johnson counter in the lab →Frequently asked
How does a Johnson counter work?
It is a shift register whose last output is inverted and fed back into the first stage. Starting from all 0s, the inverted 0 shifts a 1 in on every clock until the register is all 1s; then the inverted 1 shifts 0s in until it is empty again. That gives 2n states for n flip-flops.
How many states does a 4-bit Johnson counter have?
Eight: 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001. In general an n-bit Johnson counter has 2n states, twice as many as a ring counter of the same size.
What is a Johnson counter used for?
Generating evenly phase-shifted clock signals, simple sequencing and timing, and as a divide-by-2n counter. Because consecutive states differ in one bit, each state can be decoded glitch-free with a single 2-input gate. The CD4017 decade counter is built around a 5-stage Johnson counter.
What is the difference between a Johnson counter and a ring counter?
A ring counter feeds the last output straight back and circulates a single 1 (n states). A Johnson counter feeds back the inverted last output (a twisted ring), so it has 2n states from the same flip-flops.