Level 5: Strict choice
Open the level →Where it fits in the machine →
Task
Goal: build an Exclusive OR (XOR) gate.
XOR outputs 1 when the inputs differ and 0 when they match. It means one or the other, but not both.
The main idea: XOR works as a controlled inverter: input B decides whether A passes as is or inverted. A control input like this will be needed by the multiplexer and the ALU.
Path to this level
The competencies this level develops and their formation levels.
Related Materials
- XOR (Exclusive OR) — controlled inverter
Solution for self-check
Try building the circuit yourself first. The solution below is a way to check yourself if you're stuck or have already solved it.
What you should get: 1 on the output when the inputs differ, 0 when they match.
Formula: XOR = (A OR B) AND NOT(A AND B). The first part answers is there at least one 1; the second answers are they not both 1.
- Feed A and B into OR. Its output is 1 if there is at least one 1.
- Feed A and B into NAND. Its output is 1 except when A=1 and B=1.
- Feed the OR and NAND outputs into the AND inputs.
- Connect the AND output to Output.
AND fires only when both conditions hold: there is a 1, but not two of them. That means the inputs differ.
Compare with OR: tea or coffee is XOR, you pick one. OR would pass tea and coffee at the same time.
Check yourself
Why can XOR not be replaced by a plain OR?
OR outputs 1 when both inputs are 1, while XOR outputs 0 in that case.