20
4-1 TRUTH TABLE • Remember: Decimal to Binary Binary to Decimal Binary math Finish representation of data • Numbers • Symbols • Images • Audio • Today: Boolean Logic Truth Tables Circuits

Truth table1

Embed Size (px)

DESCRIPTION

Information technology

Citation preview

  • 1. TRUTH TABLE Remember: Decimal to Binary Binary to Decimal Binary math Finish representation of data Numbers Symbols Images Audio Today: Boolean Logic Truth Tables Circuits 4-1

2. 4-2 3. What we will cover The connection between Boolean logic and circuits Boolean (Propositional) Logic The design of simple logic circuits Representing simple logical sentences in hardware4-3 4. Logic and Logic Circuits What is a circuit? the complete path of an electric current, or a collection of electronic elements We are interested in logic circuits, those whose output varies depending on their input. Logic circuits emulate the Boolean logic operatorsfrom propositional logic 4-4 5. Binary for Logic? In Propositional Logic we examine the truth ofsentences. Sentences consist of: Variables: sub-sentences (A, B, C ) which are either true or false In computer science, we use true = 1 false = 0 Logical Operators: e.g., NOT, OR, AND, XOR, NAND, NOR Example sentence: X = (A AND B) OR C We examine the logic of a sentence through truth tableanalysis 4-5 6. Simplest Truth Tablea Single Variable A single variable has only two possible values inBoolean logic: true = 1 false = 0A A truth table represents all of the possiblevalues of a sentence given the possible values of 1its inputs (variables). We determine the output by considering all possible truth values for each variable we want to see the results of all possible combinations of0 each variable How many rows should appear in a given truthtable? Example: A = It is raining 4-6 7. Logical AND Logical AND: Takes two variables Evaluates to True only if both variables are true Written as: (A B) Example: A = It is raining B = I am in London (A B) = It is raining and I am in London What is the truth table for (A B) ? How many combinations of values exist for A AND B?4-7 8. Logical AND on two variables It is raining and IIt is raining I am in London am in London ABA B 111 100 010 000A AND B is true if both A is true and B is trueOtherwise, A AND B is false. 4-8 9. Logical Or A OR B A BA B A B Has two values: true if either Aor B is true, or if both A and B1 1 1 are true false if they are both false.1 0 1 Are either of these things true? Note: both can be true this is notexclusive or0 1 10 0 04-9 10. Logical Not Used to invert a meaning NOT A as an alternative:A A A = It is raining1 0 A = It is not raining0 1 4-10 11. XOR- Exclusive OrA BA XOR B True when either A or B are true, but not both1 1 0 So A and NOT B or B and NOT A1 0 1 Built from simpler logic:(A B) ( A B)0 1 10 0 0 4-11 12. Nor and NandA B A B A B A Nand B A Nor B1 1 1 10 01 0 0 11 00 1 0 11 00 0 0 01 1 4-12 13. Truth Table Analysis How do you build a truth table? Step 1: Create columns for all the variables in the sentence Step 2: Determine the number of rows you need given the variables in yoursentence Step 3: Define all possible sequences (cases) for your truth table, startingwith all variables false and ending with all variables true Step 4: Deconstruct the logic in the sentence and fill in your table What is the truth table for:1. X = A AND (NOT B)2. X = (NOT A) AND (NOT B)3. X = (A OR B) AND C 4-13 14. Logic and Logic Circuits What is a circuit? the complete path of an electric current, or a collection of electronic elements we will consider transistors to be the basic building blocks of logic computer hardware. Logic circuits are built from a series of transistors What is a transistor? 4-14 15. Transistors A transistor is an electronic device that has three ends: a source, a sink, and a sourcegate In this type of transistor, when the gate is:gate ON, power flows from the source to the sink. OFF, power does not flow to the sink sink 4-15 16. Transistors (like faucets)The operation of a transistor could be explained by making an analogy to faucets. A faucet has: An input the water company source An output a sink (where water is drained) sink Flow control If the tap knob (gate) is turned : ON water flows from the source to the sink OFF no water flows. The state of the tap determines the presence of water at the sink4-16 17. Transistors (like faucets) gate gate sourcesource OFF ONsinksink Changing from water to electricity in transistors: Electricity flows from the source to the sink with the gate = 1 (ON) Electricity does not flow from the source to the sink with the gate = 0 (OFF) 4-17 18. Transistors The current technology used to build computerhardware (chips) is called CMOS. source In CMOS we also use another kind oftransistor, distinguished by the littlebubble The bubble means that this transistorworks in the opposite way (its ONgatewhen the gate is OFF and OFF whenthe gate is ON). sink 4-18 19. Building Complicated Circuits with TransistorsBattery What on earth does this do?If A=0 then . . .bottom gate is offtop gate is onpower flows from the battery, cant go out the sink,and goes out through Z. Z = 1If A = 1 then A Z bottom gate is ontop gate is offpower doesnt get to Z from the battery, and anypower left in Z will flow out the sink. Z = 0 4-19 20. Building Circuits with Transistors BatteryA?10AZ01 What logical operator does this circuit perform? 4-20