cheaper in this case means that we need less area to be integrated.

A second type of gate are exclusive OR and exclusive NOR gate.

An exclusive or gate, an XOR gate, with this symbol, is defined by this table.

The XOR of a and b is a function equal

to one when a is 0 and be is 1, or

conversely, when a is 1 and b is 0.

When a is equal to b, 0 0 or 1 1,

then the function is equal to 0.

The XNOR(a,b) is the inverse

of the XOR(a,b).

So the XNOR(a, b) = 1 when a = b and

equal to 0 when a is different from b.

As regards the XOR function, the symbol used is this one,

and sometimes in the case of the XNOR function,

the equivalence symbol is used.

Now an equivalent definition is the following.

The XOR(a, b) can also be defined

as being the modulo 2 sum of a and b.

And as we already have seen the symbol, is this one.

Modulo 2 means that you compute the real sum of a and

b in this case, and then you reduce the obtained result

to 0 if the result is even and to 1 if the result is odd.

So a + b, if the result is even,

then the XOR function of a and b is equal to 0.

If the result is odd, then the XOR function is equal to 1.

The XNOR function of a and

b is the inverse of the XOR(a, b).

Then with this new definition it's very easy to define 3-input,

4-input, and so on XOR and XNOR gates.

For example, the XOR(a,

b, c) is the real value of a + b + c modulo 2.

The XNOR(a, b, c) is the inverse of the XOR(a, b, c).

Similarly, the XOR(a,b,c,d) is

obtained by computing a + b + c + d modulo 2.

The XNOR(a, b, c, d) is the inverse of the XOR(a, b, c, d).

An important conclusion is that the XOR function

is an associative operation so that in this case,

it's true that you can build a 3-input XOR gate using for

that two 2-input XOR gates.

And as regards the XNOR gate,

a 3-input XNOR gate can be implemented in this

way with one XOR gate and one XNOR gate.

Don't forget that the little circle always corresponds to an inverse.

Let us see now several applications of XOR gates.

As a first example, consider a magnitude comparator.

Given, for example, two 4-input vectors a and

b, a comparator will generate an output 1 if and

only if vector a is equal to vector b.

We could use for that this very simple algorithm.

If a3 is different from b3 or

if a2 is different from b2 or a1 different from b1 or

a0 different from b0, then a is not the same as b so

that the output comp will be equal to 0.

If the condition doesn't hold,

it means that a3 is equal to b3 and a2 is equal to b2,

and a1 equal to b1, and a0 equal to b0 so

that both vector are equal and the output is equal to 1.

To this algorithm corresponds this circuit.

Therefore, two input XOR gates

correspond to the four comparisons.