Lecture (04) Boolean Algebra and Logic...

22
Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design ١ Boolean algebra properties basic assumptions and properties: Closure law A set S is closed with respect to a binary operator, for every pair of elements of S, the binary operator specifies a rule for obtaining a unique element of S. Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design ٢

Transcript of Lecture (04) Boolean Algebra and Logic...

Page 1: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Lecture (04)Boolean Algebra and 

Logic GatesBy:

Dr. Ahmed ElShafee

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١

Boolean algebra properties

basic assumptions and properties:

• Closure law

– A set S is closed with respect to a binary operator, for every pair of elements of S, 

– the binary operator specifies a rule for obtaining a unique element of S.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢

Page 2: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

• Commutative law. 

– A binary operator * on a set S is said to be commutative whenever

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣

• Associative law.

– A binary operator * on a set S is said to be associative whenever

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٤

Page 3: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٥

• Identity element.

– A set S is said to have an identity element with respect to a binary operation * on S 

– if there exists an element e  S with the property that

• Example: The element 0 is an identity element with respect to the binary operator + on the set of integers I = {…, ‐3, ‐2, ‐1, 0, 1, 2, 3,…}, since

• x + 0 = 0 + x = x for any x  I

• Example: The element 1 is an identity element with respect to the binary operator . on the set of integers I = {…, ‐3, ‐2, ‐1, 0, 1, 2, 3,…}, since

• x . 1 = 1 . x = x for any x  I

Page 4: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٧

• Inverse. 

– A set S having the identity element e with respect to a binary operator * is said to have an inverse whenever, for every x  S, there exists an element y  S such that

• Example: In the set of integers, I, and the operator +, with e = 0, the inverse of an element a is (‐a), since a + (‐a) = 0.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٨

Page 5: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٩

• Distributive law

– If * and . are two binary operators on a set S, * is said to be distributive over . Whenever

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٠

Page 6: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١١

Summery

• The binary operator + defines addition (OR).

• The additive identity is 0.

• The additive inverse defines subtraction.

• The binary operator . defines multiplication (AND).

• The multiplicative identity is 1.

• For a  0, the multiplicative inverse of a = 1/a defines division (i.e., a . 1/a = 1 ).

• The only distributive law applicable is that of . over +:

a . (b + c) = (a . b) + (a .. c)

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٢

Page 7: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Ordinary and Boolean Algebra 

• George Boole developed an algebraic system now called Boolean algebra.

• Claude E. Shannon introduced a two‐valued Boolean algebra called switching algebra that represented the properties of bistable electrical switching circuits.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٣

1. (a) The structure is closed with respect to the operator +.

(b) The structure is closed with respect to the operator . .

2. (a) The element 0 is an identity element with respect to +; that is, x + 0 = 0 + x = x.

(b) The element 1 is an identity element with respect to . ; that is, x . 1 = 1 . x = x.

3. (a) The structure is commutative with respect to +; that is, x + y = y + x.

(b) The structure is commutative with respect to . ; that is, x . y = y . x.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٤

Page 8: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

4. (a) The operator . is distributive over +; that is, x . (y + z) = (x . y) + (x . z).

(b) The operator + is distributive over . ; that is, x + (y . z) = (x + y) . (x + z).

5. For every element x  B, there exists an element x B (called the complement of x) such that 

(a) x + x = 1 and 

(b) x . x = 0 , 

6. There exist at least two elements x, y  B such that x  y.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٥

Comparing Boolean algebra with arithmetic and ordinary algebra:

• The distributive law of + over . (i.e., x + (y . z) = (x + y) . (x + z) ) is valid for Boolean algebra, but not for ordinary algebra.

• Boolean algebra does not have additive or multiplicative inverses; therefore, there are no subtraction or division operations.

• defines an operator called the complement that is not available in ordinary algebra.

Page 9: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

• Ordinary algebra deals with the real numbers, which constitute an infinite set of elements. Boolean algebra deals with the as yet undefined set of elements, B, but in the two‐valued Boolean algebra defined next (and of interest in our subsequent use of that algebra), B is defined as a set with only two elements, 0 and 1.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٧

Two‐Valued Boolean Algebra

• defined on a set of two elements, B = {0, 1}, with rules for the two binary operators + and .

• rules are exactly the same as the AND, OR, and NOT operations

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٨

Truth table

Page 10: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

• the structure is closed with respect to the two operators, each operation is either 1 or 0 and 1, 0  B.

• From the tables, we see that

(a) 0 + 0 =0 0+ 1 = 1 + 0 = 1;

(b) 1 . 1 = 1 1. 0 = 0 . 1 = 0.

This establishes the two identity elements, 0 for + and 1 for . ,

• The commutative laws are obvious from the symmetry of the binary operator table (A+B = B+A) & (A.B = B.A)

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design١٩

• The distributive law x . (y + z) = (x . y) + (x . z) can be shown to hold from the operator tables

• The distributive law of + over . can be shown to hold by means of a truth table

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٠Truth table

Page 11: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

• the complement table(a) x + x  = 1, since 0 + 0 = 0 + 1 = 1 and 1 + 1 = 1 + 0 = 1.

(b) x . x = 0, since 0 . 0 = 0 . 1 = 0 and 1 . 1 = 1 . 0 = 0.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢١

Postulates and Basic theorem of Boolean algebraPostulates and Theorems of Boolean Algebra

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٢

Page 12: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Duality principle

• postulates were listed in pairs and designated by part (a) and part (b). 

• One part may be obtained from the other if the binary operators and the identity elements are interchanged

• we simply interchange OR and AND operators and replace 1’s by 0’s and 0’s by 1’s.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٣

Theorem 5.a

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٤

Truth table

Page 13: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٥

Truth table

• Operator Precedence

– (1) parentheses,

– (2) NOT, 

– (3) AND, and 

– (4) OR.

• expressions inside parentheses must be evaluated before all other operations. The next operation that holds precedence is the complement, and then follows the AND and, finally, the OR.

• example: demorgan’s

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٦

Page 14: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Boolean functions

• Boolean function described by an algebraic expression consists of binary variables

• A Boolean function can be represented in a truth table. The number of rows in the truth table is 2n, where n is the number of variables in the function.

• The interconnection of gates will dictate the logic expression.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٧

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٨

Logic diagram

Page 15: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٢٩

F1xy‘ zY'

0001

1011

0000

0000

1101

1111

1100

1100

zyx

000

100

010

110

001

101

011

111

• it is sometimes possible to obtain a simpler expression for the same function and thus reduce the number of gates in the circuit and the number of inputs to the gate.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٠

Page 16: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣١

Logic diagram

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٢

Logic diagram

Page 17: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٣

zyx

000

100

010

110

001

101

011

111

f2X’zzX’Xy’Y’X

0001010

1111010

0001000

1111000

1000111

1010111

0000001

0010001

Truth table

Algebraic Manipulation

• When a Boolean expression is implemented with logic gates, each term requires a gate and each variable within the term designates an input to the gate. 

• We define a literal to be a single variable within a term, in complemented or un‐complemented form.

• By reducing the number of terms, the number of literals, or both in a Boolean expression, it is often possible to obtain a simpler circuit

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٤

Page 18: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Example 01

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٥

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٦

Page 19: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Complement of a Function

• The complement of a function may be derived algebraically through DeMorgan’s theorems

• DeMorgan’s theorems can be extended to three or more variables.

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٧

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٨

Page 20: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Example 02

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٣٩

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٤٠

Page 21: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Example 03

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٤١

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٤٢

Page 22: Lecture (04) Boolean Algebra and Logic Gatesdraelshafee.net/Spring2016/logic-design---lecture-04-2x1.pdf · Lecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١

Thanks,..

See you next week (ISA),…

Dr. Ahmed ElShafee, ACU : Spring 2016, Logic Design٤٣