Xor Gate

Abstraction and Implementation of Xor Gate in Hardware Design Language and Java™.

Xor Gate

The Xor function, also known as Exclusive-OR, returns 1 (true) when either of the inputs are same (both are 0 or both are 1 simultaneously).

Abstraction of Xor Gate - Representation and Truth Table

Implementation of Xor Gate in HDL

Xor Gate can be implemented in four ways: (in fact, they are simplifications by DeMorgan's laws.)

  • Xor Gate can be implemented using Not, And and Or gates implemented previously as follows:

Implementation of Xor Gate using two Not gates, two And gates and an Or gate.
  • Another way to implement is to substitute all gates with basic Nand gates, eventually ending up with four Nand gates.

Implementation of Xor Gate using four Nand Ga
  • We can simply the expression of first implementation of Xor gate as follows:

Output = A'B + B'A

= A'A + A'B + B'A + B'B (since A'A = B'B = 1)

= (A + B)(A' + B')

Another Implementation of Xor Gate using two Not gates, two Or gates and an And gate.
  • In the expression of third implementation of Xor gate, A' + B' can be rewritten as (AB)' [ Nand gate ] using DeMorgan's laws.

Implementation of Xor using Or, Nand and And gates.

(A + B)(A' + B') = (A + B)(AB)'

Implementation of Xor Gate in Java™

Similar to the implementations in HDL. While we're not going to implement every implementation, you can try other implementations to see if it works.

Last updated