10.1 Counter Fundamentals
Define what a digital counter is, explain how flip-flop count relates to the number of states available, and avoid the common off-by-one confusion between bit count and count range.
A counter is a sequential circuit — built from flip-flops, exactly like a register — that changes its stored state according to clock events, stepping through a predetermined sequence of binary patterns rather than simply holding whatever value is loaded into it. Counters exist because an enormous number of digital tasks reduce to 'keep track of how many clock events have happened' or 'step through a fixed sequence of states': program counters advancing through instructions, frequency dividers, timers, sequencers, and address generators are all, at their core, counters.
Core concept: a register with feedback instead of a plain load path
Where an ordinary register (Module 9) simply passes an externally supplied value through to its outputs on a clock edge, a counter computes its own next state from its current state (and possibly a direction or enable input), then feeds that computed next state back into its own flip-flops. This feedback — next state depends on present state — is what turns a bank of flip-flops from passive storage into an active sequencer that marches through a sequence entirely on its own, driven only by the clock.
An n-flip-flop counter has, at most, 2^n distinct states available to it, exactly like an n-bit register can represent 2^n distinct values — the difference is that a counter is designed to visit some or all of those states in a specific, repeating order as the clock ticks, rather than being loaded with an arbitrary externally chosen value each cycle.
• Counter = flip-flops + next-state logic that feeds back from Q to D (or T/J-K) instead of taking an external load value directly. • n flip-flops give at most 2^n distinct states; how many of those states are actually used in the counting sequence is a separate design choice. • Counters are classified along three independent axes: clocking style (asynchronous/ripple vs. synchronous), direction (up, down, or up/down), and sequence/state-count (natural binary, mod-N, ring, Johnson).
Step-by-step: tracing a 3-bit binary up-counter
The canonical example is a free-running 3-bit binary up-counter, which uses all 8 states available to 3 flip-flops (2^3 = 8) and counts through them in strict binary order: 000, 001, 010, 011, 100, 101, 110, 111, and then wraps back around to 000 on the next clock edge, repeating indefinitely. Each state differs from the previous one by adding exactly 1 (modulo 8) — this is the defining next-state rule of a natural binary up-counter.
Notice that the wraparound from 111 back to 000 is not a special case requiring extra logic in a well-designed binary counter — it falls out naturally from ordinary binary addition: 111 + 1 = 1000, and since only 3 bits exist, the carry out of the top bit is simply discarded, leaving 000. This 'discard the overflow carry' behavior is exactly what makes an n-bit binary counter automatically modulo-2^n, with no explicit reset logic needed.
Practical application and common mistake
The most direct real-world instance of a counter a learner will already be familiar with from this course is the program counter (PC) inside a CPU: on each instruction fetch, the PC increments (usually by a fixed amount corresponding to one instruction's length) so the processor automatically advances to the next instruction address without software having to compute it explicitly — this is exactly an up-counter's job, applied to instruction addresses instead of abstract numbers.
The most common mistake when first learning counters is equating the bit-width label with the counted range in an intuitive but incorrect way — for instance, assuming a '3-bit counter' only counts from 0 to 3. In fact a 3-bit counter counts through 2^3 = 8 states (0 through 7), because 'n-bit' describes the number of flip-flops (and therefore how many binary digits the count value has), not the maximum count value directly; the maximum count value of an n-bit binary counter is 2^n - 1, not n or n-1.
Counter notation
'n-bit counter' refers to the flip-flop count, not the maximum counted value — max value is 2^n - 1. A counter need not use all 2^n available states; using fewer is the subject of Mod-N counters (Topic 10.7).
n-bit counter, states labeled Q(n-1)..Q0:
Max number of distinct states = 2^n
Max count value (natural binary) = 2^n - 1
Example: n = 3
states = 2^3 = 8
count values = 0 .. 7 (binary 000 .. 111)
State diagram notation: circles = states, arrows labeled with the
clock event that causes the transition, e.g.:
(000) --CLK--> (001) --CLK--> (010) --CLK--> ... --CLK--> (111) --CLK--> (000)Code Examples
All 8 states available to 3 flip-flops are used, in strict ascending binary order, with the overflow carry out of Q2 simply discarded on the 8th clock edge, returning the counter to 000 with no special reset logic required. Expected result: Full cycle length: 8 states (000 through 111), repeating indefinitely.
111 (7) + 1 clock edge -> 000 (0): the carry out of the top bit is discarded, giving automatic modulo-8 wraparound.
Clock# Q2 Q1 Q0 Decimal
0 0 0 0 0 (start / after wraparound)
1 0 0 1 1
2 0 1 0 2
3 0 1 1 3
4 1 0 0 4
5 1 0 1 5
6 1 1 0 6
7 1 1 1 7
8 0 0 0 0 <- wraps around automatically (111+1 = 1000, carry discarded)3-bit binary up-counter state diagram
A natural n-bit binary counter always cycles through all 2^n states in order, wrapping automatically.
000 -> 001 -> 010 -> 011 -> 100 -> 101 -> 110 -> 111
^_____________________________________________________|
(wraps back to 000 after 111)Important Rules
An n-flip-flop counter has at most 2^n distinct states; a natural binary counter uses all of them.
The maximum count value of an n-bit binary counter is 2^n - 1, not n and not n-1 — do not confuse bit-width with count range.
Counters are independently classified by clocking style (async/sync), direction (up/down/up-down), and how many of the available states are used in the sequence (binary, mod-N, ring, Johnson).
The program counter
A CPU's program counter is a real-world up-counter: it holds the address of the next instruction to fetch, and after each fetch it increments automatically (by the size of one instruction) so execution naturally advances through memory in sequence, only being explicitly overwritten (rather than incremented) when a branch, jump, or call instruction redirects program flow.
Assuming a '3-bit counter' counts from 0 up to 3.
A 3-bit counter has 2^3 = 8 possible states and, as a natural binary counter, counts from 0 up to 7 before wrapping — the bit count sets how many binary digits the count has, not the highest value directly.
This distinction between 'number of bits' and 'range of values represented' recurs throughout digital design (it's the same relationship as an n-bit register representing 2^n values) and is one of the most common early mistakes when reasoning about counter sizing.
[conceptual] What fundamentally distinguishes a counter from a general-purpose register, even though both are built from flip-flops? A. Counters cannot be reset, while registers can B. A counter's next state is computed from its own current state (feedback), causing it to sequence automatically on each clock, while a register's next state comes from an external data input each time it's loaded C. Counters always use fewer flip-flops than registers D. There is no real difference; the terms are interchangeable
B. A counter's next state is computed from its own current state (feedback), causing it to sequence automatically on each clock, while a register's next state comes from an external data input each time it's loaded — The defining feature of a counter is the Q-to-next-state feedback path: its next value is a function of its present value (via next-state/excitation logic), so it advances through a sequence on its own with each clock. A register, in contrast, is loaded with whatever external value is presented to it, with no self-driven progression.
[interview] A digital designer says 'I need a 4-bit counter.' Without more information, what is the maximum count value that counter will naturally reach before wrapping around? A. 4 B. 8 C. 15 D. 16
C. 15 — A 4-bit natural binary counter has 2^4 = 16 possible states, numbered 0 through 15 — so its maximum count value before wraparound is 15 (binary 1111), not 4 or 16 itself. This is the exact bit-width-vs-range distinction the topic highlights as a common source of confusion.
How many flip-flops are the minimum needed to build a natural binary counter that can count from 0 up to at least 200 before it must wrap around, and what is the actual maximum count value achieved with that many flip-flops?
2^7 = 128 (max value 127, too small); 2^8 = 256 (max value 255, which is >= 200). So 8 flip-flops are the minimum needed, and the actual maximum count value achieved is 255, not exactly 200 — natural binary counters only land on exact powers-of-two-minus-one boundaries unless a Mod-N technique (Topic 10.7) is used to stop at a specific value like 200.
Find the smallest n such that 2^n - 1 is at least 200.