Boolean algebra George Boole (1815-1864) นักคณิ ตศาสตร์ชาวอังกฤษผูค้ ิดค้น Boolean Algebra ซึ่งเป็ นวิชาพีชคณิ ตใช้เฉพาะกับ Logic เมื่อปี ค.ศ.

Download Report

Transcript Boolean algebra George Boole (1815-1864) นักคณิ ตศาสตร์ชาวอังกฤษผูค้ ิดค้น Boolean Algebra ซึ่งเป็ นวิชาพีชคณิ ตใช้เฉพาะกับ Logic เมื่อปี ค.ศ.

Boolean algebra
George Boole (1815-1864) นักคณิ ตศาสตร์ชาวอังกฤษผูค้ ิดค้น
Boolean Algebra ซึ่งเป็ นวิชาพีชคณิ ตใช้เฉพาะกับ Logic เมื่อปี
ค.ศ. 1854 จากนั้น Boolean Algebra ก็ได้รับ
การวิวฒั นาการเรื่ อยๆ มาจนกระทัง่ ปี ค.ศ. 1938
จึงถูกนามาใช้ในวิชา Theory of switching circuits
โดย C. E. Shannon ถึงแม้วา่ ผลงานของ Shannon
จะหนักไปในด้านการออกแบบสวิทซ์
แม่เหล็กไฟฟ้ า (Electromechanical Relay
Network) แต่กส็ ามารถที่จะปรับปรุ งมา
ใช้งานได้ดีสาหรับวงจร Solid-state
electronic ทุกวันนี้
1
Boolean Algebra
• Boolean Algbera is a mathematical Model for digital
logic circuits.
– Boolean Algebra is a system <B, V, P>
• B={0,1} is the set of values1
• V is the set of variables
• P={+, •, ΄} is the set of operators (basic
functions) defined by the truth tables as follows
2
Boolean values
Boolean Algebra แตกต่างไปจากวิชาพีชคณิ ตที่เรารู ้จกั กัน ค่า
ตัวแปรต่างๆ จะมีได้เพียง 2 ค่าเท่านั้น คือ
false or true
0 or 1
low or high
กฎเกณฑ์บางอันก็คล้ายคลึงกันบางอันก็ต่างกันมาก กฎต่างๆ
ของ Boolean algebra ที่สาคัญมีดงั นี้
3
Boolean operations
•
•
•
•
•
•
not
or
and
xor (exclusive or)
nand (not and)
nor (not or)
4
Not
x
0
1
x
0
Note: Some people write x’ instead of x.
The “bubble” (or “bobble”) means “not”.
5
And
a
0
0
1
1
b
0
1
0
1
a·b
0
1
and
Notes: Some people write a^b or a&b.
The gate is shaped like a “D” as in “anD”.
6
Or
a
0
0
1
1
b
0
1
0
1
a+b
0
1
1
1
or
or
Note: Some people write ab or a|b.
7
Exclusive-or (xor)
a
0
0
1
1
b
0
1
0
1
ab
0
1
1
1
8
Nand
a b a·b a·b
0
0
0
0
1
0
1
0
0
1
1
1
9
Nor
a b a+b a+b
0
0
0
0
1
1
1
0
1
1
1
1
10
Boolean Algebra
The axioms (or postulates) of Boolean Algebra
(A1) X=0 หรื อ (A1’) X=1
(A2) If X=0, then X’=1 (A2’) If X=1, then X’=0
(A3) 0·0 = 0
(A3’) 1+1 = 1
(A4) 1·1 = 1
(A4’) 0+0 = 0
(A5) 0·1 = 1·0 = 0
(A5’) 1+0 = 0+1 = 1
Note We use a prime (’) to denote an inverter’s function.
11
Theorems involving a single variable:
(T1)
(T2)
(T3)
(T4)
(T5)
X+0 = X
X+1 = 1
X+X = X
(X’)’ = X
X+X’ = 1
(T1’) X·1 = X
(T2’) X·0 = 0
(T3’) X·X = X
(Identities)
(Null elements)
(Idempotency)
(Involution)
(T5’) X·X’ = 0
(complements)
These theorems can be proved to be true. Let us prove
T1: [X=0] 0+0=0 (true, according to A4’)
[X=1] 1+0=1 (true, according to A5’)
12
Theorems involving two or three variables:
(T6) X+Y = Y+X
(T6’) X·Y = Y·X
(Commutativity)
(T7) (X+Y)+Z = X+(Y+Z) (T7’)(X·Y)·Z = X·(Y·Z)
(Associativity)
(T8) X·Y+X·Z = X·(Y+Z) (T8’) (X+Y)·(X+Z) = X+Y·Z
(Distributivity)
(T9) X+X·Y = X
(T9’) X·(X+Y) = X (Covering)
(T10) X·Y+X·Y’ = X
(T10’)(X+Y)·(X+Y’) = X
(Combining)
13
(T11) X·Y+X’·Z+Y·Z = X·Y+X’·Z
(Consensus)
(T11’)(X+Y)·(X’+Z)·(Y+Z) = (X+Y)·(X’+Z)
(T12) (X1·X2· ... ·Xn)’ = X1´+X2´+ ... +Xn’
(T12’) (X1+X2+ ... +Xn)’ = X1´·X2´· ... ·Xn’
( DeMorgan’s theorems)
(T13) X + X’ · Y = X + Y
(T13’) X · (X’ + Y) = X · Y
Attention to theorem T8’ which is not true for integers and reals.
T9 and T10 are used in the minimisation of logic functions.
14
The most basic representation of a logic function is a truth table.
A truth table lists the output of the circuit for every possible
input combination. There are 2n rows in a truth table for an
n-variable function.
15
Gates
Three basic gates (AND, OR, NOT) are sufficient to build any
combinational digital logic system.
16
Gates (2)
Two more logic functions are obtained by combining
NOT with an AND or OR function in a single gate.
17
a
0
0
1
1
b
0
1
0
1
ab
0
1
1
0
0
1
1
1
18
Equivalent gates according to DeMorgan’s theorem
19
An electrical model
a
b
or
a
b
a
and
a
b
a+b
b
a·b
• In a parallel arrangement
electricity will flow through
if one or other switch is
closed.
• In a series arrangement both
switches must be closed.
20
When SW1 AND SW2
are closed.
F = SW1&SW2
When SW1 OR
SW2 are closed.
F = SW1+SW2
21
Finding the Boolean expression for a circuit
(p+q) ·(p ·q)’
or (p+q) ·(p ·q)
22
a
b
f
c
23
Constructing circuits for Boolean expressions
To construct a circuit for the expression
p'q +q'
24
Simplification of Boolean Functions
• General Boolean functions of n variables can be
represented by
– Boolean expressions
– Truth tables showing the function values for all
input combinations
• Boolean functions can be implemented directly
from their expressions, but
– Complicated expressions may results in circuits
• Using more gates than necessary or
• Having longer accumulative gate delay than necessary
25
การทา Logic circuits ให้ ง่าย
หลาย
วิธีดงั นี้
การทา Logic circuits ให้ง่าย สามารถทาได้
•
ทำโดยนำทฤษฎีตำงๆ
มำใช้ในกำร
่
ลดรู ปของสมการให้นอ้ ย
ลง
ตัวอย่าง จงลดรู ปสมการ A + A · B + A’ · B
A + A · B + A’ · B = (A + A · B) + A’ · B (T9)
= A + A’ · B
(T13)
26
• Minterms (Sum-of-Products) of n variables
เป็ นอีกวิธีที่จะทาให้ Logic circuits ง่ายลง ซึ่ งมีวิธี
ทาคือ จะพิจารณา Truth table ที่ได้ผลลัพธ์เป็ น 1
โดยนาตัวแปรมาทาการ AND แล้ว OR เพื่อสร้างเป็ น
Boolean expression ซึ่งมีรูปแบบเป็ นผลบวกของผล
คูณ (Sum-of-Products) โดยกาหนดค่าดังนี้
A ,B ,C = 1
A’,B’,C’ = 0
ตัวอย่าง
27
X
0
0
0
0
1
1
1
1
Y
0
0
1
1
0
0
1
1
Z
0
1
0
1
0
1
0
1
F
•
We
have
1*
f = x’y’z’ +
0
x’yz’ +
1*
x y’z +
0
xyz
0
1 * f = x’y’z’ + x’yz’ + x y’z + x y z
0
1*
28
• But the sum of product of minterms can be
further simplified to reduce
– the number of product terms and
– the number of inputs of the gates
– example
• f = x’y’z’ + x’yz’ + xy’z + xyz
= x’z’(y’+y) + xz(y’+y)
= x’z’ + xz
But, how do we reach the simplest form
systematically?
29
• Maxterms (Product-of-Sums) of n variables
- Maxterm boolean expression is developed from
the 0s in the output column of the truth table. For each
0 in the output column, an Ored term is developed.
- Note that the input variables are inverted and
then Ored.
A ,B ,C = 0
A’,B’,C’ = 1
30
C
0
0
0
0
1
1
1
1
Input
B
0
0
1
1
0
0
1
1
A
0
1
0
1
0
1
0
1
Output
F
•
Maxterm
Boolean
expression
:
1
f = (c’+b+a) · (c’+b’+a’)
1
1
1
0*
1
1
0*
31
C
0
0
0
0
1
1
1
1
Input
B
0
0
1
1
0
0
1
1
A
0
1
0
1
0
1
0
1
Output
F
•
จงหา
0
– Minterm Boolean expression
0
– Maxterm Boolean expression
1
1
0
1
0
1
32
Karnaugh Map Simplication
• Karnaugh maps เป็ นอีกวิธีที่จะทาให้ Logic
circuits ง่ายลง ซึ่งมีวธิ ีดงั นี้
– two variables
Input Output
A B
Y
0 0 0
0 1 1
1 0 1
1 1 1
B’(0) B(1)
A’(0)
1
A (1) 1
1
Y= A+B
33
- three variables and four variables
C’(0) C(1)
A’B’(00)
A’B (01)
AB (11)
AB’(10)
(C)
34
C
0
0
0
0
1
1
1
1
Input
B
0
0
1
1
0
0
1
1
A
0
1
0
1
0
1
0
1
Output
F
1
1
1
1
0
1
1
0
three variables
C’(0) C(1)
A’B’(00) 1
A’B (01) 1
1
AB (11) 1
AB’ (10) 1
1
F = C’ + A’B + AB’
35
A
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
four variables
Inputs Output
B
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
C
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
D
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Y
1
0
0
0
1
0
0
0
0
0
1
1
0
0
1
1
C’D’ C’D CD CD’
A’B’(00) 1
A’B (01) 1
AB (11)
AB’ (10)
1
1
1
1
Y = AC + A’C’D’
36
37
38
39
40
41
42
43
A
0
0
0
0
1
1
1
1
Input
B
0
0
1
1
0
0
1
1
Mapping with maxterm expression
C
0
1
0
1
0
1
0
1
Output
F
0
1
1
1
0
1
0
1
C
A+B (0+0)
C’
1
A+B’ (0+1)
A’+B’(1+1)
A’+B (1+0)
1
1
F = (B + C) · (A’+C)
44
Maxterm
Minterm
45
Don’t cares on Karnaugh maps
ในวงจร logic บางวงจรสามารถออกแบบโดยไม่ระบุ output บางตัวว่า
เป็ น 1หรื อ 0 Output ที่ไม่สนใจหรื อไม่สามารถระบุ output ได้น้ ี
เรี ยกว่า “Don’t care”
46
การเขียน logic diagram ในรู ปของ function
F(a,b,c,…) = S(0,1,2,3,…)
b
a 0
1
00 1
12 3
0
4
12
8
1
5
13
9
01 3 2
45 7 6
3
7
15
11
2
6
14
10
47
48
Inputs
A B
00
00
00
00
01
01
01
01
10
10
10
10
11
11
11
11
C
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
D
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
ตาแหน่ง
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
49
ตัวอย่าง F(a,b,c) = S(3,4,6,7)
b
bc
a
a
1
1
1
1
c
50
five variables
DE
BC 00
00 0
01 4
11 12
10 8
A=0
01 11
1 3
5 7
13 15
9 11
10
2
6
14
10
DE
BC 00
00 16
01 20
11 28
10 24
A=1
01 11
17 19
21 23
29 31
25 27
10
18
22
30
26
51
F ( A, B, C, D))  (0,2,5,7,13,15,17,18,19,21,23,29,31)
(...............................................................)
F(A,B,C,D,E
A=0
DE
BC 00 01 11 10
1
00 1
1 1
01
1 1
11
10
DE
BC 00
00
01
11
10
A=1
01 11 10
1 1 1
1 1
1 1
52
F ( A, B, C, D))  (0,2,5,7,13,15,17,18,19,21,23,29,31)
(...............................................................)
F(A,B,C,D,E
A=0
DE
BC 00 01 11 10
1
00 1
1 1
01
1 1
11
10
DE
BC 00
00
01
11
10
A=1
01 11 10
1 1 1
1 1
1 1
F(A,B,C,D,E) หรื อ X = CE + B’C’DE’ +AB’E+A’B’C’E’
53
54
55
F(A,B,C,D,E) หรื อ X = CE + B’C’DE’ +AB’E+A’B’C’E’
56
Six-Variable K-Map
EF
CD 00
00 0
01 4
11 12
10 8
EF
CD 00
00 32
01 36
11 44
10 40
AB = 00
01 11
1 3
5 7
13 15
9 11
10
2
6
14
10
AB = 10
01 11
33 35
37 39
45 47
41 43
10
34
38
46
42
EF
CD 00
00 16
01 20
11 28
10 24
EF
CD 00
00 48
01 52
11 60
10 56
AB = 01
01 11
17 19
21 23
29 31
25 27
10
18
22
30
26
AB = 11
01 11
49 51
53 55
61 63
57 59
10
50
54
62
58
57
Six-Variable K-Map
EF
CD 00
00
01 1
11
10
EF
CD 00
00
01 1
11
10
AB = 00
01 11 10
1
1
1
1
AB = 10
01 11 10
EF
CD 00
00
01 1
11
10
EF
CD 00
00
01 1
11
10
AB = 01
01 11 10
1
1
1 1 1
1 1 1
AB = 11
01 11 10
1
1
1
1
58
CD = 00
10
11
10
EF
00
01
11
10
AB = 00
AB = 01
AB = 11
AB = 10
59
Combinational circuits แบบง่ายๆ
Half-Adder ใช้ในการบวกเลขฐานสอง
Input
X Y
0 0
0 1
1 0
1 1
Output
C S
0 0
0 1
0 1
1 0
S = Sum
0
C = 1Carry
X
Y
1
S
1
0
1
and
C
60
Adder Design Example
 To design the 4-bit binary adder, we first design
two types of adders: a half adder and a full adder.
 A half adder is a combinational circuit that
performs the addition of two bits (no carry in).
A
S • Boolean expressions for S and Co:
1 bit
Half
Adder
B
Co
A B
S
Co
0
0
1
1
0
1
1
0
0
0
0
1
0
1
0
1
S = AB’+A’B = A  B
Co = AB
• Logic diagram:
61
Adder Design Example
 Full adder: a combinational circuit that performs
the addition of 3 bits (two bits and a carry-in bit).
Ai
Bi
Si
Ci Ai Bi
Si Ci+1
0
0
0
0
0
1
0 0
1 0
0
1
0
1 0
S = A  B C
0
1
1
0
1
0
0 1
1 0
C = ABC’ +A’BC +AB’C+ABC
1 0 1
0 1
1
1
0 1
1 1
FA
Ci
= AB(C +C’)+C(AB’ + A’B)
= AB + C(A + B)
Ci+1
1
1
0
1
62
Full Adder Design Example
 Full adder can be realized with two half adders and
an OR gate, since Ci+1 can be expressed as:
Ai
Bi
Ci
Si
Ci+1
63
Binary Decoder
• Logic with n input lines and 2n output lines.
• Only one output is a 1 for any given input.
n
inputs
Binary
Decoder
2n outputs
64
• truth table for 2 to 4
decoder:
X Y
0 0
0 1
1 0
1 1
F0 = X'Y'
F1 = X'Y
F
F F F
0
1
2 3
1
0
0 0
0
1
0 0
0
0
1 0
0
0
0 1
• Note: Each output is a
2-variable minterm
(X'Y', X'Y, XY' or
XY)
F2 = XY'
F3 = XY
X
Y
65
3-to-8-Line Decoder
66
67
68
Encoder
• 2n (or fewer) input lines and n output lines.
• The output lines generate the binary code
corresponding to the input value, assuming only
one input is high.
• An encoder is the reverse function of a decoder
69
8-to-3-line Encoder
8-to-3
Encoder
70
Example: Octal-to-Binary Encoder
A0 =
A1 =
A2 =
71
Code Converter Example
 Design a circuit that converts a binary-coded-decimal
(BCD) to the seven signals required to drive a sevensegment light-emitting diode (LED) display.
Assuming the signal 1
illuminates the segment
and a logic-0 signal turns
off the segment
72
73
Code Converter Example
 Derive the Boolean function for each output
- e.g., using the following K-map to derive the
Boolean function for output a
CD
00
01
11
10
00
1
0
1
1
01
0
1
1
1
11
0
0
0
0
10
1
1
0
0
AB
a = A’C + A’BD + A’B’D’+
AB’C’
74
75
76
77
78
79
80
81
A’B’(00)
C’(0) C(1)
A’B (01)
AB (11)
AB’ (10)
1
1
1
1
82
การสร้างวงจรแสดง : ลูกเต๋ า 6 ด้าน
ถ้าต้องการสร้างวงจรที่แสดงสัญลักษณ์ในการออกลูกเต๋ าแต่
ละหน้าดังนี้
โดยใช้ LED วางตามตาแหน่งเพื่อแสดงการออกลูกเต๋ าที่ทอด
ได้ในแต่ละหน้า
A
B
C D E
G
F
83
Karnaugh maps with XOR and XNOR
XOR :
84
Truth table : A’B + AB’ = A + B
A
0
0
1
1
B
0
1
0
1
A’
1
1
0
0
B’ A’B AB’
1
0
0
0
1
0
1
0
1
0
0
0
A’B + AB’ A + B
0
0
1
1
1
1
0
0
85
XNOR :
86
Truth table : AB + A’B’ = (A + B)’
A
0
0
1
1
B
0
1
0
1
A’
1
1
0
0
B’ AB A’B’
1
0
1
0
0
0
1
0
0
0
1
0
AB + A’B’ (A + B)’
1
1
0
0
0
0
1
1
87
88
89