Exclusive OR Gate: what it is & how it works

The Exclusive OR gate can be a very useful logic gate, giving a 'High' output only when either one or the other of its inputs are 'High' and not both


Logic / Digital Design Includes:
Logic gate types     Logic truth table     How to convert NAND / NOR gates with inverters     Exclusive OR, XOR     RS Flip-Flop     Edge triggered RS Flip-Flop     Programmable inverter     D-type frequency divider    


The exclusive OR gate, often represented as XOR can be a very useful and important gate and function to use in any logic or digital design.

The standard OR gate gives a high output when either or both of the inputs are high, and this is fine for many situations.

However the exclusive OR gate, XOR gives a high output when only one or the other input is high and not both of them.

Also like other popular gates, there are the inverted output versions, the not-exclusive OR gate like the NAND and NOR gates.

Exclusive OR, XOR symbol

Like all logic symbols there is a standard circuit symbol for te exclusive OR, XOR gate and this is widely used in circuit diagrams as there are many chips that provide the XOR function.

Exclusive OR, XOR circuit symbol
Exclusive OR, XOR circuit symbol

Like other basic gates there are also versions with inverted outputs - the exclusive NOR gate. There are many chips that contain exclusive NOR gates.

Exclusive NOR, circuit symbol
Exclusive NOR, circuit symbol

Occasionally the small circles as seen on the output of the NOR gate may also be seen on the input. This effectively is the same as having inverter gates on the relevant input lines.

Exclusive OR truth table

It helps to summarise the output states for the exclusive OR for the different input levels in a truth table.


Exclusive OR Truth Table
 
Input 1 Input 2 Output
0 0 0
1 0 1
0 1 1
1 1 0

Exclusive NOR truth table

Exclusive NOR gates are also widely used and accordingly its truth table is included below as a reference.


Exclusive NOR Truth Table
 
Input 1 Input 2 Output
0 0 1
1 0 0
0 1 0
1 1 1

Synthesising XOR from other gates

It is useful to understand the composition of an exclusive OR gate, in some circumstances. It may also be necessary in some instances to synthesise on from other gates, if an exclusive OR gate is not available for some reason.

Although the XOR function uses a number of other gates to be able to synthesise it, the circuit is actually quite straightforward.

Exclusive OR synthesised from other gates
Exclusive OR synthesised from other gates

Although the need to synthesise an XOR gate from other gate types is unlikely to happen very often it is very helpful to see how it can be done. It is also a question that sometimes appears in interview and other questions.

Exclusive OR applications

the exclusive OR gate is one of the basic building blocks for many logic circuits, and although it is not one of the fundamental logic functions, it is nevertheless very widely used in a number of specific areas.

  •   General logic

The exclusive OR gate is often used in basic logic circuits where its function of only giving an output when either but not both of the inputs are activated.

  •   Computational circuits

XOR gates are extensively used in computational circuits, and especially in adders and half adders.

  •   Pseudo-random number generator

When used within a loop, the XOR function can be used as part of a pseudo-random number generator.

The circuit is based around a shift register and the output is fed back toth e input via the exclusive OR.

The output from this type of generator is only pseudo-random because the number repeats after a givne number of digits.

By having a larger number of stages in the shift register, the repeat interval will become longer.

  •   Phase detector

An exclusive OR, XOR gate can be usedas a phase detector in RF circuits like phase locked loops, frequency synthesizers,etc.

the circuit can provide a very useful simple phase detector for some applications. Being digital in format it can often fit into a phase locked loop with ease as many of the circuits associated with phase locked loops may already have many digital ICs and functions. Alternatively an exclusive OR can be made from discrete components to give a wider variety of levels and other options.

Exclusive OR XOR phase detector
Exclusive OR phase detector

The way in which an exclusive OR, XOR phase detector works can be seen by the diagram below:

XOR phase detector response curve
XOR phase detector response waveforms

It can be seen that using these waveforms, the XOR logic gate can be used as a simple but effective phase detector.

As might be expected for such a simple circuit, there are a few drawbacks to using an XOR phase detector:

  • The phase detector is sensitive to the clock duty cycle. This means that a steady duty cycle, i.e. 1:1 should be used. It will lock with a phase error if the input duty cycles are not 50%.
  • The output characteristic of the XOR phase detector show repetitions and gain changes. This means that if there is a frequency difference between the input reference and PLL feedback signals the phase detector can jump between regions of different gain. The characteristic of the phase detector is as shown below:
     XOR phase detector response
    XOR phase detector response curve
  • The nominal lock point with an XOR phase detector is also at the 90° static phase shift point.

Unlike an analogue mixer phase detector, the XOR version is independent of input amplitude and constant over a π phase range.


More Digital Logic and Embedded Topics:
FPGA programming     Embedded systems     How a computer works     Logic circuit design basics     Logic / circuit design guidelines    
    Return to Digital / Logic / Processing menu . . .