Counters: ring, Johnson and BCD
Study notes on three counter families — ring (one-hot) counters, Johnson (twisted-ring) counters and BCD (decade) counters — their definitions, state counts, circuit connections, timing constraint formula and design examples.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Counters are fundamental sequential circuits used to count events, generate timing sequences and create state machines inside processors, timers, digital interfaces and control logic. Engineers choose a counter type (binary, ring, Johnson, BCD) based on required number of states, decoding simplicity, speed and hardware cost.
Key ideas
Ring counter (one-hot) — A shift-register style counter implemented with n flip-flops in a ring, where exactly one flip-flop is '1' at any time (one-hot encoding) and all others are '0'. Exact definition: connect each flip-flop output Q_i to the next flip-flop's input D_{i+1}, and connect the last Q_{n-1} back to D_0. Assumption: initial state must be a one-hot state (e.g., 100...0) otherwise the ring may lock in a different pattern including all zeros.
- Number of states: exactly n (each clock shifts the single 1 through positions 0..n-1). Derivation: starting from a one-hot vector, each clock edge moves the '1' one position; after n clocks the original position returns.
- To draw: draw n D flip-flops horizontally, label outputs Q_0 ... Q_{n-1} left to right. Draw arrows Q_i -> D_{i+1} (with wrap-around Q_{n-1} -> D_0). Indicate initial state 100...0.
Johnson (twisted-ring) counter — A variation of ring counter where the complemented output of the last flip-flop is fed back into the first input. Exact definition: for n flip-flops, set D_0 = NOT(Q_{n-1}) and D_{i+1} = Q_i for i=0..n-2. Assumption: flip-flops update on the same clock edge (synchronous shifting).
- Number of states: exactly 2n. Derivation (standard): starting from a state with k leading ones followed by zeros, each clock shifts the pattern right and injects complement of the previous last bit; the pattern grows ones until all ones then in next cycles zeros are injected producing n more distinct patterns. Formal: count of distinct cyclic states = 2n because there are n states with a contiguous block of ones of length 0..n-1 and n states with a contiguous block of zeros of length 0..n-1 (or you can trace transitions length by length).
- To draw: draw n D flip-flops horizontally, label outputs Q_0...Q_{n-1}. Connect Q_i -> D_{i+1} (wrap) and connect NOT(Q_{n-1}) -> D_0.
BCD (decimal or decade) counter — A counter with modulus M = 10 that counts binary representations 0000 through 1001 (0..9) then returns to 0000. Usually implemented with 4 flip-flops (n = 4) since 2^4 = 16 ≥ 10. Two common implementations:
- Binary up-counter (4 bits) with asynchronous clear (or synchronous reset) triggered when the state reaches 1010 (decimal 10). Detection function often uses Q3 AND Q1 for asynchronous clear when the count reaches 1010; using a NAND feeding the active-low asynchronous clear (/CLR) is a standard textbook trick. Assumption: asynchronous clear is safe only if timing/glitch hazards are managed in the real circuit.
- Dedicated decade counter ICs or state machine with combinational next-state logic.
- To draw (asynchronous clear method): draw 4 flip-flops Q3 (MSB) to Q0 (LSB). Draw a 2-input NAND that takes Q3 and Q1, output connected to active-low clear (/CLR) inputs of all flip-flops. Explain detection: when the state reaches 1010 (Q3=1, Q2=0, Q1=1, Q0=0), the NAND of Q3 and Q1 outputs 0 and clears flip-flops to 0000.
Timing parameters (definitions)
- Clock-to-Q time (t_co) — time from active clock edge to when flip-flop output responds.
- Propagation delay of combinational logic (t_pd_comb) — worst-case delay from input change to output stable.
- Setup time (t_s) — time before the clock edge during which input must be stable.
- Hold time (t_h) — time after the clock edge during which input must remain stable.
- Maximum safe clock frequency (f_max) — set by the worst-case timing path. Exact statement for synchronous counters with combinational next-state: a safe clock period T must satisfy T >= t_co + t_pd_comb + t_s. Then f_max = 1 / T. (Assumes no additional clock skew; include clock skew t_skew if present: T >= t_co + t_pd_comb + t_skew + t_s.) In addition, satisfy the hold-time constraint: t_co(min) + t_pd_comb(min) - t_skew >= t_h.
Notes and assumptions: we assume ideal instantaneous logic levels except for the timing parameters above. For asynchronous clears or preset signals, mention hazards: asynchronous signals can produce metastability or transient invalid states if detection logic glitches; many designs use synchronous reset for robustness.
Formulas
M = number of distinct states of a counter — M is integer, no unit; applies to any counter.
M_max(n) = 2^n — n = number of flip-flops, applies to general binary storage.
M_ring(n) = n — ring counter with n flip-flops (one-hot), applies only when a single 1 is circulated; unitless.
M_johnson(n) = 2·n — Johnson (twisted-ring) counter with n flip-flops; unitless.
T_min >= t_co + t_pd_comb + t_s — T_min is minimum allowable clock period (s), t_co is clock-to-Q (s), t_pd_comb is propagation delay of next-state logic (s), t_s is setup time (s). Applies to synchronous counters.
f_max = 1 / T_min — maximum clock frequency (Hz).
Clear_detect = Q3 AND Q1 — minimal asynchronous-clear detection for when the count reaches 10 (1010) using Q3..Q0; unitless Boolean expression. For exact decoding of 1010, use Q3 AND NOT Q2 AND Q1 AND NOT Q0.
Worked examples
- 4-bit ring counter (one-hot) using D flip-flops
- Requirement: build a 4-state counter using 4 D flip-flops with states 1000 -> 0100 -> 0010 -> 0001 -> 1000 ...
- Circuit connections: D0 <= Q3, D1 <= Q0, D2 <= Q1, D3 <= Q2. (Wrap Q3 back to D0.) Initialize to 1000.
- State table (clock edges): initial 1000 -> after 1 clk 0100 -> after 2 clk 0010 -> after 3 clk 0001 -> after 4 clk 1000. This traces 4 distinct states (n=4). Final answer: bold sequence in order: 1000, 0100, 0010, 0001, ....
- 4-bit Johnson (twisted-ring) counter sequence and state count
- Circuit: D0 <= NOT(Q3), D1 <= Q0, D2 <= Q1, D3 <= Q2.
- Starting from 0000, next states: 1000 (inject NOT(0)=1), 1100, 1110, 1111, 0111, 0011, 0001, 0000 -> back. List of eight states (2n = 8). Step-by-step: 0000 -> 1000 -> 1100 -> 1110 -> 1111 -> 0111 -> 0011 -> 0001 -> 0000. Final answer: 0000,1000,1100,1110,1111,0111,0011,0001, ....
- Design a BCD (mod-10) counter using a 4-bit binary up-counter with asynchronous clear
- Use 4 flip-flops Q3..Q0 as binary count. Detection of 10 (decimal) corresponds to 1010 (Q3=1, Q2=0, Q1=1, Q0=0). Minimal detection logic: signal D = Q3 AND Q1.
- If flip-flops have active-low asynchronous clear (/CLR), implement /CLR = NAND(Q3, Q1). Explanation: NAND outputs 0 only when Q3=1 and Q1=1, which corresponds to 1010 if the counter reached that state; the asynchronous clear then forces 0000 immediately.
- Caveat: if the counter transiently produces 1011, 1111 etc due to glitches, the NAND approach may misfire. A safer method is synchronous reset: compute R = Q3·Q1 and feed to synchronous clear input so reset happens at next clock edge (useful if combinational glitching is a concern).
- Final functional description: binary sequence 0000..1001 then clear -> 0000. Bold: Sequence: 0000,0001,...,1001,0000.
Common mistakes
- Using NAND(Q3,Q1) without noting active-low clear polarity or hazards; forgetting that NAND produces 0 only when both inputs are 1.
- Not stating or checking initial state for ring counters; if initial state is all zeros the ring will remain at 000...0 (no single 1 to circulate).
- Ignoring timing: not checking t_co, t_pd_comb and t_s leads to incorrect f_max and possible metastability.
- When asked to draw diagrams, forgetting to label Q indices, D inputs and the feedback path (especially the inversion in Johnson counter).
For your exam
Types of questions you will get: definitions and short notes (define ring, Johnson and BCD counters), derivations (show why Johnson has 2n states), circuit-drawing questions (draw n D flip-flops and show connections), design problems (design a mod-10 counter using 4 flip-flops and show detection/reset logic), timing analysis (compute f_max from given t_co, t_pd_comb and t_s), and state-trace questions (trace k clock cycles starting from a given initial state).
What full-marks answers include:
- Precise definitions with bold terms (one-hot, twisted feedback, modulus).
- Correct circuit connection description and clearly labelled diagram instructions.
- State table or state sequence for requested cycles.
- Timing constraints when asked and correct substitution into formulas with units.
- Notes about assumptions (initial state, reset polarity, synchronous vs asynchronous choice) and practical cautions (hazards).
Quick check
- How many flip-flops are required to implement a Johnson counter with 12 distinct states?
- What Boolean function is commonly used for asynchronous clear when the count reaches 10 (1010) using bits Q3..Q0?
- Give the minimum clock period expression (T_min) for a synchronous counter in terms of t_co, t_pd_comb and t_s.
Answers: 1) 6 flip-flops (because 2n = 12 => n = 6). 2) Q3 AND Q1 (i.e., Q3·Q1) for asynchronous clear; exact 1010 decode is Q3 AND NOT Q2 AND Q1 AND NOT Q0. 3) T_min >= t_co + t_pd_comb + t_s.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?