02 Gates I G
02 Gates I G
02 Gates I G
Hakim Weatherspoon
CS 3410, Spring 2015
Computer Science
Cornell University
See: P&H Appendix B.2 and B.3 (Also, see B.1)
From Switches to Logic Gates to Logic Circuits
Understanding the foundations of
Computer Systems Organization and Programming
From Switches to Logic Gates to Logic Circuits
Understanding the foundations of
Computer Systems Organization and Programming
e.g. Galaxy Note 3
From Switches to Logic Gates to Logic Circuits
Understanding the foundations of
Computer Systems Organization and Programming
e.g. Galaxy Note 3
with the big.LITTLE 8‐core ARM processor
From Switches to Logic Gates to Logic Circuits
Understanding the foundations of
Computer Systems Organization and Programming
e.g. Galaxy Note 3
with the big.LITTLE 8‐core ARM processor
big Quad Core LITTLE Quad Core
Architecture ARM v7a ARM v7a
Process Samsung 28nm Samsung 28nm
Frequency 200MHz~1.8GHz+ 200MHz~1.2GHz
Area 19mm2 3.8mm2
Power‐ratio 1 0.17
L1 Cache Size 32 KB I/D Cache 32 KB I/D Cache
L2 Cache Size 2 MB Data Cache 512 KB Data Cache
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)
• Acts as a conductor or
insulator
• Can be used to build
amazing things…
The Bombe used to break the German
Enigma machine during World War II
+
Truth Table
A A B Light
‐
OFF OFF
OFF ON
B ON OFF
ON ON
+
Truth Table
A A B Light
‐
OFF OFF OFF
OFF ON ON
B ON OFF ON
ON ON ON
+
A ‐ A B Light
OFF OFF
OFF ON
B ON OFF
ON ON
+
Truth Table
A A B Light
‐
OFF OFF OFF
OFF ON ON
B ON OFF ON
ON ON ON
+
A ‐ A B Light
OFF OFF
OFF ON
B ON OFF
ON ON
+
Either (OR)
Truth Table
A A B Light
‐
OFF OFF OFF
OFF ON ON
B ON OFF ON
ON ON ON
Both (AND)
+
A ‐ A B Light
OFF OFF OFF
OFF ON OFF
B ON OFF OFF
ON ON ON
Either (OR)
Truth Table
A A B Light
‐
OFF OFF OFF
OR OFF ON ON
B ON OFF ON
ON ON ON
Both (AND)
A ‐ A B Light
OFF OFF OFF
AND OFF ON OFF
B ON OFF OFF
ON ON ON
Either (OR)
Truth Table
A A B Light
‐
0 0 0 0 = OFF
OR 0 1 1 1 = ON
B 1 0 1
1 1 1
Both (AND)
A ‐ A B Light
0 0 0
AND 0 1 0
B 1 0 0
1 1 1
A
OR
B
George Boole,(1815-1864)
A Did you know?
George Boole Inventor of the idea
AND of logic gates. He was born in
B Lincoln, England and he was the son
of a shoemaker in a low class family.
Binary (two symbols: true and false) is the basis of
Logic Design
A Out
NOT: A
A B Out
0 0 0
AND: A 0 1 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
A Out
NOT: A 0 1
1 0
A B Out
0 0 0
AND: A 0 1 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]
A Out
NOT: A 0 1
1 0
A B Out A B Out
0 0 0 0 0 1
AND: A 0 1 0
NAND: A
0 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]
Fill in the truth table, given the following Logic
Circuit made from Logic AND, OR, and NOT gates.
What does the logic circuit do?
a b Out
a
b
Out
XOR: out = 1 if a or b is 1, but not both;
out = 0 otherwise.
out = 1, only if a = 1 AND b = 0
OR a = 0 AND b = 1
a b Out
0 0 0
0 1 1
1 0 1
a
1 1 0
b
Out
XOR: out = 1 if a or b is 1, but not both;
out = 0 otherwise.
out = 1, only if a = 1 AND b = 0
OR a = 0 AND b = 1
a b Out
0 0 0
0 1 1
1 0 1
a
Out
1 1 0
b
Fill in the truth table, given the following Logic
Circuit made from Logic AND, OR, and NOT gates.
What does the logic circuit do?
a b d Out
0 0 0
0 0 1
0 1 0 a
0 1 1
1 0 0 d Out
1 0 1
1 1 0 b
1 1 1
Multiplexor: select (d) between two inputs (a and b)
and set one as the output (out)?
out = a, if d = 0
out = b, if d = 1
a b d Out
0 0 0 0
0 0 1 0
0 1 0 0 a
0 1 1 1
1 0 0 1 d Out
1 0 1 0
1 1 0 1 b
1 1 1 1
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
Fewer gates: A cheaper ($$$) circuit!
A Out
NOT: A 0 1
1 0
A B Out
0 0 0
AND: A
0 1 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
.
A Out
NOT: A 0 1
1 0
A B Out A B Out
0 0 0 0 0 1
AND: A
0 1 0
NAND: A
0 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 + 0 = a
a + 1 = 1 a
a + ā = 1
b
a ∙ 0 = 0
a ∙ 1 = a
a ∙ ā = 0 a
b
Identities useful for manipulating logic equations
– For optimization & ease of implementation
=
=
a + a b =
a(b+c) =
=
Identities useful for manipulating logic equations
– For optimization & ease of implementation
A A
= ∙ B
↔ B
A A
= + B
↔ B
a + a b = a
a(b+c) = ab + ac
= + ∙
a + 0 = a Show that the Logic equations
a + 1 = 1
below are equivalent.
a + ā = 1
a 0 = 0
a 1 = a (a+b)(a+c) = a + bc
a ā = 0
(a+b)(a+c) =
=
= +
a + a b = a
a(b+c) = ab + ac
= + ∙
a + 0 = a Show that the Logic equations
a + 1 = 1
below are equivalent.
a + ā = 1
a 0 = 0
a 1 = a (a+b)(a+c) = a + bc
a ā = 0
(a+b)(a+c) = aa + ab + ac + bc
= = a + a(b+c) + bc
= +
a + a b = a = a(1 + (b+c)) + bc
a(b+c) = ab + ac = a + bc
= +
• 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
• functions: gates ↔ truth tables ↔ equations
• Example: (a+b)(a+c) = a + bc
a b c a+b a+c LHS bc RHS
0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 1 1 1 1
1 0 0 1 1 1 0 1
1 0 1 1 1 1 0 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
Binary (two symbols: true and false) is the basis of
Logic Design
More than one Logic Circuit can implement same
Logic function. Use Algebra (Identities) or Truth
Tables to show equivalence.
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)
How to standardize minimizing logic circuits?
How to implement a desired logic function?
a b c out
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 0
How to implement a desired logic function?
a b c out minterm 1) Write minterms
0 0 0 0 a b c 2) sum of products:
0 0 1 1 a b c • OR of all minterms where out=1
0 1 0 0 a b c
0 1 1 1 a b c
1 0 0 0 a b c
1 0 1 1 a b c
1 1 0 0 a b c
1 1 1 0 a b c
How to implement a desired logic function?
a b c out minterm 1) Write minterms
0 0 0 0 a b c 2) sum of products:
0 0 1 1 a b c • OR of all minterms where out=1
0 1 0 0 a b c • E.g. out = c + bc + a c
0 1 1 1 a b c a
b
1 0 0 0 a b c c
out
1 0 1 1 a b c
1 1 0 0 a b c
1 1 1 0 a b c
corollary: any combinational circuit can be implemented in
two levels of logic (ignoring inverters)
How does one find the most efficient equation?
– Manipulate algebraically until…?
– Use Karnaugh maps (optimize visually)
– Use a software optimizer
For large circuits
– Decomposition & reuse of building blocks
Sum of minterms yields
out = abc + abc + abc + abc
a b c out
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0
Sum of minterms yields
out = abc + abc + abc + abc
a b c out
0 0 0 0
0 0 1 1
0 1 0 0 Karnaugh maps identify
0 1 1 1 which inputs are (ir)relevant
1 0 0 1
1 0 1 1
to the output
1 1 0 0
1 1 1 0
ab
c 00 01 11 10
0 0 0 0 1
1 1 1 0 1
Sum of minterms yields
out = abc + abc + abc + abc
a b c out
0 0 0 0
0 0 1 1
0 1 0 0 Karnaugh maps identify
0 1 1 1 which inputs are (ir)relevant
1 0 0 1
1 0 1 1
to the output
1 1 0 0
1 1 1 0
ab
c 00 01 11 10
0 0 0 0 1
1 1 1 0 1
Sum of minterms yields
out = abc + abc + 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 + ac
1 1 1 0 1
ab
c 00 01 11 10
Minterms can overlap
0 0 1 1 1
out = bc + ac + 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
c 00 01 11 10
Minterms can overlap
0 0 1 1 1
out = bc + ac + 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
• out = b d
01 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 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
• out = b d
01 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
0 0 0 0 • assume all x’s = 1
ab
• out = d
cd 00 01 11 10
00 1 0 0 x
• assume middle x’s = 0
01 0 x x 0
• assume 4th column x = 1
11 0 x x 0
• out = b d
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
0 0 0 0 • assume all x’s = 1
ab
• out = d
cd 00 01 11 10
00 1 0 0 x
• assume middle x’s = 0
01 0 x x 0
• assume 4th column x = 1
11 0 x x 0
• out = b d
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
0 1 1
1 0 0
Derive logic diagram
1 0 1
1 1 0
1 1 1
a
a b d out
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
a
More than one Logic Circuit can implement same
Logic function. Use Algebra (Identities) or Truth
Tables to show equivalence.
Any logic function can be implemented as “sum of
products”. Karnaugh Maps minimize number of gates.
Dates to keep in Mind
• Prelims: Tue Mar 3rd and Thur April 30th
• Lab 1: Due Fri Feb 13th before Winter break
• Proj2: Due Thur Mar 26th before Spring break
• Final Project: Due when final would be (not known until Feb
14th)
Lab Sections (required)
• Labs sections are required.
– Separate than lecture and homework
• Bring laptop to Labs
• “Make up” lab sections only 8:40am Wed, Thur, or Fri
• This week: intro to logisim and building an adder
Register iClicker
• http://atcsupport.cit.cornell.edu/pollsrvc/
• iClicker GO
http://pollinghelp.cit.cornell.edu/iclicker‐go/#students
From Transistors to Gates to Logic Circuits
Logic Gates
• From transistors
• 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)
Transistors:
• 6:10 minutes (watch from from 41s to 7:00)
• http://www.youtube.com/watch?v=QO5FgM7MLGg
• Fill our Transistor Worksheet with info from Video
• NMOS Transistor PMOS Transistor
VD VS= 0 V
VG VG
VG = VS VG = 0 V VG = VS VG = 0 V
VS = 0 V VD
VG VG
VG = 1 VG = 0 VG = 1 VG = 0
VS = 0 V VD
• Function: NOT
0 1
in out • Called an inverter
• Symbol:
in out
(ground is logic 0)
• Function: NOT
1 0
in out • Called an inverter
• Symbol:
in out
(ground is logic 0)
• Function: NOT
in out A = 0 Out = 1 A = 1 Out = 0
• Called an inverter
• Symbol:
in out
(ground is logic 0)
1
A
A B out
0 0 1
1 0 1
0 1 1
1 1 0
Vsupply
• Function: NOR
0
A • Symbol:
0 a
B out
1 b
out
0 0
A B
A B out
0 0 1
1 0 0
0 1 0
1 1 0
NOT:
AND:
OR:
NAND and NOR are universal
• Can implement any function with NAND or just NOR gates
• useful for manufacturing
NOT: a
AND: a
b
OR: a
b
NAND and NOR are universal
• Can implement any function with NAND or just NOR gates
• useful for manufacturing
One can buy gates separately
• ex. 74xxx series of
integrated circuits
• cost ~$1 per chip, mostly
for packaging and testing
Cumbersome, but possible to
build devices using gates put
together manually
http://techguru3d.com/4th‐gen‐intel‐haswell‐processors‐architecture‐and‐lineup/
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