Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
King Abdul Aziz University Faculty of Computing and Info Tech Computer Science Department LAB MANUAL CPCS 211 Digital Logic Design Prepared By: Aman Ullah 2012(1) - 1433 Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Statement Purpose: In this lab we shall discuss about the Boolean algebra, basic theorems and properties of Boolean algebra, logical operations, types of logic gates, and simplification of Boolean expressions using axioms and postulates. Activity Outcomes: The students will learn about the application of Boolean Algebra in circuit designing. They will also know how to minimize the Boolean expressions using the axioms and postulates of Boolean algebra. This will ultimately help them in designing logical circuits with as few logic gates as possible. Instructor Note: Read the lab notes carefully and thoroughly. All the examples have been solved in an easy to understand manner. You should not find it difficult to learn the topics given in these lab notes. Try to solve all the exercises yourself that are given at the end of notes. These exercises will certainly help you in achieving the objectives of this lab. CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Digital Circuits and Logic Gates: Digital circuits are hardware components for the processing of binary input. They are built up of transistors and interconnections in semiconductor devices called integrated circuits A basic circuit is called a logic gate; its function can be represented mathematically. What is inside the gate is not of concern to the system/computer designer (Only its function) Binary logic (Boolean Algebra ) is a mathematical system to analyze and design digital circuits Boolean Algebra: In 1854, George Boole introduced a systematic treatment of logic and for this purpose developed an algebraic system now called Boolean algebra. Boolean algebra, like any other deductive mathematical system, may be defined with a set of elements, set of operators and a number of axioms or postulates. Two Valued Boolean Algebra: A two valued Boolean algebra is defined on a set of two elements B = {0, 1} with rules for the two binary operators + and . as shown below: X Y X.Y X Y X+Y X X’ 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 These rules are exactly the same as the AND, OR and NOT operations respectively. Two valued Boolean algebra satisfies the following properties: 1. Closure w.r.t + and . operations 2. Identity elements w.r.t + and . operations. 3. Commutative laws hold w.r.t + and . operations i.e. X+Y = Y+X and X.Y = Y.X CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates 4. Distributive laws hold i.e. X+(Y.Z) = (X + Y) . (X + Z) [+ is distributive over .] X.(Y+Z) = X.Y + X.Z [. Is distributive over +] 5. Complements w.r.t + and . operators exist in the set B i.e. X + X’ =1 and X.X’ = 0 6. Associative Law holds w.r.t + and . operators i.e. X + (Y + Z) = (X + Y) + Z X . (Y . Z) = (X . Y) . Z Boolean Function: A binary variable can take the value of 0 or 1. A Boolean function is an expression formed with binary variable, the two binary operators + and . , the unary operator ‘ (complement), parenthesis and equal sign. For a given value of variables, Boolean function can be either 0 or 1. For example, the Boolean function F = XYZ’ will be equal to 1 when X=1, Y=1 and Z’=1 (or Z=0). Otherwise F=0. Dual of a Boolean Function: Dual of a Boolean function can be obtained by interchanging + and . operators and replacing 1’s by 0’s and 0’s by 1’s. For example, the dual of (X+Y).Z is (X.Y)+Z CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Difference Between Boolean Algebra and Ordinary Algebra: 1. Ordinary algebra deals with the set of real numbers whereas two valued Boolean algebra deals with only two values 0 and 1. 2. Ordinary algebra involves operators like +, -, X, / etc whereas Boolean algebra involves only + (OR), . (AND) and ‘ (NOT or Complement) operators only. That is why Boolean algebra does not include additive and multiplicative inverses (as it does not contain subtraction and division operators). 3. In ordinary algebra, distributive law of + over . does not hold whereas it is valid for Boolean algebra. CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Basic Theorems and Postulates of Boolean Algebra: 18. X+(X.Y) = X 19. X.(X+Y) 20. X +X’.Y = X + Y 21. X.Y + Y.Z + Y’Z = X.Y + Z CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Types of Logic Gates CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Operator Precedence: The operator precedence for evaluating Boolean expression is 1. 2. 3. 4. Parentheses NOT (i.e. Complement) AND (i.e. .) OR (i.e. +) Implementation of a Boolean Function: A Boolean function may be transformed from an algebraic expression into a logic diagram composed of AND, OR and NOT gates. While implementing any Boolean function, we should keep in mind the precedence of the operators. CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Truth Table: A truth table is one which lists all the possible values of all the variables involved in a Boolean expression. It shows the output of each and every gate involved in the expression as well as the final output of the entire Boolean expression. Constructing a Truth Table: Write out the names of variables involved in the Boolean expression along with the output of each and every gate and the final output of the entire Boolean expression. In order to write the values of the variables, just start from the right most variable’s column and go on writing one 0, one 1 and so on, for the next variable, go on writing two o’s and two 1’s and so on, for the next variable, go on writing four 0’s and four 1’s and so on. The number of entries in the truth table will be equal to 2n for ‘n’ number of variables. For example, if there are 3 variables involved in a Boolean expression, there will be 23=8 entries (i.e. rows) in the truth table. CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Exercise: By means of truth tables, prove the following identities: DeMorgan’s theorem for three variables: (x+y+z)’ = x’y’z’ and (xyz)’=x’+y’+z’ The distributive law: x+y.z = (x+y).(x+z) Solution: CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Simplification of Boolean Functions: Using the above theorems and postulates of Boolean algebra, we can simplify the Boolean expressions to minimum number of literals so that we have to use as few logic gates to implement them as possible. Example: Simplify the following Boolean functions to minimum number of literals. (i) (ii) (iii) (iv) F1 = x + x’.y Solution: F1 = x + x’.y = (x + x’).(x + y) = 1.(x + y) =x+y F2 = x . ( x’+ y) Solution: F2 = x . ( x’+ y) = (x.x’) + (x.y) = 0 + x.y = x.y (3 literals, 2 terms) (By 15 above) (By 7 above) (By 2 above) (By 14 above) (By 8 above) (By 1 above) F3 = x’y’z + x’yz + xy’ Solution: F3 = x’y’z + x’yz + xy’ = x’z (y’ + y) + xy’ (By 14 above) = x’z.1 + xy’ (By 7 above) = x’z + xy’ (By 2 above) F4 = xy + x’z + yz Solution: F4 = xy + x’z + yz = xy + x’z + yz.(x + x’) = xy + x’z + xyz + x’yz = xy + xyz + x’z + x’yz = xy.(1 + z) + x’z.(1+ y) = xy.1 + x’z.1 = xy + x’z (2 literals, 2 terms) (4 literals, 2 terms) (2 literals, 1 term) (8 literals, 3 terms) (4 literals, 2 terms) (6 literals, 3 terms) (By 7 above) (By 14 above) (Rearranging the terms) (By 14 above) (By 3 above) (4 literals, 2 terms) CPCS-211 Digital Logic Design Term Spring 2012 (v) Lab 3: Boolean Algebra and Logic Gates F5 = (x + y)(x’ + z)(y + z) Solution: F5 = (x + y)(x’ + z)(y + z) =(x.x’ + xz + x’y + yz)(y + z) =(0 + xz + x’y + yz)(y + z) = (xz + x’y + yz)(y + z) = (xyz + xz.z + x’y.y + x’yz + y.yz + yz.z = (xyz + xz + x’y + x’yz + yz + yz) = (xyz + xz + x’y + x’yz + yz) = (xz(y + 1) + x’y(1 + z) + yz) =(xz.1 + x’y.1 + yz) = xz + x’y + yz = xz + x’y + yz + x.x’ = x.x’ + x’y + xz + yz = x’.(x + y) + z.(x + y) = (x + y)(x’ + z) (By 14 above) (By 8 above) (By 1 above) (By 14 above) (By 6 above) (By 5 above) (By 14 above) (By 3 above) (By 2 above) (By 8 above) (Rearranging the terms) (By 14 above) (By 14 above) Complement of a Boolean Function: The complement of a Boolean function F, denoted by F’ (read as F prime) is obtained by converting 0’s into 1’s and 1’s into o’s and complementing each literal. It may also be achieved by using De Morgan’s laws (i.e. (x + y)’ = x’ . y’ and (x.y)’ = x’ + y’) Example: Find complement of the following functions: (i) F1 = x’yz’ + x’y’z Solution: F1 = x’yz’ + x’y’z (F1 )’= (x’yz’ + x’y’z)’ F1’ = (x’yz’)’ . (x’y’z)’ =[(x’)’+y’+(z’)’].[(x’)’ + (y’)’ +z’] = (x + y’ + z)(x + y + z’) CPCS-211 Digital Logic Design Term Spring 2012 (ii) Lab 3: Boolean Algebra and Logic Gates F2 = x.(y’z’ + yz) Solution: F2 = x.(y’z’ + yz) (F2 )’= [x.(y’z’ + yz)]’ F2’ = x’ + (y’z’ + yz)’ = x’ + [(y’z’)’ . (yz)’] = x’ + [[(y’)’ + (z’)’].[y’ + z’]] = x’ + (y + z).(y’ + z’) Note: Procedure of finding complement of a function is comprised of two steps: Step 1: Take dual of the function (i.e. interchange + and . signs) Step 2: Complement each literal (i.e. convert primed literal into unprimed literal and vice versa. Examples: 1. Simplify the following Boolean functions to a minimum number of literals: (i) xy + xy’ (ii) (x + y)(x + y’) (iii) (A + B)’(A’ + B’)’ (iv) y.(wz’ + wz) + xy Solution: (i) xy + xy’ = x.(y + y’) = x.1 = x (ii) (x + y)(x + y’) = x + (y.y’) = x + 0 = x (iii) (A + B)’(A’ + B’)’ = [(A + B) + (A’ + B’)]’ = [A + A’ + B + B’]’ = (1 + 1)’ = (1)’ = 0 (iv) y.(wz’ + wz) + xy = y.[w.(z’ + z)] + xy = y.[w.1] + xy = y.w + xy = (w + x).y CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates 2. Reduce the following Boolean expressions to the required number of literals: (i) ABC + A’B’C + A’BC + ABC’ + A’B’C’ (to five literals) (ii) BC + AC’ + AB + BCD (to four literals) (iii) [(CD)’ + A]’ + A + CD + AB (to three literals) Solution: (i) ABC + A’B’C + A’BC + ABC’ + A’B’C’ = ABC + A’BC + A’B’C + A’B’C’ +ABC’ = (A + A’).BC + A’B’(C + C’) + ABC’ = 1.BC + A’B’.1 + ABC’ = BC + A’B’ + ABC’ = BC + ABC’ + A’B’ = B.(C + AC’) + A’B’ = B.[(C + A)(C + C’)] + A’B’ = B.[(C + A).1] + A’B’ = B.(A + C) + A’B’ (ii) BC + AC’ + AB + BCD = BC + BCD + AB + AC’ = BC.(1 + D) + AB + AC’ = BC.1 + AB.(C + C’) + AC’ = BC + ABC + ABC’ + AC’ = BC (1 + A) + AC’ (B + 1) = BC.1 + AC’.1 = BC + AC’ (iii) [(CD)’ + A]’ + A + CD + AB = [(CD)’]’.A’ + A + CD + AB = A’CD + A + CD + AB = A’CD + CD + A + AB = CD.(A’ + 1) + A.(1 + B) = CD.1 + A.1 = A + CD CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates Exercises: Construct truth table for the following Boolean functions: (i) F1(x, y, z) = xy’ + x’z (ii) F2 (A, B, C) = A’BC’ + A’C + B’C’ (iii) F3 (w, x, y, z) = wy’ + xy’z + x’y Solution: Exercises: Solution: Exercise: Take complement of the following Boolean functions and simplify them to minimum number of literals: (i) xy+xy' (ii) (x + y)’(x’ + y’) (iii) C.(AD’ + AD) + BC Solution: CPCS-211 Digital Logic Design Term Spring 2012 Lab 3: Boolean Algebra and Logic Gates NOT FOR FALL 2013 Assignment No 2 Due Date: March 13, 2012 Q. No. 1: Simplify the following Boolean functions to a minimum number of literals: (i) F = xyz + x’y + xyz’ (ii) F = zx + zx’y Also implement the simplified Boolean functions using AND, OR and NOT gates. Q. No. 2: Find the complement of the following Boolean functions and reduce them to a minimum number of literals: (i) F = (BC’ + A’D)(AB’ + CD’) (ii) F = [(AB)’A][(AB)’B] Q. No. 3: Implement the Boolean function F = xy + x’y’ + y’z using only AND and NOT gates. Q. No. 4: Simplify the following functions T1 and T2 to minimum number of literals A B C T1 T2 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 0 0 1 1 1 1 0 1 Note: Use Cedar Logic Simulator to implement the above Boolean functions CPCS-211 Digital Logic Design