LearnGates

The 2-bit counter: counting clock pulses

A counter adds one to the number it stores every time the clock rises. With 2 bits, Q1 Q0, it goes 00, 01, 10, 11 and then wraps around to 00. Counters keep time in watches, count events, and step a processor through its program.

Step by step

The order matters here: the checker sets the inputs one row at a time, top to bottom, and the outputs must match each row.

Step by step: 2-bit counter
StepCLKQ1Q0
1000
2101
3001
4110
5010
6111
7011
8100

How it works

Look at how binary numbers count: 00, 01, 10, 11. The lowest bit Q0 flips on every step. The next bit Q1 flips only when Q0 was 1 just before. A T flip-flop (T for toggle) flips its output on every clock edge while its T input is 1, and holds it while T is 0. So: one T flip-flop for Q0 with T always at 1, and one for Q1 with T connected to Q0.

Add more flip-flops following the same rule and you get counters of any size: a bit flips when all the bits below it are 1.

Hints and solution

Try on your own first. Each hint gives away a little more.

  1. A T flip-flop flips its output on every clock edge while T is 1.
  2. Q0 flips on every edge.
  3. Q1 flips only when Q0 was 1.