Basic Logic Gates

Basic Logic Gates

AND

Input1 Input2 OUTPUT
0 0 0
0 1 0
1 0 0
1 1 1

OR

Input1 Input2 OUTPUT
0 0 0
0 1 1
1 0 1
1 1 1

NOT

Input OUTPUT
0 1
1 0

NAND

NAND is the negate of AND, therefore we can use AND and NOT to implement NAND:

Input1 Input2 AND NOT AND(i.e., NAND)
0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0

NOR

NOR is the negate of OR, therefore we can use OR and NOT to implement NOR:

Input1 Input2 OR NOT OR(i.e., NOR)
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0

XAND(XNOR)

XAND stands for Exclusive AND, wherein a positive output is only achieved if both inputs are equal. XAND works synonymously as XNOR.

XAND can be implemented using AND, NOT and OR:

Input1 Input2 AND NOT(Input1) and NOT(Input2) AND or (NOT(Input1) and NOT(Input2)) (i.e., XAND)
0 0 0 1 1
0 1 0 0 0
1 0 0 0 0
1 1 1 0 1

The above process is as follows:

  1. Firstly we obtain the result of Input1 AND Input2, i.e., result1 = Input1 AND Input2.

  2. Then we obtain the result of Not(Input1) and NOT(Input2), i.e., result2 = Not(Input1) and NOT(Input2).

  3. Lastly, we obtain the final result, i.e., XAND = result1 OR result2.

Note that Not(Input1) and NOT(Input2) is just NOR.

XOR(XNAND)

XOR stands for Exclusive OR, wherein a negative output is only achieved if both inputs are equal. XOR works synonymously as XNAND.

XOR can be implemented using OR, NOT and AND:

Input1 Input2 OR NOT(Input1) or NOT(Input2) OR and (NOT(Input1) and NOT(Input2)) (i.e., XOR)
0 0 0 1 0
0 1 1 1 1
1 0 1 1 1
1 1 1 0 0

The above process is as follows:

  1. Firstly we obtain the result of Input1 OR Input2, i.e., result1 = Input1 OR Input2.

  2. Then we obtain the result of Not(Input1) or NOT(Input2), i.e., result2 = Not(Input1) or NOT(Input2).

  3. Lastly, we obtain the final result, i.e., XOR = result1 AND result2.

Note that Not(Input1) or NOT(Input2) is just NAND.

Here is a simple comparison between OR(inclusive or) and XOR(exclusive or):

  • OR: A triangle can be defined as a polygon with three sides or a polygon with three vertices. These two conditions can be both true or both false.
  • XOR: The coin landed either heads or tails. These two conditions cannot be both true or both false. If one conditon is true, the other must be false.