1.Why should I care?
This lesson opens the computer architecture thread. A processor is built from billions of gates, but there are only a handful of kinds. Learn their rules now and you can follow a signal all the way from a switch to an adder, and later to a whole CPU.
- ◇ Write the truth tables of NOT, AND, OR, NAND, NOR and XOR.
- ◇ Explain that a truth table with n inputs has 2ⁿ rows and describes a gate completely.
- ◇ Connect a logic level to a voltage and a gate to transistors made of doped silicon.
2.Watch
→ Notice how each gate is first built from transistors acting as switches, before it becomes a symbol.
Introduces AND, OR, NOT and XOR, the building blocks behind every digital decision a computer makes.
10 min 7 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
The video is optional: everything you need is also in the lesson text and the interactive.
3.Predict
A truth table lists the output for every possible combination of inputs. How many rows does a gate with three inputs need?
Guess first. Being wrong here is how the surprise works.
4.Discover
In the logic lab, start from the 'One gate' preset. Change the gate to each type in turn (AND, OR, NAND, NOR, XOR) and toggle A and B through all four combinations. Copy each live truth table into your notebook. Which two gates are exact opposites of each other?
Explorer 05 — Digital logic
Build answers out of ones and zeros
Every digital chip is built from a handful of simple gates. Flip the inputs to watch signals travel through a circuit, then wire your own gates to meet a target truth table.
- 1 (high)
- 0 (low)
- Unknown
- Inverting output
A single two-input gate. Change its type and watch the truth table change.
Inputs
Gates (1 of 8)
G1 = 0
Add a gate
Outputs
- Gates
- 1
- Depth
- 1
- Longest chain of gates a signal passes through
- Rows
- 4
- 2^2 input combinations
- Check
- —
| Set inputs | A | B | Y |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 1 |
State
Inputs A = 0, B = 0. Outputs Y = 0.
Inputs A = 0, B = 0. Outputs Y = 0.
How to read this
Signals flow left to right. Circles on the left are the inputs, boxes are gates and squares on the right are outputs. A thick bright wire carries a 1, a thin grey wire carries a 0, and each gate shows the value it outputs. A small circle on a gate's output means it inverts (NOT, NAND, NOR, XNOR).
The truth table lists every possible input combination and what the circuit outputs for each, so it describes the circuit completely. Two circuits with the same truth table are equivalent, however differently they are built. That is why NAND alone can make any other gate. Choose a row to set the inputs to it.
Assumptions & limitations
- Ideal logic: every wire is exactly 0 or 1. Real gates use voltage ranges (for example near 0 V and near 3.3 V or 5 V) and an input between them is undefined.
- Gates switch instantly here. Real gates take nanoseconds each, so a deeper circuit is slower, and outputs can glitch briefly while signals race through different paths.
- Only combinational circuits are allowed: no output may feed back into its own input. Feedback is how memory (latches and flip-flops) works, but it needs timing this model does not simulate, so loops are reported as an error.
- Gates here have one input (NOT) or two inputs. Real chips also have three- and four-input gates, and limits on how many inputs one output can drive (fan-out).
- Gate counts are a simple measure of size; real designs also weigh speed, power and the number of transistors per gate.
Can't use the interactive? Read a description instead
In the logic lab's one-gate preset, toggling inputs A and B through 00, 01, 10 and 11 gives: AND 0,0,0,1; OR 0,1,1,1; NAND 1,1,1,0; NOR 1,0,0,0; XOR 0,1,1,0. OR and NOR are exact opposites, as are AND and NAND.
5.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
When does A XOR B output 1?
Practice 2 · a fresh version every time
With A = 0, B = 1 and C = 0, what is Y = ¬A ⊕ C? Answer 0 or 1.
6.Understand
Bits as voltages
Digital circuits treat a voltage near the supply (say 3.3 V or 5 V) as 1 and near 0 V as 0. Anything in between is avoided. Because only two levels matter, small amounts of noise do not change the answer.
The basic gates
NOT flips its input. AND gives 1 only if all inputs are 1. OR gives 1 if any input is 1. XOR gives 1 if the inputs differ. NAND and NOR are AND and OR followed by NOT. Engineers write them as ¬A, A·B, A + B and A ⊕ B.
A truth table says everything
List every input combination in counting order (00, 01, 10, 11) and write the output. That table completely defines the gate: two circuits with the same truth table do the same job, however different they look.
Gates are made of transistors
A transistor is a switch made from doped silicon (week 10): a voltage on one terminal lets current flow between the other two. Two transistors in series make a NAND-like path; in parallel, a NOR-like one. That is how a material property becomes logic.
Explain it another way
AND is two light switches in series: both must be on. OR is two switches in parallel: either will do. NOT is a switch that is on when you are not pressing it.
Boolean functions map {0,1}ⁿ to {0,1}. Logic families such as CMOS implement them with complementary transistor networks so that the output is always driven firmly to one rail or the other.
There are 2ⁿ input rows, and each row's output can be 0 or 1, so there are 2^(2ⁿ) different n-input functions: 16 for two inputs, 256 for three.
A car's interior light comes on if the driver's door OR the passenger's door is open. A lift moves only if the doors are closed AND a floor is selected. Logic gates make these rules physical and fast.
Worked example 1
Write the truth table of A NAND B.
AND gives 0, 0, 0, 1 for AB = 00, 01, 10, 11. NOT flips each: NAND = 1, 1, 1, 0. It is 0 only when both inputs are 1.
Common mix-ups
- OR means one or the other but not both.
✓ In logic, OR includes the case where both are 1. 'One but not both' is XOR. - Logic 1 always means exactly 5 V.
✓ It means 'near the high supply rail', which might be 5 V, 3.3 V or 1.8 V depending on the chip.
7.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 3
How many rows does the truth table of a 4-input gate have?
Practice 4 · a fresh version every time
With A = 1, B = 0 and C = 0, what is Y = (C ⊕ B) ⊕ A? Answer 0 or 1.
Practice 5
Which gate's truth table is the exact opposite (every output flipped) of OR?
8.Apply it
Choose a machine at home or school (a microwave, a lift, a printer). Write three of its rules as gates, for example 'heat only if door closed AND timer running'. For one rule, write the full truth table and test it in the logic lab.
9.Reflect
Concepts: Logic gates and Boolean algebra