Digital Logic Fundamentals
Senior 4 · ICT
Digital Logic Fundamentals
Lesson 2 of 5
25 min
In 1854 the English mathematician George Boole published An Investigation of the Laws of Thought, in which statements that are either true or false are combined with operations, just as numbers are combined with + and ×. For eighty years it looked like pure mathematics. Then, in 1937, the American engineer Claude Shannon showed in his master's thesis that circuits of switches obey exactly Boole's rules. Every digital device since, from a calculator to a smartphone, is built from circuits that compute Boolean algebra.

Definition
Boolean variable: a quantity with only two values, written 1 (true, on, high voltage) and 0 (false, off, low voltage).
Logic gate: an electronic circuit with one or more binary inputs and one binary output, whose output is a Boolean function of its inputs.
Truth table: a table listing every combination of input values with the output for each. With inputs there are rows.
Boolean expression: a formula built from variables with AND (written or ), OR () and NOT (, read "A bar" or "not A").
Think of switches in a lamp circuit. Two switches in series light the lamp only if both are closed; two in parallel light it if either is closed.
Order of operations: brackets first, then NOT, then AND, then OR. So means , just as .
Combining NOT with AND and OR gives the inverted gates NAND and NOR. XOR (exclusive OR) is 1 when the inputs are different, and XNOR when they are the same.
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
NOT has one input: ; . Each inverted gate's column is the opposite of its partner's: compare AND with NAND, OR with NOR, XOR with XNOR.

NAND and NOR are called universal gates: any circuit can be built from NAND gates alone (or NOR gates alone). For example, joining both inputs of a NAND gate gives , a NOT gate; a NAND followed by that NOT gives AND. Chip makers like this, because one kind of gate is cheaper to make in large numbers, which is why the 7400 chip above is a NAND chip.
Crash Course Computer Science #3: Boolean Logic and Logic Gates. Watch how AND, OR, NOT and XOR are built from transistors, and how the gate symbols correspond to the truth tables in this lesson.
Worked example 1: evaluate an expression
Find when , , .
Now complete the truth table of :
| A | B | Y | ||||
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 | 0 |
The output column 0, 1, 1, 0 is the XOR column, so .
Worked example 2: from words to Boolean algebra
A water pump on a school's tank must run () when its switch is on () and the tank is not full (). Write .
"Switch on" is ; "tank not full" is ; "and" is AND: Check: switch on, tank full: , so the pump stops and the tank does not overflow.
Warning
OR is not "one or the other but not both". In logic, : OR is true when both inputs are 1. "One or the other but not both" is XOR.
is not . A bar over the whole term (NAND) is different from bars over each letter. With : but . Lesson 5 gives the rule (De Morgan's law) that links them.
Tip
One word per gate. AND: all. OR: any. XOR: different. XNOR: same. NAND and NOR: the opposite of AND and OR. A bubble always means NOT.
Practice
Key points
Sources and credits
This lesson adapts CC BY-SA material and is shared under CC BY-SA 4.0.
Quick check
Which gate gives 1 only when its two inputs are different?