# Digital Electronics/Lecture Digital Logic Gates

* EE111 Edit/View
* Electronic Engineering
* EE Digital Electronics
* Lecture, Number systems and logic states
* Lecture, Digital Logic Gates
* Lecture, Combinatorial Functions
* Lecture, Karnaugh Map Reductions
* Lecture, Arithmetic
* Lecture, Flip-flops
* Mid-term Exam
* Lecture, Sequential Logic
* Lecture, Memory Elements
* Lecture, Registers and Counters
* Lecture, Advanced Sequential Circuits
* Lecture, Logic Simulation
* Lecture, High Level Language Logic Modelling and Synthesis
* Final Exam

## Introduction

Digital electronics work on a branch of mathematics called Boolean Algebra or Boolean Logic. George Boole is credited with the invention of what is now called Boolean logic. Boolean logic deals with variables that take on any one of the two discreet values and performs operations on it. The two values that can be assigned to the variables are normally attributed as "logical true" or "logical false"; which are represented in real world digital electronics as different voltage level - high and low, respectively. For simplicity, we will assign them the bit value of 0 and 1. In Boolean Logic (or more commonly referred to as Binary Logic in digital world), the variables are designated by the letters of the alphabet such as A,x,C, etc., with the variables having only 1 of the two allowed values - 0 or 1.
Digital electronics is based entirely on the fundamental principles of Boolean logic. Consider the following devices:
* a soda machine which accepts coins and dispenses cans of soda
* a microwave oven with programmable power levels and timers
* a hand-held calculator
All of these systems rely on digital electronics to some extent. The degree of digital control could vary from a simple finite state machine for the soda machine, to a general-purpose computer for the calculator. Despite the apparent complexity, all digital devices can be boiled down to three elementary Boolean functions commonly known as AND, OR and NOT. These three elementary functions can be further combined to produce other functions: NAND (NOT of AND), NOR (NOT of OR) and the more complicated Ex-OR and Ex-NOR functions.
Operations using boolean algebra deal with the relationship between two signal levels. This relationship is the result of the operation performed on them.

### Representing state

For this course, all signal levels with a positive voltage are to be determined as 'high' or 'on'. A signal that is 'high' should be considered as a representation of true. Conversely, any electrical signal with a voltage of zero should be considered 'low' or 'off'. A signal that is 'low' should be considered as a representation of false. These high and low signals are further represented as 1s and 0s. This convention makes it easy to represent a logical sequence using one character rather than a three of four letter word.
For the purpose of this course all signals are determined to either be in state high or low.
With these two rules we have the basis of almost all computing devices in the world.

### Truth Tables

Digital logic functions can operate on between one and many signals and have either one or many results. A standard way to represent these inputs and outputs is using what is called a Truth Table to list the inputs and outputs of a digital logic function. Truth tables will be used extensively in this course and students should become familiar with their structure.

### The AND function

The "ANDing" of two bits can be defined by the following rule.
The AND of two bits is a logic '1', if and only if both the input bits are also logic '1'.
AND logic is very helpful in implementing 'inhibit' functions. A common TTL IC with AND gate function is the 7408. This IC contains four 2 input AND gates.
$A\cdot B=X\!$
Where A and B are inputs and X is the output.
AND gate with 2 inputs :
| Input A | Input B | OUTPUT X |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

### The OR function

The "ORing" of two bits can be defined by the following rule.
The OR of two bits is a logic '1', if any or both the input bits are logic '1'.
$A+B=X\!$
Where A and B are inputs and X is the output.
An OR gate with 2 inputs :
| Input A | Input B | Output X |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |

### The NOT function

The logical NOT function is a single operand function. This means it determines its output based on the logic level of a single input. The output of the NOT function is the opposite of the input level. If the NOT function is applied to a logical high signal, the result would be a low level. As one would expect executing a NOT function on a low signal produces a result of high.
NOT high -> low
NOT low -> high
$\lnot A=X$
Where A is the input and X is the output
| A | X |
| 0 | 1 |
| 1 | 0 |

### The NAND and NOR functions

NAND = "NOT"-"AND" ~ Therefore this indicates that the result of the inputs placed through the gate will go through the AND operation and the NOT operation. The correct order of processing is: Step 1. Put the inputs through the AND operation. Step 2. From the results of the first step - invert (using the NOT operation). Step 3. Take the result from Step 2 as the output.
Similarly NOR = "NOT"-:OR". The output is obtained by using the NOT operation on the output of the OR operation.
A NAND gate with 2 inputs :
| Input A | Input B | Output X |
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
$X={\overline {A\cdot B}}$
The NAND gate and the NOR gate can be said to be universal gates since combinations of them can be used to accomplish any of the basic operations and can thus produce an inverter, an OR gate or an AND gate. The non-inverting gates do not have this versatility since they can't produce an invert.

### The Exclusive-OR (XOR) function

The "XORing" of two bits can be defined by the following rule.
The XOR of two bits is a logic '1', if any but not both the input bits are logic '1'.
An XOR gate with 2 inputs :
| Input A | Input B | Output X |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
MARICA

## Logic technology types

There have been several different types of logic circuit over the years all of their names are based on the way the various components are interconnected internally.
| DCTL | Direct-Coupled Transistor Logic |
| RTL | Resistor-Transistor Logic |
| RCTL | Resistor-Capacitor-Transistor Logic |
| DTL | Diode-Transistor Logic |
| ECL | Emitter-Coupled Logic |
| TTL | Transistor-Transistor Logic |
| MOS | Metal-Oxide Semiconductor Logic |
| CMOS | Complementary Metal-Oxide Semiconductor Logic |
Out of all these logic types TTL, MOS, and CMOS are the ones used today.

### TTL

TTL is named because the only components performing logic operations are BJT's. Looking at the image of a TTL NOT gate Q1 has multiple emitters built on to the transistor base. The emitters each can function as an input to the inverter. When the base emitter of Q1 is forward biased, Q1 is in saturation and V$_{ce(sat)}$ is less than the forward bias V$_{be}$ of Q2 will be off and the output(X) will be 5 V, 0 or high.
V$_{be}$ = V$_{ce(sat)}$ = 0.2 V, 0 and low
There is also a 0.3 volt noise margin because:
| V$_{be}$ of Q2 = | V$_{in}$ + Vce(sat) of Q1 |
| = | 0.2 V+ 0.2 V |
| = | 0.4 V |
As you remember a diode has 0.7 volt voltage drop, 0.4 V + 0.3 V$_{(noise)}$ = 0.7 V drop.
The diodes D1 and D2 are reverse biased Zener diodes which have a deliberate avalanche reverse current flow above the max input voltage(Vinput$_{(max)}$), this protects the logic gate to a point against static electricity.
(TODO: analysis and differences NAND gate)

### Bipolar Transistor as a switch
## Moving to digital logic gates
### Boolean algebra

Every digital circuit has inputs and outputs. Then, purpose of the digital circuit can be thought of as "matching" an output to a certain input (or a sequence of inputs). For example, a digital circuit can be designed to control the movement of an elevator. The inputs are the floor you are on and the floor you want to go to. The output is the motor being turned on in the right direction for the correct period of time. To design this and more complicated digital circuits, we use a field of mathematics called boolean algebra.
Like high school algebra, boolean algebra also deals with variables and operations performed on them. In boolean algebra, the variables usually represent the logic state of some part of the circuit (usually inputs). The output is then represented as an expression containing these variables and operations to be performed on them. And like an algebraic expression, boolean expressions can be simplified. The usefulness of this is evident if you imagine a digital circuit containing a million transistors being simplified into a citcuit of only 10 transistors.
To begin our study of boolean algebra, consider some arbitary input variables A and B and an output variable Y. We shall perform the basic operations AND, OR and NOT on them to demonstrate how boolean algebra is used.
AND(.): Y is equal to A AND B: Y = A.B
OR(+): Y is equal to A OR B: Y = A+B
NOT: Y is equal to NOT A: $Y={\overline {A}}$
A typical boolean expression is Y = (A+B').(A'.B)

### Fundamental laws

A.0 = 0
A.1 = A
A + 0 = A
A + 1 = 1
A.(B + C) = A.B + A.C

### DeMorgan's Theorem

DeMorgan's Therom allows the conversion of an AND function to an OR function.
By inverting each individual input to a gate, and then inverting the output, an AND gate can perform the function of an OR gate, and vice versa.
This can be proven by truth tables.
$\lnot (A+B)=\lnot A\lnot B$
$\lnot (AB)=\lnot A+\lnot B$