Exclusive OR (XOR) and Exclusive NOR (XNOR)
The Exclusive OR (or XOR) relationship
The XOR function is frequently used in digital circuits to manipulate signals that represent binary numbers—these circuits will be presented in a later module. For now, note the XOR output is asserted whenever an odd number of inputs are asserted. This “odd detector” nature of the XOR relationship holds for any number of inputs.
Compound XOR functions like
The XNOR function is the inverse of the XOR function. Since the output of a 2-input XNOR is asserted when both inputs are the same, it is sometimes referred to as the Equivalence function (EQV), but this name is misleading because it does not hold for three or more variables (i.e., the output of a 3-input XNOR is not asserted whenever all three inputs are the same). Truth tables for 2 and 3 input XNOR functions are shown in Fig. 2, and it can be seen that for each combination of inputs, the output is the inverse of the XOR truth tables above. The Exclusive NOR (or XNOR) relationship
If either the A or B inputs are in the XNOR truth table inverted, then XOR outputs are produced; that is,
More succinctly, inverting an odd number of inputs changes an XOR to an XNOR and vice-versa, inverting an even number of inputs changes nothing, and inverting the entire function has the same effect as inverting a single input. Some representative cases are shown.
An even more succinct description of the XOR and XNOR function outputs can be drawn from the properties discussed. The XOR output is asserted whenever an odd number of inputs are asserted, and the XNOR is asserted whenever an even number of inputs are asserted: the XOR is an odd detector, and the XNOR an even detector. This very useful property will be exploited in data error detection circuits discussed later.
XOR and XNOR gate symbols are shown below in Fig. 3. CMOS circuits for either function can be can built from just 6 transistors, but those circuits have some undesirable features. More typically, XOR and XNOR logic gates are built from three NAND gates and two inverters, and so take 16 transistors.
A useful application of the XOR function is the “controlled inverter” circuit illustrated below in Fig. 4. The truth table, derived directly from the XOR truth table, uses an XOR gate with one input tied to a signal named “control”. When control is a ‘1’ the input A is inverted, but when control is a ‘0’ A is simply passed through the logic gate without modification. This controlled inversion function will be useful in later work.
Important Ideas
- The XOR output is asserted whenever an odd number of inputs are asserted, and the XNOR is asserted whenever an even number of inputs are asserted: the XOR is an odd detector, and the XNOR, an even detector.
- Any odd number of input inversion changes the function output between the XOR and XNOR functions; any even number of input signal inversions does not change function outputs; any three input signal inversions changes the function output
- Xor gate can be used as a “controlled inverter”.