Introduction To Electronics Part 4: Digital Electronics L02: Digital Design
Introduction To Electronics Part 4: Digital Electronics L02: Digital Design
1
Binary Subtraction
• For subtraction, we use the following
𝐴 − 𝐵 = 𝐴 + (−𝐵)
• Example: 7 − 5 =?
• 7 = 0111
• 5 = 0101
• −5 =?
n-bit binary
number x
2 − 1 − 1011
4
x = 1011, n = 4
1’s complement
• What does this binary number represent?
1011
1111 − 1011 = 0100
2’s complement
0100 + 1 = 0101
1011 represents – 5
With n = 4 bit,
a 4 bit number can represent numbers from –8 to 7 (signed in 2’s complement form)
Unique zero
representation
magnitude
magnitude
magnitude
2n-1 – 1
positive nos.
2’s comp. of
0 and -8 are
themselves
magnitude
magnitude
magnitude
2n-1
negative nos.
10 – 6 = ?
n = 5 bit representation 1010 ⇒ (01010)2 610 ⇒ (00110)2
2’s complement of 00110 is 11010
01010
11010
----------
100100 0100 2 ⇒ 410 Answer is + 4
6 – 10 = ?
610 ⇒ (00110)2 1010 ⇒ (01010)2
2’s complement of 01010 is 10110
Answer is – 4
Dr. Rik Dey ESC201, 2023-24 Sem-II 10
Addition/Subtraction Computation
August 2016: Casino machine at Resorts World Casino printed a prize ticket of $42,949,672.76
as a result of an overflow bug. The Casino refused to pay this amount calling it a malfunction.
The Iowa Supreme Court ruled in favor of the Casino.
Dr. Rik Dey ESC201, 2023-24 Sem-II 12
Addition
S a b S C
0 0 0 0 Truth Table
0 1 1 0
C Half Adder
1 0 1 0
1 1 0 1
a b
a
How to get this gate S
b
implementation?
C
x y x1 x2 y x1 x2 y
0 1 0 0 0 0 0 0
0 1 0 0 1 1
1 0 1 0 0 1 0 1
1 1 1 1 1 1
x1 x1
AND y OR y
x2 x2
Dr. Rik Dey ESC201, 2023-24 Sem-II 14
Gates with more than 2 inputs
x1
AND: y = x1. x 2 . x3 ... x2
x3
AND y
x1
OR: y = x1 + x 2 + x3 + .... x2
y
x3
x1x2 x1+x2
x1 x1
AND x1x2 OR x1+x2
x2
x2
x1 x1
NAND y NOR y
x2 x2
Dr. Rik Dey ESC201, 2023-24 Sem-II 16
Gate Level Abstraction: Logic Gates
NOT: y = x x y
x1
AND: y = x1 . x 2 x2
AND y
x1
OR: y = x1 + x 2 OR y
x2
x1
NAND: y = x1. x 2 x2
NAND y
x1
NOR: y = x1 + x 2 x2
NOR y
Dr. Rik Dey ESC201, 2023-24 Sem-II 17
How to get an expression from truth table?
x1 x2 y
x1
0 0 0
y
0 1 1
x2 1 0 0
1 1 0
y = 1 when x1 is 0 and x2 is 1
x1 x2 y y = x1 . x2 x1 x2 y
y = x1 . x2
0 0 1 0 0 0
0 1 0 0 1 0
1 0 0 1 0 1
1 1 0 1 1 0
x1 x2 y x1 . x2
0
0
0
1
1
0
y = x1 . x2 + x1. x2
1 0 0
x1 . x2
(NOT 𝑥1 ) AND (NOT 𝑥2 ) OR 𝑥1 AND 𝑥2
1 1 1
Dr. Rik Dey ESC201, 2023-24 Sem-II 19
Boolean Expressions & Truth Tables: XOR & XNOR Gate
x1 x2 y x1 x2 y
0 0 0 0 0 1
0 1 1 0 1 0
1 0 1 1 0 0
1 1 0 1 1 1
y = x1 . x2 + x1. x2 y = x1 . x2 + x1. x2
Sum of Products (SOP) form Sum of Products (SOP) form
XOR gate XNOR gate
x1 x1
XNOR
XOR y
XOR y x2
x2
Dr. Rik Dey ESC201, 2023-24 Sem-II 20
Boolean Expressions & Truth Tables
Instead of writing expressions as sum of terms that make y equal to 1,
we can also write expressions using terms that make y equal to 0
x1 x2 y
y = x1 . x2 + x1 . x2 + x1. x2
0 0 1 Here we are telling when
0 1 1 y will be true
1 0 1
1 1 0 y = 𝑥1 . 𝑥2 FALSE when both are true
Here we are telling when
Recall
y will be false
y = 𝑥1 + 𝑥2 𝑥1 + 𝑥2 = 𝑥1 . 𝑥2
x1 x2 y x1 + x2
0 0 0 y = (x1 + x2 ).( x1 + x2 )
0 1 1
1 0 1 x1 + x2
1 1 0
0 1 0 0 x1
x2
0 1 1 1 x3
y
x1
1 0 0 0 x2
1 0 1 1 x3
x1
1 1 0 0 x2
1 1 1 1 x3
A SOP or POS expression can be easily implemented using NOT, AND & OR gates.
NAND to Inverter x. x = x
NAND to AND
x. y x. y
x
NAND to OR
y f = x. y = x + y
Dr. Rik Dey ESC201, 2023-24 Sem-II 27
Implementation using only NAND gates
A SOP expression is easily implemented with NAND gates.
a
b
f =a.b + c.d + f .g
c
d f
g
h
AND OR
c
d f
g
h
a
b
There is a one-to-one mapping c
between AND-OR network and f
NAND network d
g
h
Dr. Rik Dey ESC201, 2023-24 Sem-II 29
NOR Gates are Universal
NOR to Inverter x+ x = x
NOR to OR
x+ y x+ y
NOR to AND
x
f = (𝑎 + 𝑏). (𝑐 + 𝑑). (𝑓 + 𝑔)
a
b
c
d f
g
h
OR AND
c
d f
g
h
a
b
There is a one-to-one mapping c
between OR-AND network and d f
NOR network
g
h
Simplification Minimization
• Show 𝑥 + 𝑥 = 𝑥
𝑥 𝑥 𝑥+𝑥
0 0 0
1 1 1
• Show 𝑥 . 𝑦 = 𝑥ҧ + 𝑦ത
𝑥 𝒚 𝑥 .𝑦 𝑥ҧ + 𝑦ത
0 0 1 1
1 0 1 1
0 1 1 1
1 1 0 0
Dr. Rik Dey ESC201, 2023-24 Sem-II 35
How to verify an expression?
• Using truth tables
• Using postulates
(x1.x 2 + x 2 .x 3 ) == ?(x1. x 2 ) . (x 2 . x 3 )
= (x1 +x 2 ) . (x 2 + x 3 )
= (x1 + x 2 ) . (x 2 + x 3 )
= x1. x 2 + x 2 .x 2 +x1 . x 3 + x 2 . x 3
= x1. x 2 + x1 . x 3 + x 2 . x 3
f = 𝑥lj + 𝑥.lj 𝑦lj + 𝑥. 𝑦lj
f = 𝑥lj + 𝑦.lj 𝑥lj + 𝑥
f = 𝑥lj + 𝑦lj
Principle: x + x = 1 and x + x = x
Simplification will yield y = x3 which does not require any gates at all !
Boolean Expression f = x .y . z + x . y . z + x . y . z + x . y . z
Minimized ⇒ f=𝑧
Boolean Expression
Gate Netlist
Dr. Rik Dey ESC201, 2023-24 Sem-II 40
Compact Representation: Min-terms
• SOP => sum of min-terms
x y f1 x y min term
0 0 0 0 0 x.y m0
0 1 1 0 1 x.y m1
1 0 1 1 0 x.y m2
1 1 0 1 1 x.y m3
f1 = x . y + x. y f1 = m1 + m2 f1 = (1, 2)
f 2 = (0, 2,3) = ? f 2 = x . y + x. y + x . y
Dr. Rik Dey ESC201, 2023-24 Sem-II 41
Compact Representation: Min-terms
Three variable functions
x y z min terms
0 0 0 x.y.z m0
0 0 1 x.y.z m1
0 1 0 x.y.z m2
0 1 1 x.y.z m3
1 0 0 x.y.z m4
1 0 1 x.y.z m5
1 1 0 x.y.z m6
1 1 1 x.y.z m7
f 2 = (1, 4, 7) = ? f 2 = x . y. z + x. y. z + x . y . z
Dr. Rik Dey ESC201, 2023-24 Sem-II 42
Compact Representation: Max-terms
• POS => product of maxterms
x y f1 x y Max term
0 0 0 0 0 x+y M0
0 1 1 0 1 x+y M1
1 0 1 1 0 x+y M2
1 1 0 1 1 x+y M3
f1 = (x + y ) (x + y )
f1 = M 0 M 3 f1 = (M 0 , M 3 )
Dr. Rik Dey ESC201, 2023-24 Sem-II 43
Compact Representation: Max-terms
Three variable functions
x y z Max. terms
0 0 0 x + y + z M0
0 0 1 x + y + z M1
0 1 0 x + y + z M2
0 1 1 x + y + z M3
1 0 0 x + y + z M4
1 0 1 x + y + z M5
1 1 0 x + y + z M6
1 1 1 x + y + z M7
y
x y min term 0 1
x
0 0 x.y m0 0 m0 m1 only x is different
0 1 x.y m1
1 0 x.y m2
1 m2 m3
1 1 x.y m3
only 1 bit is different
only y is different
Dr. Rik Dey ESC201, 2023-24 Sem-II 45
K-map Example
x y f1 y
x 0 1
0 0 0
f1 = (1,2) 0 0 1
0 1 1
1 0 1
1 1 0 1 1 0
y
x 0 1
0 1 0
f2 = 𝑥. 𝑦 + 𝑥. 𝑦 f2 = (0,4)
1 0 1
yz yz
x 00 01 11 10 x 00 01 11 10
0 m0 m1 m3 m2 0 1 1 0
0
1 m4 m5 m7 m6 1 0 1 1 0 only 1 bit is different
yz
x 00 01 11 10
0 1 0 1 0
1 0 1 1 0
f = x.y . z + x. y . z + x. y . z + x. y . z
yz
wx 00 01 11 10
00 1 0 1 0
01 0 1 1 0 f =w. x . y . z + w. x . y . z + w. x . y . z + w. x . y . z
11 1 0 0 1
+ w . x . y . z + w . x . y. z + w . x . y . z
10 1 0 0 0
y
f2 = (1,2,3) x 0 1
1s that are next to each other
0 0 1 represent possible groupings
1 1 1
𝑓 = 𝑥 ⋅ 𝑦lj + 𝑥 ⋅ 𝑦 + 𝑥lj ⋅ 𝑦
Each circle (pair of 1s)
= 𝑥 ⋅ 𝑦lj + 𝑥 ⋅ 𝑦 + 𝑥lj ⋅ 𝑦 + 𝑥 ⋅ 𝑦 represents a simplified term
= 𝑥 ⋅ 𝑦lj + 𝑦 + 𝑥lj + 𝑥 ⋅ 𝑦
f = x.y . z + x. y . z + x. y . z + x. y . z
yz
x 00 01 11 10
0 1 0 0 1
1 0 1 1 0 x. z
x. z f = x . z + x. z
Dr. Rik Dey ESC201, 2023-24 Sem-II 51
Simplification using K-map: Grouping of 22 = 4 terms
f = x. y . z + x . y . z + x . y . z + x . y . z
f =x . y + x . y
yz
x 00 01 11 10
0 0 0 0 0
z z
yz
x 00 01 11 10
𝑧
0 1 0 0 1
f=𝑥+𝑧
1 1 1 1 1
𝑥
Dr. Rik Dey ESC201, 2023-24 Sem-II 53
K-map Caveat: Grouping Only Powers of 2 Rectangle
• Do not circle 3 terms
yz
x 00 01 11 10
0 0 0 0 f =x . y. z + x. y.z + x. y.z
0
1 1 1 1 0 = x . y + x.z
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 1 0 1 0 00 1 0 1 0
0 1 1 0 01 0 1 1 0
01
11 1 0 0 1 11 1 0 0 1
10 1 0 0 0 10 1 0 0 0
w. x . y . z + w. x . y . z = w. x . z w. x . y . z + w. x . y . z = x . y . z
11 1 0 0 1
w. x . z
10 1 0 0 0
w. y . z Is this the
simplest
f = w . y. z + w . x. z + w . y. z + w . x . y. z + w . x . y. z expression ?
Dr. Rik Dey ESC201, 2023-24 Sem-II 56
K-map: 4-variable Minimization
yz
wx 00 01 11 10
00 1 0 1 0
x. y. z 0 1 1 0
w. y . z
01
11 1 0 0 1
w. x . z 10 1 0 0 0
w. x . z
w. y . z
f = w . y. z + w . x. z + w . y. z + w . x . z + x . y. z
Can we do
ever better?
Dr. Rik Dey ESC201, 2023-24 Sem-II 57
K-map: 4-variable Minimization
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 1 0 1 0 00 1 0 1 0
01 0 1 1 0 01 0 1 1 0
11 1 0 0 1 11 1 0 0 1
10 1 0 0 0 10 1 0 0 0
f = w . y. z + w . x. z + f = w . y. z + w . x. z +
w . y. z + w . x . z + x . y. z w . x . z + x . y. z
Dr. Rik Dey ESC201, 2023-24 Sem-II 58
K-map Minimization: Non-uniqueness
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 1 0 0 0 00 1 0 0 0
01 1 1 0 0 01 1 1 0 0
11 0 0 0 0 11 0 0 0 0
10 1 0 0 1 10 1 0 0 1
f = w . x. y + w. x. z + w . y. z f = w . x. y + w. x. z + x . y. z
yz x. z
wx 00 01 11 10
00 0 1 0 0
yz
1 1 1 1 wx 00 01 11 10
01
00 0 0 0 0
11 0 1 0 0
01 0 1 1 0
w. x 10 0 1 0 0 w. z
11 0 1 1 0
10 0 1 1 0
y.z
Dr. Rik Dey ESC201, 2023-24 Sem-II 60
K-map: Combining Group of 8
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 0 1 1 0 00 0 0 0 0
1 1 1 1
01 0 1 1 0
z 01
11 1 1 1 1
x
11 0 1 1 0
10 0 1 1 0 10 0 0 0 0
yz yz
wx 00 01 11 10
wx 00 01 11 10
00 1 0 0 1
00 1 1 1 1
01 1 0 0 1 0 0 0 0
01
11 1 0 0 1
z 11 0 0 0 0
x
10 1 0 0 1 10 1 1 1 1
Dr. Rik Dey ESC201, 2023-24 Sem-II 61
K-map: Combining Group of 8
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 0 0 0 0 00 0 1 1 0
01 1 0 0 1 01 0 0 0 0
11 1 0 0 1
x. z 11 0 0 0 0
x. z
10 0 0 0 0 10 0 1 1 0
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 1 0 0 1 00 1 0 1 0
01 0 0 0 0 01 0 0 0 0
x. z ??
11 0 0 0 0 11 0 0 0 0
10 1 0 0 1 10 1 0 1 0
Dr. Rik Dey ESC201, 2023-24 Sem-II 62
K-map: Combining Group of 2k
yz yz
wx 00 01 11 10 wx 00 01 11 10
00 0 1 0 1 00 0 1 0 1
01 1 1 1 1 1 1 0 1
01
11 1 1 1 1 11 1 1 1 1
10 0 0 0 1 10 0 0 0 1
yz
x 00 01 10 11
0 0 0 0 0
1 0 1 1 0