EngineerPlay

Flip-flop and counter formulas

n flip-flops have 2ⁿ states, so a counter of N states needs the least n with 2ⁿ ≥ N. A chain of n T flip-flops divides a clock by 2ⁿ, a MOD-N counter divides it by N, and a ripple counter settles after n × t_pd.

The formulas

FormulaWhat it givesSymbols
2ⁿ ≥ NFlip-flops for N statesn = the number of flip-flops; take the least n, so a counter from 0 to 59 (N = 60) needs 6
f_out = f_in ÷ 2ⁿFrequency out of n T flip-flops in a roweach flip-flop with T = 1 changes once for every two clock edges it reacts to, so it halves the frequency
f_in ÷ f_out = 2ⁿFlip-flops to divide a crystal downa 32,768 Hz watch crystal needs 15 flip-flops for 1 Hz
f_out = f_in ÷ NFrequency out of a MOD-N counterN = the count at which the NAND gate clears the counter; it shows 0 to N − 1
f = 1 ÷ TFrequency from the periodT = one whole high and low of the clock, read from one rising edge to the next
t = n × t_pdRipple counter settling timet_pd = one flip-flop's delay from its clock edge to its output; the delays add up along the chain
f_max = 1 ÷ (n × t_pd)Fastest clock for a ripple counterthe whole count must settle within one clock period

Worked example

This example is made by the same code as the practice questions. Open the working to see every step.

The NAND gate clears every flip-flop through CLR as soon as all its inputs are 1. What frequency comes out of the last flip-flop?

A counter of 3 T flip-flops whose NAND gate clears them all through CLRLabels shown, in drawing order: f_in = 1 kHz, 1, T, Q, Q̄, CLR, Q₀, T, Q, Q̄, CLR, Q₁, T, Q, Q̄, CLR, Q₂, f_out = ?.f_in = 1 kHz1TQQ̄CLRQ₀TQQ̄CLRQ₁TQQ̄CLRQ₂f_out = ?
Show the working
  1. Write down what is given: the NAND gate's inputs: Q₂, Q₀, f_in = 1 kHz.
  2. The NAND clears every flip-flop the moment all its inputs are 1, so that count never stays: the counter starts again from 0.
  3. Those outputs are all 1 at the count N = 4 + 1 = 5.
  4. The last output goes through one cycle for every N input pulses: f_out = f_in ÷ N.
  5. Work it out: f_out = 1 kHz ÷ 5 = 0.2 kHz = 200 Hz.
  6. Check: the counter shows N different counts, so it divides by N. Answer: 200 Hz.
Why not the others?
  • 250 Hz Uses the highest count shown; the counts start at 0, so there is one more.

Remember: A MOD-N counter divides the clock by N: f_out = f_in ÷ N. Formula sheet

Common mistakes

These are the wrong answers the practice questions offer, and the slip that leads to each.

Questions

What is the formula for flip-flops for N states?

2ⁿ ≥ N. Symbols: n = the number of flip-flops; take the least n, so a counter from 0 to 59 (N = 60) needs 6.

What is the formula for frequency out of n T flip-flops in a row?

f_out = f_in ÷ 2ⁿ. Symbols: each flip-flop with T = 1 changes once for every two clock edges it reacts to, so it halves the frequency.

What is the formula for flip-flops to divide a crystal down?

f_in ÷ f_out = 2ⁿ. Symbols: a 32,768 Hz watch crystal needs 15 flip-flops for 1 Hz.