2_Combinational Logic
2_Combinational Logic
Jia Chen
[email protected]
Outline
• Two types of logics
• The theory behind combinational logics
• The building blocks of combinational logics
2
Types of circuits
3
Combinational v.s. sequential logic
❑ Combinational logic
❑ Sequential logic
❑ Sequential logic
External Combinational External
inputs Logic outputs
Current Next
state state
Memory
Element
Internal output Internal input 5
When to use combinational logic?
• Which can we simply use combinational logics to accomplish?
① Counters
② Adders
③ Decimal to 7-segment LED-decoders
6
When to use combinational logic?
• How many of the following can we simply use combinational
logics to accomplish?
① Counters — You need the previous input
② Adders
③ Decimal to 7-segment LED-decoders
8
Boolean Algebra
9
Boolean algebra
❑ Boolean algebra — George Boole, 1815—1864
➢ Introduced binary variables
➢ Introduced the three fundamental logic operations: AND, OR, and NOT
➢ Extended to abstract algebra with set operations: intersect, union, complement
10
Basic Boolean Algebra Concepts
• {0, 1}: The only two possible values in inputs/outputs
• Basic operators
• AND (•) — a • b or ab
• returns 1 only if both a and b are 1s
• otherwise returns 0
• OR (+) — a + b
• returns 1 if a or b is 1
• returns 0 if none of them are 1s
• NOT (’) — a’ or !a or a
• returns 0 if a is 1
• returns 1 if a is 0
11
Generalization of AND & OR to > 2 variables
❑ Given n variables a1, a2, …, an where n > 2
➢ OR (+) — a1 + a2 … + an
• returns 1 if at least one variable is 1
• returns 0 if none of the variables are 1s
• In other words, it returns 0 if and only if a1 = a2 = … = an = 0
12
Truth tables
• A table sets out the functional values of logical expressions
on each of their functional arguments, that is, for each
combination of values taken by their logical variables
AND OR NOT
Input Input Input
Output Output Output
A B A B A
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
13
Let’s practice!
• X, Y are two Boolean variables. Consider the following function:
X•Y+X
How many of the following the input values of X and Y can lead to an output
of 1
① X = 0, Y = 0
② X = 0, Y = 1
③ X = 1, Y = 0
④ X = 1, Y = 1
A. 0
B. 1
C. 2
D. 3
E. 4
14
Let’s practice!
• X, Y are two Boolean variables. Consider the following function:
X • Y’ + X
How many of the following the input values of X and Y can lead to an output
of 1
① X = 0, Y = 0 Input
Output
② X = 0, Y = 1 X Y Y’ XY’ XY’ + X
③ X = 1, Y = 0 0 0 1 0 0 0
④ X = 1, Y = 1 0 1 0 0 0 0
A. 0 1 0 1 1 1 1
B. 1 1 1 0 0 1 1
C. 2
D. 3
E. 4
15
Derived Boolean operators
• NAND — (a • b)’
• NOR — (a + b)’
• XOR — (a + b) • (a’ + b’) or ab’ + a’b or a⨁b, a.k.a. odd operator
• XNOR — (a + b’) • (a’ + b) or ab + a’b’ or a⨀b, a.k.a. concurrence operator
NAND NOR XOR XNOR
Input Input Input Input
Output Output Output Output
A B A B A B A B
0 0 1 0 0 1 0 0 0 0 0 1
0 1 1 0 1 0 0 1 1 0 1 0
1 0 1 1 0 0 1 0 1 1 0 0
1 1 0 1 1 0 1 1 0 1 1 1
16
Generalization of XOR & XNOR to > 2 variables
❑ XOR: Exclusive-OR (Ex-OR for abbreviation)
❑ XNOR: Exclusive-NOR (Ex-NOR for abbreviation)
➢ XOR (⨁) — a1 ⨁ a2 … ⨁ an or a1 ⨀ a2 … ⨀ an
• returns 1 if there is an odd number of variables that are 1s
• otherwise returns 0
• odd operator
➢ XNOR (⨀) — a1 ⨀ a2 … ⨀ an or a1 ⨁ a2 … ⨁ an
• returns 1 if there is an even number of variables that are 1s
• otherwise returns 0
• concurrence operator
17
Express Boolean Operators/Functions
in Circuit “Gates”
AND NAND
OR NOR
XOR
NOT represents where we take a
compliment value on an input
represents where we take a XNOR
compliment value on an output
19
How to express y = e(ab+cd)
# inputs : 5 AND
# outputs : 1
a # gates : 4 OR
b # signal nets : 9
NOT
# pins: 12
c NAND
d NOR
y XOR
e
NXOR
20
We can make everything NAND!
Original NAND
a a
AND b b
a
a
OR
b
b
a a
NOT
21
We can also make everything NOR!
Original NOR
a
a
AND b
b
a a
OR b b
a a
NOT
22
How to express y = e(ab+cd)
a
b
c
d
y
e
23
How to express y = e(ab+cd)
a
b
c
d y
24
How gates are implemented?
25
Two type of CMOSs
CMOS: complementary metal-oxide-semiconductor
• nMOS S
• Turns on when G = 1
• When it’s on, passes 0s, but not 1s G
• Connect S to ground (0)
• Pulldown network
D
• pMOS
• Turns on when G = 0 S
• When it’s on, passes 1s, but not 0s
• Connect S to Vdd (Voltage Drain Drain,
G
positive supply voltage to a circuit, 1)
• Pullup network
26 D
Other symbols for CMOSs
S S
G nMOS G
D D
S S
G pMOS G
D
27
NOT Gate (Inverter)
Vdd
1 ON OFF 0
GND
28
Vdd
AND Gate
Vdd
A B
Output
A
B GND
GND 29
Vdd
OR Gate
A
Vdd
Output
A B
GND
GND 30
Vdd
NAND Gate
A B
Output
A
Input NMOS1 PMOS1 NMOS2 PMOS2
(passes 0 when (passes 1 when (passes 0 when (passes 1 when Output
A B on G=1) on G=0) on G=1) on G=0)
0 0 OFF ON OFF ON 1
0 1 OFF ON ON OFF 1
1 0 ON OFF OFF ON 1
B
1 1 ON OFF ON OFF 0
GND 31
Why use NAND?
• NAND and NOR are “universal gates” — you can build any
circuit with everything NAND or NOR
• Simplifies the design as you only need one type of gate
• NAND only needs 4 transistors — gate delay is smaller
than OR/AND that needs 6 transistors
• NAND is slightly faster than NOR due to the physics nature
32
How about total number of transistors?
33
However …
Inverter Inverter
Now, only 5 gates and 4 transistors each — 20 transistors!
a
b
c
d y
Inverter Inverter
e
34
How big is the truth table of y = e(ab+cd)
• How many rows in a truth table do we need to express the
circuit represented by y = e(ab+cd)?
A. 5
B. 9
C. 25
D. 32
E. 64
35
How big is the truth table of y = e(ab+cd)
• How many rows in a truth table do we need to express the
circuit represented by y = e(ab+cd)?
A. 5
B. 9
C. 25 2×2×2×2×2= 2 5 = 32
D. 32
Boolean expression is a lot more
E. 64
compact than a truth table!
36
Timing diagram
• A timing diagram graphically shows a circuit's output values for given
input values that change over time. Each signal (input or output)
name is listed on the left. Time proceeds to the right. Each signal is
drawn as a high line (1) or a low line (0).
a
y
b
37
Can We Get the Boolean
Equation from a Truth Table?
38
Definitions of Boolean Function Expressions
• Complement: variable with a bar over it or a ’ — A’, B’, C’
• A literal is a variable appearance, in true or complemented form,
in an expression— A, A’, B, B’, C, C’
• Implicant: product of literals — ABC, AC, BC
• Implicate: sum of literals — (A+B+C), (A+C), (B+C)
• A minterm is a product term having exactly one literal for every
function variable — ABC, A’BC, AB’C
• A maxterm is a sum term having exactly one literal for every
function variable — (A+B+C), (A’+B+C), (A’+B’+C)
39
Minterms and Maxterms
40
A canonical form of a Boolean equation
is a standard equation form for a
function
41
Canonical form — Sum of “Minterms”
Input
Output A minterm
X Y
0 0 0
0 1 0 f(X,Y) = XY’ + XY Sum (OR) of minterms
1 0 1
1 1 1
XNOR
Input
A B
Output f(A,B) = A’B’ + AB
0 0 1
0 1 0
1 0 0
1 1 1
42
Canonical form — Product of “Maxterms”
A maxterm
Input
Output
X Y f(X,Y) = (X+Y) (X + Y’) Product of maxterms
0 0 0
0 1 0
1 0 1
1 1 1
XNOR
Input
Output
A B
0 0 1 f(A,B) = (A+B’) (A’+B)
0 1 0
1 0 0
1 1 1
43
Sum-of-Products (SoP) Form
❑ A logic expression in the sum-of-products (SoP) form:
o Consisting of product (AND) terms that are summed (ORed)
❑ Represent a function f by a sum of minterms
f = 𝑚1 + 𝑚4 + 𝑚5 + 𝑚6
= ∑(𝑚1 , 𝑚4 , 𝑚5 , 𝑚6 )
=∑𝑚(1, 4, 5, 6)
=∑ 𝑥 , 𝑥 (1, 4, 5, 6)
1 2 , 𝑥3
44
Sum-of-minterms (a.k.a. canonical SoP)
• Different equations may represent the same function. Ex: y = a + b,
and y = a + a'b, represent the same function. The sameness is not
obvious, so a standard equation form is desirable.
• A canonical form of a Boolean equation is a standard equation form
for a function.
• Sum-of-minterms form is a canonical form of a Boolean equation
where the right-side expression is a sum-of-products with each
product a unique minterm.
45
Product-of-Sums (PoS) Form
❑ A logic expression in the product-of-sums (PoS) form:
o Consisting of sum (OR) terms that are the factors of a logical product
𝑓 = M0 M2 M3 M7
=Π M0 , M2 , M3 , M7
=Π M 0, 2, 3, 7
=Π 𝑥 , 𝑥 0, 2, 3, 7
1 2 , 𝑥3
46
Product-of-maxterms (a.k.a. canonical PoS)
• Product-of-maxterms form is a canonical form of a Boolean
equation where the right-side expression is a product-of-sums with
each sum a unique maxterm.
47
Let’s design a circuit!
48
Binary addition
3+2=5 3+3=6
1 carry 11
0011 0011
+0010 +0011
Input Output 0101 0 1 1 0 half adder — adder
A B Cin Out Cout without a carry as an
0 0 0 0 0 full adder — adder with
input
a carry as an input
0 1 0 1 0
Input Output
1 0 0 1 0
A B Out Cout
1 1 0 0 1
0 0 0 0
0 0 1 1 0
0 1 1 0
0 1 1 0 1
1 0 1 0
1 0 1 0 1
1 1 0 1
1 1 1 1 1 49
Half adder
Cout
50
The sum-of-product form of the full adder
• How many of the following minterms are part of the canonical sum-of-products form of the
full adder in generating the output bit, namely Out in the truth table?
① A’B’Cin’
② A’BCin’ Input Output
③ AB’Cin’ A B Cin Out Cout
④ ABCin’ 0 0 0 0 0
⑤ A’B’Cin
0 1 0 1 0
⑥ A’BCin
⑦ AB’Cin 1 0 0 1 0
⑧ ABCin 1 1 0 0 1
A. 0 0 0 1 1 0
B. 1
0 1 1 0 1
C. 2
D. 3 1 0 1 0 1
E. 4 1 1 1 1 1
51
The sum-of-product form of the full adder
• How many of the following minterms are part of the canonical sum-of-products form of the
full adder in generating the output bit, namely Out in the truth table?
① A’B’Cin’
② A’BCin’ Input Output
③ AB’Cin’ A B Cin Out Cout Out = A’BCin’+ AB’Cin’+ A’B’Cin+ ABCin
④ ABCin’ 0 0 0 0 0 Cout = ABCin’ + A’BCin + AB’Cin + ABCin
⑤ A’B’Cin
0 1 0 1 0
⑥ A’BCin
⑦ AB’Cin 1 0 0 1 0
⑧ ABCin 1 1 0 0 1
A. 0 0 0 1 1 0
B. 1
0 1 1 0 1
C. 2
D. 3 1 0 1 0 1
E. 4 1 1 1 1 1
52
sum-of-products (SoP)/product-of-sums (PoS)
• They can be used interchangeably
• Depends on if the truth table has more 0s or 1s in the
result
• Neither forms give you the “optimized” equation. By
optimized, we mean — minimize the number of operations
53
Can we simplify these
functions?
54
Laws in Boolean Algebra
OR AND
55
Duality
Duality: We swap all operators between (+ , ·)
and interchange all elements between (0 , 1).
For a theorem if the statement can be proven with the laws of Boolean algebra,
then the duality of the statement is also true.
For example: D
D D
56 D: dual
Some more tools
OR AND
57
Absorption Law
a + a’b = a + b
a(a’ + b) = ab
Shannon’s Expansion
59
f(a,b,c) = a f(1, b, c) + a’ f(0,b,c)
Applying Theorems
• Which of the following represents BC+BA+C’A?
1. AB+AC’ Consensus Theorem ab+ac+b’c = ab+b’c
2. BC+AC’
3. AB+BC
CB + BA1 + C’A
4. AB+AC = BC + BA (C’+C) + C’A
5. None of the other = BC + BAC’ + BAC + C’A
= (1+A)BC + (B+1)AC’
choices
= BC + AC’
60
SoP simplification
• For the truth table shown on the right, please simplify the
SoP as much as possible.
Input
Output
A B C
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 0 0 1
1 1 1 0
61
SoP simplification
• For the truth table shown on the right, please simplify the
SoP as much as possible.
F(A, B, C) =
Input
A’B’C’+ A’B’C+ A’BC’+ A’BC+ AB’C’+ ABC’ Output
A B C
= A’B’(C’+C)+ A’B(C’+C)+ AC’(B’+B) 0 0 0 1
= A’B’+ A’B + AC’ 0 0 1 1
= A’ + AC’= A’(1+C’)+AC’ Distributive Laws 0 1 0 1
= A’ + A’C’ + AC’ 0 1 1 1
= A’ + (A’+A)C’ 1 0 0 1
= A’ + C’ 1 0 1 0
1 1 0 1
1 1 1 0
62