2210 · Topic 9 of 10

Boolean Logic and Logic Gates

Explore the binary decision-making at the heart of all digital computers using logic gates.

~5Minutes
8Key points
5Questions
All Computer Science topics

Study path

Learn it, recall it, then prove it

01 · Understand

Read the explanation and work through each example.

02 · Recall

Close the notes and explain the main idea yourself.

03 · Practise

Attempt the quiz, then revisit only missed concepts.

At the core of every digital computer, smartphone, and electronic device are circuits that make simple decisions based on the principles of Boolean logic. Developed by George Boole in the 19th century, this system of algebra deals with two values: TRUE (represented by the binary digit 1) and FALSE (represented by 0). Every complex operation a computer performs is broken down into millions of these simple true/false decisions.

These decisions are physically implemented by logic gates, which are the fundamental building blocks of digital circuits. A logic gate is an electronic circuit that takes one or more binary inputs and produces a single binary output. The Cambridge O Level syllabus requires you to understand several key logic gates.

Primary Logic Gates

  1. AND Gate: The output of an AND gate is 1 only if all of its inputs are 1. Think of it as a logical multiplication. The Boolean expression is written as Q = A . B (or simply AB).
  1. OR Gate: The output of an OR gate is 1 if at least one of its inputs is 1. This is like logical addition. The Boolean expression is Q = A + B.
  1. NOT Gate (Inverter): This is the simplest gate. It has only one input and one output. The output is the inverse of the input. If the input is 1, the output is 0, and vice versa. The Boolean expression is Q = Ā (read as 'NOT A' or 'A bar').

Combination Logic Gates

These gates are derived from the primary gates.

  1. NAND Gate (NOT-AND): A NAND gate is an AND gate followed by a NOT gate. Its output is 0 only when all its inputs are 1 (the exact opposite of an AND gate). It is a universal gate, meaning any other logic gate can be constructed using only NAND gates. The Boolean expression is Q = A.B.
  1. NOR Gate (NOT-OR): A NOR gate is an OR gate followed by a NOT gate. Its output is 1 only when all its inputs are 0 (the opposite of an OR gate). Like the NAND gate, the NOR gate is also a universal gate. The Boolean expression is Q = A+B.
  1. XOR Gate (Exclusive-OR): The output of an XOR gate is 1 only if its inputs are different. For example, if A=1 and B=0, the output is 1. But if A=1 and B=1, the output is 0. This is useful for tasks like binary addition and error checking. The Boolean expression is Q = A ⊕ B.

Truth Tables

A truth table is a crucial tool used to represent the output of a logic gate or a more complex logic circuit for all possible combinations of its inputs. For a circuit with 'n' inputs, the truth table will have 2ⁿ rows. For a 2-input gate (like AND, OR, XOR), there are 2² = 4 possible input combinations (00, 01, 10, 11).

Example Truth Table for a 2-Input AND gate:

ABQ (A.B)
000
010
100
111

Designing Simple Logic Circuits

Individual logic gates can be combined to create logic circuits to perform more complex tasks. To analyse or design a circuit, you follow a clear process:

  1. Write the Boolean Expression: Define the logical relationship between inputs and the final output.
  2. Draw the Logic Circuit Diagram: Represent the expression using the standard symbols for each logic gate, connecting them in the correct order.
  3. Create a Truth Table: Systematically work out the output for every possible combination of inputs. This often involves creating intermediate columns in the table to track the output of each gate in the circuit.

Example Circuit: Consider the expression Q = (A . B) + C.

  • Circuit: An AND gate takes inputs A and B. Its output is then fed into one input of an OR gate. The other input of the OR gate is C. The final output is Q.
  • Truth Table: Since there are 3 inputs (A, B, C), there are 2³ = 8 possible input combinations. We would create a table with columns for A, B, C, an intermediate column for (A.B), and the final column for Q.

Quick revision infographic

Computer Science · Quick revision

Boolean Logic and Logic Gates

Key concepts

  1. 01Boolean logic is a system of reasoning using two values: TRUE (1) and FALSE (0).
  2. 02Logic gates are electronic circuits that perform Boolean operations on binary inputs.
  3. 03The three fundamental gates are AND (output is 1 if all inputs are 1), OR (output is 1 if any input is 1), and NOT (inverts the input).
  4. 04NAND and NOR gates are known as 'universal gates' because any other logical function can be built from them.
  5. 05The XOR (Exclusive-OR) gate produces a 1 output only when its inputs are different.
  6. 06A truth table systematically lists all possible input combinations for a logic circuit and shows the corresponding output for each.
Logic Gates in a UPS/Generator Automatic Transfer Switch (ATS)

In many homes and businesses in Pakistan, an Automatic Transfer Switch (ATS) is used to switch from the main grid power (WAPDA/K-Electric) to a backup UPS or generator during load-shedding. A simple logic circuit controls this. Let Input **A** be 'Grid Power Available' (1=Yes, 0=No). The system should only activate the generator when grid power is NOT available. This requires a **NOT** gate. The condition to start the generator could be expressed as: 'Start Generator if (**NOT A**)'. This ensures the generator only runs when needed, preventing fuel wastage and damage, a practical application of Boolean logic seen daily across the country.

SeekhoAsaan.com · Free revisionBoolean Logic and Logic Gates

Test your knowledge.

5 explained questions. Har answer ke baad reasoning foran milegi.

3 Beginner2 Intermediate
Start 5-question quiz