Transcript for:
Understanding Logic Gates and Truth Tables

in this video we go over using logic gate diagrams and truth tables [Music] so here we see an example of a logic diagram created using a selection of and or and not gates also sometimes referred to as a circuit diagram so let's go over the various logic gates and truth tables for the boolean operators that you need to know about for the exam this is the symbol for not gate and not gate simply reverses the input so if the input a is zero we mean false or off then the output is one true or on and we can see that shown here and there's the reverse nice simple truth table nice simple logic gate this is the symbol for an and gate an and gate output is true if both of its input true otherwise the output is false so here we have zero and zero as our input so the output is zero zero and one for the inputs the output's still zero one and zero the output zero only in the case where both a and b are one is the output one this is the symbol for an or gate and an or gate's output is true if at least one of the inputs is true otherwise it's false so here we have zero and zero as the inputs well because they're both zero the output's zero but in all other cases it's going to be true zero or one is the input the output is one one or zero the output is one and one and one the output is one and finally the symbol for an xor gate now this is an exclusive or gate so the output is true if one and only one of its inputs are true otherwise it's false so we've got zero and zero well if both inputs are zero the output zero we've got one of the out inputs as one here zero and one so the output's one we've flipped it so now we've got a one and a zero so it's one but here is where it differs from an or gate both the inputs are one so the output returns to zero so there's a quick summary there the four gates which are mentioned in your specification along with what they're called and the associated truth tables underneath so how to remember the different logic gates so or we can think of the left hand curve of an or gate fitting around the o of an or xor just think of it the same but we've got the additional line which is crossing through the middle of the ore we've got an and gate that's nice and easy we can think of it fitting neatly around the capital letter d of an and and a not gate well if we turn the word not on its side the catalytic t fits nicely into the base of a not gate so it's just a nice summary here of everything we've learned up to this point we've got the the english on the left there we've got the diagrammatic version of the logic gate we've got the symbol the ocr use when writing this out in boolean notation and alternative notation which you may see in other videos and textbooks these would be accepted in the exam but ocr won't be using them so a quick note from the exam board the ocr clarification document states that candidates should be able to construct logic gate diagrams from a boolean expression and vice versa and candidates should be able to construct truth tables from building expressions and logic gates so boolean expressions truth tables and circuit diagrams are all alternative ways of really representing the same thing to make sure you're completely ready for the exams you should be comfortable with at least one of these three and be able to produce therefore the other two from it so let's have a go at completing the truth table for this logic diagram the first thing we need to do is create columns for each of the inputs a b and c we then need to list all the possible combinations the easiest way to do this is to count up in binary from zero zero zero to one one one in other words we're counting up from naught to seven you then need a blank column for any interim outputs or inputs and a column for the final output so we have output d which is the result of a or b which then becomes one of the inputs for the final and gate and then finally we have the output from the whole logic diagram e we take each row in turn working through the logic gates in order so start with the or gate on the left if we consider the first two rows a is zero and b is zero both these rows would result in the output d being zero because it's an or gate remember of an or gate at least one of the inputs needs to be one for the output to be one in the next two rows a is zero and b is one both these rows would result in d being one in the next two rows a is one and b is zero so both these rows would result in d being one and the next two rows a is one and b is one so both these rows would also result in d being one we are finished with the or gate so we can now move on to the and gate this gate has two inputs c and d if we consider the first row c is zero and d is zero this means the output e will be zero both inputs to an and gate must be one for the output to be one in the next row c is one and d is zero so the output e would be zero in the next row c 0 and d is 1 so the output e is 0. in the next row c is 1 and d is 1. so now we have two ones so the output e would be 1. so zero and one is a zero one and one is a one zero and one is a zero and one and one outputs as a one so let's try constructing a boolean expression from a logic diagram the final output of the diagram is d so we start the expression with d equals there are two gates feeding into the or gate the first is an and gate with the inputs a and b we use the little kind of up carrot mountain symbol to represent and so the and gate can be represented as a and b as shown here the output from this and gate is combined with the output from the not gate to become the two inputs for the or gate therefore directly after our amb we need to use the or symbol when i have d equals a and b or all that's left is to represent the other input to the or gate which is not c we use that symbol there to represent not so the final boolean expression is d equals a and b or not c as shown okay so try this example yourself pause the video and write out the boolean expression for this logic diagram then unpause the video and check your answer so we've got d equals not c and a or b and notice the use of brackets to help apply the precedence here another acceptable answer would be not a or b and c both of these expressions are equivalent and they mean the same thing let's try one final example pause the video and write out the boolean expression for this logic diagram then unpause the video and check your answer so either of the following two boolean expressions shown are correct it all depends which gate you started with so in this example we're going to tie everything we've learned so far together carefully read the scenario on the left then pause the video and try to draw the logic diagram construct the truth table and write the boolean expression so here's the scenario a fire alarm goes off if either the temperature inside the building rises above 60 degrees celsius or someone manually activates a fire alarm a firefighter should be able to manually shut the fire alarm off regardless of how the alarm was triggered so here's the correct logic diagram let's work through the scenario to check it's correct we should start by trying various inputs to work through the logic let's start with all the inputs as zero or force in other words the temperatures below 60 degrees celsius the fire alarm's not been set off and a fire fighter has not shut the alarm off manually if the temperature rises above 6 degrees celsius the fire alarm should go off we can see that if we set the temperature input to one or true then both inputs to the and gate are one or true and the final output is one or true meaning the fire alarm goes off if the fire alarm is set off manually it should also go off and this results in the same situation as before once again the final and gate output is a one or true and the fire alarm goes off we also need to check if the fire alarm still goes off if both the temperatures above 60 degrees and the alarm is activated manually this still works as we're using an or gate at this stage and it only requires at least one of the inputs to be true for the output to be true now if we'd use an xor gate at this point the alarm wouldn't go off quite a dangerous situation in this scenario we also need to check that regardless of the inputs to the or gate the alarm can be manually shut off by a firefighter we can see this works if we set the input of the not gate to 1 true its output becomes zero false and so the final out and gate outputs zero effectively turning the alarm off now let's turn our logic diagram to a truth table and a boolean expression we start by creating a column for each input in this case a b and c we then need a blank column for any interim inputs and the final output we need a column for the output of a or b we're going to call that e we also need a column for the output of not c calling that f and you can substitute any letters you like here for the various inputs outputs and we have our final output d which is e and f we then need to list all the possible combinations the easiest way to do this is to count up in binary so we're going from zero zero zero to one one one from naught to seven next we complete the part of the truth table that represents the or gate remember if either a or b is one then the output is one and you can see we've done that here next we complete the part of the truth table that represents the not gate remember if c is zero then f is one and vice versa and you can see we've done that there next we complete the part of the truth table which represents the and gate remember both inputs to the and gates that's e and f must be one for d to be one and we've shown that there and here is the boolean expression for the truth table note that either the expression is shown are correct it all depends whether you choose to start with the or gate or the not gate having watched this video you should be able to answer the following key question how do you translate a logic gate diagram into its associated truth table and boolean expression and vice versa so that's everything you know for the exam we're just going to cover two other logic gates which aren't technically in the specification but really you should know about them for a level and you'd certainly need to know about them if you're doing anything deeper with boolean logic say at university so there are all the different logic gates that you need to know for the exam and or not or xor but you can see we've got two others here directly under the and and the not the first here in the bottom left is the nand gate that means not and it's like putting an and gate followed by a not gate together it simply reverses the output of an and gate so if the and gate was outputting one a nand gate would now output zero and vice versa the other gate is a nor gate and as you've probably guessed this is simply a not or gate it's like having all gate followed by not gate whatever comes out of your gate is reversed so if the or gate chucked out at zero the nor gate would therefore chuck out a one these look very similar to the and and or gates just with a circle on the end the reason these gates are so important is they're actually known as universal logic gates so nand and nor are universal logic gates that means you can create the logic of all the other gates by using only combinations of an and gate or only combinations of a nor gate so just before we end this video we want to make you aware of our freely available boolean algebra cheat sheet this is a double-sided cheat sheet that comes in a4 or a3 version which can be used as posters and it covers all the information on boolean algebra the various logic gates truth tables definitions and a lot more material will be going over in future videos all in one handy double-sided sheet you can find this over at student.craigandave.org just scroll down to where it says a-level revision if you select that you will see ocr a-level revision including a whole bunch of free resources including these cheat sheets you can click download no subscription login is required and you'll get access to this cheat sheet [Music] you