 The purpose of this video is to explain the concept of logic gates in the context of digital circuits. Now, let's start first by saying that these logic gates are connected with the concept of Boolean algebra. In a Boolean algebra, there is typically two symbols, which are true and false. And in the context of logic gates, true will be represented as the number one, or also if we get it closer to the circuit level, it will be a high voltage, and false will be represented as a zero, or a low voltage. And then in the context of Boolean algebra as well, we have three basic operations, which are the conjunction, the disjunction, and the negation. So the logic gates that we're going to study here, first they correspond with these basic operations in the Boolean algebra, and then we're going to derive some additional gates. So the first one we introduce is the AND gate. AND gate is the one that corresponds with the conjunction. So we can express in the context of this Boolean algebra the operation that is implemented by just saying x, y, or x times y. The symbol for this logic gate is the following two inputs, x and y, this symbol, and the output. Now what we are assuming, not only for this gate, but for all the gates that we're going to describe next, is that there is some sort of direction between the inputs towards the output. So once the inputs are set to certain value, almost instantaneously the output will follow certain rule, which in the case of the AND gate is that the output is 1 if all inputs are 1. And what we're not going to say, but it's implicitly otherwise the output is 0. So let's review again the definition of this gate. Again, it corresponds with the operation conjunction in the Boolean algebra. In Boolean algebra, we represent this operation with x times y, either like this or like that. We remove the operator and we just put symbols 1 next to each other. The symbol represented this gate is the one over here. And whenever these two signals or all of the inputs of this gate are equal to 1, then almost immediately the output will also be 1. So this is what defines the behavior of the AND gate. Let's look some other additional logic gates. The next one I want to talk about is the OR gate. And it's interesting because it corresponds with the operation of the disjunction in our Boolean algebra. And if we follow the same derivation process as we did for the AND gate, the Boolean operation that is implemented is represented like this, x plus y in terms of algebraic expression. But the symbol we typically use when we draw the circuits is this one. Again, two inputs and the output, x and y. And the rule that tells us the behavior of this gate is that the output is 1 if any input is 1, 0 otherwise. So as you can see, the difference between these two gates is that in order for this gate to produce a 1 in the output, both the inputs, actually all the inputs have to agree on value 1. Whereas for this one, for the OR gate or for the disjunction, it is enough for one of these inputs, any of them, to be 1, and the output then will almost immediately become 1. The third operation, which is trivial, is the negation. OR the gate is called NOT. The operation is negation. The Boolean expression that is implemented in this gate is simply x prime, the negation of x, and the symbol is very simple. It's just something like this. And the rule is equally trivial. Output is opposite value than input. So again, you can imagine this gate as sensing what kind of value is in here and the output will have exactly the opposite. So x equals 0 will produce an out equal 1, x equal 1, out equal 0. So these are three basic logic gates, but when we implement circuits, there are actually quite a lot of additional ones that are used. One of them is called NAN, and is somewhat related to the N or conjunction we have seen here. In fact, we call this NOT N, or an N that has been negated. Actually, this N over here is the reason to use the NOT N. What is the Boolean expression? Well, it's just an N, a conjunction with a negation. Therefore, the Boolean expression is this one. And the symbol, here we could use a symbol, which is a combination of these two, because what we are saying is that we have an N that then negate the output. So it could be something like this with an inverter connected to the output. So this would be x, y and out. However, typically what happens, rather than using these two circuits next to each other, we collapse them in one single symbol, and this gate is typically represented like this. x, y and out. And as you can see, as if this inverter has collapsed into this shape, we preserve the shape, and we maintain just the circle of the inverter. What is the rule governing this gate? Well, we can deduce that knowing what the N does and what the NOT does. And looking at this symbol, it's fairly clear. In this case, the output is zero if all inputs are one and one otherwise. Why do we deduce this rule? Because this output is telling us that when all the inputs are one, this output produces a one. But in here, this inverter switches that to a zero, so the new rule is that the output will be zero when all the inputs are equal to one. So this over here describes the behavior of the NAND gate. Let's take a look at three additional gates here. The next one is called the NOR gate. And it's also very easy to deduct by combining an OR and a NOT. So we could call this gate a NOT OR gate. And similarly to what we described here in the case of the NAND gate, this will implement the operation OR x plus y with a negation. So it's x plus one prime. And again, we're going to play the same trick we did here. And rather than represented this gate by an OR followed by an inverter, we're going to collapse the inverter. And the resulting symbol that we're going to be using in our circuits is this one with a circle at the end for the output. And the rule for this gate can also be very easily deducted. That used from the behavior of the OR and the NOT. Namely, the output is zero if any input is one. One. Otherwise. So again, as in the case of the NAND gate, we have derived the NOR gate by simply assuming that we take an OR gate and we negate the output and the OR gate follows the rules described here and the inverter, the rules of the negation. So let's now describe two additional gates that are very useful when designing digital circuits. The first one is called xOR, as an abbreviation for exclusive OR. And it's represented in Boolean expressions as a plus surrounded by a circle. And the symbol is similar to the OR but with an additional line next to the input. So this is x, y and the output. Now this is a logic gate that has a very interesting rule. The rule to compute the output of this gate is the following. The output is going to be one if the number of ones in inputs is odd. It's an odd number. Now for this gate it's kind of trivial because since we only have two inputs, the only possibility is to have either none of them to one, which would be zero number of ones, one of them to one or both of them to one. So we can see that this output, this gate is going to produce a one when we have the one zero combination or zero one combination at the input. For the other two remaining combinations, zero zero and one one, since both combinations they have an even number of ones, one has zero ones, the other one has two ones, then this output will produce a zero. And the same trick we applied to derive the none gate from the AND gate and the NOR gate from the OR gate, we can apply to derive the XNOR gate or the NOT exclusive OR. The expression is very simple, it's the same one than before, but with an negation. And the symbol, we apply exactly the same technique we applied here and we just modify our little symbol, same as before, but now with a circle at the end. So this is X, this is Y and this is the output. And the rule in this case, we need to negate this, so a different way of saying that is the output is one if the number of ones in inputs is even. So in this case the XNOR gate for the two input combination we see here will produce a one when we have the combination 00 and 11, which are the ones that have an even number of ones. So these are some of the basic blocks that we're going to use similar to LEGO pieces and combine them to create more sophisticated circuits. Let's create a circuit as an example. Let's assume we have a three input circuit, X, Y and Z, and let's assume we connect them following this scheme. We'll do something like this. We put an AND gate here. Y and Z will feed another NAND gate. Then this output will feed an AND gate and Y will also feed this gate like this. The output of this gate is going to enter an XOR together with the value we obtained by negating this Y over here. And then we take this output and this one we connected over here like this. This output we negated as well and we bring it finally to an OR gate. So here you have an example in which we have used and combined one, two, three, four, five, six, seven, eight gates. And this circuit has three inputs. So what is the functionality of this circuit? Well, we have all the information we need here to anticipate what would be the behavior of this circuit if we apply certain values to X, Y and Z. Let's set it an example. For example, X will be zero, Y will be one, and Z will be zero. Now the only thing we need to do is apply the rules we've seen here and remember that the direction of the signals is always going towards the right. So this is very simple. This is an inverter and it's directly connected to X. We assume that X is equal to zero. Therefore here in this wire we have a one. This gate over here is an AND gate, this type, and it has a one-zero combination. Now the rule is that the output is going to be zero if all the inputs are one. In this case, not all the inputs are one. Therefore the output is not going to be zero. It's going to be one, which means there will be a one in this wire. This Y is connected also to the input of this gate, so there will be another one here. Now look, this AND gate has both inputs to one. When both inputs, all inputs are one, this output produces a one. Therefore this Y over here is going to have a one. At the same time, this one in this wire will go through this inverter and produce a zero. Now this one over here will also propagate through this wire and produce a one at the input of this gate. Now this is an AND gate. We go here to the rules and says that it will produce a zero if all the inputs are one, which is precisely the case. Therefore the output of this gate will be a zero, which itself is the input of this inverter. So this will produce a one here. This gate over here that remains to be evaluated, it's an XOR gate, and we have a one and a zero. We have an odd number of ones here. Therefore this is the case where the output is going to be one because the number of ones in its input is just an odd number. So we'll produce a one here, and the final result of this circuit is a one. So here we can see first how the logic gates are defined with their rules, how they can be connected, and with this connection we have something similar to a Boolean expression because as we can see, and this is the connection between logic gates and the Boolean algebra, we'll have here a function that receives three possible symbols, each one taking values zero or one and produces an output. And of course, in order to derive the truth table from this circuit, we can try all possible combinations in X, Y, and Z from zero, zero, zero to one, one, one. We apply these rules the same way we did here. We applied for the zero, one, zero combination, but we can obtain the rest of the values and very easily derive the truth table from the circuit that is made out of logic gates.