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:
Boolean Algebra:
Truth Table:
Input 0 → Output 1
Input 1 → Output 0
AND Gate
Function: Logic 1 only if all inputs are 1.
Logic Notation:
Boolean Algebra:
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:
Boolean Algebra:
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:
Boolean Algebra:
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:
Boolean Algebra:
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:
Boolean Algebra: or
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: , where is the number of inputs.
2 inputs = rows.
3 inputs = rows.
4 inputs = 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., ).
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 . If input A is 1, use .
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:
Row 2:
Final Expression:
Real-World Case Studies
Greenhouse Control System:
Alarm () sounds if:
Shutters () are closed (0) AND Temperature () is (1).
OR Temperature () is below (0) AND Humidity () is (1).
Expression: .
Manufacturing Plant (Car Parts):
Alarm () sounds if:
Temperature () > (1) AND Pressure () is (0).
OR Speed () > (1) AND Temperature () is (0).
Traffic Light System:
Activated () if:
Signal is red (0).
OR Signal is green (1) AND Signals and are both red (0 and 0).
Expression: .
Burglar Alarms: Commonly constructed using NAND gates.
Wheelchair Propulsion Motor:
Motor () is on if Power switch () is on AND (Forward switch () is on XOR Reverse switch () is on).
Expression:
Chapter Summary Checklist
Logic gates control electronic signals using binary states ().
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 .
Boolean algebra provides an alternative shorthand for logic gates:
AND:
OR:
XOR:
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.