Log in Sign up
Back to Discover
💻

XOR gate

technology Maturity 11-13

Computers use tiny parts to think.

XOR ANSI.svg
XOR ANSI.svg
One part is a special switch. It works when things are not the same. It helps computers do math.
DOV-1X - Philips HEF4070BP on printed circuit board-9802.jpg
DOV-1X - Philips HEF4070BP on printed circuit board-9802.jpg
It is very smart! Do you like math?

43 words

Computers use tiny parts to think.

XOR ANSI.svg
XOR ANSI.svg
One part is a special switch. It works when things are not the same.

If the two inputs are different, the switch turns on. If they are the same, it stays off.

DOV-1X - Philips HEF4070BP on printed circuit board-9802.jpg
DOV-1X - Philips HEF4070BP on printed circuit board-9802.jpg

This switch helps computers do math. It can add small bits together.

It can also help make random numbers. This is useful for many machines.

These tiny switches are very important. They help computers work every day.

85 words

Computers use tiny parts to make decisions. One important part is the XOR gate.

XOR ANSI.svg
XOR ANSI.svg
The name stands for "exclusive OR." This gate looks at two inputs. It gives a "true" output only if the inputs are different.
XOR IEC.svg
XOR IEC.svg
If both inputs are the same, the output is "false." For example, if one input is true and the other is false, the gate turns on. But if both are true, the gate stays off.

This gate helps computers do many jobs. It is used in a part called a half adder.

Half Adder.svg
Half Adder.svg
A half adder uses an XOR gate to add bits together. This helps the computer do math. XOR gates also help make random numbers. They can also be used to find patterns in data.

Engineers build these gates in many ways. Some use a method called CMOS.

CmosXORGate.png
CmosXORGate.png
Others use transmission gates to make the gate smaller. You can even build an XOR gate using other gates, like NAND gates. These parts are found on many computer chips.

173 words

The XOR gate is a very important part of digital logic.

XOR ANSI.svg
XOR ANSI.svg
Its name stands for "exclusive OR." You might also see it called EOR or EXOR. This gate helps computers make decisions by looking at inputs. It provides a "true" output, which is also called a HIGH signal or a 1. This only happens when the number of true inputs is odd.
XOR IEC.svg
XOR IEC.svg
If you have two inputs, the output is true only if one input is true. If both inputs are false, the output is false. If both inputs are true, the output is also false. You can think of it as a rule that says "one or the other, but not both."

This gate works by checking if inputs are different.

XOR DIN.svg
XOR DIN.svg
If the inputs are not alike, the output is true. This is why it is sometimes called an inequality function. You can also use an XOR gate as a programmable inverter. An inverter is a part that flips a signal from true to false. In this setup, one input acts like a switch. It decides whether to flip the other input or just let it pass through. This makes the XOR gate very flexible for different electronic tasks.

Engineers use many different ways to build these gates.

CmosXORGate.png
CmosXORGate.png
One common way is using CMOS, which stands for metal–oxide–semiconductor. This method uses transistors to connect power to the output. Another way uses transmission gates to make the gate smaller. A version using transmission gates only needs eight transistors. This is four fewer than the CMOS version. Some designs are even more optimized to use only six transistors. Engineers must be careful when connecting many gates together. This is because some parts can cause the signal to get weaker.

There are many ways to create an XOR gate if you do not have one.

XOR from NAND.svg
XOR from NAND.svg
You can build one using only NAND gates. NAND gates are called "universal gates" because they can build any other kind of gate. You can also build an XOR gate using only NOR gates. Another way is to use a mix of AND, OR, and NOT gates. Using a mix of different gates can sometimes take up more space. For example, one method uses five different gates. However, using only NAND gates might be simpler for some circuits.

We see XOR gates working in many places every day.

Half Adder.svg
Half Adder.svg
They are used in a part called a half adder. This part helps computers perform binary addition by adding bits together. XOR gates also help create pseudo-random numbers. This is done using a setup called a linear-feedback shift register. They are also great at finding patterns in long strings of data. In communications, they help extract specific signals from a crowded group of signals. You can even find them on standard chips, like the 7486 or the 4070.
DOV-1X - Philips HEF4070BP on printed circuit board-9802.jpg
DOV-1X - Philips HEF4070BP on printed circuit board-9802.jpg

489 words

An XOR gate is a fundamental component of digital logic used in electronic circuits.

XOR ANSI.svg
XOR ANSI.svg
The name stands for "exclusive OR," though it is also known as EOR or EXOR. This gate is essential because it performs a specific logical operation based on its inputs. It produces a true output, also called a HIGH signal or a 1, only when the number of true inputs is odd.
XOR IEC.svg
XOR IEC.svg
For a standard gate with two inputs, this means the output is true if one, and only one, input is true. If both inputs are false, or if both inputs are true, the output remains false. This makes the XOR gate an inequality function, as it only yields a true result when the inputs are not alike.

Beyond simple logic, the XOR gate can act as a programmable inverter. In this role, one input acts as a control switch for the other. If the control input is set a certain way, the gate will invert the signal, acting like a NOT gate. If the control input is set differently, the gate simply passes the signal through without any change. This flexibility allows engineers to use XOR gates to flip or buffer signals as needed. Mathematically, the operation can also be viewed as addition modulo 2, which is a key concept in digital arithmetic.

Engineers use several different methods to implement XOR gates in physical hardware.

CmosXORGate.png
CmosXORGate.png
One common method is using CMOS, or metal–oxide–semiconductor technology. In a CMOS implementation, nMOS and pMOS transistors are arranged to connect the output to either the supply voltage (Vdd) for a HIGH signal or to the ground (Vss) for a LOW signal. If the circuit does not already have inverted inputs available, it may require two additional inverters, bringing the total to twelve transistors. This specific AOI (AND-OR-invert) logic style was used, for example, in the Intel 386 CPU.

Another implementation method uses transmission gates with pass transistor logic.

XOR gate implemented with pass gates.svg
XOR gate implemented with pass gates.svg
This design is often more efficient, using only eight transistors, which is four fewer than the standard CMOS design. In this setup, the gate passes the inverted value of input A when input B is high. When B is low, the gate passes the original value of A. While this saves space, there is a trade-off. Transmission gates are not ideal switches and have some resistance. If many gates are connected in a row, known as cascading, the signal strength might degrade.

Advanced designs can optimize this even further to use only six transistors.

XOR from NAND.svg
XOR from NAND.svg
This optimized version uses a specific arrangement of transistors to perform conditional inversion with fewer components. If a specific XOR gate is not available in a circuit, it can be built using other types of gates. NAND and NOR gates are known as "universal gates" because they can be used to construct any other logic function. For instance, an XOR gate can be built using only four NAND gates or a specific arrangement of NOR gates. Using a mix of AND, OR, and NOT gates is possible, but it can require up to five gates to achieve the same result.

In the world of computing, XOR gates are vital for performing binary addition.

Half Adder.svg
Half Adder.svg
They are a primary part of a half adder, which combines an XOR gate with an AND gate. In binary addition, the XOR gate produces the sum bit, while the AND gate produces the carry bit. By chaining these circuits together into full adders, computers can add much larger numbers. XOR gates are also used in subtractors and comparators, making them essential for almost all mathematical processing in a CPU.

These gates also play a role in more complex digital systems like pseudo-random number generators.

LFSR-G16.svg
LFSR-G16.svg
Specifically, they are used in linear-feedback shift registers (LFSR) to create sequences of numbers that appear random. Additionally, XOR gates are used in communication devices as correlators. They can compare a long string of data against a target pattern to see how well they match. In a CDMA receiver, for example, they help extract specific signals from a collection of many different signals. From simple math to complex communication, the XOR gate is a building block of the modern digital age.

710 words
🖼️ Images & Media (16)
File:XOR ANSI.svg
XOR ANSI.svg
File:XOR IEC.svg
XOR IEC.svg
File:XOR DIN.svg
XOR DIN.svg
File:XOR gate implemented with pass gates.svg
XOR gate implemented with pass gates.svg
File:CmosXORGate.png
CmosXORGate.png
File:ANDNOR XOR Gate implementation.png
ANDNOR XOR Gate implementation.png
File:254px 3gate XOR.svg
254px 3gate XOR.svg
File:XOR ANSI Labelled.svg
XOR ANSI Labelled.svg
File:XOR from NAND.svg
XOR from NAND.svg
File:XOR from NOR 2.svg
XOR from NOR 2.svg
File:XOR from NAND 2.svg
XOR from NAND 2.svg
File:XOR from NOR.svg
XOR from NOR.svg

+ 4 more

Up Next
💻
XNOR gate
Technology
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.