Anupam Sir DLD3
Anupam Sir DLD3
Anupam Sir DLD3
E-CONTENTS :
Unit: 3
Name of the Topics:
Developed By:
Lecturer in Computer Science &Technology
Boolean Algebra is the mathematics we use to analyse digital gates and circuits. We
can use these “Laws of Boolean” to both reduce and simplify a complex Boolean
expression in an attempt to reduce the number of logic gates required. Boolean
Algebra is therefore a system of mathematics based on logic that has its own set of
rules or laws which are used to define and reduce Boolean expressions.
The variables used in Boolean Algebra only have one of two possible values, a logic
“0” and a logic “1” but an expression can have an infinite number of variables all
labelled individually to represent inputs to the expression, For example, variables A, B,
C etc, giving us a logical expression of A + B = C, but each variable can ONLY be a 0
or a 1.
As well as the logic symbols “0” and “1” being used to represent a digital input or
output, we can also use them as constants for a permanently “Open” or “Closed” circuit
or contact respectively.
Annulment Law – A term AND´ed with a “0” equals 0 or OR´ed with a “1” will equal 1
Identity Law – A term OR´ed with a “0” or AND´ed with a “1” will always equal that
term
Idempotent Law – An input that is AND´ed or OR´ed with itself is equal to that input
Commutative Law – The order of application of two separate terms is not important
Double Negation Law – A term that is inverted twice is equal to the original term
(1) Two separate terms NOR´ed together is the same as the two terms inverted
(Complement) and AND´ed for example: 𝐴 ̅̅̅̅̅̅̅̅
+ 𝐵= A̅ . B̅
(2) Two separate terms NAND´ed together is the same as the two terms inverted
(Complement) and OR´ed for example: ̅̅̅̅̅
𝐴. 𝐵 = A̅ + B̅
Distributive Law – This law permits the multiplying or factoring out of an expression.
Examples:
Q= (A + B).(A + C)
Q= AB + A(B + C) + B(B + C)
AB + AB + AC + BB + BC – Distributive law
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
Note that the Boolean Expression for a two input AND gate can be written as: A.B or
just simply AB without the decimal point.
A B Q
0 0 0
0 1 1
1 0 1
1 1 1
A Q
0 1
1 0
The NAND and the NOR Gates are a combination of the AND and OR Gates
respectively with that of a NOT Gate (inverter).
A B Q
0 0 1
0 1 1
1 0 1
1 1 0
̅̅̅̅̅̅
Boolean Expression Q = 𝐴 .𝐵 Read as A AND B gives NOT-Q
A B Q
0 0 1
0 1 0
1 0 0
1 1 0
As well as the standard logic gates there are also two special types of logic gate
function called an Exclusive-OR Gate and an Exclusive-NOR Gate. The Boolean
expression to indicate an Exclusive-OR or Exclusive-NOR function is to a symbol with a
plus sign inside a circle, ( ⊕ ).
The switching actions of both of these types of gates can be created using the above
standard logic gates. However, as they are widely used functions they are now
available in standard IC form and have been included here as reference.
A B Q
0 0 0
0 1 1
1 0 1
1 1 0
Boolean Expression Q = A ⊕ B
A B Q
0 0 1
0 1 0
1 0 0
1 1 1
̅̅̅̅̅̅̅̅̅̅
Boolean Expression Q = 𝐴 ⊕ 𝐵
Sum of Products
So we have seen that the AND function produces the logical product of Boolean
multiplication, and that the OR function produces the logical sum of Boolean addition.
But when dealing with combinational logic circuits in which AND gates, OR gates
and NOT gates are connected together, the expressions of Sum-of-
Products and Product-of-Sums are widely used.
The Sum of Product (SOP) expression comes from the fact that two or more products
(AND) are summed (OR) together. That is the outputs from two or more AND gates are
connected to the input of an OR gate so that they are effectively OR’ed together to
create the final AND-OR logical output. For example, the following Boolean function is a
typical sum-of-product expression:
Sum-of-Product Example
The following Boolean Algebra expression is given as:
Q = A̅(B̅C + BC + BC̅) + ABC
1. Convert this logical equation into an equivalent SOP term.
2. Use a truth table to show all the possible combinations of input conditions that will
produces an output.
Bipradas Pal Chowdhury Institute of Technology, Digital Logic Design 17 | P a g e
3. Draw a logic gate diagram for the expression.
1. Convert to SOP term
Q = A.B.C + A̅.B̅.C + A̅.B.C + A̅.B.C̅
2. Truth Table
Sum of Product Truth Table Form
Then we have seen in this tutorial that the Sum-of-Products (SOP) expression is a
standard boolean expression that “Sums” two or more “Products” and that for a digital
logic circuit an SOP expression takes the output of two or more logic AND gates
and OR’s them together to create the final (AND-OR) output.
1. Truth Table
Then we have seen in this tutorial that the Product-of-Sum (POS) expression is a
standard boolean expression that takes the “Product” of two or more “Sums”. For a
digital logic circuit the POS expression takes the output of two or more logic OR gates
and AND’s them together to create the final OR-AND logic output.
Bipradas Pal Chowdhury Institute of Technology, Digital Logic Design 20 | P a g e
3.4 K-map representation of logical functions and
minimization (2,3,4 variable).
Karnaugh Maps (K-maps) :
• Karnaugh maps -- A tool for representing Boolean functions of up to
six variables.
• K-maps are tables of rows and columns with entries represent 1`s or
0`s of SOP and POS representations.
• An n-variable K-map has 2n cells with each cell corresponding to an n-
variable truth table value.
• K-map cells are labeled with the corresponding truth-table row.
• K-map cells are arranged such that adjacent cells correspond to truth
rows that differ in only one bit position (logical adjacency).
Minimization with Karnaugh Maps and advantages of K-map
K-maps are used to convert the truth table of a Boolean equation into minimized
SOP form.
Easy and simple basic rules for the simplification.
The K-map method is faster and more efficient than other simplification techniques
of Boolean algebra.
All rows in the K-map are represented by using a square shaped cells, in which
each square in that will represent a minterm.
It is easy to convert a truth table to k-map and k-map to Sum of Products form
equation.
1. Un-optimized form
2. Optimized form
Un-optimized form: It involves in converting the number of 1’s into equal number of
product terms (min terms) in an SOP equation.
Optimized form: It involves in reducing the number of min terms in the SOP
equation.
Note that the Gray code sequence, above right, only varies by one bit as we go down
the list, or bottom to top up the list. This property of Gray code is often useful for
digital electronics in general. In particular, it is applicable to Karnaugh maps.
The possible min terms with 2 variables (A and B) are A.B, A.B̅, A̅.B and A̅.B̅. The
conjunctions of the variables (A, B) and (A̅, B) are represented in the cells of the top
row and (A, B̅) and (A̅, B̅) in cells of the bottom row. The following table shows the
positions of all the possible outputs of 2-variable Boolean function on a K-map.
When we are simplifying a Boolean equation using Karnaugh map, we represent the
each cell of K-map containing the conjunction term with 1. After that, we group the
adjacent cells with possible sizes as 2 or 4. In case of larger k-maps, we can group the
variables in larger sizes like 8 or 16.
Example
1. Simplify the given 2-variable Boolean equation by using K-map.
F = A B̅ + A̅ B + A̅B̅
First, let’s construct the truth table for the given equation,
Solution:
A typical plot of a 3-variable K-map is shown below. It can be observed that the
positions of columns 10 and 11 are interchanged so that there is only change in one
variable across adjacent cells. This modification will allow in minimizing the logic.
Up to 8 cells can be grouped in case of a 3-variable K-map with other possibilities being
1,2 and 4.
Example
1. Simplify the given 3-variable Boolean equation by using k-map.
F = X’ Y Z + X’ Y’ Z + X Y Z’ + X’ Y’ Z’ + X Y Z + X Y’ Z’
First, let’s construct the truth table for the given equation,
There are 8 cells (23) in the 3-variable k-map. It will look like (see below image).
The largest group size will be 8 but we can also form the groups of size 4 and size 2, by
possibility. In the 3 variable Karnaugh map, we consider the left most column of the k-
map as the adjacent column of rightmost column. So the size 4 group is formed as
shown below.
And in both the terms, we have ‘Y’ in common. So the group of size 4 is reduced as the
conjunction Y. To consume every cell which has 1 in it, we group the rest of cells to
form size 2 group, as shown below.
2.
A typical 4-variable K-map plot is shown below. It can be observed that both the
columns and rows of 10 and 11 are interchanged.
The possible number of cells that can be grouped together are 1, 2, 4, 8 and 16.
F = W Y’ Z + W ‘Y’ Z
A variable is in complemented form, if its value is assigned to 0, and the variable is un-
complimented form, if its value is assigned to 1.
For a 3-variable (x, y and z) Boolean function, the possible minterms are:
Any Boolean function can be expressed as the sum (OR) of its 1- min terms. The
representation of the equation will be
The inverse of the function can be expressed as a sum (OR) of its 0- min terms. The
representation of the equation will be
Examples of canonical form of sum of products expressions (min term canonical form):
i) Z = XY + XZ′
In standard SOP form, the maximum possible product terms for n number of variables
are given by 2ⁿ. So, for 2 variable equations, the product terms are 22 = 4. Similarly, for
3 variable equations, the product terms are 23 = 8.
For a 2-variable (x and y) Boolean function, the possible max terms are:
For a 3-variable (x, y and z) Boolean function, the possible maxterms are:
Any Boolean function can be expressed the product (AND) of its 0 – max terms. The
representation of the equation will be
The inverse of the function can be expressed as a product (AND) of its 1 – max terms.
The representation of the equation will be
Examples of canonical form of product of sums expressions (max term canonical form):
i. Z = (X + Y) (X + Y′)
In standard POS form, the maximum possible sum terms for n number of variables are
given by 2ⁿ. So, for 2 variable equations, the sum terms are 22 = 4. Similarly, for 3
variable equations, the sum terms are 23 = 8.
Example:
Step 2: writing the missing indexes of the terms, 001, 100 and 110. Now write the sum
form for these noted terms.
Example:
Step 2: writing the missing indexes of the terms, 000, 001, 100, 110, and 111. Now
write the product form for these noted terms.
110 = A * B* C’ 111 = A * B * C
circuit using basic gates and universal gates of: (a) Half adder
and full adder. (b) Half subtractor and full subtractor. Binary
parallel adder, adder-subtractor, BCD adder.
Half Adder
TRUTH TABLE:
K-Map
Full Adder
TRUTH TABLE:
Half subtractor
TRUTH TABLE:
Full subtractor
TRUTH TABLE:
The output will varies from 0 to 18, if we are not considering the carry
from the previous sum. But if we are considering the carry, then the
maximum value of output will be 19 (i.e. 9+9+1 = 19).
When we are simply adding A and B, then we get the binary sum. Here,
to get the output in BCD form, we will use BCD Adder.
Example 1:
Input :
A = 0111 B = 1000
Output :
Y = 1 0101
Input :
A = 0101 B = 1001
Output :
Y = 1 0100
4x1 Multiplexer
4x1 Multiplexer has four data inputs I3, I2, I1 & I0, two selection lines s1 & s0 and one output Y.
The block diagram of 4x1 Multiplexer is shown in the following figure.
One of these 4 inputs will be connected to the output based on the combination of inputs present
at these two selection lines. Truth table of 4x1 Multiplexer is shown below.
S1 S0 Y
0 0 I0
0 1 I1
1 0 I2
1 1 I3
8x1 Multiplexer
In this section, let us implement 8x1 Multiplexer using 4x1 Multiplexers and 2x1 Multiplexer. We
know that 4x1 Multiplexer has 4 data inputs, 2 selection lines and one output. Whereas, 8x1
Multiplexer has 8 data inputs, 3 selection lines and one output.
We can implement 8x1 Multiplexer using lower order Multiplexers easily by considering the above
Truth table. The block diagram of 8x1 Multiplexer is shown in the following figure.
The same selection lines, s1 & s0 are applied to both 4x1 Multiplexers. The data inputs of upper
4x1 Multiplexer are I7 to I4 and the data inputs of lower 4x1 Multiplexer are I 3 to I0. Therefore, each
4x1 Multiplexer produces an output based on the values of selection lines, s1 & s0.
Multiplexer (8:1mux)
The Boolean expression for this 1-to-4 Demultiplexer above with outputs A to D and
data select lines a, b is given as:
F = ̅̅̅
𝑎𝑏A + a̅bB + ab̅C + abD
1-to-8 Demultiplexer
The below figure shows the block diagram of a 1-to-8 demultiplexer that consists of
single input D, three select inputs S2, S1 and S0 and eight outputs from Y0 to Y7.
It is also called as 3-to-8 demultiplexer due to three select input lines. It distributes one
input line to one of 8 output lines depending on the combination of select inputs.
The truth table for this type of demultiplexer is shown below. The input D is connected
with one of the eight outputs from Y0 to Y7 based on the select lines S2, S1 and S0.
For example, if S2S1S0=000, then the input D is connected to the output Y0 and so on.
From these obtained equations, the logic diagram of this demultiplexer can be
implemented by using eight AND gates and three NOT gates as shown in below figure.
The different combinations of the select lines , select one AND gate at given time , such
that data input will appear at a particular output.
Fig.(a) demonstrates the logic diagram of a 1-to-16 demultiplexer, contains 8 NOT gates, 16 NAND
gates, one data input line(G), 4 select lines (A,B,C,D) and 16 output lines (that is D0, D1, D2 ------D16).
8 NOT gates stop excessive loading of the driving source. Individual data input line G is implemented
along with a NOR gate utilized as negative AND gate. A low level in all input G1 and G2 is needed to
make the output G high. The output G of allows is one of the inputs to whole 16 NAND gates. G should
be high for the gates to be allowed. If allow or enable gate is not activated so all 16 de-multiplexer outputs
will be high not respective of the state of the select lines A, B, C, D.
Truth Table
For example, if the application needs 32 output lines from a DEMUX, then we cascade
two 1:16 demultiplexers or three 1:8 demultiplexers. Therefore, by cascading the two or
more demultiplexers, a large demultiplexer can be implemented.
Consider the case that a 1-to-8 demultiplexer can be implemented by using two 1-to-4
demultiplexers with a proper cascading.
In the above figure, the highest significant bit A of the selection inputs are connected to
the enable inputs such that it is complemented before connecting to one DEMUX and
to the other it is directly connected.
By this configuration, when A is set to zero, one of the output lines from Y0 to Y3 is
selected based on the combination of select lines B and C. Similarly, when A is set to
one, based on the select lines one of the output lines from Y4 to Y7 will be selected.
As seen from the truth table, the output is 000 when D0 is active; 001 when D1 is active; 010 when
D2 is active and so on.
Implementation –
From the truth table, the output line Z is active when the input octal digit is 1, 3, 5 or 7. Similarly, Y
is 1 when input octal digit is 2, 3, 6 or 7 and X is 1 for input octal digits 4, 5, 6 or 7. Hence, the
Boolean functions would be:
X = D4 + D5 + D6 + D7
Y = D2 +D3 + D6 + D7
One limitation of this encoder is that only one input can be active at any given time. If more than
one inputs are active, then the output is undefined. For example, if D6 and D3 are both active,
then, our output would be 111 which is the output for D7. To overcome this, we use Priority
Encoders.
Another ambiguity arises when all inputs are 0. In this case, encoder outputs 000 which actually is
the output for D0 active. In order to avoid this, an extra bit can be added to the output, called the
valid bit which is 0 when all inputs are 0 and 1 otherwise.
Decoders –
A decoder does the opposite job of an encoder. It is a combinational circuit that converts n lines of
input into 2n lines of output.
Let’s take an example of 3-to-8 line decoder.
A demultiplexor receives as input, selection lines and one Input line. These selection lines
are used to select one output line out of possible lines. To implement a demultiplexor, we
use a decoder with Enable input. The selection lines of the demultiplexer are
the input lines that the decoder gets and the one input line of demulitplexer is the Enable input
of the Decoder.
Making 1:4 demultiplexer using 2:4 Decoder with Enable input. Let A, B be the selection lines and
EN be the input line for the demultiplexer.
The decoder shown below functions as a 1:4 demultiplexer when EN is taken as a data input line
and A and B are taken as the selection inputs. The single input variable E has a path to all four
outputs, but the input information is directed to only one of the output lines, as specified by the
binary combination of the two selection lines A and B. This can be verified from the truth table of
the circuit.
Truth Table-
The following circuit diagram shows the implementation of Full adder using a 3:8 Decoder and OR
gates.
Excess-3 code:
It is a non-weighted code. It is also a self-complementing BCD code used in decimal
arithmetic units. . The Excess-3 code for the decimal number is performed in the same
manner as BCD except that decimal number 3 is added to the each decimal unit before
encoding it to binary.
Code Converters:
The availability of a large variety of codes for the same discrete elements of information
results in the use of different codes by different digital systems. It is some time
necessary to use the output of one system as the input to the other. The conversion
circuit must be inserted between the two systems if each uses different codes for the
same information. Thus a code converter is a circuit that makes the two systems
compatible even though each uses the different code.
Truth Table:
Equations:
Diagram:
Equations:
Diagram:
To convert from binary code A to binary code B, the input lines must supply the bit combination of elements as
specified by code A and the output lines must generate the corresponding bit combination of code B. A combinational
circuit performs this transformation by means of logic gates. As we want to design 4-bit code, we must use four
input variables and four output variables. Designate the four input binary variables by the symbols A,B,C,D, and the
four output variables by w, x, y, and z. The truth table relating the input and output variables is as shown. A two-
level logic diagram may be obtained directly from the Boolean expressions derived by the maps. The expressions
obtained may be manipulated for the purpose of using common gates for two or more outputs. This manipulation
illustrates flexibility obtained with multiple-output systems when implemented with three or more levels of gates.
Equations:
z=D
y = CD+C’D’=CD(C+D)’
x = B’C+B’D+BC’D’= B’(C+D) +BC’D’
x = B’(C+D) +B(C+D)’
w = A+BC+BD=A+B(C+D)
Diagram:
0 0 0 0 0 0
0 0 1 0 0 1
0 1 0 0 1 1
0 1 1 0 1 0
1 0 0 1 1 0
1 0 1 1 1 1
1 1 0 1 0 1
1 1 1 1 0 0
Note: Notice how each subsequent gray code number differs with its predecessor by
only one bit.
Based on this
G3 = B3
G2 = B2 B3
G1 = B1 B2
G0 = B0 B1
The equations above indicate the presence of three EXOR gates. Therefore the simple
combinational circuit for 4-bit binary to gray code converters is as shown below.
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
1 1 1 1 1 0 0 0
Based on this
B2 = G2
B1 = G1 B2
B0 = G0 B1
0 0 0 0 0 0
0 0 1 0 0 1
0 1 0 0 1 1
0 1 1 0 1 0
1 0 0 1 1 1
1 0 1 1 1 0
1 1 0 1 0 0
1 1 1 1 0 1
B3 = G3
B2 = G2 B3
B1 = G1 B2
B0 = G0 B1
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 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
1 1 1 1 1 0 1 0
The circuit obtained by olving the K-maps for the above truth table is as below.
0 0 0 0 1 1
0 0 1 1 0 0
0 1 0 1 0 1
0 1 1 1 1 0
1 0 0 1 1 1
1 0 1 x x x
1 1 0 x x x
1 1 1 x x x
Let’s obtain the equations for the code converter circuit using K-maps.
E0 = B0′
Hence, from the equations above we can design the following combinational logic
circuit for 3-bit binary to excess 3 code converter circuit.
0 0 0 0 0 0 1 1
0 0 0 1 0 1 0 0
0 0 1 0 0 1 0 1
0 0 1 1 0 1 1 0
0 1 0 0 0 1 1 1
0 1 0 1 1 0 0 0
0 1 1 0 1 0 0 1
0 1 1 1 1 0 1 0
1 0 0 0 1 0 1 1
1 0 0 1 1 1 0 0
1 0 1 0 1 1 0 1
1 0 1 1 1 1 1 0
1 1 0 0 1 1 1 1
1 1 0 1 x x x x
1 1 1 0 x x x x
1 1 1 1 x x x x
Using Kmaps, we will solve for the output terminals. Remember that since we have
don’t care conditions, there are more than one correct options for reducing the Kmap.
You might end up with different equations than the ones in this post.
You should always try to optimize for the equation that requires you to employ the least
number of logic gates.
This is because when you etch a logic circuit into an IC chip, the real estate of the chip
is an expensive resource. And the least number of logic gates that you use, the higher
will be the judicious use of space on the IC.
This BCD to seven segment decoder has four input lines (A, B, C and D) and 7 output lines (a, b,
c, d, e, f and g), this output is given to seven segment LED display which displays the decimal
number depending upon inputs.
The circuit design, as well as operation, mainly depends on the concepts of Boolean
algebra as well as logic gates. A seven segment LED display circuit can be built with eight
LEDs. The common terminals are either anode otherwise cathode. A general cathode seven
segment display includes 8 pins where 7-pins are input pins that are marked with from a to
g & 8th-pin is a ground pin.
The designing of BCD to seven segment display decoder circuit mainly involves four steps
namely analysis, truth table design, K-map and designing a combinational logic circuit using
logic gates.
The first step of this circuit design is an analysis of the common cathode seven segment
display. This display can be constructed with seven LEDs in the form of H. A truth table of
this circuit can be designed by the inputs combinations for every decimal digit. For instance,
decimal number ‘1’ would control a blend of b & c.
The second step is the truth table design by listing the display input signals-7, equivalent
four-digit binary numbers as well as decimal number.
The designing of the truth table for the decoder mainly depends on the kind of display.
Already we have discussed above that is, for a common cathode display, the decoder output
must be high in order to blink the segment.
The tabular form of a BCD to 7-segment decoder with a common cathode display is shown
below. The truth table consists of seven o/p columns equivalent to each of the seven
segments. For example, the column for a-segment illustrates the various arrangements for
Bipradas Pal Chowdhury Institute of Technology, Digital Logic Design 89 | P a g e
which it is to be light up. Thus ‘a’- segment is energetic for the digits like 0, 2, 3, 5, 6, 7, 8 &
9.
By using the above truth table, for every output function, the Boolean expression can be
written.
a = F1 (X, Y, Z, W) = ∑m (0, 2, 3, 5, 7, 8, 9)
c = F3 (X, Y, Z, W) = ∑m (0, 1, 3, 4, 5, 6, 7, 8, 9)
d = F4 (X, Y, Z, W) = ∑m (0, 2, 3, 5, 6, 8)
f = F6 (X, Y, Z, W) = ∑m (0, 4, 5, 6, 8, 9)
g = F7 (X, Y, Z, W) = ∑m (2, 3, 4, 5, 6, 8, 9)
a = X+Z+YW+Y’W’
b = Y’+Z’W’+ZW
c= Y+Z’+W
d = Y’W’+ZW’+YZ’W+Y’Z+X
e= Y’W’+ZW’
f= X + Z’W’+YZ’+YW’
g = X+YZ’+Y’Z+ZW’
The final step of this is a designing of a logic circuit using the above k-map equations. A
combinational circuit can be built by using 4-inputs namely A, B, C, D and outputs on display
like a, b, c, d, e, f, g. The operation of the above logic circuit can be understood with the help
of truth table only. Once all the i/ps are connected to small logic.
Then the combinational logic circuit’s output will drive each and every one of output LEDs
apart from ‘g’ to transmission. Therefore the number ‘0’ will be exhibited. Similarly, for all
another grouping of the input switches, the same process would take place.
A decoder is one kind of combinational logic circuit that connects the binary data from n-
input lines toward 2n output lines. The IC7447 IC is a BCD to seven segment decoder. This
IC7447 gets the binary coded decimal like the input as well as gives the outputs like the
related seven-segment code.
A detailed discussion of digital comparator and magnitude comparator mainly includes the
following.
As data comparison is mostly required in many digital systems at the time of logical or
arithmetic functions, digital comparators are the one best option to compare data. Digital
comparators are the most appropriate combinational logic circuits used to compare relative
magnitudes of two binary numbers.
The device accepts two binary numbers (A and B)as input and generates an output based
on the magnitude of given inputs (example: A=B or A>B or A<B). Digital Comparators are
developed through logic gates like AND, NOT or NOR gates. Digital comparators are available
as identity comparators and magnitude comparators.
What is Magnitude Comparator?
Magnitude comparators are mostly utilized in microcontrollers and CPUs to address data
comparison, register and perform all other arithmetic operations. Magnitude comparators
Bipradas Pal Chowdhury Institute of Technology, Digital Logic Design 96 | P a g e
are implemented in many devices and every auto-turn-off device is surely designed using a
comparator.
A comparator is a decision-making tool and it holds the ability to be executed in numerous
control devices. Accepting two binary numbers as input (A and B), data comparison through
magnitude comparators produces the output to indicate equality (A=B), logic 1 in two
conditions when (A>B or A<B).
There are different kinds of magnitude comparators which include the following.
Truth Table
B A<B A>B
A A=B
0
0 0 0 1
0 0
1 1 0
0
1 0 0 1
1
1 1 0 0
The truth table derives the expressions of A<B, A>B and A=B as below
A<B – A’B
A>B – AB’
A=B – A’B’+AB
With these expressions, the Circuit diagram can be as follows
Truth Table
A0 B1 B0 A<B A=B A>B
A1
0
0 0 0 0 1 0
0 0
0 0 1 1 0
0
0 0 1 0 1 0
0 0
0 1 1 1 0
1
0 1 0 0 0 0
0 0
1 0 1 0 1
0 0 0
1 1 0 1
0 0
1 1 1 1 0
1 0 1
0 0 0 0
1 0 0
1 0 0 1
1 0
0 1 1 1 0
1
1 0 0 0 0 1
1 1
1 0 1 0 0
1 1
1 1 0 0 0
0
1 1 1 1 0 1
The truth table derives the expressions of A<B, A>B, and A=B as below
2-bit magnitude
Bipradas Pal Chowdhury Institute of Technology, Digital Logic Design 99 | P a g e
3-bit Magnitude Comparator
A comparator that compares two binary numbers (each number having 3 bits) and produces
three outputs based on the relative magnitudes of given binary bits is called a 3-bit
magnitude comparator.
3-bit magnitude
A<B = A3‘B3 + (A3 Ex-Nor B3) A2’B2 + (A3 Ex-Nor B3) (A2 Ex-Nor B2) A1’B1 + (A3 Ex-
Nor B3) (A2 Ex-Nor B2) (A1 Ex-Nor B1) A0’B0
And similarly, A=B can be expressed as
A=B = (A3 Ex-Nor B3) (A2 Ex-Nor B2) (A1 Ex-Nor B1)(A0 Ex-Nor B0)
With these expressions, the Circuit diagram can be as follows.
Mostly, 4-bit comparators are in the form of IC’s and the IC 7485 is widely used. Data
comparison can be performed by grounding A>B, A<B and A+B inputs to the Vcc terminal.
Furthermore, this integrated circuit performs a cascading operation where it helps for
cascading multiple comparators.
8-bit Magnitude Comparator
Here, data comparison is possible through the cascading of two 4-bit comparators. The
circuit is connected as below
The outputs of the lower-order comparator are connected to the corresponding cascading
inputs of the higher-order comparator
In the lower order comparator, the cascading input (A=B) needs to be connected HIGH, and
A, B needs to be connected to LOW. The result of the 8-bit comparator is the output of the
higher-order comparator.
Applications Comparator
Digital comparator and magnitude comparator is used in different applications where data
comparison is mostly required in many of the activities, and these hold many benefits too.
The sum of the data bits and parity bits can be even or odd . In even parity, the added
parity bit will make the total number of 1s an even amount whereas in odd parity the
added parity bit will make the total number of 1s odd amount.
The basic principle involved in the implementation of parity circuits is that sum of odd
number of 1s is always 1 and sum of even number of 1s is always zero. Such error
detecting and correction can be implemented by using Ex-OR gates (since Ex-OR gate
produce zero output when there are even number of inputs).
To produce two bits sum, one Ex-OR gate is sufficient whereas for adding three bits
two Ex-OR gates are required as shown in below figure.
Parity Generator
It is combinational circuit that accepts an n-1 bit stream data and generates the
additional bit that is to be transmitted with the bit stream. This additional or extra bit is
termed as a parity bit.
In even parity bit scheme, the parity bit is ‘0’ if there are even number of 1s in the
data stream and the parity bit is ‘1’ if there are odd number of 1s in the data stream.
In odd parity bit scheme, the parity bit is ‘1’ if there are even number of 1s in the data
stream and the parity bit is ‘0’ if there are odd number of 1s in the data stream. Let us
discuss both even and odd parity generators.
The figure below shows the truth table of even parity generator in which 1 is placed as
parity bit in order to make all 1s as even when the number of 1s in the truth table is
odd.
The above expression can be implemented by using two Ex-OR gates. The logic
diagram of even parity generator with two Ex – OR gates is shown below. The three bit
message along with the parity generated by this circuit which is transmitted to the
receiving end where parity checker circuit checks whether any error is present or not.
To generate the even parity bit for a 4-bit data, three Ex-OR gates are required to add
the 4-bits and their sum will be the parity bit.
Let us consider that the 3-bit data is to be transmitted with an odd parity bit. The three
inputs are A, B and C and P is the output parity bit. The total number of bits must be
odd in order to generate the odd parity bit.
In the given truth table below, 1 is placed in the parity bit in order to make the total
number of bits odd when the total number of 1s in the truth table is even.
The output parity bit expression for this generator circuit is obtained as
P = A ⊕ B Ex-NOR C
The above Boolean expression can be implemented by using one Ex-OR gate and one
Ex-NOR gate in order to design a 3-bit odd parity generator.
The logic circuit of this generator is shown in below figure , in which . two inputs are
applied at one Ex-OR gate, and this Ex-OR output and third input is applied to the Ex-
NOR gate , to produce the odd parity bit. It is also possible to design this circuit by
using two Ex-OR gates and one NOT gate.
When a parity error occurs, the ‘sum even’ output goes low and ‘sum odd’ output goes
high. If this logic circuit is used as an odd parity checker, the number of input bits
should be odd, but if an error occurs the ‘sum odd’ output goes low and ‘sum even’
output goes high.
The below table shows the truth table for the even parity checker in which PEC = 1 if
the error occurs, i.e., the four bits received have odd number of 1s and PEC = 0 if no
error occurs, i.e., if the 4-bit message has even number of 1s.
The above truth table can be simplified using K-map as shown below.
If the total number of 1s in the data is odd, then it indicates no error, whereas if the total
number of 1s is even then it indicates the error since the data is transmitted with odd
parity at transmitting end.
The below figure shows the truth table for odd parity generator where PEC =1 if the 4-
bit message received consists of even number of 1s (hence the error occurred)
and PEC= 0 if the message contains odd number of 1s (that means no error).
It is a 9-bit parity generator or checker used to detect errors in high speed data
transmission or data retrieval systems. The figure below shows the pin diagram of
74180 IC.
This IC can be used to generate a 9-bit odd or even parity code or it can be used to
check for odd or even parity in a 9-bit code (8 data bits and one parity bit).
This IC consists of eight parity inputs from A through H and two cascading inputs.
There are two outputs even sum and odd sum. In implementing generator or checker
Bipradas Pal Chowdhury Institute of Technology, Digital Logic Design 112 | P a g e
circuits, unused parity bits must be tied to logic zero and the cascading inputs must not
be equal.