130 likes | 220 Views
CS170 Computer Organization and Architecture I. Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 22: 11/19/2002. Outline. Appendix B Basic definitions truth tables logic equations gates. Logic Blocks (Logic Functions).
E N D
CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 22: 11/19/2002 CS170 Fall 2002
Outline • Appendix B • Basic definitions • truth tables • logic equations • gates CS170 Fall 2002
Logic Blocks (Logic Functions) • Electronics inside a modern computer are digital • Two voltage levels: High and Low correspond to 1 and 0 (On/Off) • 1 Logically true (asserted) • 0 Logically 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) CS170 Fall 2002
Combinatorial Logic Functions • Defining Combinatorial logic Functions • 1. Truth tables 2. Boolean Algebra 3. Logic Gates • Truth Tables • With N inputs and each input having the value 1 or 0, there are precisely 2N 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 CS170 Fall 2002
Truth Table Example • 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? CS170 Fall 2002
Boolean Algebra1/2 • Express Logic functions using logic equations (named after Boole, a 19th 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) CS170 Fall 2002
Boolean Algebra2/2 Boolean Algebra Laws CS170 Fall 2002
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 CS170 Fall 2002
Example • 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 CS170 Fall 2002
Logic diagram of A A A A A+B A.B B B B Logic diagram of A+B A+B+C C Logic Gates1/2 • Devices which implement basic logic functions • AND gate implements AND function • OR gate implements OR function • NOT function implemented with an inverter CS170 Fall 2002
Using DeMorgan’s Theorem A B Logic Gates2/2 Can we simplify Can you express output E in the previous example as a gates diagram. Use only 2 input AND, OR, or inverters? CS170 Fall 2002
Logic Gates Diagram or Circuit • The process of obtaining a combinatorial logic circuit • Define the logic function • Translate the function to a truth table • Generate the logic equation using either sum of products or product of sums • 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 CS170 Fall 2002
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? CS170 Fall 2002