Logic gates

Comprehensive study notes, diagrams, and exam preparation for Logic gates.

Logic Gates

Definition

A logic gate is an electronic circuit that accepts one or more binary inputs and produces a single binary output according to a specific logical function, such as AND, OR, NOT, NAND, NOR, XOR, or XNOR.

Each gate follows a truth table that shows the output for every possible input combination. Logic gates are implemented using switches, diodes, transistors, or integrated circuits, and they form the basis of all digital systems.


Main Content

1. Binary Logic and the Role of Logic Gates

  • Logic gates work only with binary values, where:
  • 0 represents false, low voltage, or OFF
  • 1 represents true, high voltage, or ON
  • Because computers and digital devices internally use binary, logic gates are essential for:
  • decision-making
  • arithmetic processing
  • data storage control
  • signal manipulation

A simple binary condition can be written as:

  • A = 0 or A = 1
  • B = 0 or B = 1

Logic gates combine these values to produce outputs.

Example: If a circuit receives:

  • A = 1
  • B = 0

then an AND gate gives output 0, while an OR gate gives output 1.

This makes logic gates the basic “decision units” of digital electronics.


2. Basic Logic Gates and Their Functions

AND Gate

  • Output is 1 only if all inputs are 1
  • Boolean expression: Y = A · B
  • Truth table:
    • 0,0 → 0
    • 0,1 → 0
    • 1,0 → 0
    • 1,1 → 1
  • Used when all conditions must be satisfied.

OR Gate

  • Output is 1 if at least one input is 1
  • Boolean expression: Y = A + B
  • Truth table:
    • 0,0 → 0
    • 0,1 → 1
    • 1,0 → 1
    • 1,1 → 1
  • Used when any one of several conditions can activate the output.

NOT Gate

  • Output is the inverse of the input
  • Boolean expression: Y = A' or Y = ¬A
  • Truth table:
    • 0 → 1
    • 1 → 0
  • Also called an inverter.
  • Used to reverse a logic state.

Example: If a security system needs both a password and a fingerprint to unlock, an AND gate models that condition. If the system unlocks when either a card or a fingerprint is valid, an OR gate is used. If a signal must be reversed, a NOT gate is used.


3. Universal and Special Logic Gates

NAND Gate

  • Output is the opposite of AND
  • Boolean expression: Y = (A · B)'
  • Output is 0 only when all inputs are 1
  • It is a universal gate, meaning any logic circuit can be built using only NAND gates.
  • Important because it is widely used in digital IC design.

NOR Gate

  • Output is the opposite of OR
  • Boolean expression: Y = (A + B)'
  • Output is 1 only when all inputs are 0
  • It is also a universal gate
  • Useful in memory and control circuits.

XOR Gate

  • Output is 1 only when inputs are different
  • Boolean expression: Y = A ⊕ B
  • Truth table:
    • 0,0 → 0
    • 0,1 → 1
    • 1,0 → 1
    • 1,1 → 0
  • Used in addition circuits and comparison operations.

XNOR Gate

  • Output is 1 only when inputs are the same
  • Boolean expression: Y = (A ⊕ B)'
  • Truth table:
    • 0,0 → 1
    • 0,1 → 0
    • 1,0 → 0
    • 1,1 → 1
  • Used in equality checking.

Example: If two binary numbers are being compared bit by bit, XNOR outputs 1 when the bits match. This is useful in digital comparators.


Working / Process

1. Apply binary inputs

  • The gate receives one or more input signals in binary form, such as 0 and 1.
  • These inputs represent voltage levels in hardware.

2. Perform the logical operation

  • The gate processes the input according to its built-in rule.
  • For example:
    • AND checks whether all inputs are 1
    • OR checks whether at least one input is 1
    • NOT reverses the input value

3. Generate the binary output

  • Based on the logic rule, the gate produces an output of 0 or 1.
  • The output can then be used as the input to another gate, allowing complex digital circuits to be built.

For example, consider a circuit with input values A = 1 and B = 0:

  • AND output = 0
  • OR output = 1
  • NAND output = 1
  • NOR output = 0

This process happens extremely fast in real electronic devices, enabling modern computing.


Advantages / Applications

  • Logic gates make it possible to design digital circuits that are fast, reliable, and easy to represent using binary.
  • They are used in computers and microprocessors to perform arithmetic, logic operations, and decision-making.
  • They are essential in control systems, communication devices, calculators, alarms, and memory units, where binary decisions must be made accurately.

Other important applications include:

  • combinational circuits such as adders, subtractors, and multiplexers
  • sequential circuits such as flip-flops and registers
  • digital comparison and encoding/decoding systems
  • automation and embedded systems

Summary

  • Logic gates are basic digital circuits that operate on binary inputs to produce binary outputs.
  • They form the foundation of all modern electronic and computer systems.
  • Common gates include AND, OR, NOT, NAND, NOR, XOR, and XNOR.
  • Important terms to remember: binary, truth table, Boolean expression, universal gate, inverter, comparator