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

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

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

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

Добавлен: 13.06.2025

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

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

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

446 C H A P T E R 9 • Counters and Shift Registers

If it is used for event sequencing, a Johnson counter must be decoded, unlike a ring counter. Its output states are such that each state can be decoded uniquely by a 2-input AND or NAND gate, depending on whether you need active-HIGH or active-LOW indication. This yields a simpler decoder than is required for a binary counter.

Table 9.19 shows the decoding of a 4-bit Johnson counter.

Table 9.19 Decoding a 4-bit Johnson Counter

Q3 Q2 Q1 Q0

Decoder Outputs

Comment

0

0

0

0

3 0

MSB LSB

Q Q

0

1

0

0

0

3 2

“1/0”

Q Q

1

1

0

0

2 1

Pairs

Q Q

1

1

1

0

1 0

Q Q

1

1

1

1

Q3Q0

MSB LSB

1

0

1

1

1

3

Q

2

“0/1”

Q

0

0

1

1

2

Q

1

Pairs

Q

0

0

0

1

1

Q

0

Q

0

0

0

0

D

Q3

D

Q2

D

Q1

D

Q0

Q

Q

Q

Q

Q

Q

Q

Q

Clock

Q3Q0

Q3Q2

Q2Q1

Q1Q0

Q3Q0

Q3Q2

Q2Q1

Q1Q0

FIGURE 9.84

4-bit Johnson Counter with Output Decoding


9.9 • Shift Register Counters

447

Decoding a sequential circuit depends on the decoder responding uniquely to every

possible state of the circuit outputs. If we want to use only 2-input gates in our decoder, it

must recognize two variables for every state that are both active only in that state.

A Johnson counter decoder exploits what might be called the “1/0 interface” of the

count sequence table. Careful examination of Tables 9.17 and 9.18 reveals that for every

state, except where the outputs are all 1s or all 0s, there is a side-by-side 10 or 01 pair

which exists only in that state.

Each of these pairs can be decoded to give unique indication of a particular state. For

example, the pair Q3Q2 uniquely indicates the second state since Q3 1 AND Q2 0 only

in the second line of the count sequence table. (This is true for any size of Johnson counter;

compare the second lines of Tables 9.17 and 9.18. In the second line of both tables, the

MSB is 1 and the 2nd MSB is 0.)

For the states where the outputs are all 1s or all 0s, the most significant AND least sig-

nificant bits can be decoded uniquely, these being the only states where MSB LSB.

Figure 9.84 shows the decoder circuit for a 4-bit Johnson counter.

The output decoder of a Johnson counter does not increase in complexity as the mod-

ulus of the counter increases. The decoder will always consist of 2n 2-input AND or

NAND gates for an n-bit counter. (For example, for an 8-bit Johnson counter, the decoder

will consist of sixteen 2-input AND or NAND gates.)

EXAMPLE 9.20

Draw the timing diagram of the Johnson counter decoder of Figure 9.84, assuming the

counter is initially cleared.

Solution Figure 9.85 shows the timing diagram of the Johnson counter and its decoder outputs.

FIGURE 9.85

Example 9.20

Johnson Counter Decoder

Outputs


448 C H A P T E R 9 • Counters and Shift Registers

SECTION 9.9 REVIEW PROBLEM

9.9How many flip-flops are required to produce 24 unique states in each of the following types of counters: binary counter, ring counter, Johnson counter? How many and what type of decoding gates are required to produce an active-LOW decoder for each type of counter?

S U M M A R Y

1.A counter is a circuit that progresses in a defined sequence at the rate of one state per clock pulse.

2.The modulus of a counter is the number of states through which the counter output progresses before repeating.

3.A counter with an ascending sequence of states is called an UP counter. A counter with a descending sequence of states is called a DOWN counter.

4.In general, the maximum modulus of a counter is given by 2n for an n-bit counter.

5.A counter whose modulus is 2n is called a full-sequence counter. The count progresses from 0 to 2n 1, which corresponds to a binary output of all 0s to all 1s.

6.A counter whose output is less than 2n is called a truncated sequence counter.

7.The adjacent outputs of a full-sequence binary counter have

afrequency ratio of 2 1. The less significant of the two bits has the higher frequency.

8.The outputs of a truncated sequence counter do not necessarily have a simple frequency relationship.

9.A synchronous counter consists of a series of flip-flops, all clocked from the same source, that stores the present state of the counter and a combinational circuit that monitors the counter’s present state and determines its next state.

10.A synchronous counter can be analyzed by a formal procedure that includes the following steps:

a.Write the Boolean equations for the synchronous inputs of the counter flip-flops in terms of the present state of the flip-flip outputs.

b.Evaluate each Boolean equation for an initial state to find the states of the synchronous inputs.

c.Use flip-flop function tables to determine each flip-flop next state.

d.Set the next state to the new present state.

e.Continue until the sequence repeats.

11.The analysis procedure above should be applied to any unused states of the counter to ensure that they will enter the count sequence properly.

12.A synchronous counter can be designed using a formal method that relies on the excitation tables of the flip-flops used in the counter. An excitation table indicates the required logic levels on the flip-flop inputs to effect a particular transition.

13.The synchronous counter design procedure is based on the following steps:

a.Draw the state diagram of the counter and use it to list the relationship between the counter’s present and next states. The table should list the counter’s present states in binary order.

b.For the initial design, unused states can be set to a known destination, such as 0, or treated as don’t care states.

c.Use the flip-flop excitation table to determine the synchronous input levels for each present-to-next state transition.

d.Use Boolean algebra or Karnaugh maps to find the simplest equations for the flip-flop inputs (JK, D, or T) in terms of Q.

e.Unused states should be analyzed by substituting their values into the Boolean equations of the counter. This will verify whether or not an unused state will enter the count sequence properly.

14.If a counter must reset to 0 from an unused state, the flipflops can be reset asynchronously to their initial states or the counter can be designed with the unused states always having 0 as their next state.

15.A counter can be designed in VHDL by using a behavioral description or a structural design that uses a component from the Library of Parameterized Modules (LPM).

16.A behavioral counter design requires a PROCESS statement that lists the clock signal and any asynchronous inputs in its sensitivity list. An IF statement inside the PROCESS can monitor the active clock edge by using the predefined EVENT attribute (e.g., clk EVENT) and increment a count variable.

17.A variable is local to a PROCESS and is assigned with the : operator. A signal is global to the VHDL design entity and is assigned with the <= operator. (Recall that a signal is like an internal connecting wire and a variable is a piece of working memory.)

18.A structural counter design can use an LPM component (lpm_counter) and instantiate the component in a component instantiation statement. The statement’s generic map specifies the component parameters, and its port map indicates the correspondence between the component port names and the user port, signal, or variable names.

19.Some of the most common control features available in synchronous counters include:

a.Synchronous or asynchronous parallel load, which allows the count to be set to any value whenever a LOAD input is asserted

b.Synchronous or asynchronous clear (reset), which sets all of the counter outputs to zero

c.Count enable, which allows the count sequence to progress when asserted and inhibits the count when deasserted

d.Bidirectional control, which determines whether the counter counts up or down


e.Output decoding, which activates one or more outputs when detecting particular states on the counter outputs

f.Ripple carry out or ripple clock out (RCO), a special case of output decoding that produces a pulse upon detecting the terminal count, or last state, of a count sequence

20.The parallel load function of a counter requires load data (the parallel input values) and a load command input, such as LOAD, that transfer the parallel data when asserted. If the load function is synchronous, a clock pulse is also required.

21.Synchronous load transfers data to the counter outputs on an active clock edge. Asynchronous load operates as soon as the load input activates, without waiting for the clock.

22.Synchronous load is implemented by a function select circuit that selects either the count logic or the direct parallel input to be applied to the synchronous input(s) of a flip-flop.

23.Asynchronous load is implemented by enabling or inhibiting

apair of NAND gates, one of which asserts a flip-flop clear input and the other of which asserts a preset input for the same flip-flop.

24.The count enable function enables or disables the count logic of a counter without affecting other functions, such as clock or clear. This can be done by ANDing the count logic with the count enable input signal.

25.A flip-flop in an UP counter toggles when all previous bits are HIGH. A flip-flop in a DOWN counter toggles when all previous bits are LOW. A circuit that selects one of these two conditions (a pair of AND-shaped gates, combined in an OR gate; essentially a 2-to-1 multiplexer) can implement a bidirectional count.

26.An output decoder asserts one output for each counter state. A special case is a terminal count decoder that detects the last state of a count sequence.

27.RCO (ripple clock out) generates one clock pulse upon terminal count, with its positive edge at the end of the count cycle.

28.Asynchronous inputs to a behaviorally defined counter in VHDL must be included in the sensitivity list of the process defining the counter. Asynchronous inputs must be checked inside the process before the clock is checked for an active edge.

29.Synchronous inputs to a behaviorally defined counter should not be included in the sensitivity list of the process defining the counter. Synchronous inputs must be checked inside the IF statement that checks the clock edge.

Glossary 449

30.A shift register is a circuit for storing and moving data. Three basic movements in a shift register are: serial (from one flipflop to another), parallel (into all flip-flops at once), and rotation (serial shift with a connection from the last flip-flop output to the first flip-flop input).

31.Serial shifting can be left (toward the MSB) or right (away from the MSB). This is the convention used by MAX PLUS II. Some data sheets indicate the opposite relationship between right/left and LSB/MSB.

32.A function select circuit can implement several shift register variations: bidirectional serial shift, parallel load with serial shift, and universal shift (parallel/serial in/out and bidirectional in one device). The circuit directs data to the D inputs of each flip-flop from one of several sources, such as from the flip-flop immediately to the left or right or from an external parallel input.

33.A shift register can be created in VHDL by the structural, dataflow, or behavioral method.

34.A structural design instantiates components, such as D flipflops, and connects them with internal signals.

35.A dataflow design uses internal Boolean relationships between inputs and outputs. It is similar to a structural model, except that it must contain a process to create the flip-flops.

36.A behavioral design method uses a description of the shift register function to generate the required hardware.

37.A VHDL component can be created with parameters (such as width) that are specified when the component is instantiated. The parameters are listed in a GENERIC clause in the component’s entity declaration. Each parameter must be given a default value. The parameters are specified in a generic map in the design entity that instantiates the component.

38.A ring counter is a serial shift register with the serial output fed back to the serial input so that the internal data is continuously circulated. The initial value is generally set by asynchronous preset and clear functions.

39.The maximum modulus of a ring counter is n for a circuit with n flip-flops, as compared to 2n for a binary counter. A ring

counter output is self-decoding, whereas a binary counter requires m 2n AND or NAND gates with n inputs each.

40.A Johnson counter is a ring counter where the feedback is complemented. A Johnson counter has 2n states for an n-bit counter which can be uniquely decoded by 2n 2-input AND or NAND gates.

G L O S S A R Y

Attribute A property associated with a named identifier in VHDL. (e.g., the attribute EVENT, when associated with the identifier clk (written clk EVENT), indicates whether a transition has occurred on the input called clk.)

Behavioral design A VHDL design technique that uses descriptions of required behavior to describe the design.

Bidirectional counter A counter that can count up or down, depending on the state of a control input.

Bidirectional shift register A shift register that can serially shift bits left or right according to the state of a direction control input.

Binary counter A counter that generates a binary count sequence.

Clear Reset (synchronous or asynchronous)

Command lines Signals that connect the control section of a synchronous circuit to its memory section and direct the circuit from its present to its next state.

Conditional signal assignment statement A signal assignment statement that is executed only when a Boolean condition is satisfied.

Control section The combinational logic portion of a synchronous circuit that determines the next state of the circuit.

Count enable A control function that allows a counter to progress through its count sequence when active and disables the counter when inactive.