Transcript for:
Binary Numbers and Logic Gates

let's begin our discussion with binary numbers now when you hear the word by what do you think of by is associated with the number two and so binary numbers have only two possibilities zero or one now when dealing with circuits zero is or a corresponds to a circuit being in the off state one corresponds to a circuit being in the on state so if you're dealing with true and false statements an off state will be considered false and on state would be considered true if you're dealing with voltage an off state would have zero volts and an on state typically five volts but something other than zero now before we go over and or and not gates let's talk about the buffer gate so here is the symbol of the buffer gate and it basically looks like a triangle pointing towards the right on the left we have the input on the right we have the output so we're going to call the input a the output will also be the same so if we were to make a truth table with the input and the output if the input is on which means it has a binary number of one the output will also be in the on state if the input is in the off state which means it has a binary of zero the output will have the same binary number of zero as well now let's draw a circuit to represent this and the principal element of this circuit will be an npn transistor this is the base this is the collector and this is the emitter now we're going to connect this to a power source and we're also going to use a light emitting diode now the light emitting diode it's going to represent the output of the circuit now let's connect this to a voltage source so here is the input which we'll call it input a and what's going to happen if we apply a voltage to point a so if the input is in an on state will the led will be on or off well once you apply a voltage to the base the transistor will turn on current will flow from the collector to the emitter therefore the led will be in an on state so this corresponds to a one for the input and the output now what about if the input is off so in this case we have a zero at the input if there's no voltage at the base then the transistor will be off no current will be able to flow from the collector to the emitter so therefore the led will be off as well and so that's basically the buffer logic gate so if you have a one n in the input you're gonna have a one in the output if you have a zero in the input you have a zero in the output now the next type of logic eight that we're going to talk about is the not gate so here is the electrical symbol for it it looks like a buffer gate but it has like a circle in the front now let's call the input a the output will be the complementary of a you can also write it as a bar now let's write a truth table so we're going to have the input and the output so if we have a zero at the input the output will be a one and if we have a one at the input the output will be zero it's always going to be the opposite so basically if the input is in an off state the output will be in an on state and vice versa now how can we represent this using a transistor circuit the circuit is going to be very similar to what we drew before but there's going to be one key difference and that is the location of the led so here is our voltage source and on the left we have our input a the emitter is attached to the ground but the led will be connected across the collector of the transistor and the emitter so once again this will be our output so let's say if the circuit or rather input a is in the on state will the led be in the on state or the off state well let's analyze it so once we apply a voltage to the base of the transistor current will be able to flow from the collector to the emitter so current will flow from the positive five volts through the resistor now once it gets to this point it has two options the current can flow to the right or it can flow to the left now electricity will usually rather not usually but will always take the path of least resistance and if the transistor is on then the path of least resistance is from the collector to the emitter so therefore no current will flow in this direction so this will be in the off state because the current has been diverted through the transistor so notice that we have a complementary situation the input is on but the output is off likewise the reverse is true so let's say that the input is off there's no voltage applied at input a so what's going to happen current will still flow through the resistor now once it reaches this point because the transistor is off it cannot flow through the transistor so therefore it has no choice but to flow through the led so therefore the led is in an on state so as we can see here if we have a zero at a the output will be a one and if we have a 1 at a the output is a 0. and so that's the basic function of a not gate it turns an off state into an on state and vice versa it turns a into a prime now the next logic gate that we're going to talk about is the and gate and here is the symbol for an and gate we're going to have two inputs a and b and the output will be a times b now let's write a truth table and at the same time let's draw a circuit for this so we're going to need two transistors as opposed to one so this is input a and this is input b and let's connect it to a voltage source so what happens if input a and b are in an off state will the led be on or off in this case both transistors will be off so no current can flow from the positive 5 voltage source to the ground so therefore the output will be a zero because the led is off now what if a is in an on state and b is an off state will the led be on or off current can flow through the resistor through the led and through the first transistor however because the second transistor is off no current can flow through it so therefore no current will flow through the led so the led will be in an off state so we're going to put a zero the only way the led can be on is if both inputs a and b are on only under that circumstance can current flow through the led and through both transistors to make it to the ground so thus we have the word and the only way the output can be in an on state is if both inputs a and b [Music] are on the on state so even if b is on and a is off no current will flow through the led only if a and b are on now let's move on to the ore circuit and let's begin by drawing the symbol for that so here's how it looks like so let's say this is input a and b now it's not going to be a times b as in the case of an and circuit but it's a plus b for the or logic gate now let's make a table just like before and let's draw a circuit that corresponds to it so this time what we're going to have is two npn transistors but they're going to be connected parallel to each other to make the or logic gate in the case of an and logic gate they were connected in series with each other and so that's the key difference between the and and or logic gate now let's say that transistor a and b are in the off state will the led be on or off so clearly no current can flow through the first transistor or through the second transistor so therefore no current will flow through the led the led will be off so we can put a zero in the truth table now what about if the first transistor is on but the second one is off what's going to happen current can flow through the resistor through the led but through the transistor that is on so therefore there's a path from the positive voltage source to the ground so the led will be on so let's put a one now what if transistor b is on but transistor a is off current can still flow but this time through transistor b so the led will be on now what if both transistors are on in this case the led will definitely be on current can flow through transistor a or through transistor b so that's we have the or logic gate the led will be on if a or b is on and so that helps me to remember the truth table for the or logic gate if we have a one in a or b doesn't matter which one the output will be on now i want to talk about the nand gate but let's compare it with the and gate the nand gate is basically the complement of the and gate so here is the symbol for the and gate the nand gate symbol looks very similar the only difference is we're going to have a circle at the end so let's say this is input a and this is input b the output of an and gate we said it's a times b for a nand gate it's going to be the complement of a times b now remember the complement of a zero is one and the complement of one is zero now let's look at the the truth tables for these two types of gates so as we recall the only way to get a one with an and gate is if both inputs a and b have a one besides that it will be a zero in the case of a nand gate when both inputs a and b are on the output will be off so as you can see this row i mean this column rather is the complement of this column now we could use an and gate and a not gate to construct a nand gate so here is the and gate and let's put a not gate next to it so let's say this is input a input b the output of an and gate is a b and once you use a not gate it basically takes the input and gives you the complement of that so the complement of a b is just a b prime and so the combination of these two logic gates will produce or is equivalent to a nand gate now here's a question for you let's say if we have a nand gate and let's say if we take the two inputs of a nand gate and connect them together what type of logic 8 do we now have what would you say so let's compare it to the original nand gate so this would be a and b and we would get a times b but the complement of that result well now we only have one input because both of these will be a and so if we multiply these two it would be a times a and then we'll get the complement of that what is a times a now you need to be familiar with some rules of boolean algebra and we're going to go over those rules soon but a times a is basically a one way to help you to see this is if you multiply zero and zero you get zero if you multiply one and one you get one now keep in mind we're dealing with binary numbers and so in a binary system this is it it works out to be true a times a is a so this is the same as the complement of a so notice that we went from a to a prime this is the equivalent of a not gate so that's how you could use a nand gate to make a knocking so these two are functionally equivalent now let's understand how this works using a truth table so let's write the truth table of a nand gate now once we connect the two inputs together let's say once we make this circuit here we have this circuit by the way these two columns has to be the same so therefore these two possibilities cannot work because let's say if this is a this has to be a as well so meaning let's say if we have a one we can't have a one and a zero that's not possible it's either if this is going to be a one both of these inputs will be a one or if we have a zero here both inputs will be a zero so these are the only two possibilities so if we have a zero the output is a one and if we have a one the output is zero and so that's the this is the same table of a not gate now let's talk about the ore and the nor gate the nor gate is the complement of the or gate much in the same way as the nand gate is the complement of the and gate and so let's draw the symbols for both of these the nor gate looks like the or gate but with a circle at the end so given inputs a and b the output of the or gate we said it's a plus b for the nor gate it's going to be a plus b and then it's the complement of that result now let's write out the truth tables the or gate the output of a or gate will be in the on state if either a or b is in the on state now in the case of the nor gate it's simply the reverse if either a or b is in the on state the output will be in the off state now one of the first things that you need to be able to do if you're taking a course in intro to logic design is that you need to be able to write a function given a block diagram so let's start with the first one in the upper left corner the first thing i like to do is identify what type of logic gates i'm dealing with so this is an and gate i'm going to use a capital a to represent it now for the over here notice that the inputs of the first and gate are a and b and when dealing with an and gate you need to associate it with multiplication and when dealing with an or gate associate it with addition so what the and gate is going to do it's going to take the two inputs and basically multiply them together so the output will be a times b now the second and gate will take this input which is av and multiplied by this input which is c so thus we could say that the output of this entire circuit represented by function f is going to be the product of a b and c so this is the answer for the first one now what about the second one in the upper right corner feel free to pause the video if you want to try it yourself so let's begin by identifying each logic gate in a circuit so we have two and gates and here we have an or gate so the output of an and gate is going to be basically the product of the inputs so this is just going to be x times y and here the inputs are x and y prime so this is going to be x y prime now the or gate is going to take the two inputs and then it's going to add them together so the output of the or gate will give us the function x y plus the other input x y prime and so we could say that function f is equal to xy plus xy prime so that's how we can write the function using or given a block diagram now let's consider the third one on the bottom left so this is an and gate and so is this one and here we have an or gate so when dealing with an or gate we're going to take the two inputs and add them together so this is going to be a plus b and for the and gate we're going to take the two inputs and multiply them together so this is a times b prime now here we have another and gate so we're going to take these two inputs multiply them together so we may need to use a set of parentheses so the function is going to be a plus b so that's this input times a b prime you could put down parentheses if you want to but you really don't need to now let's focus on the last one we have one and gate and two or gates so for the first or gate we're going to take the two inputs and add them together so this is going to be x plus y and for the second one we're going to do the same thing so this is going to be x prime plus c now for the and gate we're going to take these inputs and then multiply them together so in parenthesis we have the first one x plus y and then times the second one x prime plus z so f is equal to what we have here now here is the challenge problem go ahead and write the function given the block diagram shown below feel free to take a minute and work on this one so let's identify the logic gates that we have so here we have an and gate and or gate another and gate and then we also have an or gate at the right now let's focus on the first and gate we're going to take the inputs x and y and we're going to multiply them now for the or gate we're going to add x y with the other input z so this will be x y plus z now for this and gate we are going to multiply these two together so it's going to be x prime times x y plus c now let's talk about the and gate at the bottom this is a three input and gate and the output of that and gate is simply going to be the product of the three inputs and so that's going to be x times y prime times a z now the last thing we need to deal with is the or gate and this is a three input or gate and all we need to do is add the three inputs together so anytime you're dealing with an or gate think of addition when you're dealing with an and gate think of multiplication so we could say the function f the output of it is going to be the first input which is x prime times x y plus c plus the second input which is w plus the last input which is x y prime z so this will give us the output of this circuit diagram using the inputs that we have here so that's how you can write a function given a block diagram now let's work on the reverse let's say if we're given a function how can we draw the block diagram let's say the function is a b plus c go ahead and draw the block diagram for that given function so first notice that a and b are multiplied to each other so we're going to deal with an and gate and notice that we have an addition symbol so we're going to use an or gate between a b and c so let's begin let's start with the and gate so here are the two inputs a and b and then the output of that will be just a b now we need to connect that with an or gate and then we need a new input input c so the or gate will take the sum of these two inputs and so we'll get the output a b plus c and so that's it for that example here's another function let's say we have f is equal to x y plus x prime y plus y prime z so go ahead and draw a block diagram for that given function so notice that here we have what is called a product term so we're going to use a and function for this product term here this is another product term so we're going to use another and function to connect x prime with y and we need another one to connect y prime with z so we need three and logic gates now we could use one or gate to basically add the three and logic gates together because we have the plus symbol or sum we need to use an or gate so this is going to be the first and gate and we're going to put x and y together and so that will give us the output x y and then we're going to use another and gate we're going to have the inputs x prime y and then another one so this is going to be y prime and then z now we're going to feed these three and gates into an or gate and so the output of the or gate is going to be the sum of the three inputs and so that's how we can draw a block diagram for this expression now something else that you need to know this expression here is something known as an sop expression which stands for sum of products x y is a product as mentioned before x prime y is a product and y prime z is a product so we have three product terms and we're adding them so that's a sum of products expression now another term you need to be familiar with is literals so every variable that you see whether complemented or uncomplemented is literal so x is a literal y is a literal x prime is one so we have a total of six literals in this expression now let's consider another example so let's say that f is going to be a plus b prime and then times a plus b plus c times b prime plus c prime go ahead and draw a block diagram now the last example was a sum of products example this one is known as a pos which is product of sums this right here is a single sum term the reason why it's a sum term is because you're adding a and b prime so notice that we have a total of three sum terms and we're multiplying each of those three sum terms together so thus it is a product of sums expression now how many literals do we have in this problem so we have one two three four five six seven so there's a total of seven literals in that expression now let's go ahead and draw the block diagram now for at some term should we use an and logic gate or an or logic game what would you say now remember you want to associate or with addition or sums and you want to associate and with multiplication or basically products so because we have a sum turn we're going to use an or logic gate for each one so we're going to need three or gates and we're going to feed these three or gates into a single and gate because we do have multiplication here so let's go ahead and draw the diagram so let's start with our first or gate this is going to be a two input or gate based on what we see here so the first input is going to be a the second one is going to be b prime and the output of this or gate will be a plus b prime now moving on to the second or gate it's going to be a three input or gate the inputs will be a b and c the output is going to be a plus b plus c and for the last or gate this is a two input or gate with the inputs b prime and c prime so this is going to be b prime plus c prime now let's feed these three or gates into a single and gate so the output of this and gate is going to be the sum i mean that's the sum but the product of these three expressions and so you just got to multiply them this is going to be everything that we see here so i'm not going to write it again and so this is the block diagram for the function f now let's work on number three describe each of the following expressions as an sop expression sum of products or pos expression product of sums both or neither and at the same time discuss the number of variables literals product terms and sum terms and identify any min or max terms so let's start with this one let's say we have the expression x y prime plus x y is z prime plus x prime y z w plus x y prime z prime so is this a sum of products expression or a product of some expressions or is it both for neither so this is a product term each one of these are product terms now just to review one literal could be a product term so x is a product term y prime is a product term or if you multiply them these are product terms so what we have here is a sum of products expression we have four product terms and as we can see there's a plus sign separating them so it's a sum of products expression now how many different variables do we have in this expression notice that we have x y z and let's not forget w so we have a total of four different variables how many literals do we have so here we have two literals they can be complemented or uncomplemented here we have three literals this has four and then this is three so if we add them together there's a total of twelve literals in this expression now what about if we have a min term or a max term what would you say in this case since we're dealing with an sop expression a sum of product expression we need to identify the standard product terms or the min terms now a midterm is basically a standard product term that includes each variable of the problem so we need it has to include all four variables either complemented or uncomplemented so this term right here is the min term in this expression because it has all four variables now let's move on to our next example consider this expression x plus y times x prime plus z and then times y plus z prime times x plus y plus z prime so is this a sum of products expression or a product of sums expression so x plus y this is a sum term x prime plus z is also a sum term so notice that we have a total of four sum terms and each of them are multiplied to each other so this is going to be a product of sums expression we have the product of four sum terms now how many variables do we have in this expression so i see three variables x y and z now how many literals are there in this expression so here we have two literals in the first sum term the second sum term has two literals the third one has two and the last sum term has three literals so thus we have a total of nine literals in this problem now we're not going to have any mint terms because this is not a sum of product expressions but we do have a max term because this is a product of sums expression so what is the max term in this particular problem so which sum term includes each variable of the problem either complemented or uncomplemented so this is the sum term that has all the variables so therefore this is considered the max term now let's move on to our next example let's say we have the expression x y prime z w so this expression is it an sop expression a pos expression both or neither what would you say it turns out that this is both a sum of products expression and you could describe it as a product of some expression so in terms of let's say sop we could say that this is the sum of one product term now in the case of a pos expression you can also describe it as the product of four sum terms now if that statement confuses you see it this way x you could think of x as x plus zero y prime you can see it has y prime plus zero and then z plus zero and w plus zero now in this form it looks more like a product of four sum terms at least that's one way i think of it but that particular expression can be described as both a sop and a pos expression now how many variables do we have and how many literals so for this expression we have a total of four variables w x y and z we also have four literals w x y prime and z so that's all we could say about this expression let's move on to our next example consider the expression a plus b plus c prime plus d plus e prime so can we describe this as an sop or pos expression like the other example you could represent it as both pos and sop so as an sop expression we can say that this represents the sum of five product terms and as a pos expression we could say that this represents the product of one sum term so imagine if we put it inside a single set of parentheses in this case this would appear as one sum term now it's important to understand that if you have just one literal let's say it's either x or y prime one literal can be considered a product term or a sum term so just keep that in mind now for this particular example we have a total of five literals a b c prime d and e prime we also have five variables a b c d and e and so that's it for that expression so make sure that you understand the difference between a product term a sum term and a literal so a product term could be just a single variable x it could be y prime or it could be multiple literals multiplied to each other like x y prime or x y z so those are product terms a sum term can be an individual literal it could be x it could be z prime or it could be a sum of multiple literals like x plus y or even x plus y prime plus c so those are sum terms and the literal is just a variable it could be x y prime it could be complemented or uncomplemented so that's literal now let's consider one more expression let's say we have a multiplied to b plus c d prime what type of expression do we have so here we have a single term like a literal and this is a product term and it looks like just a mixture of sop and pos it turns out that this expression is neither it's neither a sum of products or a product of sums expression now this expression has four variables as we could see it's a b c and d and it has four literals if we list them it's a b c and d prime and that's all we can say about this expression so this is an example of an expression that is neither sop or pos now let's say if c wasn't there what type of expression will we have now would you still say it's neither because this is now a sum term when you have c here this is no longer a sum term but when you take away c now we have a sum term and a is considered a sum term you can write that as a plus zero so that's the sum term and then b plus d prime that's another sum term so this is the product of two sum terms so this would be a pos expression but once you put c into the mix this is no longer a sum term nor is it a product term so this would be neither now let's review some basic rules of boolean algebra now whenever you see a plus sign know that you're dealing with the or logic gate and if you see like multiplication or a product term remember you're dealing with the and logic gate so the first law that we're going to go over is the commutative property a plus b is the same as b plus a and a times b is the same as b times a the next one is the associative property so a plus b plus c is the same as a plus b plus c and a times bc is the same as a b times c so that's the associative property and as you can see the order for the and and or operators doesn't matter the next one is the identity rule a plus 0 is equal to a and a times 1 is also equal to a the next one is the null property a plus one is equal to one and a times one i mean a times zero rather is equal to zero now if you're analyzing this using old school algebra this equation might make sense to you but this one might be a little confusing for instance if a is zero zero plus one equals one okay that makes sense but what if a is one one plus one does it really equal one well in old school algebra one plus one is two but when dealing with boolean algebra one plus one does equal one and let's prove that using logic gates so here we're dealing with the or logic gate so let's draw that now we're going to have two inputs a and b but b we're going to say it's always equal to one now the output will be a plus b now let's make a truth table now remember the output will be a 1 if either input a or input b is in the on state so a could be one or zero b is always one so this is b so if a and b are both in the on state then this logic gate will be on so we're going to give it a value of 1. here b is on a is off so if one of the inputs is on for the or gate the output will be on so in this case if a and b are in the on state we can see that the output is one here if b is on a is off the output is still one but this is the one that we're working with so one plus one does equal one when dealing with uh logic gates this means that if a is on and b is on then the output a plus b will be on as well and that's the way you have to think about it when dealing with these types of boolean algebra expressions now the next rule that we're going to talk about is the complements a plus a prime is going to be one and a times a prime will always be zero so this is the complement property now using numbers if you have a zero and a one let's say a is zero a prime has to be one this is going to be one so when dealing with the or logic gate if one of the inputs is in the off state and the other is in the on state the output will be on so that's what zero plus one equals one mean now for this one we're dealing with the and gate so let's draw that circuit so let's say if we'll call this a and a prime so if a is on that means the other one a prime will be off now when dealing with the and logic gate the only way the output will be on is if both inputs a and b or in this case a and a prime are both odd because keyword and well this will never happen because if a is on a prime will automatically be off so the two inputs will never be on at the same time so no matter what this is always in the off state so we're gonna have a binary number of zero therefore whenever you use an and logic gate with the a and a prime inputs the output will always be zero it will always be off