einarvalur.co

Micro Controller : Logic Gates

Traditional mathematics deal with quantities; adding, subtracting, multiplying and dividing. Boolean algebra deals with logical values. In boolean algebra, values are either True or False. Boolean algebraic logic can be implemented with transistors, producing physical components called logic gates.

Boolean Algebra.

Boolean algebra was introduced by George Boole in his first book The Mathematical Analysis of Logic (1847), and set forth more fully in his An Investigation of the Laws of Thought (1854). Boolean algebra didn't have much practical application until the invent of the electronic computer where it is the fundamental principal.

As stated previously, values in Boolean algebra are either True or False, often denoted as 1 (one) for True or 0 (zero) for False. In electronics, the presence of current is True or 1 and the absence of current is False or 0.

Boolean Algebra has three basic operators. Logical addition (or), logical multiplication (and) and compliment (not).

AND : Logical Multiplication.

Two values in Boolean algebra can be evaluated with the AND operator. The AND operator (⋀) states that both values need to equal to True for the statement to be True, else the statement is False.

The behavior is similar to algebraic multiplication. 0 × 0 = 0, 0 × 1 = 0, 1 × 0 = 0 and 1 × 1 = 1.

Logical Multiplication can be noted with the AND symbol (⋀), with the multiplication symbol (·) or without a symbol. All these statements are equivalent: A ⋀ B, A · B and AB.

The AND operator can be implemented with two NPM transistors connected in sequence. For current to flow from source (Vcc) to ground, both transistors need to be open. For both transistors to be open, both base terminals need to be sourcing current, making them True.

The illustration below describes an AND logic gate. Input values are represented with terminals A and B. The electronic schematic symbol is displayed in the top right corner. The Truth Table for the AND operator is located in the bottom right corner.

OR : Logical Addition.

Two values in Boolean algebra can be evaluated with the OR operator. The OR operator (⋁) states that either values need to equal to True for the statement to be True, else the statement is False.

The behavior is similar to algebraic addition. 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1 and 1 + 1 = 1. Only the last one is different. Since Boolean values can either be 0 or 1, the addition of 1 and 1 yields 1 but not 2.

Logical Addition can be noted with the OR symbol (⋁) or the plus sign (+). These statements are equivalent: A ⋁ B and A + B.

The OR operator can be implemented with two NPM transistors connected in parallel. For current to flow from source (Vcc) to ground, only one transistor needs to be open.

The illustration below describes an OR logic gate. Input values are represented with terminals A and B. The electronic schematic symbol is displayed in the top right corner. The Truth Table for the OR operator is located in the bottom right corner.

NOT : Compliment.

A value can be inverted (complimented) in Boolean algebra with the NOT operator (¬). This operator is a unary operator, it only requires a single value: True becomes False and False becomes True.

The NOT operator is sometimes denoted with a bar over the value: True = False

The NOT operator can be implemented with a single NPM transistor.

The illustration below describes the NOT logic gate. Input value is represented with terminal A. The electronic schematic symbol is displayed in the top right corner. The Truth Table for the NOT operator is located in the bottom right corner.

Boolean Identities.

Boolean Algebra complies with Algebraic rules.

Identity AND OR  
Identity Law 1x = x 0+x + x  
Dominance Law 0x = 0 1+x = x  
Idempotent Law xx = x x+x = x  
Inverse Law xx = 0 x + x = 1  
Commutative Law xy = yx x+y = y+x  
Associative Law (xy)z = x(yz) (x+y)+z = x+(y+z)  
Distributive Law x+yz = (x+y)(x+z) x(y+z) + xy+xz  
Absorption Law x(x+y) = x x+xy = x  
DeMorgan's Law (xy) = x+x (x + y) = xy  
Double Complement Law x = x x = x  

Simplification of Boolean Expressions.

It can be beneficial to simply Boolean expressions. Boolean Expressions are said to be equvilant if both produce the same truth-tables.

Proof Identity
(x+y)(x̅+y) = xx̅+xy+yx̅+yy Distributive Law
  = 0+xy+yx̅+yy Inverse Law
  = 0+xy+yx̅+y Idempotent Law
  = xy+yx̅+y Identity Law
  =y(x+x̅)+y Distributive Law (and Commutative Law)
  = y(1)+y Inverse Law
  = y+y Identity Law
  = y Idempotent Law

Therefor (x+y)(x̅+y) = y.

Combination logic.

Some equations come up so often that they are get their own gates and symbols.

XOR

Two values in Boolean algebra can be evaluated with the XOR (exclusive or) operator. The XOR operator (⊕) works the same way as OR except that if both values are True, the statement becomes False.

XOR circuit can be implemented with a combination of NOR gates, NAND gates or AND, OR and NAND gates.

The XOR operator can be implemented with two NPM transistors connected in parallel.

The illustration below describes an XOR logic gate. Input values are represented with terminals A and B. The electronic schematic symbol is displayed in the top right corner. The Truth Table for the XOR operator is located in the bottom right corner.

NAND

Two values in Boolean algebra can be evaluated with the NAND operator. NAND is the inverse of AND. NAND is True only if both inputs are FALSE, else it evaluates to True.

NAND circuit can be implemented with an AND and a NOT gate.

The illustration below describes an NAND logic gate. Input values are represented with terminals A and B. The electronic schematic symbol is displayed in the top right corner. The Truth Table for the NAND operator is located in the bottom right corner.

NOR

Two values in Boolean algebra can be evaluated with the NOR operator. NOR is the inverse of OR.

NOR circuit can be implemented with an OR and a NOT gate.

The illustration below describes a NOR logic gate. Input values are represented with terminals A and B. The electronic schematic symbol is displayed in the top right corner. The Truth Table for the NOR operator is located in the bottom right corner.

Additional Resources.