<P> If a specific type of gate is not available, a circuit that implements the same function can be constructed from other available gates . A circuit implementing an XOR function can be trivially constructed from an XNOR gate followed by a NOT gate . If we consider the expression A ⋅ B _̄ + A _̄ ⋅ B (\ displaystyle A \ cdot (\ overline (B)) + (\ overline (A)) \ cdot B), we can construct an XOR gate circuit directly using AND, OR and NOT gates . However, this approach requires five gates of three different kinds . </P> <P> As an alternative, if different gates are available we can apply Boolean algebra to transform A ⋅ B _̄ + A _̄ ⋅ B ≡ (A + B) ⋅ (\ displaystyle A \ cdot (\ overline (B)) + (\ overline (A)) \ cdot B \ equiv (A + B) \ cdot) (A _̄ + B _̄) (\ displaystyle ((\ overline (A)) + (\ overline (B)))) as stated above, and apply de Morgan's Law to the last term to get (A + B) ⋅ (\ displaystyle (A + B) \ cdot) (A ⋅ B) _̄ (\ displaystyle (\ overline ((A \ cdot B)))) which can be implemented using only three gates as shown on the right . </P> <P> An XOR gate circuit can be made from four NAND gates . In fact, both NAND and NOR gates are so - called "universal gates" and any logical function can be constructed from either NAND logic or NOR logic alone . If the four NAND gates are replaced by NOR gates, this results in an XNOR gate, which can be converted to an XOR gate by inverting the output or one of the inputs (e.g. with a fifth NOR gate). An alternative arrangement is of five NOR gates in a topology that emphasizes the construction of the function from (A + B) ⋅ (\ displaystyle (A + B) \ cdot) (A _̄ + B _̄) (\ displaystyle ((\ overline (A)) + (\ overline (B)))) (noting from de Morgan's Law that a NOR gate is, in effect, an inverted - input AND gate). Two possible configurations constructed from NAND gates and two possible configurations constructed from NOR gates are shown below . </P> <Table> <Tr> <Th> Desired gate </Th> <Th> NAND construction </Th> <Th> NOR construction </Th> </Tr> <Tr> <Td> </Td> <Td> </Td> <Td> </Td> </Tr> <Tr> <Td> </Td> <Td> </Td> </Tr> </Table>

Xor gate using minimum number of nand gates