π This lesson is divided into two parts. You can view the lessons as numbered order or your own discretion.
1. Logic Gates
Introduction to Logic Gates
What is a Logic Gate ?
- Logic Gates are the building blocks of digital electronics and computer systems.
- They are electronic circuits or switches that turn ON or OFF depending what the user is doing.
- Logic Gates turn ON when a certain condition is True.
- Logic Gates turn OFF when a certain condition is False.
- Logic Gates always Output either True (ON) or False (OFF).
Remember:
π‘ True = ON = 1
π‘ False = OFF = 0
π‘ Logic Gates Input and Output Binary Values (1 or 0) ONLY!
Types of Logic Gates
There are several types of logic gates, each with their own unique function. These are the most common types of logic gates,
Basic Logic Gates
- NOT Gate
- AND Gate
- OR Gate
Derived Logic Gates
- NAND Gate
- NOR Gate
- XNOR Gate
- XOR Gate
- Each Logic Gate performs a specific logical operations and associated with a logic expression. (just keep this in mind)
- Each Logic Gate has a symbol and a truth table of its own.
- Truth table is a way of expressing the logical operation in detail.
Letβs first understand the 3 Basic Logic Gates.
Basic Logic Gates
All other logic gates are derived from these basic gates. They are the most basic type of gates there is.
1. AND Gate
- The AND gate is a basic gate that takes minimum two, or more inputs and produces an output that is only high if all the inputs are high.
- This means that both inputs A
AND
B** should be 1 for output Y to be 1. - This also means that the output is Low, if any of the inputs are Low.
- This is represented by the expression Y = A.B
- The AND gate is represented by the symbol given above.
π‘ Logical Operation: Logical Conjunction
π‘ Logical Expression: Y = A.B
Truth Table of AND Gate
A | B | Output (Y = A.B) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
2. OR Gate
- The OR gate is another gate that has minimum two, or more ** inputs and produces and output which is high if any of the input is high.
- This means that if either inputs A βORβ B is 1 the output Y is 1.
- This also means that output is Low only if both inputs are Low.
- This is represented by the expression Y = A+B
- The OR gate is represented by the symbol given above.
π‘ Logical Operation: Logical Inclusive
π‘ Logical Expression: Y = A+B
Truth Table of OR Gate
A | B | Output (Y = A+B) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
2. NOT Gate
-
The NOT gate is gate that only has ONE Input and produces and output which is the opposite of the input.
-
NOT is a unary operator, always has one input.
-
This means for a 1 it will give a 0, and for a 0 it will give a 1.
-
This is represented by the expression Y = Aβ / Δ
-
Another name for a NOT gate is inverter, because it inverts (makes opposite) the input
-
The NOT gate is represented by the symbol given above.
π‘ Logical Operation: Logical Negation
π‘ Logical Expression: Y = Δ / Aβ
Truth Table of NOT Gate
A | Output (Y = Δ / Aβ ) |
---|---|
0 | 1 |
1 | 0 |
Derived Logic Gates
The derived gates have their own unique symbols, truth tables, and Boolean expressions. They are derived of the three ,main logic gates we discussed earlier.
Let us take a look at the main 4 types of logic gates,
1. NAND Gate
- The NAND gate is a combination of the AND gate followed by a NOT gate (inverter).
- It takes minimum two, or more inputs and produces an output that is high unless all inputs are high.
- This means that the output of the NAND gate is the complement (inverse) of the AND gate output.
- The NAND gate behaves as an AND gate followed by a NOT gate.
- This is represented by the expression Y = (A.B)' or Y = A NAND B.
- The NAND gate is represented by the symbol given above.
π‘ Logical Expression: Y = (A.B)' or Y = A NAND B.
Truth Table of NAND Gate
A | B | Output (Y = (A.B)') |
---|---|---|
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
2. NOR Gate
- The NOR gate is a combination of the OR gate followed by a NOT gate (inverter).
- It takes minimum two, or more inputs and produces an output that is high only if all inputs are low.
- This means that the output of the NOR gate is the complement (inverse) of the OR gate output.
- The NOR gate behaves as an OR gate followed by a NOT gate.
- This is represented by the expression Y = (A+B)' or Y = A NOR B.
- The NOR gate is represented by the symbol given above.
π‘ Logical Expression: Y = (A+B)' or Y = A NOR B
Truth Table of NOR Gate
A | B | Output (Y = (A+B)') |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
3. XOR Gate
- The XOR gate is a gate that takes exactly two inputs and produces an output that is high if the number of high inputs is odd.
- This means that the output of the XOR gate is high (1) when the inputs are different and low (0) when the inputs are the same.
- XOR stands for "exclusive OR," which means it is true only when one input is true exclusively.
- This is represented by the expression Y = A β B or Y = A XOR B.
- The XOR gate is represented by the symbol given above.
π‘ Logical Expression: Y = A β B or Y = A XOR B
Truth Table of XOR Gate
A | B | Output (Y = A β B) |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
4. XNOR Gate
- The XNOR gate is a gate that takes exactly two inputs and produces an output that is high if the number of high inputs is even.
- This means that the output of the XNOR gate is high (1) when the inputs are the same and low (0) when the inputs are different.
- XNOR stands for "exclusive NOR," which means it is true only when both inputs are true or both inputs are false.
- This is represented by the expression Y = A β B or Y = (A β B)β
- The XNOR gate is represented by the symbol given above.
π‘ Logical Expression: Y = A β B or Y = (A β B)β or Y = A XNOR B
Truth Table of XNOR Gate
A | B | Output (Y = A β B) |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Conclusion
Logic gates are the basic building blocks of digital electronics and computer systems. They perform basic logical operations such as AND, OR, NOT, and XOR. Understanding how these gates work is essential for anyone interested in digital electronics or computer systems. In this blog post, we've introduced the different types of logic gates and how they work. With this knowledge, you can start building your own digital circuits and computer systems.
2. Truth Tables
Introduction To Truth Tables
π A convenient way to visualize the outputs for the logic gates is through a truth table. The truth table depicts the gateβs response to each possible set of inputs.
How to Find Number Of Input Combinations for a Logic Circuit
To find out how the number of possible outputs we can use a little trick.
Letβs say we have a gate with 2 inputs,
We take the number of inputs as the power of two to find out the number of possible input combinations.
So in this case, 2Β² = 4 input combinations.
Input 1 | Input 2 | Output |
---|---|---|
0 | 0 | |
0 | 1 | |
1 | 0 | |
1 | 1 |
now letβs take a gate with 3 inputs,
As before take the number of inputs as the exponent (power) of two
So it gives us, 2Β³ = 8
Input 1 | Input 2 | Input 3 | Output |
---|---|---|---|
0 | 0 | 0 | |
0 | 0 | 1 | |
0 | 1 | 0 | |
0 | 1 | 1 | |
1 | 0 | 0 | |
1 | 0 | 1 | |
1 | 1 | 0 | |
1 | 1 | 1 |
Do you see a pattern in the truth tables given above?
How to Draw a Truth Table
Yes, to draw a truth table you need some type conventions and standards,
Step 1: Determine the number of variables and the number of rows as mentioned in the previous step. 3 input Gate needs a 4 columned table. (including the Output column).
Step 2: Create the column headers with variable names. (use given names if its A B C use A B C)
Input 1 | Input 2 | Input 3 | Output |
---|
Step 3: Starting from the top row, assign the binary value for each variable in a repetitive pattern. Begin with assigning "0" to each variable for the first half of the rows, and then assign "1" for the remaining half. Repeat this pattern for each variable but halve the number of 0βs and 1βs every column.
Input 1 | Input 2 |
---|---|
0 | 0 |
0 | 1 |
1 | 0 |
1 | 1 |
Step 4: Calculate the logical expression using the assigned binary values for the variables. Apply logical operators such as AND, OR, NOT, etc., to determine the truth value of the expression. Write the resulting "1" or "0" in the corresponding row under the "Output" column.
Step 5: Repeat steps 3 and 4 for each row, assigning binary values to variables and calculating the truth value based on the logical expression.
Step 6: Once you have completed all the rows, your truth table will be filled with ones and zeros representing the truth values of the logical expression for each combination of variable values.
β οΈ Outputs are not filled as there is no specific Logical Expressions in this lesson section
Vocabulary
Gate Combination: The arrangement or connection of logic gates to form more complex logic circuits or functions.
Boolean Algebra: A mathematical system that deals with binary variables and logic operations, named after mathematician George Boole. It provides a foundation for analyzing and manipulating logical expressions and circuits.
Binary: A number system based on two digits, 0 and 1, representing OFF and ON states, respectively.
Bit: Short for "binary digit," it is the basic unit of information in computing and represents a single 0 or 1 value.
Logic Gate: An electronic component that performs a logical operation on one or more binary inputs and produces a binary output based on a specific logic function.
Input: The binary signals or values provided to a logic gate for processing or evaluation.
Output: The resulting binary signal or value produced by a logic gate after processing the input.