Productive Toolbox

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

AND: Output is 1 only when both inputs are 1

Input Values

Click to toggle
Click to toggle

Logic Gate Reference

AND
Output is 1 only when both inputs are 1
OR
Output is 1 when at least one input is 1
¬NOT
Output is the inverse of the input
NAND
Output is 0 only when both inputs are 1 (NOT AND)
NOR
Output is 1 only when both inputs are 0 (NOT OR)
XOR
Output is 1 when inputs are different (Exclusive OR)
XNOR
Output is 1 when inputs are the same (NOT XOR)

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.

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

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

NAND Gate - Universal Gate: NAND gate can implement any Boolean function. You can create AND, OR, NOT, and all other gates using only NAND gates. This makes NAND gates extremely important in IC design. Example: NOT gate = NAND with inputs tied together. AND gate = NAND followed by NOT. OR gate = NAND with inverted inputs.
NOR Gate - Universal Gate: NOR gate can also implement any Boolean function. Like NAND, you can create all other gates using only NOR gates. Used in memory cells (SR latch, flip-flops). Example: NOT gate = NOR with inputs tied together. OR gate = NOR followed by NOT. AND gate = NOR with inverted inputs.
Why Universal Gates Matter: In IC manufacturing, using only one type of gate (NAND or NOR) simplifies design, reduces cost, and improves reliability. Most digital ICs are built primarily with NAND gates due to their speed and efficiency. Understanding universal gates is crucial for digital circuit design and optimization.

Logic Gate Applications

Arithmetic Circuits: Half adders and full adders use XOR and AND gates to perform binary addition. Subtractors use XOR with NOT gates. ALU (Arithmetic Logic Unit) in processors uses combinations of logic gates for all arithmetic operations. Multipliers use arrays of AND gates with adders.
Memory Circuits: SR latch (Set-Reset) uses NOR or NAND gates to store 1 bit. D flip-flop uses multiple gates for synchronized data storage. RAM and ROM use arrays of logic gates. Cache memory uses complex gate combinations for fast access. All computer memory fundamentally relies on logic gates.
Control Logic: Multiplexers (MUX) use AND, OR, NOT gates to select data inputs. Demultiplexers route signals to multiple outputs. Encoders and decoders convert between binary codes. State machines use gates with feedback for sequential logic. Used in CPUs, controllers, and automation.
Error Detection: Parity checkers use XOR gates to detect single-bit errors in data transmission. Hamming code uses multiple XOR gates for error correction. CRC (Cyclic Redundancy Check) uses XOR in polynomial division. Essential for reliable communication and data storage.
Comparators: XNOR gates compare two bits for equality. Magnitude comparators use combinations of gates to determine if A > B, A < B, or A = B. Used in sorting, searching, and conditional operations. Essential in processors for branch instructions and conditional execution.
Encryption: XOR gates are fundamental in cryptography. Stream ciphers use XOR with key stream. Block ciphers (AES, DES) use complex gate combinations. One-time pad uses XOR for perfect encryption. Hash functions use extensive gate logic for data integrity.

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

TTL (Transistor-Transistor Logic): Uses bipolar junction transistors (BJTs). Fast switching speed, high power consumption. Common ICs: 7400 series (7408 AND, 7432 OR, 7404 NOT). Operating voltage: 5V. Used in older systems and educational projects. Being replaced by CMOS in modern designs.
CMOS (Complementary Metal-Oxide-Semiconductor): Uses MOSFETs (both NMOS and PMOS). Very low power consumption, slower than TTL. Common ICs: 4000 series (4081 AND, 4071 OR, 4069 NOT). Operating voltage: 3-15V. Dominant technology in modern ICs, processors, and memory. Used in all smartphones, computers, and digital devices.
Discrete Components: Can build logic gates using individual transistors, resistors, and diodes. Educational value for understanding gate operation. Diode logic (AND, OR) is simple but has limitations. Transistor logic provides better performance. Used in custom circuits and prototyping.
FPGA and CPLD: Field Programmable Gate Arrays implement logic gates using lookup tables (LUTs) and programmable interconnects. Allows custom logic without manufacturing ICs. Used in prototyping, signal processing, and specialized applications. Can implement millions of gates. Reconfigurable hardware.

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.