In this article, I will explain how to implement the XOR gate using NAND Gate. In digital electronics, the XOR gate and NAND gate are widely used types of logic gates. The XOR gate is a derived logic gate with two inputs and one output. Whereas, the NAND gate is a universal logic gate that can have two or more inputs and one output. Since the NAND gate is a universal logic gate, we can use it to realize the XOR operation.
Before going to learn the implementation of XOR gate using NAND gate, let us first get an overview of XOR and NAND gates individually.
What is XOR Gate?
The XOR gate is a derived logic gate that can have only two inputs and one output. It is also termed an Exclusive OR gate or ExOR gate.
The output of the XOR gate is considered logic 1 or high when both of the inputs are dissimilar. If both inputs to the XOR gate are the same i.e., 1 and 1 or 0 and 0, then the output of the XOR gate is considered logic 0 or low.
The operation of the XOR gate is given in the following truth table.
Inputs 
Output 

A 
B 
Y 
0 
0 
0 
0 
1 
1 
1 
0 
1 
1 
1 
0 
The relationship between the inputs and output of the XOR gate is given by its Boolean function which is given below.
$$Y=A⊕B=A\overline{B}+\overline{A}B$$
Here, A and B are the input variables and Y is the output variable.
What is NAND Gate?
The NAND gate is a universal logic gate that can have two or more inputs and one output. The output of the NAND gate is considered logic 0 or low, if and only if all its inputs are logic 1 or high. For all other input combinations, the output of the NAND gate is considered logic 1 or high.
The operation of the twoinput NAND gate is described in the truth table below.
Inputs 
Output 

A 
B 
Y 
0 
0 
1 
0 
1 
1 
1 
0 
1 
1 
1 
0 
The relationship between inputs and output of the NAND gate is given by its Boolean expression, which is given below.
$$Y=\overline{AB}$$
After getting insights about the XOR gate and NAND gate, let us now discuss how to use the NAND gates to implement the XOR gate.
Implement XOR Gate using NAND Gate
To implement the XOR gate using the NAND gate, we have to obtain the Boolean expression of the output of the XOR gate in terms of NAND logic.
We can derive the Boolean expression of the XOR gate in terms of NAND logic as follows.
The Boolean expression of the output of the XOR gate is given by,
$$Y=A⊕B=A\overline{B}+\overline{A} B$$
Using Boolean laws, we get,
$$Y=A\overline{B}+\overline{A} B+A\overline{A}+B\overline{B}$$
Since,
$$A\overline{A}=B\overline{B}=0$$
$$⇒Y=A(\overline{A}+\overline{B})+B(\overline{A}+\overline{B})$$
$$⇒Y=(A+B)(\overline{A}+\overline{B})$$
$$∵(\overline{A}+\overline{B})=\overline{A.B}$$
$$∴Y=(A+B)(\overline{AB})$$
Using distribution law, we get,
$$Y=A(\overline{AB})+B(\overline{AB})$$
Using the double complement rule, we get,
$$Y=\overline{\overline{A(\overline{AB})+B(\overline{AB})}}$$
$$∴Y=\overline{\overline{A(\overline{AB})}.\overline{B(\overline{AB})}}$$
This Boolean expression is equivalent to the XOR gate output and it can be implemented using the NAND gates only.
Circuit Diagram of XOR Gate using NAND Gate:
The circuit diagram of the XOR gate using the NAND gates is depicted in the following figure.
From the circuit diagram, it is clear that the implementation of the XOR gate using the NAND gate required four NAND gates.
Conclusion
Hence, this is how we can implement the XOR gate using the NAND gate. In this article, I have explained how we can utilize NAND gates to implement the XOR gate.
If you have any queries related to this topic. Please let me know in the comment section.