📑 Contents

Chapter 3.2: Logic Gates & Logic Circuits

9618 AS Computer Science - Boolean Logic

📚 Learning Objectives
🌟 Did You Know?

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.

The Six Logic Gates NOT AND OR NAND NOR XOR

1. Introduction to Logic 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.

📖 Key Concepts

1.1 Truth Tables

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.

📝 Calculating Number of Rows in Truth Table

The number of possible combinations is calculated using:

Number of combinations = 2ⁿ (where n = number of inputs)
💡 Exam Tip

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!

1.2 Boolean Algebra Notation

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)

2. NOT Gate (Inverter)

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 Gate Function
A X Truth Table A X 0 1 1 0 Logic Notation: X = NOT A Boolean Algebra: X = Ā
Real-World Example: A NOT gate could be represented by a simple lighting circuit with a push-to-break switch: if the switch is pressed (input = 1), then the lamp will turn off (output = 0). NOT gates are often used in emergency-stop buttons on machine tools.
🧠 Memory Trick

NOT = "NOT what you put in" - Whatever you input, the output is the OPPOSITE. Think of it as a "contrarian" gate that always disagrees!

3. AND Gate

The AND gate outputs 1 (TRUE) only when ALL inputs are 1 (TRUE). If any input is 0, the output is 0.

📖 AND Gate Function
A B X Truth Table A B X 0 0 0 0 1 0 1 0 0 1 1 1 Logic Notation: X = A AND B Boolean Algebra: X = A · B
Real-World Example: A safety system where a machine only starts if BOTH the safety guard is closed (A=1) AND the start button is pressed (B=1). If either condition is not met, the machine won't start.
🧠 Memory Trick

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.

4. OR Gate

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 Gate Function
A B X Truth Table A B X 0 0 0 0 1 1 1 0 1 1 1 1 Logic Notation: X = A OR B Boolean Algebra: X = A + B
Real-World Example: A home alarm system that triggers if EITHER the front door sensor (A) OR the back door sensor (B) detects entry. Only one needs to be triggered for the alarm to sound.
🧠 Memory Trick

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!

5. NAND Gate (NOT AND)

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.

📖 NAND Gate Function
A B X Truth Table A B X 0 0 1 0 1 1 1 0 1 1 1 0 Logic Notation: X = A NAND B Boolean: X = NOT (A · B) = Ā·B
💡 Exam Tip

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

🧠 Memory Trick

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!

6. NOR Gate (NOT OR)

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 Gate Function
A B X Truth Table A B X 0 0 1 0 1 0 1 0 0 1 1 0 Logic Notation: X = A NOR B Boolean: X = NOT (A + B)
💡 Exam Tip

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

🧠 Memory Trick

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).

7. XOR Gate (Exclusive OR)

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 Gate Function
A B X Truth Table A B X 0 0 0 0 1 1 1 0 1 1 1 0 Logic Notation: X = A XOR B Boolean: X = A ⊕ B
Real-World Example: A stairway light control system with switches at both top and bottom. XOR is used because you want the light to toggle (change state) when either switch is flipped - the light turns ON/OFF when the switches are in different positions.
🧠 Memory Trick

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.

8. Logic Gates Summary

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
Quick Reference: All 6 Logic Gates NOT X = NOT A AND X = A · B OR X = A + B NAND X = NOT(A·B) NOR X = NOT(A+B) XOR X = A ⊕ B Key: · = AND, + = OR, ⊕ = XOR, Bar (Ā) = NOT
⚠️ Important: Universal Gates

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.

9. Logic Circuits

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.

📖 Logic Circuit Characteristics

9.1 Creating Truth Tables for Logic Circuits

📝 Step-by-Step Method
  1. Count the number of inputs → Calculate rows needed (2ⁿ)
  2. Fill in all possible input combinations (count in binary)
  3. Identify intermediate outputs and label them
  4. Work through each gate systematically
  5. Calculate final output based on intermediate values
Example: Logic Circuit with 3 Inputs A B C P Q X Logic Expression: X = (A AND B) XOR (B OR C) Boolean Algebra: X = (A · B) ⊕ (B + C)
💡 Exam Tip

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.

10. Constructing Logic Circuits

10.1 From Problem Statement to Logic Circuit

Converting a problem statement into a logic circuit involves identifying key words and translating them into logic operations.

📝 Key Words to Look For
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
Worked Example:
A safety system uses three inputs to a logic circuit. An alarm, X, sounds if input A represents ON and input B represents OFF; or if input B represents ON and input C represents OFF.

Step 1: Identify conditions
• Condition 1: A = ON (1) AND B = OFF (0) → A AND NOT B
• Condition 2: B = ON (1) AND C = OFF (0) → B AND NOT C
Step 2: Combine with OR (either condition triggers alarm)
Logic Expression: X = (A AND NOT B) OR (B AND NOT C)
Logic Circuit: X = (A AND NOT B) OR (B AND NOT C) A B B C P Q X

11. Real-World Application: Wind Turbine Safety System

Let's apply our knowledge to a practical example involving a wind turbine safety system.

📖 Problem Statement

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
📝 Shutdown Conditions (X = 1)
Logic Expression: X = (NOT S AND T) OR (S AND W) OR (NOT T AND W)
Wind Turbine Safety Logic Circuit S T S W T W X Truth Table (partial) S T W X 0 0 0 0 0 0 1 1 0 1 0 1 ... (8 rows total)

12. Glossary of Key Terms

📖 Key Terms and Definitions
Quick Reference: Boolean Operators · AND + OR Ā NOT XOR A·B NAND A+B NOR

13. Exam-Style Questions

1. Complete the truth table for the following logic expression: X = A AND NOT B [4 marks]

Answer:

ABNOT BX = A AND NOT B
0010
0100
1011
1100

Marking points: 1 mark for correct A/B columns, 1 mark for NOT B column, 2 marks for final X column

2. A safety system uses three switches A, B, and C. An alarm sounds (X = 1) if switch A is ON and switch B is OFF, OR if switch B is ON and switch C is OFF. Write the logic expression and draw the logic circuit. [6 marks]

Answer:

Logic Expression: X = (A AND NOT B) OR (B AND NOT C)

Logic Circuit:

  • NOT gate on input B (produces NOT B)
  • NOT gate on input C (produces NOT C)
  • AND gate with inputs A and NOT B (produces first condition)
  • AND gate with inputs B and NOT C (produces second condition)
  • OR gate combining outputs of both AND gates (produces X)

Marking points: 2 marks for correct logic expression, 4 marks for correct circuit (1 per gate)

3. Describe the function of a NAND gate and explain why it is called a "universal gate". [4 marks]

Answer:

  • A NAND gate outputs 0 only when ALL inputs are 1; in all other cases it outputs 1
  • It is called a universal gate because any other logic gate can be constructed using only NAND gates
  • NOT gate: Connect both inputs together (A NAND A = NOT A)
  • AND gate: NAND followed by NOT (using NAND as NOT)
  • OR gate: Can be built using multiple NAND gates with NOT operations

Additional points for deeper understanding:

  • This is important in electronics because using one type of gate reduces manufacturing costs
  • NAND gates are simpler to fabricate in integrated circuits

Marking points: 2 marks for function description, 2 marks for universal gate explanation

4. Complete the truth table for a logic circuit with the expression: X = (A OR B) AND C [5 marks]

Answer:

ABCA OR BX
00000
00100
01010
01111
10010
10111
11010
11111

Marking points: 1 mark for input columns, 2 marks for intermediate column, 2 marks for output column

5. Draw the logic circuit for the expression: X = (A XOR B) OR NOT C [5 marks]

Answer:

The logic circuit requires:

  • XOR gate: Inputs A and B, produces output (A XOR B)
  • NOT gate: Input C, produces NOT C
  • OR gate: Inputs are output of XOR gate and output of NOT gate, produces X

Marking points: 2 marks for XOR gate, 1 mark for NOT gate, 2 marks for correct OR gate connection

13. Exam-Style Questions (Continued)

6. A manufacturing process uses a logic circuit. The process receives a STOP signal (X = 1) when: Volume > 1000L AND Speed ≤ 15 m/s, OR Temperature ≤ 750°C AND Speed > 15 m/s. Given V=1 when Volume>1000L, S=1 when Speed>15m/s, T=1 when Temperature>750°C, write the logic expression. [4 marks]

Answer:

Step 1: Convert conditions to logic:

  • Volume > 1000L → V = 1
  • Speed ≤ 15 m/s → S = 0 (NOT S)
  • Temperature ≤ 750°C → T = 0 (NOT T)
  • Speed > 15 m/s → S = 1

Step 2: Write logic expression:

X = (V AND NOT S) OR (NOT T AND S)

Marking points: 1 mark each for correct identification of conditions, 1 mark for correct expression

7. Explain the difference between an OR gate and an XOR gate. Give an example of where each might be used. [6 marks]

Answer:

OR Gate:

  • Outputs 1 when ANY input is 1 (including when both are 1)
  • Truth table: Output = 1 for inputs 01, 10, 11
  • Example: Home alarm system - triggers if front door OR back door is opened

XOR Gate:

  • Outputs 1 when inputs are DIFFERENT (one is 1, other is 0)
  • Truth table: Output = 1 for inputs 01, 10 only
  • Example: Stairway light switches - flipping either switch toggles the light state

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

8. Write the logic expression from the following truth table and draw the logic circuit. [6 marks]
ABX
001
010
100
110

Answer:

Step 1: Identify rows where X = 1

  • Only row 1 has X = 1: A = 0, B = 0

Step 2: Write expression for that row

  • A = 0 means NOT A, B = 0 means NOT B

Logic Expression:

X = NOT A AND NOT B (which is the same as A NOR B)

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

9. A server room cooling fan (F) turns on based on inputs: Temperature (T), Humidity (H), Maintenance mode (M), Door sensor (D). The fan turns on if: Temperature is high AND Humidity is high AND Door is closed, UNLESS maintenance mode is active (fan stays off). Write the logic expression. [5 marks]

Answer:

Step 1: Define binary values:

  • T = 1: Temperature too high, T = 0: Temperature acceptable
  • H = 1: Humidity too high, H = 0: Humidity acceptable
  • D = 1: Door open, D = 0: Door closed
  • M = 1: Maintenance mode active, M = 0: Maintenance mode inactive

Step 2: Write the conditions:

  • Temperature high AND Humidity high: T AND H
  • Door closed: NOT D
  • Maintenance NOT active: NOT M

Logic Expression:

F = T AND H AND NOT D AND NOT M

Alternative form: F = (T AND H) AND (NOT D) AND (NOT M)

Marking points: 2 marks for condition identification, 3 marks for correct expression

10. Complete the truth table for: X = (A AND B) XOR (B OR C) [6 marks]

Answer:

ABCA AND BB OR CX
000000
001011
010011
011011
100000
101011
110110
111110

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)

14. Exam Success Tips (Part 1)

💡 Truth Table Construction Tips
💡 Logic Expression Tips
🧠 Memory Tricks for Gate Functions
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
❌ Common Mistakes to Avoid

14. Exam Success Tips (Part 2)

💡 Drawing Logic Circuits
⚠️ Important Exam Reminders
💡 Quick Reference for Problem Statements
🌟 Did You Know?

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.

15. Key Takeaways

📌 Summary Points

Logic Gates

Truth Tables

Logic Circuits

Boolean Algebra

Good Luck in Your Exam! 📝 Remember: Practice makes perfect!