DigiFlop

Counts 0 up to N-1, then wraps back to 0.

Verilog Coding Exercise · Sequential
Mod-N Counter
Counts 0 up to N-1, then wraps back to 0.

A counter that resets itself back to zero once it reaches N-1, instead of rolling over at a fixed power of two — useful whenever the count needs to match something other than a binary width, like a 6-state sequencer.

▶ Try the interactive version