3.4.9Sequential Circuits

Ring and Johnson counters

1,889 words9 min readdifficulty · medium

Two special shift-register counters built by feeding the output of a shift register back to its input. They trade off "wasted" states for glitch-free, self-decoding counting.

[!intuition] The core picture

A shift register is just a chain of flip-flops passing a bit along like a bucket-brigade of people passing a ball. A counter normally needs an adder or complex logic. But what if we just take a shift register and loop its last output back into its first input? The pattern of 1s and 0s circulates forever — and that circulating pattern IS the count.

  • Ring counter = feed QlastQ_{last} straight back to DfirstD_{first}. One "hot" bit circulates.
  • Johnson counter (a.k.a. twisted-ring / switch-tail) = feed the complement Qlast\overline{Q_{last}} back. This twist doubles the number of states.

WHY care? No decoding logic is needed to know the state — you read it directly. And each transition changes only one flip-flop at a time, so there are no decoding glitches (unlike a binary counter where multiple bits flip at once).

[!definition] Definitions

  • Ring counter: an nn-flip-flop shift register with Qn1Q_{n-1} (or Q\overline{Q}) wired to D0D_0; exactly one flip-flop is high, and the 1 rotates. Has ==nn== valid states.
  • Johnson counter: same shift register but the inverted last output feeds the first input; produces ==2n2n== valid states.
  • A valid/used state is one the counter actually visits in its normal cycle; all others are unused (lock-out) states.

[!formula] Number of states — derived, not memorised

WHY does a ring counter give nn states? Load a single 1 into nn cells. Each clock shifts it one position. After nn shifts the 1 has visited every cell and returned home. So the cycle length = number of cells: Nring=n\boxed{N_{\text{ring}} = n}

WHY does Johnson give 2n2n? Trace the fill/empty process. Start all 0. Feedback is Qlast=1\overline{Q_{last}}=1, so a 1 enters. Each clock the 1s fill from the left until the register is all 1s — that's nn steps. Now Qlast=0\overline{Q_{last}}=0, so 0s enter and empty the register from the left — another nn steps to reach all 0s again. fill n steps+empty n steps=NJohnson=2n\text{fill } n \text{ steps} + \text{empty } n \text{ steps} = \boxed{N_{\text{Johnson}} = 2n}

Efficiency (the 80/20 fact). With nn flip-flops you could count to 2n2^n. So: state utilisation=N2n={n2nring2n2nJohnson\text{state utilisation}=\frac{N}{2^n}=\begin{cases}\dfrac{n}{2^n} & \text{ring}\\[2mm]\dfrac{2n}{2^n} & \text{Johnson}\end{cases} Johnson is twice as efficient as ring but both are hugely wasteful vs a binary counter. You pay silicon for simplicity + no glitches.

Figure — Ring and Johnson counters

[!example] Worked: 4-bit Ring counter (n=4n=4)

Wiring: D0=Q3,  D1=Q0,  D2=Q1,  D3=Q2D_0=Q_3,\; D_1=Q_0,\; D_2=Q_1,\; D_3=Q_2. Preset with 10001000.

Clock Q3Q2Q1Q0Q_3Q_2Q_1Q_0
init 1000
1 0100
2 0010
3 0001
4 1000 (repeat)
  • Why start at 1000? The ring counter cannot generate its own starting 1 — feedback just copies. You must inject one 1 (preset/clear). Why this step? Because D0=Q3D_0=Q_3: if all cells were 0, D0=0D_0=0 forever → stuck at 0000.
  • Why only 4 states? One 1 in 4 positions → 4 arrangements. Why this step? The number of hot positions equals the register length.

[!example] Worked: 4-bit Johnson counter (n=48n=4 \Rightarrow 8 states)

Wiring identical except D0=Q3D_0=\overline{Q_3}. Start at 00000000.

Clock Q3Q2Q1Q0Q_3Q_2Q_1Q_0 Q3D0\overline{Q_3}\to D_0
0 0000 1
1 0001 1
2 0011 1
3 0111 1
4 1111 0
5 1110 0
6 1100 0
7 1000 0
8 0000 (repeat)
  • Why does it fill then empty? Once Q3=1Q_3=1, feedback Q3=0\overline{Q_3}=0 starts injecting 0s. Why this step? The twist (complement) is what flips the incoming bit and doubles the cycle.
  • Decoding a state uniquely with a 2-input AND. Notice each state has exactly one "0→1 boundary" or "1→0 boundary". E.g. state 00110011 is the only one with Q1=1,Q2=0Q_1=1,Q_2=0. So decode it with Q1Q2Q_1\overline{Q_2}. Why this step? Adjacent-bit patterns are unique per Johnson state → each output needs just a 2-input gate, cheap and glitch-free.

[!example] Self-starting fix (mini-derivation)

Problem: what if a Johnson counter powers up in an unused state like 01010101? Trace it: 0101Q3=10101\to \overline{Q_3}=1, shift → 101001011010 \to 0101… it oscillates in a dead loop, never joining the main cycle.

  • Fix: modify the feedback so D0=Q3+Q1D_0 = \overline{Q_3\,+\,\overline{Q_1}} style correction (a common trick: D0=Q3(Q0+Q2)D_0=\overline{Q_3}\cdot(Q_0+\overline{Q_2}) variants) forcing illegal states back into the valid cycle. Why this step? A self-correcting counter must have every unused state eventually map into a used one, guaranteeing recovery after noise/power-up.

[!mistake] Common mistakes (steel-manned)

"A ring counter with nn flip-flops counts to 2n2^n." Why it feels right: every other counter you learned (binary ripple/sync) does 2n2^n. The fix: ring counters encode the count as position of a single 1, giving only nn states. The whole point is trading count-range for zero decode logic.

"Ring and Johnson are the same, one just has an inverter — no big deal." Why it feels right: the circuits differ by one wire. The fix: that inverter twists the ring and doubles states (n2nn\to2n) and enables 2-gate self-decoding. One wire changes the fundamental state count.

"They start counting by themselves." Why it feels right: other counters just power on and go. The fix: both need initialisation (preset a 1 into a ring; clear a Johnson) or must be made self-starting, else they can lock into dead loops.

"Johnson state 11111111 then 00000000 — did we skip?" Why it feels right: looks like a jump. The fix: at 11111111 feedback is Q3=0\overline{Q_3}=0, so a 0 shifts in giving 11101110, not 00000000. The all-0 state comes only after all 1s are shifted out.

[!recall]- Explain it to a 12-year-old

Imagine a line of 4 kids passing a single glowing ball to the right; the last kid throws it back to the first. Wherever the ball is = the "count" — that's a ring counter, 4 possible spots. Now the twist: the last kid, instead of passing the same ball, passes the opposite — if he has a lit ball he passes a dark one, and vice-versa. Now the whole line lights up one-by-one, then goes dark one-by-one. Twice as many patterns from the same kids! That's a Johnson counter. You never need a scoreboard — just look at the lights.

[!mnemonic]

  • Ring = one 1 Runs in a Ringnn states.
  • Johnson = Just add iNverter → doubles → 2n2n (J for "twisted / double").
  • "Ring: n. Johnson: 2n. Binary: 2ⁿ." — increasing count, increasing decode-cost.

Flashcards

How many states does an nn-bit ring counter have?
nn
How many states does an nn-bit Johnson counter have?
2n2n
What single hardware change turns a ring counter into a Johnson counter?
Feed the complement Qlast\overline{Q_{last}} (instead of QlastQ_{last}) back to D0D_0 — an inverter in the feedback.
Why do ring/Johnson counters need no decoding logic (no glitches)?
Only one flip-flop changes per clock, and each state has a unique bit pattern; Johnson states decode with a single 2-input gate.
Why must a ring counter be preset with exactly one 1?
Feedback only copies existing bits; if all are 0 it stays 0000 forever — it can't create the circulating 1.
State utilisation of a Johnson counter vs binary counter?
2n/2n2n/2^n — far below 1; wasteful in states but glitch-free and simple.
What is a "lock-out"/dead loop and how is it fixed?
An unused state cycle the counter can enter and never leave; fixed by modifying feedback to make it self-starting/self-correcting.
In a 4-bit Johnson counter, what follows state 11111111?
11101110 (feedback Q3=0\overline{Q_3}=0 shifts a 0 in).
Decode gate for Johnson state 00110011 (4-bit)?
Q1Q2Q_1\overline{Q_2} — a single 2-input AND, since that adjacent pattern is unique.

Connections

  • Shift Registers — the base building block both counters are made from.
  • Synchronous Counters — compare: full 2n2^n range but multi-bit transitions cause glitches.
  • Flip-Flops (D type) — the storage element used here.
  • Glitches and Decoding Hazards — why single-bit-change counters matter.
  • Self-starting Sequential Circuits — lock-out and correction feedback.
  • Frequency Division — a ring counter divides clock by nn, Johnson by 2n2n.

Concept Map

loop output back

straight Qlast

inverted Qlast

circulates

twist

cycle length

fill plus empty

shifts one place

avoids

read directly

needs

Shift register chain

Feedback last to first

Ring counter

Johnson counter

One hot bit rotates

Complement fed back

N states = n

N states = 2n

One FF changes per clock

No decoding glitches

Self-decoding no logic

Must inject a 1 preset

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek shift register basically flip-flops ki ek chain hoti hai jo bit ko ek se doosre cell tak pass karti hai — jaise line me log ball aage badha rahe ho. Ab agar hum last output ko wapas first input me joड़ de, to woh pattern circulate karta rehta hai. Yahi ghoomta hua pattern hi hamara count hai. Isko bolte hain Ring counter: ek hi "1" ghoomta rehta hai, aur nn flip-flops ho to sirf nn states milte hain.

Johnson counter me bas ek chhota sa twist hai — last output ka ulta (complement, NOT gate se) wapas bhejo. Yeh twist state count ko double kar deta hai: 2n2n states. Trace karo: register pehle 1s se bharta hai (0000 → 0001 → 0011 → ... → 1111), phir 0s se khaali hota hai (1111 → 1110 → ... → 0000). Ek inverter ki wajah se hi yeh magic hota hai.

Inka faayda kya hai? Har clock pe sirf ek flip-flop badalta hai, isliye koi decoding glitch nahi aata, aur state ko decode karne ke liye bahut simple gate chahiye (Johnson me sirf 2-input AND). Nuksaan? Bahut saare states waste hote hain — binary counter 2n2^n tak ginta hai, ring sirf nn tak. To yeh silicon "waste" karke simplicity aur clean output khareedte hain.

Ek important baat exam ke liye: dono counters khud se start nahi hote. Ring me ek "1" preset karna padta hai (warna 0000 pe atak jaayega), aur Johnson agar galat state (jaise 0101) me power-on ho jaaye to dead-loop me phans sakta hai — isliye self-starting feedback banate hain jo galat states ko wapas valid cycle me le aaye.

Go deeper — visual, from zero

Test yourself — Sequential Circuits

Connections