An Introduction to Logic Gates

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello today we're going to do an introduction to logic gates this is going to be a very simple introduction and once again please ignore all the pencil lines that you can see which simply will be a guide for me when I actually deliver the video to understand logic gates we really need to understand how transistors work and that was covered in my video atomic physics 3 semiconductors diodes and transistors and there is a link to that video on the screen but you may recall that I showed that there is a device called an NPN device which is made up of semiconductor material this is n this is P this is N and the point about this type of device is that if you put a voltage across that device plus minus then you might expect that electrons will flow towards the positive charge but in fact they don't because there's what's called a depletion layer which builds up at this Junction and which I described in the earlier video that essentially stops the electrons from flowing but if you put a positive charge at that point then the electrons will indeed flow across and so this is essentially a switch if there is no positive charge at that point no electrons flow in other words no current flows but if you put a positive voltage at this point then the electrons will flow and the current will flow so it's a very simple transistor switch we call this part of the transistor the emitter because that's where essentially the electrons are emitted from we call this part the collector because it collects the electrons if you like and we call this part the base sometimes it's called the gate now in electronic circuits you will find that a transistor is usually represented by a symbol of this kind of form and in this case this is the emitter this is the collector and this is the base so this is just a schematic representation of these semiconductor material here and the same principle applies that if there is a voltage you might have it varies for different transistors but let's say you have five volts here and nope North volts here then and we better join up the wire so that there is a link and the position is that no current will flow the electrons are going in this direction from the emitter to the collector so the conventional current is coming in this direction down the voltage so no current will flow through that transistor if there is no voltage on the base but if you put a voltage on the base then a current will flow through the transistor so what you can say is if there is no voltage on the base then the switch is off because no current will flow through so insofar as that transistor is acting as a switch its off nothing will flow and that is often given the symbol zero or sometimes called false on the other hand if there is a positive voltage on the base then the switch is on and that is given the representation 1 or true all these schematic transistor diagrams that I draw in this video will be in this form with the emitter here the collector here and the base here now since we are looking at logic gates which are based on transistors we must just temporarily abandon transistors to understand a little bit about what logic we're talking about and this is known as boolean logic or boolean algebra and I can try to describe it by imagining that there is a playground and that there are children playing in the playground and some of those children are wearing red jackets and some of the children are wearing black shoes this group of children are wearing red jackets this group of children are wearing black shoes and this group in the middle are wearing red jackets and black shoes so if I shade the area then what you've got is that this shaded area is children wearing red jackets and black shoes this group are children wearing red jackets but not black shoes this group are children wearing black shoes but not red jackets and all around the outside are children who are neither wearing red jackets or black shoes here's the self-same playground again and here are the same groupings but this time I want to know who are the children who are either wearing black shoes or red jackets or both then the answer will be everyone inside the two circles because they're either wearing red jackets or they're wearing black shoes or they're wearing both and the final question just for these illustrative purposes that I might come up with is how many children are not wearing red jackets or black shoes and the answer to that is everybody outside the circle and in terms of logic this is known as an and because what we're saying is red jackets and black shoes this is known as or in other words either you're wearing red jackets all you're wearing black shoes or maybe you're wearing both and this is known as not that is the say you're not wearing a red jacket or black shoes or both now what logic gates do is they translate that boolean logic into an electronic form I'll explain later in the video exactly how you construct these gates using transistors but let's just think about the different types of logic gates you can have and there are seven basic logic gates the first gives effect to this logic the end logic it's actually called the and gate it's diagrammatic form is something like this it has two inputs and one output and that's called the and gate and what it means is that you've got two wires coming into a device will actually design the device in a while and one output from the device in here there's some electronics which I haven't told you about but the idea is that if both inputs have got positive voltages then there will be a positive voltage out but if either one or both have no voltage then there will be no voltage out so in other words you only get a positive felt voltage out if both the inputs have got positive voltages if one or both do not you won't get a voltage out so that's a piece of logic it tells you that if you get a positive voltage out it must be because both of these have got positive voltages the next electronic device gives effect to be or option and that is called the or logic gate and the diagram for an or gate looks something like this again it has two inputs one output and now the idea is that you'll get a positive voltage output if one or both of these inputs has a positive voltage so if neither has a positive voltage you get no output but if just one of these has a positive voltage or both then you will get a positive voltage out the next device gives effect to the knot arrangement here and again this is an electronic device it's called the not gate and it's symbol looks something like this it only has one input and one output and the idea is that whatever the input is the output is the opposite so if the input has a positive voltage the output would have no voltage if the input is has no voltage the output will have a positive voltage whatever this is it's the opposite of this and it's often called an inverter for that reason now there are four more fairly common gates the next one is called the nor a gate and that is drawn rather like an or gate here's the or gate so so far it looks the same but what you do is you put a little circle there and that tells you that it's a no it's a not so it's a nor version of the or gate and what this means is that you only get a positive output if both of these have no voltage in the input so if there's no voltage here and no voltage here you get a positive voltage out but if either or both of these have a positive voltage you get nothing out here the next logic gate is called the X or gate and that has a symbol that looks like this rather similar to the or gate except it's got this extra line here it also has two input one output and what an X or does is it gives you a positive output if one of these inputs is positive but not both so if both are zero you get no output and if both are positive you get no output but if one of them is positive and one of them is zero so that could be positive that could be zero or that could be positive and that could be zero then you get an output and then there's the kind of opposite of that the X nor which looks exactly the same as the X or except that it has the little circle on it so it has two inputs one output and this is the reverse of this this reverses this so in other words this will only give you a positive output if both the inputs are positive voltages or both the inputs are zero voltages you will get a positive voltage out but if one of them is positive and one of them zero you won't get anything out and that's precisely the opposite of this one and then the final one in the basic series of seven is called the NAND gate which kind of says not and and its symbol is very similar to the and symbol it has two inputs but because this is the end symbol because it's an and symbol of course it will have the little circle to indicate and what that will do is it will give you a positive output if either or neither has a zero and voltage it will give you zero output if both of these are positive voltages but if one is a positive voltage and the other is zero or they're both zero then you'll get a voltage out and in that respect of course it's just precisely the opposite of the and gate the and gate you only get a positive voltage out if you have two positive voltages coming in in this case you get no voltage out if you have two positive voltages coming in but if you have either one or both as zero voltages you'll get a positive voltage out now I'll just give you an illustration of how you can use these devices to build a very very very simple computer suppose we wanted a computer that would enable us to solve the equation a plus B equals C and we're going to be very simple here because the only values that you can have for a and B will be 0 or 1 so a and B can be 0 or 1 which means that the value of C can either be 0 that's if a and B are both 0 or the value of C can be 1 if a is 1 and B is 0 or vice versa or the value of C could be 2 if both a and B are 1 so if we put that in a simple table where we put the values of a B and C then we say that if a and B are both 0 then C will be 0 if a is 1 and B is 0 then C will be 1 if a is 0 and B is 1 C will be 1 and if a and B are both 1 C will be 2 and we're going to build a computer that will do that calculation for us and we're going to use logic gates to do it so here is the device that we're going to build we're going to have an X or gate here we're going to have a and gate here and we're going to have a nor gate here we're going to have let's move that up so you can see it we're going to have two inputs and they are going to represent our values of a and B and if there's a positive voltage then that represents the number 1 and if there's no voltage then that represents the number 0 so in other words we're going to either put a voltage a positive voltage on a or not and the positive voltage on B or not and the positive voltage represents our number 1 and if we don't put a positive voltage on that represents the number 0 so we're now going to feed these cables through to all of our logic gates we're also going to feed the B through to all of the logic gates so now we've got a and B feeding through to each of our 3 logic gates they are all going to have outputs of what I'm going to do is to send those outputs to a light emitting diode these are diodes which will glow red or any color actually but red is a common one if there is a voltage coming down the line but they won't glow if there isn't now what does an XOR device do let me just remind you that will send a positive voltage out if one of these is positive and the other isn't if both of them are no voltage or if both of them are positive voltages you get no output but if one of them has a positive voltage and the other one doesn't then you will get a positive voltage out and the light emitting diode will light up well if one of them is positive and the other one is not you've essentially got one plus zero so this is essentially the answer 1 what about the end gate well the and will only put out a positive voltage if I miss an input there if both the inputs are positive all right so that means that a and B both have to be positive voltages so a has to be one and B has to be one so this is essentially the answer to - if this lights up it must mean that there's a positive voltage on a and a positive voltage on B and what about Noor well nor will only send out a positive voltage if both the inputs are zero volts if either or both have got positive voltages you'll get no output so the only way this light emitting diode is going to light up is if both inputs have no volts and that means they represent zero so zero plus zero is zero so what you do is you take your inputs a and B and you put whatever you like you can put say a positive charge on a and no charge at all on B and what will happen is that you will get no output from end because they both have to be potted but they both have to be positive no output from the nor because both would have to be zero so these two transistor light-emitting diodes do not light up but the X or will light up because the XOR says one but not both of them has to be positive and when that lights up you have added one and zero to make one now that is a very long-winded way of adding together two numbers which can either be 0 or 1 but that is what the heart of computers do except they had millions of these logic devices that are handling information very fast so now let's see how we might actually design these logic gates using the transistors and we're going to start with the not gate and what we mean when we talk about the not gate is that the output which we usually refer to as y is equal to not the input and if the input is labeled by a then it's generally said a with a bar over means not so the output is not the input that's what we mean and we're going to start off with a transistor with a base input and we're going to go up via a resistance to a five volt battery and this end we're going to come down to zero volts which means essentially it's grounded so this is zero volts and we've got an output that we'll take here - we could take it to say a light emitting diode so that diode will only light up if there is a positive voltage coming out of the output now what will happen let's suppose there is no voltage on the base if there is no voltage on the base this switch will be open in other words no current can flow through the transistor because there's no voltage on the base and that means that there will be a positive voltage on this output because this is at 5 volts some of that will drop across the resistance but they'll still be a positive voltage we don't need to worry about what it is they'll still be a positive voltage here and that means that the transistor will light up so if there's no voltage coming in there will be a voltage coming out now let's look at it the other way suppose there is a voltage coming in well if there's a voltage coming in then this switch closes and the current can now flow through the transistor and if a current flows through the transistor then since this point is zero volts this point also will be zero volts and so you've now got a positive voltage on the base the input but now no voltage on the output because a current is flowing through here and so essentially this and this are at the same potential and that potential is zero and so this potential is zero and the whole five volts is dropped across the resistance here so this is simply an inverter and what you can do is to draw what's sometimes called a truth table if you look at the input which we'll call a and the output which we'll call Y if the input is zero volts then you will get a positive voltage out which we denote by the number one on the other hand if you have a voltage on the input you'll get no voltage on the output and so this is an inverter whatever you put in the input you get the opposite in the output and this is essentially known as a truth table and we should be drawing more of these for other devices the actual symbol for the not gate is the triangle with the little circle on the end and when you draw a sign a triangle with a little circle on the end this bit in the middle the transistor and the resistance is essentially the component that is creating the not gate and here is the input here and here is the output here a single input single output you do of course have to power it and that's what this five volt probably a battery of some kind is doing here but that's just the power this is the input this is the output now let's move on and design an end gate so this is a NAND gate and that is usually written as Y is a dot B that's that that's the standard way of defining that the output is a and B together and once again we have our transistors this time we're going to have two transistors and they are connected together this one goes up to the five volt battery this one comes down through a resistance to zero volts so that's essentially grounded put a connect this up here and our two inputs are essentially the two base inputs to the two transistors and we're going to take the output at this point here that's our output and once again you can send it through a light-emitting diode if you like I'm not going to draw that in here what we're now going to look at is the logic if you have no volts at all on these two inputs then these two transistors which are acting as switches will be open so no current will flow through the transistors and consequently since this point here is at zero volts then everything up to here will be zero volts this is essentially a switch that's open not no current can flow this way and so all of this is going to be at zero volts so the output will be zero so if the two inputs are 0 the output is zero what happens if one of these is open sorry one of these is a positive voltage and the other one has zero volts well if this has a positive voltage a current can flow through that transistor but if that is zero volts it doesn't do it any good because the current cannot flow through this transistor and vice versa if this has one volt the current could flow through this transistor but if this has zero volts it can't flow through this one so even if you have one of them with a positive charge and the other with a zero charge sorry a positive voltage and the other with a zero voltage still no current can flow still therefore this will be at zero volts but what happens if both have positive voltages then the switches will close a current can now flow the potential difference will fall across the resistance but this output will now have a positive voltage because it's connected to the five volts up here through the switches which are now closed so if and only if both of these inputs are positive you get a positive output and that's the end gate and the symbol for the and gate is something that looks a bit like this so when we draw the and gate in this form what we're actually saying is that here are the two inputs here is the output and this two transistors and resistance are what's contained within so once again we can draw our truth table for our inputs and our output our inputs are a and B and our output Y if the inputs are both zero the output zero if one of them has a positive voltage and the other doesn't the output is still zero if it's the other way round the outputs still zero it's only if both a and B have positive voltages that you will get a positive voltage out let's move on and design the or gate and this is often represented as Y which is the output equals a plus B and of course that means that either or both are true either A or B inputs and will be a positive voltage and once again we need two transistors with the two inputs here a and B these are the two inputs this time we're going to connect this to the five volt battery and here we're going to connect this via a resistance to north bolts but what we do here is we send this up to the five volts that way and here we bring this out down to an output which is coming here now let's draw our truth table as we go along the inputs a and B the output is y let's now ask what happens if a and B are both zero if a and B are both zero then these two transistors acting as switches are both open that means that no current can flow this way and no current can flow this way so in other words this output line here will be in exactly the same voltage as here and that's not volts so if a and B are both nought no current can flow through that transistor no current can flow through that transistor therefore the output is also nought now what happens if a is 1 in other words if a has a positive voltage but B doesn't well let's do B first of all be no current flows so consequently nothing happens as far as B is concerned but if a has got a positive voltage here a current flows through the transistor and right the way down to the zero volts I'll just show you the path again through that transistor which is now closed the switch is closed because there's a positive voltage here so through the transistor right the way down to the ground here and that means that there will be a potential drop across the resistance but there will be a positive voltage on the output so there's a positive voltage there and I think you can see fairly easily that the same is true if it's the reverse if a now has no voltage there will be no current going that way but if B has a positive voltage then the current can flow through the transistor and down here the potential is dropped across this resistance which means that the output here has a positive voltage and obviously if they a and B both have positive voltages then the current can flow both this way and this way and that means there'll be a positive voltage on the output so we've now got a device which says if you've got no voltage on the inputs you won't get a voltage on the output but if you've got a voltage or on one or both of the inputs you will get a voltage on the output and the symbol that we use for an or gate is the one that I drew before and that is this one now in fact we can use this description of the or gate to create our nor gate because you don't do very much more with an or gate with an or gate you simply add a further transistor and you have the output from the or gate going into this transistor and then you go up through a resistance to the five volt level and you come down here to the North volt level and this of course is simply a not gate that's exactly what we drew here transistor and a resistance is a not gate so this is a not gate so in other words whatever the output is and what so it will take the output there whatever the output from the or gate is the output from the not gate will be the opposite so let's now look at our truth table and we can see that this is the output from an or gate but now let's look at the output from an or gate well it will always be the opposite of whatever the or gate is throwing out because we're putting it through an inverter so if it was zero here it'll be one here if it was one here it will be zero if it's one here it will be zero if it's one here it will be zero it's precisely the opposite of the or gate because we're putting it through an inverter and taking the output heat out here and that output will be the opposite of the input and the input is effectively the output of the or gate and so you've now got an or gate and an or gate symbol of course is the same as an or gate but you put a circle on it like that and the representation of an or gate is y equals a plus B which is the same of course as the or gate but you put a line over the top remember that a line over the top in the same way as we did it with the not gate a line over the top i segment that there's a not element to it so here we've got a knot or this is the or gate this is not a nor gate it's the opposite of a nor gate giving us the exact opposite output to what you would get from an or gate and now we're going to look at a NAND gate that's the remember that's the knot and so why the output is equal to a dot B which is the same as for the and gate but because it's a knot you put a line over the top and the way we design that we again need two transistors and each of those will have an input and those are going to be our inputs a and B we're going to go up through a resistance here to the five volt level and we're going to connect these to come down here to a North bulb level so essentially it once again we've put a battery between the two devices and when it this time we're going to take our output along this line here and now we'll draw our truth table as we go along a and B are our two inputs and Y is our output so let's suppose that both the out the inputs are 0 volts if that is the case that switch is off that switch is off no current can flow through here and consequently the current will flow this way some of the voltage will be dropped across this resistance but they'll still be a positive voltage here because no current can fall down here so there's a positive voltage so if there's no voltage on the inputs there will be a voltage on the output what happens if a is 0 but B is a positive voltage well the current still can't get down because it can go past feet it can't even get past the a transistor let alone go through the b1 and so consequently there's no current flowing right the way down the current will flow this way there will be a voltage drop across the resistance but they'll still be a voltage here and similarly the other way around if a and B a has the positive voltage B does not then the current will flow through the a transistor but it can't get through the B transistor because that transistor as a switch is open consequently the current can go this way some voltage drop across the resistance but there's still a positive voltage here but if both a and B have got positive voltages both those switches will close the current will now flow straight down here the entire voltage will be dropped across that resistance which means that this point here will be the same potential as this point here because this is just the equivalent of a straight wire the current is flowing straight through so this potential which is zero volts is the same as this potential and therefore the output will be zero volts ittsan and what it means is that you get an output for everything except where both the inputs have got positive voltages and remember that the symbol for a NAND gate is the same as the symbol for the and gate except it's a knot so it gets a little circle and then the output we've done five of the gates we've just got two more to do the next one we're going to do is the X or gate and the hole if you see it and that has representation of y equals y is the output don't forget a plus in little circle B and that means that either one of the inputs is positive but the other isn't so one can be positive but not both and here we actually have to use other gates but they will contain transistors but we need to use actually for mend gates to create an xor gate and that's how you start to see how these gates build up in logic terms so let me draw my for NAND gates 1 2 3 4 and we're going to connect them this way here is the input well actually the input is going to come here and we're going to split the input like this the output that comes from this NAND gate becomes the in booked foot for this nand or these NAND gates and then the output from those NAND gates become the input for this NAND gate so here's the input this is a and this is B we split it so that we send the input through this NAND gate we also take a and B into these NAND gates and we take the output from the NAND gate into these NAND gates and then we take the output from both of those NAND gates to become the input to this NAND gate and finally we get an output from there so let's try to create the truth table we've got a and B and we've got Y which is the output and let's start off with a and B both being 0 and remember that the point about the NAND gate is that you get an output in all circumstances unless both the inputs are positive so we've got 0 coming in here 2 zeros that will give us a positive output so we'll now have a positive output going in here with a 0 coming in here a 1 and a 0 still gives you a positive output similarly here you've got remember we had a positive output going in with a negative that still gives a positive output we've now got positive coming in here positive coming in here and 2 positives going through a NAND gate will give you a 0 output hope you followed that now let's do the situation where a is 0 but B has a positive input so a is positive sorry a is 0 but B is positive so in this one we've got a 0 and a positive well that means you'll get a positive out a positive out coming in here together with a 0 a will give you a positive out so that's a positive coming in here what about at this end well B we said remember is is positive so B is positive the output from here is positive so we've now got two positives going in that means you're going to get a negative you're going to get a 0 coming out you had a positive coming in here a 0 going in here a positive and a 0 will give you a positive output if you do it the other way around I think I don't need to talk you through it it's obviously symmetrical it's going to be exactly the same so there is going to be a positive output coming out here and the final set of situations is if both a and B have got positive inputs well what's going to happen to positive inputs coming in here will give you a zero output because that's the consequence of an end gate a positive out input and a zero input will give you a positive output same applies here zero out positive zero out becomes zero in plus the positive in gives you positive out positive and positive going in gives you zero coming out so you get zero coming out and that is your X or gate you get a positive out if one or the other is positive but not both and not neither and the diagram which reflects the X or gate is this one and that just leaves us with one more to do which is the X nor gate which is y equals a plus B with plus in a little circle but we put a line over it to show that it's a knot and how do we create that well I don't actually have to draw another diagram you'll be pleased to know all that you do is you take the output here and you put it through and not gate and if you put it through a not gate all that will happen is that the output from the XOR gate will be as it were inverted so whatever you get out of an XOR gate will be the opposite of what you get out of an X nor gate so down here this is the X or output this is the X nor output y and that will always be the opposite to what you get out of here so that will be 1 0 0 1 and the symbol for an X nor gate is the same as for an X or gate but of course it has the little circle at the end so an X nor gate will give you a positive output if either both the inputs are 0 or both the inputs are positive but if one is positive and the other isn't you will get no output from the X nor gate now just to say that of course some of those gates you didn't actually need to use transistors you could have used diodes this is a perfectly respectable or gate you put your inputs through 2 diodes and join them together here is the input a here is the input B and here is the output Y if a is 0 and B is 0 the output Y will be 0 but if a is positive and B is 0 then a current will flow through here and you'll get an output if a is 0 and B is positive you will get a current flowing through here and Y will be positive and if both of them are positive voltages currents will flow and Y will be positive and that is essentially an or gate but that works for or ok but you can't use diodes for some of the other gates that we've described you have to use transistors and finally just to give you some flavor for how these logic gates are used in computers they no longer use separate individual transistors instead they use a process called photolithography which is essentially a means of itching on semiconductor material so that you create not just one transistor but what's called an integrated circuit and currently you can get something of the order of the equivalent of nine million transistors per square millimeter of an integrated circuit board a scientist called Moore set up what became known as Moore's law back in 1965 he said that the number of transistors that you could get on a reasonable sized chip would double every two years in 1971 they could get about 2,000 transistors on a chip by using this process of integrated circuit boards now or in 2011 2.8 billion transistors per chip are possible and those chips go on to make micro processors and the micro processors are what are at the heart of computers and that all involves from the essence of the logic gates that I described today
Info
Channel: DrPhysicsA
Views: 908,168
Rating: 4.9082928 out of 5
Keywords: Logic, Gates, Physics, Electronics, transistors, Boolean, Algebra, AND, OR, NOT, NOR, NAND, XOR, XNOR, computers
Id: 95kv5BF2Z9E
Channel Id: undefined
Length: 47min 9sec (2829 seconds)
Published: Mon Jun 04 2012
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.