ForHosting KIT · Engineering & construction

Johnson counter states calculator

Four flip-flops wired as a Johnson counter give 8 unique states, twice the number of stages. Enter the stage count to get that figure, the plain ring count and, up to 53 stages, the binary count for comparison. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Stages
4
You get
Unique states
8
Ring counter states
4
Modulus
8
Binary counter states
16

A Johnson counter, also called a twisted ring counter or Moebius counter, is a shift-register style sequential circuit in which the inverted output of the last flip-flop feeds the first stage. Unlike a free-running binary counter that can visit 2 to the power of n codes with n flip-flops, or a plain ring counter that cycles through only n one-hot patterns, the Johnson topology systematically walks through exactly 2n distinct states before repeating. Digital designers, students, and FPGA coders need that 2n figure instantly when sizing a modulus, choosing a decoder, or comparing counter styles on a data sheet. This calculator accepts the number of flip-flop stages and returns the unique state count with the textbook formula, plus a side-by-side plain ring count and, when exact, the binary counter size for the same stage count.

What a Johnson twisted ring counter is and why it has 2n states

Start with n D flip-flops wired as a shift register: on each clock edge the bit stored in stage i moves into stage i plus one. In a plain ring counter the non-inverted output of the last stage returns to the first stage input, so a single circulating one (or zero) produces a cycle of length n—the classic one-hot or one-cold sequence. A Johnson counter twists that feedback: the complement of the last stage drives the first.

That inversion doubles the path through the state graph. From a cleared reset the machine steps through n rising patterns that fill ones from one end, then n falling patterns that clear them, for a closed orbit of length 2n with no invalid intermediate codes when started from a legal seed. Every legal code is a contiguous block of ones followed by zeros or zeros followed by ones when viewed as a circular shift of the twisted chain—exactly 2n such strings exist for width n.

That is why the unique state count of a Johnson counter is always two times the stage count, independent of clock rate or technology node. Designers use this modulus of 2n to build divide-by-2n clocks, decade or multi-phase generators with n equals five (ten states), and low-logic-cost sequence controllers that decode with a handful of two-input gates rather than a full binary decoder tree.

Classroom and lab checks

Students enter flip-flop stage count n and verify that a Johnson twisted ring counter has exactly 2n unique states before comparing with ring (n) and binary (2^n) counters.

Exam and LMS auto-grading

Mark digital-logic questions on Johnson counter modulus with a deterministic 2n oracle instead of a full flip-flop simulation.

FPGA and sequence design sizing

Pick n so that 2n matches a required divide ratio or multiphase step count before writing HDL for the shift chain and decoder.

How many unique states does a Johnson counter have?

A Johnson (twisted ring) counter with n flip-flop stages has exactly 2n unique states.

How is a Johnson counter different from a ring counter?

A plain ring counter feeds the last stage non-inverted and has n unique states. A Johnson counter inverts that feedback and has 2n unique states.

How many flip-flops do I need for a divide-by-10 Johnson counter?

Five. A Johnson counter with 5 stages walks through 10 states before repeating, the common decade arrangement used in decade counters and multiphase waveform generators.

What sequence does a Johnson counter step through?

From a cleared reset it fills with ones from one end, one stage per clock, then clears them again the same way. That gives n rising patterns and n falling ones, and every legal code is a single block of ones next to a block of zeros.

Why is a Johnson counter easy to decode?

Because its states follow that simple block pattern, each one can be picked out with a handful of two-input gates instead of a full binary decoder tree. That keeps logic cost low in sequence controllers and divide-by-2n clocks.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/elec/johnson-counter

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/elec/johnson-counter \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"stages":4}'
{
  "stages": 4
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "elec.johnson_counter",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Input contract, response fields, and validation rules

Example: stages equals four yields eight unique Johnson states, four ring states, and sixteen binary states. Example: stages equals five yields ten unique states—the common decade Johnson arrangement used in decade counters and multiphase waveform generators. POST a JSON body with one required field: stages, a positive integer n from one through ten thousand. Numeric strings are accepted; aliases n, flip_flops, flipflops, stages_n, ff, and count map to the same parameter so SDK clients and form widgets stay flexible. Missing stages, non-finite values, non-integers, zero, negatives, and values above the ceiling all fail with invalid_input and are not billed. On success the body echoes stages, reports unique_states as two times stages, ring_counter_states as stages for the non-twisted comparison, and modulus equal to unique_states so frequency-divider wording is one field away. The formula string restates unique_states equals two times stages for display next to the number. When stages is at most fifty-three, binary_counter_states is also returned as two to the power of stages so you can contrast linear Johnson capacity with exponential binary capacity using exact IEEE integers; for larger n that comparison field is omitted rather than rounded or null, matching the platform rule that optional outputs disappear instead of carrying null.

Where a Johnson counter states API earns its keep

Lecture notes and lab manuals ask for the number of unique states of a four-bit or five-bit Johnson counter; tutors need a deterministic oracle that always answers 2n instead of conflating ring, Johnson, and binary figures. FPGA and ASIC architects sketch modulus choices—eight, ten, twelve, sixteen—before committing LUTs or standard cells, and a one-field calculator is faster than spinning up a HDL testbench for a counting-theory check. Failed validation does not consume balance. Exam generators and LMS plugins call a tiny parse endpoint to mark free-response items without embedding circuit simulators. Keep stages small and integer, pin unique_states in tests, and you get reproducible answers for homework, datasheet tables, and edge workers without standing up a sequential-logic simulator of your own.

What input does the calculator require?

A positive integer stages from 1 to 10000 (aliases: n, flip_flops, flipflops, stages_n, ff, count). Non-integers, zero, negatives, and missing values return invalid_input.

Why is binary_counter_states sometimes missing?

It is included only when stages ≤ 53 so 2^stages is an exact safe integer. For larger n the optional field is omitted rather than approximated or set to null.

What does the Johnson counter states calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →