Docsity

Combinatorial Logic Design, Exams of Logic

Toggle sidebar
bg1
5-27
Publication# 90003 Rev. AAmendment /0
Issue Date: June 1993
Combinatorial Logic Design
INTRODUCTION
In this section we will take a detailed look at several as-
pects of combinatorial logic design. Most combinatorial
design applications can be easily segmented into five
major fields.
Encoders and Decoders
Multiplexers
Comparators
Adders and Arithmetic Logic
Latches
We will not only focus on the design methodology for
these functions, but will also explore further function-
specific PLD selection requirements. Generalized
designs will be developed, which can be customized
later to suit specific system applications. Ways of opti-
mizing the design will also be discussed.
Encoders and Decoders
Two of the most important functions required in digital
design are encoding and decoding. The encoding and
decoding of data are used extensively in digital commu-
nications as well as in peripherals. Both these areas use
various complex encoding and decoding techniques.
Most of these techniques are extensions of the simple
encoding and decoding techniques often used in other
digital designs. In this discussion we will focus on simple
encoding and decoding techniques. More complex
techniques will be discussed later.
Encoders
A binary code of n bits can be used to represent 2n dis-
tinct pieces of coded data. A simple combinatorial
encoder is a circuit which generates n bits of output in-
formation based upon one of the 2n unique pieces of
input data information. This encoding of information is
controlled by other independent control signals in a typi-
cal digital circuit.
An illustration of a typical encoder is shown in Figure 1.
The design methodology typically followed is based on
truth tables (Table 1), from which the Boolean equations
are directly derived for the design. The same generic de-
vice selection considerations discussed in the section
on PAL device design methodology apply for encoder
and decoder designs.
A
B
C
D
C0
C1
Inputs Encoded
Outputs
Encoder
90003A-1
Figure 1. A Block Diagram of an Encoder
Table 1. Truth Table of a Typical Encoder
A B C D C0 C1
1 000LL
0 100LH
0 010HL
0 001HH
Inputs Outputs
The Boolean equations can then be optimized using
Karnaugh maps or the software minimizer.
The resulting Boolean equations are:
C1 = /A * B * /C * /D
+/A*/B*/C*D
C0 =/A*/B*C */D
+/A*/B*/C*D
A Priority Encoder
Let us take another look at the encoder example of Ta-
ble 1. In this example it is assumed that only one of the
inputs A, B, C or D is asserted HIGH at any one time. If
two of the inputs are asserted HlGH simultaneously, a
conflict would be created. To resolve this, a priority
needs to be assigned to each of the inputs. Such a prior-
ity assignment is used to select a particular element
when several inputs are asserted simultaneously. Each
input is assigned a priority with respect to the other in-
puts. The output code generated is the code assigned to
the highest priority input asserted.
Thus, a priority encoder is a combinatorial circuit block
similar to a general encoder, except that the inputs are
assigned a priority. Such priority encoders are used
often in state machine applications, where they detect
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Combinatorial Logic Design and more Exams Logic in PDF only on Docsity!

Publication# 90003 Rev. A Amendment / Issue Date: June 1993

Combinatorial Logic Design

INTRODUCTION

In this section we will take a detailed look at several as- pects of combinatorial logic design. Most combinatorial design applications can be easily segmented into five major fields.

Encoders and Decoders Multiplexers Comparators Adders and Arithmetic Logic Latches

We will not only focus on the design methodology for these functions, but will also explore further function- specific PLD selection requirements. Generalized designs will be developed, which can be customized later to suit specific system applications. Ways of opti- mizing the design will also be discussed.

Encoders and Decoders

Two of the most important functions required in digital design are encoding and decoding. The encoding and decoding of data are used extensively in digital commu- nications as well as in peripherals. Both these areas use various complex encoding and decoding techniques. Most of these techniques are extensions of the simple encoding and decoding techniques often used in other digital designs. In this discussion we will focus on simple encoding and decoding techniques. More complex techniques will be discussed later.

Encoders

A binary code of n bits can be used to represent 2n dis- tinct pieces of coded data. A simple combinatorial encoder is a circuit which generates n bits of output in- formation based upon one of the 2n unique pieces of input data information. This encoding of information is controlled by other independent control signals in a typi- cal digital circuit.

An illustration of a typical encoder is shown in Figure 1. The design methodology typically followed is based on truth tables (Table 1), from which the Boolean equations are directly derived for the design. The same generic de- vice selection considerations discussed in the section on PAL device design methodology apply for encoder and decoder designs.

A B C D

C

C

Inputs (^) Encoder EncodedOutputs

90003A- Figure 1. A Block Diagram of an Encoder

Table 1. Truth Table of a Typical Encoder

A B C D C0 C 1 0 0 0 L L 0 1 0 0 L H 0 0 1 0 H L 0 0 0 1 H H

Inputs Outputs

The Boolean equations can then be optimized using Karnaugh maps or the software minimizer.

The resulting Boolean equations are:

C1 = /A * B * /C * /D

  • /A * /B * /C * D

C0 = /A * /B * C * /D

  • /A * /B * /C * D

A Priority Encoder

Let us take another look at the encoder example of Ta- ble 1. In this example it is assumed that only one of the inputs A, B, C or D is asserted HIGH at any one time. If two of the inputs are asserted HlGH simultaneously, a conflict would be created. To resolve this, a priority needs to be assigned to each of the inputs. Such a prior- ity assignment is used to select a particular element when several inputs are asserted simultaneously. Each input is assigned a priority with respect to the other in- puts. The output code generated is the code assigned to the highest priority input asserted.

Thus, a priority encoder is a combinatorial circuit block similar to a general encoder, except that the inputs are assigned a priority. Such priority encoders are used often in state machine applications, where they detect

5-28 Combinatorial Logic Design

the occurrence of the highest priority event. They are also used for microprocessor interrupt controllers, where they detect the highest priority interrupt. Another use for priority encoders is in bus control, where they are used in arbitration schemes for allowing selective ac- cess to the bus.

The model of a priority encoder is shown in Figure 2. The four input signals are A, B, C and D. These are to be en- coded as LL, LH, HL and HH outputs. Let us assign priority to D over C, C over B, and B over A. The next design step would be to modify the truth table (Table 2) to reflect these priorities.

A

B C D

C C

Priority Encoder

90003A-

Figure 2. A Four-Input Priority Encoder Block Diagram

Table 2. Priority Encoder Truth Table

A B C D C0 C 1 0 0 0 L L 0 1 0 0 L H 0 0 1 0 H L 0 0 0 1 H H X 1 0 0 L H X X 1 0 H L X X X 1 H H

Inputs Outputs

Priority Assignments

The Boolean equations, directly derived from the truth table, are:

C1 = /A * B * /C * /D

  • /A * /B * /C * D
  • B * /C * /D
  • D

C0 = /A * /B * C * /D

  • /A * /B * /C * D
  • C * /D
  • D

These equations can be further optimized by the design software to the following:

C1 = D + /C * B C1 = D + C

Although a priority encoder is a purely combinatorial function, output registers are frequently used to hold the output signal stable for longer durations.

Decoders

A decoder performs the reverse function of an encoder. It converts an n-bit code to one of its 2n^ unique items. It is a combinatorial circuit designed such that at most one of its several outputs will be asserted based upon the unique input codes.

A decoder may have as many outputs as there are pos- sible binary input selection combinations. As shown in the truth table (Table 3), only one output may be as- serted at any time. When a new combination is applied, another output is asserted and the original output is re- turned to its non-asserted state.

5-30 Combinatorial Logic Design

(and priority assignments in priority encoders) can often reduce the required number of product terms. This can sometimes determine whether or not a design fits a de- vice successfully. Figure 4 shows the truth tables of two simple partial 3-to-2 encoders. The product terms re- quired for the two designs are different due to the different assignment of encoded bits.

A B C X1 X 1 0 0 0 0 0 1 0 0 1 0 0 1 1 0

Inputs Outputs Inputs Outputs A B C X1 X 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1

X1 = /A * /B * C

X0 = /A * /B * /C

X1 = /A * B * /C

+ /A */B * C

X0 = A * /B * /C

+ /A * /B * C

10173D-

Figure 4. Two Encoders with Different Product Term Requirements

Another way of looking at a decoder is as a logic function which, depending upon the select code applied, con- nects one data input to the selected outputs. Also known as a demultiplexer, a decoder essentially connects an input to one of 2n^ outputs based upon n select code bits. The reverse logic function, which combines data from multiple sources to an output signal, is called a multi- plexer and is discussed next.

Multiplexers

A multiplexer (sometimes referred to as a data selector) is a special combinatorial circuit, widely used in digital design. It is designed to gate one of several inputs to a single output. The input selected for connection to the output is controlled by a separate set of select inputs.

The traditional use of a multiplexer is for “time division multiplexing” in data communication, when gating sev- eral data lines to a single data transmission line for short intervals of time. The data received is then de- multiplexed by using a demultiplexer.

The design methodology employed for multiplexer de- sign is the truth-table approach. As an example, we can look at a three in put-to-one-output (3:1) multiplexer, which uses two select signals A and B. Based on these two select bits, the data on one of the three inputs is sent to the output. The truth table is shown in Table 4.

Table 4. Truth Table for a Three-to-One Multiplexer

B A I1C0 I1C1 I1C2 O1Y 0 0 0 X X 0 0 0 1 X X 1 0 1 X 0 X 0 0 1 X 1 X 1 1 0 X X 0 0 1 0 X X 1 1

Select Inputs Output

Deriving the Boolean equation from this truth table is a straight forward task. In this case no further minimiza- tion is possible. The Boolean equation is:

/01Y = /B * /A * /I1C

  • /B * A * /I1C
  • B * /A * /I1C

The equations derived in the above example can be easily generalized for other multiplexers. The symbol for a general 2n-inputs-to-one-output multiplexer is shown in Figure 5 where n select lines are used.

Multiplexer Y Output

I

I Inputs

I2n–

S0 S1 Sn– 90003A- Input Select Lines

Figure 5. General Model of a 2n^ -to-1 Multiplexer

Combinatorial Logic Design 5-

The Boolean equations are:

n=

Y = /S1 * /S0 * (I0)

  • /S1 * S0 * (I1)
  • S1 * /S0 * (I2)
  • S1 * S0 * (I3)

n=

Y = /S2 * /S1 * /S0 * (I0)

  • /S2 * /S1 * S0 * (I1)
  • /S2 * S1 * /S0 * (I2)
  • /S2 * S1 * S0 * (I3)
  • S2 * /S1 * /S0 * (I4)
  • S2 * /S1 * S0 * (I5)
  • S2 * S1 * /S0 * (I6)
  • S2 * S1 * S0 * (I7)

Multiplexer Device Selection

Considerations

Multiplexers typically require more inputs than outputs, so the devices with a large number of inputs and l/Os are usually more useful. Careful consideration must also be given to the number of product terms available on each output.

Several multiplexers are often used simultaneously to route multiple address and data bits, under the control of the same select lines. In such cases, multiple devices can be cascaded when the number of inputs and out- puts exceeds device limits. Cascading is also possible for large multiplexers that do not fit in a single device. In such cases, the select bits should also be judiciously se- lected for each PLD, to minimize the number of product terms.

Another common trick for designing a multiplexer is to connect a number of outputs together and control the output enables using the select bits to multiplex data. Timing considerations for such designs include the out- put enable and disable times, which should be carefully selected to avoid output contentions.

Comparators

A comparator is a combinatorial circuit designed primar- ily to compare the relative magnitude of two binary numbers. Table 5 shows the truth table for a two-bit comparator.

Table 5. Truth Table for a Comparator

A2 A1 B2 B1 A=B AB 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 1 0 0 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0

A

Outputs B

Inputs EQL LES GTR

A basic comparator compares two numbers only for equality, and generates the EQL signal (indicating A=B). An extension, called a magnitude comparator, also generates the LES signal (indicating A<B) and GTR signal (indicating A>B). Based on this truth table, the equations for the three output signals EQL, LES and GTR can be easily derived. These equations can then be optimized by using Boolean algebra, Karnaugh maps, or the minimization routine available with the software.

Combinatorial Logic Design 5-

As such designs require few product terms and no XOR gates, they are efficiently implemented on standard combinatorial PLDs. A general form of range co- mparators with two boundary comparands will be discussed later.

The third output signal is the EQL signal. The EQL Boolean equation tells us whether the two numbers are identical. Such information is useful not only in address decoders, but also in digital signal processing designs. This equation requires a large number of product terms. A closer examination reveals that it is essentially an ex- clusive-OR function.

EQL = /A2 * /B2 * (/A1 * /B1 + A1 * B1)

  • A2 * B2 * (/A1 * /B1 + A1 * B1)

EQL = (A1::B1) (A2:*:B2);Exclusive-NOR ;function

Inverting this:

/EQL = (A1:+:B1) + (A2:+:B2); Exclusive–OR ; function

This equation can be extended to give a general equa- tion for equal-to comparison for two n-bit comparands.

/EQL = (An :+: Bn)

  • (An–1 :+: Bn–1)
  • (An–2 :+: Bn–2)
  • (An–3 :+: Bn–3)
  • ...
  • ...
  • (A1 :+: B1)

This inverted equation is implementable in the sum-of- products form of the exclusive-OR functions, and can be easily expanded to the following:

/EQL = A1 * /B1 + /A1 * B

  • A2 * /B2 + /A2 * B
  • A3 * /B3 + /A3 * B
  • ...
  • ...
  • An * /Bn + /An * Bn

This gives us a general sum-of-products form of a co- mparator equation which is easily implemented in PAL devices. A n-bit comparator requires 2n product terms.

Note that the EQL equation, as well as GTR and LES equations, rely upon the XOR function. Often the logic represented by the equations is implemented in two or more devices.

Let us analyze these equations further. The LES and GTR outputs indicate whether one number is greater than or less that another. In fact, these equations can also be judiciously combined to get a comparison of a range of numbers such as A>X>B. Such range compari- sons are very useful for address decoder circuits.

Range Decoders

Range decoders implemented as address decoders are one of the most commonly used applications of PLDs in digital systems. A good example is the address decoder illustrated earlier. Range decoders compare a number (address) to a given range of comparands (addresses). One way to arrive at the range decoder Boolean equa- tions is to use the traditional truth table approach. Another way is to use the Boolean equations generated earlier in the comparator section for greater-than and less-than functions. To decode a range of three-bit num- bers from B to A, we must compare another number X such that A>X>B. The Boolean equations for the GTR (A>X) and LES (B<X) functions are illustrated below:

GTR = A3 */X

  • (A3 :+: /X3) * A2* /X
  • (A3 :+: /X3) * (A2:+: /X2 *A1 * /X

LES = X3 * /B

  • (X3 :+: /B3) * X2 * /B
  • (X3 :+: /B3) * (X2:+: /B2)* X */B

Combining these two equations can give us a range sig- nal which will be asserted only when A is greater than X and X is greater than B. The combined Boolean equa- tion follows:

RANG = (A3 * /X

  • (A3 :+: /X3) * A2 * /X
  • (A3 :+: /X3) * (A2 :+: /X2)* A1 * /X1) * (X3* /B
  • (X3 :+: /B3) * X2 * /B
  • (X3 :+: /B3 * (X2 :+:/B2) * X */B1)

5-34 Combinatorial Logic Design

Using Boolean algebra we get the following equation:

RANG =

(A3 :+:/X3) * (X3 :+: /B3) * (A2 :+: /X2)* A1 * /X1 * X2 * /B

  • (A3 :+:/X3) * (X3 :+: /B3) * (X2 :+: /B2)* A2 * /X2 * X1 * /B
  • (A3 :+:/X3) * (A2 :+: /X2) * A1 * /X1 * X3 * /B
  • (X3 :+:/B3) * (X2 :+: /B2) * A3 * /X3 * X1 * /B
  • (A3 :+:/X3) * A2 * /X2 * X3 * /B
  • (X3 :+:/B3) * A3 * /X3 * X2 * /B

The general equation for n-bit comparands can also be obtained by extending these equations.

RANG = (An * /Xn

  • (An :+:/Xn) * An–1 * /Xn–
  • (An :+:/Xn) * (An–1:+:/Xn–1) * An–2 * /Xn–
  • ...
  • ...
  • (An :+:/Xn) * (An–1:+:/Xn–1)... (A2 :+: /X2)* A1 * /X1)

(Xn * /Bn

  • (Xn :+:/Bn) * Xn–1 * /Bn–
  • (Xn :+:/Bn) * (Xn–1:+:/Bn–1) * Xn–2 * /Bn–
  • ...
  • ...
  • ...
  • (Xn :+:/Bn) * (Xn–1:+:/Bn–1)... (X2 :+: /B2)* X1 * /B1)

The number of product terms required is clearly very large and can easily exceed one hundred for an eight-bit range comparator. Most microprocessors have ad- dresses which exceed 16 bits. In order to fit the design on a PAL device, one commonly used technique is to se- lect the address range defined by A and B such that the range extends from address B+1 to A–1, where A and B+1 are power-of-two numbers. Because the address space is aligned on the power-of-two boundaries, a number of bits of the address comparands will be zero. When implemented in Boolean equations, this substan- tially reduces the number of product terms required.

The maximum number of product terms required for a three-bit range decoder shown above, with any com- parand values, is 28. If the address chosen is from 2 to 3, resulting in A=4 and B=1, then only one product term will be required.

RANG = /X3 * X

Similarly, for a range from one to five, B =1 and A = 6 (a multiple-of-two), and the number of product terms re- quired is only two.

RANG = /X3 * X

  • X3 * /X

Thus, a careful selection of range boundaries allows such logic functions to be implemented easily in PLDs. Such reduction in logic obviously also holds true for dis- crete implementations. Most address decoders are designed with address ranges with boundaries that are power-of-two numbers, and require few product terms for implementation.

For a power-of-two address range, the comparand A would be a power-of-two; 2, 4 or 8. These are numbers whose least significant bits are all zeros. Similarly, com- parand B will be a power-of-two number (minus one); 1, 3, and 7. These are numbers whose least significant bits are all ones. Substituting these in the general equation for range comparators we arrive at:

A = 0000100000000000 n p 1

B = 0000000000011111 n q 1

RANG = /Xn * /Xn–1 ... /Xp * (Xp–1 + Xp–2 + ... +Xq)

5-36 Combinatorial Logic Design

and finally the carry-out is:

Cn = An * Bn

  • (An + Bn) *(An–1 *Bn–1)

  • (An + Bn) (An–1 +Bn–1) * (An–2 Bn–2)

  • ...

  • ...

  • (An + Bn) * ... *(A0 + B0) * Cin

These equations are essentially a combination of the traditional generate and propagate logic for ALU design.

Adder Device Selection Considerations

The number of product terms required for implementing a carry-look-ahead adder is enormous. The carry-out function alone for a four-bit carry-look-ahead adder re- quires over 36 product terms in the sum-of-products form. For a single-level AND-OR implementation the number of product terms required for the most signifi- cant bit Y3 is 28.

A logic trick lies in the bit-pair decoding function. All of the bits of the first operand in the registers (A) and the second operand at the inputs (B) are bit-pair decoded. As illustrated in Figure 6, the results of this bit-pair de- coding are A + B, A + /B, /A + B, and /A + /B. These outputs are then fed to the AND array as inputs.

Input A B Feedback

Bit-Pair Decoding A + B

A + B

A + B

A + B

90003A-

Figure 6. Bit-Pair-Decoding Function

Sixteen AND combinations of these four inputs can then be formed on every product term of the AND-OR array. These are shown in Figure 7, and include the standard true and complements of both the bits as well as XOR< XNOR and various other combinations. This bit pair de- coding essentially provides an extra two-level AND-OR logic level before the AND-OR array. The cost as well as

extra propagation delay of the extra logic level is mini- mal, since the array size does not increase.

The equations for the adder can obviously benefit from multi-level logic. The bit-pair decoding can be used to implement the first two levels of logic. The next level of logic can be implemented in the standard AND-OR ar- ray. Every product term of the AND-OR array can combine one of the sixteen possible functions of differ- ent inputs/feedbacks of the device.

The product terms are then combined together through an OR gate to implement the CARRY-OUT function, shown in Figure 8. For adder outputs Y0, Y1, Y2, and Y3, the product terms are combined through an XOR gate, as shown in Figure 9.

A + B

0

A + B

A

A + B

A :*: B

B

A * B

A + B

A :+: B

A * B

B

A

A * B

A * B

1

A + B A + B A + B A + B Product Terms

90003A- Figure 7. Sixteen Possible Input Logic Combinations

Combinatorial Logic Design 5-

Bit Pair Decoding

Bit Pair Decoding

Bit Pair Decoding

Bit Pair Decoding

A B

A B

A B

A B

Cin

Carry-Out

A3 * B (A3 + B3) * A2 * B (A3 + B3) * (A2 + B2) * A1 * B (A3 + B3) * (A2 + B2) * (A1 + B1) * A0 * B (A3 + B3) * (A2 + B2) * (A1 + B1) * (A0 * B0) * Cin

A3 + B3A3 +

B

3

A3 + B3 A3 +

B

3

A2 + B2A2 +

B

2

A2 + B2 A2 +

B

2

A1 + B1A1 +

B

1

A1 + B1 A1 +

B

1

A0 + B0A0 +

B

0

A0 + B0 A0 + B

Carry-Out = A3 * B (A3 + B3) * A2 * B (A3 + B3) * (A2 + B2) * A1 * B (A3 + B3) * (A2 + B2) * (A1 + B1) * A0 * B (A3 + B3) * (A2 + B2) * (A1 + B1) * (A0 * B0) * Cin

90003A-

Figure 8. Implementation of CARRY-OUT Function

Bit Pair Decoding

Bit Pair Decoding

Bit Pair Decoding

Bit Pair Decoding

A B

A B

A B

A B

Cin

A3 :+: B

(A2 * B2) (A2 + B2) * (A1 * B1) (A2 + B2) * ( A1 + B1) * (A0 * B0) (A2 + B2) * (A1 + B1) * (A0 * B0) * Cin

A3 + B3A3 +

B

3

A3 + B3 A3 +

B

3

A2 + B2A2 +

B

2

A2 + B2 A2 +

B

2

A1 + B1A1 +

B

1

A1 + B1 A1 +

B

1

A0 + B0A0 +

B

0

A0 + B0 A0 +

B

0

Y

C in C in

Y3 = A3 :+: B :+: (A2 * B2) +(A2 + B2) * (A1 * B1) +(A2 + B2) * (A1 + B1) * (A0 * B0) +(A2 + B2) * (A1 + B1) * (A0 * B0) * Cin)

90003A-

Figure 9. Relationship Between Adder Boolean Equation and Device Logic

Combinatorial Logic Design 5-

Covering Hazard

1 2

0 0

1 1

0

0

0

1

0

1

00 01 11 10

D LEN

Q

Static 1 Hazard

Notes:

  1. Q = D * LEN
    • Q * LEN (^) 90003A-

Figure 13. Karnaugh Map for Transparent Latch Design

The possibility of a hazard exists when the signal LEN changes. Initially, when D and LEN are HIGH, the output Q is also HIGH. When LEN switches to LOW, it is possi- ble for the output to go LOW momentarily. This is because when LEN goes LOW the first product term is disabled, and to maintain the output HIGH the second

product term should be enabled exactly at the same in- stant. Due to the uneven gate delays or routing conditions on board, these two events will not take place simultaneously. This is a static 1 hazard. It can also be identified directly in the Karnaugh map by the two adja- cent but disjoint sets of ones, grouped together to form a product term each.

The hazard conditions can be easily avoided in the PLDs by providing an extra cover product term. This product term is shown with a dotted line in the Karnaugh map. This third product term will keep the output as- serted during the transition of the LEN signal, when the control changes from the first product term to the sec- ond. The modified Boolean equation is shown below.

/Q = /D * LEN

  • /Q * /LEN
  • /D * /Q (Cover product term)

Devices on which latches are implemented need to pro- vide output feedback. All devices with l/O pins provide this necessary feedback. The only other consideration for selecting a device would be the provision of sufficient number of product terms for addressing the needs of glitch-free and testable design.