10.9 Johnson Counter

Explain how a Johnson (twisted-ring) counter's complemented feedback doubles its state count relative to a plain ring counter, trace its walking-1s/walking-0s sequence, and identify why its states are not one-hot.

A Johnson counter, also called a twisted-ring counter, is built exactly like a ring counter — a shift register with its last stage's output fed back to its first stage's input — except the feedback connection is inverted: it is the complement of the last stage's output, not the output itself, that feeds back into the first stage. This single change to the feedback path doubles the number of distinct states the counter cycles through compared to a plain ring counter with the same flip-flop count, producing a distinctive 'walking 1s, then walking 0s' pattern that shows up wherever a cheap multi-phase or low-glitch cyclic sequence is needed.

Core concept: complemented ('twisted') feedback

Structurally, the only difference between a ring counter (Topic 10.8) and a Johnson counter is one inverter: instead of wiring Q(n-1) directly back to D0, a Johnson counter wires NOT Q(n-1) back to D0. Starting from an all-zero state, this small change produces a very different, and much richer, sequence: on the first clock, the complement of Q(n-1) (which is 0, so its complement is 1) shifts in at the front, giving one stage set to 1 and the rest still 0. On each subsequent clock, another 1 shifts in at the front, progressively filling the register with 1s from one end — a 'walking 1s' pattern.

Once the register is entirely full of 1s, the same complemented-feedback rule now shifts in 0s instead (since the last stage's output, now 1, complements to 0), and the register progressively fills with 0s from the same end, a 'walking 0s' pattern, until it returns to all-zero and the whole cycle repeats. This complete cycle — walking 1s in, then walking 0s in — is what gives an n-stage Johnson counter exactly 2n distinct states, double the n states of a plain ring counter with the same flip-flop count.

• The only structural change from a ring counter: the feedback path carries the COMPLEMENT of the last stage's output, not the output itself. • Sequence pattern: 1s progressively fill the register from one end, then 0s progressively fill it from the same end, repeating. • An n-bit Johnson counter produces up to 2n states — exactly twice the state count of an n-bit ring counter.

Step-by-step working: the full 8-state cycle for n = 4

Tracing a 4-flip-flop Johnson counter starting from all-zero: 0000 -> 1000 -> 1100 -> 1110 -> 1111 -> 0111 -> 0011 -> 0001 -> 0000. The first four transitions (0000 through 1111) are the walking-1s phase, each clock inserting one more 1 at the front; the next four transitions (1111 through 0000) are the walking-0s phase, each clock inserting one more 0 at the front, using the same complemented-feedback mechanism now operating on an all-1s register. Counting the distinct states in this full cycle gives exactly 8 = 2 x 4, matching the 2n formula for n = 4 flip-flops.

This is the spec's tricky point made concrete: a Johnson counter built from the same number of flip-flops as a ring counter produces exactly twice as many usable states under normal operation, purely because of that one inverted feedback connection — the complemented feedback is what keeps the sequence from simply repeating after only n clocks the way a plain ring counter's direct feedback does.

Practical application, real-world use, and common mistake

Johnson counters are used to generate multiple, evenly-spaced clock phases cheaply — for example, driving a multi-phase stepper motor sequence, or any application needing several timing signals offset from each other by a fixed fraction of the overall cycle, directly from flip-flop outputs. They are also used to build low-glitch decade (Mod-10) counters: a 5-flip-flop Johnson counter naturally produces exactly 2 x 5 = 10 states, matching a decade counter's needs with fewer flip-flops than an equivalent binary Mod-10 design, and with simpler, more glitch-resistant decoding than a binary counter's decode network typically achieves.

The most important mistake to avoid is treating a Johnson counter's states as one-hot the way a ring counter's are. Because most Johnson counter states have several bits set (or several bits clear) at once — for example, state 1100 has two 1s, and state 0111 has three — you cannot simply read a single flip-flop's Q output to know 'we are in state k' the way you can with a plain ring counter. Correctly decoding each individual Johnson-counter state requires small combinational logic (typically a 2-input gate per state, since each state differs from its neighbors by only one bit) rather than a single wire tap.

Johnson counter notation and state-count formula

The formula 2n states assumes normal (correctly-initialized, self-consistent) operation as stated in the spec. Unlike a ring counter, most Johnson counter states are NOT one-hot — several bits are set (or clear) simultaneously in most states.

n-stage Johnson (twisted-ring) counter:

  D0 <---[NOT]<---Q(n-1)   (complemented feedback -- the one difference from a ring counter)
   |
  [FF0]--Q0-->[FF1]--Q1-->...-->[FF(n-1)]--Q(n-1)---(back to the inverter)

Number of states = 2n   (double a same-size ring counter's n states)

Example, n = 4:
  0000 -> 1000 -> 1100 -> 1110 -> 1111 -> 0111 -> 0011 -> 0001 -> 0000
  (8 = 2 x 4 states total: 4 "walking 1s", then 4 "walking 0s")

Code Examples

Each clock edge shifts the register and inserts the complement of the outgoing bit's neighbor at the front. During clocks 1-4, that inserted bit is progressively 1 (since the fed-back bit, Q3, starts at 0 and its complement is 1), filling the register with 1s; during clocks 5-8, the inserted bit is progressively 0 (since Q3 is now 1 and its complement is 0), filling the register with 0s — 8 total distinct states for 4 flip-flops, exactly matching the 2n = 8 formula. Expected result: Full cycle: 0000, 1000, 1100, 1110, 1111, 0111, 0011, 0001, then repeats from 0000.

8 distinct states for 4 flip-flops (2n = 2x4 = 8), versus only 4 states a same-size plain ring counter would produce.

Clock#   Q3 Q2 Q1 Q0   Phase
  0        0  0  0  0    (start)
  1        1  0  0  0    walking 1s
  2        1  1  0  0    walking 1s
  3        1  1  1  0    walking 1s
  4        1  1  1  1    walking 1s complete (all set)
  5        0  1  1  1    walking 0s
  6        0  0  1  1    walking 0s
  7        0  0  0  1    walking 0s
  8        0  0  0  0    walking 0s complete (back to start)

Johnson counter: ring counter with an inverter in the feedback path

One inverter in the feedback path turns a ring counter (n states) into a Johnson counter (2n states).

+----[NOT]----------------------------------+
        |                                              |
        v                                              |
  D0 -->[FF0]--Q0-->[FF1]--Q1-->[FF2]--Q2-->[FF3]--Q3---

The single inverter in the feedback loop is the only structural
difference from the plain ring counter of Topic 10.8.

Important Rules

An n-stage Johnson counter produces up to 2n distinct states under normal operation — exactly double a same-size ring counter's n states.

The sequence pattern is always 'walking 1s fill the register from one end, then walking 0s fill it from the same end, then repeat.'

Unlike a ring counter, most Johnson counter states have multiple bits set (or clear) simultaneously — they are not one-hot, so decoding an individual state needs a small combinational gate, not a single flip-flop tap.

Multi-phase clock generation and low-glitch decade counters

Johnson counters are used to generate several evenly-spaced timing phases directly from flip-flop outputs — useful for sequencing multi-phase stepper-motor windings or generating a family of offset clock signals — and a 5-flip-flop Johnson counter is a standard, low-glitch way to build a Mod-10 (decade) counter, since 2 x 5 = 10 states exactly matches a decade counter's requirement, typically with simpler and cleaner decoding logic than an equivalent binary Mod-10 design built with reset/decode logic (Topic 10.7).

Assuming a Johnson counter's states can be read directly off a single flip-flop's Q output the same way a ring counter's one-hot states can.

Decode each individual Johnson-counter state with a small 2-input gate comparing two adjacent bits (since each state differs from its neighbor by exactly one bit at one end), rather than expecting any single Q output to directly indicate a specific state the way a ring counter's outputs do.

A Johnson counter's states are not one-hot — most have several bits set or several bits clear simultaneously (e.g., 1100 or 0111 in the 4-bit example) — so no single flip-flop's output by itself uniquely identifies the current state; proper decoding needs logic that looks at more than one bit.

[tricky-problem] A ring counter and a Johnson counter are both built from the same number of flip-flops, n. Under normal operation, how do their numbers of distinct states compare? A. They have the same number of states, n, since both are ring-style feedback shift registers B. The Johnson counter has exactly twice as many states (2n) as the ring counter (n), because its complemented feedback produces a 'walking 1s, then walking 0s' sequence instead of simply repeating after n clocks C. The ring counter always has more states than the Johnson counter D. Both have 2^n states, identical to a binary counter

B. The Johnson counter has exactly twice as many states (2n) as the ring counter (n), because its complemented feedback produces a 'walking 1s, then walking 0s' sequence instead of simply repeating after n clocks — This is exactly the spec's tricky point: the only structural difference between the two is the inverter in the Johnson counter's feedback path, but that single change doubles the state count from n (ring counter) to 2n (Johnson counter) under normal operation, by producing a walking-1s-then-walking-0s cycle instead of a plain rotating one-hot pattern.

[interview] Why can't you decode an individual Johnson counter state by simply reading one flip-flop's Q output, the way you can with a ring counter? A. Because Johnson counters do not have individually accessible Q outputs at all B. Because most Johnson counter states have more than one bit set (or more than one bit clear) at the same time, so no single flip-flop's output uniquely identifies which state the counter is in — you need a small gate examining at least two bits C. Because Johnson counters change state faster than their outputs can be read D. Because Johnson counters do not actually have distinct, identifiable states

B. Because most Johnson counter states have more than one bit set (or more than one bit clear) at the same time, so no single flip-flop's output uniquely identifies which state the counter is in — you need a small gate examining at least two bits — A ring counter's states are one-hot (exactly one 1 at a time), so each flip-flop's Q output is by itself a unique 'we are in state k' signal. A Johnson counter's states are not one-hot — for example, in a 4-bit Johnson counter, the state 1100 has two 1s and the state 0111 has three — so identifying a specific state requires combinational logic that looks at more than one bit, typically a small 2-input gate per state.

How many flip-flops are needed to build a Johnson counter with exactly 12 states (for example, to drive a 12-phase sequencer), and how does that compare to the number of flip-flops a plain ring counter would need for the same 12 states?

For a Johnson counter, 2n = 12 states means n = 6 flip-flops. A plain ring counter, which has exactly n states for n flip-flops, would need 12 flip-flops to produce 12 states directly. The Johnson counter therefore needs only half as many flip-flops (6 versus 12) to achieve the same 12-state cycle, at the cost of needing small 2-input decode gates per state instead of the ring counter's free, single-wire one-hot decoding.

Use the Johnson counter's 2n-states formula to solve for n, then compare to a ring counter, which needs one flip-flop per state.