Ripple Counters
Chain T flip-flops so each one clocks the next. Watch the false counts between edges, and see why decoding them glitches.
You Will Be Able To
- Explain how a ripple counter counts with one flip-flop clocking the next.
- List the false values a ripple counter shows between two counts.
- Explain why a decoded ripple-counter output glitches.
- Compare a ripple counter with a synchronous counter.
- Lesson
- G6.3
- Time
- 20 min
- Runs on
- Your browser
- Check
- 5 questions
A board counts pulses with three toggle flip-flops in a chain. A second chip watches for the count 0. It fires twice before the count ever wraps to 0.
Each Flip-Flop Clocks the Next
A T flip-flop with T = 1 toggles at every active edge of its clock. So it divides its clock by two. Chain such stages, each clocked by the output of the one before, and they count in binary.
- Clock / reset
- Storage
- Clock
- Stage 0
It toggles at every clock edge: q0 = 0, 1, 0, 1, ...
- Stage 1
It toggles each time q0 falls from 1 to 0, so at half the rate.
- Stage 2
It toggles each time q1 falls, at a quarter of the rate. Together q2 q1 q0 count 0 to 7.
Read the diagram as text
- clk: input clock
- Stage 0: toggles on clk
- Stage 1: toggles when q0 falls
- Stage 2: toggles when q1 falls
- clk → Stage 0
- Stage 0 → Stage 1: q0
- Stage 1 → Stage 2: q1
A bit falling from 1 to 0 is exactly when binary counting carries into the next bit.
No logic gates are needed between stages. That is why ripple counters are small and draw little power.
False Counts Between Edges
Each stage waits for the one before it to switch. So the bits change one after another, and the outputs pass through values that are not counts.
| Gate delays after the edge | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| q2 q1 q0 | 011 | 010 | 010 | 000 | 000 | 100 |
From the circuit above: 011 becomes 100 through 010 and 000. Each bit adds a stage delay.
The lab does the same with 2 ns flip-flops. It prints every value the outputs pass through. The change from 3 to 4 shows two false values and takes 6 ns.
Decoding a Ripple Counter Glitches
A decoder turns one count into a 1, for example "the count is 0". On a ripple counter it also sees the false values. In the circuit above the NOR for 000 is 1 for two gate delays while the count goes from 3 to 4.
- Cycle 1
At 32 ns the count goes from 1 to 2. Stage 0 falls first, so q reads 000 for 2 ns.
- Cycle 5
At 74 ns, during 3 to 4, q reads 000 again. The decoder pulsed twice; the count was never 0.
Measured: the times and values are the lab's printed lines.
A glitch is harmless when a flip-flop on the same clock samples the decoder later, after the count settles. It is harmful on a clock, a reset or a latch enable (G5.3).
Counting Down
Clock each stage from the rising edge of the stage before it, and the chain counts down. Subtracting 1 borrows from bit 1 exactly when bit 0 goes from 0 to 1.
The bits still change one after another, starting with bit 0. So a down counter shows false values too, but different ones.
Why Synchronous Counters Replaced Them
Ripple counter
stage i clocked by q[i-1]
No gates between stages. The count settles after N stage delays and passes through false values.
Synchronous counter (G6.4)
every stage on clk; T[i] = q[i-1] & ... & q[0]
All bits change one clock-to-Q after the edge. It needs an AND chain, but it never shows a false count.
Ripple counters survive where only the final count matters and power is tight, such as slow clock dividers. Inside a synchronous design, the rule is one clock for every flip-flop (G5.9).
Asked in interviews
What is a ripple counter?
A chain of toggle flip-flops where each stage is clocked by the output of the stage before it. Only the first stage sees the system clock.
What is the main problem with a ripple counter?
The bits change one after another, so the count settles only after N flip-flop delays and passes through false values. Decoding it glitches.
How long does a 16-bit ripple counter take to settle?
Up to 16 clock-to-Q delays, when a carry ripples through every stage, as in 0111...1 to 1000...0.
Try It
Each edge flips stage 0 after 2 ns. When q0 falls, stage 1 flips 2 ns later, and so on up the chain.
The change from 1 to 2 shows one false value (000). The change from 3 to 4 shows two (010 and 000) and settles 6 ns after the edge.
The decoder for 000 pulsed twice, though the count went only from 0 to 4. Change #2 to #5 and run again: the false values last longer.
t=12 q=001 t=32 q=000 t=34 q=010 t=52 q=011 t=72 q=010 t=74 q=000 t=76 q=100 decoder for 000: 2 pulsesRead included file: tb.sv
// tb.sv: four falling clock edges; prints every value q passes through (read-only).
`timescale 1ns/1ns
module tb;
logic clk = 1, clr = 0;
wire [2:0] q;
wire is0 = (q == 3'b000); // a decoder for the count 0
int pulses = 0;
ripple3 dut (.clk(clk), .clr(clr), .q(q));
always #10 clk = ~clk; // falling edges at 10, 30, 50, 70
always @(q) if (!clr) $display("t=%0d q=%b", $time, q);
always @(posedge is0) if (!clr) pulses++;
initial begin
#1 clr = 1;
#4 clr = 0; // q = 000
#75 $display("decoder for 000: %0d pulses", pulses);
$finish;
end
endmodule
Check Yourself
Common Mistakes
Wrong Assume every bit of a ripple counter changes at the clock edge.
Each stage waits for the stage before it. In the lab, 011 to 100 passed through 010 and 000 first.
Fix Read a ripple counter only after N stage delays, or use a synchronous counter.
Wrong Decode a count of a ripple counter and use the result as a clock or a reset.
The false values make real pulses on the decoder output. The lab's decoder for 000 pulsed twice in four counts that never held 0.
Fix Sample decoded outputs with a flip-flop on the system clock, or count synchronously.
Wrong Expect a ripple counter to settle in one flip-flop delay.
The worst change ripples through every stage: a 3-bit counter with 2 ns stages took 6 ns from 011 to 100.
Fix Budget N times the clock-to-Q delay before the count is valid.
Remember
- In a ripple counter only stage 0 sees the clock; each other stage is clocked by the stage before it.
- The bits change one after another, so the outputs pass through false counts between edges.
- A ripple counter settles only after N stage delays, and decoding it glitches.
- Synchronous counters change every bit at one edge; ripple counters remain for small, slow dividers.