👁 Preview — Study, Practice and Revise are open; mock tests and the rest of the syllabus unlock on subscription. Unlock all · ₹4,999
← Back to Number Systems & Logic
Study mode

Logic gates

Introduction to Logic Gates

In the world of computers and digital electronics, everything boils down to two fundamental states: ON and OFF. These states are represented by the numbers 1 and 0 respectively. This binary system forms the foundation of all digital logic.

Logic gates are the basic building blocks that process these binary signals. They take one or more binary inputs and produce a single binary output based on a specific logical operation. Understanding logic gates is essential because they form the core of all digital circuits, from simple calculators to complex computers.

Think of logic gates as tiny decision-makers: they decide the output based on the inputs they receive, much like how a traffic signal decides whether to stop or go based on certain conditions.

Basic Logic Gates

Let's begin with the three fundamental logic gates: AND, OR, and NOT. Each performs a unique logical operation on its inputs.

AND Gate

ABOutput (A AND B)
000
010
100
111

Operation: Output is 1 only if both inputs are 1.

OR Gate

ABOutput (A OR B)
000
011
101
111

Operation: Output is 1 if at least one input is 1.

NOT Gate

AOutput (NOT A)
01
10

Operation: Output is the opposite of the input.

Derived Logic Gates

Derived gates are built by combining basic gates or by adding inversion to their outputs. They include NAND, NOR, XOR, and XNOR gates. These gates are widely used because they can simplify circuit design and are fundamental in creating complex logic.

NAND Gate

ABOutput (NAND)
001
011
101
110

Operation: Output is the opposite of AND gate output.

NOR Gate

ABOutput (NOR)
001
010
100
110

Operation: Output is the opposite of OR gate output.

XOR Gate

ABOutput (XOR)
000
011
101
110

Operation: Output is 1 if inputs are different.

XNOR Gate

ABOutput (XNOR)
001
010
100
111

Operation: Output is 1 if inputs are the same.

Constructing Truth Tables

A truth table is a tabular representation that lists all possible input combinations to a logic gate or circuit and shows the corresponding output. It helps us understand how a gate behaves for every input scenario.

For n inputs, there are \(2^n\) possible input combinations. For example, a gate with 2 inputs has \(2^2 = 4\) combinations: 00, 01, 10, and 11.

Example: Truth Table for AND Gate with 2 Inputs
ABOutput (A AND B)
000
010
100
111

When constructing truth tables for combined gates or circuits, calculate the output step-by-step for each gate based on the inputs, then use those outputs as inputs for the next gate.

Boolean Algebra and Simplification

Boolean algebra is a branch of algebra that deals with variables having two possible values: 0 and 1. It provides a mathematical framework to analyze and simplify logic circuits.

Each logic gate corresponds to a Boolean operation:

  • AND: \(Y = A \cdot B\)
  • OR: \(Y = A + B\)
  • NOT: \(Y = \overline{A}\)

Simplifying Boolean expressions reduces the number of gates needed in a circuit, saving cost and space.

graph TD    A[Start with Boolean Expression]    B[Apply Basic Laws (Idempotent, Null, Domination)]    C[Use De Morgan's Theorems]    D[Simplify using Distribution and Combination]    E[Obtain Simplified Expression]    A --> B --> C --> D --> E

For example, the expression \(A \cdot \overline{A} + B\) simplifies to \(B\) because \(A \cdot \overline{A} = 0\).

Formula Bank

Formula Bank

AND Gate Output
\[ Y = A \cdot B \]
where: A, B = inputs; Y = output (1 only if both A and B are 1)
OR Gate Output
\[ Y = A + B \]
where: A, B = inputs; Y = output (1 if at least one input is 1)
NOT Gate Output
\[ Y = \overline{A} \]
where: A = input; Y = output (complement of A)
NAND Gate Output
\[ Y = \overline{A \cdot B} \]
where: A, B = inputs; Y = output (complement of AND gate output)
NOR Gate Output
\[ Y = \overline{A + B} \]
where: A, B = inputs; Y = output (complement of OR gate output)
XOR Gate Output
\[ Y = A \oplus B = A \overline{B} + \overline{A} B \]
where: A, B = inputs; Y = output (1 if inputs differ)
XNOR Gate Output
\[ Y = \overline{A \oplus B} = A B + \overline{A} \overline{B} \]
where: A, B = inputs; Y = output (1 if inputs are the same)

Worked Examples

Example 1: Constructing a Truth Table for a NAND Gate Easy
Construct the truth table for a NAND gate with inputs A and B.

Step 1: List all possible input combinations for A and B. Since there are 2 inputs, total combinations = \(2^2 = 4\):

00, 01, 10, 11

Step 2: Find the AND output for each combination:

  • A=0, B=0 -> AND = 0
  • A=0, B=1 -> AND = 0
  • A=1, B=0 -> AND = 0
  • A=1, B=1 -> AND = 1

Step 3: NAND output is the complement of AND output:

  • Complement of 0 is 1
  • Complement of 1 is 0

Step 4: Write the final truth table:

ABANDNAND
0001
0101
1001
1110

Answer: The NAND gate outputs 1 for all input combinations except when both inputs are 1.

Example 2: Simplify a Boolean Expression Using Boolean Laws Medium
Simplify the Boolean expression: \( Y = A \cdot \overline{A} + A \cdot B \).

Step 1: Apply the Complement Law: \( A \cdot \overline{A} = 0 \) because a variable AND its complement is always 0.

So, \( Y = 0 + A \cdot B \).

Step 2: Apply the Identity Law: \(0 + X = X\).

Therefore, \( Y = A \cdot B \).

Answer: The simplified expression is \( Y = A \cdot B \).

Example 3: Design a Logic Circuit for a Given Truth Table Hard
Given the truth table below, design a logic circuit using basic gates (AND, OR, NOT):
ABOutput Y
000
011
101
110

Step 1: Identify input combinations where output is 1:

  • A=0, B=1
  • A=1, B=0

Step 2: Write the sum of products expression:

\[ Y = \overline{A} \cdot B + A \cdot \overline{B} \]

This is the Boolean expression for the XOR gate.

Step 3: Design the circuit:

  • Use two NOT gates to get \(\overline{A}\) and \(\overline{B}\).
  • Use two AND gates: one for \(\overline{A} \cdot B\) and one for \(A \cdot \overline{B}\).
  • Use one OR gate to combine the outputs of the two AND gates.

Answer: The circuit implements an XOR function using basic gates.

Example 4: Using XOR Gate for Parity Checking Medium
Explain how XOR gates are used to check the parity of a 3-bit binary number.

Step 1: Parity checking involves determining if the number of 1s in a binary number is even or odd.

Step 2: XOR gate outputs 1 if inputs differ, which makes it ideal for parity calculations.

Step 3: For a 3-bit number \(A, B, C\), calculate parity as:

\[ P = A \oplus B \oplus C \]

Step 4: Use two XOR gates:

  • First XOR gate: \(X = A \oplus B\)
  • Second XOR gate: \(P = X \oplus C\)

If \(P = 0\), the number of 1s is even (even parity). If \(P = 1\), the number of 1s is odd (odd parity).

Answer: XOR gates efficiently compute parity by combining bits pairwise.

Example 5: Combining Multiple Gates to Implement a Logic Function Hard
Implement the logic function \( Y = \overline{A} \cdot B + A \cdot \overline{B} + A \cdot B \) using AND, OR, and NOT gates.

Step 1: Analyze the expression:

\[ Y = \overline{A} \cdot B + A \cdot \overline{B} + A \cdot B \]

Step 2: Notice that the first two terms represent XOR, and the last term is AND.

Step 3: Simplify the expression:

\[ Y = (A \oplus B) + (A \cdot B) \]

Step 4: Recognize that \( (A \oplus B) + (A \cdot B) = A + B \) (since OR covers all cases except both 0).

Step 5: Therefore, the simplified expression is:

\[ Y = A + B \]

Step 6: Implement the circuit using a single OR gate with inputs A and B.

Answer: The complex function simplifies to \(Y = A + B\), implemented with one OR gate.

Tips & Tricks

Tip: Remember that NAND and NOR gates are universal gates and can be used to implement any logic function.

When to use: When simplifying circuits or designing with limited gate types.

Tip: Always use truth tables to verify your logic expressions before implementing circuits.

When to use: During problem solving and circuit design.

Tip: Apply Boolean algebra laws like De Morgan's Theorems to simplify expressions quickly.

When to use: When simplifying complex Boolean expressions.

Tip: For XOR gates, remember output is 1 only when inputs differ, useful in parity and error detection.

When to use: In problems involving parity bits or conditional logic.

Tip: Use Karnaugh Maps (K-maps) to minimize Boolean expressions visually and efficiently.

When to use: When simplifying multi-variable Boolean expressions.

Common Mistakes to Avoid

❌ Confusing the output of NAND and AND gates by forgetting the inversion.
✓ Always remember NAND output is the complement of AND output.
Why: NAND gate is an AND gate followed by a NOT gate, so the output is inverted.
❌ Incorrectly constructing truth tables by missing input combinations.
✓ List all possible input combinations systematically (2^n for n inputs).
Why: Missing rows leads to incomplete or wrong truth tables and incorrect logic conclusions.
❌ Misapplying Boolean algebra laws, especially De Morgan's Theorems.
✓ Review and practice the correct application of each law with examples.
Why: De Morgan's Theorems involve negation and distribution, which can be confusing without practice.
❌ Assuming XOR behaves like OR gate.
✓ Remember XOR outputs 1 only when inputs differ, unlike OR which outputs 1 if any input is 1.
Why: XOR's exclusive property is often misunderstood as inclusive OR.
❌ Not simplifying expressions before circuit design, leading to unnecessarily complex circuits.
✓ Always simplify Boolean expressions using algebra or K-maps before implementation.
Why: Simplification reduces circuit complexity, cost, and improves reliability.
Key Concept

Logic Gates Summary

Basic and derived gates with symbols and truth tables for quick revision.

Curated videos per subtopic
Top YouTube explainers, AI-ranked for your exam and language. Unlocks with subscription.
Unlock

Try Practice next.

Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.

Go to practice →
Ask a doubt
Logic gates · 10 free messages
Ask me anything about this subtopic. You have 10 free messages this session — chat history isn't saved in preview.