TFT

Logic Gate Simulator – Simulate Digital Logic Gates

Simulate AND, OR, NOT, XOR, NAND, NOR, and XNOR logic gates with our free online logic gate simulator. Interactive truth tables and visual output for digital logic learning.

Gate Inputs

Click to toggle

Click to toggle

Examples:

Understanding Logic Gates

Logic gates are the fundamental building blocks of digital circuits. Each gate takes one or more binary inputs (0 or 1, false or true, low or high) and produces a single binary output based on a specific logical rule. Computers, smartphones, and all digital devices are built from billions of these gates working together.

There are seven basic logic gates: AND, OR, NOT, XOR, NAND, NOR, and XNOR. Each has a unique truth table that defines its behavior for every possible input combination. By combining gates, you can build circuits that perform arithmetic, store memory, and execute complex operations.

The Seven Logic Gates

AND Gate

Output = A · B

Output is 1 only when BOTH inputs are 1. Like multiplication: 1×1=1, otherwise 0.

OR Gate

Output = A + B

Output is 1 when AT LEAST ONE input is 1. Like addition (but 1+1=1 in Boolean algebra).

NOT Gate

Output = Ā

Output is the INVERSE of input. Also called an inverter. The only gate with one input.

XOR Gate

Output = A ⊕ B

Output is 1 when inputs are DIFFERENT. "Exclusive OR" – one or the other, but not both.

NAND Gate

Output = (A · B)'

AND followed by NOT. Output is 0 only when both inputs are 1. A "universal gate" – can build any circuit from NANDs alone.

NOR Gate

Output = (A + B)'

OR followed by NOT. Output is 1 only when both inputs are 0. Also a universal gate.

Worked Examples

Example 1: AND Gate

A = 1, B = 1

AND truth table:
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1 ✓
Output: 1

Example 2: XOR Gate

A = 1, B = 0

XOR truth table:
0 XOR 0 = 0 (same)
0 XOR 1 = 1 (different) ✓
1 XOR 0 = 1 (different) ✓
1 XOR 1 = 0 (same)
Output: 1

Example 3: NAND Gate

A = 1, B = 1

First compute AND: 1 AND 1 = 1
Then invert: NOT 1 = 0
Output: 0

Example 4: NOR Gate

A = 0, B = 0

First compute OR: 0 OR 0 = 0
Then invert: NOT 0 = 1
Output: 1

Quick Fact

Claude Shannon's 1937 master's thesis showed that Boolean algebra (logic gates) could be implemented using electrical switches. This insight launched the digital age. Modern CPUs contain billions of transistors acting as microscopic logic gates, switching billions of times per second.

Frequently Asked Questions

What's the difference between XOR and OR?

OR outputs 1 if either or both inputs are 1. XOR (exclusive OR) outputs 1 only if exactly one input is 1 – not both. XOR is like "one or the other, but not both."

Why are NAND and NOR called universal gates?

You can build ANY logic circuit using only NAND gates (or only NOR gates). You can create AND, OR, and NOT functions from combinations of NANDs. This makes them fundamental for chip design.

What does a NOT gate do?

NOT inverts the input: 0 becomes 1, and 1 becomes 0. It's also called an inverter. NOT is the only gate with a single input. The symbol is a triangle with a small circle at the output.

How are logic gates physically implemented?

Modern gates use transistors – tiny electronic switches. A CMOS gate might use 2-6 transistors. When voltage is applied to the gate terminal, it controls current flow, implementing the logical operation.

What is a truth table?

A truth table lists every possible input combination and the corresponding output. For a 2-input gate, there are 4 rows (00, 01, 10, 11). It completely defines the gate's behavior.

Can logic gates have more than 2 inputs?

Yes! AND, OR, NAND, and NOR gates commonly have 3, 4, 8, or more inputs. A 3-input AND outputs 1 only when all three inputs are 1. XOR with multiple inputs outputs 1 when an odd number of inputs are 1.

Other Free Tools

Truth Table Generator – Create Logic Truth Tables Online

Generate truth tables for any logical expression with our free online truth table generator. Supports AND, OR, NOT, XOR, NAND, NOR, and implication operators for any number of variables.

Boolean Expression Evaluator – Evaluate Logic Expressions Online

Evaluate any Boolean expression for given variable values with our free online Boolean expression evaluator. Supports all logical operators including AND, OR, NOT, XOR, and more.

Binary Addition & Subtraction Calculator – Compute in Base 2

Add and subtract binary numbers step by step with our free online binary calculator. See each bit-by-bit operation clearly – perfect for computer science and digital electronics.

Bitwise Operations Calculator – Compute AND OR XOR NOT Shifts

Perform bitwise AND, OR, XOR, NOT, left shift, and right shift operations on integers with our free online bitwise calculator. See binary representations alongside results.

Number Base Converter – Binary, Octal, Decimal, Hex Converter

Convert numbers between binary, octal, decimal, and hexadecimal bases instantly with our free online number base converter. Perfect for computer science students and programmers.

Data Storage Converter – Convert KB, MB, GB, TB Online

Convert between any digital storage unit with our free online data storage converter. Supports bytes, kilobytes, megabytes, gigabytes, terabytes, and petabytes instantly.

Free Online Scientific Calculator – Advanced Math Functions

Perform complex scientific calculations online with our free scientific calculator. Supports trigonometry, logarithms, exponents, roots, and more – ideal for students and professionals.

BODMAS / PEMDAS Calculator – Order of Operations Solver

Solve any math expression using the correct order of operations with our free BODMAS/PEMDAS calculator. Get step-by-step breakdowns to understand exactly how each expression is evaluated.