You are on page 1of 42

Chapter 3

Logic Gates

Dr_hanan mohammed 1
Contents

1. The Inverter
2. The AND Gate
3. The OR Gate
4. The NAND Gate
5. The NOR Gate
6. The Exclusive-OR and Exclusive-NOR Gates

Dr_hanan mohammed 2
Introduction

1. Logic gates are electronic circuits that can be used to implement the
most elementary logic expressions, (Boolean expressions).
2. The logic gate is the most basic building block of combinational logic.
3. There are three basic logic gates; the OR gate, the AND gate, and the
NOT gate.
4. Other logic gates that are derived from these basic gates are the NAND
gate, the NOR gate, the EXCLUSIVE-OR gate, and the EXCLUSIVE-NOR
gate.

Dr_hanan mohammed 3
Positive and Negative Logic

1. The binary variables can have ‘0’ or ‘1’ logic state.


2. These logic states in digital systems are represented by
two different voltage levels or two different current levels.
3. If the more positive voltage or current levels represents a logic ‘1’ , then the
logic system is referred to as a positive logic system.
4. If the more positive of the two voltage or current levels represents a logic
‘0’, then the logic system is referred to as a negative logic system.

Dr_hanan mohammed 4
Truth Table
1. A truth table lists all possible combinations of input binary variables and the
corresponding outputs of a logic system.
2. The logic system output can be found from the logic expression, often
referred to as the Boolean expression, that relates the output with the
inputs of that very logic system.
3. When the number of input binary variables is only one, there are only two
possible inputs. If the number of inputs is two, there are four possible input
combinations.

Dr_hanan mohammed 5
The Inverter

 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.

Inverter truth table


A X Input Output
A X
LOW (0) HIGH (1)
HIGH (1) LOW(0)
Logic Expression for an Inverter
 The NOT operation (complement) is shown with an overbar. Thus, the
Boolean expression for an inverter is X = A.
Dr_hanan mohammed 6
The Inverter
Example of timing diagram
A

An Application
Binary number
 A group of inverters can be 1 0 0 0 1 1 0 1

used to form the 1’s


complement of a binary
number: 0 1 1 1 0 0 1 0
1’s complement

Dr_hanan mohammed 7
The AND Gate
 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
Inputs Output
A A B X
A X X
& 0 0 0
B 0 1 0
B
1 0 0
1 1 1
 The total number of possible combinations of binary inputs to a gate is
determined by the following formula: N=2𝑛
 where N is the number of possible input combinations and n is the number
of input variables. To illustrate, For two input variables: N = 22 = 4
combinations Dr_hanan mohammed 8
The AND Gate
Example waveforms:
A A X
B B

Boolean multiplication is the


 The AND operation is usually shown with a dot between the same as the AND function.
variables but it may be implied (no dot). Thus, the AND operation
is written as X = A .B or X = AB.
 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.
Dr_hanan mohammed 9
The AND Gate
 Example 1: If the binary number 10100011 is ANDed with the mask
00001111, what is the result? 00000011

 Example2:

Dr_hanan mohammed 10
The AND Gate Application
The AND Gate as Enable/Inhibit Device
 A common application of the AND gate is to enable (allow) the passage of
a signal (pulse waveform) from one point to another at certain times and
to inhibit (prevent) the passage at other times as shown
 The purpose of this circuit is to measure the frequency of waveform A.
The enable pulse has a width of precisely 1 ms.

During 1 ms interval of the enable


pulse, pulses in waveform A pass
through the AND gate to the
counter. The number of pulses
passing through during the 1 ms
interval is equal to the frequency of
waveform A.
Dr_hanan mohammed 11
The AND Gate Application
A Seat Belt Alarm System
 In the Figure, the AND gate is used in a simple automobile seat belt alarm
system to detect when the ignition switch is on and the seat belt is
unbuckled.

Dr_hanan mohammed 12
The OR Gate
 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
Inputs Output
A X A B X
B 0 0 0
0 1 1
1 0 1
 The OR operation is shown with a plus sign (+) between the 1 1 1
variables. Thus, the OR operation is written as X = A + B.
 Boolean addition is the same as the OR function.
 Notice that Boolean addition differs from binary addition in
the case where two 1s are added. There is no carry in
Boolean addition.
Dr_hanan mohammed 13
The OR Gate
Example 1: waveforms:
A
A X
B B

Example 2:For the 3-input OR gate,


determine the output waveform in
proper time relation to the inputs.

Dr_hanan mohammed 14
The OR Gate Application
An Intrusion Detection and Alarm System
 This system is used for one room with two windows and a door. As
long as the windows and the door are secured, the switches are closed
and all three of the OR gate inputs are LOW.

 When one of the windows or the


door is opened, a HIGH is
produced on that input to the OR
gate and the gate output goes
HIGH. It then activates an alarm
circuit.
Dr_hanan mohammed 15
The NAND Gate

 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

Inputs Output
A B X
0 0 1
0 1 1
1 0 1
1 1 0

 The term NAND is a contraction of NOT-AND and implies an AND function


with a complemented (inverted) output.
Dr_hanan mohammed 16
The NAND Gate
Example1: waveforms:
A A X
B B

Example 2

Dr_hanan mohammed 17
The NAND Gate
 The NAND gate is particularly useful because it is a “universal” gate – all
other basic gates can be constructed from NAND gates.
Example: How would you connect a 2-input NAND gate to
form a basic inverter? (using 2-input NAND to get AND ,
NOT GATE
OR)
Logic Expressions for a NAND Gate
 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.)
Dr_hanan mohammed 18
Negative-OR Equivalent Operation Of A NAND Gate

 A NAND gate can be realized by an OR gate with inverted inputs. This


aspect of NAND operation is referred to as negative-OR.

 For a 2-input NAND gate performing a negative-OR operation, output X


is HIGH when either input A or input B is LOW, or when both A and B
are LOW.
Dr_hanan mohammed 19
NAND Gate Application
 Two tanks store certain liquid chemicals that are required in a manufacturing process.
Each tank has a sensor that detects when the chemical level drops to 25% of full. The
sensors produce a HIGH level of 5 V when the tanks are more than one-quarter full.
When the volume of chemical in a tank drops to one-quarter full, the sensor puts out
a LOW level of 0 V. It is required that a single green light-emitting diode (LED) on an
indicator panel show when both tanks are more than one-quarter full. Show how a
NAND gate can be used to implement this function.

 A NAND gate with its two inputs


connected to the tank level sensors and its
output connected to the indicator panel.
 When both tanks are more than one-
quarter full, the NAND gate output is LOW
(0 V) and the green LED is turned on.
Dr_hanan mohammed 20
NAND Gate Application
 For the process described in previous Example it has been decided to have a red LED
display come on when at least one of the tanks falls to the quarter-full level rather than
have the green LED display indicate when both are above one quarter. Show how this
requirement can be implemented.

 a NAND gate operating as a negative-OR


gate to detect the occurrence of at least
one LOW on its inputs.
 The operation can be stated as follows: If
tank A or tank B or both are below one-
quarter full, the LED is on.

Dr_hanan mohammed 21
The NOR Gate
 The term NOR is a contraction of NOT-OR and implies an OR function with an inverted
(complemented) output.
 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

Inputs Output
A X A B X
B
0 0 1
0 1 0
1 0 0
1 1 0

 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.

Dr_hanan mohammed 22
The NOR Gate
Example waveforms:
A A X
B B

The NOR operation will produce a LOW if any input is HIGH.

Example : When is the LED is ON for the circuit shown? +5.0 V

330 W
The LED will be on when any of the four
inputs are HIGH. A
X
B
C
D
Dr_hanan mohammed 23
Negative-AND Equivalent Operation of NOR Gate
 A NOR gate can be realized by an AND gate with inverted inputs. This aspect of NOR
operation is referred to as negative-AND.

 When a NOR gate is used to detect all LOWs on its inputs rather than one or more
HIGHs, it is performing the negative-AND operation and is represented by the
standard symbol in the above Figure. Remember that the two symbols in Figure
represent the same physical gate and serve only to distinguish between the two
modes of its operation. The following three examples illustrate this.
Dr_hanan mohammed 24
Negative-AND Equivalent Operation of NOR Gate
 As part of an aircraft’s functional
monitoring system, a circuit is required
to indicate the status of the landing
gears prior to landing. A green LED
display turns on if all three gears are
properly extended when the “gear
down” switch has been activated in
preparation for landing. A red LED
display turns on if any of the gears fail
to extend properly prior to landing.
When a landing gear is extended, its
sensor produces a LOW voltage. When
a landing gear is retracted, its sensor
produces a HIGH voltage. Implement a
circuit to meet this requirement. Dr_hanan mohammed 25
The XOR Gate
 The XOR gate produces a HIGH output only when both inputs are at opposite logic
levels. The truth table is

A X Inputs Output
B A B X
0 0 0
0 1 1
1 0 1
1 1 0

 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.

Dr_hanan mohammed 26
The XOR Gate
Example waveforms:
A A X

B B

 Notice that the XOR gate will produce a HIGH only when exactly one input is
HIGH.

Example : If the A and B waveforms are both inverted for the above
waveforms, how is the output affected?
Solution :There is no change in the output.
Dr_hanan mohammed 27
The XNOR Gate
 The XNOR gate produces a HIGH output only when both inputs are at the same logic
level. The truth table is

Inputs Output
A B X
0 0 1
0 1 0
1 0 0
1 1 1

 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.

Dr_hanan mohammed 28
The XNOR Gate
Example waveforms:
A
A X

B B

 Notice that the XNOR gate will produce a HIGH when both inputs are the same. This
makes it useful for comparison functions.

Example : If the A waveform is inverted but B remains the same, how is


the output affected?
The output will be inverted.
29
Dr_hanan mohammed 30
Dr_hanan mohammed 31
Dr_hanan mohammed 32
1. The truth table for a 2-input AND gate is

Inputs Output Inputs Output


A B X A B X
a. 0 0 0 b. 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 0

Inputs Output Inputs Output


A B X A B X
0 0 0 0 0 0
c. 0 1 0 d. 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
© 2008 Pearson Education
2. The truth table for a 2-input NOR gate is

Inputs Output Inputs Output


A B X A B X
a. 0 0 0 b. 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 0

Inputs Output Inputs Output


A B X A B X
0 0 0 0 0 0
c. 0 1 0 d. 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
© 2008 Pearson Education
3. The truth table for a 2-input XOR gate is

Inputs Output Inputs Output


A B X A B X
a. 0 0 0 b. 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 0

Inputs Output Inputs Output


A B X A B X
0 0 0 0 0 0
c. 0 1 0 d. 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
© 2008 Pearson Education
A ≥1 X
4. The symbol is for a(n)
B

a. OR gate
b. AND gate
c. NOR gate
d. XOR gate

© 2008 Pearson Education


A X
5. The symbol is for a(n)
B

a. OR gate
b. AND gate
c. NOR gate
d. XOR gate

© 2008 Pearson Education


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

© 2008 Pearson Education


7. The expression X = A + B means

a. A OR B
b. A AND B
c. A XOR B
d. A XNOR B

© 2008 Pearson Education


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

© 2008 Pearson Education


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

© 2008 Pearson Education


Answers:
1. c
6. b
2. b
7. c
3. a
8. d
4. a
9. d
5. d

You might also like