4-bit counter

Counts 0 through 15 on every clock tick, then wraps back to zero. A ready-made counters circuit you can open in the TorchAnvil simulator.

Four bits, sixteen values

This is the 2-bit counter's bigger sibling. Same ripple trick, two more stages. With four T flip-flops chained together you can count from 0000 (0) all the way to 1111 (15), and then the whole thing wraps back to zero and starts over.

Press Run and watch the lamps. Bit 0 flips every tick. Bit 1 flips every two ticks. Bit 2 every four. Bit 3 every eight. Read them as a binary number (Bit 3 is the most significant) and you're watching the counter tick through every value from 0 to 15 in order.

How it works

tick Bit 3 Bit 2 Bit 1 Bit 0 decimal
0 0 0 0 0 0
1 0 0 0 1 1
2 0 0 1 0 2
3 0 0 1 1 3
7 0 1 1 1 7
15 1 1 1 1 15
16 0 0 0 0 0 (wrap)

Why it matters

Every computer clock divider, every binary readout, every "how many times has this happened" tally starts here. Add four more stages and you've got an 8-bit counter reaching 255. Ripple counters are cheap and cheerful — the tradeoff is that each stage adds a little delay, so at very high speeds designers reach for synchronous counters instead, where every flip-flop shares the same clock.

Try this