Digital design with CPLD applications and VHDL (R. Dueck, 2000)
.pdf300 C H A P T E R 7 • Introduction to Sequential Logic
Figure 7.40 shows a circuit that acts as a simplified positive edge detector. Edge detection depends on the fact that a gate output does not switch immediately when its input switches. There is a delay of about 3 to 10 ns from input change to output change, called propagation delay.
FIGURE 7.40
Positive Edge Detector
When input x, shown in the timing diagram of Figure 7.40, goes from LOW to HIGH, the inverter output, x, goes from HIGH to LOW after a short delay. This delay causes both x and x to be HIGH for a short time, producing a high-going pulse at the circuit output immediately following the positive edge at x.
When x returns to LOW, x goes HIGH after a delay. However, there is no time in this sequence when both AND inputs are HIGH. Therefore, the circuit output stays LOW after the negative edge of the input waveform.
Figure 7.41 shows how the D flip-flop circuit operates. When D 0 and the edge detector senses a positive edge at the CLK input, the output of the lower NAND gate steers a low-going pulse to the RESET input of the latch, thus storing a 0 at Q. When D 1, the upper NAND gate is enabled. The edge detector sends a high-going pulse to the upper steering gate, which transmits a low-going SET pulse to the output latch. This action stores a 1 at Q.
FIGURE 7.41
Operation of a D Flip-Flop
|
|
|
7.4 • |
Edge-Triggered D Flip-Flops |
301 |
|||
|
|
|
|
|||||
EXAMPLE 7.6 |
Figure 7.42 shows a MAX PLUS II Graphic Design File with a D latch and a D flip- |
|||||||
|
flop connected to the same data input and clock. Create a MAX PLUS II simulation that |
|||||||
|
illustrates the difference between the latch (level-sensitive enable) and the flip-flop (edge- |
|||||||
|
triggered clock). |
|
|
|
|
|
|
|
|
|
|
LATCH |
|
|
|
|
|
|
|
INPUT |
|
|
|
|
|
|
|
D |
|
D |
|
OUTPUT |
Q_latch |
||
|
INPUT |
|
Q |
|||||
|
CLK |
|
ENA |
|
||||
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
DFF
PRN |
|
|
|
D |
OUTPUT |
Q_flip_flop |
|
Q |
|||
|
|||
CLRN |
|
|
FIGURE 7.42
D Latch and D Flip-Flop
SOLUTION The simulation, shown in Figure 7.43, has a 200 ns grid. Several points on the waveform indicate the similarities and differences between the latch and flip-flop operation.
FIGURE 7.43
Simulation showing the Difference between D Latch and D Flip Flop
latch_ff.gdf latch_ff.scf
2.D goes LOW at 2 s. Both Q outputs go LOW at 2.8 s since the positive edge of the CLK and its HIGH level occur at the same time.
3.The D input goes HIGH at 4.4 s, in the middle of a CLK pulse. Since the CLK line is HIGH, Q_ latch changes immediately. Q_ flip_ flop does not change until the next positive edge, at 6 s.
4.D goes LOW at 7.8 s. Q_latch also changes at this time, since CLK is HIGH. Q_ flip_ flop changes on the next positive edge, at 9.2 s.
302 C H A P T E R 7 • Introduction to Sequential Logic
|
Note that the latch output is in an unknown state until the first CLK pulse, whereas the |
|
flip-flop output is LOW, even before the first CLK pulse. This is because Altera CPLDs |
|
have power-on reset circuitry that ensures that flip-flop outputs in a CPLD are LOW im- |
|
mediately after power is applied to the device. The MAX PLUS II simulator accounts for |
|
this condition. |
|
|
EXAMPLE 7.7 |
Two positive edge-triggered D flip-flops are connected as shown in Figure 7.44a. Inputs D0 |
|
and CLK are shown in the timing diagram. Complete the timing diagram by drawing the |
|
waveforms for Q0 and Q1, assuming that both flip-flops are initially reset. |
FIGURE 7.44 |
|
Example 7.7 |
|
Circuit and Timing Diagram |
|
SOLUTION Figure 7.44b shows the output waveforms. Q0 follows D0 at each point where the clock input has a positive edge. One result of this is that the HIGH pulse on D0 between clock pulses 5 and 6 is ignored, since D0 0 on positive edges 5 and 6.
Since D1 Q0 and Q1 follows D1, the waveform at Q1 is the same as at Q0, but delayed by one clock cycle. If Q0 changes due to CLK, we assume that the value of D1 is the same as Q0 just before the clock pulse. This is because delays within the circuitry of the flip-flops ensure that their outputs will not change for several nanoseconds after an applied clock pulse. Therefore, the level at D1 remains constant long enough for it to be clocked into the second flip-flop.
The data entering the circuit at D0 are moved, or shifted, from one flip-flop to the next. This type of data movement, called “serial shifting,” is frequently used in data communi-
cation and digital arithmetic circuits. |
|
|
SECTION 7.4 REVIEW PROBLEM
7.4Which part of a D flip-flop accounts for the difference in operation between a D flipflop and a D latch? How does it work?
304 C H A P T E R 7 • Introduction to Sequential Logic
|
FIGURE 7.47 |
|
Toggle Action of a JK Flip-Flop |
|
|
EXAMPLE 7.8 |
The J, K, and CLK inputs of a negative edge-triggered JK flip-flop are as shown in the tim- |
|
ing diagram in Figure 7.48. Complete the timing diagram by drawing the waveforms for Q |
|
and Q. Indicate which function (no change, set, reset, or toggle) is performed at each clock |
|
pulse. The flip-flop is initially reset. |
|
FIGURE 7.48 |
|
Example 7.8 |
|
Timing Diagram (Negative-Edge-Triggered JK Flip-Flop) |
|
SOLUTION The completed timing diagram is shown in Figure 7.48. The outputs change |
|
only on the negative edges of the CLK waveform. Note that the same output sometimes re- |
|
sults from different inputs. For example, the function at clock pulse 4 is reset and the func- |
|
tion at pulses 5 and 6 is no change, but the Q waveform is LOW in each case. |
|
|
EXAMPLE 7.9 |
The toggle function of a JK flip-flop is often used to generate a desired output sequence |
|
from a series of flip-flops. The circuit shown in Figure 7.49 is configured so that all flip- |
|
flops are permanently in toggle mode. |
|
Assume that all flip-flops are initially reset. Draw a timing diagram showing the CLK, |
|
Q0, Q1, and Q2 waveforms when eight clock pulses are applied. Make a table showing each |
7.5 • Edge-Triggered JK Flip-Flops |
307 |
Figure 7.53 shows the circuit of a 3-bit synchronous counter. Unlike the circuit in Figure 7.49, the flip-flops in this circuit are clocked from a common source. Therefore, flip-flop delays do not add up through the circuit, and all the outputs change at the same time. Figure 7.54 shows a simulation of the circuit of Figure 7.53. Note that the outputs progress in a binary sequence, and there are no intermediate states.
FIGURE 7.54
Simulation of a 3-bit Synchronous Counter
The circuit works as follows:
1.Flip-flop 0 is configured for toggle mode (J0K0 11). Since the flip-flops in Figure 7.53 are positive edge-triggered, Q0 toggles on each positive clock edge.
2.Q0 is connected to inputs J1 and K1. Since these inputs are tied together, only two states are possible: no change (JK 00) or toggle (JK 11). If Q0 1, Q1 toggles. Otherwise, it does not change. This results in a Q1 waveform that toggles at half the rate of Q0.
3.J2 and K2 are both tied to the output of an AND gate. The AND gate output is HIGH if both Q1 and Q0 are HIGH. This makes Q2 toggle, since J2K2 11. In all other cases, there is no change on Q2. The result of this is that Q2 toggles every fourth clock pulse, the only times when Q1 and Q0 are both HIGH.
Asynchronous Inputs (Preset and Clear)
K E Y T E R M S
Synchronous inputs The inputs of a flip-flop that do not affect the flip-flop’s Q outputs unless a clock pulse is applied. Examples include D, J, and K inputs.
Asynchronous inputs The inputs of a flip-flop that change the flip-flop’s Q outputs immediately, without waiting for a pulse at the CLK input. Examples include preset and clear inputs.
Preset An asynchronous set function.
Clear An asynchronous reset function.
The D, J, and K inputs of the flip-flops examined so far are called synchronous inputs. This is because any effect they have on the flip-flop outputs is synchronized to the CLK input.
Another class of input is also provided on many flip-flops. These inputs, called asynchronous inputs, do not need to wait for a clock pulse to make a change at the output. The two functions usually provided are preset, an asynchronous set function, and clear, an
asynchronous reset function. These functions are generally active LOW, and are abbreviated PRE and CLR.
Figure 7.55 shows a modification to the JK flip-flop of Figure 7.46. The PRE and CLR inputs have direct access to the latch gates of the flip-flop and thus are not affected by the
308 C H A P T E R 7 • Introduction to Sequential Logic
FIGURE 7.55
PRE and CLR Inputs
|
CLK input. They act exactly the same as the SET and RESET inputs of an SR latch and will |
|
override any synchronous input functions currently active. |
|
|
EXAMPLE 7.10 |
The waveforms for the CLK, J, K, PRE, and CLR inputs of a negative edge-triggered JK |
|
flip-flop are shown in the timing diagram of Figure 7.56. Complete the diagram by draw- |
|
ing the waveform for output Q. |
FIGURE 7.56
Example 7.10
Waveforms
SOLUTION The Q waveform is shown in Figure 7.56. The asynchronous inputs cause an immediate change in Q, whereas the synchronous inputs must wait for the next negative clock edge. If asynchronous and synchronous inputs are simultaneously active, the asynchronous inputs have priority. This occurs in two places: pulse 3 (K, PRE) and pulse 10
(J, CLR).
The diagram shows the synchronous functions (no change, reset, set, and toggle) at each clock pulse and the asynchronous functions (preset and clear) at the corresponding transi-
tion points.
The function table of a negative edge-triggered JK flip-flop with preset and clear functions is shown in Table 7.9.
|
|
|
7.5 |
• |
Edge-Triggered JK Flip-Flops |
309 |
|||||||
Table 7.9 Function Table of a Negative Edge-Triggered JK Flip-Flop with Preset and Clear |
|
||||||||||||
Functions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
PRE CLR |
CLK |
J |
K |
|
Qt 1 |
Qt 1 |
|
Function |
|||
Synchronous Functions |
1 |
1 |
|
↓ |
0 |
0 |
|
Qt |
Qt |
|
No change |
||
|
|
1 |
1 |
|
↓ |
0 |
1 |
|
0 |
1 |
|
Reset |
|
|
|
1 |
1 |
|
↓ |
1 |
0 |
|
1 |
0 |
|
Set |
|
|
|
1 |
1 |
|
↓ |
1 |
1 |
|
Qt |
Qt |
|
Toggle |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Asynchronous Functions |
0 |
1 |
|
X |
X |
X |
|
1 |
0 |
|
Preset |
|
|
|
|
1 |
0 |
|
X |
X |
X |
|
0 |
1 |
|
Clear |
|
|
|
0 |
0 |
|
X |
X |
X |
|
1 |
1 |
|
Forbidden |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
1 |
|
0 |
X |
X |
|
Qt |
Qt |
|
Inhibited |
|
|
|
1 |
1 |
|
1 |
X |
X |
|
Qt |
Qt |
|
Inhibited |
|
|
|
1 |
1 |
|
↑ |
X |
X |
|
Qt |
Qt |
|
Inhibited |
|
|
|
|
|
|
|||||||||
X Don’t care |
↓ HIGH-to-LOW transition |
|
|
|
|
|
|
|
|
||||
Qt Present state of Q |
↑ LOW-to-HIGH transition |
|
|
|
|
|
|
|
|
||||
Qt 1 Next state of Q |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
N O T E |
|
|
|
|
|
|
|
If preset and clear functions are not used, they should be disabled by connecting |
|
|||
|
|
|
them to logic HIGH (for active-LOW inputs). This prevents them from being acti- |
|
|||
|
|
|
vated inadvertently by circuit noise. The synchronous functions of some flip-flops |
|
|||
|
|
|
will not operate properly unless PRE and CLR are HIGH. In MAX PLUS II, the |
|
|||
|
|
|
asynchronous inputs of all flip-flop primitives are set to a default level of HIGH. |
|
|||
|
|
Using Asynchronous Reset in a Synchronous Circuit |
|
|
|||
|
|
|
K E Y T E R M |
|
|
|
|
|
|
|
Master Reset An asynchronous reset input used to set a sequential circuit to a |
|
|||
|
|
|
known initial state. |
|
|
|
|
|
|
|
Figure 7.57 shows an application of asynchronous clear inputs in a 3-bit synchronous |
||||
|
|
counter. An input called RESET is tied to the asynchronous CLR inputs of all flip- |
|||||
|
|
flops. The counter output is set to 000 when the RESET line goes LOW. |
|
||||
|
VCC |
|
|
|
|
|
|
|
JKFF |
|
JKFF |
AND2 |
JKFF |
|
|
|
|
|
|
|
|
||
|
|
PRN |
PRN |
|
J |
PRN |
|
|
J |
|
Q |
|
|||
|
Q |
J |
Q |
|
|||
|
|
|
|
||||
|
K |
CLRN |
K |
|
K |
CLRN |
|
|
|
CLRN |
|
|
|||
CLK |
INPUT |
|
|
|
|
|
|
INPUT |
|
|
|
|
OUTPUT |
|
|
RESET |
|
|
|
|
Q2 |
||
|
|
|
|
|
|||
|
|
|
|
|
|
OUTPUT |
Q1 |
|
|
|
|
|
|
OUTPUT |
|
|
|
|
|
|
|
Q0 |
|
|
|
|
|
|
|
|
|
FIGURE 7.57 |
|
|
|
|
|
|
|
Synchronous Counter with Asynchronous Reset |
|
|
|
|