In this video, we will be looking at a type of logic gate known as an AND gate. Now a logic gate is a component with one or more inputs and one output, each of which can take on two values, zero or one. Now based on the values of the input or inputs as well as the behaviour of that particular logic gate, the value of the output is decided. Now before we discuss specific properties of AND gate, let’s just consider a generic logic gate and discuss some terminology first.
Now as we’ve already said, the input or inputs as well as the output on a logic gate can take one of two values. For example, the value of the input could be zero or one. And the same is true for the output; it could be zero or one. However, sometimes we use slightly different terminology. For example, instead of saying that the input or the output is set to zero, we may say that it’s set to false. And conversely, if either one of them is set to one, then we can say that it’s set to true. In another words then, instead of zero or one, we could say that it’s set to false or true. Or, we could also say that instead of zero or one or false or true that the input or output in question is set to off or on.
In other words then, let’s say we’re talking about this input, and it’s set to zero. We could also say that it’s set to false or to off. And then let’s say that this output happens to be set to one. We could equivalently say that the output is set to true or to on. It doesn’t matter which set of terminology we use. We just need to know that they exist. It’s worth noting, by the way, that we use the off and on terminology most commonly when talking about electrical circuits. For example, if we’ve got an AND gate as part of an electrical circuit that stretches out in this direction and in this direction, and if we then think about the inputs to the AND gate which are usually represented on the left-hand side of the circuit diagram, then we might see that there is a current flowing in one of these inputs.
However, there isn’t a current flowing in the other input. Well, in that case, we could say that the top input is set to on whereas the bottom input is set to off. Equivalently, we could say that the top input is set to one and the bottom input is set to zero. Or, we could use true and false if we wanted to as well. But, anyway, so we’ve already started looking at an AND gate. So let’s consider it in a little bit more detail.
The first thing to consider is that this is the symbol that we use to represent an AND gate. It’s basically just a D shape. And so, a simple way to remember the symbol for an AND gate is to remember that the word AND ends in D. Now, another thing we can see about this AND gate is that it’s got two inputs. Now inputs are usually represented to the left-hand side of the logic gate whereas the output of the logic gate is represented to the right. And depending on what the values of these two inputs is, the output will be set to a certain value as well.
And it’s this relationship between the values of the inputs and the corresponding value of the output that allows us to distinguish between different types of logic gates. In another words, for a specific set of inputs, let’s say zero and one, the AND gate will return a specific value for the output which may not be the same as the value returned by another logic gate. Let’s say an OR gate. So to truly understand the behaviour of an AND logic gate, let’s set up something known as a truth table.
Now a truth table is just a table that will allow us to calculate what the output of an AND gate will be for any combination of inputs. And the reason it’s called a truth table is because it tells us the instances in which the output of the logic gate is going to be true. Well, actually, it gives us information about the output for any combination of inputs, as we’ve said already. So to start building a truth table, we need to set up a column for each one of the inputs and another column for the output as well. So let’s say that the first input to our logic gate we will call input A. And the second input we’ll call B. So here’s our truth table. We’ve got a column for input A, another one for input B, and a third one for the output.
So let’s start filling in this truth table by saying that our first instance involves both input A and input B being set to zero. In this case, we can say on our truth table that input A is set to zero and input B is set to zero. Well, in this situation, the behaviour of the AND gate is such that the output is also zero. And so we can put on our truth table that, for this situation, the output is zero. Now, second scenario, let’s say we keep input A as zero. But we change input B so that it’s now one. Or we could also say that it’s set to true, or it’s in the on position. And so, in our truth table, we say that input A is still zero but input B is set to one. Well, in this situation, the AND gate still returns an output of zero. And so, that’s our second row of the truth table complete.
Let’s now look at a third scenario where input A is set to one this time but input B is set to zero. Well, in that case, the AND gate still returns an output of zero. And so, in our third row of the truth table, we can say that input A is set to one, input B is set to zero, and the output, because of this, is set to zero as well. So we’ve now put down three possible combinations of the inputs in our truth table. There is one more combination that we haven’t yet considered, however. And that combination is if both input A and input B are set to one. In this situation, the AND gate returns an output of one. And so, in our truth table, we can say that input A is one, input B is one, and the output is one as well.
So at this point, we filled in all possible combinations of the two inputs in our truth table. The first possible combination is when both inputs are set to zero. The second possible combination is when input A is kept the same but input B is switched to one. The third combination is when input A is one but B is zero. And the final combination is when both are set to one. And we’ve also seen the corresponding output values in each case. And this brings us very neatly on to just why this type of logic gate is known as an AND gate. So the reason that this particular type of logic gate with this truth table is known as an AND gate is because the only time that the output is one is when both input A and input B are set to one. And we can write this down over here. In order for the output to be one, both input A and input B need to be set to one. We can see that in every other scenario, the output is set to zero. And that is why this particular type of gate is known as an AND gate.
Now in order to clarify our understanding of how AND gates work, let’s think about a very simple situation in which the AND gate’s output is connected to a lamp, say. So here’s our AND gate, the D-shaped gate, with its two inputs and one output. And the output is connected to a lamp. Now, we’ve drawn dotted lines here to represent the rest of the circuit. And that simply say that we don’t have to draw in the rest of the circuit. But anyway, so let’s start by considering that both of the inputs to the AND gate are set to zero. Or in an electrical circuit, we can say that they’re set to the off state. But for the sake of simplicity, we’ll use zero and one. So anyway, both inputs are set to zero.
Well, if we recall the truth table for an AND gate where we’ve got input A in this column, input B in this column, and the output in this column, we see that when both inputs are set to zero, then the output is set to zero as well. In other words then, the output of the AND gate is also set to zero or the off state. This means that there’s not going to be any current through the output. And hence, the lamp is not going to light up. But what if we change the second input to one or to the on state. Well, in that case, we see that input A is zero, input B is one, and the output is still zero. So, once again, there is no current for the output, and the lamp does not light up. The same will be true if we set input A to one and input B to zero because in that case we, once again, see that the output is zero. Hence, there’s no current in the output, and the lamp will not light up once again.
However, if we now set both inputs to be one, then from the truth table we can see that the output will be one as well. This means that there is a current in the output, and the lamp is going to light up. In other words then, in this circuit, the AND gate is behaving almost like a double switch. We need both of the inputs to be set to one or to the on state in order for us to be able to switch on this lamp. And that could be quite a useful safety feature, especially in situations where switching on this component, if it wasn’t a lamp, would be dangerous. And if accidentally passing a current through one of these inputs was easy. An AND gate, therefore, comes in handy because you need both inputs to be set to one in order for the lamp, or whatever this component may be, to be switched on.
Now in real life, AND gates combined with other logic gates from a very important part of the circuitry inside the computers we use nowadays, pretty cool right? So now that we’ve had a fairly detailed look at AND gates, let’s have a look at an example question.
Which of the following symbols represents an AND gate?
Okay, so in this question, we’ve been given four fairly similar-looking symbols and we need to figure out which one is representing an AND gate. Now in each one of these symbols, we can see that the gate in question has two inputs and one output. And as we know, an AND gate has two inputs and one output. But because each one of these options has two inputs and one output, we can’t use that as a determining factor. Instead, we can use a memory technique that tells us what the symbol for an AND gate should look like. We can recall that the symbol for an AND gate should look like the letter D. And this is quite easy to remember because the word AND has a D in it. So based on this information, we can go through options A to D.
Let’s start with option A. Now option A looks fairly promising. We can see that the D shape exists in the symbol. However, because there’s this little circle after the D shape, we know that this cannot be representing an AND gate. Because the little circle represents something else. It turns it into something known as a NAND gate. But anyway, so option A is not the answer to our question. Looking at option B then, we see that we’ve got almost a D shape but that the left-hand edge is curved. And so, that does not look like the letter D. And hence, this is not the answer to our question either.
Now the same is true for option C. It’s got almost this D-shape but this curve on the left side. And as well as this, it’s got the circle on the right. So it cannot be the symbol for an AND gate whereas option D gives us this D shape for the AND gate. And that’s all it is. It doesn’t have a little circle on the right or a curve on the left-hand side. And so, option D is the symbol that we’re looking for. And hence, we can say that this is the symbol which represents an AND gate. So now that we’ve answered that question, let’s take a look at another one.
The truth table shows the output of an AND gate for various combinations of inputs. What is the value of 𝑝 in the table? What is the value of 𝑞 in the table? Okay, so in this question, we’ve been given a truth table for an AND gate specifically. But instead of it being completely filled with zeros and ones, we see that in this location we’ve got the letter 𝑝. And in this location, we’ve got the letter 𝑞. Now the question is asking us to work out the values of 𝑝 and 𝑞. So to do this, we need to remember what the behaviour of an AND gate is. We can recall that the AND gate gives an output of one only if input A and input B are set to one. In other words, in any other combination of input such as zero, zero or zero, one or one, zero, the output is still going to be zero. However, if both inputs are set to one, then the output is going to be set to one as well.
So let’s start by looking at letter 𝑝. We can see that letter 𝑝 represents the output of an AND gate in the situation where input A is set to zero and input B is set to one. Well, in this case, both of the inputs aren’t set to one, only one of them is. And so the AND gate will give an output of zero. And hence, we can say that the value of 𝑝 in the table is zero. So let’s move on to looking at letter 𝑞. Now 𝑞 represents the output when input A is set to one and input B is set to one. And as we can see from the statement here, when both inputs are set to one, then the output of the AND gate will also be set to one. And hence, we can say that the value of 𝑞 in the table is one.
Okay, so now that we’ve had a look at a couple of example questions, let’s summarise what we’ve talked about in this lesson. We’ve seen, firstly, that an AND gate is a logic gate with two binary inputs and one binary output, where the word binary simply means that it could take two values. So each one of the inputs of the AND gate could take either a value of zero or the value of one. And the same is true for the output. And the fact that it can take one of two values means that it’s a binary input or output. We saw that specifically for an AND gate. If we say that the two inputs are called input A and input B, then an AND gate returns an output of one only if both input A and input B are set to one. And finally, we saw that AND gates, along with other logic gates, are commonly used in the circuitry found in computers.