Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Logic Gates

A logic gate is a device that acts as a building block for digital circuits.
They perform basic logical functions that are fundamental to digital circuits.
Most electronic devices we use today will have some form of logic gates in
them. For example, logic gates can be used in technologies such as
smartphones, tablets or within memory devices.

In a circuit, logic gates will make decisions based on a combination of


digital signals coming from its inputs. Most logic gates have two inputs and
one output. Logic gates are based on Boolean algebra. At any given
moment, every terminal is in one of the two binary conditions, false or true.
False represents 0, and true represents 1. Depending on the type of logic
gate being used and the combination of inputs, the binary output will differ.
A logic gate can be thought of like a light switch, wherein one position the
output is off -- 0, and in another, it is on -- 1. Logic gates are commonly
used in integrated circuits (IC).

Basic logic gates


There are seven basic logic gates: AND, OR, XOR, NOT, NAND, NOR,
and XNOR.

AND Gate
The following illustration and table show the circuit symbol and logic
combinations for an AND gate. (In the symbol, the input terminals are at left
and the output terminal is at right.) The output is "true" when both inputs
are "true." Otherwise, the output is "false."
Logic diagram

Truth Table

OR Gate
The OR gate gets its name from the fact that it behaves after the fashion of
the logical inclusive "or." The output is "true" if either or both of the inputs
are "true." If both inputs are "false," then the output is "false."

Logic diagram
Truth Table

NOT Gate
A logical inverter, sometimes called a NOT gate to differentiate it from other
types of electronic inverter devices, has only one input. It reverses the logic
state. If the input is 1, then the output is 0. If the input is 0, then the output
is 1.

Logic diagram

Truth Table

NAND Gate
The NAND gate operates as an AND gate followed by a NOT gate. It acts
in the manner of the logical operation "and" followed by negation. The
output is "false" if both inputs are "true." Otherwise, the output is "true."
Logic diagram

Truth Table

NOR Gate
The NOR gate is a combination OR gate followed by an inverter. Its output
is "true" if both inputs are "false." Otherwise, the output is "false."

Logic diagram
Truth Table

XOR Gate

The XOR ( exclusive-OR ) gate acts in the same way as the logical
"either/or." The output is "true" if either, but not both, of the inputs are
"true." The output is "false" if both inputs are "false" or if both inputs are
"true." Another way of looking at this circuit is to observe that the output is 1
if the inputs are different, but 0 if the inputs are the same.

Logic diagram
Truth Table

XNOR Gate

The XNOR (exclusive-NOR) gate is a combination XOR gate followed by


an inverter. Its output is "true" if the inputs are the same, and "false" if the
inputs are different.

Logic diagram
Truth Table

Boolean Algebra

Boolean Algebra is used to analyze and simplify the digital (logic)


circuits. It uses only the binary numbers i.e. 0 and 1. It is also called
as Binary Algebra or logical Algebra. Boolean algebra was invented
by George Boole in 1854.

Rule in Boolean Algebra


Following are the important rules used in Boolean algebra.
• Variable used can have only two values. Binary 1 for HIGH and
Binary 0 for LOW.
• Complement of a variable is represented by an overbar (-). Thus,
complement of variable B is represented as . Thus if B = 0
then = 1 and B = 1 then = 0.
• ORing of the variables is represented by a plus (+) sign between
them. For example ORing of A, B, C is represented as A + B + C.
• Logical ANDing of the two or more variable is represented by
writing a dot between them such as A.B.C. Sometime the dot may
be omitted like ABC.
Boolean Laws
There are six types of Boolean Laws.
Commutative law
Any binary operation which satisfies the following expression is referred to as
commutative operation.

Commutative law states that changing the sequence of the variables does not have
any effect on the output of a logic circuit.
Associative law
This law states that the order in which the logic operations are performed is
irrelevant as their effect is the same.

Distributive law
Distributive law states the following condition.

AND law
These laws use the AND operation. Therefore they are called as AND laws.

OR law
These laws use the OR operation. Therefore they are called as OR laws.

INVERSION law
This law uses the NOT operation. The inversion law states that double inversion of a
variable results in the original variable itself.
Important Boolean Theorems
Following are few important boolean Theorems.
Boolean function/theorems Description

Boolean Functions and Expressions, K-Map and NAND


Boolean Functions
Gates realization

De Morgan's Theorem 1 and Theorem 2


De Morgan's Theorems

Boolean Expression ⁄ Function


Boolean algebra deals with binary variables and logic operation.
A Boolean Function is described by an algebraic expression
called Boolean expression which consists of binary variables, the
constants 0 and 1, and the logic operation symbols. Consider the
following example.

Here the left side of the equation represents the output Y. So we can
state equation no. 1

Truth Table Formation


A truth table represents a table having all combinations of inputs and
their corresponding result.
It is possible to convert the switching equation into a truth table. For
example, consider the following switching equation.

The output will be high (1) if A = 1 or BC = 1 or both are 1. The truth


table for this equation is shown by Table (a). The number of rows in the
truth table is 2n where n is the number of input variables (n=3 for the
given equation). Hence there are 23 = 8 possible input combination of
inputs.
Methods to simplify the boolean function
The methods used for simplifying the Boolean function are as follows −
• Karnaugh-map or K-map, and
• NAND gate method.

Karnaugh-map or K-map
The Boolean theorems and the De-Morgan's theorems are useful in
manipulating the logic expression. We can realize the logical expression
using gates. The number of logic gates required for the realization of a
logical expression should be reduced to a minimum possible value by K-
map method. This method can be done in two different ways, as
discussed below.
Sum of Products (SOP) Form
It is in the form of sum of three terms AB, AC, BC with each individual
term is a product of two variables. Say A.B or A.C etc. Therefore such
expressions are known as expression in SOP form. The sum and
products in SOP form are not the actual additions or multiplications. In
fact they are the OR and AND functions. In SOP form, 0 represents a
bar and 1 represents an unbar. SOP form is represented by .
Given below is an example of SOP.
Product of Sums (POS) Form
It is in the form of product of three terms (A+B), (B+C), or (A+C) with
each term is in the form of a sum of two variables. Such expressions are
said to be in the product of sums (POS) form. In POS form, 0 represents
an unbar and 1 represents a bar. POS form is represented by .
Given below is an example of POS.
DeMorgan’s Theorems
DeMorgan’s Theorem uses two sets of rules or laws to solve various
Boolean algebra expressions by changing OR’s to AND’s,
and AND’s to OR’s.

Boolean Algebra uses a set of laws and rules to define the operation of a
digital logic circuit with “0’s” and “1’s” being used to represent a digital input
or output condition. Boolean Algebra uses these zeros and ones to create
truth tables and mathematical expressions to define the digital operation of
a logic AND, OR and NOT (or inversion) operations as well as ways of
expressing other logical operations such as the XOR (Exclusive-OR)
function.

DeMorgan’s Theory

DeMorgan’s Theorems are basically two sets of rules or laws developed


from the Boolean expressions for AND, OR and NOT using two input
variables, A and B. These two rules or theorems allow the input variables to
be negated and converted from one form of a Boolean function into an
opposite form.

DeMorgan’s first theorem states that two (or more) variables NOR´ed
together is the same as the two variables inverted (Complement) and
AND´ed, while the second theorem states that two (or more) variables
NAND´ed together is the same as the two terms inverted (Complement)
and OR´ed. That is replace all the OR operators with AND operators, or all
the AND operators with an OR operators.
DeMorgan’s First Theorem
DeMorgan’s First theorem proves that when two (or more) input variables
are AND’ed and negated, they are equivalent to the OR of the
complements of the individual variables. Thus the equivalent of
the NAND function will be a negative-OR function, proving that A.B = A+B.
We can show this operation using the following table.

Verifying DeMorgan’s First Theorem using Truth Table

Inputs Truth Table Outputs For Each Term

B A A.B A.B A B A+B

0 0 0 1 1 1 1

0 1 0 1 0 1 1

1 0 0 1 1 0 1

1 1 1 0 0 0 0

We can also show that A.B = A+B using logic gates as shown.
DeMorgan’s First Law Implementation using Logic Gates

The top logic gate arrangement of: A.B can be implemented using a
standard NAND gate with inputs A and B. The lower logic gate
arrangement first inverts the two inputs producing A and B. These then
become the inputs to the OR gate. Therefore the output from the OR gate
becomes: A+B

Then we can see here that a standard OR gate function with inverters
(NOT gates) on each of its inputs is equivalent to a NAND gate function. So
an individual NAND gate can be represented in this way as the equivalency
of a NAND gate is a negative-OR.

DeMorgan’s Second Theorem


DeMorgan’s Second theorem proves that when two (or more) input
variables are OR’ed and negated, they are equivalent to the AND of the
complements of the individual variables. Thus the equivalent of
the NOR function is a negative-AND function proving that A+B = A.B, and
again we can show operation this using the following truth table.
Verifying DeMorgan’s Second Theorem using Truth Table

Inputs Truth Table Outputs For Each Term

B A A+B A+B A B A.B

0 0 0 1 1 1 1

0 1 1 0 0 1 0

1 0 1 0 1 0 0

1 1 1 0 0 0 0

We can also show that A+B = A.B using the following logic gates example.

DeMorgan’s Second Law Implementation using Logic Gates


The top logic gate arrangement of: A+B can be implemented using a
standard NOR gate function using inputs A and B. The lower logic gate
arrangement first inverts the two inputs, thus producing A and B. Thus then
become the inputs to the AND gate. Therefore the output from
the AND gate becomes: A.B

Then we can see that a standard AND gate function with inverters (NOT
gates) on each of its inputs produces an equivalent output condition to a
standard NOR gate function, and an individual NOR gate can be
represented in this way as the equivalency of a NOR gate is a negative-
AND.

Combinational Circuits
Combinational circuit is a circuit in which we combine the different gates
in the circuit, for example encoder, decoder, multiplexer and
demultiplexer. Some of the characteristics of combinational circuits are
following −
• The output of combinational circuit at any instant of time, depends
only on the levels present at input terminals.
• The combinational circuit do not use any memory. The previous
state of input does not have any effect on the present state of the
circuit.
• A combinational circuit can have an n number of inputs and m
number of outputs.
Block diagram

Half Adder
Half adder is a combinational logic circuit with two inputs and two
outputs. The half adder circuit is designed to add two single bit binary
number A and B. It is the basic building block for addition of
two single bit numbers. This circuit has two outputs carry and sum.

Block diagram
Truth Table

Circuit Diagram

Full Adder
Full adder is developed to overcome the drawback of Half Adder circuit.
It can add two one-bit numbers A and B, and carry c. The full adder is a
three input and two output combinational circuit.
Block diagram
Truth Table

Circuit Diagram

N-Bit Parallel Adder


The Full Adder is capable of adding only two single digit binary number
along with a carry input. But in practical we need to add binary numbers
which are much longer than just one bit. To add two n-bit binary
numbers we need to use the n-bit parallel adder. It uses a number of full
adders in cascade. The carry output of the previous full adder is
connected to carry input of the next full adder.
4 Bit Parallel Adder
In the block diagram, A0 and B0 represent the LSB of the four bit words A
and B. Hence Full Adder-0 is the lowest stage. Hence its Cin has been
permanently made 0. The rest of the connections are exactly same as
those of n-bit parallel adder is shown in fig. The four bit parallel adder is
a very common logic circuit.
Block diagram

Half Subtractors
Half subtractor is a combination circuit with two inputs and two outputs
(difference and borrow). It produces the difference between the two
binary bits at the input and also produces an output (Borrow) to indicate
if a 1 has been borrowed. In the subtraction (A-B), A is called as
Minuend bit and B is called as Subtrahend bit.
Truth Table
Circuit Diagram

Full Subtractors
The disadvantage of a half subtractor is overcome by full subtractor. The
full subtractor is a combinational circuit with three inputs A,B,C and two
output D and C'. A is the 'minuend', B is 'subtrahend', C is the 'borrow'
produced by the previous stage, D is the difference output and C' is the
borrow output.

Truth Table
Circuit Diagram

Multiplexers
Multiplexer is a special type of combinational circuit. There are n-data
inputs, one output and m select inputs with 2m = n. It is a digital circuit
which selects one of the n data inputs and routes it to the output. The
selection of one of the n inputs is done by the selected inputs.
Depending on the digital code applied at the selected inputs, one out of
n data sources is selected and transmitted to the single output Y. E is
called the strobe or enable input which is useful for the cascading. It is
generally an active low terminal that means it will perform the required
operation when it is low.
Block diagram

Multiplexers come in multiple variations


• 2 : 1 multiplexer
• 4 : 1 multiplexer
• 16 : 1 multiplexer
• 32 : 1 multiplexer
Block Diagram
Truth Table

Demultiplexers
A demultiplexer performs the reverse operation of a multiplexer i.e. it
receives one input and distributes it over several outputs. It has only one
input, n outputs, m select input. At a time only one output line is selected
by the select lines and the input is transmitted to the selected output line.
A de-multiplexer is equivalent to a single pole multiple way switch as
shown in fig.
Demultiplexers comes in multiple variations.
• 1 : 2 demultiplexer
• 1 : 4 demultiplexer
• 1 : 16 demultiplexer
• 1 : 32 demultiplexer
Block diagram
Truth Table

Decoder
A decoder is a combinational circuit. It has n input and to a maximum m
= 2n outputs. Decoder is identical to a demultiplexer without any data
input. It performs operations which are exactly opposite to those of an
encoder.
Block diagram

Examples of Decoders are following.


• Code converters
• BCD to seven segment decoders
• Nixie tube decoders
• Relay actuator

2 to 4 Line Decoder
The block diagram of 2 to 4 line decoder is shown in the fig. A and B are the two
inputs where D through D are the four outputs. Truth table explains the operations of
a decoder. It shows that each output is 1 for only a specific combination of inputs.
Block diagram

Truth Table
Logic Circuit

Encoder
Encoder is a combinational circuit which is designed to perform the
inverse operation of the decoder. An encoder has n number of input
lines and m number of output lines. An encoder produces an m bit binary
code corresponding to the digital input number. The encoder accepts an
n input digital word and converts it into an m bit another digital word.
Block diagram

Examples of Encoders are following.


• Priority encoders
• Decimal to BCD encoder
• Octal to binary encoder
• Hexadecimal to binary encoder

You might also like