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

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.

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, “ring and Johnson counter from JK flip-flops”, https://digiwleea.wleeaf.dev/tools/build/ring-johnson-counter-jk/

What you need

Step by step

  1. Place a clock CLK, inputs MODE, LOAD and CLR, four JK flip-flops and probes Q0 to Q3.
  2. Chain the flip-flops: J of each stage from Q of the stage before, K from its Qbar. All share CLK and CLR.
  3. First stage: J0 = LOAD OR (Q3 XOR MODE) and K0 = NOT J0.
  4. Johnson counter: MODE = 1, turn CLR off and watch 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001 repeat.
  5. 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)

ClockRing counter (MODE 0)Johnson counter (MODE 1)
01000 (after LOAD)0000 (after CLR)
101001000
200101100
300011110
410001111
501000111
600100011
700010001
810000000

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.