3.1.6 · D5Boolean Algebra & Logic Gates

Question bank — XOR, NAND, NOR, XNOR gates

1,919 words9 min readBack to topic

Before the traps, the exact notation and words we lean on constantly, defined from zero so nothing is assumed:

What a "bubble" looks like on a real gate, and the four truth-table rows every two-input gate has:

Look at the left sketch: the plain AND gate (flat back, round nose) becomes a NAND the instant we glue the small circle — the bubble — onto its output. That bubble is the overbar made physical. The right sketch is the truth-table matrix: for two inputs there are exactly rows — — and every trap below refers to these four rows, so keep them in view.

Here are all five gates side by side across those four rows, so no trap forces you to rebuild a table in your head:


True or false — justify

TRUE or FALSE: NAND is just AND with a different name.
FALSE — NAND is AND with the output inverted (the bubble); its output is the exact opposite of AND on every one of the four rows, agreeing with AND nowhere.
TRUE or FALSE: NOR outputs only when every input is .
TRUE — NOR is ; OR is if any input is , so its inverse is only when nothing is .
TRUE or FALSE: XOR and OR give the same result for two inputs.
FALSE — they agree on but split at : OR (at least one), XOR (they are the same, not different).
TRUE or FALSE: XNOR is the same as "both inputs are ".
FALSE — XNOR is whenever inputs agree, which includes as well as ; requiring both to be would miss the case.
TRUE or FALSE: A single NAND gate can act as a NOT gate.
TRUE — tie both inputs together: , since by idempotence.
TRUE or FALSE: AND is universal because you can build NAND from it.
FALSE — AND alone can never produce an inverted output, so it cannot make NOT; without NOT it fails universality entirely.
TRUE or FALSE: .
FALSE — De Morgan flips the operator: . The bar over a sum becomes a product of bars.
TRUE or FALSE: XNOR is the inverse of XOR, so .
TRUE — "same" is the logical opposite of "different", so inverting the XOR output row-by-row gives exactly the XNOR table.
TRUE or FALSE: NOR is also universal, just like NAND.
TRUE — from NOR you can build NOT (tie inputs), then OR (NOR then NOT), then AND (invert inputs then NOR by De Morgan), so it makes all three basics.
TRUE or FALSE: Chaining XOR across many bits tells you the parity of the group.
TRUE — by associativity the chain is well-defined, and each additional toggles the running result, so the final bit is exactly when an odd number of s was seen.

Spot the error

Claim: " because ." Where's the error?
The person stopped before inverting — NAND includes the bubble, so , not .
Claim: "To build OR from NAND, just feed and straight into a NAND." Error?
That gives (NAND), not OR. You must first invert each input, then NAND: by De Morgan.
Claim: "XOR's SOP is ." Error?
Those are the same-input rows — that's XNOR. XOR uses the different rows: .
Claim: "NAND of is because both inputs are low." Error?
NAND outputs only when all inputs are ; with the AND is and its inverse is , so NAND.
Claim: "Since NAND is universal, a NAND gate is more physically complex than an AND gate." Error?
Backwards — a CMOS NAND is simpler (fewer transistors) than AND, which is literally a NAND followed by an inverter. Universality is about logic completeness, not part count.
Claim: "XNOR of is because at least one input is ." Error?
That is OR-style reasoning. XNOR asks whether the inputs match; disagree, so XNOR.
Claim: ", so NAND equals AND-of-inverses." Error?
De Morgan again: (a sum, i.e. OR of inverses), not a product.

Why questions

Why does XOR sit at the heart of an adder's sum bit?
Adding two bits, the sum digit is exactly when the inputs differ ( or ); that "difference detector" is precisely XOR — see Half Adder and Full Adder.
Why can inverting both inputs of a NAND produce OR but not AND?
Because by De Morgan — inverting inputs before a NAND turns the internal AND into an OR. AND instead needs a NAND followed by a NOT.
Why is a gate that can only make AND and OR (but never NOT) not universal?
Every useful family of circuits needs the ability to invert; without NOT you cannot express complements, so whole classes of functions are unreachable.
Why does XOR detect odd parity rather than even?
XOR outputs for a single (odd) mismatch and returns to after a second toggles it back; each flips the state, so an odd count ends at — the basis of Parity Bits & Error Detection.
Why do real chips flood the die with NAND (or NOR) cells instead of a mix of AND/OR/NOT?
One universal cell type can be etched identically billions of times and wired into any function, which is far cheaper to manufacture than several distinct cell designs.
Why is De Morgan the engine behind every NAND↔NOR↔basic conversion?
It is the one law that lets you move a bar across an operator, swapping AND for OR — every "build X from NAND" trick is a De Morgan rewrite from Boolean Algebra Laws.

Edge cases

If both inputs of a two-input XOR are the same, what is the output — and does this ever depend on whether they are or ?
Output is always for matching inputs, whether or ; XOR only cares that they agree, not what value they agree on.
What does NAND with a single input tied to constant compute, e.g. ?
— feeding a constant turns the NAND into a plain inverter of the other input.
What does NOR with one input held at constant always produce?
— a constant on any NOR input forces the output to regardless of the other input.
For a chained XOR over zero bits (an empty group), what is the parity result?
— because is the identity element of XOR (), combining no bits at all must return that identity, just as an empty sum is ; and zero s is an even count, so parity is even.
If you tie both inputs of an XOR gate together (), what do you get?
Always — a value is never different from itself, so XOR of any bit with itself is (a handy "clear to zero" trick).
If you tie both inputs of an XNOR gate together (), what do you get?
Always — a value always matches itself, so XNOR of a bit with itself is constant .
For inputs , which of NAND, NOR, XOR, XNOR output ?
Only XNOR outputs (inputs agree); NAND (all ones), NOR (a is present), XOR (no difference).

Connections

  • AND, OR, NOT gates — the basics every trap here reduces to
  • Boolean Algebra Laws — De Morgan settles most "spot the error" items
  • Sum of Products (SOP) — why XOR/XNOR have those exact expressions
  • Universal Gates — the universality traps in full
  • Half Adder and Full Adder — XOR as the sum bit
  • Parity Bits & Error Detection — the parity edge cases
  • Karnaugh Maps — visual home of these truth tables