# 8. The XOR logic gate¶

The XOR logic gate has two or more inputs and one output. Its symbol is the following:

The output has a logic high value (1) if the sum of the inputs is an odd value. That is, if input A **or** input B are at a high level, but not both at the same time, the output will be at a high level. Hence the name **eXclusive OR** in English.

The logical XOR function is represented by a plus symbol surrounded by a circle, so that the output of the gate will be the exclusive logical sum of the inputs:

If both inputs have a value of zero, the output will have a value of zero, if either input has a value of one, the output will have a value of one, and if both inputs have a value of one, the output will have a value of zero again.

The truth table of the XOR logic function is as follows:

## XOR Gate Applications¶

- The XOR gate can be used to calculate the parity value of all its inputs, so that the inputs next to the output will always have an even value of ones.
- Another application of the XOR gate is to do bit arithmetic additions. The XOR gate computes the arithmetic addition of two bits and the AND gate computes the carry of adding two bits.
- Another application of the XOR gate is to invert or not invert the value of input B depending on input A:
- If input A is zero, input B is copied to the output.
- If input A is worth one, input B is copied
**inverted**to the output.

## Exercises¶

Draw the symbol for the XOR logic gate, its logic function, and its truth table.

Check with the simulator that the truth table of the XOR function is correct.

In the simulator, copy the circuit that appears in the following image to emulate the operation of the XOR gate using NOT, OR and AND gates:

Check that its operation is the same as that of the XOR gate.

Draw a three-input XOR logic gate and its truth table.

To create the truth table of the gate, remember that the output is one if the input bits to one are odd.