Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 8135
Скачиваний: 6
10.3 • State Machines with Control Inputs |
471 |
The transition from start is conditional, so the case for start contains an IF statement that defines the possible state transitions and their associated output states. The transition from continue is unconditional, so no IF statement is needed in the corresponding case.
Figure 10.14 shows the simulation for the VHDL design entity, state_x1.vhd. The values of the state variable, sequence, are also shown in the simulation. This gives us a ready indication of the machine’s state (start or continue).
FIGURE 10.14
Simulation of the State Machine in VHDL Entity state_x1
The design of the state machine is such that if the input in1 is held LOW beyond the end of one pulse cycle, the cycle will repeat, as shown in the simulation of Figure 10.15.
FIGURE 10.15
Simulation of VHDL State Machine Showing a Repeated Output Cycle
EXAMPLE 10.1 |
A state machine called a single-pulse generator operates as follows: |
|
1. |
The circuit has two states: seek and find, an input called sync and an output called |
|
pulse. |
||
2. |
The state machine resets to the state seek. If sync 1, the machine remains in seek and |
|
Application |
||
the output, pulse, remains LOW. |
||
3. |
When sync 0, the machine makes a transition to find. In this transition, pulse goes |
|
HIGH. |
||
4. |
When the machine is in state find and sync 0, the machine remains in find and pulse |
|
goes LOW. |
||
5. |
When the machine is in find and sync 1, the machine goes back to seek and pulse re- |
|
mains LOW. |
||
Use classical state machine design techniques to design the circuit for the single-pulse |
||
generator, using D flip-flops for the state logic. Use MAX PLUS II to draw the state
10.3 • State Machines with Control Inputs |
473 |
FIGURE 10.18
Example 10.1
Simulation of a Single-pulse Generator (from GDF)
Vcc |
Single-pulse |
|
generator |
||
Debouncer |
SYNC |
|
N.O. |
CLK |
PULSE |
FIGURE 10.19
Example 10.1
Single-pulse Generator Used with a Debounced Pushbutton
EXAMPLE 10.2 |
The state machine of Example 10.1 is vulnerable to asynchronous input changes. How do |
|||||||||||||||||
we know this from the circuit schematic and from the simulation waveform? Modify the |
||||||||||||||||||
circuit to eliminate the asynchronous behavior and show the effect of the change on a sim- |
||||||||||||||||||
ulation of the design. How does this change improve the design? |
||||||||||||||||||
Solution The output, pulse, in the state machine of Figure 10.17 is derived from the |
||||||||||||||||||
state flip-flop and the combinational logic of the circuit. The output can be affected by a |
||||||||||||||||||
change that is purely combinational, thus making the output asynchronous. This is demon- |
||||||||||||||||||
strated on the first pulse of the simulation in Figure 10.18, where pulse momentarily goes |
||||||||||||||||||
HIGH between clock edges. Since no clock edge was present when either the input, sync, |
||||||||||||||||||
changed or when pulse changed, the output pulse must be due entirely to changes in the |
||||||||||||||||||
combinational part of the circuit. |
||||||||||||||||||
The circuit output can be synchronized to the clock by adding an output flip-flop, as in |
||||||||||||||||||
Figure 10.20. A simulation of this circuit is shown in Figure 10.21. With the synchronized |
||||||||||||||||||
output, the output pulse is always the same width: one clock period. This gives a more pre- |
||||||||||||||||||
dictable operation of the circuit. |
||||||||||||||||||
DFF |
||||||||||||||||||
DFF |
||||||||||||||||||
NOT |
NOT |
AND2 |
||||||||||||||||
PRN |
PRN |
OUTPUT |
||||||||||||||||
SYNC |
INPUT |
D |
Q |
PULSE |
||||||||||||||
D |
Q |
CLRN |
||||||||||||||||
CLRN |
||||||||||||||||||
INPUT
CLK
FIGURE 10.20
Example 10.2
Single-pulse Generator with Synchronous Output