The boolean expression of an XOR gate is Y = A ⊕ B (algebraically written as Y = AB' + A'B), meaning the output yields a logic HIGH only when exactly one of its inputs is HIGH. In a physical circuit, this logic function changes a parallel binary state into a mismatch detector, a controllable inverter, or an error-detecting parity bit. Makers commonly confuse the exclusive-OR (XOR) with the standard inclusive-OR gate (which outputs HIGH if both inputs are HIGH) or the XNOR gate (which outputs HIGH when inputs match). Understanding the exact boolean math behind the XOR gate is the difference between designing a reliable digital phase detector and building a circuit that toggles randomly due to noise.

The Boolean Expression of XOR Gate Decoded

To read the boolean expression of an XOR gate on a schematic or datasheet, you need to break down the algebraic sum of products. The expression Y = AB' + A'B translates directly to hardware: you need two AND gates, two NOT gates (inverters), and one OR gate to build it from discrete logic.

Bench Tip: When reading schematics, the XOR symbol is a standard OR gate shape with an extra curved line at the input side. If that curved line has a bubble on the output, you are looking at an XNOR gate, which is simply an XOR gate followed by an inverter (Y = (A ⊕ B)').

Here is the definitive truth table that maps the boolean expression to physical voltage states:

Input AInput BA AND B'A' AND BOutput Y (A ⊕ B)
0 (LOW)0 (LOW)000 (LOW)
0 (LOW)1 (HIGH)011 (HIGH)
1 (HIGH)0 (LOW)101 (HIGH)
1 (HIGH)1 (HIGH)000 (LOW)

The critical takeaway from this table is the 1,1 input state. Unlike a standard OR gate, the XOR gate rejects the condition where both inputs are asserted. This 'rejection' is what makes it the fundamental building block for binary addition and parity checking.

Worked Numeric Example: 74HC86 Half-Adder Propagation

Let's move from abstract algebra to the workbench. Suppose you are building a 4-bit ripple carry adder using a Texas Instruments SN74HC86 quad 2-input XOR IC. You are using it to generate the 'Sum' bits, while a separate AND gate handles the 'Carry' bits.

Let's calculate the real-world timing and voltage thresholds for a single bit addition where Input A is 5.0V (Logic 1) and Input B is 0.2V (Logic 0).

  1. Verify Voltage Thresholds: For a 74HC86 operating at VCC = 5.0V, the minimum HIGH-level input voltage (V_IH) is 3.15V, and the maximum LOW-level input voltage (V_IL) is 1.35V. Our inputs (5.0V and 0.2V) have excellent noise margins.
  2. Determine Logic State: Since A=1 and B=0, the boolean expression Y = AB' + A'B resolves to Y = (1)(1) + (0)(0) = 1. The output will drive HIGH.
  3. Calculate Propagation Delay: According to the datasheet, the typical propagation delay (t_pd) from input to output at 5V and 25°C is 14ns, with a maximum guaranteed delay of
    18ns
    across the full -40°C to 85°C range.
  4. Cascade the Delay: In a 4-bit ripple adder, the carry signal must ripple through all four bits sequentially. The worst-case propagation delay for the final Sum bit is the sum of the delays through four XOR gates and four AND gates. Assuming 18ns max for the XOR and 18ns for the AND, your worst-case total delay is roughly 144ns before the final output settles.

If your system clock is running at 10 MHz (100ns period), this 144ns propagation delay means the adder will fail to settle before the next clock edge. You would need to switch to a faster logic family, like 74LVC or 74AUC, or redesign as a carry-lookahead adder.

Where You Meet This in Practice

You rarely wire up discrete XOR gates just to perform basic logic inversion. In modern electrical and electronics design, the boolean expression of an XOR gate manifests in three highly specific practical applications:

  • Quadrature Encoder Decoding: When reading rotary encoders on a motor shaft, the A and B channels are 90 degrees out of phase. Feeding these into an XOR gate yields a pulse train that doubles the resolution (counting both rising and falling edges) and helps determine direction when paired with a D flip-flop.
  • Parity Generators and Checkers: In serial communication (like UART or SPI), an XOR tree is used to generate a parity bit. If you XOR all the data bits together, the output is 1 if there is an odd number of HIGHs (odd parity). The receiver runs the same boolean math to verify data integrity.
  • Phase Detectors in PLLs: In a Phase-Locked Loop (PLL), a digital phase detector is often just an XOR gate. If the reference clock and the VCO output are perfectly in phase (or exactly 180° out), the output duty cycle changes proportionally to the phase error, which is then filtered into a DC control voltage.

Bench Scenario: The Ghost-Switching CD4030 Parity Checker

Theory is clean; the bench is messy. Here is a real-world scenario demonstrating what happens when you ignore the physical realities of the IC housing the boolean logic.

The Setup: A hobbyist was building a digital 3-way switch replacement for a long hallway using a CD4030BE CMOS quad XOR gate. The idea was simple: two SPST toggle switches at opposite ends of the hall fed into the inputs of the XOR gate. The output drove a MOSFET to switch a 12V LED strip. Flipping either switch changes the state of exactly one input, toggling the XOR output and the light.

The Numbers: The CD4030 was powered by a 12V supply (VDD = 12V, VSS = 0V). The switches connected the inputs directly to VDD when closed. When open, the switches were left completely disconnected (floating).

The Outcome: The light worked perfectly when toggling the switches. However, the light would randomly turn on and off when the HVAC system kicked on, or even when someone walked past the wall carrying a running cordless drill. The XOR gate was 'ghost switching'.

What Went Wrong: The builder forgot the fundamental rule of CMOS logic: never leave an input floating. CMOS inputs have an ultra-high impedance (often >10^12 Ω). Without a pull-down resistor to ground when the switch was open, the floating input pin acted as a high-gain antenna. It picked up 60Hz electromagnetic interference from the HVAC wiring and the drill motor. This induced AC voltage easily crossed the CD4030's V_IH threshold (which is roughly 70% of VDD, or 8.4V), causing the boolean expression to rapidly evaluate and re-evaluate, toggling the output MOSFET.

The Fix: Always add a 10kΩ to 100kΩ pull-down resistor from each XOR input to ground (VSS) when using mechanical switches that only pull the line HIGH. This bleeds off induced noise and forces a solid Logic 0 when the switch is open.

Frequently Asked Questions

Can I use an XOR gate as a controllable inverter?

Yes. If you tie Input A to your data signal and Input B to a control line, the XOR gate acts as a programmable inverter. When B is LOW (0), the boolean expression Y = A(1) + A'(0) simplifies to Y = A (the signal passes through unchanged). When B is HIGH (1), the expression simplifies to Y = A' (the signal is inverted). This is heavily used in ALU (Arithmetic Logic Unit) designs to switch between addition and subtraction.

Why is the XOR gate called an 'inequality' detector?

Because the output is strictly HIGH only when A ≠ B. If you are comparing two digital words bit-by-bit, feeding each pair of bits into an XOR gate will yield a HIGH output on any bit position where the two words differ. OR-ing all those XOR outputs together gives you a single 'mismatch' flag.

What is the difference in power draw between TTL and CMOS XOR gates?

A classic TTL gate like the 74LS86 draws a continuous quiescent current of about 1mA to 2mA per gate, regardless of switching, because of its internal bipolar transistor biasing. A CMOS gate like the CD4030 or 74HC86 draws virtually zero quiescent current (microamps) when static. However, CMOS power draw scales linearly with switching frequency due to the charging and discharging of internal gate capacitances. At very high frequencies (e.g., >20 MHz), a CMOS XOR gate can actually dissipate more dynamic power than a TTL equivalent.