Chapter 27 of 32

Synchronous Counters

In Asynchronous Counters we built counters where each flip-flop is clocked by the previous one. They were simple, but the delay grew with every bit, false states appeared during each ripple, and we could only build simple MOD-N sequences. A synchronous counter solves all three problems with one idea: give every flip-flop the same clock, and use a little combinational logic to decide which flip-flops should change on the next edge.

This chapter is also your first full sequential circuit design. The procedure you learn here (state table → excitation table → K-maps → circuit) is exactly the one used later for finite state machines and sequence detectors, so take your time with it.

Synchronous counter: a counter in which all flip-flops are triggered by the same clock edge at the same time. The next state of each flip-flop is decided by combinational logic driving its inputs (T, JK or D), based on the present state.


From Ripple to Synchronous: The Binary Up Counter

Go back to the binary count table and ask, for each bit: when does it toggle?

count  Q3 Q2 Q1 Q0
  0     0  0  0  0
  1     0  0  0  1      Q0 toggles on every clock
  2     0  0  1  0      Q1 toggles when Q0 = 1
  3     0  0  1  1      Q2 toggles when Q1 = Q0 = 1
  4     0  1  0  0      Q3 toggles when Q2 = Q1 = Q0 = 1
  ...
  7     0  1  1  1
  8     1  0  0  0      (0111 → 1000: all four toggle together)

A bit toggles when all the bits below it are 1 (that is when adding 1 produces a carry into it). With T flip-flops that rule becomes the equations directly:

T0 = 1, T1 = Q0, T2 = Q1Q0, T3 = Q2Q1Q0, and in general Ti = Qi−1 · Qi−2 · ... · Q0.

         T0 = 1        T1 = Q0       T2 = Q1·Q0      T3 = Q2·Q1·Q0
           │             │               │                 │
        +--▼--+       +--▼--+         +--▼--+           +--▼--+
        | FF0 |──► Q0 | FF1 |──► Q1   | FF2 |──► Q2     | FF3 |──► Q3
        +--┬--+       +--┬--+         +--┬--+           +--┬--+
 CLK ──────┴─────────────┴───────────────┴─────────────────┘
       (the SAME clock edge reaches every flip-flop; Q0, Q1, Q2
        feed the AND gates that produce T1, T2 and T3)

Because every flip-flop is clocked together, all the bits that must change do so at the same moment (one tpd after the edge). There are no false intermediate states like 0110 → 0100 → 0000 any more.

Parallel Carry vs Serial Carry

There are two ways to build the AND terms:

  • Parallel (look-ahead) carry: each Ti has its own AND gate with i inputs, as drawn above. Every T input is ready one gate delay after the clock edge. Fast, but bit n−1 needs an (n−1)-input gate, so fan-in grows.

  • Serial (ripple) carry: reuse the previous term: Ti = Ti−1 · Qi−1. Only 2-input gates are needed, but the signal now passes through a chain of gates.

This is the same trade-off as ripple-carry vs carry look-ahead adders in Ripple-Carry & Carry Look-Ahead Adders. Note that even the serial version is still a synchronous counter: the gate chain delays the T inputs, not the clock.

Maximum Clock Frequency

On each clock edge the flip-flop outputs change after tpd(FF), the new values travel through the logic, and the T inputs must be stable for tsetup before the next edge:

Tclk ≥ tpd(FF) + tlogic + tsetup, and fmax = 1 / Tclk.

Example. Flip-flops with tpd = 15 ns and tsetup = 5 ns, AND gates with 10 ns delay.

  • Parallel carry, any width: one AND gate in the path. Tclk ≥ 15 + 10 + 5 = 30 ns, so fmax ≈ 33.3 MHz.

  • Serial carry, 8 bits: T7 passes through a chain of 6 two-input AND gates (T1 = Q0 needs none, T2 needs one, ..., T7 needs six). Tclk ≥ 15 + 6 × 10 + 5 = 80 ns, so fmax = 12.5 MHz.

  • Compare an 8-bit ripple counter with the same flip-flops: 8 × 15 = 120 ns, about 8.3 MHz, plus glitches.


Synchronous Down and Up/Down Counters

Counting down, a bit toggles when all the bits below it are 0 (a borrow ripples in). So for a down counter Ti = Q̅i−1 · ... · Q̅0. To choose the direction with a control input M (M = 1 up, M = 0 down), combine both:

T0 = 1
T1 = M·Q0       + M̅·Q̅0
T2 = M·Q1·Q0    + M̅·Q̅1·Q̅0
T3 = M·Q2·Q1·Q0 + M̅·Q̅2·Q̅1·Q̅0

Check: in down mode from 000, T0 = 1, T1 = Q̅0 = 1, T2 = Q̅1Q̅0 = 1, so all three toggle and the next state is 111. Correct: 0 − 1 wraps to 7.

Unlike the ripple up/down counter, changing M here is safe at any time between clock edges (as long as it is stable for the setup time before the next edge): M only changes the T inputs, which are sampled at the next edge.


The General Design Procedure

A binary counter has an obvious pattern, but what about MOD-10, or a strange sequence like 0, 2, 5, 7? The systematic method works for any sequence and any flip-flop type:

  1. Draw the state diagram (or list the sequence) and decide the number of flip-flops: ⌈log2(number of states)⌉.

  2. Write the state table: present state → next state for every used state. Unused states become don't-cares (x).

  3. Choose a flip-flop type and use its excitation table (from Flip-Flops: SR, JK, D & T) to find the input each flip-flop needs for each transition.

  4. Simplify each flip-flop input with a K-map, using the don't-cares.

  5. Draw the circuit: common clock, the derived logic on each input.

  6. Check the unused states. Find where each unused state goes. If every unused state eventually reaches the main sequence, the counter is self-starting. If some unused states loop among themselves, the counter suffers from lock-out and must be fixed.

Here are the excitation tables we will need (Q → Q+ means present → next value):

Q → Q+DTJK
0 → 0000x
0 → 1111x
1 → 001x1
1 → 110x0

Worked Example 1: Synchronous Decade (MOD-10) Counter with T Flip-Flops

Step 1. 10 states (0 to 9), so 4 flip-flops Q3Q2Q1Q0. States 10 to 15 are unused.

Steps 2 and 3. State table with the T inputs (T = 1 wherever a bit changes):

Present Q3Q2Q1Q0Next Q3Q2Q1Q0T3T2T1T0
0000 (0)00010001
0001 (1)00100011
0010 (2)00110001
0011 (3)01000111
0100 (4)01010001
0101 (5)01100011
0110 (6)01110001
0111 (7)10001111
1000 (8)10010001
1001 (9)00001001
1010 to 1111xxxxx

Step 4. K-map for T1 (rows Q3Q2, columns Q1Q0, in Gray order):

T1          Q1Q0
            00   01   11   10
Q3Q2  00  [  0    1    1    0 ]
      01  [  0    1    1    0 ]
      11  [  x    x    x    x ]
      10  [  0    0    x    x ]

The 1s sit in column Q0 = 1, rows Q3 = 0  →  T1 = Q̅3·Q0
(the 1 at 1001 must NOT be there: going 9 → 0, Q1 stays 0)

Doing the same for the other inputs (and checking with a computer, see the note below) gives:

T0 = 1 T1 = Q̅3·Q0 T2 = Q1·Q0 T3 = Q3·Q0 + Q2·Q1·Q0

Compare with the binary counter: T1 gained the factor Q̅3 (so that 9 → 0 does not set Q1), and T3 gained the term Q3·Q0 (so that Q3 is cleared at 9). Everything else is identical.

Step 6: unused states. Apply the equations to 10 to 15:

Unused stateNext stateThen
1010 (10)1011 (11)→ 6, in the main sequence
1011 (11)0110 (6)main sequence
1100 (12)1101 (13)→ 4
1101 (13)0100 (4)main sequence
1110 (14)1111 (15)→ 2
1111 (15)0010 (2)main sequence

Every unused state reaches the 0 to 9 loop within two clocks, so this design is self-starting.

Verifying by Simulation

// synchronous decade counter built from T flip-flops
// T0 = 1, T1 = Q3'Q0, T2 = Q1Q0, T3 = Q3Q0 + Q2Q1Q0
module decade_sync (input logic clk, rst, output logic [3:0] q);
  logic [3:0] t;
  assign t[0] = 1'b1;
  assign t[1] = ~q[3] & q[0];
  assign t[2] = q[1] & q[0];
  assign t[3] = (q[3] & q[0]) | (q[2] & q[1] & q[0]);
  always_ff @(posedge clk)                // ONE clock for all four flip-flops
    if (rst) q <= 4'b0000;
    else     q <= q ^ t;                  // a T flip-flop toggles where t = 1
endmodule

module tb;
  logic clk = 0, rst = 1;
  logic [3:0] q;
  decade_sync dut (.clk(clk), .rst(rst), .q(q));
  always #5 clk = ~clk;
  initial begin
    @(negedge clk) rst = 0;
    repeat (12) begin
      $write("%0d ", q);
      @(negedge clk);
    end
    $display("");
    // force each unused state and see where the counter goes next
    for (int s = 10; s <= 15; s++) begin
      dut.q = s; @(negedge clk);
      $display("unused %0d -> %0d", s, q);
    end
    $finish;
  end
endmodule

Output (Icarus Verilog, iverilog -g2012 sync10.sv && vvp a.out):

0 1 2 3 4 5 6 7 8 9 0 1
unused 10 -> 11
unused 11 -> 6
unused 12 -> 13
unused 13 -> 4
unused 14 -> 15
unused 15 -> 2

Worked Example 2: An Arbitrary Sequence with JK Flip-Flops (and Lock-Out)

Problem. Design a synchronous counter that goes 0 → 1 → 3 → 7 → 6 → 4 → 0 using JK flip-flops.

Step 1. Six states, so 3 flip-flops Q2Q1Q0. The unused states are 2 (010) and 5 (101).

Steps 2 and 3. Use the JK excitation table bit by bit:

Present Q2Q1Q0NextJ2 K2J1 K1J0 K0
0000010 x0 x1 x
0010110 x1 xx 0
0111111 xx 0x 0
111110x 0x 0x 1
110100x 0x 10 x
100000x 10 x0 x
010, 101xx xx xx x

Step 4. Minimising each column with K-maps (taking the unused states as don't-cares) gives very neat results:

J2 = Q1     K2 = Q̅1
J1 = Q0     K1 = Q̅0
J0 = Q̅2     K0 = Q2

Each flip-flop has J and K complementary, so it behaves like a D flip-flop: Q2+ = Q1, Q1+ = Q0, Q0+ = Q̅2. You may recognise this as the 3-bit Johnson (twisted-ring) counter from Registers & Shift Registers.

Step 6: unused states. This is where the trouble shows up:

010 (2):  Q2+ = Q1 = 1,  Q1+ = Q0 = 0,  Q0+ = Q̅2 = 1   →  101 (5)
101 (5):  Q2+ = Q1 = 0,  Q1+ = Q0 = 1,  Q0+ = Q̅2 = 0   →  010 (2)

         main loop                      lock-out loop
   0 → 1 → 3 → 7 → 6 → 4 → 0              2 ⇄ 5

If noise or power-up puts the counter in state 2 or 5, it will bounce between them forever and never return to the main sequence. This is called lock-out, and a counter that has it is not self-starting.

Self-starting counter: a counter that reaches its intended sequence from every possible state (including unused ones) within a finite number of clocks. Lock-out: the situation where one or more unused states form a loop that never enters the intended sequence.

Fixing the Lock-Out

The don't-cares gave the K-maps freedom, and the minimiser chose values that happened to create the bad loop. We now fix the next state of one unused state ourselves. Let us send 010 to 100 (state 4), which is in the main sequence. For 010 → 100 we need J2 = 1 (Q1 = 1 gives it already), K1 = 1 (Q̅0 = 1 already) and J0 = 0. The only change is in J0. With 010 no longer a don't-care for J0, the K-map for J0 has 1 only at 000, 0s at 110, 100 and 010, and gives:

J0 = Q̅2 · Q̅1 (K0 = Q2 stays the same, as do the other four inputs).

New next-state table for all 8 states, worked out from the corrected equations:

PresentNextComment
000001main loop
001011main loop
011111main loop
111110main loop
110100main loop
100000main loop
010100unused → enters the loop in 1 clock
101010unused → 010 → 100, enters in 2 clocks

The counter is now self-starting, at the cost of one extra AND input. The lesson: always check unused states, because K-map minimisation does not care whether don't-cares form loops.


Which Flip-Flop Type Should You Use?

TypeDesign effortLogic sizeWhere you see it
DEasiest: D = next stateOften larger (no "hold for free")FPGAs and ASICs: practically every real design, written in HDL
TEasy: T = 1 where a bit changesSmall for counting sequencesBinary and BCD counters
JKMost columns to fillUsually smallest (many don't-cares)Exam problems, discrete TTL designs

In practice, modern designs simply write q <= q + 1; in an HDL and let synthesis tools produce D flip-flops plus an adder. But knowing the T and JK methods is required for university and GATE exams, and it teaches you how the logic really works.


Practical Counter Features and ICs

Real counter chips add a few control inputs that you will meet in data sheets and in Verilog code:

  • Enable (count enable): when 0 the counter holds. With T flip-flops: AND every T input with EN.

  • Synchronous clear / load: on the next clock edge the counter goes to 0 or loads a parallel input. Clearing synchronously avoids the glitchy short state we saw with the asynchronous clear of a ripple MOD-N counter.

  • Terminal count / ripple carry out (RCO): a signal that is 1 at the last state (for example 1111). It enables the next counter in a cascade, so two 4-bit counters form an 8-bit synchronous counter.

ICFunction
741614-bit synchronous binary counter, asynchronous clear, synchronous load
741634-bit synchronous binary counter, synchronous clear and load
74160 / 74162Synchronous decade counters (asynchronous / synchronous clear)
741914-bit synchronous up/down counter with a single clock and a D/U̅ control
741934-bit synchronous up/down counter with separate up and down clocks

A MOD-N counter from a 74163: decode state N−1 and feed it to the synchronous clear (or load 0). For MOD-10, detect 1001 and clear on the next edge, so the sequence is cleanly 0 to 9 with no 1010 glitch. Notice the difference: with an asynchronous clear you detect N, with a synchronous clear you detect N−1.


Common Mistakes

  • Forgetting the common clock. If any flip-flop is clocked by another flip-flop's output, it is (partly) a ripple counter.

  • Using the characteristic table instead of the excitation table. Design needs "what input causes this transition" (excitation), not "what does this input do" (characteristic).

  • Ignoring unused states. Always compute where each unused state goes. Lock-out is a classic exam question.

  • Wrong K-map order. Columns and rows must follow Gray code 00, 01, 11, 10.

  • Saying a synchronous counter has zero delay. It still has tpd(FF) + gate delay + setup time; it just does not grow with each bit (for parallel carry).

  • Mixing up clear styles. Synchronous clear: detect N−1. Asynchronous clear: detect N.


GATE and Interview Questions

Q1. A 4-bit synchronous counter uses flip-flops with tpd = 20 ns and tsetup = 5 ns, and parallel-carry AND gates with 10 ns delay. What is fmax? What would it be for a 4-bit ripple counter with the same flip-flops?

Synchronous: T ≥ 20 + 10 + 5 = 35 ns, fmax ≈ 28.6 MHz. Ripple: T ≥ 4 × 20 = 80 ns, fmax = 12.5 MHz.

Q2. In a 3-bit synchronous counter with T flip-flops, T2 = Q1Q0, T1 = Q0, T0 = 1. The counter is at 101. What are the next three states?

This is the binary up counter: 101 → 110 → 111 → 000.

Q3. A synchronous counter uses D flip-flops with D2 = Q1, D1 = Q0, D0 = Q̅2. Starting from 000, list the sequence. Is it self-starting?

000 → 001 → 011 → 111 → 110 → 100 → 000 (a 3-bit Johnson counter, MOD-6). States 010 and 101 go 010 → 101 → 010, a lock-out loop, so it is not self-starting.

Q4. How many flip-flops and how many states are unused in a synchronous MOD-12 counter?

⌈log2 12⌉ = 4 flip-flops, so 16 − 12 = 4 unused states.

Q5. Using a 74163 (synchronous clear), which state should be decoded to build a MOD-6 counter?

Decode 5 (0101). On the clock edge after the counter reaches 5, the synchronous clear loads 0, giving 0, 1, 2, 3, 4, 5, 0. Decoding 6 would make a MOD-7 counter.

Q6. What is the main advantage of a synchronous counter over an asynchronous one?

All flip-flops change together, so the delay does not grow with the number of bits (allowing much higher clock rates), there are no ripple transient states to cause decoding glitches, and any count sequence can be designed.


Summary

  • A synchronous counter clocks all flip-flops together; combinational logic on the flip-flop inputs decides the next state.

  • Binary up counter: Ti = AND of all lower bits. Down counter: AND of all lower complements. Up/down: select with M.

  • fmax = 1 / (tpd(FF) + tlogic + tsetup). Parallel carry keeps tlogic to one gate; serial carry adds a gate per bit.

  • Design procedure: state diagram → state table → excitation table → K-maps → circuit → check unused states.

  • Decade counter with T flip-flops: T0 = 1, T1 = Q̅3Q0, T2 = Q1Q0, T3 = Q3Q0 + Q2Q1Q0; it is self-starting.

  • Lock-out happens when unused states loop among themselves. Fix it by assigning the don't-cares yourself so that unused states lead into the main sequence.

  • Counters are the simplest state machines. Next, Finite State Machines: Mealy & Moore generalises this procedure to circuits with inputs and outputs.