Combinational Circuits
Combinational Circuits
X Half S
Y Adder C-OUT
Half Adder Truth Table
Inputs Outputs
X Y C-in S C-out
Full
0 0 0 0 0 C-out
Adder
C-in
0 0 1 1 0
0 1 0 1 0
S
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Full Adder
Sum S X
XY
C-in 00 01 11 10
X Y C-in S C-out 0 2 6 4
0 0 0 0 0 0 1 1
0 0 1 1 0 1
1
3 7
1
5
C-in
1
0 1 0 1 0
0 1 1 0 1 Y
Inputs Outputs
1 0 0 1 0
S = X’Y’(C-in) + XY’(C-in)’ + XY’(C-in)’ + XY(C-in)
1 0 1 0 1 S = X Y (C-in)
1 1 0 0 1
1 1 1 1 1 Carry C-out X
XY
C-in 00 01 11 10
Full Adder Truth Table 0 2 6 4
0 1
1 3 7 5
S(X,Y, C-in) = S (1,2,4,7) 1 1 1 1 C-in
X’ X’Y’C-in
X Y’
X X’ C-in
X’
X’YC-in’ Sum S
Y
Y C-in’
Y Y’ X
Y
C-in C-in’ X
Y
C-in’ XYC-in
X XY
Y
X
XC-in C-out
C-in
Y
C-in YC-in
Full Adder Circuit Using Ex-OR
X
Y Sum S
C-in
X
XY
X
XC-in C-out
C-in
C-in YC-in
Full Adder Circuit Using two half - Adders
Half Adder -1
Half Adder -2
Binary adder
• Binary adder that produces the arithmetic
sum of binary numbers can be constructed
with full adders connected in cascade, with
the output carry from each full adder is
connected to the input carry of the next full
adder in the chain
• Note that the input carry C0 in the least
significant position must be 0.
Binary Adder
C0 = 0
Binary Adder
• For example to add A= 1011 and B= 0011
subscript i: 3 2 1 0
Input carry: 0 1 1 0 Ci
Augend: 1 0 1 1 Ai
Addend: 0 0 1 1 Bi
--------------------------------
Sum: 1 1 1 0 Si
Output carry: 0 0 1 1 Ci+1
DECIMAL/BCD ADDER
Subtractors
Combinational Arithmetic
Circuits
Addition:
Half Adder (HA).
Full Adder (FA).
Binary Adder
BCD(Decimal) Adder.
Subtraction:
Half Subtractor.
Full Subtractor.
Multiplication:
Binary Multipliers.
Comparator:
Magnitude Comparator.
Combinational Arithmetic
Circuits
Multiplexers
Demultiplexers
Encoders
Decoders
Half Subtractor
Subtracting a single-bit binary value Y from anther X (I.e. X
-Y ) produces a difference bit D and a borrow out bit B-out.
This operation is called half subtraction and the circuit to
realize it is called a half subtractor.
D(X,Y) = S (1,2)
D = X’Y + XY’
D = XY
Half Subtractor Truth Table
Inputs Outputs B-out(x, y, C-in) = S (1)
X Y D B-out B-out = X’Y
0 0 0 0 Difference
X
0 1 1 1 D
Y
1 0 1 0
1 1 0 0 B-out
X Half D
Y Subtractor B-OUT
Binary Arithmetic Operations
Subtraction
Two binary numbers are subtracted by subtracting each pair of
bits together with borrowing, where needed.
Subtraction Example:
0 0 1 1 1 1 1 0 0 Borrow
X 229 1 1 1 0 0 1 0 1
Y - 46 - 0 0 1 0 1 1 1 0
183 1 0 1 1 0 1 1 1
Full Subtractor
Subtracting two single-bit binary Difference D X
values, Y, B-in from a single-bit value XY
X’
X’YB-in’ Difference D
Y
Y B-in’
Y Y’ X
Y
B-in B-in’ X
Y
B-in’ XYB-in
X Y X’ X’Y
Y
Full X’
B-out B-in X’B-in
Subtractor B-out
B-in
Y
D
B-in YB-in
Full Subtractor Circuit Using XOR
X
Y Difference D
X Y B-in
Full X’ X’Y
B-out B-in
Subtractor Y
X’
X’B-in
B-out
D B-in
Y
B-in YB-in
n-bit Subtractors
An n-bit subtracor used to subtract an n-bit number Y from another
n-bit number X (i.e X-Y) can be built in one of two ways:
=1
Adder Subtractor
• The addition and subtraction can be combined
into one circuit with one common binary
adder (see next slide).
• The mode M controls the operation. When
M=0 the circuit is an adder when M=1 the
circuit is subtractor. It can be don by using
exclusive-OR for each Bi and M. Note that 1 ⊕
x = x’ and 0 ⊕ x = x
Checking Overflow
• Note that in the previous slide if the numbers
considered to be signed V detects overflow. V=0
means no overflow and V=1 means the result is
wrong because of overflow
• Overflow can be happened when adding two
numbers of the same sign (both negative or positive)
and result can not be shown with the available bits.
It can be detected by observing the carry into sign bit
and carry out of sign bit position. If these two carries
are not equal an overflow occurred. That is why
these two carries are applied to exclusive-OR gate to
generate V.
Design example: 2x2-bit
multiplier
A2 A1 B2 B1 P8 P4 P2 P1
0 0 0 0 0 0 0 0
0 1 0 0 0 0
1 0 0 0 0 0
1 1 0 0 0 0
A1 P1 0 1 0 0 0 0 0 0
A2 P2 0 1 0 0 0 1
1 0 0 0 1 0
B1 P4 1 1 0 0 1 1
B2 P8 1 0 0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 0 1 1 0
1 1 0 0 0 0 0 0
block diagram 0 1 0 0 1 1
and 1 0 0 1 1 0
truth table 1 1 1 0 0 1
4-variable K-map
for each of the 4
output functions
Design example: 2x2-bit
multiplier (cont’d)
A2 A2
K-map for P8 K-map for P4
0 0 0 0 0 0 0 0
P4 = A2B2B1'
0 0 0 0 0 0 0 0
B1 + A2A1'B2 B1
0 0 1 0 0 0 0 1
B2 P8 = A2A1B2B1 B2
0 0 0 0 0 0 1 1
A1 A1
A2 A2
0 0 0 0
K-map for P2 K-map for P1 0 0 0 0
P1 = A1B1
0 0 1 1 0 1 1 0
B1 B1
0 1 0 1 0 1 1 0
B2 P2 = A2'A1B2 B2
0 1 1 0 + A1B2B1' 0 0 0 0
A1 + A2B2'B1 A1
+ A2A1'B1
Magnitude Comparator
Magnitude Comparator
• It is a combinational circuit that compares two
numbers and determines their relative magnitude
• The output of comparator is usually 3 binary
variables indicating: A>B
A=B
A<B
• For example to design a comparator for 2 bit binary
numbers A (A1A0) and B (B1B0) we do the following
steps:
Comparators
• For a 2-bit comparator we have four inputs A1A0 and B1B0 and three
output E ( is 1 if two numbers are equal), G (is 1 when A > B) and L (is 1
when A < B) If we use truth table and KMAP the result is
• E= A’1A’0B’1B’0 + A’1A0B’1B0 + A1A0B1B0 + A1A’0B1B’0
or E=(( A0 ⊕ B0) + ( A1 ⊕ B1))’ (see next slide)
• G = A1B’1 + A0B’1B’0 + A1A0B’0
• L= A’1B1 + A’1A’0B0 + A’0B1B0
A0
E
A1
Comparator G
B0
L
B1
Truth Table
A0 A1 B0 B1 E L G
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 0 1 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
Magnitude Comparator
1 0 0 0 0 1 0 0 0 0 1 1
D D D
1 1 0 1 0 0 1 0 0 0 0 0
C C C
1 1 0 0 0 0 0 1 0 0 1 0
B B B
two alternative
implementations of EQ
with and without XOR
EQ
0 0 0 0
G3’G2
1 1 1 1
G3G2
1 1 1 1
G3G2’
B3 = G3
K MAP For B2
G1’G0’ G1’G0 G1G0 G1G0’
0 0 0 0
G3’G2’
1 1 1 1
G3’G2
0 0 0 0
G3G2
1 1 1 1
G3G2’
B1 G3 G 2 G1
K MAP For B1
G1’G0’ G1’G0 G1G0 G1G0’
0 0 1 1
G3’G2’
1 1 0 0
G3’G2
0 0 1 1
G3G2
1 1 0 0
G3G2’
B1 G3 G 2 G1
K MAP For B0
G1’G0’ G1’G0 G1G0 G1G0’
0 1 0 1
G3’G2’
1 0 1 0
G3’G2
0 1 0 1
G3G2
1 0 1 0
G3G2’
B0 G3 G 2 G1 G0
B3 G3
B2 G2
B1 G1
G0
B0
Assignment
Design the Converter for
1. Binary to BCD
2. BCD to Gray
3. BCD to Binary
4. BCD to Excess
Analysis of Combinational Circuits
Designing Combinational Logic Circuits
•A logic circuit having 3 inputs, A, B,
C will have its output HIGH only
when a majority of the inputs are
HIGH.
Step 1 Set up the truth table
Step 2
Write the AND term for each case
where the output is a 1.
Sum-Of-Products Form
• SOP is useful in simplification and design
• Two or more AND terms OR together
–Ex: ABC+ABC
–the inversion sign cannot cover more than
one variable (ABC)
• Another general form for logic expressions is
sometimes used in logic-circuit design. It called
product-of-sum (POS)
• Consist 2 or more OR terms that are AND together.
- Ex: (A+B+C)(A+C)
Analysis of Logic Circuits
• First obtain one expression for the circuit, then try to simplify.
• Example:
SELECT INPUTS (aka ADDRESS LINES)- used by the mux to determine which data
inputs will be switched to the output.
if 2 N input lines N select lines
Example of a Combinatorial Circuit:
A Multiplexer (MUX)
I1
DATA
INPUTS Z I 0 S I1 S
I0
S S OUTPUT
SELECT INPUT
0 Z=I0
1 Z=I1
Example: A 4-to-1 Multiplexer
A 4-to-1 Multiplexer:
I0
2n inputs I1 Y
I2 4:1 MUX
1 output
I3
Enable (G) S0 S1
n control inputs
FOUR-INPUT MULTIPLEXER
I0
I1
I2
I3 S1 S0 OUTPUT
0 0 Z=I0
0 1 Z=I1
1 0 Z=I2
S1 S0 1 1 Z=I3
MULTIPLEXER LOGIC DIAGRAM
•Takes one of many inputs and funnels it to an output Z.
•Take the selector lines convert to a decimal number and this is the
input funneled to the output.
•DATA ROUTING
•PARALLEL-TO-SERIAL CONVERSION
•OPERATION SEQUENCING
•IMPLEMENT LOGIC FUNCTION OF A TRUTH
TABLE
LOGIC FUNCTION GENERATION
+5
I0
C B A Z
I1
0 0 0 0
I2 74151
Z ABC ABC ABC 0 0 1 1
I3
I4 MUX 0 1 0 1
I5
0 1 1 0
I6 1 0 0 0
I7 1 0 1 0
E 1 1 0 0
S2 S1 S0 1 1 1 1
DEMULTIPLEXER
DEMULTIPLEXER LOGIC DIAGRAM
•Logic circuit that depending on the status of its select inputs will funnel
its data input to one of several data outputs.
•Separate enable inputs (useful for cascading decoders) into AND gate
which must be high to enable the decoder outputs.
O0
E3 O1
E2 74138 O2
E
DEMUX O3
E1 1-OF-8 DECODER E1 E 2 E3 OUTPUTS
O4
0 0 1 RESPOND TO INPUT CODE A2A1A0
O5 1 X X DISABLED –ALL HIGH
X 1 X DISABLED –ALL HIGH
O6 X X 0 DISABLED –ALL HIGH
O7
A2 A1 A0
SELECT LINES
LOGIC FUNCTION GENERATION
74138
O0
O1
O2
+5
O3 f(ABC)
E3 O4
O5
E2
O6
C B A f
E1 O7
0 0 0
A2 A1 A0 0 0 1
0 1 0
C B A 0 1 1
1 0 0
A B X
1 0 1
0 0 1 1 1 0
0 1 1 1 1 1
1 0 1
1 1 0
DECODERS
116
DECODER
•A decoder is a logic circuit that accepts a set of inputs that
represents a binary number and activates only the output
that corresponds to the input number.
•In other words, a decoder circuit looks at its inputs,
determines which binary number is present there, and
activates the one output that corresponds to that number ;
all other outputs remain inactive
117
Decoding logic for the binary code 1001 with an active-HIGH output.
119
General decoder diagram
For each of these input combinations only one of the M outputs will be active HIGH (1),
all the other outputs are LOW (0).
120
2-to-4-Line Decoder
(with Enable input)-Active LOW output (1)...
122
2-to-4-Line Decoder
(with Enable input)-Active LOW output (2)
•Decoders are used in many types of applications. One example is in computers for I/O
selection as in previous slide
•Computer must communicate with a variety of external devices called peripherals by sending
and/or receiving data through what is known as input/output (I/O) ports
•Each I/O port has a number, called an address, which uniquely identifies it. When the
computer wants to communicate with a particular device, it issues the appropriate address
code for the I/O port to which that particular device is connected . The binary port address is
decoded and appropriate decoder output is activated to enable the I/O port
•Binary data are transferred within the computer on a data bus, which is a set of parallel lines
134
BCD -to- Decimal decoders
BCD-7segment decoders/drivers
7-segment decoder
Example:
In a 6-digit display the number 6.4 may be displayed as
006.400 if the zeros are not blanked out
145
7-segment display
Common Anode
In commonanode, the anode of all of the LEDs are tied together to positive of
the power supply (Vcc) as shown
148
Common Cathode
GND
149
A low at any single input will produce the output binary code corresponding to that
input. For instance , a low at A3’ will produce O2 =0, O1=1 and O0 =1, which is
binary code for 3. Ao’ is not connected to the logic gates because the encoder
outputs always be normally at 0000 when none of the inputs is LOW
Design of 4-input Priority Encoder
( 4-line-to 2 line priority encoder) (1)...
• A priority encoder is an encoder that includes the priority
function
• If two or more inputs are equal to 1 at the same time, the
input having the highest priority will take precedence.
• Truth Table of a 4-input Priority Encoder:
Inputs Outputs
D0 D1 D2 D3 x y V
0 0 0 0 X X 0
1 0 0 0 0 0 1
X 1 0 0 0 1 1
X X 1 0 1 0 1
X X X 1 1 1 1
Design of 4-input Priority Encoder
( 4-line-to 2 line priority encoder) (2)...
V=D0+D1+D2+D3
K-Maps for 4-input Priority Encoder
Design of 4-input Priority Encoder
( 4-line-to 2 line priority encoder) (4)
•For instance if the input 6 and the 3 are active, the output
will be 1001, which is the inverse value of BCD output 0110
(which represents decimal 6)
74147 decimal-BCD priority encoder
• ActiveLOW enable output, the output pin goes LOW when all
inputs are inactive (HIGH) and is LOW.
•When a key is depressed, the line is connected to ground, and a LOW is applied
to the corresponding encoder input.
•The zero key is not connected because the BCD output represents zero when
none of the other keys is depressed
•The BCD complement output of the encoder goes into a storage device, and
each successive BCD code is stored until the entire number has been entered
Assignment