Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 8116
Скачиваний: 6
9.9 • Shift Register Counters |
439 |
Figure 9.77 shows a 4-bit ring counter made from D flip-flops. This circuit could also be constructed from SR or JK flip-flops, as can any serial shift register.
A ring counter circulates the same data in a continuous loop. This assumes that the
FIGURE 9.77
4-bit Ring Counter
D |
Q |
Q3 |
D |
Q |
Q2 |
D |
Q |
Q1 |
D |
Q |
Q0 |
|||||||
Q |
Q |
Q |
Q |
|||||||||||||||
Clock
data have somehow been placed into the circuit upon initialization, usually by synchronous or asynchronous preset and clear inputs, which are not shown.
Figure 9.78 shows the circulation of a logic 1 through a 4-bit ring counter. If we assume that the circuit is initialized to the state Q3Q2Q1Q0 1000, it is easy to see that the 1 is shifted one place right with each clock pulse. The feedback connection from Q0 to D3 ensures that the input of flip-flop 3 will be filled by the contents of Q0, thus recirculating the initial data. The final transition in the sequence shows the 1 recirculated to Q3.
A ring counter is not restricted to circulating a logic 1. We can program the counter to circulate any data pattern we happen to find convenient.
Figure 9.79 shows a ring counter circulating a 0 by starting with an initial state of Q3Q2Q1Q0 0111. The circuit is the same as before; only the initial state has changed. Figure 9.80 shows the timing diagrams for the circuit in Figures 9.78 and 9.79.
Ring Counter Modulus and Decoding
The maximum modulus of a ring counter is the maximum number of unique states in its count sequence. In Figures 9.78 and 9.79, the ring counters each had a maximum modulus of 4. We say that 4 is the maximum modulus of the ring counters shown, since we can change the modulus of a ring counter by loading different data at initialization.
For example, if we load a 4-bit ring counter with the data Q3Q2Q1Q0 1000, the following unique states are possible: 1000, 0100, 0010, and 0001. If we load the same circuit with the data Q3Q2Q1Q0 1010, there are only two unique states: 1010 and 0101. Depending on which data are loaded, the modulus is 4 or 2.
Most input data in this circuit will yield a modulus of 4. Try a few combinations.
N O T E
The maximum modulus of a ring counter is the same as the number of bits in its output.
A ring counter requires more flip-flops than a binary counter to produce the same number of unique states. Specifically, for n flip-flops, a binary counter has 2n unique states and a ring counter has n.
This is offset by the fact that a ring counter requires no decoding. A binary counter used to sequence eight events requires three flip-flops andeight 3-input decoding gates. To perform the same task, a ring counter requires eight flip-flops and no decoding gates.
As the number of output states of an event sequencer increases, the complexity of the decoder for the binary counter also increases. A circuit requiring 16 output states can be implemented with a 4-bit binary counter and sixteen 4-input decoding gates. If you need 18 output states, you must have a 5-bit counter (24 18 25) and eighteen 5-input decoding gates.
The only required modification to the ring counter is one more flip-flop for each addi-
440 C H A P T E R 9 • Counters and Shift Registers
1 |
0 |
0 |
0 |
|||||||||||||||||||||
Q3 |
Q2 |
Q1 |
Q0 |
|||||||||||||||||||||
D |
Q |
D |
Q |
D |
Q |
D |
Q |
|||||||||||||||||
Q |
Q |
Q |
Q |
|||||||||||||||||||||
Clock
0 |
1 |
0 |
0 |
|||||||||||||||||||||
Q3 |
Q2 |
Q1 |
Q0 |
|||||||||||||||||||||
D |
Q |
D |
Q |
D |
Q |
D |
Q |
|||||||||||||||||
Q |
Q |
Q |
Q |
|||||||||||||||||||||
Clock
0 |
0 |
1 |
0 |
|||||||||||||||||||||
Q3 |
Q2 |
Q1 |
Q0 |
|||||||||||||||||||||
D |
Q |
D |
Q |
D |
Q |
D |
Q |
|||||||||||||||||
Q |
Q |
Q |
Q |
|||||||||||||||||||||
Clock
0 |
0 |
0 |
1 |
|||||||||||||||||||||
Q3 |
Q2 |
Q1 |
Q0 |
|||||||||||||||||||||
D |
Q |
D |
Q |
D |
Q |
D |
Q |
|||||||||||||||||
Q |
Q |
Q |
Q |
|||||||||||||||||||||
Clock
1 |
0 |
0 |
0 |
|||||||||||||||||||||
Q3 |
Q2 |
Q1 |
Q0 |
|||||||||||||||||||||
D |
Q |
D |
Q |
D |
Q |
D |
Q |
|||||||||||||||||
Q |
Q |
Q |
Q |
|||||||||||||||||||||
Clock
FIGURE 9.78
Circulating a 1 in a Ring Counter
tional state. A 16-state ring counter needs 16 flip-flops and an 18-state ring counter must have 18 flip-flops. No decoding is required for either circuit.
Johnson Counters
Figure 9.81 shows a 4-bit Johnson counter constructed from D flip-flops. It is the same as a ring counter except for the inversion in the feedback loop where Q0 is connected to D3. The circuit output is taken from flip-flop outputs Q3 through Q0. Since the feedback introduces a “twist” into the recirculating data, a Johnson counter is also called a “twisted ring