XOR gates and AND gates are the two most-used structures in
VLSI applications.
Addition The XOR logic gate can be used as a one-bit
adder that adds any two bits together to output one bit. For example, if we add 1 plus 1 in
binary, we expect a two-bit answer, 10 (i.e. 2 in decimal). Since the trailing
sum bit in this output is achieved with XOR, the preceding
carry bit is calculated with an
AND gate. This is the main principle in
half adders. A slightly larger
full adder circuit may be chained together in order to add longer binary numbers. In certain situations, the inputs to an OR gate (for example, in a full-adder) or to an XOR gate can never be both 1's. As this is the only combination for which the OR and XOR gate outputs differ, an
OR gate may be replaced by an XOR gate (or vice versa) without altering the resulting logic. This is convenient if the circuit is being implemented using simple integrated circuit chips which contain only one gate type per chip.
Pseudo-random number generator pseudo-random number generator|class=skin-invert-image
Pseudo-random number (PRN) generators, specifically
linear-feedback shift registers (LFSR), are defined in terms of the exclusive-or operation. Hence, a suitable setup of XOR gates can model a linear-feedback shift register, in order to generate random numbers.
Phase detectors XOR gates may be used in simplest
phase detectors.
Buffer or invert a signal An XOR gate may be used to easily change between buffering or inverting a signal. For example, XOR gates can be added to the output of a
seven-segment display decoder circuit to allow a user to choose between active-low or active-high output.
Correlation and sequence detection XOR gates produce a 0 when both inputs match. When searching for a specific bit pattern or PRN sequence in a very long data sequence, a series of XOR gates can be used to compare a string of bits from the data sequence against the target sequence in parallel. The number of 0 outputs can then be counted to determine how well the data sequence matches the target sequence. Correlators are used in many communications devices such as
CDMA receivers and decoders for error correction and channel codes. In a CDMA receiver, correlators are used to extract the polarity of a specific PRN sequence out of a combined collection of PRN sequences. A correlator looking for 11010 in the data sequence 1110100101 would compare the incoming data bits against the target sequence at every possible offset while counting the number of matches (zeros): 1110100101 (data) 11010 (target) 00111 (XOR) 2 zero bits 1110100101 11010 00000 5 zero bits 1110100101 11010 01110 2 zero bits 1110100101 11010 10011 2 zero bits 1110100101 11010 01000 4 zero bits 1110100101 11010 11111 0 zero bits Matches by offset: . : : : : : : : ----------- 0 1 2 3 4 5 In this example, the best match occurs when the target sequence is offset by 1 bit and all five bits match. When offset by 5 bits, the sequence exactly matches its inverse. By looking at the difference between the number of ones and zeros that come out of the bank of XOR gates, it is easy to see where the sequence occurs and whether or not it is inverted. Longer sequences are easier to detect than short sequences. == Analytical representation ==