Unit 3 Combinational Logic
Unit 3 Combinational Logic
Combinational Logic
Combinational vs. Sequential Logic
In Out
Logic Logic
In Out
Circuit Circuit
State
X Difference
D
Y
X Half D
Y Subtractor B-OUT B-out
Full Subtractor
Subtracting two single-bit binary values, Y, B-in from a single-
Difference D X
bit value X produces a difference bit D and a borrow out B-out
bit. This is called full subtraction. XY
B-in 00 01 11 10
0 2 6 4
0 1 1
Full Subtractor Truth Table 1 3 7 5
Inputs Outputs 1 1 1 B-in
X Y B-in D B-out Y
0 0 0 0 0 S = X’Y’(B-in) + XY’(B-in)’ + XY’(B-in)’ + XY(B-in)
S = X Y (C-in)
0 0 1 1 1
0 1 0 1 1 Borrow B-out X
0 1 1 0 1 XY
1 0 0 1 0 B-in 00 01 11 10
0 2 6 4
1 0 1 0 0 0 1
1 1 0 0 0 1 3 7 5
1 1 1 1 B-in
1 1 1 1 1
Y
S(X,Y, C-in) = S (1,2,4,7)
B-out = X’Y + X’(B-in) + Y(B-in)
C-out(x, y, C-in) = S (1,2,3,7)
Full Subtractor
Parallel Binary Adders
An n-bit adder used to add two n-bit binary numbers can built by connecting in series n
full adders.
Each full adder represents a bit position j (from 0 to n-1).
Each carry out C-out from a full adder at position j is connected to the
carry in C-in of the full adder at the higher position j+1.
The output of a full adder at position j is given by:
Sj = Xj Yj Cj
Cj+1 = Xj .Yj + Xj . Cj + Y . Cj
In the expression of the sum Cj must be generated by the full adder at the lower position
j-1.
The propagation delay in each full adder to produce the carry is equal to two gate delays
= 2D
Since the generation of the sum requires the propagation of the carry from the lowest
position to the highest position , the total propagation delay of the adder is approximately:
Total Propagation delay = 2 nD
4-bit Ripple Carry Adder
Inputs to be added
Adds two 4-bit numbers:
X3X2X1X0 Y3Y2Y1Y0
X = X3 X2 X1 X0
Y = Y3 Y2 Y1 Y0
producing the sum S = S3 S2 S1 S0 ,
C-out = C4 from the most significant 4-bit
C4 C-out C-in C0 =0
position j=3 Adder
X3 Y3 X2 Y2 X1 Y1 X0 Y0
S3 S2 S1 S0
Sum output
An example of 4-bit addition
1
Let’s try1our initial
1 0
example: 1 1
A=1011 0
(eleven), 1
B=1110
(fourteen).
0
1 1 0
1 1 0 0 1
21
Binary Subtractor
The subtrcation A – B can be done by taking the 2’s
complement of B and adding it to A because A- B = A
+ (-B)
It means if we use the inveters to make 1’s
complement of B (connecting each Bi to an inverter)
and then add 1 to the least significant bit (by setting
carry C0 to 1) of binary adder, then we can make a
binary subtractor.
Binary Subtractor
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
Adder Subtractor
Carry Look-Ahead Adders
The disadvantage of the ripple carry adder is that the
propagation delay of adder (2 nD ) increases as the size of
the adder, n is increased due to the carry ripple through
all the full adders.
Carry look-ahead adders use a different method to create
the needed carry bits for each full adder with a lower
constant delay equal to three gate delays.
Pi= Ai XOR Bi
Gi=AiBi
Si =Pi XOR Ci
Ci+1 = Gi+Pici
Magnitude Comparator
It is a combinational circuit that compares to numbers
and determines their relative magnitude
The output of comparator is usually 3 binary variables
indicating: A>B
A=B
A<B
1-bit Magnitude Comparator
2-bit magnitude comparator
2-bit magnitude comparator
4-bit magnitude comparator
Algorithm
Algorithm -> logic
A = A3A2A1A0 ; B = B3B2B1B0
A=B if A3=B3, A2=B2, A1=B1and A1=B1
Test each bit:
equality: xi= AiBi+Ai'Bi'
(A=B) = x3x2x1x0
39
2-to-1 multiplexer
4-to-1 multiplexer
Symbol of Multiplexer
Output Waveforms in relation with the Data-Input and Data-Select
waveforms - 4-input MUX
43
8-input multiplexer
44
8-to-1 multiplexer from Smaller
MUX
16-to-1 multiplexer from 4:1 mux
Design 8 to 1 Multiplexer using 2 to
1 multiplexer.
LOGIC FUNCTION GENERATION USING MUX
Exercise 1:
Implement the logic circuit function specified in the table given below by using 74LS151
8-input data selector/multiplexer.
Input Output
A2 A1 A0 Y
0 0 0 0 0
0 0 1 1 1
0 1 0 0 2
0 1 1 1 3
1 0 0 0 4
1 0 1 1 5
1 1 0 1 6
1 1 1 0 7 48
Solution :
49
Exercise 2:
Implement the logic circuit function F= A XOR B XOR C by 8-input
data selector/multiplexer.
LOGIC FUNCTION GENERATION USING MUX-Method
52
LOGIC FUNCTION GENERATION USING MUX-Example 2
Implement the Boolean function F=x’y’z +x’yz’ + xyz’ + xyz
using a suitable MUX
0
1
2
3
54
LOGIC FUNCTION GENERATION USING MUX-Example 2
The two variables x and y are applied to the selection lines in that
order; x is connected to the S1 input and y to the S0 input.
The values for the data input lines are determined from the truth
table of the function
For ex., when xy=00, output F is equal to z because F=0 when z=0
and F=1 when z=1. This requires that variable z is applied to the data
input 0
55
LOGIC FUNCTION GENERATION USING MUX-Example 3
Implement the Boolean function F=A’B’C’D+A’B’CD+A’BC’D’
+AB’CD+ABC’D’+ABC’D+ABCD’+ABCD using a suitable MUX
0
1
2
3
4
5
6
7 58
Design the function F(a,b,c,d) = ∑m (0,3,6,7,11,14,15)
using 4 to 1 Multiplexer.
Design the function F(a,b,c,d) = ∑m
(0,3,6,7,11,14,15) using 4 to 1 Multiplexer.
DEMULTIPLEXERS
A DEMULTIPLEXER (DEMUX) basically reverses the
multiplexing function. It takes data from one line and
distributes them to a given number of output lines. For
this reason, the demultiplexers is also known as a data
distributor.
A multiplexer takes several inputs and transmits one of
them to the output.
A demultiplexer (DEMUX) performs the reverse
operation ; it takes a single input and distributes it over
several outputs.
62
1-line-to-4-line demultiplexer.
1-line-to-4-line demultiplexer.
64
The serial data input waveform (Data in) and data select inputs (So and S1)
and
the corresponding data output waveforms (D0 through D3) are shown
below
65
1-line- to-8 line demultiplexer
66
Implementation of Full Subtractor
Using 1-to-8 DEMUX
Example:
Decimal number 4926 4 9 2 6
V+
abcdef g .
74LS47
A3 g
A2 f
A1 e
A0 d
c
b
a
5V
test
RBI RBO
ENCODERS AND DECODERS
A0 O0 A0 O0
A1 O1 A1 O1
A2 O2 A2 O2
A3 ENCODER DECODER O3
A4 O4
A5 O5
A6 O6
A7 O7
S4 S3 S2 S1 S0
0 1 0 1 0 10
0 1 0 1 1 11
0 1 1 0 0 12
0 1 1 0 1 13
0 1 1 1 0 14
0 1 1 1 1 15
1 0 0 0 0 16
1 0 0 0 1 17
1 0 0 1 0 18
DesignBCD Adder. Using this 4-bit
parallel adder design BCD adder.
Whenever S4=1 (sums greater than 15)
Whenever S3=1 and either S2 or S1 or both are 1 (sums 10 to
15)
The previous table can be expressed as:
X = S4 + S3 ( S2 + S1)
So, whenever X = 1 we should add a correction of 0110 to the
sum.
DesignBCD Adder. Using this 4-bit
parallel adder design BCD adder.
Parity bit generator and checker
A parity bit 0 or 1 is attached such that total number of 1s in
the word is even for even parity and odd for odd parity.
At the receiving end if the word received has an even
number of 1s in the odd parity system or odd number of 1s
in the even parity system than error is occurred .
Modulo sum of even number of 1s =0
Modulo sum of odd number of 1s =1
If the modulo sum =0 in odd parity then error is detected
If modulo sum=1 for even parity then error occurred.
Design a POS circuit that will generate
an even parity bit for 4-bit input
Design a circuit that will generate an odd
parity bit for 4-bit input
FOUR BIT BINARY TO GRAY CODE CONVERTER –DESIGN
(1)…
MSB + + + + Binary code
0 1 1 0 1
TRUTH TABLE:
Gray code
0 1 0 1 1
INPUT ( BINARY) OUTPUTS (GRAY CODE)
B3 B2 B1 B0 G3 G2 G1 G0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 0
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 1
0 1 1 1 0 1 0 0
1 0 0 0 1 1 0 0
1 0 0 1 1 1 0 1
1 0 1 0 1 1 1 1
1 0 1 1 1 1 1 0
1 1 0 0 1 0 1 0
1 1 0 1 1 0 1 1
1 1 1 0 1 0 0 1
109 1 1 1 1 1 0 0 0
FOUR BIT BINARY TO GRAY CODE CONVERTER –DESIGN
(2)…
Simplification using K-maps:
110
FOUR BIT BINARY TO GRAY CODE CONVERTER –DESIGN (3)
Logic Diagram:
111
FOUR BIT GRAY CODE TO BINARY CONVERTER –DESIGN
(1)…
MSB + + + + Gray code
1 0 1 0 0
Truth Table:
Binary code
INPUT ( GRAY CODE) 1 1 )
OUTPUTS (BINARY 0 0 0
G3 G2 G1 G0 B3 B2 B1 B0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 0
0 1 0 0 0 1 1 1
0 1 0 1 0 1 1 0
0 1 1 0 0 1 0 0
0 1 1 1 0 1 0 1
1 0 0 0 1 1 1 1
1 0 0 1 1 1 1 0
1 0 1 0 1 1 0 0
1 0 1 1 1 1 0 1
1 1 0 0 1 0 0 0
1 1 0 1 1 0 0 1
1 1 1 0 1 0 1 1
112 1 1 1 1 1 0 1 0
FOUR BIT GRAY CODE TO BINARY CONVERTER –DESIGN
(2)…
Simplification using K-Maps:
113
FOUR BIT GRAY CODE TO BINARY CONVERTER –DESIGN
(3)…
Simplification using K-Maps:
114
FOUR BIT GRAY CODE TO BINARY CONVERTER –DESIGN (4)
Logic Diagram:
115
Exercise
Solution:
116
Binary to BCD code converter.
BCD to XS 3 code converter- Design (1)...
TRUTH TABLE FOR BCD TO XS3 CODE CONVERTER:
121
BCD to XS 3 code converter- Design (3)...
122
BCD to XS 3 code converter- Design (4)
123