Boolean Logic and Circuits

Download Boolean Logic  and Circuits

Post on 23-Feb-2016

36 views

Category:

Documents

0 download

Embed Size (px)

DESCRIPTION

Boolean Logic and Circuits. Professor James T. Williams, Jr. HONP112 Week 2 Lesson. George Boole (1815-1864). George Boole developed the mathematics that made modern computing possible, almost a century before the first computers were actually developed. . Boolean Logic. - PowerPoint PPT Presentation

TRANSCRIPT

<p>Variables In Real Life: A Jar Of Spare Change</p> <p>Boolean Logic and CircuitsProfessor James T. Williams, Jr.HONP112Week 2 LessonGeorge Boole (1815-1864)George Boole developed the mathematics that made modern computing possible, almost a century before the first computers were actually developed. </p> <p>A special kind of mathematics where there are only 2 possible values. These values are true and false.Special operators are used with these values to create expressions.A boolean expression will evaluate to either true or false in its entirety.Boolean LogicThere are three Boolean operators:ANDORNOT</p> <p>Boolean OperatorsFirst, any expression in parenthesisThen the ANDThen the OR</p> <p>Order of OperationsThe AND operator is a BINARY operator (i.e. it acts on two variables or expressions binary in this context does not mean base-2)Example expression: A AND BAlso can be written as A * BThe resulting value of the expression depends on the values of A and B.The AND OperatorAn AND expression only evaluates to true if BOTH of the sub-expressions also evaluate to true. Otherwise, it evaluates to false.false AND false = false false AND true = false true AND false = falsetrue AND true = true</p> <p>Evaluating AND expressionsAND Truth TableWe can look at all the possibilities for the value of A*B as a truth table: ABA*BfalsefalsefalsefalsetruefalsetruefalsefalsetruetruetrueAssume: A is true and B is false What does the expression A * B evaluate to?What if A is true and B is true?</p> <p>AND - ExampleAssume: A is true, B is false, C is true, D is true What does the expression A * B evaluate to?What does the expression C * D evaluate to?What does (A*B) * (C*D) evaluate to?</p> <p>AND More examplesThe OR operator is a BINARY operator (i.e. it acts on two variables or expressions)Example expression: A OR BAlso can be written as A + B (Careful the plus sign does not mean and!!)The resulting value of the expression depends on the values of A and B.The OR OperatorAn OR expression only evaluates to true if EITHER of the sub-expressions also evaluate to true. Otherwise, it evaluates to false.false OR false = false false OR true = true true OR false = truetrue OR true = true</p> <p>Evaluating OR expressionsOR Truth TableWe can look at all the possibilities for the value of A+B as a truth table: ABA+BfalsefalsefalsefalsetruetruetruefalsetruetruetruetrueAssume: A is true and B is false What does the expression A + B evaluate to?What if A is true and B is true?What if A is false and B is false?</p> <p>OR - ExampleAssume: A is true, B is false, C is true, D is true What does the expression A + B evaluate to?What does the expression C + D evaluate to?What does (A+B) + (C+D) evaluate to?</p> <p>OR More examplesThe NOT operator is a UNARY operator (i.e. it acts on one variable or expressions)Example expression: NOT AAlso can be written as -AThe resulting value of the expression depends on the value of AThe NOT OperatorAn NOT expression simply evaluates to the inverse value of the expression.NOT false = true NOT true = false </p> <p>Evaluating NOT expressionsNOT Truth TableWe can look at all the possibilities for the value of -A as a truth table: A-AfalsetruetruefalseAssume: A is true and B is false What does the expression -A evaluate to?What does the expression -B evaluate to?</p> <p>NOT - ExampleConsider (B AND NOT A) OR (NOT D OR C). Assume A=1, B=1, C=1, and D=0Put in the variable values and simplify as below:(1 AND NOT 1) OR (NOT 0 OR 1)(1 AND 0) OR (1 OR 1)0 OR 11</p> <p>Evaluating Boolean ExpressionsSome more examples to work out in class or on your own time. Remember the order of operations. Assume A=1, B=1, C=1, and D=0A OR D AND B = x(NOT B AND C) AND (A OR C) = x(B AND NOT D OR C) OR (NOT B AND B) = x(A AND B AND C) OR (B AND D) = x(A*B*C) + (B*D) = x [alt. version of above]</p> <p>More Boolean ExpressionsAll computer/digital circuits are constructed from various combinations of Boolean expressions.These are implemented in the computer by very tiny electronic components, built into chips, called gates. Depending on the values going into the gates, the end result will be either a logical 0 or 1. This corresponds with false or true.</p> <p>What does this have to do with computers?The gates in a computer understand the state 0 or 1 based on electrical voltage.Very generally speaking, for our purposes only, a 1 is about 5 volts, and a 0 is 0 volts or close to it.In real life these values may vary, but the idea is the same.It is more accurate to refer to the 1 and 0 in computer circuits as high or low.</p> <p>Technically speakingIn case you wonder where the following screen shots are coming from...There is a free logic circuit simulator called Logisim.http://ozark.hendrix.edu/~burch/logisim/Dark green is low, bright green is highLets see what happens with our logic gates.The Logisim simulatorThe AND gate is represented using the symbol below.It takes two inputs and produces a single output. For the output to be high, both inputs must be high.</p> <p>The AND gate</p> <p>Lets change one of the inputs to high.Because both are not high, the output is still low.</p> <p>The AND gate</p> <p>Now lets make both inputs high.Notice that now the output is high.</p> <p>The AND gate</p> <p>The OR gate is represented using the symbol below.It takes two inputs and produces a single output. For the output to be high, only one of the inputs must be high.</p> <p>The OR gate</p> <p>Lets change one of the inputs to high.Notice that the output went high just by making one of the inputs high.</p> <p>The OR gate</p> <p>The symbol below represents the NOT gate. This is also called an inverter.Notice that the output is high when the input is low.The NOT gate</p> <p>Changing the input to high makes the output low.The NOT gate</p> <p>(A AND NOT B) OR (C OR D) = xWhat is x? It depends on the values assigned to A, B, C, and D.Remember the values can only be true or false.Consider This Boolean Expression(A AND NOT B) OR (C OR D) = xAssume A=true, B=false, C = false, D=true.Our Example as a Circuit</p> <p>(A AND NOT B) OR (C OR D) = xAssume A=false, B=false, C = false, D=true.Lets make a change</p> <p>(A AND NOT B) OR (C OR D) = xAssume A=false, B=true, C = false, D=false.Lets make another change</p> <p>Maybe in class, or on your own time try to visualize them as circuits this time around.(A AND NOT B) AND (C OR D)(A * -B) * (C + D) [alt. version of above](D + -B + C) * C-A * B * (C + A)Substitute different values for the variables.Try some with more or less variables. Experiment. Learn by doing.Some more examples In circuit design, there are some special gates that are commonly used.The purpose of these gates is to make circuits simpler to build (less hardware = less effort = less cost).The gates we will discuss are not standard boolean operators, but are actually single circuits constructed from the standard boolean gates.</p> <p>Special GatesNAND: Not And (AND gate followed by a NOT gate)NOR: Not Or (OR gate followed by a NOT gate)XOR: Exclusive OR (means that you only get a high output if EITHER of the inputs is high, not both. The circuit for XOR is more complex than for NAND or NOR)Three Special GatesSame as AND followed by a NOT. Notice that we only draw the bubble part of the NOT gate on a NAND symbol (short-cut)The NAND gate</p> <p>Same as OR followed by a NOT. Notice that we only draw the bubble part of the NOT gate on a NOR symbol (short-cut)The NOR gate</p> <p>This means that only one of the two inputs can be high to get a high output. Notice how XOR symbols are drawn, and see the two simulations below. (The XOR circuit itself is not shown).The XOR gate</p> <p>NAND Truth TableRemember our earlier AND truth table. Just invert the output values and that is the NAND truth table.Lets use 1 and 0 to represent true/high and false/low. ABA NAND B001011101110NOR Truth TableRemember our earlier OR truth table. Just invert the output values and that is the NOR truth table. Lets use 1 and 0 to represent true/high and false/low. </p> <p>ABA NOR B001010100110XOR Truth TableRemember our earlier OR truth table. XOR is the same except that we get low when both inputs are high. Lets use 1 and 0 to represent true/high and false/low. </p> <p>ABA XOR B000011101110Know the truth tables for the six gates we have discussed. Know the various ways to represent the logical values of true/false.Be able to evaluate a boolean expression using the three simple operators.Be able to evaluate a circuit using any of the six logic gates.Lets stop and reviewAt this point, trying to imagine what the computer can do with these types of circuits may be a bit abstract.So lets look at a concrete example of a real circuit that is used by every computer.You will not have to memorize this circuit but hopefully it will help illustrate a real-life application of a boolean logic circuit.Boolean circuits in actionThis circuit (a full adder) is used by computers to add one column of two whole numbers (in base-2 of course).Again You do not have to memorize this circuit, but just try to understand what it does.</p> <p>This is a real circuit</p> <p>Imagine you are adding a single column of numbers.Notice there are three inputs. These are the first addend, the second addend, and the current value of the carry.There are two outputs. One is the result value that gets placed in the result column, and the other is the new carry value.We already know the addition algorithm so lets test the circuit to make sure it works correctly. Important: in the following slides, the + symbol will mean plus !</p> <p>The Full Adder - analysisAssume the carry is 0, the first addend is 1, the second addend is 0.0+1+0 = 1. 1 is not &gt;= the base, so we set the result to 1, and the carry stays zero.Full adder one test</p> <p>Now, assume the carry is 0, the first addend is 1, the second addend is also 1.0+1+1= 2. 2 is &gt;= the base, so we subtract the base from the result, and set the carry to 1.Full adder another test</p> <p>OK, now assume that the carry, the first addend, and the second addend are all 1.1+1+1 = 3. 3 is &gt;= the base, so we subtract the base from the result, and set the carry to 1.Full adder another test</p> <p>A Question: By now you should be asking yourself what if the two numbers we are adding are more than one column wide? How does the adder handle multiple columns??The answer: A whole bunch of individual full adders are chained together to account for many columns. When you move to the next column, the next full adder circuit takes in the two new addends, and also the carry value calculated from the previous column. </p> <p>The Full Adder a questionThe adder is just one example of a logic circuit that is really used inside a computer. There are numerous and varied logic circuits that make up an entire computer.Though we will not be examining the specific circuits, just keep the concept in mind as we continue our studies.I hope this lecture has provided insight into how boolean logic is related to computers.Our next lesson will expand on the boolean logic idea and how it applies to sets.</p> <p>Conceptually speaking </p>