XOR Gate (Exclusive OR)

The XOR gate outputs HIGH when inputs are DIFFERENT - one or the other, but not both.

The XOR gate (Exclusive OR) outputs HIGH when its inputs are different. If both inputs are the same (both 0 or both 1), the output is LOW. XOR is fundamental to arithmetic, parity checking, and encryption.

Objectives

  • Understand XOR vs regular OR
  • Use XOR for parity generation and checking
  • Apply XOR in binary addition (half adder)
  • Understand XOR's self-inverse property
  • Use XOR for controlled inversion and encryption

Key Takeaways

  • XOR outputs HIGH when inputs are DIFFERENT
  • XOR outputs LOW when inputs are the SAME
  • Notation: A ⊕ B, A ^ B, A XOR B
  • Self-inverse: A ⊕ A = 0, A ⊕ B ⊕ B = A
  • Multi-input XOR = 1 when ODD number of 1s
  • Common IC: 74HC86 (four 2-input XOR gates)
  • Essential for parity, addition, comparators, and encryption

Applications

  • Parity Generation: XOR all bits to get parity bit for error detection
  • Binary Addition: XOR produces the sum bit in a half adder
  • Comparator: XOR outputs 1 when inputs differ (inequality detection)
  • Controlled Inverter: XOR with 0 passes signal, XOR with 1 inverts it
  • Encryption: XOR with key encrypts; XOR again decrypts (stream ciphers)

Practice Problems

Problem 1: What is 1 XOR 1?

Problem 2: What is 0 XOR 1 XOR 1 XOR 0?

Problem 3: Simplify A XOR A XOR A

Problem 4: Find parity of 11010111