Menu
Fundamental Digital Logic Gates

In this article I explain the fundamental concept of digital logic in simple and clear language so that anyone can understand it Lets look at a simple electric circuit with a battery, a light bulb, and a switch. This circuit is shown below.

Simple electric circuit 1

With the switch open, the light bulb does not illuminate.

Simple electric circuit 2

With the switch closed, the light bulb illuminates.

Lets designate the situation where the light is off as "0". Lets designate the situation were the light is illuminated as "1". What we have is a system with two possible situations, referred to as a "binary" system.

It doesn't matter what voltage the battery is, as long as its high enough to illuminate the light. Light off is binary 0. Light on is binary 1.

Lets make a slightly more complex circuit.

Simple electric circuit 3

In the circuit shown above, switch A is open, but the light is still illuminated. That's because switch B is closed, providing a path from the battery to the light.

The idea behind this circuit is - if switch A OR switch B is closed, the light is illuminated. If both switched are open, the light will not be illuminated. Of course if both switched are closed the light will be illuminated.

This circuit functions as what we call a logical OR gate.

Simple electric circuit 4

In the circuit shown above, switch A is closed, but the light is not illuminated. This is because switch B is open, breaking the path to the battery. If switch B were to be closed, the light would be illuminated because then there would be a closed path from the battery to the light.

If either switch is open, the light will not be illuminated. Both switch A AND switch B must be closed for the light to be illuminated.

This circuit functions as a logical AND gate.

These circuits demonstrate the fundamental concept of logic circuits.

Let's substitute the symbol shown below for the logical OR gate function.

Symbol for OR gate

If voltage is applied (a logical 1) to either A OR B (or both), voltage (a logical 1) will appear at the output. If neither input is 1, the output will be 0. The following table describes the logical OR function.

ABOut
000
011
101
111

This table is called a "truth table". It is the truth table for a 2-input OR gate.

Let's substitute the symbol shown below for the logical AND gate function.

Symbol for AND gate

If a logical 1 is applied only to input A, or only to input B, the output will be 0. Both inputs must be 1 for the output to be 1. The following table describes the logical AND function.

ABOut
000
010
100
111

This is the truth table for a 2-input AND gate.

Let's introduce a very simple gate shown below.

Symbol for NOT gate

The output of this gate is always the binary opposite of the input. For example if A is 0, the output is 1. If A is 1, the output is 0. This describes the logical NOT function. many people just call it an "inverter". The following table describes the logical NOT function.

AOut
01
10

Let's introduce one more gate before we move on to bigger things.

Symbol for XOR gate

This is an "exclusive or gate" - XOR. The output of the XOR gate is 1 only if input A or input B are 1. If input A and input B are both 0, or if input A and input B are both 1, The output of the XOR gate is 0. The following table describes the logical XOR function.

ABOut
000
011
101
110

A gate is not restricted to only 2 inputs. Shown below is a 3 input AND gate.

3 input AND gate

This is the truth table for a 3-input AND gate:

ABCOut
0000
0010
0100
0110
1000
1010
1100
1111

Shown below is a 3 input XOR gate.

3 input XOR gate

This is the truth table for a 3-input XOR gate:

ABCOut
0000
0011
0101
0110
1001
1010
1100
1110

Be careful with the last line in this truth table. Many people have been cascading XOR gates to create the odd-parity checking function. They think the output of the last line should 1. XOR is logic gate, not an odd-parity checking gate. Apparently they don't understand the meaning of the word "exclusive". IEEE-Std91a-1991 gives the symbol for the exclusive-OR on p. 62 with the definition "The output stands at its 1 state if one and only one of the two inputs stands at its 1 state."

Shown below is a 2-input AND gate whose output is used as the input to a NOT gate. This creates the NAND function.

NAND function

We don't actually need to construct such a circuit because this function is performed by a a NAND gate, the symbol of which is shown below.

NAND gate

This is the truth table for a 2-input NAND gate:

ABOut
001
011
101
110

As you can see the output of the NAND gate is the opposite of the AND gate. Why would they bother to put such a function as a fundamental gate? Actually combinations of NAND gates can be used to create any of the other basic logic functions. This makes the NAND gate one of the most useful logic gates.

Shown below is a 2-input OR gate whose output is used as the input to a NOT gate. This creates the NOR function.

NOR function

We don't actually need to construct such a circuit because this function is performed by a NOR gate, the symbol of which is shown below.

NOR gate

ABOut
001
010
100
110

As you can see the output of the NOR gate is the opposite of the OR gate.

Shown below is an example of what those designers who have been cascading XOR gates to create the odd-parity checking function are doing.

Cascading XOR gates

ABCYOut
00000
00101
01011
01110
10011
10110
11000
11101

To construct this logic table, you would first enter the values of Y based on A XORed with B. Then you would enter the Output values based on C XORed with Y. Note how that last output disagrees with the same out from the XOR logic table.

That concludes my explanation of fundamental digital logic gates. If you understood most of what is in this section, you are well on your way to becoming a digital logic designer. But in order to do that, you will want to get a working knowledge of Boolean Algebra, a mathematical technique to design complex logic circuits developed by English mathematician George Boole (1815 - 1864).

More Computer Architecture Articles:
• Multilevel Queue CPU Scheduling Algorithm
• The AMD Athlon 64 X2 Processor
• Multicore Programming
• Dynamic Loading of Program Routines and Dynamically linked libraries (DLLs)
• AMD's Microarchitectures
• Pi-Top kit - Build Your Own Laptop
• Inductors in DC Circuits
• Using The I2C Bus
• The Microcontroller Memory Map
• Intel's Dual-Core Core i3 Processor