Logic gates and truth tables

  • Computer Science
  • Boolean algebra explained
  • NAND and NOR gates universal
  • De Morgan's Laws…
  • digital logic circuit…

Podcast

Boolean Algebra: The Secret Language of Computers0:00 / 17:12
0:001:00 remaining

Logic gates are the fundamental building blocks of all digital electronic circuits. They are elementary devices that implement basic Boolean functions, which are mathematical operations performed on binary variables. Understanding logic gates and truth tables is essential for anyone delving into digital electronics, as they form the backbone of how digital devices process information.

In digital systems, information is represented by two discrete states, typically denoted as 0 and 1. These states can correspond to various physical phenomena, such as low or high voltage levels, off or on switches, or false or true logical conditions. Logic gates take one or more binary inputs and produce a single binary output based on a specific logical rule.

Boolean algebra, developed by George Boole, provides the mathematical framework for analyzing and designing digital circuits. It defines operations such as AND, OR, and NOT, which directly correspond to the functions performed by logic gates. This article will guide you through these concepts, making the abstract idea of digital processing tangible.

Understanding Logic Gates and Truth Tables: A Comprehensive Guide

Each logic gate has a unique graphical symbol, a Boolean expression that describes its function algebraically, and a truth table that lists all possible input combinations and their corresponding output. For clarity, we will primarily use ANSI/IEEE standard symbols for gates. Exploring these representations is key to mastering digital logic.

Basic Logic Gates Explained

Let's start with the foundational logic gates, understanding their behavior through symbols, Boolean expressions, and truth tables.

NOT Gate (Inverter)

The NOT gate, also known as an inverter, is the simplest logic gate. It takes a single binary input and produces an output that is the complement of the input. If the input is 0, the output is 1; if the input is 1, the output is 0.

  • Symbol: A triangle with a small circle (inversion bubble) at the output.
  • Boolean Expression: A' (read as "A prime" or "not A"). Sometimes denoted as ¬A or Ā.
  • Truth Table:
Input A
Output A'
0
1
1
0

AND Gate

The AND gate takes two or more binary inputs and produces a high output (1) only if all inputs are high (1). If any input is low (0), the output is low (0).

  • Symbol: A 'D' shape with inputs on the flat side and output on the curved side.
  • Boolean Expression: A · B (read as "A AND B"). Sometimes denoted as AB.
  • Truth Table (for two inputs A, B):
Input A
Input B
:-------:
Output A · B
:------------:
0
0
0
0
1
0
1
0
0
1
1
1

OR Gate

The OR gate takes two or more binary inputs and produces a high output (1) if at least one of its inputs is high (1). The output is low (0) only if all inputs are low (0).

  • Symbol: A curved shape resembling a crescent moon, with inputs on the concave side.
  • Boolean Expression: A + B (read as "A OR B").
  • Truth Table (for two inputs A, B):
Input A
Input B
:-------:
Output A + B
:------------:
0
0
0
0
1
1
1
0
1
1
1
1

XOR Gate (Exclusive OR)

The XOR gate takes two or more binary inputs and produces a high output (1) if an odd number of inputs are high (1). For two inputs, it outputs 1 if the inputs are different, and 0 if they are the same.

  • Symbol: Similar to an OR gate, but with an additional curved line at the input side.
  • Boolean Expression: A ⊕ B (read as "A XOR B").
  • Truth Table (for two inputs A, B):
Input A
Input B
:-------:
Output A ⊕ B
:------------:
0
0
0
0
1
1
1
0
1
1
1
0

XNOR Gate (Exclusive NOR)

The XNOR gate is the complement of the XOR gate. It produces a high output (1) if an even number of inputs are high (1). For two inputs, it outputs 1 if the inputs are the same, and 0 if they are different.

  • Symbol: Similar to an XOR gate, but with an inversion bubble at the output.
  • Boolean Expression: (A ⊕ B)' or A ⊙ B (read as "A XNOR B").
  • Truth Table (for two inputs A, B):
Input A
Input B
:-------:
Output (A ⊕ B)'
:---------------:
0
0
1
0
1
0
1
0
0
1
1
1

Check what you already know

Test · 20 questions · first 3 free

Question 1 of 30%

The logical equivalence of an original and a simplified Boolean expression is confirmed when their truth tables yield identical outputs for all input combinations.

Practise it with flashcards

14 cards · first 3 free, no account

1 / 14

What does Boolean algebra provide the mathematical framework for?

Analyzing and designing digital circuits.

Tap to flip · Swipe to navigate

Universal Logic Gates: NAND and NOR Capabilities

Universal gates are special types of logic gates that can be used to implement any other Boolean function. This means you don't need any other type of gate to build complex circuits, making them highly valuable in digital circuit design. This property simplifies manufacturing and reduces component variety significantly.

The Versatility of the NAND Gate

The NAND gate (NOT-AND) is essentially an AND gate followed by a NOT gate. It produces a low output (0) only if all its inputs are high (1); otherwise, its output is high (1).

  • Symbol: An AND gate symbol with an inversion bubble at the output.
  • Boolean Expression: (A · B)' (read as "A NAND B").
  • Truth Table (for two inputs A, B):
Input A
Input B
:-------:
Output (A · B)'
:---------------:
0
0
1
0
1
1
1
0
1
1
1
0

Implementing Other Gates with NAND

  • NOT Gate: Connect a single input A to both inputs of a NAND gate. Output is (A · A)' = A'.
  • AND Gate: Connect the output of a NAND gate (A · B)' to the input of another NAND gate configured as a NOT gate. Output is ((A · B)')' = A · B.
  • OR Gate: Invert each input (A' and B') using NAND gates, then feed these inverted inputs into another NAND gate. Output is (A' · B')' = A'' + B'' = A + B (by De Morgan's Laws).

The Power of the NOR Gate

The NOR gate (NOT-OR) is an OR gate followed by a NOT gate. It produces a high output (1) only if all its inputs are low (0); otherwise, its output is low (0).

  • Symbol: An OR gate symbol with an inversion bubble at the output.
  • Boolean Expression: (A + B)' (read as "A NOR B").
  • Truth Table (for two inputs A, B):
Input A
Input B
:-------:
Output (A + B)'
:---------------:
0
0
1
0
1
0
1
0
0
1
1
0

Implementing Other Gates with NOR

  • NOT Gate: Connect a single input A to both inputs of a NOR gate. Output is (A + A)' = A'.
  • OR Gate: Connect the output of a NOR gate (A + B)' to the input of another NOR gate configured as a NOT gate. Output is ((A + B)')' = A + B.
  • AND Gate: Invert each input (A' and B') using NOR gates, then feed these inverted inputs into another NOR gate. Output is (A' + B')' = A'' · B'' = A · B (by De Morgan's Law).

De Morgan's Laws in Boolean Algebra

De Morgan's Laws are two fundamental rules in Boolean algebra that describe how to convert Boolean expressions involving NOT, AND, and OR operations. They are crucial for simplifying complex logic circuits and for converting between different gate types, especially when working with universal gates.

First Law: Complement of a Product

The complement of a product of variables is equal to the sum of the complements of the individual variables.

  • Boolean Expression: (A · B)' = A' + B'
  • In words: NOT (A AND B) is equivalent to (NOT A) OR (NOT B).
  • Proof using Truth Table:
A
B
:-:
A · B
:-----:
(A · B)'
:--------:
A'
:--:
B'
:--:
A' + B'
:-------:
0
0
0
1
1
1
1
0
1
0
1
1
0
1
0
0
1
0
0
1
0
1
1
1
0
0
0
0

As shown, the column for (A · B)' is identical to the column for A' + B', proving the first law.

Second Law: Complement of a Sum

The complement of a sum of variables is equal to the product of the complements of the individual variables.

  • Boolean Expression: (A + B)' = A' · B'
  • In words: NOT (A OR B) is equivalent to (NOT A) AND (NOT B).
  • Proof using Truth Table:
A
B
:-:
A + B
:-----:
(A + B)'
:--------:
A'
:--:
B'
:--:
A' · B'
:-------:
0
0
0
1
1
1
1
0
1
1
0
1
0
0
1
0
1
0
0
1
1
1
0
0
0
0

As shown, the column for (A + B)' is identical to the column for A' · B', proving the second law. De Morgan's laws are not limited to two variables; they can be extended to any number of variables. For example, (A · B · C)' = A' + B' + C' and (A + B + C)' = A' · B' · C'. These laws are fundamental for converting between AND-OR logic and NAND-NOR logic, which is often necessary for optimizing circuit designs.

Worked Example: Circuit Simplification with De Morgan's Laws

Let's apply our knowledge of Boolean algebra and De Morgan's Laws to simplify a Boolean function. This example demonstrates how to analyze and optimize logic circuits.

Consider a Boolean function F defined by the expression: F = (A · B)' + (A' + C)'. We will simplify this expression and compare the original and simplified circuits using truth tables.

Step 1: Apply De Morgan's Law to the first term (A · B)'.

Using (X · Y)' = X' + Y', we get: (A · B)' = A' + B'. So, the expression becomes: F = (A' + B') + (A' + C)'.

Step 2: Apply De Morgan's Law to the second term (A' + C)'.

Using (X + Y)' = X' · Y', we get: (A' + C)' = (A')' · C'.

Step 3: Apply the Double Negation Law ((X')' = X) to (A')'.

(A')' = A. So, the second term simplifies to: A · C'.

Step 4: Substitute the simplified terms back into the expression for F.

F = (A' + B') + (A · C').

Step 5: Remove unnecessary parentheses (OR operations are associative).

F = A' + B' + (A · C'). This is the simplified Boolean expression for F.

Comparing Original vs. Simplified Logic Circuits

Original Logic Circuit (Conceptual)

The original expression F = (A · B)' + (A' + C)' would conceptually require:

  1. One AND gate for A · B.
  2. One NOT gate (or inversion bubble) for (A · B)'.
  3. One NOT gate for A'.
  4. One OR gate for A' + C.
  5. One NOT gate (or inversion bubble) for (A' + C)'.
  6. One OR gate to combine (A · B)' and (A' + C)'.

Total: 2 AND, 2 OR, 3 NOT gates (or their equivalents). This shows the initial complexity.

Simplified Logic Circuit (Conceptual)

The simplified expression F = A' + B' + (A · C') would conceptually require:

  1. One NOT gate for A'.
  2. One NOT gate for B'.
  3. One NOT gate for C'.
  4. One AND gate for A · C'.
  5. One OR gate to combine A', B', and (A · C').

Total: 1 AND, 1 OR, 3 NOT gates. The number of gates is similar, but the structure is simpler and potentially faster due to fewer cascaded inversions.

Truth Table Comparison for Verification

Let's construct the truth table for both the original and simplified expressions to verify their equivalence. We need 3 input variables (A, B, C), so there will be 2³ = 8 rows.

Original Expression Truth Table

A
B
:-:
C
:-:
A · B
:-----:
(A · B)'
:--------:
A'
:--:
A' + C
:------:
(A' + C)'
:---------:
F = (A · B)' + (A' + C)'
:--------------------------:
0
0
0
0
1
1
1
0
1
0
0
1
0
1
1
1
0
1
0
0
1
0
1
1
1
0
0
1
0
1
0
1
1
1
0
0
1
0
0
1
0
1
0
1
1
0
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
1
0
1
0
0
1
1
1
0
0
1
1
0
0
1
1
0
0
0
1
0
0
0
0

Simplified Expression Truth Table

Now for the simplified expression F = A' + B' + (A · C'):

A
B
:-:
C
:-:
A'
:--:
B'
:--:
C'
:--:
A · C'
:------:
F = A' + B' + (A · C')
:------------------------:
0
0
0
1
1
1
0
1
0
0
1
1
1
0
0
1
0
1
0
1
0
1
0
0
1
0
1
1
1
0
0
0
1
1
1
0
0
1
1
1
0
1
0
0
1
0
1
0
0
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0

Comparing the final columns for F, both truth tables yield identical outputs for all input combinations, confirming that the original and simplified expressions are logically equivalent. This demonstrates the power of Boolean algebra in optimizing circuit designs.

Common Mistakes When Working with Logic Gates and Truth Tables

When working with logic gates and truth tables, several common errors and misunderstandings can arise. Being aware of these pitfalls can significantly improve your accuracy and understanding.

  1. Confusing Boolean Operators with Arithmetic Operators: The '+' symbol in Boolean algebra means OR, not arithmetic addition. Similarly, '·' means AND, not multiplication. While some properties are analogous (e.g., commutativity), others are not (e.g., A + A = A in Boolean, but A + A = 2A in arithmetic). This distinction is crucial for correct circuit analysis.

  2. Incorrect Application of De Morgan's Laws: A frequent mistake is to distribute the complement incorrectly, for example, assuming (A + B)' is equal to A' + B' (which is incorrect; it should be A' · B'). Remember that De Morgan's laws involve changing the operator (AND to OR, or OR to AND) in addition to complementing the individual terms.

  3. Misinterpreting Gate Symbols: While standard symbols exist, slight variations can occur. It is important to recognize the core characteristics of each gate's symbol and its associated function. Forgetting the inversion bubble on NOT, NAND, or NOR gates is a common oversight.

  4. Errors in Truth Table Construction: Systematically listing all input combinations and carefully evaluating the output for each step of a complex expression is vital. A single error in one row or one intermediate column can lead to an incorrect final output.

  5. Assuming All Gates Have Only Two Inputs: While most introductory examples use two-input gates, many logic gates (especially AND and OR) can have three or more inputs. The fundamental logic remains the same: for an N-input AND gate, all N inputs must be 1 for the output to be 1; for an N-input OR gate, at least one of the N inputs must be 1 for the output to be 1.

  6. Overlooking the Importance of Parentheses: Just like in standard algebra, parentheses dictate the order of operations in Boolean expressions. Incorrectly applying the order of operations can lead to an entirely different logical function.

Observing Logic Gates in a Simulation for Better Understanding

An interactive simulation provides a valuable tool for understanding the dynamic behavior of logic gates. In such an environment, you can directly manipulate the inputs of various gates and immediately observe the resulting output. This hands-on experience reinforces the theoretical concepts learned from truth tables and Boolean expressions.

When using a simulation, you typically interact with virtual switches or buttons that represent the binary inputs (0 or 1) to a logic gate or a combination of gates. For example, for a simple AND gate, you would set Input A to 0 and Input B to 0, and observe that the output is 0. Then, by changing Input A to 1 while B remains 0, the output stays 0. Only when both Input A and Input B are set to 1 will the output change to 1. This direct cause-and-effect relationship makes the abstract concept of a truth table tangible.

For universal gates like NAND and NOR, the simulation allows you to build and test their universality. You can construct a NOT gate using a single NAND gate (by connecting its inputs together) and verify its behavior. Similarly, you can assemble AND and OR gates using only NAND or NOR gates and confirm that their outputs match the truth tables of the standard AND and OR gates. This demonstrates the power and flexibility of universal gates in practical circuit design.

Furthermore, a simulation can be used to visually confirm De Morgan's Laws. You can build two separate circuits: one representing (A · B)' and another representing A' + B'. By systematically changing the inputs A and B for both circuits, you will observe that their outputs are always identical, thus providing an empirical verification of the law. The same can be done for the second law, comparing (A + B)' with A' · B'. The immediate visual feedback from the simulation helps solidify the understanding of these logical equivalences and their practical implications in digital logic design.

Frequently Asked Questions about Logic Gates and Truth Tables

What are the main types of logic gates?

The main types of logic gates include NOT, AND, OR, XOR, XNOR, NAND, and NOR gates. Each performs a specific Boolean function based on its inputs, producing a single binary output.

Why are NAND and NOR gates called "universal gates"?

NAND and NOR gates are called universal gates because any other basic logic gate (AND, OR, NOT) can be constructed using only NAND gates or only NOR gates. This makes them incredibly versatile for digital circuit design.

How do truth tables help in understanding logic gates?

Truth tables provide a systematic way to visualize the behavior of a logic gate or a combination of gates. They list all possible combinations of binary inputs and show the corresponding output for each combination, clearly defining the gate's logical function.

What are De Morgan's Laws and why are they important?

De Morgan's Laws are fundamental rules in Boolean algebra that describe how to convert expressions involving NOT, AND, and OR operations. They are important for simplifying complex logic circuits and for converting between different gate types, which is crucial for optimizing designs and proving logical equivalences.

Can logic gates have more than two inputs?

Yes, many logic gates, such as AND and OR gates, can have three or more inputs. The fundamental logical rules remain the same: an N-input AND gate requires all N inputs to be 1 for a 1 output, and an N-input OR gate requires at least one 1 input for a 1 output.

Practise it, don't just read it

14 flashcards, a test with explanations and a podcast for this topic. The account is free and you pick up right where you left off.

  • No credit card
  • Web and mobile app
  • 330,000+ students
Start for free

Related topics