Skip to content

Practice problems

Counters and flip-flops practice problems

A chain of toggle flip-flops is a binary ripple counter: the first toggles on each clock edge, and each one after it toggles when the previous stage's output goes from 1 to 0, so together they count clock pulses in binary. These ten problems find how high a counter can count, how many flip-flops it needs, what frequency comes out of each stage, where the count lands after many pulses, and how long a ripple counter takes to settle. Type your answer to check it, and open the working whenever you want it.

The method

n flip-flops count 0 to 2n − 1
  • Each toggle stage divides the frequency by 2: after n stages, f = fclock ÷ 2n
  • Rollover: an n-bit counter is mod-2n, so after k pulses it shows k mod 2n, the remainder of k ÷ 2n
  • Ripple delay: the bits toggle one after another, so the worst case is n × one flip-flop's propagation delay

The problems

Type your answer and tap Check. Every one has the working, step by step.

  1. Problem 1 of 10

    A binary counter is built from 4 flip-flops. What is the highest number it can count to before it rolls over to 0?

    Show the working
    1. n flip-flops store n bits, which count from 0 to 2ⁿ − 1.
    2. 2⁴ − 1 = 16 − 1 = 15. In binary that's 1111.

    Answer: 15

  2. Problem 2 of 10

    A mod-50 counter has to step through 50 different states, 0 to 49. What is the fewest flip-flops it needs?

    Show the working
    1. n flip-flops give 2ⁿ states. Find the smallest n that reaches 50.
    2. 5 flip-flops give only 2⁵ = 32. 6 give 2⁶ = 64, which is enough: 6 flip-flops.

    Answer: 6

  3. Problem 3 of 10

    A T flip-flop with T held at 1 (so it toggles on every clock edge) is clocked at 10 kHz. What is the frequency at its output, in kilohertz?

    Show the working
    1. It toggles on each rising clock edge, so one full output cycle takes two clock cycles.
    2. fout = 10 kHz over 2 = 5 kHz

    Answer: 5 kHz

  4. Problem 4 of 10

    A 1 MHz clock drives a 3-stage ripple counter. What frequency comes out of the last stage, in kilohertz?

    Show the working
    1. Each stage divides the frequency by 2, so 3 stages divide by 2³ = 8.
    2. f = 1,000,000 Hz over 8 = 125,000 Hz = 125 kHz

    Answer: 125 kHz

  5. Problem 5 of 10

    A 3-bit counter starts at 0. What number does it show after 11 clock pulses?

    Show the working
    1. 3 bits count 0 to 7, then roll over: it is a mod-8 counter, so 8 pulses bring it back to 0.
    2. 11 mod 8 = 3, so after the rollover it has counted 3 more: 3. In binary that's 011.

    Answer: 3

  6. Problem 6 of 10

    A 4-bit counter starts at 0. What number does it show after 100 clock pulses?

    Show the working
    1. 4 bits count 0 to 15, so it is a mod-16 counter and rolls over every 16 pulses.
    2. 100 ÷ 16 = 6 complete counting cycles (96 pulses) with remainder 4: 100 mod 16 = 4.
    3. It shows 4. In binary that's 0100.

    Answer: 4

  7. Problem 7 of 10

    A watch crystal runs at 32,768 Hz. It drives a chain of 10 toggle flip-flops (a 10-stage ripple counter). What frequency comes out?

    Show the working
    1. 10 divide-by-2 stages divide by 2¹⁰ = 1024.
    2. f = 32,768 Hz over 1024 = 32 Hz. Five more stages would bring it down to 1 Hz.

    Answer: 32 Hz

  8. Problem 8 of 10

    A 1 kHz clock feeds a ripple counter. What is the period of the second stage's output, in milliseconds?

    Show the working
    1. Two stages divide by 2² = 4: f = 1000 Hz over 4 = 250 Hz.
    2. T = 1 over f = 1 over 250 Hz = 0.004 s = 4 ms

    Answer: 4 ms

  9. Problem 9 of 10

    Stretch: each flip-flop in a 4-bit ripple counter has a clock-to-output propagation delay of 10 ns. The count goes from 1111 to 0000. How long until the MSB has changed, in nanoseconds?

    Show the working
    1. In a ripple counter each stage is clocked by the output of the one before, so each bit must wait for the previous bit to toggle.
    2. From 1111 to 0000 all four bits toggle, one after another, so the propagation delays add.
    3. 4 × 10 ns = 40 ns. Until then the outputs pass through brief invalid intermediate counts.

    Answer: 40 ns

  10. Problem 10 of 10

    Stretch: each flip-flop in an 8-bit ripple counter has a propagation delay of 15 ns. The count must settle before the next pulse. What is the maximum clock frequency, in megahertz?

    Show the working
    1. The worst case is all 8 bits toggling, as in 11111111 to 00000000: 8 × 15 ns = 120 ns.
    2. The clock period must be at least 120 ns, so f = 1 over T.
    3. f = 1 over 0.00000012 s ≈ 8,330,000 Hz ≈ 8.33 MHz

    Answer: 8.33 MHz

Build it in a free lesson

“Clocks and counters” is lesson 6 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 47 before it first.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Clocks and counters” is lesson 6 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 47 before it first.

Or start from the very first lesson, no account needed

Check it with a calculator

The ideas behind it

Questions people ask

How high can an n-bit counter count?

n flip-flops store n bits, which give 2ⁿ different states. One of them is 0, so the counter goes from 0 to 2ⁿ − 1, then rolls over to 0: it is a mod-2ⁿ counter. A 4-bit counter counts 0 to 15.

Why does a flip-flop halve the frequency?

A T flip-flop with T = 1 toggles (changes state) on every active clock edge. Going high and then low again takes two toggles, so one output cycle takes two clock cycles. Chain n of them and the last runs at the clock ÷ 2ⁿ.

What's the difference between a ripple counter and a synchronous counter?

In a ripple (asynchronous) counter each flip-flop is clocked by the output of the one before, so the bits change one after another and the propagation delays add up. A synchronous counter clocks every flip-flop from the same clock and uses logic gates to decide which bits toggle, so its bits change together and it can run faster.

More practice