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

3-bit synchronous counter using JK flip-flops, live

A 3-bit synchronous counter counts 0 to 7 and wraps, with all three flip-flops on one clock. With JK flip-flops the design is J0 = K0 = 1, J1 = K1 = Q0 and J2 = K2 = Q1 AND Q0: each bit toggles exactly when all the bits below it are 1.

This is the textbook design procedure in miniature: write the state table (000, 001, up to 111 and back to 000), look up the J and K each flip-flop needs in the JK excitation table, and simplify with K-maps. Every bit only ever holds or toggles, so J = K for each stage, and the toggle condition is the AND of the lower bits. The flip-flops are the master-slave JK flip-flops from NAND gates, saved as a part, so the count changes when the clock falls. The 4-bit synchronous counter uses D flip-flops instead, and a ripple counter chains the clocks instead of sharing one. Fourteen clocks are checked before the page is built, including the 7 to 0 wrap and a clear. The live circuit starts with CLR on: turn it off to 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. Write the state table: each count and the one after it, 000 to 001 up to 111 to 000.
  2. For each bit, use the JK excitation table: 0 to 0 needs J = 0, 0 to 1 needs J = 1, 1 to 0 needs K = 1, 1 to 1 needs K = 0 (the other input is a don't-care).
  3. Simplify: J0 = K0 = 1, J1 = K1 = Q0, J2 = K2 = Q1 Q0.
  4. Wire three JK flip-flops to one clock and one CLR, tie J0 and K0 to 1, feed Q0 to J1 and K1, and an AND of Q1 and Q0 to J2 and K2.
  5. Turn CLR off: Q2 Q1 Q0 counts 000, 001, 010 up to 111 and wraps.

Count sequence and JK inputs

CountQ2 Q1 Q0J2 = K2J1 = K1J0 = K0
0000001
1001011
2010001
3011111
4100001
5101011
6110001
7111111

A 1 in a J = K column means that bit toggles on the next falling clock edge. From 111 every bit toggles at once, which is the wrap to 000.

You can also read the full theory in the lesson on synchronous counters. 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

half adderfull adderhalf subtractorfull subtractor2:1 multiplexer4:1 multiplexerXOR gate from NAND gates2-to-4 decoderSR latchD flip-flopJK flip-flopT flip-flop4-bit shift register4-bit ripple carry adderD latch1-to-4 demultiplexer4-bit magnitude comparator4-bit ring counter4-bit Johnson counter4-to-2 priority encoder4-bit synchronous counter3-to-8 decoder8-to-1 multiplexer4-bit carry lookahead adderhalf adder from NAND gates2-bit comparatorBCD to 7-segment decoder4-bit up/down counterdecade counter2-bit multiplier4-bit ALU4-bit array multiplierNOT, AND, OR and NOR from NANDNOT, OR, AND and XOR from NORfull adder from NAND gatesSR latch from NAND gatesparity generator and checker4-bit adder/subtractorBCD adder4-bit universal shift registermod-6 counter4-bit ripple counterbinary to Gray code converterhalf adder from NOR gatesfull adder from NOR gates4-bit register with parallel load1011 sequence detectorbinary to BCD converterD flip-flop from NAND gates1-bit ALUCMOS inverterCMOS NAND gateCMOS NOR gatePISO shift registerSR flip-flop from NAND gatesBCD to excess-3 code converterHamming (7,4) code encoder and correctortraffic light controller4-bit barrel shifterCMOS AND gateCMOS OR gateCMOS XOR gate1-bit magnitude comparatorhalf subtractor from NAND gatesfull subtractor from NAND gates8-to-3 encoderGray to binary converter4-to-16 decoderfull adder using 4:1 multiplexersedge detectorserial adder4-bit carry-select adderMealy machine (1011 detector)master-slave JK flip-flop (NAND)half subtractor from NOR gates1-to-8 demultiplexerexcess-3 to BCD code convertervending machine FSM4-bit carry-save adderCMOS transmission gatetri-state buffer (CMOS)2-to-1 mux from transmission gatesmod-5 counterflip-flop conversion (JK to D)8-bit ALUdecimal to BCD encoderBCD to decimal decoder4-to-1 mux from 2-to-1 muxes

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 3-bit synchronous counter (JK) in the lab →

Frequently asked

How do you design a 3-bit synchronous counter?

Write the count sequence as a state table, find the J and K (or T, or D) inputs each flip-flop needs from its excitation table, simplify them with K-maps, and connect all flip-flops to one clock. With JK flip-flops: J0 = K0 = 1, J1 = K1 = Q0, J2 = K2 = Q1 Q0.

How many flip-flops does a 3-bit counter need?

Three. With n flip-flops a binary counter has 2 to the n states, so three give the eight counts 0 to 7 (a mod-8 counter).

What is the difference between a synchronous and an asynchronous counter?

In a synchronous counter every flip-flop shares one clock and all bits change together. In an asynchronous (ripple) counter each flip-flop is clocked by the previous one, so the change ripples through and the bits settle one after another.

How do you make it count down?

Toggle a bit when all lower bits are 0 instead of 1: J1 = K1 = NOT Q0 and J2 = K2 = NOT Q1 AND NOT Q0.