# How XOR gates work

## XOR gate

Do you want to know what an XOR gate is? In the following we show you the truth table, the Boolean expression and how you can represent it using other gates.

• Combinations and circuit symbol
in the text
• Truth table and boolean expression
in the text
• in the text

### Combinations and circuit symbol

Like the NAND and NOR gates, for example, the XOR gate is a combination of the three basic logic functions AND, OR and NOT.

The XOR gate is also referred to as an exclusive-or gate and an antivalence gate. The following symbols are common for the function in German-speaking countries.

### Truth table and boolean expression

Let us now consider the associated truth table for our logic gate.

With an XOR gate, the output is only 1 if an odd number of the inputs is also 1. If the number of highs is even, the output is 0. In Boolean algebra, the function is represented as follows:  ### XOR gate from NAND

We can also represent all gates with these two functions. The circuit diagram for an equivalent circuit for the XOR gate, consisting of NAND gates, looks like this, for example:

Here, three NAND gates are combined to form an XOR gate. You can use a truth table to check whether the two gates actually match each other. As you can see, you have four inputs to begin with , , and . In the truth table, not A and not B correspond to the equivalent of A and B. So 1 becomes 0 and vice versa. Now two NAND gates follow, one with the input (not A) and B and one with the input A and (not B).

For the output of the upper NAND gate you have to first multiply the input and then reverse the result. The result is: 1011. You can also express this algebraically as follows:  Now try output set up yourself. Do you come up with the following result? The two results and now serve as input for the last NAND gate. Here you proceed in the same way as the last step. We take the inputs together and turn the output around.

If you compare the result to the truth table for an XOR gate with two inputs, you will see that the output is the same. Alternatively, you can replace the four inputs with another NAND gate.

In principle, all gates with any number of inputs can be represented by NAND gates, but this becomes more and more complex as the number of inputs increases.

You now know the XOR gate and can also represent it using NAND gates. We have also put our knowledge of truth tables into practice with an example!