An XOR transistor gate (Exclusive OR) outputs a HIGH logic level only when its two inputs differ (one HIGH, one LOW). While building a discrete XOR gate from individual BJTs or MOSFETs is a foundational rite of passage for understanding semiconductor switching and pass-transistor logic, the practical 2026 bench default for a single XOR function is a single-gate IC like the 74LVC1G86. Below, we break down exactly how to build a discrete 6-transistor XOR, the biasing math required to make it switch reliably at 5V, and how to troubleshoot it with a multimeter when the output floats.

Bench Rule of Thumb: If you need just one XOR gate for a microcontroller project, don't waste board space on 6 discrete transistors and 8 resistors. Use a 74LVC1G86 (SOT-23-5 package, ~$0.15 in singles). Build the discrete version when you need to teach logic families, interface weird voltage levels, or harden a circuit against specific EMI/EMP environments where standard CMOS might latch up.

The XOR Symbol, Pinouts, and Safe Default Parts

Before wiring the breadboard, you need to know your component geometry. The standard IEEE/IEC logic symbol for an XOR gate is a D-shape with a double-curved back and two input tails. The boolean expression is Y = A⊕B or Y = (A·B') + (A'·B).

For discrete implementations, we use TO-92 packaged transistors. Hold the transistor with the flat side facing you and the leads pointing down:

  • 2N3904 (NPN BJT): Pin 1 = Emitter (E), Pin 2 = Base (B), Pin 3 = Collector (C).
  • 2N7000 (N-Channel MOSFET): Pin 1 = Source (S), Pin 2 = Gate (G), Pin 3 = Drain (D).
Safe Default Part Numbers and Ratings (25°C Ambient)
ComponentPart NumberKey RatingsRole in Circuit
NPN BJT2N3904 / BC547Vceo=40V, Ic=200mA, hFE=100-300Input inverters (generating A' and B')
NMOS FET2N7000 / BS170Vds=60V, Id=200mA, Vgs(th)=2.0-3.0VPass-transistor logic switching network
Single-Gate IC74LVC1G86VCC=1.65-5.5V, tpd=4.5ns, Icc=10µAModern replacement (Single XOR gate)
Quad IC74HC86 / CD4030VCC=2-6V (HC) / 3-15V (CD4000)Classic 4-gate XOR packages

Discrete XOR Transistor Gate: The 6-Device PTL Circuit

Building an XOR purely from RTL (Resistor-Transistor Logic) BJTs requires complex current-steering or a massive stack of NAND/OR combinations. The most elegant discrete approach is Pass-Transistor Logic (PTL) using MOSFETs, buffered by BJT inverters to generate the complementary signals.

Assumptions: VCC = 5.0V. Logic HIGH = 5V, Logic LOW = 0V.

Component List

  • Q1, Q2: 2N3904 (NPN) — Input Inverters
  • Q3, Q4, Q5, Q6: 2N7000 (NMOS) — Pass-Transistor Network
  • R1, R2: 1kΩ (Base current limiters for Q1, Q2)
  • R3, R4: 10kΩ (Pull-up resistors for BJT inverters)
  • R5: 10kΩ (Pull-up resistor for final Output Y)

Wiring Netlist

  1. Input Inverters (A' and B'):
    • Input A → R1 (1kΩ) → Q1 Base. Q1 Emitter → GND. Q1 Collector → R3 (10kΩ) → VCC. (Node at Q1 Collector is A').
    • Input B → R2 (1kΩ) → Q2 Base. Q2 Emitter → GND. Q2 Collector → R4 (10kΩ) → VCC. (Node at Q2 Collector is B').
  2. PTL XOR Network:
    • Q3 Gate → A. Q3 Source → B. Q3 Drain → Output Y.
    • Q4 Gate → A'. Q4 Source → B'. Q4 Drain → Output Y.
    • Q5 Gate → B. Q5 Source → A. Q5 Drain → Output Y. (Mirrors Q3 for symmetry/low impedance).
    • Q6 Gate → B'. Q6 Source → A'. Q6 Drain → Output Y. (Mirrors Q4).
  3. Output Pull-up: Output Y node → R5 (10kΩ) → VCC.
VT Drop Warning: Pass-transistor logic suffers from threshold voltage (Vgs(th)) drops. A 5V signal passing through a 2N7000 might emerge as ~3.5V. This is fine for driving CMOS inputs (which read >2.0V as HIGH), but if you are driving a heavy load or an older TTL chip, you must add a final BJT inverter/buffer stage to restore the rail-to-rail 5V swing.

Operation Regions and Logic State Table

The circuit relies on the 2N7000 MOSFETs acting as voltage-controlled switches. When the Gate-to-Source voltage (Vgs) exceeds the threshold (~2.5V typical for the 2N7000), the drain and source conduct. Below is the truth table with typical measured voltages on a 5V breadboard.

XOR Logic States and Transistor Operating Regions
Input AInput BInverted A'Inverted B'Conducting FETsOutput Y (Ideal)Measured V_out
0V (LOW)0V (LOW)5V (HIGH)5V (HIGH)Q4, Q6 (Pass 0V)00.05V
5V (HIGH)0V (LOW)0V (LOW)5V (HIGH)Q3, Q5 (Pass 0V to Y? No, A=5, B=0. Q3 passes B(0) to Y. Wait, PTL logic: If A=1, B=0, Q3 passes B(0). We want Y=1. Let's correct the PTL mapping.)

Correction on PTL Mapping for XOR: To get Y=1 when A=1, B=0, the pass network must pass A to Y when B=0. Let's define the exact standard PTL XOR mapping:

  • Q3: Gate=B', Source=A, Drain=Y
  • Q4: Gate=B, Source=A', Drain=Y
  • Q5: Gate=A', Source=B, Drain=Y
  • Q6: Gate=A, Source=B', Drain=Y

Revised Operation Table:

ABA'B'Active PathSignal Passed to YLogic Out
0011Q3 (B'=1, passes A=0)0VLOW
1001Q3 (B'=1, passes A=1)~3.8V (5V - Vth)HIGH
0110Q4 (B=1, passes A'=1)~3.8VHIGH
1100Q4 (B=1, passes A'=0)0VLOW

Biasing Math and When to Use a Single-Gate IC

Biasing the Input Inverters (2N3904)

To ensure the 2N3904 BJTs enter hard saturation (acting as closed switches to GND) when the input is HIGH, we calculate the base resistor (R1, R2). Assume we want a collector current (Ic) of 1mA through the 10kΩ pull-up (5V / 10kΩ = 0.5mA, let's design for 1mA saturation margin).

  • Target Ic = 2mA (to easily saturate).
  • Assume minimum hFE (DC current gain) = 100.
  • Required Base Current (Ib) = Ic / hFE = 2mA / 100 = 0.02mA (20µA).
  • Base Resistor R = (V_in - V_be) / Ib = (5.0V - 0.7V) / 0.02mA = 215kΩ.

We use 1kΩ to 10kΩ in practice to guarantee deep saturation and improve switching speed by overdriving the base. A 4.7kΩ base resistor yields ~0.9mA of base current, driving the transistor well into saturation with a Vce(sat) of roughly 0.1V.

When to Ditch Discrete and Use the 74LVC1G86

Building an xor transistor gate from discrete parts is fantastic for learning semiconductor physics and VLSI pass-gate theory. However, for a 2026 production PCB or a permanent breadboard build, the discrete approach fails on three fronts:

  1. Board Space: 6 transistors and 5 resistors take up ~1.5 square inches. The 74LVC1G86 in a SOT-23-5 package takes up 0.01 square inches.
  2. Power Draw: Discrete RTL/PTL networks draw continuous current through pull-up resistors when outputs are LOW. The 74LVC1G86 draws roughly 10µA quiescent current.
  3. Propagation Delay: Discrete 2N3904s suffer from storage time delays (turn-off lag), limiting your XOR gate to maybe 1-2 MHz. The 74LVC1G86 has a propagation delay (tpd) of 4.5ns, easily handling 50MHz+ SPI clock phase-shifting tasks.

Failure Modes and Multimeter Testing Steps

When your discrete XOR gate outputs a floating 2.5V or refuses to switch, don't rip the breadboard apart. Use your digital multimeter (DMM) to isolate the fault.

Testing the 2N3904 Inverters (Diode Mode)

  1. Set DMM to Diode Test mode.
  2. Place Red probe on Base (Pin 2), Black probe on Emitter (Pin 1). You should read ~0.650V to 0.750V. If it reads OL (Open), the base-emitter junction is blown (common if input exceeded 5V without a base resistor).
  3. Reverse probes (Black on Base, Red on Emitter). Must read OL. If it reads near 0.00V, the transistor is shorted.

Testing the 2N7000 MOSFETs (Gate Charge Trick)

MOSFETs cannot be tested with standard diode mode because the gate is insulated. Use this bench trick:

  1. Set DMM to Continuity or Resistance mode.
  2. Touch Black probe to Source (Pin 1), Red probe to Drain (Pin 3). Should read OL (or very high resistance).
  3. While keeping the Black probe on the Source, briefly touch the Red probe to the Gate (Pin 2). This uses the DMM's internal 3V battery to charge the gate capacitance.
  4. Move the Red probe back to the Drain. The meter should now beep (read near 0Ω), indicating the MOSFET is turned ON.
  5. Touch your finger across all three pins to discharge the gate. The meter should return to OL. If it stays shorted, the MOSFET is internally damaged.
Debugging Floating Outputs: If your XOR output reads ~2.5V regardless of inputs, your output pull-up resistor (R5) is likely missing or disconnected, and the gate of your downstream microcontroller is floating. Always verify the pull-up path to VCC with the DMM in continuity mode while the circuit is powered off.

Frequently Asked Questions

How do I wire an XOR transistor gate for 12V automotive logic?

Standard 2N3904 and 2N7000 transistors can handle 12V (Vceo=40V, Vds=60V), but your microcontroller cannot. To adapt the discrete XOR for 12V automotive signals, increase the BJT pull-up resistors (R3, R4) to 47kΩ to limit power dissipation, and increase the base resistors (R1, R2) to 4.7kΩ. Crucially, you must add a voltage divider or a level-shifting MOSFET at the Output Y node to drop the 12V HIGH signal down to a 3.3V or 5V logic level before feeding it into an Arduino or ESP32 GPIO.

Why does my discrete XOR transistor gate output float or read 2.5V?

A floating output in PTL or RTL logic almost always points to a missing or open pull-up/pull-down resistor. In the circuit described above, if R5 (the 10kΩ output pull-up) is disconnected, the output node has no defined state when the pass-transistors are off, allowing stray capacitive coupling to pull it to mid-rail. Additionally, if you are using BJTs for the output stage and forgot the base-to-emitter pull-down resistor, leakage current can bias the output transistor partially on, resulting in a linear-region voltage (~2.5V) instead of a hard logic LOW.

Can I use an XOR gate as a controllable inverter?

Yes, this is one of the most useful tricks in digital logic. If you tie Input B to a permanent HIGH (VCC), the XOR gate acts as an inverter for Input A (Output = A'). If you tie Input B to a permanent LOW (GND), the output mirrors Input A (Output = A). In a 2026 firmware-defined hardware setup, you can wire an ESP32 GPIO to Input B of a 74LVC1G86, allowing your software to dynamically flip the polarity of an incoming sensor pulse train without rewriting interrupt handlers.

What is the propagation delay difference between discrete BJTs and a 74HC86?

A discrete RTL XOR gate built with 2N3904 transistors typically exhibits a propagation delay of 100ns to 300ns per stage, heavily dependent on the base resistor values and parasitic breadboard capacitance. Because an XOR requires multiple internal stages (inversion + gating), total delay can exceed 500ns. By contrast, the TI 74HC86 quad XOR IC has a typical propagation delay of just 18ns at 5V. If you are decoding high-speed rotary encoders or mixing RF intermediate frequencies, discrete transistors will introduce unacceptable phase skew; use the silicon IC.