Logic Gate Calculator
Evaluate digital logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) with instant results, interactive truth tables, and real-time output visualization.
Logic Gate Calculator
Evaluate digital logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) with instant results and interactive truth tables.
Actions
Select Logic Gate
Input Values
Logic Gate Reference
What are Logic Gates?
Logic gates are the fundamental building blocks of digital circuits and computer systems. They perform basic logical operations on one or more binary inputs (0 or 1) to produce a single binary output. Logic gates implement Boolean algebra and are used in processors, memory, controllers, and all digital devices. Understanding logic gates is essential for digital electronics, computer architecture, programming, and electrical engineering. The seven basic logic gates are AND, OR, NOT, NAND, NOR, XOR, and XNOR.
Basic Logic Gates
AND Gate (∧)
Operation: Output is 1 (HIGH) only when ALL inputs are 1. Otherwise, output is 0 (LOW).
Formula: Y = A · B or Y = A AND B
Example: 1 AND 1 = 1, 1 AND 0 = 0, 0 AND 0 = 0. Used in conditional logic, enable signals, and masking operations. Real-world: Door lock that requires both key AND code.
OR Gate (∨)
Operation: Output is 1 when AT LEAST ONE input is 1. Output is 0 only when all inputs are 0.
Formula: Y = A + B or Y = A OR B
Example: 1 OR 1 = 1, 1 OR 0 = 1, 0 OR 0 = 0. Used in combining signals, interrupt handling, and selection logic. Real-world: Alarm triggered by motion sensor OR door sensor.
NOT Gate (¬)
Operation: Output is the INVERSE of input. Also called inverter. Single input gate.
Formula: Y = Ā or Y = NOT A
Example: NOT 1 = 0, NOT 0 = 1. Used in signal inversion, complementing data, and creating other gates. Real-world: Light switch (ON becomes OFF, OFF becomes ON).
NAND Gate (⊼)
Operation: Output is 0 only when ALL inputs are 1. Inverse of AND gate. Universal gate.
Formula: Y = (A · B)' or Y = NOT (A AND B)
Example: 1 NAND 1 = 0, 1 NAND 0 = 1, 0 NAND 0 = 1. Universal gate - can create any other gate. Used extensively in IC design due to simplicity and versatility.
NOR Gate (⊽)
Operation: Output is 1 only when ALL inputs are 0. Inverse of OR gate. Universal gate.
Formula: Y = (A + B)' or Y = NOT (A OR B)
Example: 0 NOR 0 = 1, 1 NOR 0 = 0, 1 NOR 1 = 0. Universal gate - can create any other gate. Used in memory cells (SR latch) and control logic.
XOR Gate (⊕)
Operation: Output is 1 when inputs are DIFFERENT. Output is 0 when inputs are SAME. Exclusive OR.
Formula: Y = A ⊕ B or Y = A'B + AB'
Example: 1 XOR 0 = 1, 0 XOR 1 = 1, 1 XOR 1 = 0, 0 XOR 0 = 0. Used in adders, parity checkers, encryption, and error detection. Real-world: Comparing two values for difference.
XNOR Gate (⊙)
Operation: Output is 1 when inputs are SAME. Output is 0 when inputs are DIFFERENT. Inverse of XOR.
Formula: Y = (A ⊕ B)' or Y = AB + A'B'
Example: 1 XNOR 1 = 1, 0 XNOR 0 = 1, 1 XNOR 0 = 0. Also called equivalence gate. Used in comparators, error detection, and equality checking. Real-world: Password match verification.
Truth Tables Explained
A truth table shows all possible input combinations and their corresponding outputs for a logic gate. It's a complete specification of gate behavior. For n inputs, there are 2n possible combinations.
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Reading Truth Tables: Each row represents one possible input combination. The output column shows the gate's response. Truth tables are used for circuit design, verification, and debugging.
Universal Gates
Logic Gate Applications
Boolean Algebra and Logic Gates
Basic Boolean Laws
Identity Law: A + 0 = A, A · 1 = A
Null Law: A + 1 = 1, A · 0 = 0
Idempotent Law: A + A = A, A · A = A
Complement Law: A + A' = 1, A · A' = 0
Commutative Law: A + B = B + A, A · B = B · A
Associative Law: (A + B) + C = A + (B + C)
Distributive Law: A · (B + C) = A · B + A · C
De Morgan's Theorem: (A + B)' = A' · B', (A · B)' = A' + B'
Boolean algebra provides mathematical foundation for logic gates. These laws allow circuit simplification, optimization, and transformation. De Morgan's theorem is particularly useful for converting between NAND/NOR and other gates. Understanding Boolean algebra is essential for digital design and computer science.
Logic Gate Implementation
Frequently Asked Questions
What is the difference between AND and NAND gates?
AND gate outputs 1 only when both inputs are 1. NAND gate is the inverse - it outputs 0 only when both inputs are 1, otherwise outputs 1. NAND is a universal gate (can create any other gate), while AND is not. In IC design, NAND gates are preferred because they're simpler to manufacture and faster than AND gates. NAND = NOT + AND.
What is XOR gate used for?
XOR (Exclusive OR) outputs 1 when inputs are different, 0 when same. Main uses: (1) Binary addition - XOR gives sum bit in half adder. (2) Parity checking - XOR chain detects odd/even number of 1s. (3) Encryption - XOR with key for simple cipher. (4) Comparison - detects if two bits differ. (5) Toggle - XOR with 1 inverts bit. Essential in arithmetic circuits, error detection, and cryptography.
Why are NAND and NOR called universal gates?
NAND and NOR are called universal gates because you can create ANY other logic gate using only NAND or only NOR gates. For example, using only NAND: NOT = NAND with tied inputs, AND = NAND + NOT, OR = NOT + NAND + NOT. This property is crucial in IC manufacturing - entire processors can be built using primarily NAND gates, simplifying design and production. AND, OR, NOT are not universal.
How do I read a truth table?
Truth table shows all possible input combinations and their outputs. Each row is one combination. For 2 inputs (A, B), there are 4 rows: 00, 01, 10, 11. For 3 inputs, 8 rows. For n inputs, 2nrows. Read left to right: input values, then output. Example: AND gate row "1 1 → 1" means when both inputs are 1, output is 1. Truth tables completely define gate behavior and are used for circuit design and verification.
What voltage levels represent 0 and 1 in logic gates?
In TTL (5V logic): 0 = 0-0.8V (LOW), 1 = 2-5V (HIGH). In CMOS (3.3V logic): 0 = 0-1V, 1 = 2.3-3.3V. In CMOS (5V logic): 0 = 0-1.5V, 1 = 3.5-5V. The gap between LOW and HIGH provides noise immunity. Modern processors use lower voltages (1.8V, 1.2V, 0.9V) for power efficiency. Arduino uses 5V logic, Raspberry Pi uses 3.3V. Voltage level shifters needed when interfacing different logic families.
Can I build a computer using only logic gates?
Yes! All computers are fundamentally built from logic gates. CPU contains billions of transistors forming logic gates. Basic components: (1) ALU - arithmetic using adders (XOR, AND gates). (2) Registers - memory using flip-flops (NAND/NOR gates). (3) Control unit - state machines (various gates). (4) Memory - arrays of latches. Simple 8-bit computer can be built with ~1000 gates. Modern processors have billions of gates. Educational projects like Ben Eater's 8-bit computer demonstrate this concept.
What is propagation delay in logic gates?
Propagation delay is the time between input change and corresponding output change. Measured in nanoseconds (ns). TTL gates: 5-10ns. CMOS gates: 10-50ns. Modern processors: <1ns. Delay limits maximum clock speed - faster gates allow higher frequencies. Caused by transistor switching time and capacitance. Critical in timing analysis and high-speed design. Multiple gates in series add delays. Affects maximum operating frequency of digital circuits.
💡 Pro Tip
When learning logic gates, start with truth tables - they provide complete understanding of gate behavior. Practice converting between different gate types using Boolean algebra and De Morgan's theorem. Remember that NAND and NOR are universal gates - understanding how to build other gates from them is crucial for digital design. Use online simulators to visualize complex circuits before building hardware. When debugging digital circuits, check truth tables systematically for each gate. For exam preparation, memorize truth tables for all seven basic gates and practice Boolean simplification. In practical applications, always consider propagation delay and power consumption when selecting gate types.