SomeQuiz

Course

Logic Gates and Truth Tables

First Contributor

Top Contributor

Venul Minsara

@venulminzara

πŸ“– 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

  1. NOT Gate
  2. AND Gate
  3. OR Gate

Derived Logic Gates

  1. NAND Gate
  2. NOR Gate
  3. XNOR Gate
  4. 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

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

ABOutput (Y = A.B)
000
010
100
111

2. OR Gate

2-input-OR-gate.png

  • 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

ABOutput (Y = A+B)
000
011
101
111

2. NOT Gate

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

AOutput (Y = Δ€ / A’ )
01
10

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

NAND Gate

  • The NAND gate is a combination of the AND gate followed by a NOT gate (inverter).

NAND Gate vs NAND Circuit

  • 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

ABOutput (Y = (A.B)')
001
011
101
110

2. NOR Gate

NOR.png

  • The NOR gate is a combination of the OR gate followed by a NOT gate (inverter).

NOR Gate vs NOR Circuit

  • 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

ABOutput (Y = (A+B)')
001
010
100
110

3. XOR Gate

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

ABOutput (Y = A βŠ• B)
000
011
101
110

4. XNOR Gate

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

ABOutput (Y = A βŠ™ B)
001
010
100
111

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 1Input 2Output
00
01
10
11

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 1Input 2Input 3Output
000
001
010
011
100
101
110
111

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 1Input 2Input 3Output

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 1Input 2
00
01
10
11

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.