Ad Banner Placeholder

Cambridge IGCSE Computer Science · 0478

Topic 10: Boolean Logic

Logic Gates, Truth Tables & Logic Circuits

What is Boolean logic?

Boolean logic is a branch of algebra that works with values that can only be true or false. In computer hardware, these are represented as the binary digits 0 (off / false) and 1 (on / true).

Computers are built from millions of tiny electronic switches. Each switch is either on or off. By combining these switches using logic gates, a processor can perform calculations, make decisions, and control devices such as security barriers, traffic lights, and sensors.

Boolean logic in hardware (Topic 10) is closely related to the logical operators AND, OR, and NOT used in pseudocode (Topic 8) — but in this topic you work with logic gate symbols, truth tables, and logic circuit diagrams.

Diagram comparing binary digits 0 and 1 with Boolean values FALSE and TRUE
Diagram 1: Logic circuits use 0 and 1; pseudocode uses FALSE and TRUE — they represent the same two states.

Logic gate symbols

A logic gate is an electronic component that takes one or more binary inputs and produces a single binary output according to a fixed rule. Cambridge IGCSE 0478 requires you to recognise and draw the standard symbols for six gates:

Gate Inputs Function
NOT 1 Inverts the input (0 → 1, 1 → 0)
AND 2 Output is 1 only if both inputs are 1
OR 2 Output is 1 if at least one input is 1
NAND 2 NOT AND — output is the inverse of AND
NOR 2 NOT OR — output is the inverse of OR
XOR (EOR) 2 Exclusive OR — output is 1 if inputs are different
Standard logic gate symbols for NOT, AND, OR, NAND, NOR, and XOR gates
Diagram 2: Standard logic gate symbols used in Cambridge 0478 exams. NAND and NOR have a small circle (bubble) on the output; XOR has an extra curved line on the input side of the OR shape.

Truth tables

A truth table lists every possible combination of inputs and shows the resulting output. For a gate with two inputs (A and B), there are four rows (2² = 4 combinations). For three inputs, there are eight rows (2³ = 8).

Inputs are usually labelled A, B, C on the left of a circuit; the output is labelled X (or sometimes W, Y, or Z).

NOT gate

A X
01
10

AND gate

A B X
000
010
100
111

OR gate

A B X
000
011
101
111
Truth tables for NOT, AND, OR, NAND, NOR, and XOR logic gates
Diagram 3: Complete truth tables for all six logic gates. NAND and NOR outputs are the inverse of AND and OR respectively. XOR outputs 1 only when the two inputs differ.

NAND, NOR, and XOR in detail

NAND gate (NOT AND)

The NAND gate produces the opposite output to an AND gate. Its output is 0 only when both inputs are 1; otherwise the output is 1.

A B X
001
011
101
110

NOR gate (NOT OR)

The NOR gate produces the opposite output to an OR gate. Its output is 1 only when both inputs are 0.

A B X
001
010
100
110

XOR gate (exclusive OR / EOR)

The XOR gate outputs 1 when the inputs are different (one is 0 and the other is 1). When both inputs are the same (both 0 or both 1), the output is 0.

A B X
000
011
101
110

Boolean expressions and logic circuits

A Boolean expression describes the logic of a circuit using operators: NOT, AND, OR, and sometimes XOR. Brackets show which operations are performed first.

Example expression: X = (NOT P AND Q) OR R

To draw a logic circuit from an expression:

  1. Identify the inputs (P, Q, R) on the left.
  2. Work from the innermost brackets outward — draw NOT P first, then feed it and Q into an AND gate.
  3. Feed the AND output and R into an OR gate to produce X.
  4. Label the final output X on the right.
Logic circuit diagram for X equals NOT P AND Q OR R showing NOT, AND, and OR gates
Diagram 4: Logic circuit for X = (NOT P AND Q) OR R. Each gate has at most two inputs; the circuit matches the expression exactly without simplification.

Completing truth tables for expressions

To complete a truth table for a complex expression such as X = (NOT P AND Q) OR R:

  1. List every combination of the input columns (P, Q, R) — 8 rows for three inputs.
  2. Add intermediate columns for each sub-expression, working from inside the brackets outward: first NOT P, then (NOT P AND Q), then the final X.
  3. Fill each column by applying the gate rule row by row.
Step-by-step truth table for X equals NOT P AND Q OR R with intermediate columns
Diagram 5: Worked truth table with intermediate columns. Add columns for each stage inside the brackets before calculating the final output.

Shortcut for OR: once you have the (NOT P AND Q) column, X is 1 on any row where that column is 1 or R is 1.

Boolean algebra rules

These identities help you understand and check circuits (you will not usually be asked to simplify expressions in Paper 2, but they help with truth tables):

Rule Example
NOT NOT A = A Inverting twice returns the original value
A AND 1 = A  ·  A AND 0 = 0 AND with 1 leaves A unchanged; AND with 0 forces 0
A OR 0 = A  ·  A OR 1 = 1 OR with 0 leaves A unchanged; OR with 1 forces 1
De Morgan's: NOT (A AND B) = (NOT A) OR (NOT B) NOT distributes over AND by becoming OR with inverted inputs
De Morgan's: NOT (A OR B) = (NOT A) AND (NOT B) NOT distributes over OR by becoming AND with inverted inputs

Real-world applications

Logic gates are found throughout digital systems:

  • CPU — millions of gates perform arithmetic and comparisons.
  • Security systems — a barrier may open only when a valid ticket AND a clear sensor signal are both present.
  • Memory — solid-state flash storage uses NAND gate technology (see Topic 3).

NAND and NOR are called universal gates because any other gate can be built using only NAND gates (or only NOR gates). For example, connecting both inputs of a NAND gate together creates a NOT gate.

Applications of Boolean logic in CPUs, security systems, and NAND memory technology
Diagram 6: Boolean logic in CPUs, security systems, and NAND flash memory. NAND is a universal gate — NOT can be made by feeding the same input to both pins of a NAND gate.

0/15

Ad Banner Placeholder