02 Gates W
02 Gates W
Hakim Weatherspoon
CS 3410, Spring 2015
Computer Science
Cornell University
Both (AND)
+
A - A B Light
OFF OFF
OFF ON
B ON OFF
ON ON
Either (OR)
Truth Table
A A B Light
-
OR
OFF OFF
OFF ON
B ON OFF
ON ON
Both (AND)
A - A B Light
OFF OFF
AND OFF ON
B ON OFF
ON ON
Either (OR)
Truth Table
A A B Light
-
OR 0 = OFF
0 0
0 1 1 = ON
B 1 0
1 1
Both (AND)
A - A B Light
0 0
AND 0 1
B 1 0
1 1
A
OR
B
George Boole,(1815-1864)
A B Out
AND: A 0 0
0 1
0
0
B 1 0 0
1 1 1
OR: A B Out
A
0 0 0
B 0 1 1
1 0 1
1 1 1
Logic Gates
• digital circuit that either allows a signal to pass through it or not.
• Used to build logic functions
• There are seven basic logic gates:
AND, OR, NOT,
NAND (not AND), NOR (not OR), XOR, and XNOR (not XOR) [later]
NOT:
A Out
A 0 1
1 0
A B Out
AND: A 0 0
0 1
0
0
B 1 0 0
1 1 1
OR: A B Out
A
0 0 0
B 0 1 1
1 0 1
1 1 1
Logic Gates
• digital circuit that either allows a signal to pass through it or not.
• Used to build logic functions
• There are seven basic logic gates:
AND, OR, NOT,
NAND (not AND), NOR (not OR), XOR, and XNOR (not XOR) [later]
NOT:
A Out
A 0 1
1 0
A B Out A B Out
AND: A 0 0
0 1
0
0
NAND: A
0 0
0 1
1
1
B 1 0 0 B 1 0 1
1 1 1 1 1 0
Logic Gates
• digital circuit that either allows a signal to pass through it or not.
• Used to build logic functions
• There are seven basic logic gates:
AND, OR, NOT,
NAND (not AND), NOR (not OR), XOR, and XNOR (not XOR) [later]
From Switches to Logic Gates to Logic Circuits
Logic Gates
• From switches
• Truth Tables
Logic Circuits
• Identity Laws
• From Truth Tables to Circuits (Sum of Products)
Logic Circuit Minimization
• Algebraic Manipulations
• Truth Tables (Karnaugh Maps)
Transistors (electronic switch)
Given a Logic function, create a Logic Circuit that
implements the Logic Function…
…and, with the minimum number of logic gates
A B Out
AND: A
0 0
0 1
0
0
B 1 0 0
1 1 1
OR: A
A B Out
0 0 0
B 0 1 1
1 0 1
XOR: 1 1 1
A B Out
A 0 0 0
0 1 1
B
1 0 1
1 1 0
.
NOT:
A Out
0 1
A
1 0
A B Out A B Out
AND: A
0 0
0 1
0
0
NAND: A
0 0
0 1
1
1
B 1 0 0 B 1 0 1
1 1 1 1 1 0
XOR: 1 1 1
XNOR:
1 1 0
A B Out A B Out
A 0 0 0 A 0 0 1
0 1 1 0 1 0
B B
1 0 1 1 0 0
1 1 0 1 1 1
.
NOT:
• out = ā = !a = ¬a
AND:
• out = a ∙ b = a & b = a ∧ b
OR:
• out = a + b = a | b = a ∨ b
XOR:
• out = a ⊕ b = ab� + āb
Logic Equations
• Constants: true = 1, false = 0
• Variables: a, b, out, …
• Operators (above): AND, OR, NOT, etc.
NOT:
• out = ā = !a = ¬a
AND: NAND:
• out = a ∙ b = a & b = a ∧ b • out = a · b = !(a & b) = ¬ (a ∧ b)
OR: NOR:
• out = a + b = a | b = a ∨ b • out = a + b = !(a | b) = ¬ (a ∨ b)
XOR: XNOR:
• out = a ⊕ b = ab� + āb • out = a ⊕ b = ab + ab
Logic Equations
• Constants: true = 1, false = 0
• Variables: a, b, out, …
• Operators (above): AND, OR, NOT,
• . etc.
Identities useful for manipulating logic equations
– For optimization & ease of implementation
a+0=
a+1=
a+ā=
a∙0 =
a∙1 =
a∙ā =
Identities useful for manipulating logic equations
– For optimization & ease of implementation
(a + b) =
(a � b) =
a+ab =
a(b+c) =
a(b + c) =
• functions: gates ↔ truth tables ↔ equations
• Example: (a+b)(a+c) = a + bc
a b c
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Binary (two symbols: true and false) is the basis of
Logic Design
ab
c 00 01 11 10
0 0 0 0 1
1 1 1 0 1
Sum of minterms yields
�
out = abc + a�bc + abc + abc
a b c out
0 0 0 0
0 0 1 1
0 1 0 0 Karnaugh map minimization
0 1 1 1
Cover all 1’s
1 0 0 1
1 0 1 1 Group adjacent blocks of 2n
1 1 0 0 1’s that yield a rectangular
1 1 1 0
shape
ab
c 00 01 11 10 Encode the common features
of the rectangle
0 0 0 0 1
out = ab� + a�c
1 1 1 0 1
ab
c 00 01 11 10
Minterms can overlap
0 0 1 1 1
out = b�c + a�c + ab
1 0 0 1 0
ab
c 00 01 11 10
0 1 1 1 1 Minterms can span 2, 4, 8
1 0 0 1 0
or more cells
out = c� + ab
ab
cd 00 01 11 10
00 0 0 0 0 The map wraps around
01 1 0 0 1 �
• out = bd
11 1 0 0 1
10
0 0 0 0
ab
cd 00 01 11 10
00 1 0 0 1
01 • out =
0 0 0 0
11 0 0 0 0
10
1 0 0 1
ab
cd 00 01 11 10
00 0 0 0 0 “Don’t care” values can be
01 1 x x x interpreted individually in
11 1 x x 1 whatever way is convenient
10 • assume all x’s = 1
0 0 0 0
ab
• out = d
cd 00 01 11 10
00 1 0 0 x
01
• assume middle x’s = 0
0 x x 0
• assume 4th column x = 1
11 0 x x 0
• out =
10
1 0 0 1
A multiplexer selects
a between multiple inputs
b • out = a, if d = 0
d • out = b, if d = 1
a b d out
0 0 0 Build truth table
0 0 1
0 1 0 Minimize diagram
Derive logic diagram
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Binary (two symbols: true and false) is the basis of
Logic Design
VG VG
VG = VS VG = 0 V VG = VS VG = 0 V
VS = 0 V VD = 0 V
VG VG
VG = 1 VG = 0 VG = 1 VG = 0
VS = 0 V VD = 0 V
• Function: NOT
in out • Called an inverter
• Symbol:
in out
(ground is logic 0)
A B out
0 0 1
1 0 1
0 1 1
1 1 0
Vsupply • Function: NOR
A • Symbol:
a
B out
b
out
A B
A B out
0 0 1
1 0 0
0 1 0
1 1 0
NOT:
AND:
OR:
AND: a
b
OR: a
b
in out d out
b
Vss
a
d out
in out
b
Most modern devices are made from billions of on /off
switches called transistors
• We will build a processor in this course!
• Transistors made from semiconductor materials:
– MOSFET – Metal Oxide Semiconductor Field Effect Transistor
– NMOS, PMOS – Negative MOS and Positive MOS
– CMOS – complementary MOS made from PMOS and NMOS transistors
• Transistors used to make logic gates and logic circuits
We can now implement any logic circuit
• Can do it efficiently, using Karnaugh maps to find the minimal
terms required
• Can use either NAND or NOR gates to implement the logic
circuit
• Can use P- and N-transistors to implement NAND or NOR gates