Boolean Logic Gates: AND, OR, NOT, XOR, NAND Simulator

simulator beginner ~6 min
Loading simulation...
AND(0, 0) = 0 — both inputs must be 1

The AND gate outputs 1 only when both inputs are 1. With inputs A=0 and B=0 the output is 0. This is the foundation of digital multiplication.

Formula

AND: Q = A · B
OR: Q = A + B
NOT: Q = ¬A
XOR: Q = A ⊕ B = A·¬B + ¬A·B
NAND: Q = ¬(A · B)

The Atoms of Computation

Every digital device — from a pocket calculator to a supercomputer — is built from a small set of logic gates. These gates take binary inputs (0 or 1) and produce a binary output according to a fixed Boolean function. The AND gate outputs 1 only when both inputs are 1. The OR gate outputs 1 when at least one input is 1. The NOT gate simply inverts its single input. From these primitives, all of digital computing is constructed.

Universal Gates

A remarkable fact of Boolean algebra is that the NAND gate alone can implement any logical function. By combining NAND gates in different configurations, you can build AND, OR, NOT, XOR, and every other gate. This universality is why real-world chip fabrication often uses NAND-only or NOR-only libraries — it simplifies manufacturing while retaining full computational power.

From Gates to Circuits

Individual gates are combined into larger circuits: multiplexers route data, decoders select memory addresses, and arithmetic logic units (ALUs) perform addition and subtraction. Each layer of abstraction builds on the layer below. The half adder you can explore in another simulation is just an XOR gate and an AND gate working together.

Propagation and Timing

In physical circuits, signals don't change instantaneously. Each gate introduces a tiny propagation delay — typically a few picoseconds in modern silicon. When gates are chained, these delays accumulate, forming the critical path that determines a processor's maximum clock speed. Understanding gate-level timing is essential for designing fast, reliable digital systems.

FAQ

What are the five basic logic gates?

The five fundamental logic gates are AND (outputs 1 only when both inputs are 1), OR (outputs 1 when at least one input is 1), NOT (inverts a single input), XOR (outputs 1 when inputs differ), and NAND (the inverse of AND). NAND and NOR are called universal gates because any circuit can be built from them alone.

Why is NAND called a universal gate?

NAND is universal because you can construct AND, OR, NOT, and every other Boolean function using only NAND gates. A NOT is a NAND with both inputs tied together. An AND is a NAND followed by a NOT-NAND. This property makes NAND the preferred gate in chip manufacturing.

How do logic gates relate to transistors?

Each logic gate is built from one or more transistors. A CMOS NOT gate uses two transistors (one PMOS, one NMOS). A NAND gate uses four transistors. Modern CPUs contain billions of transistors implementing millions of logic gates.

What is gate propagation delay?

Propagation delay is the time it takes for an input change to appear at the output. In modern chips this is measured in picoseconds. Chaining many gates increases total delay and limits the maximum clock frequency of a processor.

Sources

Embed

<iframe src="https://homo-deus.com/lab/logic-circuits/boolean-gates/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub