2011-06-16 11.56.16

An example of an XOR-gate.


An exclusive OR gate -short: XOR- will turn to its active state when only one of the inputs is active. Thus, when both inputs are active, the output will not be active. An optimal XOR-gate will require 1.5 ticks.

Truth TableEdit

0 0 0
0 1 1
1 0 1
1 1 0


There are a few ways it can be constructed. "If (A is 1 AND B is 0) OR (A is 0 AND B is 1)". We can easily convert that into code:


As with every circuit, we need to convert it to OR and NOT gates to have something we can build.


Another way is by using negative logic, and just inverting that, just by eliminating the cases when the output is not active. Which are AND and NAND, so the cases where the input is of are: "If (A is 1 AND B is 1) OR (A is 0 AND B is 0)". And all we do is just invert the cases we don't want, to get the cases we want. Resulting in:



Because here we have 3 stages of inversion, the delay will be equally to that. So in positive logic circuits, this design is unuseful. The design in the picture on this page is one of the easiest to build, though hard to understand. It first calculates A NOR B<code>, which will only be active when both inputs are off. We'll call that value <code>C for now. And then it will check: If (A is 0 AND C is 0) OR (B is 0 AND C is 0). Which we can rewrite as:

C = (A+B)'



Of course there are more ways of constructing this gate, but these are the most common.


An XOR-gate can be used for various purposes. A directly applied use is to use it to open a door from both sides with levers. Since the door will only open when the levers are different of each other, and difference can be caused at any input. Another use is to invert an input, depending on the other input, this can be useful for ALU's. Also it is a key-element in adders.