Overview
Logic gates are the fundamental building blocks of all digital electronics. They are electronic circuits that perform boolean logic operations on one or more binary inputs to produce a single binary output. Every digital device — smartphones, computers, game consoles, microwave ovens — contains millions or billions of logic gates working together.
There are seven standard logic gates: AND, OR, NOT, NAND, NOR, XOR, and XNOR. Each gate performs a specific boolean operation and has a unique truth table. Two of these — NAND and NOR — are called universal gates because any other logic function can be implemented using only one type of universal gate.
Understanding how logic gates work is the foundation of digital electronics engineering, computer architecture, embedded systems design, and software engineering at the hardware level. This guide covers all seven gates with truth tables, boolean expressions, and real applications.
How It Works
All logic gates operate on binary signals: 0 (LOW, typically 0V) or 1 (HIGH, typically 3.3V or 5V). The output is determined solely by the current inputs with no memory (unless feedback is added).
AND Gate: Y = A·B. Output 1 only when all inputs are 1. OR Gate: Y = A+B. Output 1 when any input is 1. NOT Gate: Y = A'. Single input. Inverts the signal. NAND Gate: Y = (A·B)'. Complement of AND. Universal gate. NOR Gate: Y = (A+B)'. Complement of OR. Universal gate. XOR Gate: Y = A⊕B. Output 1 when inputs are different. XNOR Gate: Y = (A⊕B)'. Output 1 when inputs are the same.
Gates are fabricated in complementary metal-oxide-semiconductor (CMOS) technology using pairs of PMOS and NMOS transistors. Modern ICs contain billions of gates etched at nanometre scale using photolithography.
Real-World Applications
Used when all conditions must be simultaneously true: start button AND safety guard AND no fault signal.
Used when any one of several conditions should activate an output: sensor A OR sensor B OR sensor C triggers an alarm.
Inverts a signal for complementary logic, clock generation, input conditioning, and De Morgan transformations.
Either NAND or NOR alone can implement any logic function. Chip designers favour NAND for its 4-transistor efficiency.
XOR forms the sum bit in adders, generates parity, and provides the reversible mixing in cryptographic operations.
XNOR checks whether two bits are equal, forming the basis of multi-bit digital comparators.
Try It in the Interactive Simulator
Build Logic Gates Explained circuits in real time — drag gates, connect wires, toggle inputs, and see outputs update instantly.
Frequently Asked Questions
- What are the 7 basic logic gates?
The seven standard logic gates are AND, OR, NOT, NAND, NOR, XOR, and XNOR. AND/OR/NOT are the three primitive gates; NAND and NOR are universal; XOR and XNOR are equality/inequality detectors.
- Which gates are universal gates?
NAND and NOR are universal gates — any boolean function can be implemented using only NAND gates (or only NOR gates). This is important for manufacturing efficiency: a fab can build entire chips using only one gate type.
- What is the difference between a gate and a circuit?
A gate is a single logic element (AND, OR, etc.). A circuit is a combination of gates connected by wires to implement a more complex function like an adder, multiplexer, or flip-flop.
- What technology implements logic gates?
Modern logic gates use CMOS (Complementary Metal-Oxide Semiconductor) transistors. Earlier technologies included TTL (bipolar), ECL (emitter-coupled logic), and vacuum tube logic. CMOS dominates because of its near-zero static power consumption.
- How many transistors does each gate need?
NOT: 2, NAND: 4, NOR: 4, AND: 6, OR: 6, XOR: 8-10, XNOR: 8-10. NAND and NOR need fewer transistors than AND and OR, which is why real chip designs often invert logic to use NAND/NOR.