Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 8110

Скачиваний: 6

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

300 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?


7.5 • Edge-Triggered JK Flip-Flops

303

7.5 Edge-Triggered JK Flip-Flops

FIGURE 7.45

Edge-Triggered JK Flip-Flops

K E Y T E R M

Toggle Alternate between opposite binary states with each applied clock pulse.

A versatile and widely used sequential circuit is the JK flip-flop.

Figure 7.45 shows the logic symbols of a positiveand a negative-edge triggered JK flip-flop. J acts as a SET input and K acts as a RESET input, with the output changing on the active clock edge in response to J and K. When J and K are both HIGH, the flip-flop will toggle between opposite logic states with each applied clock pulse. The function tables of the devices in Figure 7.45 are shown in Table 7.7.

Figure 7.46 shows the simplified circuit of a negative-edge triggered JK flip-flop. The circuit is like that of a gated SR latch with an edge detector (an SR flip-flop), except that there are two extra feedback lines from the latch outputs to the steering gate inputs. This extra feedback is responsible for the flip-flop’s toggling action.

Figure 7.47 illustrates how the additional two lines cause the flip-flop to toggle. The cross-feedback from Q to K and from Q to J enables one, but not both, of the steering gates. The edge detector just after the CLK input produces a short positive-going pulse upon detecting a negative edge on the CLK waveform. The enabled steering gate complements and transmits this pulse to the latch, activating either the set or reset function. This in turn changes the latch state and enables the opposite steering gate.

Since all inputs of the steering gates must be HIGH to enable one of the latch functions, J and K must both be HIGH to sustain a repeated toggling action. Under these conditions, Q and Q alternately enable one of the steering gates.

Table 7.7 Function Tables for Edge-Triggered JK Flip-Flops

CLK

J

K

Qt 1

Qt 1

Function

CLK

J

K

Qt 1

Qt 1

Function

0

0

Qt

Qt

No change

0

0

Qt

Qt

No change

0

1

0

1

Reset

0

1

0

1

Reset

1

0

1

0

Set

1

0

1

0

Set

1

1

Qt

Qt

Toggle

1

1

Qt

Qt

Toggle

0

X

X

Qt

Qt

Inhibited

0

X

X

Qt

Qt

Inhibited

1

X

X

Qt

Qt

Inhibited

1

X

X

Qt

Qt

Inhibited

X

X

Qt

Qt

Inhibited

X

X

Qt

Qt

Inhibited

Positive Edge-Triggered

Negative Edge-Triggered

FIGURE 7.46

JK Flip-Flop Circuit (Simplified)


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

305

FIGURE 7.49

Example 7.9

Circuit

combination of Q2, Q1, and Q0. What pattern do the outputs form over the period shown on the timing diagram?

SOLUTION The circuit timing diagram is shown in Figure 7.50. All flip-flops are in toggle mode. Each time a negative clock edge is applied to the flip-flop CLK input, the Q output will change to the opposite state.

Table 7.8 Sequence of Outputs for Circuit in Figure 7.49

Clock

Pulse Q2 Q1 Q0

0 0 0 0

1 0 0 1

2 0 1 0

3 0 1 1

4 1 0 0

5 1 0 1

6 1 1 0

7 1 1 1

8 0 0 0

FIGURE 7.50

Example 7.9

Timing Diagram

For flip-flop 0, this happens with every clock pulse, since it is clocked directly by the CLK waveform. Each of the other flip-flops is clocked by the Q output waveform of the previous stage. Flip-flop 1 is clocked by the negative edge of the Q0 waveform. Flip-flop 2 toggles when Q1 goes from HIGH to LOW.

Table 7.8 shows the flip-flop outputs after each clock pulse. The outputs form a 3-bit number that counts from 000 to 111 in binary sequence, then returns to 000 and repeats.

This flip-flop circuit is called a 3-bit asynchronous counter.

Synchronous versus Asynchronous Circuits

K E Y T E R M S

Synchronous Synchronized to the system clock.

Asynchronous Not synchronized to the system clock

The asynchronous counter in Figure 7.49 has the advantage of being simple to construct and analyze. However, because it is asynchronous (that is, not synchronized to a single clock), it is seldom used in modern digital designs. The main problem with this and other asynchronous circuits is that their outputs do not change at the same time, due to delays in the flip-flops. This yields intermediate states that are not part of the desired output sequence.