# Converting an expression to only use NAND gates

#### Ben Scanlon

Joined Nov 28, 2015
4
Really stuck. I've tried de Morgan's law but I'm confused as to when converting the whole expression, the 'and' gates will change to 'or' gates and when where to change it to a 'not' expression. Also a bit unsure as what to do with the XOR gates. Would I just use distributivity?

I need them all to be NAND gates.

Sorry if my English is bad and ignore the crossing out after the B

#### shteii01

Joined Feb 19, 2010
4,644
XOR gate using NAND

OR gate using NAND

AND gate using NAND

NOT gate using NAND

All these came from wiki.

Last edited:

#### Ben Scanlon

Joined Nov 28, 2015
4

I get how to convert it into a circuit. It's writing it out as an expression that is confusing me.

#### WBahn

Joined Mar 31, 2012
30,243
Really stuck. I've tried de Morgan's law but I'm confused as to when converting the whole expression, the 'and' gates will change to 'or' gates and when where to change it to a 'not' expression. Also a bit unsure as what to do with the XOR gates. Would I just use distributivity?

I need them all to be NAND gates.

Sorry if my English is bad and ignore the crossing out after the B

View attachment 95499
The best approach is to expand the XOR into what it really is, namely A'B + AB'

#### shteii01

Joined Feb 19, 2010
4,644

I get how to convert it into a circuit. It's writing it out as an expression that is confusing me.
I fixed the AND gate and added NOT gate.

#### RBR1317

Joined Nov 13, 2010
715
Have you tried to layout that function on a Karnaugh Map? Minimizing for a hardware design using Boolean algebra is really difficult. I guess that is why K-maps were invented. Also, this seems like a natural for using some 3-input NAND gates.

#### WBahn

Joined Mar 31, 2012
30,243
Really stuck. I've tried de Morgan's law but I'm confused as to when converting the whole expression, the 'and' gates will change to 'or' gates and when where to change it to a 'not' expression.
The key to DeMorgan's Theorem is that you can change any AND or and OR, or vice-versa, and maintain the same functionality by inverting the signals at ALL inputs and ALL outputs of THAT gate.

Do things one layer at a time.

For instance, if you have

Y = A(B' + C)D' + AB'(C+D)

First get the final NAND gate functionality in there by applying DeMorgan's to the whole thing:

Y = {[A(B' + C)D'][AB'(C+D)]}'

Now worry about the internal signals at the next layer. And so on and so on.

#### RBR1317

Joined Nov 13, 2010
715
I've tried de Morgan's law but I'm confused as to when converting the whole expression,
There is an alternative method that does not rely on DeMorgan expansions. It is a just simple method of expansion that yields the same minterms that would appear in a Karnaugh map. Minterms can be recombined into a simpler form that mimics K-map minimization. Of course, it helps if you have the K-map so it is easy to see which terms need to be combined. This function can be implemented with just four 3-input NAND gates and three inverters to negate three of the input variables.

#### dl324

Joined Mar 30, 2015
17,006
@RBR1317 In the Homework Help forum, the preferred mode of operation is to guide students to the answer. Giving them the answer deprives them of an opportunity to prove to themselves they can do it. Most teachers would consider having someone do your homework for you cheating.

#### shteii01

Joined Feb 19, 2010
4,644
@RBR1317 In the Homework Help forum, the preferred mode of operation is to guide students to the answer. Giving them the answer deprives them of an opportunity to prove to themselves they can do it. Most teachers would consider having someone do your homework for you cheating.
I am not defending BRB, but... sometimes... it is just too painful to watch.

#### RBR1317

Joined Nov 13, 2010
715
...the preferred mode of operation is to guide students to the answer.
Exactly what I did. Explained a general method to approach the problem, pointed the direction, and walked about 15% down the path. It's up to the OP to do the other 85% to the final solution.

#### dl324

Joined Mar 30, 2015
17,006
Exactly what I did. Explained a general method to approach the problem, pointed the direction, and walked about 15% down the path. It's up to the OP to do the other 85% to the final solution.
If you say so. IMO, you did most of the work.

#### dl324

Joined Mar 30, 2015
17,006
I am not defending BRB, but... sometimes... it is just too painful to watch.
That's why I only visit the Homework Help forum when I'm really bored.

I also stay away from the ones where the OP can't communicate well.