Ring counter and Johnson counter using JK flip-flops, live
A ring counter and a Johnson counter are both four JK flip-flops wired as a shift register, each stage taking J = Q and K = Qbar from the stage before. The only difference is the feedback into the first stage: a ring counter feeds back the last output Q3, and a Johnson counter feeds back its complement Q3'. This live circuit does both, chosen by MODE.
With J = Q and K = Qbar from the previous stage, each JK flip-flop simply copies that stage on the clock edge (J K = 10 sets, 01 resets), so four of them shift their bits along by one place per clock. Closing the loop gives the two counters. In a ring counter the last output goes back to the first stage, so a single 1 circulates: 1000, 0100, 0010, 0001 and round again, four states from four flip-flops, one-hot. It has to be started with exactly one 1, because a cleared ring of 0000 just stays 0000; here LOAD = 1 for one clock forces the first stage to 1. In a Johnson counter, also called a twisted ring or switch-tail counter, the complement of the last output goes back instead, so the register fills with 1s and then empties: 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001, eight states from four flip-flops, and it starts from the cleared 0000 by itself. Here J0 = LOAD OR (Q3 XOR MODE) and K0 = NOT J0, so MODE 0 is the ring and MODE 1 is the Johnson counter. The flip-flops are the master-slave JK flip-flops from NAND gates, saved as parts, so the outputs change on the falling clock edge, and CLR clears all four. The same counters built from D flip-flops are the ring counter and the Johnson counter.
Open this circuit in the lab →
What you need
- 4× JK flip-flop: master-slave, falling edge, with clear; stage k takes J = Q, K = Qbar of stage k - 1
- 1× XOR: Q3 XOR MODE: Q3 for the ring, Q3' for the Johnson counter
- 1× OR: J0 = LOAD OR (Q3 XOR MODE), to start the ring with a single 1
- 1× NOT: K0 = NOT J0
Step by step
- Place a clock
CLK, inputsMODE,LOADandCLR, four JK flip-flops and probesQ0toQ3. - Chain the flip-flops: J of each stage from Q of the stage before, K from its Qbar. All share CLK and CLR.
- First stage: J0 = LOAD OR (Q3 XOR MODE) and K0 = NOT J0.
- Johnson counter: MODE = 1, turn CLR off and watch 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001 repeat.
- Ring counter: MODE = 0, clear, then LOAD = 1 for one clock: the single 1 then circulates 1000, 0100, 0010, 0001.
States, one per clock (Q0 Q1 Q2 Q3)
| Clock | Ring counter (MODE 0) | Johnson counter (MODE 1) |
|---|---|---|
| 0 | 1000 (after LOAD) | 0000 (after CLR) |
| 1 | 0100 | 1000 |
| 2 | 0010 | 1100 |
| 3 | 0001 | 1110 |
| 4 | 1000 | 1111 |
| 5 | 0100 | 0111 |
| 6 | 0010 | 0011 |
| 7 | 0001 | 0001 |
| 8 | 1000 | 0000 |
A 4-bit ring counter has 4 states and a 4-bit Johnson counter has 8, so an n-bit Johnson counter counts modulo 2n. Before the page is built, the live circuit runs 20 clocks: clear, LOAD, seven ring steps, clear, then the full Johnson cycle and its return to 1000, with all four outputs checked after every edge.
You can also read the full theory in the lesson on shift registers. 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: Registers and counters
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 ring and Johnson counter from JK flip-flops in the lab →Frequently asked
How do you make a ring counter using JK flip-flops?
Chain the flip-flops as a shift register, J = Q and K = Qbar of the previous stage, and connect the last stage's Q and Qbar back to the first stage's J and K. Preset one flip-flop to 1 so a single 1 circulates.
How do you make a Johnson counter using JK flip-flops?
Chain them the same way, but cross the feedback: the last stage's Qbar goes to the first J and its Q to the first K. Starting from 0000, it steps through 2n states for n flip-flops.
What is the difference between a ring counter and a Johnson counter?
A ring counter feeds the last output straight back and has n states for n flip-flops, one-hot. A Johnson counter feeds back the complement and has 2n states; it is also called a twisted ring counter.
Why does a ring counter need to be preset?
Because it only moves the bits it already has around the loop. Cleared to all zeros it stays all zeros, so one stage must be set to 1 at the start.
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.