Open In App

XOR Gate

Last Updated : 23 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The XOR or Exclusive OR Gate is a special type of logic gate used in digital electronics to perform the exclusive OR operation. The XOR gate takes two inputs and produces an output depending on the combination of the two inputs applied.

In, this article will explain the complete theory of the XOR gate along with its truth table, Boolean expression, logic symbol, circuit diagram, and more.

What is XOR Gate?

In digital electronics, there is a logic circuit called XOR Gate that takes two inputs and produces an output which is the result of the exclusive OR operation performed on the combination of inputs. This logic gate produces a high or logic 1 output when both of the inputs are dissimilar, otherwise, it produces a logic 0 output.

Operations of XOR Gate

We can explain the operation of the XOR gate as follows:

Returns 1, if the number of logical high input is odd.

Returns 0, if number of logical high input is even.

Say we have two inputs, A and B and the output is called X, then the expression is:

The Boolean expression of XOR Gate is as follows:

X = A’B + AB’

Symbol of XOR Gate

The logic symbol of XOR gate is shown in the following figure. In this figure, the variables A and B represent the input lines and A’B + AB’ is the output of the XOR gate.

XOR-Gate with truth table

XOR Gate Logic Symbol and Truth Table

Truth Table of XOR Gate

The truth table of an XOR gate is given below. This table shows the relationship between inputs and output of the XOR gate. This also provides information about the operation of XOR gate for different input combinations.

It is important to note that we do not have a single XOR gate with three or more input lines. Only two input XOR gate exists. But in case if we need an XOR gate which has more than two input lines, we simply combine multiple two-input XOR gates to obtain the desired XOR gate.

Construction of XOR Gate Using Transistor

We can implement exclusive OR gate using transistor. Here is the circuit showing the connection of different circuit elements that are combined to implement the XOR operation.

XOR Gate using NPN Transistor

XOR Gate using NPN Transistor

Working of the Circuit

We will understand this circuit with the help of different scenarios of input in case of 2 input XOR gate:

CASE I: When both the inputs are zero. (A=0, B=0)

When both the inputs A and B are zero then transistors Q1,Q2,Q4 and Q5 are open circuit so the LED will not glow because both Q4 and Q5 are open so the negative pin of LED is not connected to the ground.

CASE II: When one input if logical high and other is logical low (A=1, B=0)

In this case we can easily see that Q4 is working as close circuit now. So the negative pin of the LED is connected to Q3 via Q4 and ultimately which is connected to ground so in this case LED will glow.

CASE III – When one input if logical high and other is logical low (A=0, B=1)

In this case we can easily see that Q5 is working as close circuit now. So the negative pin of the LED is connected to Q3 via Q5 and ultimately which is connected to ground so in this case LED will glow.

CASE IV – When both the inputs are logical high. (A=1, B=1)

In this case when both A and B are logical high then transistor Q1 and Q2 are also activated then the current will directly go from +5V junction to ground through Q1 and Q2 transistors, and will not got in the path where Q3 is connected as a result transistor Q3 will now act as open circuit and ultimately negative pin of LED is disconnected from ground so the LED will not glow.

Applications of XOR Gate

Here are some of the applications of the XOR Gate:

  1. Data Encryption: XOR gates are used in data encryption algorithms. As it is used to combine data with secret key to scramble it making it very difficult for unauthorized people to crack.
  2. Comparator Circuits: It is used in comparator circuit to check if the two binary values are equal or not. As for same type of both the input it gives output 0 and for different inputs it gives output 1.
  3. Binary addition and subtraction: It helps in determining sum of each bit and also combine with other logic gates to handle borrow operations.
  4. Toggle Flip flops: In T flip flops it is used to the circuit that toggles with each clock pulse passed.

Some other uses of XOR gates are in Address decoding, Security and access control, Random number generation, clock synchronization, frequency divider circuits etc.

Advantages and Disadvantages of XOR Gate

Here are some list of Advantages and Disadvantages of XOR Gate given below :

Advantages of XOR Gate

  • It helps to detect if there are odd number of ‘1’ in the sequence of inputs.
  • XOR gates perform the exclusive OR operation, which is a fundamental operation in digital logic.

Disadvantages of XOR Gate

  • XOR gate are complex gate circuit and upon connecting it to the circuit of our use, it causes increased power consumption and circuit complexity.
  • It leads to increase in the propagation delay of the circuit.
  • Upon increasing the number of inputs the circuit becomes more and more complex making it hard to maintain and detect errors.

Solved Example of XOR Gate

Find a single number from a series of numbers given that every element appears twice except for that one single element.

Solution: We know that XOR of two same bits gives ‘0’ so here we can observe that if we XOR the elements then every elements which are occurring twice will become ‘0’ and only remaining element would be our answer.

Like out of [7,2,2,3,3,4,4,5,5,6,6]

If we XOR each of the above elements then elements occurring even number of times will give ‘0’ and elements occurring odd number of times will give the output. Ultimately we will get 7 as output as only this element is occurring once only and rest other elements are occurring even number of times.

Conclusion

In this article we have learnt about the XOR gate. XOR Gate takes Boolean values as input and returns ‘1’, if the number of logical high input is odd and returns 0, if number of logical high input is even.

This article explains the truth table, symbolic representation, solved example, and applications which helps in better understanding of the article.

XOR Gate – FAQs

Is XOR gate universal logic gate?

No XOR gate is not universal logic gate, however it can be implemented by means of universal logic gates.

Why XOR and XNOR are special gates?

XOR and XNOR gates are special because they perform exclusive operations essential for error detection, correction, and binary arithmetic, making them foundational in digital logic and computing.

What is XOR for 2 inputs?

For 2 inputs, an XOR (Exclusive OR) gate outputs 1 if and only if one of the inputs is 1 and the other is 0. If both inputs are the same, the output is 0.

What is the symbol of XOR?

The symbol for Exclusive OR(XOR) is ⊕. 

Can XOR have 4 inputs?

Yes, an XOR gate can have more than two inputs. In the case of a 4-input XOR Gate, the output is 1 if an odd number of the inputs are 1. If the number of 1’s in the inputs is even, the output will be 0.

Can XOR gates be used for addition and subtraction?

Yes, XOR gates can be used to perform binary addition and subtraction when combined with other logic gates and carry circuits. They are essential components in binary arithmetic operations.

How do XOR gates behave in terms of binary logic and truth tables?

XOR gates exhibit behavior similar to binary addition modulo 2 (bitwise exclusive OR) and are used to compare and manipulate binary data.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads