Logic Gate Truth Tables: Your Essential Reference Guide
Master digital logic with this comprehensive reference on logic gate truth tables. Covers all standard gates, Boolean expressions, and practical applications for digital design.
In the grand architecture of digital computing, from the simplest pocket calculator to the most complex supercomputer, every decision, every calculation, and every operation boils down to a series of simple "yes" or "no" questions. The components that ask and answer these questions are called logic gates. But how does a gate know how to answer?
The answer lies in its truth table. A truth table is the unchangeable constitution of a logic gate. It is a simple, elegant, and absolute definition of its behavior, listing every possible input scenario and the single, deterministic output it will produce. To understand truth tables is to understand the fundamental language of digital circuits. Let's decode this language together.
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: $Y = \overline{A}$
| 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: $Y = A \cdot B$
| 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: $Y = A + B$
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The "Gotcha": The Surprising Power of Universal Gates
Here's a fact that surprises many students: you don't actually need AND, OR, and NOT gates to build any digital circuit. You can build everything using only one type of gate. 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: $Y = \overline{A \cdot B}$
| 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: $Y = \overline{A + B}$
| 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 $\overline{A \cdot A} = \overline{A}$. - AND Gate: Pass the output of a NAND gate through a NAND gate configured as a NOT gate. The output is $\overline{\overline{A \cdot B}} = A \cdot B$.
- 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 $\overline{\overline{A} \cdot \overline{B}} = A + B$.
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: $Y = A \oplus B = \overline{A}B + A\overline{B}$
| 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: $Y = \overline{A \oplus B} = AB + \overline{A}\overline{B}$
| Input (A) | Input (B) | Output (Y) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Simulating on digisim.io
Reading about truth tables is one thing; proving them for yourself is another. This is where simulation becomes an indispensable tool for learning. Let's build a circuit to prove the universality of the NAND gate. We will 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'.
- Connect input
- 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.
Ready to see this in action? Head over to digisim.io and build your own circuits. Verify the truth tables, test the principle of universality, and start turning logic into function today