Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

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.

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 →

What you need

Step by step

  1. Start from a 4-bit shift register: four D flip-flops on one clock CLK, each Q feeding the next D.
  2. Add the twist: pass Q3 through a NOT gate and feed that back to the first stage.
  3. Add the clear: AND every D input (including the fed-back NOT Q3) with NOT CLR, so while CLR is 1 the next edge loads 0000.
  4. Probe Q0 to Q3. 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 edgeQ0Q1Q2Q3
CLR0000
11000
21100
31110
41111
50111
60011
70001
80000

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.