Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 17 of 9361. Foundations of Digital Logic and Computer ArchitectureFree lesson

Counters and Sequential Counting Logic

You will design binary and decade counters by connecting flip-flops to perform sequential incrementing operations controlled by a clock signal.

Counters and Sequential Counting Logic

In this lesson, you will learn how to arrange flip-flops to create a sequential circuit that updates its state in a specific numerical sequence every time a clock pulse arrives.

The Anatomy of a Counter

Up until now, you have used registers to store data. A counter is simply a register with a special twist: instead of loading external data, it uses combinational logic to calculate its next state based on its current value. By connecting D flip-flops in a specific feedback loop, we can force the circuit to cycle through a predetermined sequence, such as 0, 1, 2, 3... and back to 0.

Designing a 2-Bit Binary Counter

To build a 2-bit counter, we need two flip-flops, which we can call Q1 (the Most Significant Bit) and Q0 (the Least Significant Bit). For a binary count (00, 01, 10, 11), we look at the required transitions:

  • Q0 toggles on every clock edge.
  • Q1 only toggles when Q0 is currently high (1).

We can implement this using logic gates to feed the D inputs:

  1. D0 = NOT Q0 (Toggles the LSB every cycle).
  2. D1 = Q1 XOR Q0 (Toggles the MSB only when the LSB is 1).

By routing these outputs back to the inputs, the circuit "remembers" its current count and automatically increments it on the next rising clock edge.

Decade Counters (Modulo-10)

A decade counter is a sequential circuit that counts from 0 to 9 and then resets to 0. Since 9 in binary is 1001, a simple 4-bit binary counter would naturally continue to 10 (1010). To force a reset, we add an AND gate that detects when the state reaches 1010 (or specifically detects the count of 9 and triggers a reset on the next clock). When the AND gate detects the target state, it triggers the Clear or Reset pins of the flip-flops, cutting the sequence short and returning the circuit to 0.

This is the foundation of how digital clocks, timers, and cycle counters work inside your processor.

Key Takeaway: A counter is a sequential circuit that uses feedback logic to increment its stored value on every clock edge, allowing us to track time, events, or program sequences.