Skip to content
Advertisement

Logic Gate Simulator

Type a boolean expression and get its full truth table and canonical sum-of-products — AND, OR, NOT, XOR, NAND, NOR, XNOR.

Simulator Reference

Operators

AND & · * ∧ or adjacency (AB) · OR | + · NOT ! ~ ¬ · XOR ^ ⊕ · plus NAND, NOR, XNOR and constants 0/1. Variables A–H (up to 8). Precedence: NOT > AND > XOR > OR — use parentheses to override.
Variables
A, B, C
Rows
8
True rows (minterms)
3 of 8

Sum of products

A·¬B·¬C + A·B·¬C + A·B·C

Truth table for the expression
A B C Out
000 0
001 0
010 0
011 0
100 1
101 0
110 1
111 1

How Logic Gate Simulator works

A boolean expression describes a function from binary inputs to a binary output. A truth table makes that function explicit by listing every possible input combination alongside the result — for n inputs there are 2^n rows, which is why tables stay readable up to about four or five variables and become unwieldy beyond that.

The seven standard gates cover every function you need. AND outputs 1 only when all inputs are 1; OR when any input is 1; NOT inverts; XOR outputs 1 when an odd number of inputs are 1. NAND, NOR, and XNOR are the negations of the first three. NAND and NOR are individually functionally complete — any circuit whatsoever can be built from NAND gates alone, which is why they dominate real silicon.

From a truth table you can mechanically derive a canonical sum of products. Each row producing a 1 contributes one minterm: a product of every input, complemented where that input is 0. ORing all the minterms together gives an expression that is guaranteed correct, though usually not minimal.

Minimisation is the separate step that turns a correct expression into an economical one, using boolean algebra, Karnaugh maps, or the Quine–McCluskey algorithm. The canonical form is the reliable starting point: derive it from the table first, then simplify, because simplifying by inspection is where errors creep in.

Reference

  • AND: A · B OR: A + B NOT: Ā XOR: A ⊕ B
  • NAND: (A · B)′ NOR: (A + B)′ XNOR: (A ⊕ B)′
  • De Morgan: (A · B)′ = A′ + B′ and (A + B)′ = A′ · B′
  • Rows in a truth table = 2^n for n inputs
  • Canonical SOP = OR of the minterms for every row where the output is 1

How to use this simulator

  1. Type an expression

    Enter a boolean expression using AND, OR, NOT, XOR, NAND, NOR, and XNOR with your variables.

  2. Read the truth table

    Every input combination is enumerated with its result, so you can verify the behaviour exhaustively.

  3. Check the canonical form

    The sum-of-products expression derived from the table gives a directly implementable equivalent.

  4. Compare alternatives

    Enter a simplified expression and confirm its truth table matches the original exactly.

Worked examples

De Morgan verified

Given
NOT (A AND B) versus (NOT A) OR (NOT B)
Result
Identical truth tables across all four rows

The fastest way to check a De Morgan transformation is to enumerate it rather than trust the manipulation.

A half adder

Given
Sum = A XOR B, Carry = A AND B
Result
Sum is 1 for exactly one input high; carry only for both

Two gates and the whole of binary addition begins here. Chaining full adders builds an arbitrary-width adder.

Majority of three

Given
(A AND B) OR (B AND C) OR (A AND C)
Result
1 whenever at least two inputs are 1

The canonical SOP has four minterms; this three-term form is the minimised equivalent. Same table, fewer gates.

When to use it

  • Verifying that a simplified boolean expression matches the original exactly.
  • Deriving a canonical sum-of-products form from a specification.
  • Checking a De Morgan transformation before applying it to a circuit.
  • Learning or teaching how the standard gates combine.
  • Working out the gate-level logic for a combinational block before implementing it.

Things to watch out for

  • This models pure combinational logic. Flip-flops, latches, and anything with state or feedback need a sequential simulator instead.
  • Real gates have propagation delay. Signals arriving through different path lengths cause transient glitches that an instantaneous truth table cannot show.
  • The canonical form is correct but rarely minimal. Use a Karnaugh map or Quine–McCluskey for a gate-efficient implementation.
  • Truth tables double in size with each input. Beyond about five variables, algebraic methods and automated minimisation become necessary.

Frequently asked questions

How many rows does a truth table have?

2^n for n inputs: four rows for two inputs, eight for three, sixteen for four. Each additional variable doubles the table, which is why exhaustive enumeration stops being practical beyond about five inputs.

What is a sum of products?

An OR of AND terms. The canonical form takes every truth-table row whose output is 1 and writes one minterm — a product of all inputs, complemented where that input is 0 — then ORs them together. It is guaranteed correct, though usually not the smallest possible expression.

Why are NAND and NOR called universal gates?

Because either one alone can build every other gate, and therefore any digital circuit. NOT is a NAND with its inputs tied together, AND is a NAND followed by that NOT, and so on. Manufacturing a single gate type in bulk is why CMOS silicon is dominated by them.

What is De Morgan’s theorem?

NOT (A AND B) equals (NOT A) OR (NOT B), and NOT (A OR B) equals (NOT A) AND (NOT B). It lets you push inversions through a circuit, which is how designs are converted into NAND-only or NOR-only implementations.

What is the difference between XOR and OR?

OR outputs 1 when any input is 1, including when all are. XOR outputs 1 only when an odd number of inputs are 1 — so for two inputs it is 0 when both are 1. XOR is the "difference detector" and the basis of binary addition.

Can this simulate flip-flops or counters?

No. Those are sequential circuits whose output depends on stored state and past inputs, not just current ones. This tool evaluates purely combinational expressions, where the output is a function of the present inputs alone.

All electrical engineering tools