Introduction to DLD

XOR Gate Truth Table

In Logic Gates, a truth table shows all possible combinations of binary input values (0 and 1) and their corresponding binary outputs. The XOR Logic Gate is a basic digital logic gate that produces an output of 1 (HIGH) when the two inputs differ. The output becomes 0 (LOW) only when both inputs are the same (either both are 0 or 1).

The following diagram shows the very basic Boolean Expression, XOR Gate Symbol, and XOR Gate Truth Table.

XOR Gate Truth Table

XOR Gate Truth Table

Truth tables represent all possible input combinations and their corresponding outputs for a logic gate. XOR Gate truth tables for various numbers of inputs are explained below

The total possible input combinations in a truth table are calculated using 2ⁿ, where n is the number of inputs.

For example:

  • For 2 inputs, combinations will be 22 = 4
  • For 3 inputs, combinations will be 23 = 8
  • For 4 inputs, combinations will be 24 = 16
  • For 5 inputs, combinations will be 25 = 32
  • For 6 inputs, combinations will be 26 = 64
  • For 7 inputs, combinations will be 27 = 128
  • For 8 inputs, combinations will be 28 = 256

and so on…

Let’s explain various truth tables of XOR Logic gate for different numbers of inputs

XOR Gate Truth Table – 2 Inputs

For 2-input XOR Gate, there are 22=4 possible input combinations, explained below.

  • Input A Column: First 2 bits = 0, next 2 bits = 1
  • Input B Column: Alternates 0 and 1

The truth table of 2 inputs XOR Gate with its output is given below

XOR Gate Truth Table - 2 Inputs

In the above XOR gate truth table of 2 inputs

  • For A=0 and B = 0, the output (X) will be 0 because neither input is active.
  • For A=0 and B = 1, the output (X) will be 1 because the B input is active.
  • For A=1 and B = 0, the output (X) will be 1 because the A input is active.
  • For A=1 and B =1, the output (X) will be 0 because both inputs are active.

A simple rule for an XOR gate when more than 2 inputs are given

Output = 1 when an odd number of inputs are 1.
Output = 0 when an even number of inputs are 1.

For example, with 3 inputs (A, B, and C):

  • 1 or 3 inputs are 1 → Output = 1
  • 0 or 2 inputs are 1 → Output = 0

XOR Gate Truth Table – 3 Inputs

For 3-input XOR Gate, there are 23=8 possible input combinations, explained below.

  • Input A Column: First 4 bits = 0, next 4 bits = 1
  • Input B Column: First 2 bits = 0, next 2 = 1, next 2 = 0, next 2 = 1
  • Input C Column: Alternates 0 and 1

The truth table of 3 inputs XOR Gate with their output is given below

XOR Gate Truth Table - 3 Inputs

In the above XOR gate truth table of 3 inputs

  • For A = 0, B = 0, and C = 0, the output (X) will be 0 because there are zero 1s, and zero is an even number.
  • For A = 0, B = 0, and C = 1, the output (X) will be 1 because there is one 1, and one is an odd number.
  • For A = 0, B = 1, and C = 0, the output (X) will be 1 because there is one 1, and one is an odd number.
  • For A = 0, B = 1, and C = 1, the output (X) will be 0 because there are two 1s, and two is an even number.
  • For A = 1, B = 0, and C = 0, the output (X) will be 1 because there is one 1, and one is an odd number.
  • For A = 1, B = 0, and C = 1, the output (X) will be 0 because there are two 1s, and two is an even number.
  • For A = 1, B = 1, and C = 0, the output (X) will be 0 because there are two 1s, and two is an even number.
  • For A = 1, B = 1, and C = 1, the output (X) will be 1 because there are three 1s, and three is an odd number.

XOR Gate Truth Table – 4 Inputs

For 4-input XOR Gate, there are 24=16 possible input combinations, explained below.

  • Input A Column: First 8 bits = 0, next 8 bits = 1
  • Input B Column: First 4 bits = 0, next 4 = 1, next 4 = 0, next 4 = 1
  • Input C Column: 2 zeros, 2 ones, repeated
  • Input D Column: Alternates 0 and 1

The truth table of 4 inputs XOR Gate with their output is given below

XOR Gate Truth Table - 4 Inputs

For a 4-input XOR gate, the output is 1 when an odd number of inputs are 1. The output is 0 when an even number of inputs are 1.

  • For A = 0, B = 0, C = 0, and D = 0, the output (X) will be 0 because there are zero 1s, which is even.
  • For A = 0, B = 0, C = 0, and D = 1, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 0, C = 1, and D = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 0, C = 1, and D = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 1, C = 0, and D = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 1, C = 0, and D = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 1, C = 1, and D = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 1, C = 1, and D = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 0, C = 0, and D = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 1, B = 0, C = 0, and D = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 0, C = 1, and D = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 0, C = 1, and D = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 1, C = 0, and D = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 1, C = 0, and D = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 1, C = 1, and D = 0, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 1, C = 1, and D = 1, the output (X) will be 0 because there are four 1s, which is even.

XOR Gate Truth Table – 5 Inputs

For 5-input XOR Gate, there are 25=32 possible input combinations, explained below.

  • Input A Column: First 16 bits = 0, next 16 bits = 1
  • Input B Column: First 8 bits = 0, next 8 = 1, next 8 = 0, next 8 = 1
  • Input C Column: 4 zeros, 4 ones, repeated
  • Input D Column: 2 zeros, 2 ones, repeated
  • Input E Column: Alternates 0 and 1

XOR Gate Truth Table - 5 Inputs

For a 5-input XOR gate, the output is 1 when an odd number of inputs are 1 and 0 when an even number of inputs are 1. The truth table of 5 inputs XOR Gate with its output is given below

  • For A = 0, B = 0, C = 0, D = 0, and E = 0, the output (X) will be 0 because there are zero 1s, which is even.
  • For A = 0, B = 0, C = 0, D = 0, and E = 1, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 0, C = 0, D = 1, and E = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 0, C = 0, D = 1, and E = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 0, C = 1, D = 0, and E = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 0, C = 1, D = 0, and E = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 0, C = 1, D = 1, and E = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 0, C = 1, D = 1, and E = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 0, B = 1, C = 0, D = 0, and E = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 0, B = 1, C = 0, D = 0, and E = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 1, C = 0, D = 1, and E = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 1, C = 0, D = 1, and E = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 0, B = 1, C = 1, D = 0, and E = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 0, B = 1, C = 1, D = 0, and E = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 0, B = 1, C = 1, D = 1, and E = 0, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 0, B = 1, C = 1, D = 1, and E = 1, the output (X) will be 0 because there are four 1s, which is even.
  • For A = 1, B = 0, C = 0, D = 0, and E = 0, the output (X) will be 1 because there is one 1, which is odd.
  • For A = 1, B = 0, C = 0, D = 0, and E = 1, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 0, C = 0, D = 1, and E = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 0, C = 0, D = 1, and E = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 0, C = 1, D = 0, and E = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 0, C = 1, D = 0, and E = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 0, C = 1, D = 1, and E = 0, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 0, C = 1, D = 1, and E = 1, the output (X) will be 0 because there are four 1s, which is even.
  • For A = 1, B = 1, C = 0, D = 0, and E = 0, the output (X) will be 0 because there are two 1s, which is even.
  • For A = 1, B = 1, C = 0, D = 0, and E = 1, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 1, C = 0, D = 1, and E = 0, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 1, C = 0, D = 1, and E = 1, the output (X) will be 0 because there are four 1s, which is even.
  • For A = 1, B = 1, C = 1, D = 0, and E = 0, the output (X) will be 1 because there are three 1s, which is odd.
  • For A = 1, B = 1, C = 1, D = 0, and E = 1, the output (X) will be 0 because there are four 1s, which is even.
  • For A = 1, B = 1, C = 1, D = 1, and E = 0, the output (X) will be 0 because there are four 1s, which is even.
  • For A = 1, B = 1, C = 1, D = 1, and E = 1, the output (X) will be 1 because there are five 1s, which is odd.