In the chapter Registers & Shift Registers we used a row of flip-flops to store and move data. Now we use flip-flops to count. Counting is everywhere in hardware: a digital clock counts seconds, a microwave counts down the cooking time, a CPU counts instructions with its program counter, and a frequency meter counts pulses in one second.
There are two ways to build a counter. In an asynchronous counter (also called a ripple counter) only the first flip-flop receives the clock, and every other flip-flop is clocked by the output of the one before it. In a synchronous counter all flip-flops share one clock. This chapter covers the asynchronous kind: how it works, why it is so simple, how to make it count down or count to any number N, and why its delay makes it unsuitable for fast systems. The next chapter, Synchronous Counters, fixes that delay problem.
What Is a Counter?
Counter: a sequential circuit that goes through a fixed sequence of states, moving to the next state on each clock pulse (or each input pulse). The number of distinct states in the sequence is called the modulus (MOD number) of the counter.
With n flip-flops a counter can have at most 2n states. A 3-bit binary counter goes 0, 1, 2, ..., 7 and then back to 0, so it is a MOD-8 counter. A counter that goes 0 to 9 and back is a MOD-10 or decade counter.
Asynchronous (ripple) counter: a counter in which the external clock drives only the first flip-flop, and each later flip-flop is clocked by the output of the previous flip-flop. A change "ripples" through the chain one stage at a time, so the flip-flops do not change at the same instant.
The key building block is a flip-flop that toggles on every active clock edge. From the chapter Flip-Flops: SR, JK, D & T you know three ways to get one:
a T flip-flop with T = 1,
a JK flip-flop with J = K = 1,
a D flip-flop with its Q̅ output fed back to D (D = Q̅).
The Key Observation: Each Bit Divides by Two
Write the binary numbers 0 to 7 in a column and look at each bit separately:
count Q2 Q1 Q0
0 0 0 0
1 0 0 1 Q0 toggles on EVERY count
2 0 1 0 Q1 toggles when Q0 goes 1 → 0
3 0 1 1
4 1 0 0 Q2 toggles when Q1 goes 1 → 0
5 1 0 1
6 1 1 0
7 1 1 1
0 0 0 0 (wraps around)
So the rule for an up counter is: bit i toggles exactly when bit i−1 makes a 1 → 0 transition (a falling edge). A negative-edge-triggered toggle flip-flop does precisely that if we connect its clock input to the previous Q. That is the whole idea of a ripple counter.
A second way to see it: every toggle flip-flop produces an output with exactly half the frequency of its clock. Chain n of them and the last output runs at fclk / 2n. A ripple counter is therefore also a frequency divider. This is how a quartz watch turns its 32 768 Hz crystal into 1 Hz: 32 768 = 215, so 15 divide-by-2 stages are enough.
3-Bit Asynchronous Up Counter
Use three negative-edge-triggered JK flip-flops with J = K = 1:
J = K = 1 J = K = 1 J = K = 1
+-------+ +-------+ +-------+
CLK ────o>| FF0 |Q0 ──┬───o>| FF1 |Q1 ──┬───o>| FF2 |Q2 ──► Q2 (MSB)
+-------+ │ +-------+ │ +-------+
▼ ▼
Q0 (LSB) Q1
o> = clock input with a bubble: the flip-flop triggers on the FALLING edge
FF0 is clocked by CLK, FF1 by Q0, FF2 by Q1
Timing diagram (ideal, ignoring delays). Every falling edge of CLK is where a "‾‾" turns into "__":
CLK ‾‾__‾‾__‾‾__‾‾__‾‾__‾‾__‾‾__‾‾__‾‾__
Q0 __‾‾‾‾____‾‾‾‾____‾‾‾‾____‾‾‾‾____ f/2
Q1 ______‾‾‾‾‾‾‾‾________‾‾‾‾‾‾‾‾____ f/4
Q2 ______________‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾____ f/8
count 0 1 2 3 4 5 6 7 0
Read it column by column and you see Q2Q1Q0 going 000, 001, 010, ..., 111, 000. Notice that Q1 changes only when Q0 falls, and Q2 changes only when Q1 falls, exactly as the observation predicted.
Up or Down? It Depends on Two Choices
For a down counter (7, 6, 5, ..., 0, 7), bit i must toggle when bit i−1 goes 0 → 1 (look at the table above read from bottom to top). There are two ways to give a flip-flop that edge: clock it from Q̅ of the previous stage (Q rising means Q̅ falling), or use positive-edge-triggered flip-flops. The four combinations are worth memorising:
| Flip-flop triggering | Next clock taken from Q | Next clock taken from Q̅ |
|---|---|---|
| Negative edge (falling) | Up counter | Down counter |
| Positive edge (rising) | Down counter | Up counter |
A quick way to remember: "negative edge + Q = up". Changing either choice reverses the direction; changing both brings you back.
Up/Down Ripple Counter
To choose the direction with a control input M, put a 2-to-1 multiplexer between stages: the clock for stage i is M·Qi−1 + M̅·Q̅i−1 (with negative-edge flip-flops, M = 1 counts up, M = 0 counts down). One practical warning: changing M while the counter is running can itself create an edge on a stage's clock and cause a false count, so M should only change when the clock is idle.
The Ripple Delay Problem
Real flip-flops have a clock-to-Q propagation delay tpd. In a ripple counter the delays add up, because FF1 cannot start changing until FF0 has finished, FF2 waits for FF1, and so on. Look at the change from 0111 to 1000 in a 4-bit counter, with tpd = 10 ns per flip-flop:
time after the clock edge: 0 ns 10 ns 20 ns 30 ns 40 ns
Q3 Q2 Q1 Q0 0111 → 0110 → 0100 → 0000 → 1000
▲ ▲ ▲ ▲
Q0 falls Q1 falls Q2 falls Q3 rises
(false states 6, 4 and 0 appear briefly)
Two consequences:
Total settling time for an n-bit ripple counter is up to n × tpd (worst case when every bit changes, such as 0111 → 1000 or 1111 → 0000).
Transient (false) states. While the ripple travels, the outputs pass through wrong values. If a decoder watches the outputs (for example "light an LED when the count is 4"), it can produce a short false pulse called a glitch or spike.
Seeing It in Simulation
Here is a 4-bit ripple counter in SystemVerilog. Each flip-flop has a 10 ns clock-to-Q delay and the clock period is 100 ns:
// negative-edge-triggered T flip-flop with T = 1 (always toggles),
// active-low asynchronous CLEAR, clock-to-Q delay TPD
module tff_neg #(parameter TPD = 10)
(input logic clk, clr_n, output logic q);
always @(negedge clk or negedge clr_n)
if (!clr_n) q <= #TPD 1'b0;
else q <= #TPD ~q;
endmodule
// 4-bit asynchronous (ripple) up counter
module ripple4 (input logic clk, clr_n, output logic [3:0] q);
tff_neg ff0 (.clk(clk), .clr_n(clr_n), .q(q[0]));
tff_neg ff1 (.clk(q[0]), .clr_n(clr_n), .q(q[1]));
tff_neg ff2 (.clk(q[1]), .clr_n(clr_n), .q(q[2]));
tff_neg ff3 (.clk(q[2]), .clr_n(clr_n), .q(q[3]));
endmodule
module tb;
logic clk = 0, clr_n = 1;
logic [3:0] q;
ripple4 dut (.clk(clk), .clr_n(clr_n), .q(q));
always #50 clk = ~clk; // 100 ns period, falling edges at 100, 200, ...
initial begin
#1 clr_n = 0; // pulse CLEAR at power-on
#19 clr_n = 1;
$monitor("t=%4t ns Q3Q2Q1Q0 = %b (%0d)", $time, q, q);
#1680 $finish;
end
endmodule
Output (Icarus Verilog, iverilog -g2012 ripple.sv && vvp a.out), showing the first edges and the two interesting transitions 7 → 8 and 15 → 0:
t= 20 ns Q3Q2Q1Q0 = 0000 (0)
t= 110 ns Q3Q2Q1Q0 = 0001 (1)
t= 210 ns Q3Q2Q1Q0 = 0000 (0)
t= 220 ns Q3Q2Q1Q0 = 0010 (2)
t= 310 ns Q3Q2Q1Q0 = 0011 (3)
...
t= 710 ns Q3Q2Q1Q0 = 0111 (7)
t= 810 ns Q3Q2Q1Q0 = 0110 (6)
t= 820 ns Q3Q2Q1Q0 = 0100 (4)
t= 830 ns Q3Q2Q1Q0 = 0000 (0)
t= 840 ns Q3Q2Q1Q0 = 1000 (8)
t= 910 ns Q3Q2Q1Q0 = 1001 (9)
...
t=1510 ns Q3Q2Q1Q0 = 1111 (15)
t=1610 ns Q3Q2Q1Q0 = 1110 (14)
t=1620 ns Q3Q2Q1Q0 = 1100 (12)
t=1630 ns Q3Q2Q1Q0 = 1000 (8)
t=1640 ns Q3Q2Q1Q0 = 0000 (0)
The falling edge at 800 ns produces the correct value 8 only at 840 ns, after visiting 6, 4 and 0. Even going from 1 to 2 (at 200 ns) the counter shows a false 0 for 10 ns. Every transition where more than one bit changes has a transient state.
Maximum Clock Frequency
If the count must be valid (settled) before the next clock edge arrives, the clock period must be at least the worst-case ripple time:
Tclk ≥ n × tpd so fmax = 1 / (n × tpd). If the outputs also drive decoding gates that must be read (strobed) before the next edge, add that time: fmax = 1 / (n × tpd + tstrobe).
Example. A 4-bit ripple counter uses flip-flops with tpd = 25 ns. Worst-case settling = 4 × 25 = 100 ns, so fmax = 1 / 100 ns = 10 MHz. An 8-bit version of the same counter would be limited to 1 / 200 ns = 5 MHz. The more bits, the slower the counter, which is exactly the weakness the next chapter removes.
Note that the first flip-flop alone can toggle much faster. If you only use the counter as a frequency divider and never read the intermediate bits, each stage just has to keep up with its own input, and the chain can run near the single flip-flop's limit. The n × tpd rule matters when you read the count.
MOD-N Ripple Counters (Counting to Any N)
A plain n-bit ripple counter has MOD 2n. To get a modulus N that is not a power of two, use k = ⌈log2 N⌉ flip-flops and force them back to 0 as soon as the count reaches N, using the flip-flops' asynchronous CLEAR inputs.
Step-by-Step: MOD-10 (Decade) Ripple Counter
Number of flip-flops: ⌈log2 10⌉ = 4 (3 flip-flops only reach 8 states).
Wanted sequence: 0, 1, ..., 9, then 0. So the first unwanted state is 10 = 1010.
Detect 1010. We need a signal that is true for 1010 but never for 0 to 9. Among 0000 to 1010, only 1010 has Q3 = 1 and Q1 = 1 together (1011 and above never occur), so a 2-input gate is enough: we do not need to check Q2 and Q0.
Clear. CLEAR inputs are usually active-low, so use a NAND: CLR̅ = (Q3 · Q1)̅. When the count reaches 1010, the NAND output goes low and all flip-flops reset to 0000.
+---------------------------+
CLK ─────►| 4-bit ripple counter |──► Q3 Q2 Q1 Q0
| (CLEAR on every FF) |
+-------------┬-------------+
│ CLR (active low)
│
└──◄── NAND ◄── Q3, Q1
count: 0 1 2 3 4 5 6 7 8 9 (10 for a few ns) 0 1 2 ...
State 1010 does exist, but only for the few nanoseconds the NAND and the clear take. Simulation of this circuit, with a 5 ns NAND gate and 10 ns flip-flops:
// MOD-10 ripple counter: a NAND gate clears all flip-flops
// as soon as the count 1010 (Q3 = 1 and Q1 = 1) appears
module decade (input logic clk, rst_n, output logic [3:0] q);
logic clr_n;
assign #5 clr_n = ~(q[3] & q[1]) & rst_n; // NAND (5 ns), plus a power-on reset
tff_neg ff0 (.clk(clk), .clr_n(clr_n), .q(q[0]));
tff_neg ff1 (.clk(q[0]), .clr_n(clr_n), .q(q[1]));
tff_neg ff2 (.clk(q[1]), .clr_n(clr_n), .q(q[2]));
tff_neg ff3 (.clk(q[2]), .clr_n(clr_n), .q(q[3]));
endmodule
Output around the 9 → 0 transition (the flip-flop module and the testbench are the same as before, except that the testbench instantiates decade instead of ripple4, connecting its clr_n signal to the rst_n port):
t= 840 ns Q3Q2Q1Q0 = 1000 (8)
t= 910 ns Q3Q2Q1Q0 = 1001 (9)
t=1010 ns Q3Q2Q1Q0 = 1000 (8)
t=1020 ns Q3Q2Q1Q0 = 1010 (10)
t=1035 ns Q3Q2Q1Q0 = 0000 (0)
t=1110 ns Q3Q2Q1Q0 = 0001 (1)
The unwanted state 1010 lives for 15 ns (5 ns gate + 10 ns clear), then the counter is back at 0. This short spike on Q1 is a known drawback of clearing with asynchronous inputs. A second, subtler danger: if one flip-flop clears faster than another, the NAND input may disappear before the slow flip-flop has cleared. Commercial designs and synchronous counters avoid both problems.
The General Recipe and More Examples
For MOD-N: take N in binary and AND (or NAND, for active-low clear) together the outputs that are 1 in N. If the count can never reach a larger value containing those same 1s before N, you can drop the 0 bits from the check, as we did above.
| Counter | Flip-flops | Clear at | Clear logic (active-low) |
|---|---|---|---|
| MOD-5 | 3 | 101 | (Q2 · Q0)̅ |
| MOD-6 | 3 | 110 | (Q2 · Q1)̅ |
| MOD-10 | 4 | 1010 | (Q3 · Q1)̅ |
| MOD-12 | 4 | 1100 | (Q3 · Q2)̅ |
| MOD-13 | 4 | 1101 | (Q3 · Q2 · Q0)̅ |
For MOD-13, Q3·Q2 alone is not enough: it is already true at 12 (1100), which is a legal count. You need Q0 as well.
Cascading Counters
Counters can be chained: the MSB output of one counter clocks the next, and the moduli multiply. A MOD-6 counter followed by a MOD-10 counter is a MOD-60 counter, the "seconds" stage of a digital clock. Similarly, a MOD-2 and a MOD-5 stage in series give MOD-10. Classic TTL ICs are built exactly this way:
7493: a 4-bit binary ripple counter made of a ÷2 stage and a separate ÷8 stage. Connect the ÷2 output to the ÷8 clock for MOD-16. It has two reset inputs that clear the count when both are high, so extra MOD-N logic is easy.
7490: a decade ripple counter made of a ÷2 stage and a ÷5 stage, with reset-to-0 and set-to-9 inputs. Connecting the ÷2 output to the ÷5 input gives a BCD count 0 to 9.
Cascading more decade counters gives counters for 0 to 99, 0 to 999 and so on, which is how older frequency counters and event counters were built.
Asynchronous vs Synchronous Counters
| Point | Asynchronous (ripple) | Synchronous |
|---|---|---|
| Clock connection | Only FF0 gets the clock; others clocked by previous output | All flip-flops share one clock |
| Extra gates | None (for a binary counter) | AND gates to decide which bits toggle |
| Settling time | n × tpd, grows with n | About tpd + gate delay, nearly independent of n |
| Maximum frequency | Low for many bits | High |
| Transient states / glitches | Yes, during every multi-bit change | Very short skew only; outputs change together |
| Arbitrary sequences | Hard (only simple MOD-N) | Any sequence by design |
| Power | Lower: each stage switches at half the rate of the one before | All flip-flops see every clock edge |
| Typical use | Frequency dividers, slow event counters, watch chips | Program counters, timers, anything inside a clocked system |
Common Mistakes
Mixing up the edge rule. Negative edge with Q gives an up counter; positive edge with Q gives a down counter. Draw the 0 to 7 table and check which edge of Qi−1 should toggle bit i if you forget.
Clearing at N−1 instead of N. A MOD-10 counter must reset when it reaches 10, not at 9; otherwise 9 never appears and you get MOD-9.
Using too few inputs in the clear gate. Detecting MOD-13 with Q3·Q2 resets the counter at 12. Check that no legal count (less than N) satisfies the gate.
Forgetting that delays add. The settling time is n × tpd, not tpd. GATE questions on maximum frequency are built on exactly this.
Decoding ripple outputs directly. A gate watching for "count = 4" will see false 4s during 7 → 8. Strobe the decoder after the counter has settled, or use a synchronous counter.
Thinking a MOD-N counter needs N flip-flops. It needs ⌈log2 N⌉. A MOD-60 counter needs 6, not 60 (a ring counter, from Registers & Shift Registers, is the circuit that uses N flip-flops for MOD-N).
GATE and Interview Questions
Q1. A 5-bit ripple counter uses flip-flops with a propagation delay of 20 ns each. What is the maximum clock frequency at which its count can be read reliably?
Worst-case settling = 5 × 20 = 100 ns. fmax = 1 / 100 ns = 10 MHz.
Q2. How many flip-flops are needed for a MOD-25 ripple counter, and at which count should the clear logic act?
⌈log2 25⌉ = 5 flip-flops (24 = 16 < 25 ≤ 32). The clear must act at 25 = 11001: CLR̅ = (Q4 · Q3 · Q0)̅. Q4·Q3 alone would fire at 24 (11000), a legal count.
Q3. Positive-edge-triggered T flip-flops (T = 1) are connected so that each flip-flop is clocked by the Q output of the previous one. Starting from 000, what is the sequence of Q2Q1Q0?
Positive edge + Q gives a down counter: 000, 111, 110, 101, 100, 011, 010, 001, 000. Check the first step: Q0 goes 0 → 1, a rising edge, so Q1 toggles to 1; that is also a rising edge, so Q2 toggles to 1, giving 111.
Q4. A 1 MHz clock drives a chain of 10 toggle flip-flops. What is the frequency at the last output?
Each stage divides by 2: 1 MHz / 210 = 1 000 000 / 1024 ≈ 976.6 Hz.
Q5. A 4-bit ripple up counter with 10 ns flip-flops is at 1011. List the states it passes through after the next active clock edge.
Next count is 1100. Q0: 1 → 0 at 10 ns gives 1010; Q1: 1 → 0 at 20 ns gives 1000; Q2: 0 → 1 at 30 ns gives 1100, and since Q2 rose (not fell), Q3 does not change. Sequence: 1011 → 1010 → 1000 → 1100, settling after 30 ns.
Q6. Why do ripple counters still appear in modern chips if synchronous counters are better?
For pure frequency division (for example a real-time clock dividing 32 768 Hz down to 1 Hz) nobody reads the intermediate bits at high speed, so the ripple delay does not matter. Ripple counters then win on simplicity and especially power, because later stages switch far less often.
Summary
A counter steps through a fixed sequence of states; the number of states is its modulus. n flip-flops give at most 2n states.
In an asynchronous (ripple) counter only FF0 gets the clock; each later toggle flip-flop is clocked by the previous stage's output.
Each stage divides frequency by 2, so an n-stage ripple counter is a ÷2n frequency divider.
Negative edge + Q = up; changing either the edge or the Q/Q̅ connection makes it count down.
Delays accumulate: settling time n × tpd, fmax = 1 / (n × tpd), and transient false states cause decoding glitches.
MOD-N: use ⌈log2 N⌉ flip-flops and a NAND that detects N to drive the asynchronous clear. The state N appears briefly.
Cascaded counters multiply their moduli (MOD-6 × MOD-10 = MOD-60). The 7490 (÷2 and ÷5) and 7493 (÷2 and ÷8) are classic ripple counter ICs.
Next, Synchronous Counters clock every flip-flop together, removing the ripple delay and allowing any count sequence.