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.
Table of Content
- What is XOR Gate?
- Construction of XOR Gate Using Transistor
- XOR GATE Implementation using NAND GATE
- XOR GATE Implementation using NOR GATE
- Three Input XOR GATE
- Applications of XOR Gate
- Advantages and Disadvantages
- Solved Example of XOR Gate
- Conclusion
- Frequently Asked Questions (FAQ's)
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 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 TransistorWorking 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.
XOR GATE Implementation using NAND GATE
Expression of XOR gate: A'.B + A.B'
To Convert the expression into NAND form perform the following:
Apply double complement: [(A’.B + A.B’)’]’
Operate internal complement: [ (A’.B)’ . (A.B’)’ ]’
Now, expression is obtained in NAND form.
Pass Input A through the first NAND Gate to get A’, now pass this A’ and B through the second NAND Gate to get (A’.B)’. Similarly, pass Input B through the third NAND Gate to get B’, now pass this B’ and A through the fourth NAND Gate to get (A.B’)’. Pass both the output (A’.B)’ and (A.B’)’ through the fifth NAND Gate to get our desired expression of XOR Gate ((A’.B)’.(A.B’)’)’ = A’B + AB’ (By De-Morgans Law).
Logic diagram
The Logical Diagram of the Following Expression is shown below
XOR Gate from NAND GateXOR GATE Implementation using NOR GATE
To implement XOR gate from NOR gate we follow below steps
- First, we connect both the inputs in NOR gate resulting in (A + B)’.
- Then, after we have another two NOR gates with the inputs A, (A + B)’ and B, (A + B)’ respectively with outputs [A + (A + B)’]’ and [B + (A + B)’]’.
- Again, the connect outputs of the above NOR gates to next NOR gate resulting in the output [A’B + AB’]’.
- Now, the result is generated in complement form so, we connect the result as the input for last NOR gate which gives the output [AB’ + A’B].
- The resultant of the last NOR gate gives us XOR gate.
- So, the number of NOR gates required to implement XOR gate is 5.
below is the logic diagram for implementation of XOR gate from NOR gate:
Three Input XOR GATE
The logic circuit diagram of the XOR gate is shown in the following figure. It has three input line denoted by the letter A,B,C and one output line denoted by the letter X, where X=A⊕B⊕C
The Boolean expression of N input XOR Gate is as follows:
3 Input XOR GateSay we have N inputs, A0,A1,...,AN and the output is called X, the expression is:
X=A0⊕A1⊕....⊕AN
Truth Table of Three input XOR Gate
The truth table of three input XOR gate is given below. This table shows the relationship between three inputs and one output of the XOR gate. This also provides information about the operation of XOR gate for different input combinations.
Say we have three inputs A,B and C and the output is called X, then the expression is:
X = A⊕B⊕C
Applications of XOR Gate
Here are some of the applications of the XOR Gate:
- 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.
- 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.
- Binary addition and subtraction: It helps in determining sum of each bit and also combine with other logic gates to handle borrow operations.
- 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 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.
Frequently Asked Questions on 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.
Similar Reads
XOR Gate
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 ga
9 min read
XNOR Gate
In digital electronics, the XNOR gate is a type of logic gate used to perform an exclusive NOR gate. It is a special type of logic gate used in digital circuits. An XNOR gate, also known as an equivalence gate or an EX-NOR gate, is a digital logic gate that outputs true (1) when an even number of tr
10 min read
OR Gate
OR GATE is most widely used digital logic circuit and is known as a primitive digital electronics building block in digital logic. The output state of OR gate will be high i.e.,(1) if any of the input state is high or 1, else output state will be low i.e., 0. The Boolean Expression for the OR gate i
7 min read
NOR Gate
NOR gate performs NOR(NOT OR) operation between two or more binary inputs and gives output binary signal. This is a combination of OR gate and NOT gate. It gives the output high(1) only when all of its inputs are low(0). In simple words we can say that NOR gate is the opposite (inverted) of OR Gate.
6 min read
NOT Gate
This article will explain the concept of NOT gate operation in digital electronics along with its truth table, logic symbol, switching circuit diagram, etc. The NOT gate is one of the main building blocks of Digital Logic Circuits. A NOT Gate, also called an inverter, has only one input and one outp
8 min read
NAND Gate
NAND Gate is the special type of logic gate which is also known as the Universal Gate, because it can be used to implement other basic logic gates like AND, OR, and NOT. It performs NAND(NOT AND) operation between two or more binary inputs and gives output binary signal. This is a combination of AND
6 min read
CMOS Logic Gate
The logic gates are the basic building blocks of all digital circuits and computers. These logic gates are implemented using transistors called MOSFETs. A MOSFET transistor is a voltage-controlled switch. The MOSFET acts as a switch and turns on or off depending on whether the voltage on it is eithe
4 min read
AND Gate
AND gate is used to perform logical Multiplication of binary input. The Output state of the AND gate will be high(1) if both the input are high(1) ,else the output state will be low(0) if any of the input is low(0). The Boolean Expression or logic for the AND gate is the logical multiplication of in
5 min read
Universal Logic Gates
A logic gate is an active electronic component that uses one or more inputs to produce an output based on the bolean algebra each gate is designed to perform. Though there are various types of gates including AND, OR, NOT, NAND, NOR etc.. NAND and NOR gates are a little special. NAND gate and NOR ga
7 min read
GATE CSE preparation story
GATE is the most prestigious post graduate exam for engineering students. Gate score is also taken by many PSU's (Public sector Undertakings) for recruitment and job offerings. PSU'S are government owned corporations offering jobs directly to top scorers of GATE exam. A good score in GATE can direct
3 min read