GCSE OCR Computer Science: Logic Diagrams and Truth Tables
Logic Diagrams and Truth Tables
Binary situations in daily life and computing represent states that can only be in one of two conditions (e.g., Stop/Go, On/Off).
In computing terms:
A binary represents True.
A binary represents False.
Boolean operators (, , ) are used in programming constructs such as statements and loops.
The Three Fundamental Logic Gates
AND Gate:
Logic statement:
Output is (True) only if both inputs are .
OR Gate:
Logic statement:
Output is (True) if either input is .
NOT Gate:
Logic statement:
Output is the opposite of the input (inversion).
Truth Tables
A truth table displays the output for all possible combinations of inputs from a Boolean expression.
For two inputs ( and ), there are four possible combinations:
AND Truth Table
Input | Input | Output |
|---|---|---|
OR Truth Table
Input | Input | Output |
|---|---|---|
NOT Truth Table
Input | Output |
|---|---|
Logic Statement Evaluations
(4 > 3) \text{ AND } (5 > 7): False
(2 < 8) \text{ OR } (8 > 10): True
\text{NOT } (5 \times 7 > 30): False
$(((7 \text{ DIV } 3) \geq 2) \text{ OR } ((7 \text{ DIV } 3) < 2)): True\n- $(((12 \text{ MOD } 5) < 2) \text{ AND } ((12 \text{ MOD } 5) == 2)): False
Note: gives integer division; gives the remainder.
Combining Logic Gates
Complex circuits can be built by combining fundamental gates.
Example: Security Lighting
Logic requirement: The light () must come on if it senses movement () AND it is night time (), OR if a manual override button () is pressed.
Logic Statement:
Intermediate result () represents .
Questions & Discussion
Starter Activity: The Safe Problem
Prompt: Consider a safe with two keys. If both keys are used, the safe will open ( ). What are the only possible values that key1 and key2 can be?
Response: They can only be True or False (lock or unlock).
Prompt: What values must they be to open the safe?
Response: They must both be True.
Plenary Review
Question: What are the three basic logic gates?
Answer: , , and .
Question: Explain what each logic gate does.
Answer: requires both inputs to be True for a True output; requires at least one input to be True; outputs the opposite of the input.
Question: What is a truth table?
Answer: It shows all possible combinations of inputs and the outputs they create.