Lecture 9: Digital Introduction: ● We can classify the building blocks of a circuit or system as being either analog or digital in nature. ◆ If we focus on voltage as the circuit parameter of interest: ■ Analog: The voltage can take on a range of voltages, e.g. any value between 0.1 and 2 Volts. ■ Digital: The voltage can have only two values, e.g. 0 or 5 Volts ❑ We say the voltage is either on or off ☞ Digital circuits are useful when we don’t need a continuous range of voltage or current. ❑ Examples: Representing numbers, binary , counting circuits. ❑ Example: Represent base 10 numbers using the binary system: 1 0 2|10 = 10|2 = 1 x 2 + 0 x 2 3 2 1 0 10|10 = 1010|2 = 1 x 2 + 0 x 2 + 1 x 2 + 0 x 2

● Digital circuits use standard voltages (or currents) to denote ON (high, 1) or OFF (low, 0). ◆ These standards are called “Logic Families” and there are several families. ◆ Two of the most popular families are: ■ TTL (-Transistor-Logic): ON = 5 Volts, OFF = 0 Volts ■ ECL (Emitter-Coupled-Logic): ON = -1 Volt, OFF = -1.6 Volts ☞ For practical reasons both ON and OFF are given by a range of voltages or currents. ◆ ON for an input to a circuit might have slightly different voltage than ON for an output to a circuit.

K.K. Gan L9: 1 ● A description of several logic families is given in the table below: Max. FF Rate Power/Gate High Low (ns) (MHz) (mW) (V) (V) Standard TTL 10 35 15 3.5 0.2 (7400)

Low-power Schottky 9.0 33 2 3.5 0.2 (74LS00)

Fast TTL 3.5 125 5.5 2.7 0.5 (74F00)

CMOS 25 @ 10 V 10 @ 10 V 0.01 5-15 0 (74C00) 50 @ 25 V 3.5 @ 5 V

High-speed CMOS 8.0 40 0.01 2-6 0.1 (74HC00)

ECL 2 250 25 -0.9 -1.8

100k ECL 0.75 500 40 -1.0 -1.7 ◆ Advantages of Digital: ■ only deal with two voltage levels (either ON or OFF) ■ voltages (or currents) are standardized ■ do not deal with individual … ◆ Disadvantages of Digital: ■ too many “black” boxes ■ need good power supplies, clocks etc. for circuits to work properly K.K. Gan L9: Digital Electronics 2 Logic Gates: ● We want to make decisions based on digital information. ◆ For now consider the basic building blocks with one or two inputs and one output. ● The basic logic units (gates) are: AND, OR, NOT. ◆ These functions are defined by their truth tables. AND OR NOT (inverter)

A A Y Y A ↓ Y B B invert symbol A B Y A B Y A Y 0 0 0 0 0 0 A and B stand for the inputs 0 1 1 0 0 1 0 1 Y stands for the output 1 0 0 1 0 0 1 1 0: low input or output 1 1 1 1 1 1 A = Y 1: high input or output A B = Y A + B = Y

+V D0 +V VA D0 R VA Vout Vout D1 Q1 VB VA D1 VB Vout Q Vout = +V if both off Vout = V A or V B if either VA > 0.6 V, 1 is on, Vout ~ 0 = 0 if one or more diodes conduct VA < 0.6 V, Q1 is off, Vout = +V diodes conduct = 0 if both diodes are off K.K. Gan L9: Digital Electronics 3 or the Algebra of 1’s and 0’s ● Circuits consisting of logic gates are described by Boolean algebra. ◆ Use of this algebra can greatly simplify circuit design, e.g. minimize the number of components. ● The following theorems can be proved using a and the definition of OR, AND, and NOT. 1) A + A = A, A +1 =1, A + 0 = A

2) AA = A

3) AB = BA 4) ABC = (AB)C = A(BC) See Simpson page 540 for more theorems. 5) A(B+ C) = AB+ AC

6) 1 = 0, 0 =1

For clarity “·” (AND) is not shown in some theorems. 7) A + A =1, AA = 0, A ⋅1 = A 8) A = A

9) A + B = A ⋅ B DeMorgan’s Theorem 10) AB = A + B ● Example using Boolean algebra: ◆ Prove: X + YZ = (X + Y)(X + Z) (X+ Y)(X+ Z) = XX+ XZ + YX+ YZ by 5) € = X+ X(Z + Y)+ YZ by 2) and 5) € = X(1+ Z + Y)+ YZ by 5) = X+ YZ by 1) K.K. Gan L9: Digital Electronics 4

€ ◆ We could also have proven the above using a truth table. ■ There are 8 (23) possible combinations of X, Y, Z. ■ For a large number of inputs using a truth table becomes unwieldy. ■ Example, if there are 10 inputs ☞ 210 = 1024 possible combinations!

● Example: Exclusive OR = XOR = A⊕B. ◆ Output is high if inputs are different. A B Y 0 0 0 XOR 1 0 1 A Y 0 1 1 B 1 1 0

AB + AB =Y ◆ How do we make an exclusive OR with AND, OR, and NOT gates? A AB

AB + AB Brute force method

AB B

K.K. Gan L9: Digital Electronics 5 ◆ Can we simplify this circuit with the use of less parts? ■ Use logical theorems: A ⊕ B = AB + A B A A+B = AA + AB + AB + BB 7) and 1)

= A(A + B )+ B(A + B ) 5) (A+B)(AB)

= A(AB)+ B(AB) 10) AB = (A + B)(AB) 5) B ■ The circuit uses only 3 parts (OR, NAND, AND), but each of them is different! ■ Usually there are many ways to synthesize the same function (circuit). ■ Must decide if you want to minimize: € ❑ number of components ❑ types of components ❑ number of connections ❑ power consumption ■ For example we can make an XOR using only 4 NAND gates: A

A⊕ B

B

K.K. Gan L9: Digital Electronics 6 ● Final example: Suppose you have a light controlled by 3 . ◆ You want the light to be on if any one of the 3 switches is on or if all 3 switches are on. A B C Light 1 1 1 1 1 0 0 1 B 1 1 0 0 C L 0 1 1 0 A 0 1 0 1 0 0 1 1 1 0 1 0 1 = ON 0 0 0 0 0 = OFF L = ABC + AB C + A BC + A B C = A(BC + B C )+ A (BC + B C) = A(B + C )(B + C)+ A (B ⊕ C) = AB CBC + A (B ⊕ C) = AB C + BC + A (B ⊕ C) = AB ⊕ C + A (B ⊕ C) = A ⊕ (B ⊕ C)

€ K.K. Gan L9: Digital Electronics 7 Flip-Flops: ● Basic counting unit in : ◆ counters ◆ shift registers ◆ memory ● Circuit whose output depends on the history of its inputs. ● Can make a flip-flop with just 2 transistors (or 2 vacuum tubes 1919!). ● Lots of different types of flip-flops (e.g. RS, JK, T, D).

● Example: RS flip-flop or Reset-Set flip-flop ◆ Flip-flops, like logic gates are defined by their truth table. ◆ Flip-flops are controlled by an external clock pulse. ◆ All inputs and outputs are logic levels (e.g. TTL, ECL). ◆ Can make an RSFF out of NOR gates: C R R S Q Q n+1 0 0 Qn R Q 1 0 0 0 1 1 Q 1 1 undefined S Q S

■ Qn is the present state of the FF. ■ Qn+1 will be the output after the clock enables the FF to look at its inputs (R and S). ■ Many FF change state (Qn → Qn+1) on the trailing edge of the clock. The state with R = S =1 is undefined. The output is not predictable! K.K. Gan L9: Digital Electronics 8 ● Example: D flip-flop (Like RS but only one input)

D Q Qnext 0 0 0 D Q 0 1 0 Q 1 0 1 1 1 1 Clock ● Example: JK flip-flop ◆ JKFF is like the RSFF except that both inputs (J and K) can be high (1). C J K Q n+1 0 0 Qn J Q 1 0 1 0 1 0 K 1 1 Q Q n ◆ Most JKFF’s have a connection for forcing Q = 0 (clear) or forcing Q = 1 (preset).

● Example: T (Toggle) flip-flop ◆ T flip-flop is like the JKFF with both inputs (J and K) tied to each other.

T Q Qnext T Q 0 0 0 0 1 1 Q 1 0 1 1 1 0 Clock K.K. Gan L9: Digital Electronics 9 ● Flip-Flops are a class of circuits called “multivibrators” ◆ Multivibrators are circuits with one or more stable states. ■ Monostable multivibrators (one shot) have one stable state. ❑ If the circuit is forced out of its stable state (e.g. by an input pulse) ☞ it eventually returns back to the stable state by itself. ■ Bistable multivibrators have two stable states. ❑ Transitions between states occur only by an external action (e.g. voltage pulse for flip-flops). ❑ Transition voltages can be different for the two states (e.g. Schmitt trigger). ■ Astable multivibrators are two-state devices which on their own accord. ☞ Commonly used as oscillators.

K.K. Gan L9: Digital Electronics 10 ◆ Example: Bistable Multivibrator. ■ This circuit has two stable states.

■ When either transistor conducts there is 4 mA flowing (by design) in the collector (IC1 or IC2). ■ State 1: transistor 1 off, transistor 2 on

❑ VC1 ≈ 11 V, VB1 ≈ 2 V, VE1 ≈ 4 V ❑ VC2 ≈ 4 V, VB2 ≈ 5.5 V, VE2 ≈ 4 V T2 is saturated (VCE ≈ 0) ■ Transition from state 1 to state 2:

❑ Input pulse forces T1 to conduct, T1 conducting means that VC1 drops. ❑ VC1 causes VB2 to drop to the point where T2 is not conducting. ■ State 2: transistor 1 on, transistor 2 off ❑ VC1 ≈ 4 V, VB1 ≈ 5.5 V, VE1 ≈ 4 V T1 is saturated (VCE ≈ 0) ❑ VC2 ≈ 11 V, VB2 ≈ 2 V, VE2 ≈ 4 V input 12 V

2 k 2 k time -3 V 14 k 14 k output V T C1 1 14 k 14 k T2 11.2 V

C input 4.1 V 1 k time K.K. Gan L9: Digital Electronics 11