Digital Electronics Fundamentals 2: Basic Logic Ports

Let’s talk a little bit of logic ports, how they can be made with discrete components, and how to use the premade one available as integrated circuits.

All of this, while learning a thing or two about Boolean Algebra, which is very useful both for designing and analyzing digital circuits.

The NOT Gate

Let’s start with the NOT gate, the simplest form of logical port.

The little circle on the right is the actual symbol for the not operator. The rest of the symbol represents just an active component, an amplifier in particular.

And, in fact, the NOT gate is made of a simple transistor polarized in such a way that it works in only two possible states: OFF, where it does not conduct any current, and ON, where it does conduct enough current to be in saturation. And to obtain this behavior, we just need a couple of resistors: one on the collector, to limit the maximum amount of current, and one on the base, to limit the current that goes through the base-emitter junction when the base is positively polarized.

Let’s now figure out how it works.

If we put a positive voltage in A, basically the +Vcc, the transistor will be ON and a current will flow between collector and emitter, limited only by the resistor on the collector. Because of that, the output U will be at about the ground level.

If we connect A to ground, instead, the transistor will be OFF, or open, and there will be no current flowing through it. As a result, U will find itself at the positive voltage +Vcc.

Remeber now that we associate the +Vcc to TRUE, or the number 1, and we associate the ground level to FALSE, or the number 0.

With such information, we can build what is called a truth table, which is a table that represents how a logic circuit works. In this case the NOT gate.

To build this table, we list all the input symbols on the left side, and all the output symbols on the right side.

In this case, we have only one input, A, and one output, U.

Then, we write on the left side of the table all the possible combinations of ones and zeros on the inputs. In this case, since there is only one input, we will have only a 0 and a 1.

Last, on the right side, we write the output values corresponding to the inputs on the same line. Again, in this case there will be only a 1 and a 0.

This table, now tells that every time the input is at 0, the output is at 1 and, viceversa, every time the input is at 1, the output is at 0.

This logic function, therefore, does just one simple thing, it generates an output that equals the inverse of the input. And, for this reason, the NOT gate is also called Inverter.

Using the boolean algebra, we can define for each basic logic function a specific symbol. For the NOT function, or inverter, the symbol is simply a dash on top of the name of the input or output.

So, using the boolean algebra notation, the NOT function is represented like this:

This notation doesn’t seem to be important, right now, but you’ll see later how important it becomes when we need to design logic circuits.

For the everyday use, NOT gates are usually available in the form of integrated circuits that contain a number of them.

This IC needs a power supply of +5V, since it belongs to the TTL family, and it contains six NOT gates.

The NAND Gate

The symbol of the NAND gate is made of two parts: the NOT gate, which is the circle at the output of the symbol, on the right, and the AND gate, which we will talk about later.

Let’s see how we can make one with discrete components, which will help us understand how it works.

In this case we have two inputs and one output.

If both inputs are at 0, both transistors will be OFF and no current will flow through them. As a result, we will have a 1 at the output.

If one of the inputs is at 1 and the other one is at 0, one transistor will be ON and the other one will be OFF. And since they are connected in series, there will still be no current flowing through them. The output will still be at 1.

But now, if both inputs are at 1, both transistors will be ON and the current will be able to flow through them. And this will bring the output level toward ground, or a logic 0.

Here is the corresponding representation with a truth table:

And here is a typical IC carrying 4 NAND ports:

The AND Gate

And now let’s see why we have talked first about the NAND gate instead of the AND. Look at how it is made with discrete components:

Yes, you can see now that although logically the NAND gate is made with an AND and a NOT gate, building such gate works exactly the opposite. With discrete components, we need the NAND gate and a NOT gate to make an AND gate!

This is because a transistor is intrinsically an inverting amplifier and, therefore, it’s natural use is the NOT gate. Whenever we try to build a port with transistors, it will come out with inverted logic, and so building a NAND is actually more straightforward than building an AND.

And now that we have seen how to build the truth table for the NAND gate, it seems natural to obtain the truth table for the AND gate just by inverting the output. And you can easily verify that following the signals on the previous circuit.

Look closely at the table now. The AND function actually resembles the well known multiplication function. In fact, the boolean AND is identical to the classic arithmetic multiplication, but in an extremely simplified way, because there are only two digits in boolean arithmetic.

Given the resemblance, we usually represent the AND operation in the same way as we do with the arithmetic multiplication:

And now that we have a boolean representation of the AND operation, we can define the representation of the NAND, just by recalling that the output is the inverse of the AND:

Another interesting thing is that building a NAND gate is easier than building an AND gate also for TTL integrated circuits. It is not by chance that the first in the list of the TTL ICs is the NAND gate itself.

Regardless, here is the pinout of a TTL IC providing 4 AND gates with 2 inputs:

The NOR Gate

Let’s now examine another kind of port. With the NAND gate, we connected the two transistors in series. Let’s see now what happens when we connect them in parallel.

So we have the first transistor with its two resistors.

Then we add another transistor, but we connect its collector directly to the one of the first transistor.

And then this second transistor has its own input.

The output is taken on the two collectors.

Let’s see how it works.

With a zero on both A and B, both transistors will be OFF, and therefore will not draw current from the resistor at the collectors. The result is that the voltage at the two ends of the resistor is the same, which means that the voltage at the collectors is +Vcc, or a logical 1.

Putting now a 0 on A and a 1 on B, the transistor on the left will be OFF, while the transistor on the right will be ON, so it will behave like a closed switch.

This transistor will then drain current from the resistor on top, causing the output to go low, which is the logic 0.

Putting a 1 on A and a 0 on B will sort a similar effect. But now the transistor ON is the one on the left, and the transistor OFF is the one on the right.

So, this time, the current will flow through the transistor on the left and the output will still be a 0.

Finally, a 1 on both inputs causes both transistors to be ON and, therefore, the output U will once again provide a 0.

The behavior presented by this circuit is called NOR function, and the device is a NOR gate which has this representation made with 3 arcs and the circle that represents the NOT.

This is instead its truth table:

And here is the pinout of a typical IC providing 4 NOR gates with two inputs each:

In boolean algebra, we represent this function as:

And yes, it looks like the inverse of the addition. But note that in boolean algebra, the value of 1+1 is still a 1. And this is something important to remember. We are talking about logic operations here, not arithmetic operations. If one thing is true and another one is also true, if we put them together we still have a true.

The numbers 0 and 1 are used for convenience, but they do not represent actual numbers, just logic states.

The OR Gate

Let’s now make the OR port.

Similarly to what we did with the AND gate, we will make first a NOR port, and then we will attach at its output a NOT gate.

And now that you are good at it, try to verify on your own that this is the truth table for the OR function:

Here is the symbol of the OR gate:

And here is an IC with 4 ports inside:

Finally, the boolean representation of the OR function:

And remember: this is a logical expression, not an arithmetic one. Therefore: 1+1 = 1.

Conclusion

So, today we have seen 5 different logic gates, or ports: The NOT, the NAND, the AND, the NOR, and the OR.

We have also seen how it is easier to build inverting gates, because of the way transistors actually work.

And we have seen that obtaining in practice non-inverting ports requires more components, so we reach the paradox where simpler logic ports have a more complex implementation.

Now that we have the basics, next time we will start looking at something more complex, obtained as a combination of 2 or more ports of the kind we have seen today.

This series of tutorials is also backed up by a corresponding video series available on YouTube. The following page provides the links to the YouTube Videos, as well as the link for the whole series, and the links to all the files involved in the tutorials, with schematics and anything else that might be needed:

%d bloggers like this: