Gates and Logic: From Transistors To Logic Gates and Logic Circuits
Gates and Logic: From Transistors To Logic Gates and Logic Circuits
and Logic:
From Transistors to Logic Gates and
Logic Circuits
Prof. Anne Bracy
CS 3410
Computer Science
Cornell University
2
Silicon Valley & the Semiconductor Industry
• Transistors:
• Youtube video “How does a transistor work”
https://www.youtube.com/watch?v=IcrBqCFLHIY
• Break: show some Transistor, Fab, Wafer photos
3
Transistors 101
Source Gate Drain Source Gate Drain
—
Insulator Insulator
- + + + + + + + + - - + + + + + + -
+ + P-type channel created
- + + + - - - + + + - - + + + - +- - + ++ -
P-type - P-type P-type - P-type
- N-type - - N-type -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
Off On
N-Type Silicon: negative free-carriers (electrons)
P-Type Silicon: positive free-carriers (holes)
P-Transistor: negative charge on gate generates electric field that
creates a (+ charged) p-channel connecting source & drain
N-Transistor: works the opposite way
Metal-Oxide Semiconductor (Gate-Insulator-Silicon)
• Complementary MOS = CMOS technology uses both p- & n-type
transistors
4
CMOS Notation
N-type Off/Open On/Closed
0 1
gate
P-type
Off/Open On/Closed
1 0
gate
6
2-Transistor Combination: NOT
• Logic gates are constructed by combining transistors
in complementary arrangements
• Combine p&n transistors to make a NOT gate:
CMOS Inverter :
power source (1) power source (1) power source (1)
7
Inverter
Vsupply (aka logic 1) Function: NOT
Symbol:
in out
in out
(ground is logic 0)
Truth Table:
In Out
0 1
1 0
8
Logic Gates
• Digital circuit that either allows
signal to pass through it or not
• Used to build logic functions
• Seven basic logic gates:
AND,
OR,
NOT,
NAND (not AND), George Boole,(1815-1864)
NOR (not OR),
XOR
Did you know?
XNOR (not XOR)
George Boole Inventor of the idea
of logic gates. He was born in
Lincoln, England and he was the son
of a shoemaker.
9
Logic Gates: Names, Symbols, Truth Tables
A Out
NOT: A 0 1
1 0
A B Out A B Out
A NAND: A
0 0 0 0 0 1
AND: B 0 1 0 B 0 1 1
1 0 0 1 0 1
1 1 1 1 1 0
A B Out A B Out
OR: A A 0 0 1
B
0 0 0
NOR:
0 1 1 B 0 1 0
1 0 1 1 0 0
1 1 1 1 1 0
A B Out A B Out
XOR:. A 0 0 0
XNOR: A
0 0 1
B 0 1 1 B 0 1 0
1 0 1 1 0 0
1 1 0 1 1 1
NOR Gate
Vsupply
Function: NOR
A Symbol:
B a
out
b
out
A B
Truth Table:
A B out
0 0 1
0 1 0
1 0 0
1 1 0
11
iClicker Question
Which Gate is this? Function:
Vsupply Vsupply
Symbol:
A B
out
B Truth Table:
A A B out
0 0
(A) NOT
0 1
(B) OR
(C) XOR 1 0
(D) AND 1 1
(E) NAND 12
Abstraction
• Hide complexity through simple abstractions
§ Simplicity
• Box diagram represents inputs and outputs
§ Complexity
• Hides underlying NMOS- and PMOS-transistors and atomic
interactions
Vdd a
in out d out
Vss b
a
d out
in out 13
b
iClicker Question
Which Gate is this? Function:
a Symbol:
b
Out
Truth Table:
A B out
0 0
(A) NOT
0 1
(B) OR
(C) XOR 1 0
(D) AND 1 1
(E) NAND 14
Universal Gates
• NAND and NOR:
§ Can implement any function with NAND or just NOR gates
§ useful for manufacturing
• NOT:
a
• AND: a
b
• OR:
a
b
15
What does this logic circuit do?
Function:
a Symbol:
Truth Table:
Out
d a b d Out
0 0 0
b 0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
17
Logic Implementation
How to implement a desired logic function?
a b c out minterm 1) Write minterms
0 0 0 0 a b c 2) Write sum of products:
0 0 1 1 a b c OR of all minterms where out=1
0 1 0 0 a b c out = abc + abc + abc
0 1 1 1 a b c a
1 0 0 0 a b c b
c
1 0 1 1 a b c out
1 1 0 0 a b c
1 1 1 0 a b c
19
Identities
a · 0 = 0
a · 1 = a
a · ā = 0
20
Identities
Identities useful for manipulating logic equations
• For optimization & ease of implementation
(a + b) = a • b
A A
↔ B
(ab) = a + b B
A A
B
↔ B
a + a b = a
a (b+c) = ab + ac
a(b + c) = a + b • c 21
Goals for Today
• From Switches to Logic Gates to Logic Circuits
• Transistors, Logic Gates, Truth Tables
• Logic Circuits
§ Identity Laws
§ From Truth Tables to Circuits (Sum of Products)
• Logic Circuit Minimization – why?
§ Algebraic Manipulations
§ Karnaugh Maps
22
Minimization Example
a + 0 = a Minimize this logic equation:
a + 1 = 1
a + ā = 1
a · 0 = 0 (a+b)(a+c) = (a+b)a + (a+b)c
a · 1 = a = aa + ba + ac + bc
a · ā = 0
= a + a(b+c) + bc
a + a b = a = a + bc
a (b+c) = ab + ac
(a + b) = a • b
(ab) = a + b
a(b + c) = a + b • c 23
iClicker Question
a + 0 = a (a+b)(a+c) à a + bc
a + 1 = 1
a + ā = 1
a · 0 = 0 How many gates were
a · 1 = a required before and after?
a · ā = 0
a + a b = a BEFORE AFTER
a (b+c) = ab + ac (A) 2 OR 1 OR
(B) 2 OR, 1 AND 2 OR
(a + b) = a • b (C) 2 OR, 1 AND 1 OR, 1 AND
(ab) = a + b (D) 2 OR, 2 AND 2 OR
a(b + c) = a + b • c (E) 2 OR, 2 AND 2 OR, 1 AND
24
Checking Equality w/Truth Tables
circuits ↔ truth tables ↔equations
Example: (a+b)(a+c) = a + bc
a b c (a+b) LHS (a+c) RHS bc
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1 25
Checking Equality w/Truth Tables
circuits ↔ truth tables ↔equations
Example: (a+b)(a+c) = a + bc
a b c (a+b) LHS (a+c) RHS bc
0 0 0 0 0 0 0 0
0 0 1 0 0 1 0 0
0 1 0 1 0 0 0 0
0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 0
1 0 1 1 1 1 1 0
1 1 0 1 1 1 1 0
1 1 1 1 1 1 1 1 26
Minimization in Practice
How does one find the most efficient equation?
• Manipulate algebraically until…?
• Use Karnaugh Maps (optimize visually)
• Use a software optimizer
27
Building a Karnaugh Map
a b c out
Sum of minterms yields
0 0 0 0
0 0 1 1
out =
0 1 0 0
0 1 1 1 abc + abc + abc + abc
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0
ab
c 00 01 11 10 K-maps identify which inputs
0 0 0 0 1 are relevant to the output
1 1 1 0 1
28
Minimization with K-Maps
ab
c 00 01 11 10 (1) Circle the 1’s (see below)
0 0 0 0 1 (2) Each circle is a logical
component of the final equation
1 1 1 0 1
= ab" + a"c
Rules:
• Use fewest circles necessary to cover all 1’s
• Circles must cover only 1’s
• Circles span rectangles of size power of 2 (1, 2, 4, 8…)
• Circles should be as large as possible (all circles of 1?)
• Circles may wrap around edges of K-Map
• 1 may be circled multiple times if that means fewer
circles
29
Karnaugh Minimization Tricks (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 or
1 0 0 1 0 more cells
out = c" + ab
30
Karnaugh Minimization Tricks (2)
ab
cd 00 01 11 10
00 0 0 0 0 • The map wraps around
01 1 0 0 1 out = b"d
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
31
Don’t Cares
ab “Don’t care” values can be
cd 00 01 11 10 interpreted individually in
00 0 0 0 0 whatever way is convenient
01 1 x x x
• assume all x’s = 1
11 1 x x 1 à out = d
10
0 0 0 0
ab • assume middle x’s = 0
cd 00 01 11 10
(ignore them)
00 1 0 0 x • assume 4th column x = 1
01 0 x x 0 " d"
à out = b
11 0 x x 0
10
1 0 0 1
32
Takeaway
• Binary —two symbols: true and false—is the basis of
Logic Design
33
Summary
• Most modern devices made of billions of transistors
§ You will build a processor in this course!
§ Modern transistors made from semiconductor
materials
§ Transistors used to make logic gates and logic circuits
• We can now implement any logic circuit
§ Use P- & N-transistors to implement NAND/NOR
gates
§ Use NAND or NOR gates to implement the logic
circuit
§ Efficiently: use K-maps to find required minimal terms
34