LEC 2-3-4 - Logic Functions Gate Circuit
LEC 2-3-4 - Logic Functions Gate Circuit
Main Book:
Chapter 2 - Part 1 3
Binary Logic and Gates
• Binary variables take on one of two values.
• Logical operators operate on binary values and binary
variables.
• Basic logical operators are the logic functions AND, OR
and NOT.
• Logic gates implement logic functions.
• Boolean Algebra: a useful mathematical system for
specifying and transforming logic functions.
• We study Boolean algebra as foundation for designing
and analyzing digital systems!
Chapter 2 - Part 1 4
Binary Variables
• Recall that the two binary values have different names:
• True/False
• On/Off
• Yes/No
• 1/0
• We use 1 and 0 to denote the two values.
• Variable identifier examples:
• A, B, y, z, or X1 for now
• RESET, START_IT, or ADD1 later
Chapter 2 - Part 1 5
Logical Operations
• The three basic logical operations are:
• AND
• OR
• NOT
Chapter 2 - Part 1 6
Switching Circuits
AND OR
Logic Function Implementation
• Using Switches Switches in parallel => OR
• For inputs:
• logic 1 is switch closed
• logic 0 is switch open
• For outputs:
• logic 1 is light on
• logic 0 is light off.
• NOT uses a switch such
that:
Switches in series => AND
• logic 1 is switch open
• logic 0 is switch closed
Chapter 2 - Part 1 8
Logic Function Implementation (Continued)
• Light is on (L = 1) for
L(A, B, C, D) =
and off (L = 0), otherwise.
• Useful model for relay circuits and for CMOS gate circuits, the
foundation of current digital logic technology
Chapter 2 - Part 1 9
Notation Examples
Y = A B • Examples:
z = x+ y •
•
is read “Y is equal to A AND B.”
is read “z is equal to x OR y.”
X=A • is read “X is equal to NOT A.”
Chapter 2 - Part 1 10
Binary Logic
• Truth Tables, Boolean Expressions, and Logic Gates
AND OR NOT
x y z x y z x z
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
z=x•y=xy z=x+y z = x = x’
x x x
y z y z z
Binary Logic
Logic gates
• Graphic Symbols and Input-Output Signals for Logic gates:
AND OR NOT
0·0=0 0+0=0 0=1
0·1=0 0+1=1 1= 0
1·0=0 1+0=1
1·1=1 1+1=1
Chapter 2 - Part 1 13
Logic Gates
Chapter 2 - Part 1 14
15
BUILDING BLOCKS OF
MODERN COMPUTERS
16
TRANSISTORS
17
Transistors
◼ Computers are built from very large numbers of very
small (and relatively simple) structures: transistors
• Intel 4004, in 1971, had 2300 MOS transistors
Problem
• Intel’s Pentium IV microprocessor, 2000, was made up
of more than 42 Million MOS transistors Algorithm
• Apple’s M2 Max, offered for sale in 2022, is made up of Program/Language
more than 67 Billion MOS transistors Runtime System
(VM, OS, MM)
• This lecture ISA (Architecture)
• How the MOS transistor works (as a logic element) Microarchitecture
• How these transistors are connected to form logic gates Logic
Devices
Electrons
❑ How logic gates are interconnected to form larger units that
are needed to construct a computer
18
MOS Transistor
• By combining
• Conductors (Metal)
• Insulators (Oxide) Gate
• Semiconductors Source Drain
n-type p-type
• They both operate “logically,” very similar to the way wall switches work
20
Power Supply
3
0 Volt
Gate
Power Supply
Shorthand notation
• The p-type transistor works in exactly the opposite fashion
from the n-type transistor
Drain Drain
The circuit is The circuit is
closed when the closed when the
Gate Gate gate is supplied
gate is supplied
with 3V p-type with 0V
n-type
Source Source 22
23
LOGIC GATES
24
p-type
0V
Ahmad Shabani Computer 26
Architecture 26
3V 3V
p-type transistor
pulls the output
0V Out (Y) Y = 3V up
0V 0V
A= 3V Out (Y) Y = 0V
n-type transistor
pulls the output
down
0V 0V
A P N Y
0 ON OFF 1 𝑌 = 𝐴ҧ
1 OFF ON 0
29
A
𝑌 =Y 𝐴ҧ
Truth table: shows what is the logical
A Y output of the circuit
Y = Afor each possible
input
We call this a NOT gate A Y
or an inverter 0 1
(bubble indicates 1 0
inversion)
Logic Diagrams and Expressions
Truth Table Equation
XYZ F = X + Y Z
000 0 F = X +Y Z
001 1
010 0 Logic Diagram
011 0 X
100 1
101 1 Y F
110 1 Z
111 1
• Boolean equations, truth tables and logic diagrams describe the same
function!
• Truth tables are unique; expressions and logic diagrams are not. This gives
flexibility in implementing functions.
Chapter 2 - Part 1 30
31
Boolean Algebra
Formal version English version
1. B contains at least two elements,
0 and 1, such that 0 ≠ 1 Math formality...
6. Complement:
(i) 𝐚 + 𝒂ഥ= 1 There is a complement element;
(ii) 𝐚 • 𝒂
ഥ=0 AND/ORing with it gives the identity elm.
34
a • (b + c) = (a • b) + (a • c)
➙ a + (b • c) = (a + b) • (a + c)
Dr. Ahmad Shabani Logic Design 35
Duality
• The principle of duality is an important concept. This says that if an
expression is valid in Boolean algebra, the dual of that expression
is also valid.
• To form the dual of an expression, replace all + operators with .
operators, all . operators with + operators, all ones with zeros, and
all zeros with ones.
• Form the dual of the expression
a + (bc) = (a + b)(a + c)
• Following the replacement rules…
a(b + c) = ab + ac
• Take care not to alter the location of the parentheses if they are
present.
Commutative Law:
6. X + Y = Y + X 6D. X • Y = Y • X Just an axiom…
37
Distributive Laws:
8. X • (Y+ Z) = (X • Y) + (X • Z) 8D. X + (Y• Z) = (X + Y) • (X + Z) Axiom
Simplification Theorems:
ഥ= X
9. X • Y + X • 𝒀 ഥ) = X
9D. (X + Y) • (X + 𝒀
Useful for
10. X + X • Y = X 10D. X • (X + Y) = X simplifying
expressions
ഥ) • Y = X • Y
11. (X + 𝒀 11D. (X • 𝒀
ഥ) + Y = X + Y
F=A+B+C
At least one of A, B, C is TRUE --> It is not the case that A, B, C are all false
40
ഥ𝒀ഥ 𝑿 𝑿 𝒀 𝑿+𝒀 ഥ 𝒀
𝑿 ഥ ഥ𝒀
𝑿 ഥ
𝑨 = (𝑿 + 𝒀) = 𝑿 𝒀 𝑨
0 0 1 1 1 1
0 1 0 1 0 0
NOR is equivalent to AND 𝑿 1 0 0 0 1 0
with inputs complemented 𝑨
𝒀 1 1 0 0 0 0
ഥ+𝒀
𝑩 = (𝑿𝒀) = 𝑿 ഥ 𝑿 𝑩 𝑿 𝒀 𝑿𝒀 ഥ 𝒀
𝑿 ഥ ഥ+𝒀
𝑿 ഥ
𝒀 0 0 1 1 1 1
0 1 1 1 0 1
NAND is equivalent to OR 𝑿
1 0 1 0 1 1
with inputs complemented 𝑩 1 1 0 0 0 0
𝒀
Dr. Ahmad Shabani Digital Logic 41
Consensus Theorem
1. xy + x’z + yz = xy + x’z
2. (x+y)•(x’+z)•(y+z) = (x+y)•(x’+z) -- (dual)
Proof:
xy + x’z + yz = xy + x’z + (x+x’)yz
= xy + x’z + xyz + x’yz
= (xy + xyz) + (x’z + x’zy)
= xy + x’z
Boolean Algebra
• Terminology:
• Literal: A variable or its complement
• Product term: literals connected by •
• Sum term: literals connected by +
• Represent the function of a logic block
• Functional Specification
• Methodically transform the function into simpler functions
• which lead to different hardware realizations
• Logic Minimization or Logic Simplification
• We can automate this process → Computer-Aided Design or Electronic
Design Automation
• Different Boolean expressions lead to different logic gate
implementations
→ Different hardware area, cost, latency, energy properties
Boolean Functions
• Implementation with logic gates
• F4 is more economical
F2 = x + y'z
F4 = x y' + x' z
February 11, 2024 44
Complement of a Function
• An interchange of 0's for 1's and 1's for 0's in the value of F
• By DeMorgan's theorem
• (A+B+C)' = (A+X)' let B+C = X
= A'X' by theorem 5(a) (DeMorgan's)
= A'(B+C)' substitute B+C = X
= A'(B'C') by theorem 5(a) (DeMorgan's)
= A'B'C' by theorem 4(b) (associative)
• Generalizations: a function is obtained by interchanging AND and OR
operators and complementing each literal.
• (A+B+C+D+ ... +F)' = A'B'C'D'... F'
• (ABCD ... F)' = A'+ B'+C'+D' ... +F'
February 11, 2024 46
Examples
47
𝐀 𝐁 𝐂 𝐅 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1
0 0 0 0 ഥ 𝐁𝐂 + 𝐀𝑩
𝑭=𝑨 ഥ𝑪ഥ + 𝐀𝑩 ഥ + 𝐀𝐁𝐂
ഥ 𝐂 + 𝐀𝐁𝑪
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
𝐀 𝐁 𝐂 𝐅
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1 100 = decimal 4 so this is minterm #4, or m4
1 0 1 1
1 1 0 1
1 1 1 1 111 = decimal 7 so this is minterm #7, or m7
Example: 𝒀 = 𝑨 ∙ 𝑩 ∙ 𝑪 + 𝑨 ∙ 𝑩 ∙ 𝑪 + 𝑨 ∙ 𝑩 ∙ 𝑪
A B C
A B C
minterm: ABC
minterm: ABC
minterm: ABC
• Solution #1: Expand the function to include all variables i.e., sum of
minterms.
Dr. Ahmad Shabani Logic Design 59
product
Product of Sums (POS) ഥ )(𝑨 + 𝑩
𝑭 = (𝑨 + 𝑩 + 𝑪)(𝑨 + 𝑩 + 𝑪 ഥ + 𝑪)
Each sum term represents one of the
“zeros” of the function sums
0 0 0 0 0 1 0 1 0
𝐀 𝐁 𝐂 𝐅 𝑭= 𝑨+𝑩+𝑪 ഥ (𝑨 + 𝑩
𝑨+𝑩+𝑪 ഥ + 𝑪)
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
𝑭
=𝟎
Only one of the products will be 0, anything ANDed with 0 is 0
ഥ
Or just remember” POS of 𝑭 is the same as the DeMorgan of SOP of 𝑭
64
ഥ )(𝑨 + 𝑩
𝐅 = (𝑨 + 𝑩 + 𝑪)(𝑨 + 𝑩 + 𝑪 ഥ + 𝑪)
𝐀 𝐁 𝐂 Maxterms ෑ 𝑴(𝟎, 𝟏, 𝟐)
0 0 0 𝑨 + 𝑩 + 𝑪 = M0
0 0 1 𝑨+𝑩+𝑪 ഥ = M1
0 1 0 𝑨+𝑩 ഥ + 𝑪 = M2 𝐀 𝐁 𝐂 𝐅 Note that you form
0 1 1 𝑨+𝑩 ഥ +𝑪ഥ = M3 0 0 0 0 the maxterms
around the “zeros”
ഥ + 𝑩 + 𝑪 = M4
1 0 0 𝑨 0 0 1 0
of the function
ഥ+𝑩+𝑪
1 0 1 𝑨 ഥ = M5 0 1 0 0
ഥ+𝑩
1 1 0 𝑨 ഥ + 𝐂 = M6 0 1 1 1
ഥ+𝑩
1 1 1 𝑨 ഥ +𝑪ഥ = M7 1 0 0 1 This is not the
1 0 1 1 complement of the
Maxterm shorthand notation function!
1 1 0 1
for a function of three variables 1 1 1 1
Dr. Ahmad Shabani Digital Logic 65
x + x y = (x + x )(x + y ) = 1 (x + y ) = x + y
Add missing variable z:
x + y + z z = ( x + y + z ) (x + y + z )
Express as POM: f = M2 · M3
Dr. Ahmad Shabani Digital Logic 66
= ෑ 𝑴(𝟎, 𝟏, 𝟐) = 𝒎(𝟎, 𝟏, 𝟐) 68
February 11, 2024 69
• Example
• F = xy + xz
• F(x, y, z) = S(1, 3, 6, 7)
• F(x, y, z) = P (0, 2, 4, 6)
70
• Starting with the canonical SOP or POS form enables convenience and
automation
• Truth table → SOP/POS form → Boolean Simplification Rules
71
Example: 𝒀 = 𝑨 ∙ 𝑩 ∙ 𝑪 + 𝑨 ∙ 𝑩 ∙ 𝑪 + 𝑨 ∙ 𝑩 ∙ 𝑪
A B C
A B C
minterm: ABC
minterm: ABC
minterm: ABC
Example: 𝒀 = 𝑩 ∙ 𝑪 + 𝑨 ∙ 𝑩
A
B
C
A
B
C A
F
A
B F B
C C
A
B
C
A
B
C
February 11, 2024 75
Logic Implementation
• Two-level implementation
• Multi-level implementation
February 11, 2024 76
Multiple Inputs
• Extension to multiple inputs
• A gate can be extended to multiple inputs.
• If its binary operation is commutative and associative.
• AND and OR are commutative and associative.
• OR
• x+y = y+x
• (x+y)+z = x+(y+z) = x+y+z
• AND
• xy = yx
• (x y)z = x(y z) = x y z
February 11, 2024 79
Multiple Inputs
• NAND and NOR are commutative but not associative → they are not extendable.
February 11, 2024 80
drive.
• Power dissipation.
• Propagation delay: the average transition delay time for the signal to
CAD
• CAD – Computer-Aided Design
• Millions of transistors
• Computer-based representation and aid
• Automatic the design process
• Design entry
• Schematic capture
• HDL – Hardware Description Language
• Verilog, VHDL
• Simulation
• Physical realization
• ASIC, FPGA, PLD
February 11, 2024 85
Chip Design
• Why is it better to have more gates on a single chip?
• Easier to build systems
• Lower power consumption
• Higher clock frequencies