Skip Navigation

Common Gates

We can build any logical circuit by combining individual gates into more complex systems. Several types of gates are fundamental to any basic electronics circuit. These basic types are NOT, AND, OR, XOR, NAND, NOR, and XNOR. You should be able to recognize and use these gates both from their circuit diagrams and their logical expressions.

Page Contents

Video Lecture


Watch at Internet Archive

Logic Gates and Conventions

Recall that Logic Gates are composed of digital switches and other circuitry. These electronic devices take one or more inputs and perform some type of logical operation on those inputs. Each gate produces an output, which is a logical signal corresponding to the result of the logical operation performed by the gate. Input and output signals are usually implemented using positive voltage (or VCC) for 1 (on/true) and negative voltage (or GND) for 0 (off/false).

In the notation I use here, the inputs to a gate are lettered sequentially, starting with a capital A. Gates with one input use only the letter A, while those with two inputs use the letters A and B. The output of the gate is denoted by the letter Q. The symbol diagrams follow the ANSI/IEEE 91/91a-1984 and 91a-1991 standards,1 which were developed from the United States Air Force MIL-STD-806 standard.2 Note that gates with more than 2 inputs are possible; however, for our purposes in information technology, we will limit discussion to gates with 1 or 2 inputs.

NOT

NOT gate

Figure 1: A NOT gate, which is also called an inverter. The output Q is the opposite of the input A.3

A NOT gate simply inverts the logical value of its input. Thus, if the input is 0, the output of the gate will be 1. An input of 1 yields an output of zero. When this type of gate is written in a compact Boolean algebraic form, it is written either as A or ¬A, either of which reads as “not A.”

Table 1: Truth table for a NOT gate.
A Q
0 1
1 0

As shown in Table 1, the output of a NOT gate is simply the opposite value of its input.

AND

AND gate

Figure 2: An AND gate, which outputs 1 only when both its inputs are 1.3

An AND gate outputs a 0 unless both its inputs are 1. In Boolean algebraic notation, this gate is written as A·B or A∧B, and is read as “A and B.”

Table 2: Truth table for an AND gate.
A B Q
0 0 0
0 1 0
1 0 0
1 1 1

Looking at the truth table in Table 2, the quick way to remember what an AND gate does is that it outputs a 1 if and only if both its inputs are 1. In all other cases, it outputs a 0.

OR

OR gate

Figure 3: An OR gate, which outputs 1 whenever at least one input is 1.3

An OR gate outputs a 1 whenever either, or both, of its inputs are 1. In Boolean algebraic notation, an OR gate is written as A+B or A∨B, which is read as “A or B.”

Table 3: Truth table for an OR gate.
A B Q
0 0 0
0 1 1
1 0 1
1 1 1

As you can see in Table 3, an OR gate outputs a 1 most of the time. The only time it outputs a 0 is when both its inputs are 0.

XOR

XOR gate

Figure 4: An XOR gate, which outputs 1 only when one (and only one) of its inputs is 1.3

An XOR gate outputs a 1 whenever either, but not both, of its inputs is a 1. In Boolean algebraic notation, this gate is written as A⊕B or A⊻B, and it is read as “A xor B” or “A exclusive-or B.”

Table 4: Truth table for an XOR gate.
A B Q
0 0 0
0 1 1
1 0 1
1 1 0

An easy way to remember what the XOR gate does (Table 4) is that it outputs a 1 whenever its inputs are mismatched. When its inputs are the same (both 1 or both 0), the XOR gate outputs 0.

NAND

NAND gate

Figure 5: A NAND gate, which outputs a 0 only when both inputs are 1.3

The NAND gate can be created by putting a NOT gate on the output side of an AND gate, as shown in Figure 6. It is important to note that the NOT gate must be placed on the output side of the AND gate!

composition of a NAND gate

Figure 6: Composition of a NAND gate using an AND gate and a NOT gate.

The output of a NAND gate will be 1 unless both inputs are 1. In Boolean algebraic notation, the NAND gate is written as A·B or A↑B. The customary way to read this gate aloud is “A nand B.” It is technically correct to say “not (A and B),” but a listener might hear “not A and B” (¬A ∧ B) instead. To avoid this ambiguity, say “nand.”

Table 5: Truth table for a NAND gate.
A B Q
0 0 1
0 1 1
1 0 1
1 1 0

If you compare Table 5 to the AND gate in Table 2, you should see that the outputs of NAND are opposite those of AND. Therefore, one way to remember NAND is to figure out what AND does, and then do the opposite. Another way to remember NAND is that it outputs 1 unless both inputs are 1.

NOR

NOR gate

Figure 7: A NOR gate, which outputs 1 only when both its inputs are 0.3

A NOR gate can be made by putting a NOT gate on the output side of an OR gate, as shown in Figure 8.

composition of a NOR gate

Figure 8: Composition of a NOR gate using an OR gate and a NOT gate.

The output of a NOR gate is 1 only when both inputs are zero. In Boolean algebraic notation, we typically write A+B or A↓B, and we say “A nor B.”

Table 6: Truth table for a NOR gate.
A B Q
0 0 1
0 1 0
1 0 0
1 1 0

Comparing Table 6 with the OR gate in Table 3 shows that the NOR gate produces the opposite output from an OR gate. A quick way to remember what NOR does is that it only outputs 1 whenever both inputs are 0.

XNOR

XNOR gate

Figure 9: An XNOR gate, which outputs 1 only when both inputs match.3

The XNOR gate (Figure 9), which is also called the equivalence gate, can be made by wiring a NOT gate to the output of an XOR gate (Figure 10).

composition of an XNOR gate

Figure 10: Composition of an XNOR gate from an XOR gate and a NOT gate.

This gate is called XNOR instead of NXOR, since the former is much easier to say aloud. As the equivalence name implies, this gate outputs 1 only when both inputs match. In Boolean algebraic notation, A⊕B and A⊙B are used to denote XNOR. Spoken aloud, we would say “A ex-nor B”.

Table 7: Truth table for an XNOR gate.
A B Q
0 0 1
0 1 0
1 0 0
1 1 1

Comparing Table 7 with Table 4 shows the difference between XNOR and XOR. XNOR outputs 1 whenever the inputs match, while XOR outputs 1 whenever the inputs are mismatched.

Notes and References


  1. 91/91a-1984 - IEEE Standard Graphic Symbols for Logic Functions (Including and incorporating IEEE Std 91a-1991, Supplement to IEEE Standard Graphic Symbols for Logic Functions). 

  2. MIL-STD-806: Graphical Symbols for Logic Diagrams 

  3. Image Credit: Inductiveload (via Wikimedia Commons). License: Public Domain. 

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.