Verilog Johnson CounterA Johnson counter is a digital circuit with a series of flip flops connected in a feedback manner. Verilog Johnson counter is a counter that counts 2N states if the number of bits is N. The circuit is a special type of shift register where the last flip flop's complement output is fed back to the first flip flop's input. This is almost similar to the ring counter with a few extra advantages. The Johnson counter's main advantage is that it only needs half the number of flipflops compared to the standard ring counter, and then it's modulo number is halved. So an nstage Johnson counter will circulate a single data bit, giving a sequence of 2n different states and can therefore be considered a mod2n counter. The inverted output Q of the last flipflop is connected back to the input D of the first flipflop. Below is the circuit diagram for a 4bit Johnson counter: This inversion of Q before it is fed back to input D causes the counter to count differently. Instead of counting through a fixed set of patterns just like the normal ring counter such as for a 4bit counter, "0001"(1), "0010"(2), "0100"(4), "1000"(8) and repeat. The Johnson counter counts up and then down as the initial logic "1" passes through it to the right replacing the preceding logic "0". A 4bit Johnson ring counter passes blocks of four logic "0" and then four logic "1" thereby producing an 8bit pattern. As the inverted output Q is connected to the input D, this 8bit pattern continually repeats. For example, "1000", "1100", "1110", "1111", "0111", "0011", "0001", "0000". This is demonstrated in the following table:
As well as counting or rotating data around a continuous loop, ring counters can also be used to detect or recognize various patterns or number values within a set of data. By connecting simple logic gates such as the OR gates to the flipflops' outputs, the circuit can be made to detect a set number or value. Standard 2, 3 or 4stage Johnson Ring Counters can also be used to divide the clock signal frequency by varying their feedback connections, and divideby3 or divideby5 outputs are also available. For example, a 3stage Johnson Ring Counter could be used as a 3phase, 120degree phase shift square wave generator by connecting to the data outputs at A, B and NOTB. The standard 5stage Johnson counter, such as the commonly available CD4017, is generally used as a synchronous decade counter/divider circuit. Other combinations, such as the smaller 2stage circuit, which is also called a Quadrature Oscillator or Generator, can be used to produce four individual outputs that are each 90 degrees outofphase for each other to produce a 4phase timing signal. ExampleTestbench And the output looks like: ncsim> run T=0 out=xxxx T=10 out=0001 T=50 out=0000 T=70 out=1000 T=90 out=1100 T=110 out=1110 T=130 out=1111 T=150 out=0111 T=170 out=0011 T=190 out=0001 T=210 out=0000 T=230 out=1000 T=250 out=1100 T=270 out=1110 T=290 out=1111 T=310 out=0111 Simulation complete via $finish(1) at time 330 NS + 0
Next TopicBidirectional Shift Register
