Exclusive OR Gate

Bookmark added to your notes.
View Notes
×

What is XOR Gate?

XOR gate (sometimes called as EOR, EXOR, and pronounced as Exclusive OR) is a digital logic gate that results in true (either 1 or HIGH) output when the number of true inputs is an odd count. An XOR gate implements an exclusive OR, i.e., a true output result if one, and only one, of the gate inputs, is of true. If both the inputs are false (either 0 or LOW) or if both are true, there results in a false output. The XOR represents the inequality function, that is, the output is true if the inputs are not identical, and then the output is false. An easy way to remember XOR is "must have one or the other, but not both".

XOR can also be viewed as an additional modulo 2. Resultantly, XOR gates are used to implement the binary addition in computers. A half adder has an XOR gate and an AND gate. Other uses include comparators, subtractors, and controlled inverters.


Symbol of XOR Gate

There exist three schematic symbols for XOR gates. They can be given as the traditional ANSI symbol, DIN symbol, and the IEC symbol. In a few cases, the DIN symbol is used with ‘⊕’ instead of ‘≢.’

(Image to be added soon)

The logic symbols (⊕, Jpq, and ⊻) can be used to represent an XOR operation in algebraic expressions.

The C-like languages use the caret symbol (^) to represent a bitwise XOR. (It is to remember that the caret does not denote the logical conjunction (AND) in these languages, despite the similarity of the symbol).


XOR Truth Tables

There are two kinds of truth tables of XOR gate, which are with 2 inputs and 3 inputs. Let us have a look at both.


Truth Table of 2 input XOR gate

The Boolean expression representing the 2 input XOR gate is written as,

Y = (A ⨁ B) = A̅ . B + A . B̅

A

B

Y

0

0

0

0

1

1

1

0

1

1

1

0


The Truth Table for 3 Input XOR Gate

If an XOR gate were to accept three or more inputs and form a true output exactly if one of those inputs were true, then it would, in effect, be a one-hot detector (indeed, this case is only for two inputs). However, it is rarely implemented this way in practice.

The Boolean expression for the three-input XOR logic gate is represented by,

Y = A ⨁ B ⨁ C = AB̅C + A̅BC̅ + A̅BC + ABC

A

B

C

Y

0

0

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

0

0

1

1

0

1

0

1

1

0

0

1

1

1

1


XOR Gate Equivalent Circuit

(Image to be added soon)

In the figure represented above, there used three different logic gates to form an XOR, which is one of the major disadvantages. Besides, one of the easier ways to form the XOR gate is only to use the combination of the NOR gate and the NAND gate.


Construction of XOR Gate Using NAND Gate

(Image to be added soon)


Construction of XOR Gate Using NOR Gate

(Image to be added soon)


Applications of XOR Gate

There are numerous counts of various applications of the XOR gate. Let us have a look at a few of them.


Uses in Addition

This is one of the applications of XOR gate, and it can be used as a one-bit adder that adds any of the two bits together to produce one bit as output. For instance, if we add 1 plus 1 in binary, we can expect a two-bit answer, as 10 (it means 2 in decimal).

Because the trailing sum bit in this output has been achieved with the XOR gate, the preceding carry bit is calculated using an AND gate. This is the primary principle in Half Adders. A slightly larger Full Adder circuit can be chained together to add longer binary numbers.

The example of a half adder circuit diagram is shown below.

(Image to be added soon)


Pseudo-Random Number Generator

The PRN (Pseudo-Random Number) generators, specifically called Linear feedback shift registers, are described in terms of the exclusive-or operation. Thus, a suitable setup of XOR gates can model a linear feedback shift register to generate random numbers.


Correlation and Sequence Detection

The XOR gates form a 0 output when both inputs are matched. When searching for a PRN sequence or a specific bit pattern in a very long data sequence, an XOR gates series can be used to compare a string of bits from the available data sequence against the target sequence in parallel.

Then, the number of 0 outputs can be counted to determine how the data sequence matches the target sequence well. Correlators are used in various communications devices such as the CDMA receivers and decoders for channel codes and error correction. In a CDMA receiver, the correlators are used for the polarity extraction of a particular PRN sequence out of a combined collection of the PRN sequences.

An example of a full adder circuit diagram can be represented as below.

(Image to be added soon)

FAQ (Frequently Asked Questions)

1. Why is an Exclusive OR Gate Called a Controlled Inverter?

The output of the XOR gate is given by

Y = A ⊕ B = A′ B + A B′ 

If one of the XOR gate inputs is used as a control signal, suppose, consider as B,  it will produce its output either as  Y=A  or as Y=A′  depending on control B. Let us see how it is.

If  B = 0, Y = A′ B + A B′ = = A′ 0 + A 1 = A 

If  B = 1, Y = A′ B + A B′ = = A′ 1 + A 0 = A′ 

In turn, it means that, if the control input B=0 and output  Y=A  means, the output just follows the input. Whereas, when control input  B=1 and output  Y=A′  means, the output inverts its input. Therefore, the XOR gate is known as a controlled inverter.

2. What is the Difference Between an ‘OR’ Gate and an ‘Exclusive OR’ Gate?

A few common uses of OR and XOR gates can be listed as follows.

  • OR gate can only be used for summation purposes, whereas the Xor gate can use in comparison circuits and staircase switches

  • OR gate cannot be used in parity circuits, but the XOR gates can be used in parity generation/detection and Error detecting circuits as well

  • The practical application of the OR gate can be used in the Adder, Subtractor, Mux, and the other summing circuits while the XOR gate can be used only in LFSR (Linear Feedback Shift Register), comparator, CRC checks, and in other parity logic circuits

  • In the communication system, the devices for transmission of bits, the gates to be used as an XOR gate instead of OR gate