Counters

A counter is a sequential circuit with 0 inputs and n outputs. Thus, the value after the clock transition depends only on old values of the outputs. For a counter, the values of the outputs are interpreted as a sequence of binary digits (see the section on binary arithmetic).

We shall call the outputs o0, o1, ..., on-1. The value of the outputs for the counter after a clock transition is a binary number which is one plus the binary number of the outputs before the clock transition.

We can explain this behavior more formally with a state table. As an example, let us take a counter with n = 4. The left side of the state table contains 4 columns, labeled o0, o1, o2, and o3. This means that the state table has 16 rows. Here it is in full:

  o3 o2 o1 o0 | o3' o2' o1' o0'
  -----------------------------
   0  0  0  0 |  0   0   0   1
   0  0  0  1 |  0   0   1   0
   0  0  1  0 |  0   0   1   1
   0  0  1  1 |  0   1   0   0
   0  1  0  0 |  0   1   0   1
   0  1  0  1 |  0   1   1   0
   0  1  1  0 |  0   1   1   1
   0  1  1  1 |  1   0   0   0
   1  0  0  0 |  1   0   0   1
   1  0  0  1 |  1   0   1   0
   1  0  1  0 |  1   0   1   1
   1  0  1  1 |  1   1   0   0
   1  1  0  0 |  1   1   0   1
   1  1  0  1 |  1   1   1   0
   1  1  1  0 |  1   1   1   1
   1  1  1  1 |  0   0   0   0
As you can see, the right hand side of the table is always one plus the value of the left hand side of the table, except for the last line, where the value is 0 for all the outputs. We say that the counter wraps around.

Counters (with some variations) play an important role in computers. Some of them are visible to the programmer, such as the program counter (PC). Some of them are hidden to the programmer, and are used to hold values that are internal to the central processing unit, but nevertheless important.

Important variations include: