Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012 1
Digital vs Analog Digital signals are binary; analog signals are real-valued numbers 2
Integrated Circuits The building blocks of computers Designed for specialized functions Examples: the CPU, bus interface, memory management unit Transistors: primary components of Ics Motorola MPC 7400 PowerPC modules: 6.5 million transistors in less than in² 3
Transistors Boolean algebra: basis for computer logic design Transistors: means for implementing Boolean algebra Switches: on/off to represent the 0 s and 1 s of binary digital circuits Combined to form logic gates 4
Combinatorial logic Digital Circuits Results of an operation depend only on the present inputs to the operation Uses: perform arithmetic, control data movement, compare values for decision making Sequential logic Results depend on both the inputs to the operation and the result of the previous operation Uses: counter 5
Boolean Algebra Rules that govern constants and variables that can take on 2 values True/false; on/off; yes/no; 0/1 Boolean logic Rules for handling Boolean constants and variables 3 fundamental operations: AND, OR and NOT Truth Table: specifies results for all possible input combinations 6
Logic Functions Logical functions can be expressed in several ways: Truth table Logical expressions Graphical form 7
AND Boolean Operators Result TRUE if and only if both input 0 0 operands 0 are true C = A B INCLUSIVE-OR Result TRUE if any input operands are true C = A + B A B C 0 1 0 1 0 0 1 1 1 A B C 0 0 0 0 1 1 1 0 1 1 1 1 8
NOT Boolean Operators Result TRUE if single input value is FALSE C = A A C 0 1 1 0 9
Switching Circuits 10
AND Operator Similar Examples If the car is fueled AND the engine works, then the engine works, then the engine will start. AND means that both conditions must be true in order for the conclusion to be true. OR Operator If I have cash or a credit card, then I can pay the bill. OR works such that the output is true, if either of the two inputs is true. 11
Similar Examples XOR (Exclusive OR) Operator If gender A XOR gender B, then reproduction is possible. XOR works such that output is activated (equal to one) if both inputs are of a different value. 12
EXCLUSIVE-OR Boolean Operators Result TRUE if either A or B is TRUE but not both C = A B Can be derived from INCLUSIVE-OR, AND and NOT A xor B equals A or B but not both A and B A B = (A + B) ( A B ) A xor B = either A and not B or B and not A A B = (A B ) + ( B A ) 13
Boolean Algebra Operations Valid for INCLUSIVE-OR, AND, XOR Associative A + ( B + C ) = ( A + B ) + C Distributive A ( B + C ) = A B + A C Commutative A + B = B + A DeMorgan s Theorems A + B = A B A B = A + B 14
Gates and Combinatorial Logic Many computer functions defined in terms of Boolean equations Example: sum of 2 single binary digit numbers Truth table for sum Truth table for carry XOR AND A B C 0 0 0 0 1 1 1 0 1 1 1 0 A B C 0 0 0 0 1 0 1 0 0 1 1 1 15
Computer Implementation Gates or logical gates Integrated circuits constructed from transistor switches and other electronic components VLSI: very large-scale integration 16
Level of Integration An IC (a chip) Examples: Small-scale Integration (SSI): < 10 gates Medium-scale Integration (MSI): 10 ~ 100 gates Large-scale Integration (LSI): 100 ~ xk gates Very Large-scale Integration (VLSI): > xk gates VLSI Small size (compact size) Low cost Low power consumption High reliability High speed 17
Boolean Algebra Implementation Single type of gate appropriately combined 2 possibilities NAND gate: AND operation followed by a NOT operation NOR gate: INCLUSIVE-OR followed by a NOT operation Note: indicates a NOT operation 18
NAND gate Proving NAND gate is universal 19
NOR gate Proving NOR gate is universal 20
Gates with multiple inputs Graphic symbols and input-output signals for logic gates with multiple inputs 21
Multi-Input AND Gate AND gates can be built with any number of inputs Consider the symbol for the 4-input AND gate F is true only when all the inputs are true (1 s) 22
Multi-Input AND Gate Using 3 two-input AND gates, we could build the same 4-input AND gate. 23
Majority function Output is one whenever majority of inputs is 1. We use 3-input majority function. 24
Majority function 25
Practice Problem Find the output of the following circuit Answer: (x+y)y x+y (x+y)y y 26
Practice Problem Find the output of the following circuit x y x y x y Answer: 27
Practice Problem Write the circuits for the following Boolean algebraic expressions x x+y 28
Practice Problem Write the circuits for the following Boolean algebraic expressions x x+y x+y (x+y)x y 29
Logical Equivalence All three circuits implement F=AB function. 30
Logical Equivalence Proving logical equivalence of two circuits Derive the logical expression for the output of each circuit. Show that these two expressions are equivalent. Two ways: You can use the truth table method For every combination of inputs, if both expressions yield the same output, they are equivalent. Good for logical expressions with small number of variables. You can also use algebraic manipulation Need Boolean identities 31
Logical Equivalence Derivation of logical expression from a circuit Trace from the input to output Write down intermediate logical expressions along the path. 32
Logical Equivalence Proving logical equivalence: Truth table method A B F1 = A B F3 = (A + B) (A + B) (A + B) 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 33
Boolean Algebra 34
Boolean Algebra 35
Boolean Algebra Proving logical equivalence: Boolean algebra method To prove that two logical functions F1 and F2 are equivalent Start with one function and apply Boolean laws to derive the other function Needs intuition as to which laws should be applied and when Practice helps Sometimes it may be convenient to reduce both functions to the same expression Example: F1=AB and F3=(A+B)(A+B)(A+B) are equivalent. 36
Logical Expression Simplification One method is algebraic manipulation Use Boolean laws to simplify the expression. Difficult to use Don t know if you have the simplified form 37
Algebraic Manipulation Majority function example A B C + A B C + A B C + A B C = Added extra A B C + A B C + A B C + A B C + A B C + A B C We can now simplify this expression as B C + A C + A B A difficult method to use for complex expressions 38
Logic Circuit Design Process A simple logic design process involves Problem specification Truth table derivation Derivation of logical expression Simplification of logical expression Implementation 39
Selector or Multiplexer Switch input back and forth between inputs Logic circuits that make up a computer Are relatively simple but Look complicated because many circuits required 40
How to add binary numbers Consider adding two 1-bit binary numbers x and y 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 Carry is x AND y Sum is x XOR y The circuit to compute this is called a half-adder. 41
Half-Adder 42
Using half adders We can then use a half-adder to compute the sum of two Boolean numbers. 43
How to fix this We need to create an adder that can take a carry bit as an additional input. Inputs: x, y, carry in Outputs: sum, carry out This is called a full adder. Will add x and y with a half-adder Will add the sum of that to the carry in What about the carry out? It s 1 if either (or both): X + y = 10 X + y = 01 and carry in - 1 44
Truth Table for Full Adder 45
Full Adder Handles possible carry from previous bit Half adder shown as block to simplify 2-bit adder contains 32 circuits Also called ripple adder because the carry ripples through 32 bits 46
Carry lookahead adders Ripple-carry adders can be slow Delay proportional to number of bits Carry lookahead adders Eliminate the delay of ripple-carry adders Carry-ins are generated independently C 0 = A 0 B 0 C 1 = A 0 B 0 A 1 + A 0 B 0 B 1 + A 1 B 1 Requires complex circuits Usually, a combination of carry lookahead and ripplecarry techniques are used 47
Sequential Logic Circuits Output depends on Input Previous state of the circuit Flip-flop: basic memory element State table: output for all combinations of input and previous states 48
Sequential Logic Circuits Main components of a sequential circuit 49
Clock Signal 50
Clock Signal Clock serves two distinct purposes Synchronization point Start of a cycle End of a cycle Intermediate point at which the clock signal changes levels Timing information Clock period, ON, and OFF periods Propagation delay Time required for the output to react to changes in the inputs 51
Clock Signal 52
Flip-Flop Types with State Tables 53
Register COPY Operation Uses both sequential and combinatorial logic 54
Steps in a LOAD Instruction 55
56