All labs › Learn › Digital Logic Design
All articlesAll labs

NAND and NOR as Universal Gates

See why NAND and NOR are universal gates. Build NOT, AND, OR and XOR from NAND only and from NOR only, count the gates and use two level NAND logic.

Updated 28 November 2026 · 4 min read · Designed by Fasih Ullah Saleem

01What universal means02Everything from NAND03Everything from NOR04NAND NAND logic05Unused inputs and chip use06Why not always use universal gates07Checking the NAND XOR08Try it in the virtual lab09Questions and answers10Related topics
01

What universal means

A gate is called universal if you can build every other logic function from copies of it. NAND and NOR are both universal. This matters in practice. A designer can use a single type of chip, a 7400 of four NAND gates for example, and build the whole circuit, which makes the parts list shorter.

It works because each of them can make a NOT gate, and from NOT with either AND or OR you get everything else. De Morgan's laws do the rest.

02

Everything from NAND

Here is how each basic gate is made from NAND gates only.

FunctionBuilt from NANDGates
NOT ANAND(A, A)1
A AND BNAND( NAND(A, B), NAND(A, B) )2
A OR BNAND( NAND(A, A), NAND(B, B) )3
A NOR Binvert the OR above4
A XOR BNAND( NAND(A, m), NAND(B, m) ) with m = NAND(A, B)4

The AND gate is a NAND followed by a NOT, since the two bubbles cancel. The OR gate follows from De Morgan's law: A + B = (A' · B')', which is a NAND of the two inverted inputs. The XOR uses a shared first gate m, so the whole function fits in one 7400 chip.

03

Everything from NOR

NOR is the mirror image. Swap the roles of AND and OR.

FunctionBuilt from NORGates
NOT ANOR(A, A)1
A OR BNOR( NOR(A, B), NOR(A, B) )2
A AND BNOR( NOR(A, A), NOR(B, B) )3
A NAND Binvert the AND above4

The AND gate comes from A · B = (A' + B')', a NOR of the two inverted inputs. One 7402 chip holds four NOR gates.

04

NAND NAND logic

Most designs are first written as a sum of products, an OR of several AND terms. There is a direct way to build it with NAND gates only. Replace every AND with a NAND and replace the OR with a NAND. The result is the same function, with only two levels of gates.

F = AB + CD = ( (AB)' · (CD)' )' = NAND( NAND(A, B), NAND(C, D) )

The proof is De Morgan's law applied once. This takes three gates, and they fit in one chip. A product of sums does the same with NOR gates.

05

Unused inputs and chip use

  • A two input NAND used as a NOT can have its inputs tied together, or one input tied to logic 1. Tying the inputs together doubles the load on the driving gate.
  • A 7400 has four gates, so an XOR (4 gates) uses all of one chip. An OR gate (3 gates) wastes one gate, which you can use as an inverter elsewhere.
  • Count the total number of NAND gates of your design and divide by four to find the number of chips.

Delay adds up too. An OR built from three NAND gates has two gate delays, where a real OR chip has about one.

06

Why not always use universal gates

A circuit built from only NAND gates is rarely the cheapest in chips. A real XOR chip, the 7486, does the job of four NAND gates in a quarter of the space. The point of universal gates is flexibility. They also let you see that any digital system, however complicated, is made of one simple building block repeated many times. Integrated circuits are in fact built in large part from NAND or NOR structures because they are easy to make in silicon.

07

Checking the NAND XOR

Test the four gate XOR by hand. Call the first gate m = NAND(A, B). The second gate gives NAND(A, m), the third NAND(B, m), and the last combines them.

For A = 1 and B = 0 we get m = 1, then NAND(1, 1) = 0 and NAND(0, 1) = 1, so the output is NAND(0, 1) = 1. For A = 1 and B = 1 we get m = 0, then both middle gates give 1, so the output is NAND(1, 1) = 0. For A = 0 and B = 0 we get m = 1, both middle gates give 1 and the output is 0. A = 0 and B = 1 mirrors the first case and gives 1. The table matches an XOR gate on all four rows.

08

Try it in the virtual lab

SinBench has free 3D benches and interactive demos for this topic. Open one to try the ideas above with real instruments, no sign up needed.

Lab 2

NAND and NOR as Universal Gates

Open the lab →Concepts and demos
09

Questions and answers

Why are NAND and NOR called universal gates?

Each of them can build a NOT gate and either an AND or an OR gate, so any logic function can be built from NAND gates alone or NOR gates alone.

How many NAND gates make an XOR?

Four. One gate makes the NAND of A and B, and two more gates combine each input with that result. A fourth gate gives the final output.

How do you make an OR gate from NAND gates?

Invert each input with a NAND gate used as a NOT, then feed both to a third NAND gate. This follows from De Morgan's law.

What is NAND NAND logic?

A sum of products circuit where every AND and the final OR are replaced by NAND gates. It gives the same function with two gate levels.

10

Related topics

Digital Logic Design

Boolean Algebra and De Morgan's Laws

Learn the Boolean identities, absorption and consensus, and De Morgan's laws, with worked simplification examples and truth table proofs you can check.

Digital Logic Design

Logic Gates and Truth Tables: AND, OR, NOT, NAND, NOR, XOR

Learn the seven basic logic gates with truth tables, symbols and expressions, the common TTL chips that hold them and how to read a gate level circuit.

Digital Logic Design

Karnaugh Maps: Simplify Boolean Functions Step by Step

A step by step guide to Karnaugh maps: how to fill a 4 variable map, group cells, use don't cares and write the simplest sum of products, with a worked example.

SinBench SinBench · Free virtual labsDesigned by Fasih Ullah Saleem
© 2026 Fasih Ullah Saleem. All rights reserved. fasihullahsaleem.com · About · Terms of Use · Privacy