Featured post

Transaction Recording In Verilog Or System Verilog

As there is not yet a standard for transaction recording in Verilog or VHDL, ModelSim includes a set of system tasks to perform transac...

Saturday, 28 May 2011

XOR Gates

XOR gates have two bits of input and a single bit of output. The output of XOR gate is logic '1' only if the inputs have opposite values. That is, when one input has value logic '0', and the other has value logic '1'. Otherwise, the output is logic '0'.

This is called Exclusive-OR. The definition of OR is inclusive-or, where the output is logic '1' if either input is logic '1', or if both inputs are logic '1'.

XOR can be defined using AND, OR, and NOT.

x XOR y == ( x AND (NOT y) ) OR ( (NOT x) AND y ) 

Here's a diagram of the XOR2 gate.

If you look carefully at the drawing of the gate, there is a second arc behind the first one near the inputs. Since this second arc is hard to see, it's usually a good idea to write the word "XOR" inside the gate.

The truth table defines the behavior of this gate.

The function implmented by XOR gates has interesting properties:

The function is symmetric. Thus, x (+) y == y (+) x. This can be verified by using truth tables. (We use (+) to denote logical XOR--ideally, we'd draw it with a + sign inside a circle, but HTML doesn't seem to have a symbol for this).
The function is associative. Thus, [ x (+) y ] (+) z == x (+) [ y (+) z ]. This can be verified by using truth tables.
Because of these properties, it's easy to define XORn, which is an n-input XOR gate.
XORn(x1, x2,...,xn) = x1 (+) x2 (+) ... (+) xn
That is, an XOR gate with n-inputs is the XOR of all the bits. This is not ambiguous because the XOR function is associative (all parenthesization of this expression are equivalent).

No comments:

Post a Comment

Please provide valuable comments and suggestions for our motivation. Feel free to write down any query if you have regarding this post.