# Implementing logic functions using universal gates

As NAND and NOR gates are universal gates, there are often questions like:

Make the output $f = (a + b')(cd + e)$ using NAND gates.

The problem I face is that I take a long time to first convert these logic functions into AND and OR gates and then to NAND. Either the concept isn't clear or I'm just mugging it up. What are some tricks to doing these problems more quickly?

Two possible ways. You might just learn how to represent, say, OR and AND gates with NANDS, and then replace every occurrence of ORs and ANDs with this implementation. But it might lead to a non-optimal solution. The second approach would be to use Boolean algebra and convert your expression to the representation suitable for the specific gate used. In your example:

 f=(a+b')(cd+e) = (a'b)' ((cd)'e')'.


Now you need only know how to implement the NOT gate with NAND, and implement the expression as is, since the only operations are AND/NAND and NOT.

Upd: The most useful boolean algebra rule to use here is Da Morgans laws which state:
A'+B' = (AB)' (Voila! Couple of NOT's and OR are turning NAND!)
A'B' = (A+B)' (Couple of NOT's and AND are turning NOR!)

• can u also please explain how to make exclusive or and some other...is there a trick?I have seen one bubble trick which i didnt understand Feb 10 '15 at 16:20
• The trick called boolean algebra. The "Da Morgan's laws" are the most useful for this kind of transformations. See update Feb 10 '15 at 16:52
• Exclusive ORs (XOR/EXOR) do not form a complete system, i.e. are not "universal gates". You can't use only XORs to implement any system. Feb 10 '15 at 17:01