Combinational Logic Functions TN 4
Combinational Logic Functions TN 4
The aim of this topic is to enable students to appreciate the functions and uses of
combinational logic circuits to the electronic and related industries.
The Half-Adder
Recall the basic rules for binary addition leant earlier.
0+0=0
0+1=1
1+0=1
1 + 1 = 10
The operations are performed by a logic circuit called a half-adder.
The half-adder accepts two binary digits on its inputs and produces two binary digits on its
outputs—a sum bit and a carry bit.
Now observe that the sum output is a 1 only if the input variables, A and B, are not equal.
The sum can therefore be expressed as the exclusive-OR of the input variables.
A and B
From deduction above, the logic implementation required for the half-adder function can be
developed. The output carry is produced with an AND gate with A and B on the inputs, and
the sum output is generated with an exclusive-OR gate.
Remember that the exclusive-OR can be implemented with AND gates, an OR gate, and
inverters.(see the logic diagram below)
The Full-Adder
The second category of adder is the full-adder.
The full-adder accepts two input bits and an input carry and generates a sum output
and an output carry.
The basic difference between a full-adder and a half-adder is that the full-adder accepts an
input carry. A logic symbol for a full-adder and the truth table shows the operation of a full-
adder.
The full-adder must add the two input bits and the input carry. From the half-adder you know
that the sum of the input bits A and B is the exclusive-OR of those two variables, AOB. For
the input carry (Cin) to be added to the input bits, it must be exclusive-ORed with A0B,
yielding the equation for the sum output of the full-adder.
This means that to implement the full-adder sum function, two 2-input exclusive-OR gates
can be used. The first must generate the term AoB, and the second has as its inputs the output
of the first XOR gate and the input carry,
The logic required to form the sum of three bits as as shown below
The output carry is a 1 when both inputs to the first XOR gate are 1s or when both inputs to
the second XOR gate are 1s. The output carry of the full-adder is therefore produced by input
A ANDed with input B and A_B ANDed with Cin. These two terms are ORed, as expressed
in Equation below. This function is implemented and combined with the sum logic to form a
complete full-adder circuit, as shown
DECODERS
A decoder is a digital circuit that detects the presence of a specified combination of bits
(code) on its inputs and indicates the presence of that code by a specified output level. In its
general form, a decoder has n input lines to handle n bits and from one to 2n output lines to
indicate the presence of one or more n-bit combinations. The basic principles can be
extended to other types of decoders.
ENCODERS
The BCD (8421) code is listed in Table below. From this table you can determine the
relationship between each BCD bit and the decimal digits in order to analyze the logic. For
instance, the most significant bit of the BCD code, A3, is always a 1 for decimal digit 8 or
9. An OR expression for bit A3 in terms of the decimal digits can therefore be written as
A3 = 8 + 9
Bit A2 is always a 1 for decimal digit 4, 5, 6 or 7 and can be expressed as an OR function as
follows:
A2 = 4 + 5 + 6 + 7
Bit A1 is always a 1 for decimal digit 2, 3, 6, or 7 and can be expressed as
A1 = 2 + 3 + 6 + 7
Finally, A0 is always a 1 for decimal digit 1, 3, 5, 7, or 9. The expression for A0 is
A0 = 1 + 3 + 5 + 7 + 9
Now let’s implement the logic circuitry required for encoding each decimal digit to a
BCD code by using the logic expressions just developed. It is simply a matter of ORing the
appropriate decimal digit input lines to form each BCD output. The basic encoder logic
resulting from these expressions is shown in Figure 6–37.
The basic operation of the circuit in Figure above is as follows: When a HIGH appears on
one of the decimal digit input lines, the appropriate levels occur on the four BCD output
lines. For instance, if input line 9 is HIGH (assuming all other input lines are LOW), this
condition will produce a HIGH on outputs A0 and A3 and LOWs on outputs A1 and A2,
which is the BCD code (1001) for decimal 9.
MULTIPLEXER
A multiplexer (MUX) is a device that allows digital information from several sources to be
routed onto a single line for transmission over that line to a common destination. The basic
multiplexer has several data-input lines and a single output line. It also has data-select inputs,
which permit digital data on any one of the inputs to be switched to the output line.
Multiplexers are also known as data selectors.
A logic symbol for a 4-input multiplexer (MUX) is shown in Figure below. Notice that there
are two data-select lines because with two select bits, any one of the four data-input lines can
be selected.
In Figure above, a 2-bit code on the data-select (S) inputs will allow the data on the selected
data input to pass through to the data output. If a binary 0 (S1 = 0 and S0 = 0) is applied to the
data-select lines, the data on input D0 appear on the data-output line.
If a binary 1 (S1 = 0 and S0 = 1) is applied to the data-select lines, the data on input
D1 appear on the data output. If a binary 2 (S1 = 1 and S0 = 0) is applied, the data on D2
appear on the output. If a binary 3 (S1 = 1 and S0 = 1) is applied, the data on
D3 are switched to the output line. A summary of this operation is given in Table below.
Now let’s look at the logic circuitry required to perform this multiplexing operation. The data
output is equal to the state of the selected data input. You can therefore, derive a logic
expression for the output in terms of the data input and the select inputs.
The data output is equal to D0 only if S1 = 0 and S0 = 0: Y = D0S1S0.
The data output is equal to D1 only if S1 = 0 and S0 = 1: Y = D1S1S0.
The data output is equal to D2 only if S1 = 1 and S0 = 0: Y = D2S1S0.
The data output is equal to D3 only if S1 = 1 and S0 = 1: Y = D3S1S0.
When these terms are ORed, the total expression for the data output is
Y = D0S1S0 + D1S1S0 + D2S1S0 + D3S1S0
The implementation of this equation requires four 3-input AND gates, a 4-input OR gate, and
two inverters to generate the complements of S1 and S0, as shown in Figure below.
Because data can be selected from any one of the input lines, this circuit is also referred to as
a data selector.
DEMULTIPLEXER
Errors can occur as digital codes are being transferred from one point to another within a
digital system or while codes are being transmitted from one system to another. The errors
take the form of undesired changes in the bits that make up the coded information; that is, a 1
can change to a 0, or a 0 to a 1, because of component malfunctions or electrical noise. In
most digital systems, the probability that even a single bit error will occur is very small, and
the likelihood that more than one will occur is even smaller.
Nevertheless, when an error occurs undetected, it can cause serious problems in a digital
system.
The parity method of error detection in which a parity bit is attached to a group of
information bits in order to make the total number of 1s either even or odd (depending on the
system). In addition to parity bits, several specific codes also provide inherent error detection.
Parity Generator
If this device is used as an even parity generator, the parity bit is taken at the © Odd output
because this output is a 0 if there is an even number of input bits and it is a 1 if there is an odd
number. When used as an odd parity generator, the parity bit is taken at the © Even output
because it is a 0 when the number of inputs bits is odd.
At the demultiplexer end of the system, the data-select signals and the serial data stream are
applied to the demultiplexer. The data bits are distributed by the demultiplexer onto the
output lines in the order in which they occurred on the multiplexer inputs. That is, D0 comes
out on the D0 output, D1 comes out on the D1 output, and so on. The parity bit comes out on
the D7 output. These eight bits are temporarily stored and applied to the even parity checker.
Not all of the bits are present on the parity checker inputs until the parity bit D7 comes out
and is stored. At this time, the error gate is enabled by the data-select code 111.
If the parity is correct, a 0 appears on the © Even output, keeping the Error output at 0. If
the parity is incorrect, all 1s appear on the error gate inputs, and a 1 on the Error output
results.
SIGNAL CONVERTERS
Before getting into analog-to-digital converters (ADCs), let’s look briefly at an element that
is common to most types of ADCs and digital-to-analog converters (DACs). This element is
the operational amplifier, or op-amp for short.
An op-amp is a linear amplifier that has two inputs (inverting and noninverting) and one
output. It has a very high voltage gain and a very high input impedance, as well as a very low
output impedance. The op-amp symbol is shown in Figure below(a). When used as an
inverting amplifier, the op-amp is configured as shown in part (b). The feedback resistor,
Rf, and the input resistor, Ri, control the voltage gain according to the formula in Equation
12–2, where Vout/Vin is the closed-loop voltage gain (closed loop refers to the feedback
from output to input provided by Rf). The negative sign indicates inversion.
Vout/Vin= -Rf/Ri
In the inverting amplifier configuration, the inverting input of the op-amp is approximatelyat
ground potential (0 V) because feedback and the extremely high open-loop gain make the
differential voltage between the two inputs extremely small. Since the non inverting input is
grounded, the inverting input is at approximately 0 V, which is called virtual ground.
When the op-amp is used as a comparator, as shown (c), two voltages are applied to the
inputs. When these input voltages differ by a very small amount, the opamp is driven into one
of its two saturated output states, either HIGH or LOW, depending on which input voltage is
greater.
In order to better understand the operation of the successive-approximation ADC, let’s take a
specific example of a 4-bit conversion. Figure below illustrates the step-by-step conversion of
a constant input voltage (5.1 V in this case). Let’s assume that the DAC has the following
output characteristics: Vout = 8 V for the 2>3 bit (MSB), Vout = 4 V for the
2>2 bit, Vout = 2 V for the 2>1 bit, and Vout = 1 V for the 2>0 bit (LSB).
Figure (a) shows the first step in the conversion cycle with the MSB = 1. The output of the
DAC is 8 V. Since this is greater than the input of 5.1 V, the output of the comparator is
LOW, causing the MSB in the SAR to be reset to a 0.
Figure (b) shows the second step in the conversion cycle with the 2>2 bit equal to a
1. The output of the DAC is 4 V. Since this is less than the input of 5.1 V, the output of the
comparator switches to a HIGH, causing this bit to be retained in the SAR.
Figure (c) shows the third step in the conversion cycle with the 21 bit equal to a 1.
The output of the DAC is 6 V because there is a 1 on the 22 bit input and on the 21 bit input;
4 V + 2 V = 6 V. Since this is greater than the input of 5.1 V, the output of the comparator
switches to a LOW, causing this bit to be reset to a 0.
Figure (d) shows the fourth and final step in the conversion cycle with the 20 bit equal to a 1.
The output of the DAC is 5 V because there is a 1 on the 22 bit input and on the 20 bit input;
4 V + 1 V = 5 V.
The four bits have all been tried, thus completing the conversion cycle. At this point the
binary code in the register is 0101, which is approximately the binary value of the input of
5.1 V. Additional bits will produce an even more accurate result. Another conversion cycle
now begins, and the basic process is repeated. The SAR is cleared at the beginning of each
cycle.
Since there is practically no current into the op-amp inverting (-) input, all of the input
currents sum together and go through Rf. Since the inverting input is at 0 V (virtual ground),
the drop across Rf is equal to the output voltage, so Vout = IfRf.
The values of the input resistors are chosen to be inversely proportional to the binary weights
of the corresponding input bits. The lowest-value resistor (R) corresponds to the highest
binary-weighted input (2>3). The other resistors are multiples of R (that is, 2R, 4R, and 8R)
and correspond to the binary weights 2>2, 2>1, and 2>0, respectively. The input currents are
also proportional to the binary weights. Thus, the output voltage is proportional to the sum of
the binary weights because the sum of the input currents is through Rf.
Disadvantages of this type of DAC are the number of different resistor values and the fact
that the voltage levels must be exactly the same for all inputs. For example, an 8-bit converter
requires eight resistors, ranging from some value of R to 128R in binary-weighted steps. This
range of resistors requires tolerances of one part in 255 (less than 0.5%) to accurately convert
the input, making this type of DAC very difficult to mass-produce.
The general equation for a weighted resister DAC is therefore
MSB ]
Start by assuming that the D3 input is HIGH (+5 V) and the others are LOW (ground, 0 V).
This condition represents the binary number 1000. A circuit analysis will show that this
reduces to the equivalent form shown in Figure 12–30(a). Essentially no current goes
(b) Equivalent circuit for D3 = 0, D2 = 1, D1 = 0, D0 = 0
through the 2R equivalent resistance because the inverting input is at virtual ground. Thus,
all of the current (I = 5 V/2R) through R7 also goes through Rf, and the output voltage is -5
V.
The operational amplifier keeps the inverting (-) input near zero volts (L0 V) because of
negative feedback. Therefore, all current goes through Rf rather than into the inverting input.
Figure 12–30(b) shows the equivalent circuit when the D2 input is at +5 V and the others are
at ground. This condition represents 0100. If we thevenize looking from R8, we get 2.5 V in
series with R, as shown. This results in a current through Rf of I = 2.5 V/2R, which gives an
output voltage of -2.5 V. Keep in mind that there is no current into the opamp inverting input
and that there is no current through the equivalent resistance to ground because it has 0 V
across it, due to the virtual ground.
Figure(c) shows the equivalent circuit when the D1 input is at +5 V and the others are at
ground. This condition represents 0010. Again thevenizing looking from R8, you get
1.25 V in series with R as shown. This results in a current through Rf of I = 1.25 V/2R, which
gives an output voltage of -1.25 V.
In part (d), the equivalent circuit representing the case where D0 is at
+5 V and the other inputs are at ground is shown. This condition represents 0001.
Thevenizing from R8 gives an equivalent of 0.625 V in series with R as shown. The resulting
current through Rf is I = 0.625 V/2R, which gives an output voltage of -0.625 V.
Notice that each successively lower-weighted input produces an output voltage that is
halved, so that the output voltage is proportional to the binary weight of the input bits.
Resolution. The resolution of a DAC is the reciprocal of the number of discrete steps
in the output. This, of course, is dependent on the number of input bits. For example,
a 4-bit DAC has a resolution of one part in 24 - 1 (one part in fifteen). Expressed as
a percentage, this is (1/15)100 = 6.67%. The total number of discrete steps equals
2n - 1, where n is the number of bits. Resolution can also be expressed as the number
of bits that are converted.
Accuracy. Accuracy is derived from a comparison of the actual output of a DAC with
the expected output. It is expressed as a percentage of a full-scale, or maximum, output
voltage. For example, if a converter has a full-scale output of 10 V and the accuracy
is ;0.1%, then the maximum error for any output voltage is (10 V)(0.001) = 10 mV.
Ideally, the accuracy should be no worse than ;1/2 of a least significant bit. For an
8-bit converter, the least significant bit is 0.39% of full scale. The accuracy should be
approximately ;0.2%.
Linearity. A linear error is a deviation from the ideal straight-line output of a DAC.
A special case is an offset error, which is the amount of output voltage when the
input bits are all zeros.
Monotonicity. A DAC is monotonic if it does not take any reverse steps when it is
sequenced over its entire range of input bits.
Settling time. Settling time is normally defined as the time it takes a DAC to settle
within ;1/2 LSB of its final value when a change occurs in the input code.
Practice Questions