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.
Video Lecture
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
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.”
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
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.”
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
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.”
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
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.”
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
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!
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.”
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
A NOR gate can be made by putting a NOT gate on the output side of an OR gate, as shown in Figure 8.
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.”
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
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).
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”.
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.