Logic Gates
1. What are Logic Gates?
Definition: Logic gates are used in digital electronics and are used to create electronic circuits.
- Gates work on Boolean values = values with only 2 possible states → 0 and 1. Inputs are 0/1 and the output is 0/1.
- Used to build monitoring & control systems (sensors → logic → actuator). Any circuit you create uses gates.
- We pick the gate that gives the output we want: e.g. input 0, 0 must give 0 → choose the right gate.
In real life a gate is just wires + breadboard + transistors arranged to do the same processing. (At university, in digital electronics, you even learn how to build AND / OR / NOR from transistors.) It is not software either — wires carry the 0s and 1s.
Logic gate = one single gate. Logic circuit = a combination of different logic gates joined together.
2. Symbols of Logic Gates
There are 6 types of gates: NOT, OR, AND, NAND, NOR, XOR. Learn to draw every one — relate each symbol to a shape so it sticks.
- NOT = triangle + circle (bubble)
- OR = like a little fish (curved back, pointed nose)
- AND = the letter D
- NAND = AND + circle | NOR = OR + circle
- XOR = OR + one extra curved line (a "parenthesis") at the back
The lines on the left = number of inputs: NOT has only 1 input; AND, OR, NAND, NOR, XOR each have 2 inputs (called A and B). One output → X.
3. Truth Tables
- Truth tables are used to trace the output from a logic gate or logic circuit.
- The NOT gate is the only logic gate with one input.
- When constructing truth tables, all possible combinations of 1s and 0s are considered.
Link with Paper 2: a truth table is just like a trace table — there you dry-run the code step by step and note every value, then write the final output. Here you trace the values through the gates one by one and note the output. A truth table has two things: input values and output values.
| A | B |
|---|---|
| 0 | 0 |
| 0 | 1 |
| 1 | 0 |
| 1 | 1 |
| A | B | C |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
| 1 | 1 | 1 |
② Quick trick to fill the input columns (≈ 5 seconds!)
- Find rows = 2n (e.g. 3 inputs → 8).
- Column A: rows ÷ 2 → that many 0s, then that many 1s (8 ÷ 2 = 4×0, 4×1).
- Column B: halve again → 2×0, 2×1, 2×0, 2×1.
- Column C: halve again → 1×0, 1×1 repeated. Keep halving until you reach 1.
| Inputs | rows | A | B | C | D |
|---|---|---|---|---|---|
| 2 | 4 | 2×0, 2×1 | 1×0, 1×1 … | ||
| 3 | 8 | 4×0, 4×1 | 2×0, 2×1 … | 1×0, 1×1 … | |
| 4 | 16 | 8×0, 8×1 | 4×0, 4×1 … | 2×0, 2×1 … | 1×0, 1×1 … |
4. The Six Gates in Detail
① NOT gate — the INVERSE
| A | X |
|---|---|
| 0 | 1 |
| 1 | 0 |
Rule: NOT just inverts the input: 0 → 1 and 1 → 0. Easiest word to remember it: INVERSE.
1 input ⇒ 2¹ = 2 rows (only 0 and 1).
X = NOT A (Logic notation)
X = A (Boolean algebra)
A bar (dash) over a letter ⇒ a NOT gate is used.
② OR gate
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
If even one input is 1, then the output is 1.
Memory link: addition — but do not confuse it with binary addition (here 1 + 1 gives 1).
X = A OR B (Logic notation)
X = A + B (Boolean algebra)
③ AND gate
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
If even one input is 0, then the output is 0.
X = A AND B (Logic notation)
X = A·B (Boolean algebra)
④ NAND gate
| A | B | X |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Inverse the output of AND.
X = A NAND B (Logic notation)
X = A·B (Boolean algebra)
Boolean form = the AND form with a bar over the whole A·B (A·B is treated as one output, then NOT'd).
⑤ NOR gate
| A | B | X |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Inverse the output of OR.
X = A NOR B (Logic notation)
X = A + B (Boolean algebra)
0, 0 → OR gives 0 → write 1. 0, 1 → OR gives 1 → write 0. Same idea: solve as OR, then invert.
⑥ XOR gate (exclusive OR)
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Same inputs → output 0.
Different inputs → output 1.
X = A XOR B (Logic notation)
X = A ⊕ B (Boolean algebra)
⊕ = a plus with a circle — a "+" because XOR comes from OR, hence its other name: exclusive OR.
5. How Questions Come — the 5 Cases
Questions are all alike: "draw a logic circuit, fill a truth table". Sometimes the table is half-filled for you, sometimes you fill it all. Only the starting point changes → we group them into 5 cases:
| Case | Given | You must… | |
|---|---|---|---|
| 1 | logic expression | construct the logic circuit | |
| 2 | logic circuit | construct the truth table | |
| 3 | logic circuit | write the logic expression | |
| 4 | truth table | write the logic expression | A2-type |
| 5 | problem statement | construct the logic circuit | hardest-looking |
6. Case 1 — Circuit from a Logic Expression
Idea: you know every gate now, so just build the expression piece by piece. Brackets first — exactly like basic algebra / BODMAS: solve the bracket, then use its answer with the rest.
- Build the bracket part first (inside gates).
- Take that bracket's output and combine it with the remaining variable using the next gate.
- Connect the last gate to X. The order of the two inputs of a gate does not matter.
Draw a logic circuit for X = A OR (B AND NOT C)
Bracket first: B AND NOT C → B as it is; NOT gate on C (NOT C); these two go into an AND. That output is then ORed with A → X.
Draw the circuit for X = NOT (A AND B) OR NOT (NOT B OR C) using a maximum of four gates.
Why: "NOT of AND" = NAND and "NOT of OR" = NOR, so the outer NOTs are absorbed — that is how you stay within 4 gates. (NAND = AND + NOT would also be correct but uses more gates.)
Draw a circuit for X = A OR (B AND NOT C) OR (A AND B)
Part ① = A OR (B AND NOT C) → exactly the circuit above.
Part ② = (A AND B) → one AND gate.
Finally OR part ① with part ② → X. (Do part ① first or last — like addition, the order does not matter. Treat each part as its own little circuit.)
Draw a circuit for X = NOT (A AND B) AND (C XOR D)
A, B → NAND | C, D → XOR | both answers → AND → X.
7. Case 2 — Truth Table from a Logic Circuit
You must know each gate's rule (e.g. AND: any 0 → 0). Use the working space given — it makes the question easy.
- Inputs: write all 2n combinations (halving trick).
- Name each gate's output with a letter (D, E, F … any letters) and write them as columns in the working space, with a line between columns.
- Solve one gate at a time, left → right. For NAND / NOR: solve as AND / OR in your head, then invert.
- The last gate's column is the answer X.
Complete the truth table for the logic circuit shown (3 NOR gates + a final OR).
| A | B | C | D A NOR B | E B NOR C | B copy | F B NOR E | D copy | X D OR F |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
X = 1, 1, 0, 0, 0, 1, 0, 0 (4 marks — fill the table, answer matters most)
(a) Draw the circuit that directly matches: X = 1 IF (A is NOT 1 OR B is 1) AND (B is 1 OR C is 1). (b) Complete the truth table.
Reading it: "A is NOT 1" → NOT gate on A; "B is 1" → just B. First bracket: NOT A OR B (call it D). Second bracket: B OR C (call it E). The two brackets are ANDed → X.
| A | B | C | A | D Ā OR B | E B OR C | X D AND E |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 | 1 |
Complete the truth table for X = NOT (A AND B) OR (A AND (B XOR C))
No circuit is given → make your own names: D = A AND B; E = B XOR C; F = A AND E. Put these in the working space and use them. (XOR is always given with brackets.)
| A | B | C | D A AND B | D NOT D | E B XOR C | F A AND E | X D̄ OR F |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
Tip: if the working space is small, draw a line beside the table and do each AND/OR as "0 and 0 → 0" on paper — don't do it in your head. Marks are given for the answer, not the working — but showing working costs nothing and avoids mistakes.
8. Case 3 — Logic Expression from a Circuit
There are no fixed steps for this — it all depends on your logic, which gets stronger as you practise Case 1. Also write "NOT A" (NOT first, then the letter), never "A NOT".
Write a logic statement that describes the following logic circuit.
9. Case 4 — Logic Expression from a Truth Table
A = 0 (A = "A NOT" → say NOT A; bar means NOT, value 0)
Steps
STEP 1: Mark the rows with output 1 — ignore the rows whose output is 0.
STEP 2: For each marked row write A or A / B or B / C or C — value 1 → plain letter, value 0 → barred letter. Multiply them, then + between rows.
A Boolean algebraic expression produces the truth table below (X = 1 in six rows). Write the expression.
| INPUT A | B | C | OUTPUT X | |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | ✓ |
| 0 | 0 | 1 | 1 | ✓ |
| 0 | 1 | 0 | 1 | ✓ |
| 0 | 1 | 1 | 1 | ✓ |
| 1 | 0 | 0 | 1 | ✓ |
| 1 | 0 | 1 | 1 | ✓ |
| 1 | 1 | 0 | 0 | |
| 1 | 1 | 1 | 0 |
Don't simplify — simplifying with Boolean algebra is A2 and is done later.
10. Case 5 — Circuit from a Problem Statement
You are given a description of a system and must draw its circuit. These look the hardest but are also the easiest questions of the whole chapter — once you can turn the wording into an expression, the rest is Case 1. At first it feels hard; later it becomes easy. This type is an A-Level style (not in O-level).
A bank approves a customer (X = 1) if the person:
- is over 21 and employed
- or
- is over 21 and self-employed and — either earns more than 30 000 or has another account.
| Parameter | Description | 1 = True / 0 = False |
|---|---|---|
| A | Employed | 1 / 0 |
| B | Self-employed | 1 / 0 |
| C | Over 21 | 1 / 0 |
| D | Earn more than 30 000 | 1 / 0 |
| E | Another account | 1 / 0 |
Draw a logic circuit to represent the model.
This is just Case 1 again: make C AND A; make D OR E; make C AND B and AND it with (D OR E); finally OR the two big parts → X. Solve the top part first, then ignore it and solve the bottom part (5 marks).
An alarm system (X) is enabled and disabled using either a switch (A) or a remote control (B). There are two infra-red sensors (C, D) and one door pressure sensor (E).
| Parameter | Description | 1 | 0 |
|---|---|---|---|
| A | Switch | switch enabled | switch disabled |
| B | Remote control | remote enabled | remote disabled |
| C | Infra-red sensor | activated | not activated |
| D | Infra-red sensor | activated | not activated |
| E | Door pressure sensor | activated | not activated |
The alarm sounds (X = 1) if the alarm is enabled and any one or more of the sensors is activated. Draw a logic circuit for the alarm system.
Three-input OR = two OR gates: C OR D first, then that answer OR E. Connect OR(A,B) and the second answer to the final AND → X (3 marks). If asked, you can now also fill its truth table.
11. Exam Tips & Practice
- Practice = marks. Do the topical past papers (especially the drawing / problem-statement questions); each takes only ~5 minutes once you get the logic.
- The main skill is logic building — reading a question and building the expression yourself, especially in problem-statement questions.
- Draw circuits roughly in pencil, then redo in pen. Use a scale / neat drawing only when your time management allows (it comes after practising yearly past papers).
- Truth tables: write all working in the space given, name every gate output, don't solve in your head — exam pressure is high and one wrong bit costs marks.
- Marks are for the final answer (not the working) but still show working.
- Always: expression first, then circuit.
| Gate | Rule (one-liner) | Logic notation | Boolean | 00 | 01 | 10 | 11 |
|---|---|---|---|---|---|---|---|
| NOT | inverse (1 input) | X = NOT A | A | 1 | — | 0 | — |
| OR | any 1 → 1 | X = A OR B | A + B | 0 | 1 | 1 | 1 |
| AND | any 0 → 0 | X = A AND B | A · B | 0 | 0 | 0 | 1 |
| NAND | inverse of AND | X = A NAND B | A·B | 1 | 1 | 1 | 0 |
| NOR | inverse of OR | X = A NOR B | A + B | 1 | 0 | 0 | 0 |
| XOR | same 0, different 1 | X = A XOR B | A ⊕ B | 0 | 1 | 1 | 0 |
NOT row: input 0 → 1, input 1 → 0. Rows in a table = 2n; fill inputs by halving (4×0,4×1 / 2,2 / 1,1).
- 1. Expression → circuit: brackets first; NOT(AND) = NAND, NOT(OR) = NOR.
- 2. Circuit → truth table: all combinations, name each gate output (D, E, F…), fill column by column, copy far inputs beside the column, last column = X.
- 3. Circuit → expression: one bracket per gate, start from the left/top, "NOT A" not "A NOT".
- 4. Truth table → expression: mark X = 1 rows; 1 → A, 0 → A; multiply inside a row, add rows.
- 5. Problem statement → circuit: letters for parameters, and/or from keywords, write expression first, then draw (Case 1).