Lecture 22: 11/19/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 22: 11/19/2002
CS170 Fall Outline Appendix B Basic definitions truth tables logic equations gates
Lecture 22: 11/19/2002CS170 Fall Logic Blocks (Logic Functions) Electronics inside a modern computer are digital Two voltage levels: High and Low correspond to 1 and 0 (On/Off) 1Logically true (asserted) 0Logically false (deasserted) Logic blocks(Logic Functions) Black box which has some set of inputs (logic variables-independent variables) and some other set of outputs (logic variables-dependent variables) Classes of Logic Functions Without memory (Combinatorial) Output depends only on the current input With memory (Sequential) Output can depend on both inputs and value stored in memory (memory is called the state of the logic block)
Lecture 22: 11/19/2002CS170 Fall Combinatorial Logic Functions Defining Combinatorial logic Functions 1. Truth tables2. Boolean Algebra3. Logic Gates Truth Tables With N inputs and each input having the value 1 or 0, there are precisely 2 N possible combinations of inputs (How do we list the input combinations?) For each of the possible combinations specify the output (1 or 0) of each output variable Example Three inputs A, B, and C, and three outputs D, E, and F. The function is defined as follows. D is true if at least one input is true. E is true if exactly two inputs are true. F is true only if all three inputs are true. (D,E,F) = (1,0,0) means one and only one input of (A,B,C) is true (Why?) (D,E,F) = (1,1,0) means exactly two of (A,B,C) are true
Lecture 22: 11/19/2002CS170 Fall Truth Table Example InputsOutputs ABCDEF D is true if at least one input is true. E is true if exactly two inputs are true. F is true only if all three inputs are true. Truth table completely defines the logic function Given an input (A,B,C) we can lookup the output (D,E,F) Problems?
Lecture 22: 11/19/2002CS170 Fall Boolean Algebra 1/2 Express Logic functions using logic equations (named after Boole, a 19 th century British mathematician) Rules All variables are either 1 or 0 Basic operators which act on variables. The common operators are OR operator denoted by “+”. A OR B = A+B = 1 if either A or B or both are true (logical sum) AND operator denoted by “.”. A AND B = A.B = 1 if both A and B are true (logical product) Unary operator NOT written as (complement or inversion operator)
Lecture 22: 11/19/2002CS170 Fall Boolean Algebra 2/2 Identity Law Zero and One Laws Inverse Laws Commutative Laws Associative Laws Distributive Laws DeMorgan’s Laws Boolean Algebra Laws
Lecture 22: 11/19/2002CS170 Fall Generating Logic Equations from Truth Tables Two methods which can be used to systematically generate the logical function from a truth table Method A: Sum of Products(a logical sum of products (terms using AND operator)) Find all rows of the truth table for which the function is TRUE (1) For each such row, AND the variables or the complement of the variables. If the variable is true, use the variable in the AND. If the variable is False, use the complement of the variable in the AND Take the OR of all these terms. This is the desired function Method B: Product of Sums (a logical AND of sums (terms using the OR operator)) Find all rows of the truth table for which the function is FALSE (0) For each such row, OR the variables or the complement of the variables. If the variable is TRUE, use the complement of the variable in the OR. If the variable is False, use the variable in the OR Take the AND of all of these terms. This is the desired function
Lecture 22: 11/19/2002CS170 Fall Example InputsOutputs ABCDEF Output D Use method B (Why?) D = A+B+C Output F Use method A (Why?) F = A.B.C Output E Use method A (Why?) Equivalent to
Lecture 22: 11/19/2002CS170 Fall Logic Gates 1/2 Devices which implement basic logic functions AND gate implements AND function OR gate implements OR function NOT function implemented with an inverter A B A.B A B A+B A Logic diagram of C A B A+B A+B+C
Lecture 22: 11/19/2002CS170 Fall Logic Gates 2/2 Can we simplify Using DeMorgan’s Theorem ABAB Can you express output E in the previous example as a gates diagram. Use only 2 input AND, OR, or inverters?
Lecture 22: 11/19/2002CS170 Fall Logic Gates Diagram or Circuit The process of obtaining a combinatorial logic circuit 1.Define the logic function 2.Translate the function to a truth table 3.Generate the logic equation using either sum of products or product of sums 4.Generate the logic circuit by replacing the logic operators by corresponding logic gates Between steps 3 and 4 we can simplify the resulting logic expression before obtaining the logic circuit, but we ignore this for now
Lecture 22: 11/19/2002CS170 Fall NAND and NOR Gates Universal gates. (AND, OR, NOT can be expressed in terms of NAND and NOR) NOR (An OR gate followed by an inverter) defined as X NOR Y = NOT (X OR B) = NAND (An AND gate followed by an inverter) defined as X NAND Y = NOT (X AND Y) = Can we show that NOR gate is universal? X NOR X = NOT X = X NOR X X + Y = NOT (X NOR Y) = (X NOR Y) NOR (X NOR Y) X.Y = (NOT X) NOR (NOT Y) = (X NOR X) NOR (Y NOR Y) Problem B.4 requests proving that NAND is universal?