Silicon to Scripting 3
Invert
Looking at the NAND
truth table
A | B | Output |
---|---|---|
F | F | T |
T | F | T |
F | T | T |
T | T | F |
we can try to reduce it into the INV
truth table.
A | Output |
---|---|
F | T |
T | F |
If we look at the first and last row of the NAND
table, it looks similar to the INV
one, we just need to duplicate the input, which we can do.
And
Looking at the NAND
and AND
truth tables next to each other:
A | B | NAND | AND |
---|---|---|---|
F | F | T | F |
T | F | T | F |
F | T | T | F |
T | T | F | T |
we can see that when NAND
is true
, AND
is false
, and vice versa.
We can simply invert the output of NAND
with an INV
.
Or
Looking at the truth table for OR
, we can see that instead of the 3-1 pattern on the output, it is a 1-3 pattern.
A | B | Output |
---|---|---|
F | F | F |
F | T | T |
T | F | T |
T | T | T |
We can’t just invert the output.
instead we can invert the inputs of a NAND
to turn it into a 3-1 pattern.
Conveniently, this is the solution.
Xor
Moving onto XOR
, it looks very similar to OR
, except when both inputs are true
, it outputs false
.
A | B | Output |
---|---|---|
F | F | F |
F | T | T |
T | F | T |
T | T | F |
We can start with an OR
, and then try and find some component to AND
with the output of.
We need something that outputs false
when both inputs are on: NAND
.