XOR Gate

We just encountered the OR gate, which outputs a 1 if either input (or both) is a 1.

We’re now going to build an XOR gate (eXclusive OR) . This is similar to the OR gate, but it rejects the “or both” case — it only outputs a 1 if the left input is 1, or the right input is 1, but not both.

Another way of looking at it: an XOR Gate checks if the inputs are different to each other.

building an XOR

We’re already halfway there with our existing OR gate:

00/0000/00
loading…

or gate

After the OR gate, we need a way to check for the 11 case, and change the output into a 0, which is the only way an XOR differs from an OR.

How do we distinguish the 11 case?

When we get a 11, a marble appears in the left-hand output of the turn turn. This is the only time this happens — remember, this output corresponds to an AND gate.

So we need something that can detect a marble in the left-hand output, and use that to deflect the right-hand marble.

How about a switch switch?

00/0000/00
loading…

xor gate

We have our XOR gate! Let’s review how it responds to different inputs:

  • 00 — no marbles flow in, no marbles flow out, corresponding to a 0
  • 10 — the turn moves the marble to the right. It enters the switch as a signal marble, and outputs the centre channel as a 1
  • 01 — same as above
  • 11 — the marbles move in a straight line through the turn. They enter the switch, and the checker marble blocks the signal marble from falling into the centre channel, corresponding to an output of 0

xor roon

Alternatively, we could just use the xor xor :

00/0000/00
loading…

xor roon

This behaves exactly the same as our compound , just in a smaller package.

In the next tutorial we’ll start combining our XOR gates with other elements so we can build a computer component.

continue