Lesson Video: Combinations of Logic Gates | Nagwa Lesson Video: Combinations of Logic Gates | Nagwa

Lesson Video: Combinations of Logic Gates Physics

In this video, we will learn how to determine the output of logic circuits that consist of combinations of different types of logic gates.

16:43

Video Transcript

In this video, we will look at how logic gates can be used as building blocks to create logic circuits. Logic gates can be mixed and matched as necessary in order to create a logic circuit that behaves in a very specific way. However, before we look at building logic circuits, let’s first consider some of the logic gates that we can use as building blocks. Let’s start by looking at the AND gate. Now, an AND gate has a symbol which looks like this. It’s a D-shape symbol. And we can use a memory trick that the word AND has the letter D in it. So a D-shape logic gate symbol will be representing an AND gate.

Now, we can see that an AND gate has two inputs, input A and input B, and one output. And just like for all logic gates, each one of these inputs and the output can take on a value of zero or one. In other words, the inputs and output are said to be binary, which means that they can take on one of two values. And then, down here, we can see the truth table for an AND gate. We can see that when input A is set to zero and input B is set to zero, then the output is set to zero as well. If we then keep input A set to zero but change input B so it’s set to one, the output is still zero. In the third scenario, if input A is one and input B is zero, then the output is zero. And finally, if both inputs are set to one, then the output of the AND gate becomes one. And so, we can remember an AND gate’s truth table by realising that the output is only one when both input A and input B are set to one. And in every other scenario, the output is set to zero. So that’s the first of our building blocks, the AND gate.

Let’s now look at a second building block. This one is a logic gate which has a similar name. This one is known as a NAND gate. And a logic gate symbol is slightly different because it’s a D-shape symbol but with a circle on the right-hand side. Now, the difference between an AND gate and a NAND gate is that a NAND gate has exactly the opposite outputs in every single scenario to that of an AND gate. So we saw for an AND gate that the outputs were zero, zero, zero, and one. Or, in other words, the output was only one when both inputs were set to one as well. But for a NAND gate, the outputs are one, one, one, zero. In other words, the output is only zero when both inputs are set to one. So that’s the second one of our logic gate building blocks.

Let’s now move on to looking at a third one. The gate that we’re now looking at is known as an OR gate. And the symbol for an OR gate is kind of similar to that of an AND gate, except that the left-hand edge is curved inwards. Now quickly, looking at the truth table for an OR gate, we can recall that the output of an OR gate is one if either input A or input B is set to one. And that’s why it’s called an OR gate because, in the top row, neither input is set to one. And so the output is zero. Whereas in the second row, input B is set to one. In the third row, input A is set to one. And in the fourth row, both are set to one. So if either one of the inputs is set to one, then the output is one as well for an OR gate.

Now, earlier we made a comparison between an AND gate and a NAND gate. And we can make a similar comparison between an OR gate and a NOR gate. So drawing the circuit symbol for a NOR gate, we see that there’s a little circle on the right-hand side of the symbol of an OR gate. And that’s what differentiates an OR gate from a NOR gate. Now looking at the truth table, we see that the output values of a NOR gate are exactly opposite that in every situation of an OR gate. Because the OR gate’s outputs were zero, one, one, one. And for a NOR gate, we have one, zero, zero, zero. And we can think about this as the output of the NOR gate is one if neither input A nor input B is set to one. So with that being said, let’s move on to looking at our next building block.

It’s a slight variant on an OR gate, called an XOR gate, which stands for exclusive OR gate. Now, the circuit symbol is quite similar to that of an OR gate, except that we have this extra curved line on the left-hand side. And an XOR gate or an exclusive OR gate has these outputs in its truth table. And it’s called an exclusive OR gate because the output is only one if either input A or input B is set to one, but not when both are set to one, because in that situation the output becomes zero. In other words, one of the outputs, either input A or input B, must exclusively be one. And the other one must be zero. And that is an XOR gate.

So now moving on to the final building block that we’ll be looking at, this kind of gate is known as a NOT gate. Now a NOT gate is slightly different. Firstly, it’s got a triangular symbol with this little circle at the end. And secondly, as we can see, it’s only got one input and one output. Now, the truth table of a NOT gate is simply that it reverses whatever the input is to give us the output. So if the input is zero, then the output is one. And if the input is one, then the output is zero. Sometimes, the NOT gate is known as an inverter because it takes the input and inverts it to give us the output. And actually, we can see here that this NOT gate is the origin of the little circle that we’ve been adding on to previous gates such as, for example, when talking about a NAND gate or a NOR gate. Because those gates had inverted outputs relative to the AND gate and OR gate, respectively. But anyway, so the NOT gate is the final one of the building blocks that we’ll be looking at.

So here are the six gates that we’ve talked about so far, summarised on the left-hand side. We’ve got the AND gate, the NAND gate, the OR gate, the NOR gate, the XOR gate, and the NOT gate. Now, all of these logic gates can be combined in different ways, in order to give us logic circuits that behave in different ways. So if we ever come across a logic circuit consisting of multiple logic gates combined together, then we need to be able to recall firstly what each kind of logic gate in the circuit is. And for that, we need to memorize the symbols of each one of these logic gates. Secondly, we should be able to recall the truth table for each one of these logic gates individually. So that we can then combine these to work out the truth table for the overall logic circuit.

For example, let’s say that we come across this logic circuit. And we want to find the truth table that represents this logic circuit. So we can start by saying that this logic circuit consists of two inputs, input A and input B. And it also has one output at the end of it. And additionally, we can see that this logic circuit consists of two logic gates. Now, if we want to build a truth table for this logic circuit, then we might start by building three columns, one for the value of input A, one for the value of input B, and one for the value of the output.

However, quite often when dealing with logic circuits, it’s very helpful to consider what’s going on in between logic gates. In other words, if we think about the output of the first logic gate, which then becomes the input of the second logic gate and call it position C. Then, whilst we’re building our truth table, it might be helpful to add an extra column for what’s happening at position C. We can then get rid of this column once we’ve finished building the truth table and just have values for input A, input B, and the output. But it is useful to have a column for C in this case during the intermediate stages whilst we’re building the truth table.

Now, the other important thing is to be able to work out what logic gates are actually present in this logic circuit. So here, we can see that the two inputs are going firstly into an OR gate. So that’s this gate here. And then we see that the output of the OR gate is going as an input into a NOT gate. So that’s this gate here. So we should be able to recognise logic gates based on their circuit symbols. So now that we’ve identified what kind of logic gates we have in our circuit, let’s start building our truth table. Firstly, we need to put in all possible combinations of values for input A and input B because these are things that we control. And so our truth table should have every possible combination of these two inputs, starting with both inputs set to zero. Then keeping input A set to zero, and moving input B to one, then setting input A to one and B to zero, and finally input A and input B set to one. Then, we work through each row, filling in the value for C and for the output.

Now, remember C is simply the output of the OR gate. And so to work out the values of C, we simply need to recall the truth table for an OR gate. Specifically, we see that when both inputs A and B are set to zero, the output of the OR gate is set to zero as well. And hence, in the first instance, when both inputs are set to zero, C is going to be zero. And in fact, C is going to have the exact same values as the outputs in each case of the OR gate because C really is the output of an OR gate, without any other modifications done to it. And so the remaining values of C are going to be one, one, and one. So now we filled in all possible values of C. Let’s now look at filling out the values of the output.

In order to do this, we need to realise that we’ve got a NOT gate over here. And C, which was the output of the OR gate, is now becoming the input of the NOT gate. Recalling the truth table for a NOT gate then, we see that every time the input to a NOT gate is zero, the output becomes one, and vice versa. And so in the very first row, the input of the NOT gate, which is C, is set to zero. Therefore, the output is going to be set to one. And in the second case, the input of the NOT gate is one. So the output is going to be zero. And the same is true for the other two remaining rows. And so at this point, we’ve completely filled in our truth table for this logic circuit. We can now choose if we wish to get rid of the column with the values of C in it. But what we’re most interested in keeping in this truth table are all the possible combinations of the inputs to the logic circuit as a whole and the resulting values of the output in each case. So when we get rid of the column for C, this is the truth table that we’re left with.

Now as a side note, we might notice that this truth table looks exactly like the truth table for a NOR gate. In other words, when the output is one when neither input A nor input B is set to one. And so what we’ve seen building this truth table is that this setup here, an OR gate followed by a NOT gate, is functionally identical to a NOR gate. And actually, that’s why the symbol for a NOR gate is the same as the symbol for an OR gate followed by this little circle, which is found on the NOT gate. But anyway, so in order to be able to build truth tables for logic circuits, we first need to be able to identify the types of logic gates found in this logic circuit. Secondly, we need to recall the truth tables for each one of these logic gates. And finally, we need to systematically build the truth table, incorporating columns for intermediate values like we did for position C, if necessary. So now that we’ve understood this, let’s take a look at an example question.

The diagram shows a logic circuit consisting of multiple logic gates. The table shows the output for some of the different possible combinations of inputs.

So here, we have a circuit diagram showing us three logic gates combined together to form a logic circuit. And here we have a table showing some possible combinations of values for inputs A, B, C, and D and the value for the output in each case.

Now, the first question asks us what is the value of 𝑝 in the table?

And so if we look in the table, we can see that it’s not fully populated with zeros and ones. In fact, for some rows, the output values have been labelled as 𝑝, 𝑞, 𝑟, and 𝑠. And the first question is asking us to find the value of 𝑝. So to do this, the first thing that we’re going to do is to identify the logic gates that we find in this logic circuit. We can see that there are three different logic gates but that two of them are identical. This logic gate has the same symbol as this logic gate. Now we can recall, based on their symbols, that these logic gates are in fact OR gates and that the other logic gate, this one here, is an AND gate. And now, once we’ve identified this, it’s worth recalling the truth tables for OR and AND gates. So here’s the truth table for an OR gate. And here’s the truth table for an AND gate. It’s worth noting that we’ve used 𝛼 and 𝛽 in both cases to represent the inputs and 𝛺 to represent the outputs of these gates. So that we avoid confusion with these inputs and this output which has already been labelled in our diagram.

Now, we can see that, for an OR gate, the output is set to one if either input 𝛼 or input 𝛽 is set to one. And for an AND gate, the output is only set to one if both input 𝛼 and input 𝛽 are set to one. Now, coming back to our logic circuit diagram, we can see that the output of the first OR gate becomes one of the inputs to the AND gate. And the same is true for the output of the second OR gate. It becomes the second input to the AND gate. And so it might be worth extending our truth table here slightly. Specifically, it might be worth calling the output of the first OR gate position E and the output of the second OR gate position F. Both E and F then go on to become the inputs to the AND gate. And it might be worth tracking what’s happening to them, at least in the intermediate stages by adding two extra columns to our truth table. We can delete these once we’ve completed the truth table. But for now, it’ll be useful to have them there.

So with that being said, if we’re trying to calculate the value of 𝑝, then this corresponds to when input A is set to zero, B is set to zero, C is set to zero, and D is set to zero. So let’s start by putting zeros next to input A, B, C, and D. Then, we can see that inputs A and B are the inputs to the first OR gate. So we can work out what the output of that OR gate is going to be. In other words, what E is going to be using the truth table for an OR gate.

We can see that when both inputs to an OR gate are set to zero, then the output is set to zero as well. And therefore, we can see that the output of the first OR gate, which is E, is going to be zero. And then, we can do the same thing for inputs C and D. These are the inputs to the second OR gate. And since both of those are set to zero, we can see that the output of the OR gate, which is F, is going to be zero as well. But then what we have going on is that E and F become the inputs to the AND gate. And since in this particular case both of them are set to zero, we can see that when both inputs to an AND gate are set to zero, the output of the AND gate is zero as well. And hence we can say that the output of the entire logic circuit itself is set to zero. But then, that output value corresponds to 𝑝. And so at this point, we figured out the answer to the first question. The value of 𝑝 in the table is zero. And so having answered this, we can move on to the next question.

What is the value of 𝑞 in the table?

Now we can see that 𝑞 is the output value that corresponds to when input A is zero, input B is zero, input C is zero, and input D is one. So let’s put the values zero, zero, zero, and one next to inputs A, B, C, and D, respectively. Then we can see that the inputs to the first OR gate are set to zero. So looking at our OR gate’s truth table, we see that when both inputs are set to zero, the output is zero as well. In other words, in this particular case, the value of E is zero. And then, we can see that inputs C and D are set to zero and one, respectively. And so we can see that when the first input is set to zero but the second input is set to one for an OR gate, the output of the OR gate is one. And so in this case, the value of F is one. And so now what we have going on is the value of E is zero. And the value of F is one. And those are becoming the inputs to the AND gate. And so when the first input to the AND gate is set to zero and the second input is set to one, the output of the AND gate is zero. And so at this point, we found the value of 𝑞 in our table. The value of 𝑞 is zero.

Moving onto the next question then, this one asks us what is the value of 𝑟 in the table?

Now, 𝑟 corresponds to when input A is zero, input B is zero, input C is one, and input D is one. And so if we set those values next to inputs A, B, C, and D, respectively, we can see that an input of two zeros leads an output of zero for an OR gate. So the value of E is zero whereas a set of two ones as the inputs to an OR gate leads to an output of one. And so the value of F is one. But then, we’ve already seen that if the first input to an AND gate is zero and the second is set to one, then the output of the AND gate is going to be zero. And so our value of 𝑟 is zero. So we found the answer to this question.

Moving on to our final question then, what is the value of 𝑠 in the table?

Now we can see that 𝑠 corresponds to an input set of zero, one, one, and zero. So writing these down next to inputs A, B, C, and D, we see that when the first input is zero and the second input is one for an OR gate, the output is one. And so we see that the value of E is one. Secondly, we can see for the lower OR gate if the first input is one and the second input is zero, then the output is one as well. So our value of F is one. And so now what’s happening is that the two inputs to the AND gate, E and F, are both set to one. And we can see that when both inputs are set to one for an AND gate, the output is one as well. Therefore, at this point, we found the value of 𝑠 in our table. So now that we’ve calculated all the values necessary, we can get rid of the columns for E and F. And we can recall that 𝑝 was zero, 𝑞 was zero, 𝑟 was zero, and 𝑠 was one.

So now that we’ve answered this question, let’s summarise what we’ve talked about in this lesson. We saw firstly that logic circuits can contain a combination of different kinds of logic gate. Most commonly, the kinds of logic gate used are AND gates, NAND gates, OR gates, NOR gates, XOR gates, and NOT gates. We need to be able to recognise these logic gates based on their symbols and recall the truth table for each type of logic gate. And finally, we saw that when we’re building a truth table for logic circuits, it is useful to consider what’s happening at intermediate stages or, in other words, between logic gates. We can even add a column for each one of these positions temporarily to our truth table whilst we’re building it. And then we can delete these columns as necessary.

Join Nagwa Classes

Attend live sessions on Nagwa Classes to boost your learning with guidance and advice from an expert teacher!

  • Interactive Sessions
  • Chat & Messaging
  • Realistic Exam Questions

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy