Boolean Algebra and Logic Gates CSE-1108 Ahsanullah University of Science and Technology (AUST)
Have you ever asked yourself? 1.How does a computer adds/ subtract/ multiply/ divide two (or more) numbers? Does it have a brain like human? 2.How does computer stores something? (Documents, songs, movies etc.) Does it have a memory like human? Answer 01: Logic gates and circuits. Answer 02: Logic gates and circuits. 2
What is Logic Gate? Logic gates are electronic circuits that operates on one or more input signals to produce standard output signals. Are the building blocks of all the circuits in a computer. Some of the most useful and basic logic gates are AND, OR, NOT, NAND and NOR gates. 3
Logic Gate Implementation Using Switches Inputs: Inputs: logic 1 is switch closed logic 0 is switch open Outputs: Outputs: logic 1 is light on logic 0 is light off. NOT input: NOT input: logic 1 is switch open logic 0 is switch closed Switches in series => AND Switches in parallel => OR C Normally-closed switch => NOT
Logic Gate Implementation In the earliest computers, switches were opened and closed by magnetic fields produced by energizing coils in relays. The switches in turn opened and closed the current paths. Later, vacuum tubes that open and close current paths electronically replaced relays. Today, transistors are used as electronic switches that open and close current paths.
What is Boolean Algebra? We need operator and operands in an Algebra. In Boolean algebra, operands are called binary variables. Operators are called Logical Operators. Basic logical operators are the logic functions AND, OR and NOT. Logic gates implement logic functions. Boolean Algebra is a useful mathematical system for specifying and transforming logic functions. We study Boolean algebra as a foundation for designing and analyzing digital systems!
7 Basic logic gates NotAndOrNandNorXor
Truth Tables Tabular listing of the values of a function for all possible combinations of values on its arguments Example: Truth tables for the basic logic operations: X NOT XZ Z = X·Y YX AND OR XYZ = X+Y
Truth Tables – Cont’d Used to evaluate any logic function Consider F(X, Y, Z) = X Y + Y Z XYZX YYY ZF = X Y + Y Z
Logic Diagrams and Expressions Boolean equations, truth tables and logic diagrams describe the same function! Truth tables are unique, but expressions and logic diagrams are not. This gives flexibility in implementing functions. X Y F Z Logic Diagram Logic Equation ZY X F Truth Table X Y Z Z Y X F
Boolean Algebra Commutative Associative Distributive DeMorgan’s X. 1 X = X. 00 = X. XX = 0 = X + YY + X = (X + Y)Z + X + (YZ)Z) += X(Y + Z)XYXZ += X + YX. Y = XYYX = (XY)ZX(YX(YZ)Z) = X+ YZ(X + Y)(X + Z)= X. YX + Y = X + 0 X = + X 11 = X + XX = 1 = X = X Invented by George Boole in 1854 An algebraic structure defined by a set B = {0, 1}, together with two binary operators (+ and ·) and a unary operator ( ) Idempotence Complement Involution Identity element
Boolean Operator Precedence The order of evaluation is: 1.Parentheses 2.NOT 3.AND 4.OR Consequence: Parentheses appear around OR expressions Example: F = A(B + C)(C + D)
13 Logic Circuit to Boolean expression Find the output of the following circuit Answer: (x+y)y Or (x y) y Or (x y) y x+yx+y y (x+y)y(x+y)y__
14 Logic Circuit to Boolean expression Find the output of the following circuit Answer: xy Or ( x y) ≡ x y Or ( x y) ≡ x y x y xyxy _ _ ___ ___
15 Boolean expression to Logic Circuit Write the circuits for the following Boolean algebraic expressions a) x+y __ __ x x+yx+y
16 Boolean expression to Logic Circuit Write the circuits for the following Boolean algebraic expressions b)(x+y)x _______ x+yx+y x+yx+y (x+y)x(x+y)x
17 How to add binary numbers Consider adding two 1-bit binary numbers x and y 0+0 = = = = = = = = 10 Carry is x AND y Sum is x XOR y The circuit to compute this is called a half-adder xyCarrySum
18 The half-adder Sum = x XOR y Carry = x AND y
19 Using half adders We can then use a half-adder to compute the sum of two Boolean numbers ? 001
20 How to fix this We need to create an adder that can take a carry bit as an additional input Inputs: x, y, carry in Inputs: x, y, carry in Outputs: sum, carry out Outputs: sum, carry out This is called a full adder Will add x and y with a half-adder Will add x and y with a half-adder Will add the sum of that to the carry in Will add the sum of that to the carry in What about the carry out? It’s 1 if either (or both): It’s 1 if either (or both): x+y = 10 x+y = 10 x+y = 01 and carry in = 1 x+y = 01 and carry in = 1 xyccarrysum
21 The full adder The “HA” boxes are half-adders
22 The full adder The full circuitry of the full adder