FPGARelated.com
Fundamentals

Logic Gates

AND, OR, NOT: the atoms of digital circuits

Every digital circuit ever built, from a simple calculator to a billion-transistor FPGA, is made from combinations of just a few fundamental building blocks: logic gates.

A gate takes one or two binary inputs (0 or 1) and produces one output based on a simple rule. Master these six gates and you understand the atoms of all digital design.

Interactive Gate Simulator

Select a gate type, then click the inputs to toggle between 0 and 1. Watch how the output changes:

The Six Fundamental Gates

AND - Output is 1 only when all inputs are 1. Think of it as: "both must be true." If either input is 0, the output is 0.

OR - Output is 1 when any input is 1. "At least one must be true." The output is 0 only when both inputs are 0.

NOT - The simplest gate: it flips the input. 0 becomes 1, 1 becomes 0. Also called an inverter.

XOR (Exclusive OR) - Output is 1 when the inputs are different. Same inputs give 0, different inputs give 1. This gate is essential for arithmetic circuits and error detection.

NAND (NOT-AND) - The opposite of AND: output is 0 only when both inputs are 1, otherwise it's 1. NAND is a universal gate, meaning any other gate can be built using only NAND gates. This makes it the most important gate in chip manufacturing.

NOR (NOT-OR) - The opposite of OR: output is 1 only when both inputs are 0. Like NAND, NOR is also a universal gate.

Key Insight: NAND and NOR are called "universal gates" because you can build any other gate (AND, OR, NOT, XOR) using only NAND gates (or only NOR gates). This is why real chips and FPGA lookup tables are fundamentally NAND-like structures.
Try it: Can you find the gate that outputs 1 only when exactly one input is high? Try each gate type and toggle the inputs. (Hint: it's the gate whose truth table has 1s only on the diagonal.)

Why This Matters for FPGA Design

In an FPGA, you don't wire up individual gates by hand. Instead, the FPGA uses Look-Up Tables (LUTs) that can implement any combination of gates. But understanding gates is essential because:

  • LUTs implement gate functions: the truth table you program into a LUT is a gate combination
  • Your HDL code describes gate-level behavior, even when you write at a higher abstraction level
  • Timing analysis and optimization requires understanding how signals propagate through gate chains
  • Boolean algebra (simplifying gate expressions) directly reduces the resources your design uses

We'll explore LUTs in detail in the Look-Up Tables lesson.

Frequently Asked Questions

What are logic gates?

Logic gates are the fundamental building blocks of digital circuits. Each gate takes one or more binary inputs (0 or 1) and produces a single binary output based on a simple rule. The basic gates are AND (output is 1 only when all inputs are 1), OR (output is 1 when any input is 1), and NOT (flips the input). All digital systems, from calculators to supercomputers, are built from combinations of these gates.

How many types of logic gates are there?

There are seven standard logic gates: AND, OR, NOT (the three basic gates), NAND (NOT-AND), NOR (NOT-OR), XOR (exclusive OR, where the output is 1 when inputs differ), and XNOR (exclusive NOR, where the output is 1 when inputs are the same). In practice, NAND and NOR are especially important because any other gate can be built using only NAND gates or only NOR gates.

What is a NAND gate and why is it special?

A NAND gate outputs 0 only when all inputs are 1, which is the opposite of AND. NAND is called a "universal gate" because you can build any other logic gate (AND, OR, NOT, XOR) using only NAND gates. This makes it the most important gate in chip manufacturing, and most real FPGA lookup tables are essentially programmable NAND-like structures.

Quick Check

Test your understanding of the key concepts from this lesson.