There are two remaining gates of the primary electronics logic gates: XOR, which stands for Exclusive OR, and XNOR, which stands for Exclusive NOR. In an XOR gate, the output is HIGH if one, and only one, of the inputs is HIGH. If both inputs are LOW or both are LOW, the output is LOW.
Input A | Input B | Output |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Another way to explain an XOR gate is as follows: The output is HIGH if the inputs are different; if the inputs are the same, the output is LOW.
The XOR gate has a lesser-known cousin called the XNOR gate. An XNOR gate is an XOR gate whose output is inverted.
Input A | Input B | Output |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
As you can see, the only difference between these two symbols is that the XNOR has a circle on its output to indicate that the output is inverted.
One of the most common uses for XOR gates is to add two binary numbers. For this operation to work, the XOR gate must be used in combination with an AND gate.
To understand how the circuit works, review how binary addition works:
If you wanted, you could write the results of each of the preceding addition statements by using two binary digits, like this:
When results are written with two binary digits, as in this example, you can easily see how to use an XOR and an AND circuit in combination to perform binary addition.
If you consider just the first binary digit of each result, you’ll notice that it looks just like the truth table for an AND circuit and that the second digit of each result looks just like the truth table for an XOR gate.
The adder circuit has two outputs. The first is called the Sum, and the second is called the Carry. The Carry output is important when several adders are used together to add binary numbers that are longer than 1 bit.