Digital Electronics Fundamentals 4: Universal Gates

There are certain logic basic gates that can be used to reproduce the functionality of any other gate. To do that, these gates need to be able to do inversion in addition to their basic functionality. They are the NAND gate and the NOR gate. In this article, we will examine how that can be achieved.


Let’s start with the NAND gate.

NAND gate

If we tale a look at the truth table of such gate, we find that considering only the first and the last row of it, it behaves exactly like a NOT gate.

To make it work, we just need to put together the two inputs of the gate, and it will work as an inverter.


Given that, we can easily build an AND gate out of two NAND gates. The first gate provides the NAND function and the second provides a NOT function that converts the NAND into an AND.


At this point, before showing how to create any other gate from the NAND gate, we have to enounce the De Morgan theorem, which will allow us to manipulate the boolean expressions of the various gates to convert them into a number of NAND gates connected together.

De Morgan Theorem

The theorem states that we can convert a NAND operation into an OR operation, and we can also convert a NOR operation in to an AND operation, according to certain rules. Here is the theorem expressed in boolean algebra:

De Morgan Theorem

If you like to verify that the theorem holds true, just build the truth table for the right side of each equation and compare it with the truth table of the corresponding left side, which are respectively a NOR and a NAND truth table. The tables on the two sides should be identical.

OR from NAND

Let’s see now how we can make an OR gate using a circuit with only NAND gates.

Here is the symbol of the OR gate:

And here is its truth table:

Let’s now write down the boolean expression for the OR gate and let’s apply to it the De Morgan theorem so we can convert everything to AND and NAND.

The one on the right is the boolean expression of the OR gate expressed in terms of NAND gates, and we can convert it in to a digital circuit like this:

OR from NAND

Again, to prove that this circuit really behaves like an OR gate, we can deduct its truth table and compare it with the one of the actual OR gate. If they are identical, this circuit effectively mimics the OR gate. try yourself and, if you have difficulties, please take a look at the companion video on YouTube. The link is at the end of this post.


Like we did for the OR gate, we could determine the boolean expression of the NOR gate and find how to build the circuit that mimics it. However, since the NOR gate is essentially the same as the series of the OR gate and the NOT gate, we cna just reuse the previous circuit and add the NOT at its output, as in the following picture:

You can demonstrate the correctness of this circuit by comparing again, its truth table with the one of the NOR gate.


To convert the XOR gate in to a combination of NAND gates, we need to start from its truth table:

Now we can write down the boolean expression of the XOR gate by referencing to the lines of the truth table that have an output of one, like we have seen in the previous episode. One we have the XOR boolean expression, we can manipulate it using De Morgan to obtain a form that can be described with NAND gates only:

And, finally, we can draw the digital circuit corresponding to the rightmost part of the above boolean expression:


And this is the circuit that mimics the XOR gate using only NAND gates. And guess how we can prove that?


For the XNOR gate, we could just add a NOT at the output of the previous circuit. However, we can use one less NAND gate if we redo the whole procedure we made for the XOR gate.

Here is its truth table:

Here is the derived boolean expression appropriately manipulated:

And here is the corresponding schematic made only of NAND gates:



Let’s now talk about the other universal gate: the NOR gate.

NOR gate

Here is its truth table:

And we can see from there that connecting together the two inputs we obtain, like with the NAND gate, a NOT function.

NOT from NOR

Given those two ports, it is easy to implement the OR gate:

OR from NOR

Do you see the similarity with what we have done with the NAND gate? At this point we can easily proceed with generating all the other basic ports using a similar procedure, with the only difference that we will now use the second part of the De Morgan theorem, rather than the first.

AND from NOR

Boolean Expression
AND from NOR



XOR from NOR

Here is the XOR truth table:

Truth Table

Let’s now derive the boolean expression from this truth table. This time, however, it is more convenient to work with the zeros of the table, for which we will use OR operations, and the OR operations will be ANDed to each other and the whole expression is manipulated to obtain all NOR gates, like this:

XOR from NOR


Similarly, from the XNOR truth table we have:



I would finally like to remind you that this series of tutorials is also backed 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:



I am an old school electronics engineer, but I worked almost forever doing software development for the big telecommunication companies suppliers. I have recently decided that it was time to start digging into my old knowledge and make a hobby out of it. I have several subjects in mind that I would like to explore: robotics, electronic musical instruments, home automation, and so forth. Let’s make this journey together! We can surely learn a lot of new things from each other. Drop me a comment! I look forward to hear your thoughts!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: