Module 3: Sequential Circuit Design · 3.5 Counters

Up/Down, Gray, Johnson and Ring Counters

Standard binary counters increment monotonically. However, specialized digital control applications require alternative count sequences.

This article examines four specialized counter architectures:

  1. Bidirectional up/down counters
  2. Single-bit transition Gray-code counters
  3. Multi-phase Johnson counters
  4. One-hot ring sequencers

Bidirectional Up/Down Counters

In an incrementing (up) counter, bit $i$ inverts when all lower-order bits ($Q_0 \dots Q_{i-1}$) equal 1.

In a decrementing (down) counter, bit $i$ inverts when all lower-order bits equal 0.

A direction control input ($DIR$, where 1 indicates up and 0 indicates down) selects the appropriate toggle condition:

$$T_i = DIR \cdot \left(\prod_{j=0}^{i-1} Q_j\right) + \overline{DIR} \cdot \left(\prod_{j=0}^{i-1} \overline{Q_j}\right)$$

For a 3-bit up/down counter, the toggle equations are:

$$T_0 = 1 \qquad T_1 = DIR \odot Q_0 \qquad T_2 = DIR \cdot Q_0 Q_1 + \overline{DIR} \cdot \overline{Q_0},\overline{Q_1}$$

The 74HC191 standard integrated circuit implements this architecture. The device provides carry-out (asserted at maximum count when counting up) and borrow-out (asserted at count 0 when counting down) for cascading.

Gray-Code Counters

Standard binary counters exhibit multi-bit transitions. For example, incrementing from count 3 (011) to count 4 (100) switches three bits simultaneously.

If an asynchronous receiving domain samples this count during transitions, the receiver can capture false intermediate values.

A Gray-code counter changes exactly one bit per increment:

Decimal Value Standard Binary Reflected Gray Code
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100

To implement a Gray-code counter, connect a standard synchronous binary counter to a binary-to-Gray combinational converter:

$$G_i = B_i \oplus B_{i+1} \quad (\text{with } B_N = 0)$$

Asynchronous FIFO buffers use Gray-code read and write pointers. When crossing clock domains, single-bit transitions prevent bus corruption.

Johnson Counters (Twisted Ring Counters)

A Johnson counter inverts the output of the final shift register stage and feeds it back to the input of the first stage (Figure 1).

Johnson counter
Figure 1: Four-bit Johnson counter with inverted serial feedback

An $N$-bit Johnson counter sequences through $2N$ states. Starting from 0000, the inverted feedback fills the register with ones, then refills the register with zeros:

$$\text{Sequence: } 0000 \to 0001 \to 0011 \to 0111 \to 1111 \to 1110 \to 1100 \to 1000 \to 0000$$

Every transition changes exactly one bit, preventing multi-bit hazards (Figure 2).

Johnson counter timing
Figure 2: Waveforms of a 4-bit Johnson counter showing four symmetrical quadrature phases

Each output generates a symmetrical square wave with frequency $f_{\text{clk}} / 2N$. Adjacent outputs exhibit equal phase spacing, creating a multi-phase clock generator.

Furthermore, every state decodes using a single 2-input logic gate:

  • State 0000 decodes as: $\overline{Q_0} \cdot \overline{Q_3}$
  • State 0001 decodes as: $Q_0 \cdot \overline{Q_1}$
  • State 0011 decodes as: $Q_1 \cdot \overline{Q_2}$
  • State 1111 decodes as: $Q_3 \cdot Q_0$

Invalid State Lock-Up

An $N$-bit register contains $2^N$ total states. A 4-bit Johnson counter uses only 8 of its 16 available states.

The remaining 8 states form an isolated cyclic loop: 0010 $\to$ 0101 $\to$ 1011 $\to$ 0110 $\to$ 1101 $\to$ 1010 $\to$ 0100 $\to$ 1001 $\to$ 0010.

If the counter powers up in this loop, it never enters the valid sequence. Designers must apply a hardware reset to force the counter into state 0000.

Ring Counters

A ring counter feeds the true output of the final stage directly back to the first stage without inversion. The register must be initialized with a single logic 1.

An $N$-bit ring counter provides $N$ unique one-hot states (0001 $\to$ 0010 $\to$ 0100 $\to$ 1000).

Ring counters require zero decoding logic because each flip-flop output represents a distinct state. Ring counters function as sequencers for multiphase controllers.

Architecture Selection Matrix

Counter Type Unique States Flip-Flops Output Decoding Logic Single-Bit Transitions
Standard Binary $2^N$ $N$ Full $N$-input decoders No
Gray Code $2^N$ $N$ $N$-input decoders Yes
Johnson $2N$ $N$ Minimal 2-input gates Yes
Ring $N$ $N$ Zero gates (direct taps) Yes
Ripple $2^N$ $N$ Unstable during ripple delay No

Practice Exercises

Problem 1

A 3-bit Johnson counter initializes in state 000. Determine the primary count sequence and identify any isolated invalid loops.

Solution

Feedback logic: $D_0 = \overline{Q_2}$, $D_1 = Q_0$, $D_2 = Q_1$.

  1. Valid Sequence ($2N = 6$ states): 000 $\to$ 001 $\to$ 011 $\to$ 111 $\to$ 110 $\to$ 100 $\to$ 000.
  2. Invalid Loop: The remaining two states (010 and 101) form an isolated loop:
  • From 010: $D_0 = 1, D_1 = 0, D_2 = 1 \implies 101$
  • From 101: $D_0 = 0, D_1 = 1, D_2 = 0 \implies 010$

Hardware reset is required to exit the invalid loop.

Problem 2

Derive 4-bit binary-to-Gray code equations and calculate Gray codes for binary values 0, 7, 8, and 15.

Solution

Equations: $G_3 = B_3$, $G_2 = B_3 \oplus B_2$, $G_1 = B_2 \oplus B_1$, $G_0 = B_1 \oplus B_0$.

  • $0$ (4'b0000): $G = \text{4’b0000}$
  • $7$ (4'b0111): $G = \text{4’b0100}$
  • $8$ (4'b1000): $G = \text{4’b1100}$
  • $15$ (4'b1111): $G = \text{4’b1000}$

Transitioning from 7 to 8 changes only bit $G_3$. Transitioning from 15 to 0 also changes only bit $G_3$.

Problem 3

A unipolar stepper motor requires this eight-step half-stepping excitation sequence: A, AB, B, BC, C, CD, D, DA. Design a sequencer using a 4-bit Johnson counter and 2-input logic gates.

Solution

Use a 4-bit Johnson counter ($2N = 8$ states). Let states $s_1$ through $s_8$ represent codes: 0001, 0011, 0111, 1111, 1110, 1100, 1000, 0000.

Each motor coil activates for three consecutive steps. Decode coils using 2-input gates:

$$A = \overline{Q_2} \cdot \overline{Q_3} \qquad B = Q_0 \cdot Q_1 \qquad C = Q_2 \cdot Q_3 \qquad D = \overline{Q_0} \cdot \overline{Q_1}$$

  • In state $s_2$ (0011): $A = 1, B = 1, C = 0, D = 0$ (phase AB).
  • In state $s_8$ (0000): $A = 1, B = 0, C = 0, D = 1$ (phase DA).

The circuit drives the motor without complex decoders.

The next article explores practical applications of digital counters across system design.

← Modulo-N Counters Counters at Work →