Skip to content
BetterDL

Modulus

Also called: counter modulus, MOD number, modulus of a counter

The number of distinct states a counter steps through before its sequence repeats. A counter with modulus N is called a mod-N counter.

The modulus of a counter tells you how long its cycle is: how many different states it visits before it comes back to where it started.

  • A 3-bit binary counter visits 0 to 7, so its modulus is 8.
  • A BCD counter visits 0 to 9, so its modulus is 10.
  • A 4-bit ring counter visits 4 states, so its modulus is 4, even though it has 4 flip-flops.

n flip-flops can hold 2ⁿ patterns, so a full n-bit binary counter has modulus 2ⁿ. A mod n counter uses fewer than all of them, and the rest become unused states.

Two numbers sit right next to each other and are easy to mix up. The modulus N counts the states. The maximum count is the largest value shown, which is N − 1 for a counter that starts at 0, because 0 is one of the states.

The modulus also sets the division ratio: a mod-N counter goes round once every N clock cycles, so any output that repeats once per cycle runs at f / N.

startCLKCLKCLKCLKCLK000001010011100

Worked examples

Example

Finding the modulus

Count the states in one full cycle, not the flip-flops.

  1. 1.

    4-bit binary up counter: 0 to 15 → modulus 16.

  2. 2.

    The mod-5 counter in the diagram: 000, 001, 010, 011, 100 → modulus 5. Codes 101, 110 and 111 are never visited.

  3. 3.

    A counter that loads 6 whenever it leaves 15 and counts 6, 7, … , 15: that is 15 − 6 + 1 = 10 states → modulus 10.

  4. 4.

    A 4-bit Johnson counter: 8 states → modulus 8.

Example

Modulus and frequency

A mod-12 counter is clocked at 6 MHz. How often does it pass through 0?

  1. 1.

    It returns to 0 once every 12 clock cycles.

  2. 2.

    6 MHz / 12 = 500 kHz, so 500 000 times a second, once every 2 µs.

Common mistakes

  • Giving the largest count as the modulus. A counter that shows 0 to 9 has modulus 10, not 9.

  • Assuming the modulus is always 2ⁿ. Ring, Johnson, BCD and mod-N counters all use fewer states than their flip-flops allow.

  • Confusing the modulus with the number of flip-flops. Mod-16 needs 4 flip-flops, not 16.

Practice Modulus

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Modulus is taught in Counters.