Cs · Computer Science

What Does a 3-Input XOR Gate Do?

Published By the 9to5Science editorial team

At a glance

  1. 1. Count the ones

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

  2. 2. Check the truth table

    The output is 1 for one or three high inputs, and 0 for zero or two.

  3. 3. Build the gate

    Connect two 2-input XOR gates in series; XOR is associative.

A 3-input XOR gate combines three binary inputs, usually named AA, BB, and CC. Its output is 1 when the inputs contain an odd number of 1s. That means the output is 1 for either exactly one high input or three high inputs.

This parity rule distinguishes XOR from ordinary OR: OR is 1 whenever at least one input is 1, while a 3-input XOR can return 0 even when inputs are high.

Truth table

AABBCCA⊕B⊕CA \oplus B \oplus C
0000
0011
0101
0110
1001
1010
1100
1111

For example, inputs (1,0,1)(1,0,1) contain two 1s, an even count, so the output is 0. Inputs (1,1,1)(1,1,1) contain three 1s, an odd count, so the output is 1.

Boolean expression

The standard compact expression is

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

Here, ⊕\oplus means exclusive OR. Since XOR is associative, the expression can be grouped either way:

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

If you need an expression using only AND, OR, and NOT, write each input combination that produces 1 as a product term, then OR those terms together. Using a prime to mean NOT, the result is

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

Each term corresponds to one row of the truth table: the first three terms represent cases with exactly one 1, and ABCABC represents the case with three 1s.

Build it from 2-input XOR gates

You do not need a special three-input component to implement the function. Use two ordinary XOR gates:

  1. Feed AA and BB into the first XOR gate.
  2. Feed its output and CC into the second XOR gate.

The resulting output is (A⊕B)⊕C(A \oplus B) \oplus C, which equals A⊕B⊕CA \oplus B \oplus C because XOR is associative.

For a concrete check, let A=1A=1, B=1B=1, and C=0C=0. The first gate gives 1⊕1=01 \oplus 1=0; the second gives 0⊕0=00 \oplus 0=0. The final output is 0, as expected for two input 1s. With A=B=C=1A=B=C=1, the first gate gives 0 and the second gives 0⊕1=10 \oplus 1=1.

Why it is called a parity gate

A 3-input XOR computes the odd-parity bit of its inputs. It reports whether the number of 1s is odd. This property is useful in parity generation and checking, where an extra bit can be selected or tested to detect certain bit errors. With an even number of inputs, the same chained-XOR rule still applies: the output is 1 exactly when the total number of 1s is odd.

Common mistakes

  • Treating XOR as OR: For inputs 1,1,01,1,0, OR gives 1, but XOR gives 0 because there are two 1s.
  • Assuming “exclusive” means exactly one input is 1: That is true for a 2-input XOR, but not for a 3-input XOR. Three 1s also produce 1.
  • Changing the grouping: Grouping does not change the result, but changing the operation does. The expression uses XOR at both stages, not OR or AND.
  • Confusing XOR with XNOR: XNOR is the complement of XOR. A 3-input XNOR is 1 when the number of input 1s is even.

References

  1. Digital Design, 6th 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.