Cs · Computer Science

What Is the Boolean Expression for a 3-Input XOR Gate?

Published By the 9to5Science editorial team

At a glance

  1. 1. Interpret XOR

    A multi-input XOR outputs 1 when an odd number of its inputs are 1.

  2. 2. Combine inputs

    Write the function as (A XOR B) XOR C; XOR is associative.

  3. 3. Expand the truth table

    Select the input combinations with odd parity and write their minterms.

  4. 4. Check an input

    For example, 1 XOR 1 XOR 1 equals 1 because there are three ones.

A 3-input XOR gate combines three binary inputs, usually named AA, BB, and CC. The key rule is parity: its output is 1 when an odd number of the inputs are 1, and 0 when the number of 1s is even.

The compact Boolean expression is A⊕B⊕CA \oplus B \oplus C. You can also write it as two cascaded XOR operations, (A⊕B)⊕C(A \oplus B) \oplus C. To express the same function using only AND, OR, and NOT, use the sum-of-products expression derived below.

The Boolean expression

XOR, or exclusive OR, of two inputs is 1 when the inputs differ. For three inputs, apply that rule twice:

Y=(A⊕B)⊕C=A⊕B⊕C.Y = (A \oplus B) \oplus C = A \oplus B \oplus C.

XOR is associative, so the parentheses do not change the result. The output is 1 for input combinations with one or three 1s. In canonical sum-of-products form, this is:

Y=A′B′C+A′BC′+AB′C′+ABC.Y = A'B'C + A'BC' + AB'C' + ABC.

Here a prime means NOT, adjacency means AND, and plus means OR. Each product term identifies one input combination that makes the output 1. For instance, A′BC′A'BC' is true when A=0A=0, B=1B=1, and C=0C=0.

Truth table

AABBCCOutput YY
0000
0011
0101
0110
1001
1010
1100
1111

The rows with output 1 contain either one 1 or three 1s. The rows with output 0 contain zero or two 1s. This is the odd-parity rule.

Deriving the sum-of-products form

A direct way to derive the expression is to list every row of the truth table where the output is 1, then write a product term for each row. Use a complemented variable for an input that is 0 and an uncomplemented variable for an input that is 1.

For example, the row A=0A=0, B=0B=0, C=1C=1 gives A′B′CA'B'C. The row A=1A=1, B=1B=1, C=1C=1 gives ABCABC. Doing this for all four output-1 rows gives:

Y=A′B′C+A′BC′+AB′C′+ABC.\begin{aligned} Y &= A'B'C + A'BC' + AB'C' + ABC. \end{aligned}

This form is useful when you need an expression built from AND, OR, and NOT gates. If XOR is an allowed operation, A⊕B⊕CA \oplus B \oplus C is shorter and usually makes the parity behavior clearer.

Worked example

Suppose the inputs are A=1A=1, B=0B=0, and C=1C=1. Evaluate the cascaded form:

Y=(1⊕0)⊕1=1⊕1=0.\begin{aligned} Y &= (1 \oplus 0) \oplus 1 \\ &= 1 \oplus 1 \\ &= 0. \end{aligned}

There are two input 1s, which is even, so the output is 0. In the sum-of-products expression, none of the four terms is true for (1,0,1)(1,0,1), giving the same result.

For the input (1,1,1)(1,1,1), the chained expression is (1⊕1)⊕1=0⊕1=1(1\oplus1)\oplus1=0\oplus1=1. The ABCABC term is also true, so the expanded expression gives 1.

Common mistakes

  • Treating the gate as “1 if any input is 1.” That describes a 3-input OR gate. XOR returns 0 for inputs such as (1,1,0)(1,1,0) because there are two 1s.
  • Including only the one-1 cases. The three rows with exactly one 1 produce three minterms, but the row (1,1,1)(1,1,1) also produces 1 and contributes ABCABC.
  • Assuming XOR means exactly one input is 1. That is a different function for three or more inputs. A multi-input XOR is 1 for any odd number of 1s, including three.
  • Changing the result by regrouping. XOR is associative, so (A⊕B)⊕C=A⊕(B⊕C)(A\oplus B)\oplus C=A\oplus(B\oplus C). It is not generally valid to replace XOR with OR or to omit an input.

A 3-input XOR can therefore be described either as an odd-parity function, as a chain of two 2-input XOR gates, or by its four sum-of-products minterms.

References

  1. Digital Design, 5th Edition — M. Morris Mano and Michael D. Ciletti

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.