💻 Chapter Study Notes: Logic Gates

Hello future computer architect! Welcome to the microscopic world that powers every single electronic device around you. This chapter, "Logic Gates," is absolutely fundamental to the "Computer Organisation and Architecture" section.

You might think computers are magic, but they are built on layers of incredibly simple, reliable decisions. Logic gates are the electronic building blocks—tiny circuits that perform basic Boolean algebra operations. Mastering them means understanding how the CPU performs every calculation, instruction, and memory storage action. Let's dive in!

1. The Digital Foundation: Binary and Boolean Logic

Computers operate using electricity, which can be in one of two states: ON or OFF. We represent these states using the binary system:

  • ON or High Voltage = 1 (True)
  • OFF or Low Voltage = 0 (False)

Logic gates take one or more binary inputs and produce a single binary output based on a specific logical rule.

Key Concept: Boolean Algebra

Boolean Algebra is the mathematics of logic. It deals only with True (1) and False (0). Every logic gate corresponds directly to a Boolean operator.

What is a Truth Table?

A Truth Table is essential. It is a mathematical table used to compute and show the output (Q) for every possible combination of inputs (A, B, etc.) for a logic circuit.

Quick Review Box: Prerequisite Check
If you have N inputs, there are \(2^N\) possible combinations in the truth table. For example, 2 inputs (A and B) mean \(2^2 = 4\) rows.

2. The Three Core Logic Gates

These three gates form the foundation of all digital electronics.

2.1. AND Gate

The AND gate produces an output of 1 (True) only if ALL inputs are 1.

  • Boolean Expression: \(Q = A \cdot B\) (pronounced "A AND B")
  • Symbol: The 'D' shape symbol. (Refer to syllabus diagram 3.7.6)
  • Analogy: A bank vault requires two security keys (A and B) to be turned simultaneously. If key A AND key B are used, the vault opens (Q=1).

Truth Table for AND (2 Inputs)

Input A | Input B | Output Q
0 | 0 | 0
0 | 1 | 0
1 | 0 | 0
1 | 1 | 1

2.2. OR Gate

The OR gate produces an output of 1 (True) if AT LEAST ONE input is 1.

  • Boolean Expression: \(Q = A + B\) (pronounced "A OR B")
  • Symbol: The curved symbol. (Refer to syllabus diagram 3.7.6)
  • Analogy: A room light has two switches (A and B). If switch A OR switch B is pressed, the light turns on (Q=1).

Truth Table for OR (2 Inputs)

Input A | Input B | Output Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 1

2.3. NOT Gate (Inverter)

The NOT gate takes only one input and simply inverts it (flips 0 to 1, or 1 to 0).

  • Boolean Expression: \(Q = \bar{A}\) (pronounced "NOT A" or "A bar")
  • Symbol: A triangle with a small circle (the ‘bubble’) on the output side. (Refer to syllabus diagram 3.7.6)
  • Analogy: It's a "backwards" switch. If the input is active (1), the output is inactive (0).

Truth Table for NOT (1 Input)

Input A | Output Q
0 | 1
1 | 0


Key Takeaway: The small circle (bubble) always represents inversion or NOT logic. You will see it on other gates!

3. The Derived Logic Gates

These gates are created by combining the core gates, but they are so common they have their own symbols and rules.

3.1. XOR Gate (Exclusive OR)

The XOR gate produces an output of 1 (True) if the inputs are different, but not if they are both 1.

  • Boolean Expression: \(Q = A \oplus B\) (pronounced "A XOR B")
  • Symbol: Similar to the OR gate, but with an extra curved line at the input. (Refer to syllabus diagram 3.7.6)
  • Analogy: The best way to explain XOR is a two-way hallway light switch system. If only A is pressed OR only B is pressed, the light changes state (Q=1). If both are pressed, nothing changes (Q=0).

Truth Table for XOR (2 Inputs)

Input A | Input B | Output Q
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0

3.2. NAND Gate (NOT AND)

A NAND gate is simply an AND gate followed by a NOT gate. The output is the inverse of AND.

  • Boolean Expression: \(Q = \overline{A \cdot B}\)
  • Symbol: The AND symbol with a bubble on the output. (Refer to syllabus diagram 3.7.6)

Truth Table for NAND (2 Inputs)

Input A | Input B | Output Q
0 | 0 | 1
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0

Common Mistake: NAND is often called a Universal Gate because any other gate (AND, OR, NOT) can be constructed using only NAND gates. While this is interesting, focus primarily on constructing its truth table by remembering it inverts the AND output.
3.3. NOR Gate (NOT OR)

A NOR gate is an OR gate followed by a NOT gate. The output is the inverse of OR.

  • Boolean Expression: \(Q = \overline{A + B}\)
  • Symbol: The OR symbol with a bubble on the output. (Refer to syllabus diagram 3.7.6)

Truth Table for NOR (2 Inputs)

Input A | Input B | Output Q
0 | 0 | 1
0 | 1 | 0
1 | 0 | 0
1 | 1 | 0


4. Interpreting and Drawing Logic Circuits

The core skill in this topic is translating between the three representations: Boolean Expression, Logic Diagram, and Truth Table.

4.1. Writing a Boolean Expression from a Diagram

Start from the inputs on the left and work your way right, step-by-step, until you reach the final output Q.

Example Circuit (A and B are inputs to AND, C is input to NOT. The outputs of both go into an OR gate).

Step 1: Identify the output of the first gate (AND): \(X = A \cdot B\)
Step 2: Identify the output of the second gate (NOT): \(Y = \bar{C}\)
Step 3: The final gate (OR) takes X and Y as input: \(Q = X + Y\)
Final Boolean Expression: \(Q = (A \cdot B) + \bar{C}\)

4.2. Completing a Truth Table for a Complex Circuit

For a complex circuit, create intermediate columns in your truth table corresponding to the output of each internal gate. This breaks the problem into manageable steps!

For the circuit \(Q = (A \cdot B) + \bar{C}\) (which has 3 inputs, so \(2^3=8\) rows):

  • Column 1, 2, 3: Inputs A, B, C (all 8 combinations).
  • Column 4: Intermediate X (output of A AND B).
  • Column 5: Intermediate Y (output of NOT C).
  • Column 6: Final Q (output of X OR Y).

Step-by-Step Explanation: For the input row A=1, B=0, C=1:

  1. X = A AND B = 1 AND 0 = 0
  2. Y = NOT C = NOT 1 = 0
  3. Q = X OR Y = 0 OR 0 = 0

Memory Aid: Always draw intermediate columns in your truth table corresponding to the inner brackets of the Boolean expression.

5. Logic Applications: Arithmetic and Memory

Logic gates aren't just theoretical; they are the fundamental components of the Arithmetic Logic Unit (ALU) inside the processor.

5.1. The Half-Adder

A Half-Adder is a circuit that adds two single binary digits (A and B). Since \(1+1 = 10_2\), we need two outputs: Sum (S) and Carry (C).

  • Inputs: A and B (the two bits being added).
  • Outputs: Sum (S) and Carry (C).

Logic and Construction:

1. The Sum (S) is 1 only when A and B are different. This is the exact definition of an XOR gate!
S = \(A \oplus B\)

2. The Carry (C) is 1 only when A and B are both 1 (since $1+1$ generates a carry). This is the exact definition of an AND gate!
C = \(A \cdot B\)

To construct a half-adder circuit, you would draw one XOR gate and one AND gate, both taking inputs A and B, where the XOR output is S and the AND output is C.

5.2. The Full-Adder

When adding multi-bit numbers, you need to include the carry generated from the previous column. A Full-Adder performs the addition of three inputs:

  • Input A, Input B (the two bits being added)
  • Carry In ($C_{in}$) (the carry from the previous bit addition)

The outputs remain the Sum (S) and Carry Out ($C_{out}$).

(You must be able to recognise and trace the logic of a full-adder circuit, but you are not required to construct it.)


Did you know? An 8-bit computer uses eight full-adder circuits chained together to calculate an 8-bit sum! This structure is called a ripple-carry adder.

5.3. The Edge-Triggered D-Type Flip-Flop (Memory Unit)

Logic gates don't just perform calculation; they are used to build memory. The D-type flip-flop is the simplest form of sequential logic (memory) we need to understand.

It is known as a 1-bit memory unit because it can store exactly one bit (a 0 or a 1).

Key Components and Operation:

  • Data Input (D): This is the bit (0 or 1) that you want to store.
  • Clock Input (CLK): This input dictates when the data should be stored.
  • Output (Q): The stored value.

The Edge-Triggered Mechanism:

The D-type flip-flop is edge-triggered, meaning it only pays attention to the Data Input (D) at the precise moment the clock signal changes state (e.g., from 0 to 1, known as a rising edge).

  1. The Clock Signal goes high (e.g., rising edge).
  2. The current state of the Data Input (D) is read and immediately stored internally.
  3. This stored value is output on Q.
  4. The output Q remains unchanged, regardless of what happens to the Data Input (D), until the clock signal goes high again.

Think of it like a camera: the Data Input is the scene, and the Clock Signal is the shutter button. The camera only captures the scene exactly when the button is pressed; the stored picture doesn't change until you press the button again.


✔ Chapter Summary: Logic Gates

You’ve seen how simple binary decisions translate into the core components of the CPU and memory. Remember:

  • The six gates (AND, OR, NOT, XOR, NAND, NOR) define all fundamental digital logic.
  • Use Truth Tables to systematically trace the output of any circuit.
  • The Half-Adder uses XOR for the Sum and AND for the Carry.
  • The D-Type Flip-Flop is a memory unit controlled by a clock signal that captures the data input at the moment of the clock edge, holding it constant until the next clock edge.

Keep practising converting between expressions, diagrams, and truth tables—this is the key to exam success!