Logic Gates Simulator
Flip the switches and watch current flow through AND, OR, NOT, NAND, NOR, XOR and XNOR gates. Then wire your own circuit and get its Boolean expression and complete truth table automatically.
An AND gate gives 1 only when both inputs are 1; an OR gate gives 1 when at least one input is 1; NOT reverses its input. NAND and NOR are the exact opposites of AND and OR, and XOR gives 1 only when the two inputs differ. De Morgan's laws: (A·B)′ = A′ + B′ and (A + B)′ = A′·B′.
Pick a gate
Tap a gate, then tap the switches on the diagram.
AND gate
Truth table
The highlighted row is the one your switches are showing now.
Build a circuit
Tap a part to drop it on the board. Drag from a round output pin to an input pin to join them. Tap a switch to flip it, tap a wire or a gate then press Delete to remove it.
Boolean expression
Worked out from the wiring, every time you change something.
Truth table
Every combination of the input switches.
Expression to truth table
Type it any way you like: A.B + A'.C, A AND B OR NOT C, AB' + C, A ^ B.
Are two expressions the same?
Useful for checking your simplification in an exam question.
De Morgan — worked example
Simplify ((A + B′) · C)′
- The whole thing is a product being inverted, so use De Morgan's second law (X·Y)′ = X′ + Y′ with X = (A + B′) and Y = C.= (A + B′)′ + C′
- Now (A + B′)′ is a sum being inverted, so use the first law (X + Y)′ = X′·Y′.= A′·(B′)′ + C′
- Two NOTs cancel (involution): (B′)′ = B.= A′·B + C′
- ((A + B′) · C)′ = A′·B + C′
Boolean laws
Press Verify on any law to compare both sides row by row.
Build it yourself
Pick a task. The board is set up with the right switches and lamps — you add the gates and the wires, then press Check.
The truth table you must match
From one gate to a whole adder
Every digital device — calculator, phone, computer — is built from these seven gates. Each one takes 0s and 1s in and gives a single 0 or 1 out.
Try one gate
Choose a gate and click its switches. The wire turns red when it carries a 1.
Read the truth table
The row that matches your switches is highlighted, so the table stops being abstract.
Wire a circuit
Drop gates on the board and join pins. The Boolean expression and full truth table appear by themselves.
Check your algebra
Type an expression, get the table, and verify any Boolean law with a side-by-side proof.
The seven gates at a glance
| Gate | Expression | 00 | 01 | 10 | 11 |
|---|---|---|---|---|---|
| AND | A·B | 0 | 0 | 0 | 1 |
| OR | A+B | 0 | 1 | 1 | 1 |
| NAND | (A·B)′ | 1 | 1 | 1 | 0 |
| NOR | (A+B)′ | 1 | 0 | 0 | 0 |
| XOR | A⊕B | 0 | 1 | 1 | 0 |
| XNOR | (A⊕B)′ | 1 | 0 | 0 | 1 |
| NOT | A′ | A=0 → 1 | A=1 → 0 | ||
Writing Boolean algebra
AND is written like multiplication (A·B or AB), OR like addition (A+B), NOT with a bar or a prime (A′). Order of working: NOT first, then AND, then OR — brackets override it.
Remember the two rules that look odd next to ordinary algebra: A + A = A and A + 1 = 1.
De Morgan's theorems
(A + B)′ = A′ · B′
(A · B)′ = A′ + B′
In words: break the bar and change the operator. This is how a circuit made of AND, OR and NOT gates is rebuilt using NAND gates only — cheaper to manufacture, because one NAND chip can do everything.
Universal gates
NAND and NOR are called universal gates because every other gate can be built from copies of just one of them. A NAND with both inputs joined is a NOT; two NANDs make an AND; three make an OR.
That is why real chips are packed with NAND gates — and why the challenges here ask you to rebuild AND, OR and NOT from NAND alone.
Logic Gates Simulator — your questions
What is the truth table of an AND gate?
An AND gate has output 1 only when every input is 1. For two inputs A and B: 0,0 gives 0; 0,1 gives 0; 1,0 gives 0; and 1,1 gives 1. It is written A·B or simply AB, because AND behaves like multiplication — the answer is 1 only if nothing in the product is 0.
What is the difference between OR and XOR?
An OR gate gives 1 when at least one input is 1, so 1,1 also gives 1. An XOR (exclusive OR) gate gives 1 only when the two inputs are different, so 0,1 and 1,0 give 1 but 1,1 gives 0. XOR is written A⊕B and is the gate used to add two bits in a half adder.
What are De Morgan's theorems?
(A + B)′ = A′·B′ and (A·B)′ = A′ + B′. In words: break the bar and change the operator — the complement of a sum is the product of the complements, and the complement of a product is the sum of the complements. They are how a circuit of AND, OR and NOT gates is rebuilt using NAND gates alone.
Why are NAND and NOR called universal gates?
Because every other gate can be built from copies of just one of them. A NAND with both inputs joined together acts as a NOT; two NANDs make an AND; three make an OR. The same is true of NOR. Real chips are packed with NAND gates because one repeated design is cheaper to manufacture.
How many rows does a truth table have?
Two to the power of the number of inputs. Two inputs give 2² = 4 rows, three inputs give 2³ = 8 rows and four inputs give 16 rows. Write the input columns as counting in binary — 00, 01, 10, 11 — so no combination is missed and the rows always come out in the same order.
In what order are Boolean operations worked out?
NOT first, then AND, then OR, with brackets overriding everything — the same idea as BODMAS. So A + B·C means A + (B·C), not (A + B)·C. Two rules that look odd beside ordinary algebra are worth remembering: A + A = A and A + 1 = 1.
How do I prove two Boolean expressions are the same?
Build the truth table for both and compare them row by row; if every row matches for every combination of inputs, the expressions are equal. The Boolean tools tab here does exactly that — type your original expression and your simplified one, press Compare, and it checks every row for you.