BitFlow

Johnson Counter

intermediate · sequential · 150 XP

Sign in to write your solution, run it in the simulator and submit it for grading.

Sign in or create a free account →

Problem

Johnson Counter The **Johnson counter** (also called a twisted-ring or switch-tail counter) is a shift register where the **inverted MSB** feeds back to the LSB. A 4-bit Johnson counter has **8 unique states** (2×N), compared to only N states for a ring counter. | Cycle | q[3:0] | |-------|--------| | Reset | 0000 | | 1 | 0001 | | 2 | 0011 | | 3 | 0111 | | 4 | 1111 | | 5 | 1110 | | 6 | 1100 | | 7 | 1000 | | 8 | 0000 | ← back to start **Interface** | Port | Direction | Width | Description | |-----------|-----------|-------|---------------------| | `clk` | input | 1 | Clock | | `rst` | input | 1 | Synchronous reset → 4'b0000 | | `q[3:0]`| output | 4 | Johnson counter state | **Key property:** Adjacent states differ by exactly one bit — like Gray code, but with a different sequence. This makes it glitch-free for state machine applications.

Constraints

  • Reset loads 4'b0000.
  • Each clock: shift right, inverted MSB (q[3]) feeds into q[3].
  • The twisted connection: new bit = ~q[3].

Examples

Input: After reset (q=0000), clk↑

Output: q=0001 (~q[3]=1 enters at MSB... wait — shift right)

Common questions

What does the Johnson Counter problem ask you to build?
Johnson Counter The **Johnson counter** (also called a twisted-ring or switch-tail counter) is a shift register where the **inverted MSB** feeds back to the LSB. A 4-bit Johnson counter has **8 unique states** (2×N), compared to only N states for a ring counter.
What constraints does Johnson Counter have?
Reset loads 4'b0000.; Each clock: shift right, inverted MSB (q[3]) feeds into q[3].; The twisted connection: new bit = ~q[3].
What is an example input and output for Johnson Counter?
Input After reset (q=0000), clk↑ gives output q=0001 (~q[3]=1 enters at MSB... wait — shift right).
Which Verilog concepts does Johnson Counter practise?
sequential, counter, johnson, twisted-ring, gray-code-like.