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 11 represents True.

    • A binary 00 represents False.

  • Boolean operators (ANDAND, OROR, NOTNOT) are used in programming constructs such as IFIF statements and whilewhile loops.

The Three Fundamental Logic Gates

  • AND Gate:

    • Logic statement: P=A AND BP = A \text{ AND } B

    • Output is 11 (True) only if both inputs are 11.

  • OR Gate:

    • Logic statement: P=A OR BP = A \text{ OR } B

    • Output is 11 (True) if either input is 11.

  • NOT Gate:

    • Logic statement: P=NOT AP = \text{NOT } A

    • 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 (AA and BB), there are four possible combinations:

AND Truth Table

Input AA

Input BB

Output PP

00

00

00

00

11

00

11

00

00

11

11

11

OR Truth Table

Input AA

Input BB

Output PP

00

00

00

00

11

11

11

00

11

11

11

11

NOT Truth Table

Input AA

Output PP

00

11

11

00

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: DIV\text{DIV} gives integer division; MOD\text{MOD} gives the remainder.

Combining Logic Gates

  • Complex circuits can be built by combining fundamental gates.

  • Example: Security Lighting

    • Logic requirement: The light (PP) must come on if it senses movement (SS) AND it is night time (NN), OR if a manual override button (BB) is pressed.

    • Logic Statement: P=(S AND N) OR BP = (S \text{ AND } N) \text{ OR } B

    • Intermediate result (RR) represents S AND NS \text{ AND } N.

Questions & Discussion

Starter Activity: The Safe Problem

  • Prompt: Consider a safe with two keys. If both keys are used, the safe will open (if key1 AND key2 then safeOpen = True else safeOpen = Falseif \text{ key1 AND key2 then safeOpen = True else safeOpen = False} ). 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: ANDAND, OROR, and NOTNOT.

  • Question: Explain what each logic gate does.

  • Answer: ANDAND requires both inputs to be True for a True output; OROR requires at least one input to be True; NOTNOT 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.