Module 3: Sequential Circuit Design · 3.5 Counters

Modulo-N Counters

Standard binary counters roll over at powers of two ($2^n$). However, practical digital applications require arbitrary modulus cycles:

  • Seconds and minutes roll over at 60.
  • Decimal display digits roll over at 10.
  • Time displays roll over at 12 or 24.

A modulo-N (mod-N) counter sequences through $N$ states from 0 to $N-1$ and returns to 0. Digital designers use three methods to implement mod-N counters.

Method 1: Synchronous Clear on Count (N - 1)

Select a binary counter with sufficient register width:

$$n = \lceil \log_2 N \rceil$$

Connect combinational logic to decode state $N-1$ and assert the synchronous clear input (Figure 1).

Mod-6 counter with synchronous clear
Figure 1: Schematic of a mod-6 counter clearing synchronously on count 5

When the counter reaches count $N-1$, the decoded clear signal asserts. On the next active clock edge, the counter resets to 0 instead of incrementing to $N$.

For example, a mod-6 counter counts: $0 \to 1 \to 2 \to 3 \to 4 \to 5 \to 0$. Count $N-1 = 5 = 3\text{‘b}101$.

The full decode equation is:

$$\text{CLR} = Q_2 \cdot \overline{Q_1} \cdot Q_0$$

Because counts 6 and 7 are never reached during normal operation, the decode simplifies to:

$$\text{CLR} = Q_2 \cdot Q_0$$

Every state, including state 5, persists for exactly one full clock cycle. Count 6 never appears on the output pins.

Hazard Warning: Avoid Asynchronous Clear Feedback

Designers must never reset a counter by decoding count $N$ into an asynchronous reset pin (Figure 2).

Mod-6 counter with asynchronous reset
Figure 2: Timing hazard caused by decoding count 6 into an asynchronous clear pin

If an asynchronous reset decodes state 6 (110), the counter briefly enters state 6. As soon as the decoder asserts the reset net, the flip-flops clear to zero.

The resulting reset pulse width equals only two or three internal gate delays. If one flip-flop clears faster than the others, the reset signal deasserts prematurely, leaving other flip-flops unreset. Always use synchronous clear logic.

Method 2: Parallel Preload on Terminal Count

Instead of resetting to zero, a counter can preload an offset value when it reaches its maximum count ($2^k - 1$).

Let a $k$-bit counter count up to $2^k - 1$. When the terminal count asserts, configure the counter to load parallel value $2^k - N$.

For example, a 3-bit mod-6 counter counts from 2 to 7 ($2^3 - 6 = 2$):

$$\text{Sequence: } 2 \to 3 \to 4 \to 5 \to 6 \to 7 \to 2$$

This method requires no external state decoders because the terminal count logic is integrated into standard counter components. However, the sequence does not start at zero. Down-counters frequently use preload architectures in programmable timer peripherals.

Method 3: Custom Next-State FSM Synthesis

The third method treats the counter as a finite state machine with $N$ states. Designers derive minimal next-state Boolean equations using Karnaugh maps.

Unused binary codes from $N$ to $2^k - 1$ serve as don’t-care conditions ($X$). This method produces minimal logic gate counts for dedicated integrated circuit controllers.

Decade and Duodecimal Counters

Decade Counter (Mod-10)

A decade counter counts from 0 to 9, forming the core of Binary-Coded Decimal (BCD) systems. The counter uses four flip-flops ($n = \lceil \log_2 10 \rceil = 4$) and clears on count $9 = 4\text{‘b}1001$:

$$\text{CLR}_{10} = Q_3 \cdot Q_0$$

Duodecimal Counter (Mod-12)

A mod-12 counter counts from 0 to 11. It uses four flip-flops and clears on count $11 = 4\text{‘b}1011$:

$$\text{CLR}_{12} = Q_3 \cdot Q_1 \cdot Q_0$$

Cascading BCD Counters for Digital Clocks

A standard digital clock displays seconds (00 to 59), minutes (00 to 59), and hours (00 to 23 or 01 to 12).

Each two-digit unit combines a mod-10 units counter and a mod-6 tens counter (Figure 3).

Cascaded BCD counters
Figure 3: Block diagram of cascaded BCD mod-10 and mod-6 counters forming a digital clock

All flip-flops connect to the common system clock net:

  1. The 1 Hz timebase pulse enables the seconds units counter.
  2. When the seconds units counter reaches 9, its terminal count enables the seconds tens counter.
  3. When the seconds tens counter reaches 5 and units reaches 9 (count 59), its terminal count enables the minutes units counter.

For 24-hour displays, the hours counter clears when tens equals 2 and units equals 3 (count 23), returning both digits to 00 on the next cycle.

Practice Exercises

Problem 1

Design a mod-7 counter using a 3-bit synchronous counter with a synchronous clear input. Derive the minimal clear equation and prove that state 7 never occurs.

Solution

A mod-7 counter sequences: $0 \to 1 \to 2 \to 3 \to 4 \to 5 \to 6 \to 0$.

Count $N-1 = 6 = 3\text{‘b}110$. The full decode equation is:

$$\text{CLR} = Q_2 \cdot Q_1 \cdot \overline{Q_0}$$

Because the count never exceeds 6 during normal operation, only count 6 possesses $Q_2 = 1$ and $Q_1 = 1$. The minimal decode equation is:

$$\text{CLR} = Q_2 \cdot Q_1$$

When the counter reaches 6, the clear signal asserts. On the next clock edge, the counter resets to 0. State 7 (111) never appears.

Problem 2

A 12-hour digital clock displays hours from 1 to 12 using two BCD digits. Specify the parallel preload condition and the loaded value.

Solution

Detect display state 12: $\text{tens} = 1$ and $\text{units} = 2$.

The condition is:

$$\text{ROLLOVER} = (\text{tens}[0]) \cdot (\text{units}[1])$$

When ROLLOVER asserts at the end of hour 12, the counter asserts its parallel-load control to load value 01 ($\text{tens} = 0, \text{units} = 1$), continuing the sequence: $12 \to 1 \to 2$.

Problem 3

Compare a 3-bit mod-6 counter built with synchronous clear against a custom FSM design using Karnaugh maps.

Solution

Both circuits require 3 flip-flops.

  • The synchronous clear counter requires carry AND gates plus clear decode logic ($Q_2 \cdot Q_0$).
  • The custom FSM derivation uses don’t-cares for states 6 and 7:

$$D_0 = \overline{Q_0} \cdot \overline{Q_2}$$

$$D_1 = Q_1 \oplus Q_0$$

$$D_2 = (Q_2 \cdot \overline{Q_0}) + (Q_1 \cdot Q_0)$$

Both implementations use similar gate counts. The synchronous clear counter is preferred because it scales directly to larger word widths.

The next article examines bidirectional up/down counters and non-binary counters, including Gray-code and Johnson counters.

← Synchronous Counters Up/Down, Gray, Johnson and Ring Counters →