Contents > Logic Gates
NAND is a two-input gate that outputs the complement of the conjunction of its inputs. That is, the output is 0 only when both inputs are 1.
It is a universal gate. Meaning, NAND gates alone can be combined to form any other gate.
The code below realizes NAND as inverters feeding into an OR. It is based on one of De Morgan's laws, AB = A + B.
nand.t notLeft -2 0 notRight 1 0 ih 0 in a -3..-1 0 in b 0..2 0 out o -2..1 6
The follow image reveals the output for all possible inputs.
The horizontal I-tetromino functions as an OR gate.
© 2023 meatfighter.com