a, b (or just a for NOT) and the output out.
NAND
The library’s only primitive.NOT
NAND(a, a). Child: g.
AND
NOT(NAND(a, b)). Children: nand, not.
OR
NAND(NOT a, NOT b). Children: notA, notB, nand.
NOR
NOT(OR(a, b)). Children: or, not.
XOR
The classic four-NAND network. Children:n1–n4.
Changing both inputs in the same tick, for example from
0, 0 to 1, 1, makes the XOR output glitch briefly before it settles back to 0. That hazard is real gate-level behavior, and it shows up in trace().XNOR
NOT(XOR(a, b)). Children: xor, not.