Logic Gate Truth Tables: Your Essential Reference Guide
TL;DR: A truth table lists every possible input combination and the deterministic output a logic gate produces. This reference covers all seven standard gates — AND, OR, NOT, NAND, NOR, XOR, XNOR — with Boolean expressions and tables, plus a worked example showing how four NAND gates can replicate XOR behavior.
A truth table is the definitive specification of a logic gate. It enumerates every possible input scenario and the single, deterministic output the gate will produce. Reading and writing truth tables is the foundation skill of digital design — the same notation appears later in Karnaugh maps, Sum of Products derivations, and circuit verification.
The Basic Gates: The Primitives of Computation
The foundational gates—AND, OR, and NOT—are the primary colors of our digital palette. Every complex logical function can, in theory, be painted using combinations of these three.
NOT Gate (The Inverter)
The NOT gate is the simplest of all. It has a single input and a single output. Its job is to invert the input signal. If you give it a 1, it gives you a 0. If you give it a 0, it gives you a 1. It is the logical embodiment of opposition.
Boolean Expression:
| Input (A) | Output (Y) |
|---|---|
| 0 | 1 |
| 1 | 0 |
AND Gate
The AND gate is the gate of conditions. It outputs a 1 only if all of its inputs are 1. Think of it as a strict security checkpoint: if you need both ID and a ticket to enter, you need ID = 1 AND Ticket = 1. Anything less, and the output is 0.
Boolean Expression:
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR Gate
The OR gate is the gate of options. It outputs a 1 if any of its inputs are 1. It’s the lenient counterpart to the AND gate. If you can enter a venue with either a ticket OR an invitation, you only need one of them to be true (= 1) to get in.
Boolean Expression:
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The Surprising Power of Universal Gates
You don’t actually need AND, OR, and NOT to build any digital circuit. Every Boolean function can be built using a single gate type. This property is called universality, and the two gates that possess it are NAND and NOR.
Why is this important? In manufacturing, consistency is king. Fabricating millions of transistors to create just one type of gate (like NAND) is far more efficient and cost-effective than creating multiple different types. This is the secret behind the economics of silicon chips.
NAND Gate (NOT-AND)
The NAND gate is an AND gate followed by a NOT gate. It produces the exact opposite output of an AND gate. It outputs a 0 only if all its inputs are 1.
Boolean Expression:
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR Gate (NOT-OR)
Similarly, the NOR gate is an OR gate followed by a NOT gate. It outputs a 1 only if all its inputs are 0.
Boolean Expression:
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
To prove their universality, you can construct the three basic gates using only NAND gates:
- NOT Gate: Tie the inputs of a NAND gate together. An input of
AbecomesAon both inputs, so the output is . - AND Gate: Pass the output of a NAND gate through a NAND gate configured as a NOT gate. The output is .
- OR Gate: Invert both inputs
AandB(using NAND-as-NOT gates) and feed them into a third NAND gate. By De Morgan’s laws, the output is .
The Exclusive Gates: The Difference Detectors
These gates handle a special kind of logic based on whether the inputs are the same or different.
XOR Gate (Exclusive-OR)
The XOR gate is the “one or the other, but not both” gate. It outputs a 1 only when its inputs are different. This behavior is incredibly useful for arithmetic and error-checking.
Boolean Expression:
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XNOR Gate (Exclusive-NOR)
The XNOR gate is the logical inverse of XOR. It’s an equality detector, outputting a 1 only when its inputs are the same.
Boolean Expression:
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Simulating on digisim.io
Building a circuit makes a truth table concrete. To demonstrate the universality of the NAND gate, construct an XOR gate from four NAND gates.
- Open the Workspace: Navigate to the digisim.io simulator. You’ll see a blank canvas.
- Place Components:
- Drag two Input Switches onto the canvas. Label them ‘A’ and ‘B’.
- Drag four 2-Input NAND gates onto the canvas.
- Drag one Output LED onto the canvas. Label it ‘Y’.
- Wire the Circuit:
- Connect input
Ato the first input of NAND gate #1 and the first input of NAND gate #2. - Connect input
Bto the second input of NAND gate #1 and the first input of NAND gate #3. - Connect the output of NAND gate #1 to the second input of both NAND gate #2 and NAND gate #3.
- Connect the output of NAND gate #2 to the first input of NAND gate #4.
- Connect the output of NAND gate #3 to the second input of NAND gate #4.
- Finally, connect the output of NAND gate #4 to the Output LED ‘Y’.
- Test the Truth Table: Now, toggle the input switches for A and B and observe the LED.
A=0, B=0: The LED is OFF (0).A=0, B=1: The LED is ON (1).A=1, B=0: The LED is ON (1).A=1, B=1: The LED is OFF (0).
You’ve just experimentally verified the truth table for an XOR gate using nothing but NAND gates. You have proven the principle of universality in a hands-on, interactive way.
Real-World Use Cases
These abstract gates are the workhorses inside the devices you use every day.
- XOR in RAM Parity Checking: Your computer’s memory (DRAM) is not perfect; bits can occasionally flip due to radiation or electrical noise. To detect this, many systems use a parity bit. For every 8 bits of data, a 9th bit is stored. This bit is calculated by XORing the 8 data bits together. If an odd number of bits are 1, the XOR result (the parity bit) is 1. If an even number are 1, it’s 0. When the data is read back, the calculation is performed again. If the new result doesn’t match the stored parity bit, the system knows an error has occurred.
- AND in CPU Arithmetic Logic Units (ALUs): The ALU is the mathematical brain of a CPU. When you perform a bitwise
ANDoperation in a programming language, the CPU routes those bits directly to a bank of AND gates within the ALU. This is also fundamental for “masking,” a technique used to isolate specific bits within a byte. For example, to check if the 4th bit of a byteDis set, a programmer might computeD AND 00001000. If the result is not zero, the bit was set. This simple test, executed billions of times per second, is built directly on the AND gate’s truth table.
Truth tables are more than a reference to be memorized. They are a design tool, a debugging aid, and the definitive specification for the building blocks of our digital world.
Continue with Digital Logic 101 to wire each of these gates yourself, or jump ahead to Boolean algebra fundamentals to manipulate the equations behind the tables.