Science & Engineering
Logic Gate Simulator
Simulate AND, OR, NOT, NAND, NOR, XOR, XNOR, and BUFFER logic gates. Toggle inputs and see the output with a truth table.
Output is HIGH only when ALL inputs are HIGH.
Logic gate reference
Logic gates are the fundamental building blocks of all digital circuits. Each gate takes one or more binary inputs (0 = LOW / false, 1 = HIGH / true) and produces a single binary output according to a fixed truth table.
| Gate | Symbol | Inputs -> Output | Plain English |
|---|---|---|---|
| AND | ⊓ | 1,1 -> 1; all others -> 0 | Output is 1 only when both inputs are 1. |
| OR | ⊔ | 0,0 -> 0; all others -> 1 | Output is 1 when at least one input is 1. |
| NOT | ◯ | 0 -> 1; 1 -> 0 | Inverts the input (single input only). |
| NAND | ⊓̄ | 1,1 -> 0; all others -> 1 | AND followed by NOT. Universal gate - any circuit can be built from NANDs. |
| NOR | ⊔̄ | 0,0 -> 1; all others -> 0 | OR followed by NOT. Also a universal gate. |
| XOR | ⊕ | same -> 0; different -> 1 | Output is 1 when inputs differ. Used in binary addition. |
| XNOR | ⊙ | same -> 1; different -> 0 | Inverted XOR. Output is 1 when inputs are equal. |
How to build a circuit
Drag gates from the palette onto the canvas. Connect an output pin (the right side of a gate) to an input pin (the left side of another gate) by clicking and dragging between them. Toggle input switches to change their value between 0 and 1, and watch the signal propagate through your circuit in real time. Delete a wire by clicking it; delete a gate by selecting it and pressing Backspace.
Example circuits to try
- Half adder: XOR two inputs for the sum bit; AND the same two inputs for the carry bit. This is the core of binary addition.
- Full adder: Chain two half adders with an OR gate. Adds three bits (A, B, carry-in) and outputs a sum and carry-out.
- SR latch: Cross-couple two NOR gates (or two NAND gates). The circuit remembers its last state - the simplest form of digital memory.
- D flip-flop: A clocked SR latch that captures the input value on the rising edge of a clock signal. The foundation of registers and RAM.
Why logic gates matter
Every microprocessor, memory chip, and digital device is ultimately composed of billions of transistors wired together to behave like logic gates. NAND and NOR gates are called universal because any Boolean function - no matter how complex - can be implemented using only one type of universal gate. The ability to compose simple gates into arbitrarily complex computations is the foundation of all of computing: arithmetic, memory, control flow, and every app running on every device.
Boolean algebra laws
Boolean algebra provides rules for simplifying logic circuits before building them - fewer gates means lower cost, less power, and faster switching:
| Law | AND form | OR form |
|---|---|---|
| Identity | A · 1 = A | A + 0 = A |
| Null | A · 0 = 0 | A + 1 = 1 |
| Idempotent | A · A = A | A + A = A |
| Complement | A · Ā = 0 | A + Ā = 1 |
| Distributive | A(B + C) = AB + AC | A + BC = (A+B)(A+C) |
| De Morgan's | NOT(A · B) = Ā + B̄ | NOT(A + B) = Ā · B̄ |
De Morgan's theorems are especially useful: they let you replace NAND gates with OR gates (and vice versa) by pushing the NOT inside. This is how circuits using only NAND gates can implement OR and NOT functions.
Universal gates
NAND and NOR are each individually universal - any logic circuit can be built from only NAND gates, or from only NOR gates. This has major practical importance:
- Early integrated circuits (e.g., TTL 7400 series) were manufactured as all-NAND or all-NOR chips. Designers implemented every other gate type using combinations of NANDs, reducing the number of distinct ICs needed in a design.
- Modern CMOS fabrication naturally produces NAND and NOR structures with minimum transistor count - 4 transistors for NAND vs. 6 for AND - making universal gates the most area-efficient building blocks.