Electrical Engineering › Section U · Sequential logic › Topic U.5
Designing, cascading, and decoding counters
Ready-made counters count in binary or in tens, but real systems often need a stranger sequence, a much larger modulus, or a signal at one particular count. This topic shows how to design a synchronous counter for any sequence, chain counters together and pick out the states you need.
A design procedure for any sequence
A synchronous counter, as in "Finite state machines and asynchronous and synchronous counters", is a set of flip-flops sharing one clock, with gates that set each flip-flop's inputs. Designing one follows six steps. 1. Draw a state diagram: each state is a circle and an arrow shows where it goes next. 2. Write a next-state table listing each present state and the state that must follow it. 3. Using the flip-flop's transition table, list the inputs each flip-flop needs for every row. 4. Map each input on a Karnaugh map, treating unused states as don't-cares. 5. Read off the minimised expressions. 6. Check every state, used and unused, by tracing it through the logic.
Flip-flop transition tables
A transition table, also called an excitation table, turns the question round: given the change you want in Q, what inputs produce it? For a D flip-flop it is trivial, since \(D = Q_{next}\). For a J-K flip-flop each change can be made two ways, which leaves a don't-care, X:
For example, to go from 0 to 1 you can set (J = 1, K = 0) or toggle (J = 1, K = 1), so K does not matter. These don't-cares are why J-K designs often need fewer gates.
Worked example: a 2-bit Gray-code counter
Design a counter that steps \(Q_1Q_0\) = 00, 01, 11, 10 and repeats, using J-K flip-flops. 1. Flip-flop 0: from 00 to 01 it goes 0 to 1, so \(J_0 = 1\). From 01 to 11 it stays 1, so \(K_0 = 0\). From 11 to 10 it goes 1 to 0, so \(K_0 = 1\). From 10 to 00 it stays 0, so \(J_0 = 0\). 2. Reading those against \(Q_1\): \(J_0 = \overline{Q_1}\) and \(K_0 = Q_1\). 3. Flip-flop 1 by the same method: \(J_1 = Q_0\) and \(K_1 = \overline{Q_0}\). 4. Check by tracing: 00 gives 01, 01 gives 11, 11 gives 10 and 10 gives 00. Only one bit changes at each step, which is the point of Gray code.
Worked example: an irregular sequence with D flip-flops
Design a counter for the sequence 0, 2, 3, 5, 6 and repeat, using D flip-flops. 1. Next-state table:
2. Each \(D\) equals its next-state bit. The unused states 001, 100 and 111 are don't-cares. 3. Three-variable maps give \(D_2 = Q_0\), \(D_0 = Q_1\overline{Q_2}\) and
4. Check all five rows: each gives the required next state. 5. Check the unused states: 001 goes to 110, 100 to 010 and 111 to 100 and then 010, so the counter always returns to its sequence.
Cascading counters
Counters are chained, or cascaded, to reach a larger modulus. The overall modulus is the product of the individual moduli. Synchronous counters have a terminal-count output that goes HIGH in their last state; feeding it to the enable input of the next counter lets that counter advance once per full cycle of the first. Three cascaded decade counters give modulus \(10 \times 10 \times 10 = 1000\), so a 1 MHz clock produces a 1 kHz output from the last stage. Truncated stages work too: a decade counter followed by a modulus-6 counter makes modulus 60. Two cascaded 4-bit binary counters give \(16 \times 16 = 256\).
Decoding a counter state
To act at one particular count, decode it with an AND gate, complementing each output that is 0 in that state. State 110 of a 3-bit counter is detected by \(Q_2Q_1\overline{Q_0}\), which is HIGH for exactly one clock period in eight. Decoding can glitch. In a ripple counter the outputs change one after another, so transient states briefly appear; even in a synchronous counter, outputs that change together are never perfectly simultaneous. A gate decoding 000 may then pulse during the 011 to 100 change. The cure is strobing: enable the decoding gate with a pulse that arrives only after the outputs have settled, for example during the second half of the clock cycle.
A digital clock
A digital clock shows counters at work. A 60 Hz mains signal, shaped into pulses by a Schmitt trigger, is divided by 60 to give one pulse per second. The seconds counter is a decade counter for the units digit cascaded with a modulus-6 counter for the tens, so it runs 00 to 59 and then sends one pulse to the minutes counter, built the same way. The hours counter needs special logic, since it must run 1 to 12: gates detect the step past 12 and load 1 in place of 13. BCD-to-7-segment decoders, from "Comparators, decoders, encoders, and code converters", drive the digits.
More counter applications
Counters do much more than count. An up/down counter can track the cars in a car park: a sensor at the entrance counts up, one at the exit counts down, and a decoder on the full count lights a "Full" sign and closes the barrier. A counter can also convert parallel data to serial. Its outputs drive the select inputs of a multiplexer, so a 3-bit counter steps an 8-input mux through \(D_0\) to \(D_7\), sending an 8-bit word out bit by bit over 8 clocks. On IEEE dependency-notation symbols a counter is labelled CTR, with DIV followed by its modulus, such as CTR DIV 10 for a decade counter.
Troubleshooting counters
Faults in cascaded counters show up as a wrong modulus or a wrong frequency. With a known clock applied, measure the output frequency of each stage in turn with an oscilloscope or frequency counter. The first stage whose output is wrong locates the fault, often a missing terminal-count or enable connection, or a stuck output. In a truncated counter, a fault in the decoding gate that clears or loads it changes the modulus: a 6-bit binary counter meant to divide by 60 that divides by 64 has lost its truncation. For counters built from separate flip-flops, check each flip-flop's clock, J and K, or D, and asynchronous inputs.
Common mistakes to avoid
First, writing a J-K transition table without don't-cares and so missing simpler logic. Second, forgetting unused states: unchecked, a counter may power up in one and never reach its sequence. Third, adding moduli when cascading; they multiply, so decade and modulus-6 counters give 60, not 16. Fourth, decoding a state without complementing the outputs that are 0. Fifth, ignoring decoding glitches; when the decoded output clocks or clears something, strobe it.
Key takeaways
To design a synchronous counter: state diagram, next-state table, flip-flop transition table, Karnaugh maps with unused states as don't-cares, logic, then a check of every state. D inputs equal the next state; J-K transition tables include don't-cares. Cascaded counters multiply their moduli, and terminal-count outputs enable the next stage. An AND gate decodes a state, and strobing removes decoding glitches. Counters build clocks, car-park tallies and parallel-to-serial converters.
Flashcards
Flashcard
State diagram, next-state table, transition table, K-maps, logic, check
Test your understanding
Question 1 of 5
A J-K flip-flop must go from Q = 1 to Q = 1 at the next clock edge. Which inputs does the transition table give?
Question 2 of 5
A modulus-8 counter is cascaded with a modulus-12 counter and clocked at 9.6 MHz. What is the frequency of the final output?
Question 3 of 5
Which gate expression decodes state 101 of a 3-bit counter with outputs Q₂Q₁Q₀?
Question 4 of 5
A counter is designed with D flip-flops so that state 011 is followed by state 101. What must D₂D₁D₀ be when the counter is in state 011?
Question 5 of 5
Why must a counter designer check the unused states after deriving the logic?
