CHAPTER 2 LOGIC GATES
Objectives OR, AND, NOT, NAND, NOR, XOR and XNOR logic gates. Logic expression. Logic Circuits. Truth Table.
10
Logic Gates
2.1
Logic Gates
The basic building block of any digital circuit is a logic gate. OR, AND and NOT gates are the most basic gates. All other gates can be constructed using these three gates. Four other gates are NOR, NAND, XOR and XNOR gates. A logic gate has at least one and only one output. Let A and B represent two input variables listed on the left, and the output Y on the right. Logic gates operate with binary numbers. A binary 0 will mean a Low voltage (+0 volt) and a binary 1 will mean a High voltage (+5 volt). All possible input combinations for A and B and the output Y are shown using a truth table.
Input A 0 0 1 1 B 0 1 0 1 Output Y
Input A
Input B
Logic Gate
Output Y
Truth table
Logic Gate
2.2
OR Gate
The output of an OR gate is 1 if any of the inputs are 1. The parallel circuit shows the idea of an OR gate. The output lamp Y will light when either or both of the input switches are closed.
A B Y
A 0 0 1 1
B 0 1 0 1
Y=A+B 0 1 1 1
A B
Parallel circuit
Truth Table
OR gate symbol
Logic Gates
11
The Boolean expression for an OR gate is Y = A + B . Note that the plus (+) sign means OR in Boolean algebra. It is read as A OR B equals Y. The OR truth table can be expressed as follows: 0+0 0+1 1+0 1+1 = = = = 0 1 1 1
A 3 input OR logic gate will have 23 = 8 input combinations. The input variables are A, B and C. Note that if any of the inputs are 1, the output will be 1.
A B
A B C
C D
Y=A+B+C 3 input OR gate Truth Table
A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C 0 1 0 1 0 1 0 1 Y 0 1 1 1 1 1 1 1
Y=A+B+C+D 4 input OR gate Truth Table
A 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 B 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 C 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 D 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Y 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12
Logic Gates
2.3 AND Gate
The output of an AND gate is 1 if all of the inputs are 1. The serial circuit shows the idea of an AND gate. The output lamp Y will light when both of the input switches are closed.
A B Y
A 0 0 1 1
B 0 1 0 1
Y=A.B 0 0 0 1
A B
Serial circuit
Truth Table
AND gate symbol
The Boolean expression for an AND gate is Y = A B . Note that the dot ( ) sign means AND in Boolean algebra. It is read as A AND B equals Y. The dot sign is generally omitted, so that the expression becomes Y = AB . The AND truth table can be expressed as follows: 0.0 0.1 1.0 1.1 1.1 = = = = = 0 0 0 0 1
2.4 NOT Gate
The NOT gate has only 1 input. It is also called an inverter. The NOT gate produces an output that is the opposite of the input. If the input is 0, the output is 1. If the input is 1, the output is 0. Thus, the NOT gate inverts, or complement the input. The Boolean expression is Y = A , read as A inverted, A bar or A NOT.
A 0 1 Y 1 0
Truth Table
NOT gate symbol
12
Logic Gates
2.5 NOR Gate
NOR gate means NOT OR. It is actually an OR gate followed by an inverter. In other words, the output of an OR gate is inverted to form a NOR gate. The NOR gate symbol is an OR gate with an invert bubble at the output. The Boolean expression is Y = A + B .
A 0 0 1 1 B 0 1 0 1 Y 1 0 0 0
A B
Y =
A B
Invert bubble
Truth Table
NOR gate symbol
2.6
NAND Gate
NAND gate means NOT AND. It is actually an AND gate followed by an inverter. In other words, the output of an AND gate is inverted to form a NAND gate. The NOR gate symbol is an AND gate with an invert bubble at the output. The Boolean expression is Y = AB .
A 0 0 1 1
B 0 1 0 1
Y 1 1 1 0
A B
Y =
A B
Truth Table
NOR gate symbol
2.7 XOR Gate
XOR gate is Exclusive-OR gate. The output is 1 if an odd number of 1s appear at the inputs. The input 01 and 10 of the truth table have odd
Logic Gates
13
numbers of 1s, and therefore the output is 1. The Boolean expression is Y = A B , that can also be written as Y = A.B + A.B .
A 0 0 1 1 B 0 1 0 1 Y 0 1 1 0
A B
Truth Table
XOR gate symbol
2.8 XNOR Gate
XNOR gate is exclusive-NOR gate. The output of an XNOR gate is the complement of the XOR gate. The Boolean expression for XNOR gate is Y = A B , that can also be written as Y = A.B + A.B .
A 0 0 1 1 B 0 1 0 1 Y 1 0 0 1
A B
Truth Table
XNOR gate symbol
2.9 Combining logic gates
Logic gates are combined to form a new logic function. This logic circuit is also known as combinational logic circuit. The output of the circuit is determined by the Boolean expression. Suppose you are given a Boolean expression Y = AB + C . The output of AB is connected as an input to OR gate along with C to produce the output Y. The truth table is shown below.
A B C Y
A 0 0 0 0 1 1 1 1
B 0 0 1 1 0 0 1 1
C 0 1 0 1 0 1 0 1
AB 0 0 0 0 0 0 1 1
AB+C=Y 0 + 0=0 0 + 1=1 0 + 0=0 0 + 1=1 0 + 0=0 0 + 1=1 1 + 0=1 1 + 1=1
14
Logic Gates
Exercises
1. Derive the truth tables for the following logic gates: a. b. c. d. 3 3 3 3 input input input input AND gate NAND gate XOR gate XNOR gate.
2. Write the Boolean expressions for the following logic circuits: a.
A B Y C D
b.
A B C Y
c.
d.
A B Y C D
A B C Y
e.
A B C Y
f.
A B Y C D
3. Write the Boolean expressions for the following logic circuits: a.
A B C Y
b.
A B C Y
Logic Gates c.
A B C D Y
15 d.
A B C D Y
4. Write the Boolean expressions for the following logic circuits: a.
A B C Y
b.
A B C Y
c.
A B C Y
d.
A B C Y
e.
A B Y C D
f.
A B Y C D
5. Write the Boolean expressions for the following logic circuits: a.
A B C Y
b.
A B C Y
16 c.
A B C Y
Logic Gates d.
A B Y C D
e.
A B C Y
f.
A B Y C D
6. Draw the logic circuits for the following Boolean expressions: a. b. c. d. f.
Y = AB + C Y = AB + CD Y = A B + CD Y = (A + B)C
e. Y = (A + B)(C + D)
Y = A.B + C.D
g. Y = A.B.C h. Y = ABCD 7. Derive the truth tables for the following Boolean expressions: a. Y = AB + C b. Y = (A + B)C c. Y = ABC
Logic Gates
17
8. The NAND gate expression Y = AB is not equivalent to Y = A.B . Derive the expression Y = A.B truth table. 9. The logic expression A.B is not equivalent to Y = AB = AB . Derive the truth table for A.B . 10. Derive the expression Y = AB + AB truth table. Is it equivalent to the expression Y = A B ?