Logic Gates

post hero image

Introduction

Let’s introduce a useful convention LOW, 0 and false have the same logic meaning, as well as HIGH, 1 and true.

Bool Algebra

AxiomsSingle variable theorems
0 ⋅ 0 = 0x ⋅ 0 = 0
1 + 1 = 1x + 1 = 1
1 ⋅ 1 = 1x ⋅ 1 = x
0 + 0 = 0x + 0 = x
0 ⋅ 1 = 1 ⋅ 0 = 0x ⋅ x = x
0 + 1 = 1 + 0 = 1x + x = x
if x = 0, then !x = 1x ⋅ !x = 0
if x = 1, then !x = 0x + !x = 1
1 = !!1 and 0 = !!0x = !!x

Please Note: Double negation is often used with a couple of overline signs.

Duality Principle

Given a logic expression, the dual is obtained by swapping:

  1. summations with multiplications (and vice-versa)
  2. 0 with 1 (and vice-versa)

Main Gates

AND

AND gate is a logic gate that implements logical conjunction (∧).

If one or both the inputs are false, the output is false. If both inputs are true, the output is true.

Truth table:

ABA ⋅ B
000
010
100
111

AND gate in ANSI

OR gate

OR gate is a logic gate that implements logical disjunction (∨).

A true output results if one or both the inputs are true. If neither input is true, the output is false.

Truth table:

ABA + B
000
011
101
111

OR gate in ANSI

NOT gate

NOT gate is a logic gate that implements logical negation (¬).
It is more commonly referred with the exclamation mark ! before che operator: !A means logical negation of A.

Truth table:

A¬ A
01
10

NOT gate in ANSI

Compound Gates

NOR gate

NOR gate is the result of the negation of the OR operator. It can also be seen as the inverse of an AND gate.

A true output results if both the inputs are false. A false output results if one or both the inputs are true.

Truth table:

AB¬ (A ∨ B)
001
010
100
110

NOR gate in ANSI

NAND gate

NAND gate is the result of the negation of the NAND operator. It can also be seen as the inverse of an OR gate.

A true output results if one or both the inputs are false. A false output results if both the inputs are true.

Truth table:

AB¬ (A ∧ B)
001
011
101
110

NAND gate in ANSI

XOR gate

XOR gate is an Exclusive OR gate that performs exclusive disjunction (⊕).

The output of an XOR gate is true only when exactly one of its inputs is true. If inputs are both false or both true the output is false.

Truth table:

ABA ⊕ B
000
011
101
110

XOR gate in ANSI

XNOR gate

XNOR gate is the logical complement of XOR gate (⨀).

The output of an XNOR gate is false only when exactly one of its inputs is true. If inputs are both false or both true the output is true.

Truth table:

ABA ⨀ B
001
010
100
111

XNOR gate in ANSI

Conclusion

Useful links: