snippetModerate
How to construct XOR gate using only 4 NAND gate?
Viewed 0 times
xorhownandusingconstructgateonly
Problem
xor gate, now I need to construct this gate using only 4 nand gatea b out
0 0 0
0 1 1
1 0 1
1 1 0the
xor = (a and not b) or (not a and b), which is\begin{split}\overline{A}{B}+{A}\overline{B}\end{split}
I know the answer but how to get the gate diagram from the formula?
EDIT
I mean intuitively, to me, I should get this one if I do it step by step followed by the definition
xor = (a and not b) or (not a and b).\begin{split}\overline{\overline{\overline{A}{B}}\cdot\overline{{A}\overline{B}}}\end{split}
and
xor will be constructed with 5 nand gates (first #1 image below)my question is more like: imagine the first person in history figure out this formula, how can he or she (the thinking process) get the 4
nand soltuion from this formula, step by step. \begin{split}\overline{A}{B}+{A}\overline{B}\end{split}
Solution
From that formula? It can be done. But it's easier to start with this one: (using a different notation here)
Ok, now what? Eventually we should derive
So make something that looks like
Pretty close now, just apply DeMorgan to turn that middle
And that's it.
a ^ b = ~(a & b) & (a | b)Ok, now what? Eventually we should derive
~(~(~(a & b) & a) & ~(~(a & b) & b)) (which looks like it has 5 NANDs, but just like the circuit diagram it has a sub-expression which is used twice).So make something that looks like
~(a & b) & a (and the same thing but with a b at the end) and hope that it'll stick around: (and distributes over or)(~(a & b) & a) | (~(a & b) & b)Pretty close now, just apply DeMorgan to turn that middle
or into an and:~(~(~(a & b) & a) & ~(~(a & b) & b))And that's it.
Code Snippets
a ^ b = ~(a & b) & (a | b)(~(a & b) & a) | (~(a & b) & b)~(~(~(a & b) & a) & ~(~(a & b) & b))Context
StackExchange Computer Science Q#43342, answer score: 19
Revisions (0)
No revisions yet.