9618 AS Computer Science - Boolean Logic
Electronic circuits in computers, memories, and controlling devices are made up of thousands of LOGIC GATES. Logic gates take binary inputs and produce a binary output. They look at two or more inputs and use these to determine the outputs from the circuit. The process uses electronic logic, which is based on digital switches called gates.
A logic gate is a simple electronic circuit which processes two-state signals according to logical rules. Each gate has one or more inputs and a single output. Logic gates take binary inputs (0 or 1) and produce a binary output based on the logical operation performed.
Truth tables are used to show logic gate functions and trace the output from a logic gate or logic circuit. They represent all possible inputs and the associated outputs for a given Boolean expression.
The number of possible combinations is calculated using:
When constructing truth tables, always start with all 0s and count up in binary. For example, with 3 inputs (A, B, C): 000, 001, 010, 011, 100, 101, 110, 111. This ensures you don't miss any combinations!
Boolean algebra uses special symbols to represent logic operations:
| Operation | Logic Notation | Boolean Algebra |
|---|---|---|
| AND | X = A AND B | X = A · B |
| OR | X = A OR B | X = A + B |
| NOT | X = NOT A | X = Ā (bar over letter) |
The NOT gate is unique because it has only one input. Its main function is to invert the input signal applied. If the applied input is 0, the output becomes 1, and vice versa.
NOT = "NOT what you put in" - Whatever you input, the output is the OPPOSITE. Think of it as a "contrarian" gate that always disagrees!
The AND gate outputs 1 (TRUE) only when ALL inputs are 1 (TRUE). If any input is 0, the output is 0.
AND = "All or Nothing" - Think of a strict parent: "You can go out ONLY IF you finish homework AND clean your room!" Both conditions must be true for the output to be true.
The OR gate outputs 1 (TRUE) when AT LEAST ONE input is 1 (TRUE). Only when ALL inputs are 0 does the output become 0.
OR = "One is Enough" - Think of ordering pizza: "I'll eat pizza if it has pepperoni OR mushrooms." You're happy if either topping (or both) is present!
The NAND gate is the opposite (inverse) of the AND gate. It outputs 0 only when ALL inputs are 1. In all other cases, the output is 1.
The NAND gate truth table is the exact opposite of AND gate. Compare: AND gives 1 only when both inputs are 1; NAND gives 0 only when both inputs are 1. Quick way to remember: NAND = NOT AND
NAND = "Not ANd'D" - It's like an AND gate that rebels! Whatever AND does, NAND does the opposite. NAND is also called a "universal gate" because you can build ANY other logic gate using only NAND gates!
The NOR gate is the opposite (inverse) of the OR gate. It outputs 1 only when ALL inputs are 0. If any input is 1, the output is 0.
NOR gives TRUE only when ALL inputs are FALSE. It's the most "negative" gate - it says "NO" to everything except when all inputs are off. Remember: NOR = NOT OR
NOR = "NO Results" - NOR is like a strict parent who says "NO" to everything! The only time you get a YES (1) is when there's absolutely nothing to say no to (all inputs are 0).
The XOR gate (Exclusive OR) outputs 1 when the inputs are different. If both inputs are the same (both 0 or both 1), the output is 0.
XOR = "eXclusive OR" = "One OR the Other, NOT Both" - Think of ordering food: "Would you like cake OR ice cream?" You can have ONE, but not both! XOR is picky - it only likes DIFFERENT inputs.
Here is a quick reference summary of all six logic gates with their functions and truth tables:
| Gate | Output = 1 When... | Quick Memory |
|---|---|---|
| NOT | Input is 0 | Opposite of input |
| AND | ALL inputs are 1 | Both must be TRUE |
| OR | ANY input is 1 | At least one is TRUE |
| NAND | NOT all inputs are 1 | Opposite of AND |
| NOR | ALL inputs are 0 | Opposite of OR |
| XOR | Inputs are DIFFERENT | One OR other, not both |
Both NAND and NOR gates are called universal gates because you can construct ANY other logic gate using only NAND gates or only NOR gates. This is important in electronics manufacturing because using just one type of gate can reduce costs.
When logic gates are combined together to carry out a particular function, such as controlling a robot, they form a logic circuit (also called a logic network). The output from a logic circuit is checked using a truth table.
When creating truth tables for complex circuits, work left to right through the circuit. Label intermediate outputs (P, Q, R, etc.) and calculate them one at a time. This reduces errors and makes it easier to check your work.
Converting a problem statement into a logic circuit involves identifying key words and translating them into logic operations.
| Key Word | Logic Operation | Example |
|---|---|---|
| "AND", "both", "all" | AND gate | "A and B" → A AND B |
| "OR", "either", "at least one" | OR gate | "A or B" → A OR B |
| "NOT", "opposite", "inverse" | NOT gate | "not A" → NOT A |
| "ON" / "OFF" | 1 / 0 | "switch is ON" = 1 |
Let's apply our knowledge to a practical example involving a wind turbine safety system.
A wind turbine has a safety system which uses three inputs to a logic circuit. Output X = 1 shuts down the turbine. The parameters being monitored are:
| Parameter | Symbol | Value = 1 When... |
|---|---|---|
| Turbine Speed | S | > 1000 rpm |
| Bearing Temperature | T | > 80°C |
| Wind Velocity | W | > 120 kph |
Answer:
| A | B | NOT B | X = A AND NOT B |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
Marking points: 1 mark for correct A/B columns, 1 mark for NOT B column, 2 marks for final X column
Answer:
Logic Expression: X = (A AND NOT B) OR (B AND NOT C)
Logic Circuit:
Marking points: 2 marks for correct logic expression, 4 marks for correct circuit (1 per gate)
Answer:
Additional points for deeper understanding:
Marking points: 2 marks for function description, 2 marks for universal gate explanation
Answer:
| A | B | C | A OR B | X |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
Marking points: 1 mark for input columns, 2 marks for intermediate column, 2 marks for output column
Answer:
The logic circuit requires:
Marking points: 2 marks for XOR gate, 1 mark for NOT gate, 2 marks for correct OR gate connection
Answer:
Step 1: Convert conditions to logic:
Step 2: Write logic expression:
Marking points: 1 mark each for correct identification of conditions, 1 mark for correct expression
Answer:
OR Gate:
XOR Gate:
Key Difference: OR includes the case where both inputs are 1; XOR excludes it (both inputs being 1 gives 0)
Marking points: 2 marks for OR explanation, 2 marks for XOR explanation, 2 marks for examples
| A | B | X |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Answer:
Step 1: Identify rows where X = 1
Step 2: Write expression for that row
Logic Expression:
Logic Circuit: NOR gate with inputs A and B
Marking points: 2 marks for identifying correct row(s), 2 marks for correct expression, 2 marks for circuit
Answer:
Step 1: Define binary values:
Step 2: Write the conditions:
Logic Expression:
Alternative form: F = (T AND H) AND (NOT D) AND (NOT M)
Marking points: 2 marks for condition identification, 3 marks for correct expression
Answer:
| A | B | C | A AND B | B OR C | X |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 | 0 |
Marking points: 1 mark for input columns, 2 marks for A AND B column, 2 marks for B OR C column, 1 mark for X column
Additional insight: Note that X = 0 when both intermediate values are the same (both 0 or both 1)
| Gate | Memory Phrase |
|---|---|
| NOT | "NOT what you put in" - Always opposite |
| AND | "All or Nothing" - Both must be TRUE |
| OR | "One is Enough" - Any TRUE gives TRUE |
| NAND | "NOT ANd'D" - Opposite of AND |
| NOR | "NO Results" - Only TRUE when all FALSE |
| XOR | "eXclusive OR" - Different inputs = TRUE |
The Boolean operators are named after George Boole (1815-1864), an English mathematician who developed Boolean algebra. His work forms the mathematical foundation of all modern digital computers! Every calculation your computer does ultimately relies on these simple logic operations.