I sometimes find a small circuit with 3 resistors and 2 transistors that performs the eXclusive OR operation.
These two interlocked transistors use a very unusual structure, which requires the least theoretical number of switching elements, but it depends on a trick : the input impedances matter a lot and the circuit depends on a "hard" 0 level, because the circuit behaves almost like a "pass" element...
Thus, the question : is it the best method ? What about the switching speed or the capacitances ?
XOR is pretty important in CPUs because many mechanisms rely on it, for example ALUs. Does the gain in parts count affect the performance ? Apparently, it's pretty close to ideal because it's touted as a solution in Direct Coupled Transistor Transistor Logic:
Another version has only one transistor but 4 diodes :
Another question is : can this scheme (no amplification, just relying on the input's strength) be extended to other logic or sequential functions ?
The XOR gate has a much wider range of implementations in MOS and CMOS. You can find circuits using 4, 6, 8, 9, 10 or 12 transistors, again with varied strengths for the inputs and the output. For example, pass-transistor logic (transmission gates) makes it pretty simple :
Each pass element is a pair of complementary transistors, so this gate uses 2 NMOS and 2 PMOS. Add as many if you want to isolate the outputs with inverters...
Oh and don't forget another inverter at the output. This is why you'll find various transistor counts. Unless the designer wants to decompose the function into elementary boolean functions, and the size explodes, depending on how you break it up:
This decomposition leads to the "classic" CMOS XOR gate:
which gains weight again when the inputs are buffered and inverted :
XOR has a reputation of a "slow and large gate" for this reason and that's why I investigate smarter topologies and their compromises.
Another version is also pretty nice :
This is interesting for my #Yet Another (Discrete) Clock because it is almost suitable for MOSFETs. The B input must double the transistors because of the inherent diodes but it's "only" 3×BS170 and 3×BS250. In this case, the B input actually works as a multiplexer or transmission gate... Which means it might not be suited for ultra high speed.
Even fewer parts with this 3T XOR :
In this case, only 1×BS170 and 3×BS250 are required. It's still not ideal because the BS250 is more expensive than the BS170 but I don't see how to permute the polarities without requiring more inverters... Furthermore, there seems to be a conflict with one of the input combinations : B=1 forces the output to 0, but if A=0 then the input B (which is =1) is forced to 0 by itself... The solution is another PFET controlled by A, in series with the grounding NFET.
Another source https://waset.org/publications/1588/a-high-speed-8-transistor-full-adder-design-using-novel-3-transistor-xor-gates explains in great detail why the short circuit is not such a big deal for ICs : they tune the width/ratio of certain transistors to minimize the unwanted current. This trades space for power consumption.
M1 has a 1/1 ratio, almost a square, wih minimal size, hence highest resistance, while M3 has a high ratio to overcome the pull-down from M1. For very high-speed CMOS circuits, where power is dominated by switching (and leakage for the newest processes) this short current can be considered "negligible".
Another interesting compromise uses only 2 of each type:
But the "upper pass trick" on input A might still need doubling of the P-MOSFET to cancel the parasitic body diodes. This could be cheaper if XNOR was made instead, so 2 PFETs are tied to Vcc in series, and the NFETs are used as pass elements.
ICs use even more variations on these ideas:
An enhanced 9T XOR:
Even more combinations with pass transistors :
But I have not seen such variety for bipolar circuits.
ECL can use some creativity as well but these gates require many transistors anyway so it's not as interesting.
I have however wondered how to modify the differential amplifier to perform this operation...
I still can't find an answer about the bipolar case but I could easily adapt the interlocked system to MOSFET, in a bid to avoid P-MOSFETs. Naturally, this gives :
A rough simulation shows that there is a conflict through the parasitic body diode when the inputs are opposite.
One cheap way to avoid this case is with the insertion of diodes in series, to prevent one input from shorting into the other :
Here is the simulation with Falstad.
or for the purists : cancel the body diodes with back-to-back N-MOSFETs :
It would work at a lower supply voltage and the simulation shows the low state has a lower voltage but the speed would be 2x slower because the FETs in series double the ON resistance...
OTOH : if you want XNOR instead, just flip the circuit upside down and use P-MOSFET :