I'll add two more very simple, area-efficient, and fast MOSFET implementations of the XOR. The XOR is a critical part of many digital circuits, such as random number generators and adders. Therefore efficient XOR implementations are very desirable. The implementations below are in most ways superior to the brute-force CMOS implementations given in previous writeups.

OUT = A (XOR) B

              _
              B
              |
            -----
            -----
           |     |
 A----------     -----
                     |
                     |
                     |         OUT
              B      |-----------             
              |      |
            -----    |
            -----    |
 _         |     |   |
 A----------     -----
                               

The NMOSFETs are called "pass transistors"--they only pass the binary values on the left if they are on. The biggest problem with this pass transistor implementation is that NMOSFETs pass weak 1's (they pass the power supply voltage minus the NMOS threshold voltage). This problem can be rectified by adding PMOSFETs gated with opposite-polarity signals in parallel to the NMOSFETs. Such a parallel combination of an NMOSFET and PMOSFET is called a transmission gate. Notice that this XOR implementation does not consume static power--one of the MOSFETs is off at all times (assuming the inversion of B is instantaneous--in reality it will probably be lagged, which creates problems).

And another one (with rail to rail swing--notice that it doesn't require A to be inverted!)

OUT = A (XOR) B




       B
       |
       |
       |
      -               B
    ||                |
 A-o||                o
    ||              -----
      -             -----
       |    OUT    |     |
       |-----------|     |___ A
       |           |     |
      -            |     |
    ||              -----
 A--||              -----
    ||                |
      -               |
       |              _
       |              B
       |
       _ 
       B