Computer Studies Chapter 10: Logic Gates

Introduction to Logic Gates

  • Definition of Logic Gates: A logic gate is a small electronic device that controls the flow of electronic signals passing through it. These signals represent the various operations of a computer.

  • Operational Logic: Logic gates regulate the flow of electricity to make decisions based on binary data. They represent components of the computer's logic.

  • Binary Representation:

    • Logic 1: Represents ON, True, or the presence of electrical voltage.

    • Logic 0: Represents OFF, False, or the absence of electrical voltage.

  • Application: Logic gates are fundamental building blocks found in digital devices, including control units, mobile phones, microchips (processors), and new memory devices.

Standard Symbols for Logic

  • Input and Output Constraints:

    • Most logic gates take at least two binary inputs and produce a single binary output.

    • The NOT gate is the exception, as it is a single-input gate.

    • For the scope of this course, gates are limited to a maximum of two inputs.

  • The Six Primary Logic Gates:

    • NOT Gate: The output is the inverse of the input.

    • AND Gate: The output is True only if ALL inputs are True.

    • OR Gate: The output is True if at least one input is True.

    • NAND Gate (NOT AND): The output is False only if ALL inputs are True; otherwise, it is True.

    • NOR Gate (NOT OR): The output is True only if ALL inputs are False.

    • XOR Gate (Exclusive OR): The output is True if the inputs are different; it is False if both inputs are the same.

Detailed Breakdown of Logic Gate Functions and Notation

NOT Gate

  • Function: Reverses the input signal.

  • Logic Notation: X=NOT AX = \text{NOT } A

  • Boolean Algebra: X=AˉX = \bar{A}

  • Truth Table:

    • Input 0 → Output 1

    • Input 1 → Output 0

AND Gate

  • Function: Logic 1 only if all inputs are 1.

  • Logic Notation: X=A AND BX = A \text{ AND } B

  • Boolean Algebra: X=A⋅BX = A \cdot B

  • Truth Table:

    • 0, 0 → 0

    • 0, 1 → 0

    • 1, 0 → 0

    • 1, 1 → 1

OR Gate

  • Function: Logic 1 if any input is 1.

  • Logic Notation: X=A OR BX = A \text{ OR } B

  • Boolean Algebra: X=A+BX = A + B

  • Truth Table:

    • 0, 0 → 0

    • 0, 1 → 1

    • 1, 0 → 1

    • 1, 1 → 1

NAND Gate

  • Function: Equivalent to AND followed by NOT. The output is 0 only when both inputs are 1.

  • Logic Notation: X=A NAND BX = A \text{ NAND } B

  • Boolean Algebra: X=A⋅B‾X = \overline{A \cdot B}

  • Truth Table:

    • 0, 0 → 1

    • 0, 1 → 1

    • 1, 0 → 1

    • 1, 1 → 0

NOR Gate

  • Function: Equivalent to OR followed by NOT. The output is 1 only when both inputs are 0.

  • Logic Notation: X=A NOR BX = A \text{ NOR } B

  • Boolean Algebra: X=A+B‾X = \overline{A + B}

  • Truth Table:

    • 0, 0 → 1

    • 0, 1 → 0

    • 1, 0 → 0

    • 1, 1 → 0

XOR (Exclusive OR) Gate

  • Function: Output is 1 if inputs are different (e.g., 0 and 1).

  • Logic Notation: X=A XOR BX = A \text{ XOR } B

  • Boolean Algebra: X=A⊕BX = A \oplus B or X=(A⋅Bˉ)+(Aˉ⋅B)X = (A \cdot \bar{B}) + (\bar{A} \cdot B)

  • Truth Table:

    • 0, 0 → 0

    • 0, 1 → 1

    • 1, 0 → 1

    • 1, 1 → 0

Logic Circuits and Networks

  • Definition: A logic circuit (or network) is formed by connecting several logic gates together to perform complex tasks.

  • Representation: Circuits can be represented via circuit diagrams or logic expressions.

  • Drawing Conventions:

    • Overlapping Wires: To represent lines that overlap but are not connected, draw a curve (hump) on one of the lines at the intersection.

    • Connected Wires: Use a black dot at the intersection to indicate that wires are electrically connected.

  • Output Determination: The overall output of a circuit is the output of the final (rightmost) gate.

Logic Expressions and Order of Precedence

  • Writing Expressions: Start from the left-most gates (inputs) and deduce the output for every intermediate gate until reaching the final gate.

  • Order of Precedence: Just like arithmetic, logic operations have a precedence order (performed highest to lowest):

    • 1. Brackets

    • 2. NOT

    • 3. AND

    • 4. OR

  • If operators of the same precedence appear, they are evaluated from left to right.

Truth Table Construction

  • Purpose: To specify the output for all possible combinations of input values.

  • Row Calculation: The number of rows in a truth table is calculated using the formula: Number of rows=2n\text{Number of rows} = 2^{n}, where nn is the number of inputs.

    • 2 inputs = 22=42^{2} = 4 rows.

    • 3 inputs = 23=82^{3} = 8 rows.

    • 4 inputs = 24=162^{4} = 16 rows.

  • Systematic Construction Method:

    • Rightmost Input Column: Alternate 0s and 1s (0, 1, 0, 1…).

    • Second Column From Right: Alternate pairs of 0s and 1s (0, 0, 1, 1, 0, 0…).

    • Third Column From Right: Alternate quadruples of 0s and 1s (0, 0, 0, 0, 1, 1, 1, 1…).

  • Intermediate Values: When working with complex circuits, it is helpful to add columns for the outputs of every intermediate gate.

Problem-Solving Strategies

1. Problem Statement to Circuit/Expression

  • Step 1: Analyze the text to find conditional logic (e.g., "A is on AND B is off").

  • Step 2: Translate conditions into logic notation (e.g., Z=A AND (NOT B)Z = A \text{ AND (NOT } B\text{)}).

  • Step 3: Draw gates based on the logic expression.

2. Truth Table to Logic Expression (Sum of Products)

  • Step 1: Identify all rows where the output (Z) is 1.

  • Step 2: For each of those rows, write an AND expression representing the inputs.

    • If input A is 0, use NOT A\text{NOT } A. If input A is 1, use AA.

  • Step 3: Combine all individual row expressions using OR operators.

  • Example: If rows with output 1 are (A=0, B=0) and (A=0, B=1):

    • Row 1: (NOT A AND NOT B)(\text{NOT } A \text{ AND NOT } B)

    • Row 2: (NOT A AND B)(\text{NOT } A \text{ AND } B)

    • Final Expression: Z=(NOT A AND NOT B) OR (NOT A AND B)Z = (\text{NOT } A \text{ AND NOT } B) \text{ OR } (\text{NOT } A \text{ AND } B)

Real-World Case Studies

  • Greenhouse Control System:

    • Alarm (ZZ) sounds if:

      • Shutters (SS) are closed (0) AND Temperature (TT) is 28 ∘C28\,^{\circ}\text{C} (1).

      • OR Temperature (TT) is below 28 ∘C28\,^{\circ}\text{C} (0) AND Humidity (HH) is 60%60\% (1).

    • Expression: Z=(NOT S AND T) OR (NOT T AND H)Z = (\text{NOT } S \text{ AND } T) \text{ OR } (\text{NOT } T \text{ AND } H).

  • Manufacturing Plant (Car Parts):

    • Alarm (AA) sounds if:

      • Temperature (TT) > 300 ∘C300\,^{\circ}\text{C} (1) AND Pressure (PP) is 8 bar8\,\text{bar} (0).

      • OR Speed (SS) > 2 m/s2\,\text{m/s} (1) AND Temperature (TT) is 300 ∘C300\,^{\circ}\text{C} (0).

  • Traffic Light System:

    • Activated (Z=1Z=1) if:

      • Signal AA is red (0).

      • OR Signal AA is green (1) AND Signals BB and CC are both red (0 and 0).

    • Expression: Z=(NOT A) OR (A AND (NOT B AND NOT C))Z = (\text{NOT } A) \text{ OR } (A \text{ AND (NOT } B \text{ AND NOT } C\text{)}).

  • Burglar Alarms: Commonly constructed using NAND gates.

  • Wheelchair Propulsion Motor:

    • Motor (MM) is on if Power switch (PP) is on AND (Forward switch (FF) is on XOR Reverse switch (RR) is on).

    • Expression: M=P AND ((F AND NOT R) OR (NOT F AND R))M = P \text{ AND } ((F \text{ AND NOT } R) \text{ OR (NOT } F \text{ AND } R))

Chapter Summary Checklist

  • Logic gates control electronic signals using binary states (0,10, 1).

  • The gates studied are NOT, AND, OR, NAND, NOR, and XOR.

  • NOT is the only single-input gate; others have at least two.

  • Truth tables show all possible input-output outcomes.

  • Logic circuits are also known as networks.

  • The number of rows in a truth table is 2inputs2^{\text{inputs}}.

  • Boolean algebra provides an alternative shorthand for logic gates:

    • AND: ⋅\cdot

    • OR: ++

    • XOR: ⊕\oplus

    • NOT: Bar above the variable.

Questions & Discussion

  • Question: What is a logic gate?

  • Answer: It is a small device that regulates the flow of electricity to make decisions, representing computer logic.

  • Question: Describe the two logic states in terms of electrical voltage, logic values, and binary values.

  • Answer: Presence of voltage = True = 1; Absence of voltage = False = 0.

  • Question: How do you differentiate the functions of OR and AND gates?

  • Answer: The output of an OR gate is 1 if either input is 1; the output of an AND gate is 1 only if both inputs are 1. Alternatively, an OR gate is 0 only if both inputs are 0, while an AND gate is 0 if at least one input is 0.

  • Question: Which single gate is represented by a table where output is 1 only for inputs (0,0)?

  • Answer: The NOR gate.

  • Question: Which gate outputs 1 only when inputs are different?

  • Answer: The XOR gate.