COA Module 1.3
COA Module 1.3
COA Module 1.3
Digital Logic
Electronic circuits are divided into two categories, digital and analog. An analog quantity varies
continuously and digital quantities only have discrete values. Digital systems can process,
store, and transmit data more efficiently. But it can only assign discrete values. Many systems
use a mix of analog and digital signals. For example, a CD player accepts digital data from the
CD drive and converts it to an analog signal.
Positive Logic and Negative logic
In the binary system, the digits 1 and 0 are called binary digits. To represent these two bits, we
use two different voltage levels. These voltages are called logic levels.
Generally higher voltage HIGH represents 1 and low voltage LOW represents 0. This is called
positive logic.
Another system that represents 1 with LOW and 0 with HIGH is called negative logic.
In a practical digital circuit, however HIGH and LOW can be any voltage between a specified
minimum and maximum voltages.
Further Reading
10.4 Positive Logic, Negative logic
POSITIVE AND NEGATIVE LOGIC: TPUB
The lines connected to the left side of each symbol are inputs and line on the right is output. In
logic operations, the conditions mentioned earlier are represented by HIGH and LOW. Each of
the logic operations produces a unique result for a given set of conditions.
NOT
The NOT operation inverts the logic level. When the input is HIGH the output will be LOW.
When the input is LOW the output will be HIGH. Logic circuit inverter is used to implement NOT
operation.
In Boolean algebra complement of a variable is represented by a bar over a digit. The two
possible input-output combinations of an inverter(not gate) are,
This operation of an inverter(not gate) is summarized in the following table which shows the
output for each possible inputs. This is called a truth table.
INPUT A OUTPUT (Ā)
LOW 0 HIGH 1
HIGH 1 LOW 0
AND
An AND gate is composed of a single output and multiple inputs. The AND operation produces
HIGH output only when all of its inputs are HIGH. When any or all inputs are LOW, then the
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
output is LOW. The basic purpose of AND gate is to determine whether all conditions are
(
)
(
)
(
)
(
)
(
)
(
)
simultaneously true.
In Boolean expression AND operation is represented either by placing a dot ( . ) between the
variables or by writing the variables together. The four possible input-output combinations of a
two-input AND gate are,
OR
An OR gate is composed of a single output and multiple inputs. The OR operation produces
HIGH output when any of its inputs are HIGH. The output is LOW only if both of the inputs are
LOW.
The logical OR function is represented by placing a plus (+) in between the variables. The four
possible input-output combinations of a two-input OR gate are,
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
)
(
+
)
The truth table of an OR gate is given below.
INPUT A INPUT B OUTPUT A B
LOW 0 LOW 0 LOW 0
LOW 0 HIGH 1 HIGH 1
HIGH 1 LOW 0 HIGH 1
HIGH 1 HIGH 1 HIGH 1
XOR operation is represented by a + symbol with a circle around it. The four possible input-
output combinations of XOR gate is,
The output of an XNOR gate is only HIGH when the two inputs are at same logic levels. That is,
if X is the output then X is HIGH when both A and B is HIGH or both A and B is LOW.
Further Reading
Basic Logic Gates – Types, Functions | Byjus
Basic Logic Gates with Truth Table | Elprocus
Universal gates (NAND and NOR gate)
(
)
(
)
(
)
The NAND and NOR gates are called universal gates. That is universal gates can be used in
combination to perform the AND, OR and inverter operations.
NAND
The term NAND implies the function of an AND gate with an inverted output. The logic symbol
of NAND gate is equivalent to an AND gate followed by an inverter. NAND operation is
represented by a bar over the AND expression.
The NAND gate produces a LOW output only when all of its inputs are HIGH. That is for a two-
input NAND gate OUTPUT, X is LOW when both inputs A and B are HIGH. X is HIGH if either A
or B is LOW, or when both are LOW.
NOR
The term NOR implies the function of an OR gate with an inverted output. The logic symbol of
NOR gate is equivalent to an OR gate followed by an inverter. NOR operation is represented by
a bar over the OR expression.
The NOR gate produces a LOW output when any of its inputs are HIGH. That is for a two-input
NAND gate OUTPUT, X is LOW when either input A or B is HIGH or when both A and B is HIGH.
X is HIGH only when both A and B is LOW
(
)
(
)
(
)
The operation is summarized in the following truth table.
INPUT A INPUT B OUTPUT X
LOW LOW HIGH
LOW HIGH LOW
HIGH LOW LOW
HIGH HIGH LOW
Half Adder
Recall laws of binary addition,
0+0=0
0+1=1
1+0=1
1 + 1 = 10
Half adder is a logical circuit that is used to perform this operation. It accepts two binary digits
as input and produces two binary digits, a sum and a carry, in its output. The logic symbol of a
half adder is given below.
From these equations, we can implement the logic circuit required for a half adder. The Sum is
generated with an XOR gate with two inputs A and B, and the Carry is generated with an AND
gate.
Further Reading
Half Adder in Digital Logic | Geeks for Geeks
Hald Adder theory and circuit | Circuits Today
Half Subtractor
Half subtractor is a combinational circuit that performs subtraction of two bits. It accepts two
binary digits as input and produces two binary digits, a difference and a borrow, in its output.
The logic symbol of half subtractor is given below.
Expressions for Difference and Borrow can be derived from the following truth table and K-
Map.
A B D BOUT
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Observe that the value of D is 1 when inputs A and B are at different logic levels. This can be
expressed as XOR of two variables.
Now the value of Bout is 1 only when input A is 0 and input B is 1. That is Bout can be
expressed as
From these equations, we can implement the logic circuit required as follows.
D is generated with an XOR gate with two inputs A and B, and the Bout is generated with an
inverter and an AND gate.
Further Reading
Half Subtractor in Digital Logic | Geeks for Geeks
Half Subtractor Circuit Design | Elprocus
Full Adder
A full adder accepts two input bits and an input carry and generates a sum and a carry, in its
output. The logic symbol of a full adder is,
This means two XOR gates are used to implement full adder sum function. The first will
generate A⊕B and the second will add this output with an input carry Cin. The complete logic
circuit of a full adder will be,
Full Subtractor
A full subtractor is a combinational circuit that performs subtraction of three bits. This circuit
has three inputs the minuend A, subtrahend B, and borrow in Bin. Bin is the borrow of the
previous adjacent lower minuend bit. This Bin is also subtracted from A-B. A full subtractor has
two outputs, D and Bout, represents Difference and Borrow Out respectively.
These expressions can be implemented using two XOR gates, two AND gates and one OR gate
as follows
Further Reading
Full Subtractor in Digital Logic | Geeks for Geeks
Full Subtractor Circuit Design | Elprocus
4 bit Ripple Carry Adder
A full adder can be used to perform addition of two bits with an input carry. To add an N-bit
number, multiple full adder circuits can be cascaded parallelly. Such an arrangement of full
adders is called a parallel adder. N full adders are required to add n bits.
A ripple-carry adder is a parallel adder created by connecting carry output of each full-adder
with the carry input of the next higher-order full-adder. The input carry should occur first to
produce the sum and output carry of any stage (a stage is one full adder); this causes a time
delay in the addition process.
4 bit Ripple Carry Adder
A 4-bit binary ripple-carry adder is shown in the figure.
Full-adder 1 (FA1) cannot produce a potential carry until an input carry is applied. Full-adder
2(FA2) cannot produce a potential output carry until FA1 produces an output carry, Full-adder
3(FA3) cannot produce a potential output carry until FA2 produces an output carry and so on.
That is the input carry has to ripple through all the adders before a final sum is produced. This
causes a time delay in the addition process and is called propagation delay or ripple carry
delay.
Further Reading
Ripple Carry Adder | Circuits Today
4-bit ripple carry adder | Gate Vidyalay
That is we get an output carry of 1 if it is generated by the full adder or if the adder propagates
the input carry.
Circuit diagram for a full adder that produces Cg and Cp function is shown below
Full Adder 2
Full Adder 3
Full Adder 4
Observe that the output-carry for each stage is dependent only on the initial input carry Cin1,
the Cg and Cp functions of that stage. Since Cg and Cp can be expressed in terms of A and B
inputs to the full adder, all the output carries are available immediately. So we don’t have to
wait for a carry to ripple through all the stages and there will be no propagation delay.
Further Reading
Carry Look Ahead Adder | Geeks For Geeks
Carry Look Ahead Adder | Wikipedia
Decoders
Decoders are the combinational circuits that detect the presence of some code on its input and
indicate the presence of that code by a specified output. Generally, a decoder has n input lines
and 2n output lines.
Binary codes corresponding outputs and decoding functions are described in the table.
BINARY OUTPUT
DECIMAL DIGIT DECODING FUNCTION
A0 A1 0 1 2 3
0 0 0 1 0 0 0
1 0 1 0 1 0 0
2 1 0 0 0 1 0
3 1 1 0 0 0 1
logical diagram of 2 to 4 bit decoder is shown in the figure.
3-bit decoder
A 3-bit decoder has 3 input lines and 8 output lines. That is, 8 decoding gates are required to
decode all possible combinations of three bits. For any given code on its input, one of the eight
output becomes HIGH.
Binary codes corresponding outputs and decoding functions are described in the table.
BINARY OUTPUT
DECIMAL DIGIT DECODING FUNCTION
A0 A1 A2 0 1 2 3 4 5 6 7
0 0 0 0 1 0 0 0 0 0 0 0
1 0 0 1 0 1 0 0 0 0 0 0
2 0 1 0 0 0 1 0 0 0 0 0
3 0 1 1 0 0 0 1 0 0 0 0
4 1 0 0 0 0 0 0 1 0 0 0
5 1 0 1 0 0 0 0 0 1 0 0
6 1 1 0 0 0 0 0 0 0 1 0
BINARY OUTPUT
DECIMAL DIGIT DECODING FUNCTION
A0 A1 A2 0 1 2 3 4 5 6 7
7 1 1 1 0 0 0 0 0 0 0 1
Circuit of a 3 bit decoder is given below,
4-bit decoder
A 4-bit decoder has 4 input lines and 16 output lines. That is 16 decoding gates are required to
decode all possible combinations of four bits. For any given code on its input, one of the
sixteen output becomes HIGH.
Binary codes corresponding outputs and decoding functions are described in the table.
BINARY OUTPUT
DECIMAL DIGIT DECODING FUNCTION
A0 A1 A2 A3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 0 0 0 0 1 000 0 00000 0 0 0 0 0 0
1 0 0 0 1 0 1 00 0 00000 0 0 0 0 0 0
2 0 0 1 0 0 0 1 0 0 00000 0 0 0 0 0 0
(
BINARY OUTPUT
DECIMAL DIGIT DECODING FUNCTION
A0 A1 A2 A3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
3 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
4 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
5 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
6 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
7 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
8 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
9 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
10 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
11 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
12 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
13 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
14 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
15 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Further Reading
Binary Decoder | Geeks For Geeks
Decoder | Electronics Tutorials
Further Reading
BCD to 7 Segment Decoder | Geeks For Geeks
BCD Display | Electronics Tutorials
Encoders
An encoder is a combinational circuit that performs reverse function of a decoder. It accepts 2n
input and produces output in n output lines. This process of generating codes based on the
values of input lines is called encoding.
4 to 2 Line Encoder
A 4 to 2 line encoder consists of 4 input lines and 2 output lines. When any of the input lines
becomes 1, we get corresponding binary at the output lines.
Further Reading
Encoder | Tutorials Point
Encoder | Geeks for Geeks
Multiplexers
Multiplexer(MUX) is a device that allows digital signals from several sources to be routed onto a
single line of output. It has several input lines and a single output line. It has also data selector
lines which specifies which input signal has to be switched to the output line. n data selector
lines are required for routing 2n input lines.
4-input Multiplexer
A 4-input multiplexer has two data-selector lines a combination of which are used to select any
of the four data-input lines.
Logic symbol of a 4-input MUX is shown in figure.
If a binary 0 is applied to the data-selector lines, the data on input D0 appear on the data-
output line. If a binary 1 is applied to the data-selector lines, the data on input D1 appear on the
data-output line. If a binary 2 is applied to the data-selector lines, the data on input D2 appear
on the data-output line. If a binary 3 is applied to the data-selector lines, the data on input D0
appear on the data-output line.
This operation is given in the table.
DATA SELECTOR OUTPUT
S1 S0 Y
0 0
0 1
1 0
1 1
From the table it is clear that
is only if and :
is only if and :
is only if and :
is only if and :
The total expression for the data output is
This can be implemented using four 3-input AND gates, a 4-input OR gate, and two inverters
as shown in the figure.
8-input Multiplexer
An 8-input multiplexer has three data-selector lines a combination of which is used to select
any of the eight data-input lines.
Logic symbol of a 8-input MUX is shown in figure.
This can be implemented using eight 4-input AND gates, an 8-input OR gate, and three
inverters.
Higher-Order MUX Using Lower Order MUX
Multiplexers can also be implemented using a set of lower order multiplexers. Construction of
an 8×1 multiplexer using 4×1 and 2×1 multiplexers is shown in the figure.
Further Reading
Multiplexers | Geeks For Geeks
Multiplexers and Multiplexing | Tutorials Point
Demultiplexers
A demultiplexer(DEMUX performs the reverse operation of a multiplexer. It takes input from
one line and distributes it to a given number of output lines. It is also known as a data
distributor. A demultiplexer with 2n output lines should have n data-selector lines.
1:4 Demultiplexer
)
A 1:4 demultiplexer takes input from one line and distributes it to 4 output lines. It has 2 data
selector lines.