Level 5: Strict choice
Task
Build an Exclusive OR (XOR) gate.
XOR (exclusive OR) outputs 1 when inputs DIFFER, and 0 when they match.
Solution
Formula: XOR = (A OR B) AND NOT(A AND B). Build in two parallel streams:
1. Left stream — "at least one": feed A and B into OR → OR=1 when any input is 1. 2. Right stream — "not both": feed A and B into NAND → NAND=1 always EXCEPT when both inputs are 1. 3. Feed OR output and NAND output into AND inputs.
This final AND outputs 1 only when OR says 1 (at least one 1 present) AND NAND says 1 (not two 1s simultaneously) — exactly when the bits differ!
Connect AND output to Output.