Digital logic gates are the basic building blocks of digital circuits. The three main types of logic gates are AND gates, OR gates, and NOT gates. Logic gates have one or more inputs and one output, and the output depends on the combinations of inputs according to truth tables. Common logic gates include AND, OR, NAND, NOR, XOR, and XNOR gates. Logic gates can be combined to perform more complex logical operations and form the basis of digital electronics in computers and other devices.
2. Logic gates
Computer and other digital devices are sometimes
looked upon by the general public as magical.
Actually digital electronic devices are extremely
logical in their operations.
The basic building block of any digital circuit is a
logic gate.
A logic gate is an electronic circuit which makes
logical decision.
It has one or more inputs and only one output.
The output signal appears only for certain
combinations of the input signals.
3. Logic gate
In computer, logic gates are the
building blocks.
Most of the functions in a computer,
with the exception of certain types of
memory, are implemented with logic
gates used on a very large scale.
For example a microprocessor, which is
made up of hundreds of thousands or
even millions of logic gates.
4. Logic gates
Logic gates can be constructed by using
simple switches, relays, vacuum tubes,
transistors and diodes or ICs
Because of their availability , wide use and
low cost.
ICs will be used to construct digital
circuits.
A variety of logic gates are available in all
logic families including Transistor–
transistor logic (TTL) and CMOS.
5. Positive and Negative logic gate
In computing systems, the binary digits “0 and 1”
represent two possible states of a circuit or
device.
It makes difference if these two states are
referred to “Off and On” or “Closed and Open”
or “Low and High” or “Minus and Plus” or
“False and True” depending on the
circumstances.
6. Positive and Negative
logic gate
o Positive and Negative Logic
In positive logic, 1 represents:
1. An ON circuit
2. A CLOSED switch
3. A HIGH voltage
4. A PLUS sign
5. A TRUE statement
o Positive and Negative Logic
Consequently, 0
represents:
1. An OFF circuit
2. A OPEN switch
3. A LOW voltage
4. A MINUS sign
5. A FALSE statement
7. Example
o Suppose, a digital system has two voltage levels of “0V and 5V”.
1. If we say that digit 1 stands for 5V and digit 0 stands for 0V,
then we have positive logic system.
2. If, on other hand, we decide that 1 should stand for 0V and 0
stands for 5V, then we will have a negative logic system.
o Note: It is not necessary that a 0 has to be represented by 0V, it can be
any voltage level.
o The main concept is that, in positive logic, the more positive of the two
quantities represents the 1 and in negative logic, the more negative voltage
represents 0.
8. Types of logic Gates
o There are seven types logic gates whose function is to perform logical operations.
These are (note the use of capital letters to name the gates):
1. AND gate
2. OR gate
3. NOT gate
4. NAND gate
5. NOR gate
6. XOR gate
7. XNOR gate
9. The inverter performs the Boolean NOT operation. When the input is
LOW, the output is HIGH; when the input is HIGH, the output is LOW.
The Inverter
A X
Input
A X
Output
LOW (0) HIGH (1)
HIGH (1) LOW(0)
The NOT operation (complement) is shown with an overbar. Thus, the
Boolean expression for an inverter is X = A.
10. The Inverter
Example waveforms:
A
X
A X
A group of inverters can be used to form the 1’s complement of a binary
number:
Binary number
1’s complement
1 0 0 0 1 1 0
1
0 1 1 1 0 0 1
0
11. The AND gate produces a HIGH output when all inputs are HIGH;
otherwise, the output is LOW. For a 2-input gate, the truth table is
The AND Gate
The AND operation is usually shown with a dot between the variables
but it may be implied (no dot). Thus, the AND operation is written as X =
A .B or X = AB.
Inputs
A B X
Output
0 0
0 1
1 0
1 1
0
0
0
1
A
B
X &
A
B
X
12. Example waveforms:
A
X
The AND operation is used in computer programming as a selective mask.
If you want to retain certain bits of a binary number but reset the other
bits to 0, you could set a mask with 1’s in the position of the retained bits.
The AND Gate
A
B
X
B
00000011
If the binary number 10100011 is ANDed with the mask
00001111, what is the result?
&
A
B
X
13. The OR gate produces a HIGH output if any input is HIGH; if all inputs
are LOW, the output is LOW. For a 2-input gate, the truth table is
The OR Gate
The OR operation is shown with a plus sign (+) between the variables.
Thus, the OR operation is written as X = A + B.
Inputs
A B X
Output
0 0
0 1
1 0
1 1
0
1
1
1
A
B
X A
B
X
≥ 1
14. Example waveforms:
A
X
The OR operation can be used in computer programming to set
certain bits of a binary number to 1.
The OR Gate
B
A
B
X A
B
X
≥ 1
ASCII letters have a 1 in the bit 5 position for lower case
letters and a 0 in this position for capitals. (Bit positions
are numbered from right to left starting with 0.) What will
be the result if you OR an ASCII letter with the 8-bit mask
00100000?
The resulting letter will be lower case.
15. The NAND gate produces a LOW output when all inputs are HIGH;
otherwise, the output is HIGH. For a 2-input gate, the truth table is
The NAND Gate
Inputs
A B X
Output
0 0
0 1
1 0
1 1
1
1
1
0
A
B
X A
B
X
&
The NAND operation is shown with a dot between the variables and an
overbar covering them. Thus, the NAND operation is written as X = A .B
(Alternatively, X = AB.)
16. Example waveforms:
A
X
The NAND gate is particularly useful because it is a “universal” gate – all
other basic gates can be constructed from NAND gates.
The NAND Gate
B
How would you connect a 2-input NAND gate to form a
basic inverter?
A
B
X A
B
X
&
17. The NOR gate produces a LOW output if any input is HIGH; if all
inputs are HIGH, the output is LOW. For a 2-input gate, the truth
table is
The NOR Gate
Inputs
A B X
Output
0 0
0 1
1 0
1 1
1
0
0
0
A
B
X A
B
X
≥1
The NOR operation is shown with a plus sign (+) between the variables
and an overbar covering them. Thus, the NOR operation is written as X =
A + B.
18. Example waveforms:
A
X
The NOR operation will produce a LOW if any input is HIGH.
The NOR Gate
B
When is the LED is ON for the circuit shown?
The LED will be on when any
of the four inputs are HIGH.
A
C
B
D
X
330W
+5.0 V
A
B
X A
B
X
≥1
19. The XOR gate produces a HIGH output only when both inputs are at
opposite logic levels. The truth table is
The XOR Gate
Inputs
A B X
Output
0 0
0 1
1 0
1 1
0
1
1
0
A
B
X A
B
X
= 1
The XOR operation is written as X = AB + AB. Alternatively, it can be
written with a circled plus sign between the variables as X = A + B.
21. Example waveforms:
A
X
Notice that the XOR gate will produce a HIGH only when exactly
one input is HIGH.
The XOR Gate
B
If the A and B waveforms are both inverted for the
above waveforms, how is the output affected?
There is no change in the
output.
A
B
X A
B
X
= 1
22. The XNOR gate produces a HIGH output only when both inputs are at
the same logic level. The truth table is
The XNOR Gate
Inputs
A B X
Output
0 0
0 1
1 0
1 1
1
0
0
1
A
B
X A
B
X
The XNOR operation shown as X = AB + AB. Alternatively, the XNOR
operation can be shown with a circled dot between the variables. Thus, it
can be shown as X = A . B.
= 1
23. Example waveforms:
A
X
Notice that the XNOR gate will produce a HIGH when both inputs
are the same. This makes it useful for comparison functions.
The XNOR Gate
B
If the A waveform is inverted but B remains the same,
how is the output affected?
The output will be
inverted.
A
B
X A
B
X
= 1
29. Logic gates
summary
Inverter
Truth table
Timing diagram
Boolean algebra
AND gate
A logic circuit that inverts or complements its inputs.
A table showing the inputs and corresponding output(s) of a logic
circuit.
A diagram of waveforms showing the proper time relationship of all
of the waveforms.
The mathematics of logic circuits.
A logic gate that produces a HIGH output only when all of its inputs
are HIGH.
30. OR gate
NAND gate
NOR gate
Exclusive-OR gate
Exclusive-NOR gate
A logic gate that produces a HIGH output when one or more
inputs are HIGH.
A logic gate that produces a LOW output only when all of its
inputs are HIGH.
A logic gate that produces a LOW output when one or more
inputs are HIGH.
A logic gate that produces a HIGH output only when its two
inputs are at opposite levels.
A logic gate that produces a LOW output only when its two
inputs are at opposite levels.
Logic gates
summary
31. Applications
Simple application of NAND gate
The application discussed here is that of a door closing
system of an automobile.
A car needs to be so designed that the driver gets a
visual indication if any of the doors of the car is open
so that it helps to avoid accident and injury to the
passengers.
Assuming there are two doors (just for simplicity, it
works for more doors as well) where this system is
fitted, the circuit can be designed using a NAND gate
as follows
32. You can see from the figure that when
any of the switches is open due to the
door position, the NAND gate energies
the lamp inside the car, hence warning
the driver.
A Car Door Open Warning System
using a NAND Gate
33. This truth table gives us the behaviour of
lamp inside the car when any one the
doors are opened
36. Some more examples
Below is the logic gate for a simple
house alarm. The alarm protects the
front and back doors and six windows.
Once the alarm is set if any of the
doors or windows are opened the
alarm will sound.
37.
38. Find the output of the following circuit
Answer: (x+y)y
38
x
y
x+y
y
(x+y)y
__
39. Find the output of the following circuit
Answer: xy
x
y
x
y
x y x y
_ _
___
40. Give the Boolean expression of the given circuit
40
x
y
x+y
xy xy
(x+y)(xy)
Answer: (x+y)(xy)
41. Write the circuits for the following
Boolean algebraic expressions
a) x+y
41
x
y
__
x
x+y
42. Write the circuits for the following
Boolean algebraic expressions
b) (x+y)x
42
x
y
x
y
x
y
_______
x
y
x+y
x+y (x+y)x
43. Write a Boolean expression and draw the truth table to
represent this logic circuit diagram.
Exercise
A
B
C
51. 1. The truth table for a 2-input AND gate is
0 0
0 1
1 0
1 1
Inputs
A B X
Output
0 0
0 1
1 0
1 1
1
0
0
0
Inputs
A B X
Output
0 0
0 1
1 0
1 1
Inputs
A B X
Output
Inputs
A B X
Output
0 0
0 1
1 0
1 1
0
1
1
1
a. b.
c. d.
0
1
1
0
0
0
0
1
Exercise
52. 2. The truth table for a 2-input NOR gate is
0 0
0 1
1 0
1 1
Inputs
A B X
Output
0 0
0 1
1 0
1 1
Inputs
A B X
Output
0 0
0 1
1 0
1 1
Inputs
A B X
Output
Inputs
A B X
Output
0 0
0 1
1 0
1 1
a. b.
c. d.
0
1
1
0
0
0
0
1
1
0
0
0
0
1
1
1
Exercise
53. 3. The truth table for a 2-input XOR gate is
0 0
0 1
1 0
1 1
Inputs
A B X
Output
0 0
0 1
1 0
1 1
Inputs
A B X
Output
0 0
0 1
1 0
1 1
Inputs
A B X
Output
Inputs
A B X
Output
0 0
0 1
1 0
1 1
a. b.
c. d.
0
1
1
0
0
0
0
1
1
0
0
0
0
1
1
1
Exercise
54. 4. The symbol is for a(n)
≥ 1
A
B
X
a. OR gate
b. AND gate
c. NOR gate
d. XOR gate
Exercise
55. 5. The symbol is for a(n)
A
B
X
a. OR gate
b. AND gate
c. NOR gate
d. XOR gate
Exercise
56. 6. A logic gate that produces a HIGH output only when all of its
inputs are HIGH is a(n)
a. OR gate
b. AND gate
c. NOR gate
d. NAND gate
Exercise
57. 8. A 2-input gate produces the output shown. (X represents the output.)
This is a(n)
a. OR gate
b. AND gate
c. NOR gate
d. NAND gate
A
B
X
Exercise
58. 9. A 2-input gate produces a HIGH output only when the inputs agree.
This type of gate is a(n)
a. OR gate
b. AND gate
c. NOR gate
d. XNOR gate
Exercise