Skip to content
BetterDL

Counter

Also called: digital counter, counter circuit

A sequential circuit that steps through a fixed sequence of states, one step per active clock edge, usually so its outputs form a binary count.

A counter is a sequential circuit made of flip-flops whose stored bits step through a fixed list of patterns, moving one step at every active clock edge. Usually the patterns are binary numbers going up or down by one, but the sequence can be anything.

It's really the simplest kind of finite state machine: there is often no input except the clock, so each state has exactly one next state.

The main families:

Counters are everywhere: a CPU's program counter, timers in every microcontroller, clock dividers, and delays and timeouts in FPGA designs. The safest way to reason about any counter is a table with one row per clock edge, showing what the flip-flops hold after that edge.

startCLKCLKCLKCLK00011011

Worked example

Example

A counter as a table of states

A 2-bit up counter, Q1Q0, starts at 00. Write one row per edge.

  1. 1.

    Start: 00 = 0.

  2. 2.

    After edge 1: 01 = 1.

  3. 3.

    After edge 2: 10 = 2.

  4. 4.

    After edge 3: 11 = 3.

  5. 5.

    After edge 4: 00 = 0. It's back where it started: four states, so modulus 4.

Common mistakes

  • Thinking a counter must count in binary. Ring, Johnson and Gray-code counters step through other sequences.

  • Treating the edges as states. After k edges a counter has shown k + 1 values, counting the start.

Practice Counter

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Counter is taught in Counters.