In this lesson, you will learn how basic logic gates act as the "decisions" that power every computer by processing binary inputs.
What is a Logic Gate?
At its simplest level, a logic gate is an electronic component that takes one or more binary inputs (0 or 1) and produces a single output based on a fixed rule. You can think of a 0 as "Off" (or Low voltage) and a 1 as "On" (or High voltage).
The Fundamental Gates
The behavior of these gates is best visualized through a Truth Table, which maps every possible input combination to an output.
- NOT: Inverts the signal. If input is
0, output is1. - AND: Outputs
1only if both inputs are1. - OR: Outputs
1if at least one input is1.
| Input A | Input B | AND Output | OR Output |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 |
Universal and Exclusive Gates
Some gates are combinations of the basics, serving specific architectural needs:
- NAND & NOR: These are "Not-AND" and "Not-OR." They act exactly like their counterparts, but their output is flipped (e.g., NAND outputs
0only when both inputs are1). - XOR (Exclusive OR): Outputs
1only if the inputs are different. If both are0or both are1, it outputs0. - XNOR: The exact inverse of XOR; it outputs
1only if the inputs are the same.
Visualizing Logic
In computer architecture, we represent these as simple mathematical functions. If we let A and B be our inputs, the XOR gate logic looks like this:
If (A != B) Output = 1
Else Output = 0
By chaining these gates together, we can perform complex tasks like adding numbers or storing memory. Every processor instruction, from loading data to jumping through code, is ultimately just a result of these gates reacting to bits.
Key Takeaway: Logic gates are the building blocks of computing, using binary rules to transform input states into meaningful output decisions.