3.1.6 · D3Boolean Algebra & Logic Gates

Worked examples — XOR, NAND, NOR, XNOR gates

3,271 words15 min readBack to topic

This page is a drill ground. The parent note told you what each gate is. Here we hit every kind of question these gates can throw at you — every input combination, every degenerate case, a word problem, and an exam-style twist — and we work each one from line one.

Before we start: everything here uses only bits. A bit is either or . That's it. There are no other numbers in this whole page. When you see it means AND, means OR, an overbar means NOT (flip it), means XOR, and means XNOR. Later we sometimes write two letters side by side, — that is shorthand for the same AND, exactly like ; the dot is just dropped to save space. If any of those still feel shaky, re-read AND, OR, NOT gates first — but we re-explain each as it appears.


The scenario matrix

Every question in this topic falls into one of these cells. Our examples below are labelled with the cell they cover, and together they fill the whole table.

Cell What the case looks like Why it can trip you
C1 — all-zero input inputs NOR "fires" here; easy to forget
C2 — all-one input inputs NAND fires here; XOR vs OR differ here
C3 — mixed input inputs or XOR/XNOR flip here
C4 — degenerate: tie inputs together both inputs same wire () how NOT is born from NAND
C5 — degenerate: force one input to a constant one input pinned to or gate collapses to a simpler gate
C6 — 3+ inputs / chaining XOR of many bits parity; associativity
C7 — algebraic identity (no numbers) prove De Morgan direction
C8 — build a gate from NAND-only multi-step wiring order of operations
C9 — word problem switches / alarms translate words → gate
C10 — exam twist "which gate is this circuit?" reverse-engineer a truth table

Example 1 — All-zero input across all four gates · Cell C1


Example 2 — All-one input · Cell C2 (also the OR-vs-XOR trap)


Example 3 — Mixed input, both orders · Cell C3

Now that Examples 1–3 have filled every one of the four input rows, read them off the figure below. Each column is one gate; scan down its column and you are reading the exact numbers we just computed — the amber cells are the rows where that gate outputs . Notice the NAND column is all s except its bottom row, and the XOR and XNOR columns are perfect mirror images of each other, confirming the "opposite everywhere" sanity check.

Figure — XOR, NAND, NOR, XNOR gates

Example 4 — Tie both inputs together · Cell C4

The figure shows the NAND case wired out so you can see the single signal splitting into both input pins, then the bubble on the output producing — trace the amber wire from the split, through the box, to the output label:

Figure — XOR, NAND, NOR, XNOR gates

Example 5 — Pin one input to a constant · Cell C5

Before this example, one piece of shorthand: SOP stands for Sum Of Products. Don't let the arithmetic words fool you — here "product" just means an AND term (letters multiplied together) and "sum" means those terms ORed. So an SOP expression is a bunch of AND-groups joined by OR, like . We use it to turn a truth table into a formula (full method in Sum of Products (SOP)).


Example 6 — Chained XOR = parity · Cell C6


Example 7 — Algebraic identity, no numbers · Cell C7


Example 8 — Build XOR from NAND only · Cell C8

Trace it on the diagram: the amber input wires and both reach the shared gate N, whose output fans out (in cyan) to the top and bottom NANDs; those two branch gates then feed the single final NAND that emits . Walk the case along the wires — drops to , so both branch gates read a and go high to , and the final NAND of swings the output back to , exactly matching :

Figure — XOR, NAND, NOR, XNOR gates

Example 9 — Word problem · Cell C9


Example 10 — Exam twist: reverse-engineer the gate · Cell C10


Recall Which cell was hardest for you?

Re-do the one you forecasted wrong. The classic misses are C2 (XOR vs OR at ) and C7 (De Morgan direction).

Recall

Output of NOR only when...?
all inputs are (Cell C1).
XOR of vs OR of ?
XOR , OR (Cell C2).
Tie both NAND inputs to gives...?
, a NOT gate (Cell C4).
simplifies to...?
(Cell C5).
simplifies to...?
— a buffer (Cell C5).
Chained XOR of ?
(four s = even parity, Cell C6).
De Morgan: ?
(Cell C7).
Gate with table ?
XNOR, (Cell C10).

Connections