Class Website:

Similar documents
Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

Logic. Combinational. inputs. outputs. the result. system can

Midterm Exam Two is scheduled on April 8 in class. On March 27 I will help you prepare Midterm Exam Two.

Systems I: Computer Organization and Architecture

COMBINATIONAL LOGIC FUNCTIONS

Chapter 4. Combinational: Circuits with logic gates whose outputs depend on the present combination of the inputs. elements. Dr.

UNIT II COMBINATIONAL CIRCUITS:

Digital System Design Combinational Logic. Assoc. Prof. Pradondet Nilagupta

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

Lecture 2 Review on Digital Logic (Part 1)

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

PG - TRB UNIT-X- DIGITAL ELECTRONICS. POLYTECHNIC-TRB MATERIALS

IT T35 Digital system desigm y - ii /s - iii

Carry Look Ahead Adders

Combinational Logic. By : Ali Mustafa

CHAPTER1: Digital Logic Circuits Combination Circuits

3. Combinational Circuit Design

Combinational Logic Design Combinational Functions and Circuits

ELEN Electronique numérique

Combina-onal Logic Chapter 4. Topics. Combina-on Circuit 10/13/10. EECE 256 Dr. Sidney Fels Steven Oldridge

CSE140: Components and Design Techniques for Digital Systems. Decoders, adders, comparators, multipliers and other ALU elements. Tajana Simunic Rosing

Combinational Logic Design Arithmetic Functions and Circuits

Hardware Design I Chap. 4 Representative combinational logic

Chapter 5 Arithmetic Circuits

Chapter 2 Combinational Logic Circuits

Chap 2. Combinational Logic Circuits

ELCT201: DIGITAL LOGIC DESIGN

Exclusive OR/ Exclusive NOR

Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS

Combinational Logic. Course Instructor Mohammed Abdul kader

COE 202: Digital Logic Design Combinational Circuits Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

( c) Give logic symbol, Truth table and circuit diagram for a clocked SR flip-flop. A combinational circuit is defined by the function

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

Chapter 2 Combinational Logic Circuits

MODULAR CIRCUITS CHAPTER 7

Adders - Subtractors

ECE 545 Digital System Design with VHDL Lecture 1A. Digital Logic Refresher Part A Combinational Logic Building Blocks

Binary addition by hand. Adding two bits

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Logic Design. Chapter 2: Introduction to Logic Circuits

Chapter 3 Combinational Logic Design

CSEE 3827: Fundamentals of Computer Systems. Combinational Circuits

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CS6201 DIGITAL PRINCIPLES AND SYSTEM DESIGN

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

Fundamentals of Digital Design

CSE140: Components and Design Techniques for Digital Systems. Logic minimization algorithm summary. Instructor: Mohsen Imani UC San Diego

Review for Test 1 : Ch1 5

Gate-Level Minimization

Chapter 2 (Lect 2) Canonical and Standard Forms. Standard Form. Other Logic Operators Logic Gates. Sum of Minterms Product of Maxterms

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

EEE130 Digital Electronics I Lecture #4

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

211: Computer Architecture Summer 2016


14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

ECE 20B, Winter 2003 Introduction to Electrical Engineering, II LECTURE NOTES #2

ว ตถ ประสงค ของบทเร ยน

Digital Logic. Lecture 5 - Chapter 2. Outline. Other Logic Gates and their uses. Other Logic Operations. CS 2420 Husain Gholoom - lecturer Page 1

Section 3: Combinational Logic Design. Department of Electrical Engineering, University of Waterloo. Combinational Logic

Overview. Arithmetic circuits. Binary half adder. Binary full adder. Last lecture PLDs ROMs Tristates Design examples

MC9211 Computer Organization

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

Part 1: Digital Logic and Gates. Analog vs. Digital waveforms. The digital advantage. In real life...

Chapter 1 CSCI

Digital Systems and Information Part II

UNIT 1. BOOLEAN ALGEBRA AND COMBINATIONAL CIRCUITS

CMPUT 329. Circuits for binary addition

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

Review: Additional Boolean operations

Cs302 Quiz for MID TERM Exam Solved

Chapter 5. Digital systems. 5.1 Boolean algebra Negation, conjunction and disjunction

Design of Combinational Logic

Week-I. Combinational Logic & Circuits

Digital Logic Design. Combinational Logic

Every time has a value associated with it, not just some times. A variable can take on any value within a range

Combinational Logic. Review of Combinational Logic 1

UNIVERSITI TENAGA NASIONAL. College of Information Technology

14:332:231 DIGITAL LOGIC DESIGN

ELCT201: DIGITAL LOGIC DESIGN

CSC9R6 Computer Design. Practical Digital Logic

Sample Marking Scheme

Z = F(X) Combinational circuit. A combinational circuit can be specified either by a truth table. Truth Table

Adders, subtractors comparators, multipliers and other ALU elements

Total Time = 90 Minutes, Total Marks = 100. Total /10 /25 /20 /10 /15 /20

Midterm Examination # 1 Wednesday, February 25, Duration of examination: 75 minutes

EECS150 - Digital Design Lecture 19 - Combinational Logic Circuits : A Deep Dive

ELECTRONICS & COMMUNICATION ENGINEERING PROFESSIONAL ETHICS AND HUMAN VALUES

Chapter 7 Logic Circuits

Chapter 2 Combinational Logic Circuits

CHAPTER 7. Exercises 17/ / /2 2 0

Adders, subtractors comparators, multipliers and other ALU elements

EECS150. Arithmetic Circuits

Unit 3 Session - 9 Data-Processing Circuits

UNIT 4 MINTERM AND MAXTERM EXPANSIONS

Department of Electrical and Computer Engineering University of Wisconsin - Madison. ECE/CS 352 Digital System Fundamentals

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic

Chapter 4: Combinational Logic Solutions to Problems: [1, 5, 9, 12, 19, 23, 30, 33]

CPE100: Digital Logic Design I

Transcription:

ECE 20B, Winter 2003 Introduction to Electrical Engineering, II LECTURE NOTES #5 Instructor: Andrew B. Kahng (lecture) Email: abk@ece.ucsd.edu Telephone: 858-822-4884 office, 858-353-0550 cell Office: 3802 AP&M Office Hours: MW noon-pm Class Website: http://vlsicad.ucsd.edu/courses/ece20b/wi03

Goals for Lecture XOR/XNOR Combinational Logic Blocks 2

Exclusive OR/ Exclusive NOR The exclusive OR (XOR) function is an important Boolean function used extensively in logic circuits. Uses for the XOR gate include: Adders/subtractors Parity generators/checkers Signature analyzers Pseudo-random sequence generators Definitions The XOR function is: X Y = XY + XY The exclusive NOR (XNOR) function, otherwise known as Equivalence is: X Y = XY + XY 3

Tables for XOR/XNOR Operator Rules: XOR X 0 0 Y 0 0 X Y 0 XNOR The XOR function means: X OR Y, but NOT BOTH The XNOR function, denoted by the operator, is also known as the Equivalence function. 0 X 0 0 Y 0 0 X Y 0 0 4

XOR/XNOR Extension The XOR function can be extended to 3 or more variables. For more than 2 variables, it is called a modulo 2 sum (Mod 2 sum), instead of XOR: X Y Z = XYZ + XYZ + XYZ + XYZ The XOR definition, Boolean identities and Boolean theorems give: X 0 = X X = X X X = 0 X X = X Y = X Y X Y = X X Y = Y X ( X Y) Z = X (Y Z) = X Y Z Y 5

XOR Implementations The simple SOP implementation uses the following structure: X X Y A NAND only implementation is: Y X X Y Y 6

XOR Implementations (Cont.) The AND-OR implementation is the SOP form for the XOR function: X Y = XY + XY The multiple-level NAND implementation can be derived by combining inversions as follows: X Y = XY + = = XY X Y + XY = XY + XY (X + Y) = XY X + XY Y XY 7

Odd Function The modulo 2 sum function for n variables Contains an odd number of s, and Is therefore called the odd function. The inverse of the modulo 2 sum function for n variables Contains an even number of s, and Is therefore called the even function. Implementation of even and odd functions for greater than 4 variables as a single gate is difficult, so trees of 2 to 4 input XOR or XNORs are used. 8

Example: Odd Function Implementation Three-Input Odd Function: Four Input Odd Function: 9

Product terms of Odd and Even For an n-bit even or odd function, there will be (2 n )/2 or 2 n product terms of n variables (minterms)! w z y Odd Function x w z y Even Function x v=0 y v= x w w z y z x Odd Function of Five Bits 0

Parity Generators/Checkers A parity tree for n data bits generates a parity bit that is appended to the data bits to form an n + - bit codeword X Example: 3-bit even Y parity generator P A parity tree for n + bits checks the codeword for correct parity: C=0 if the codeword X parity is correct Y C= if the codeword C parity is Incorrect Z Example: 4-bit even P parity checker Z

Positive and Negative Logic The same physical gate has different logical meanings depending on interpretation of the signal levels. Positive Logic Logic is set to HIGH (more positive) signal levels Logic 0 is set to LOW (less positive) signal levels Negative Logic Logic is set to LOW (more negative) signal levels Logic 0 is set to HIGH (less negative) signal levels A gate which implements a Positive Logic AND function will implement a Negative Logic OR function. 2

Design Hierarchy (MK 3.) Combinational Circuits A combinational logic circuit has: A set of m Boolean inputs, A set of n Boolean outputs, and n switching functions mapping the 2 n input combinations to a output such that the current output depends only on the current inputs. A block diagram: Combinational Logic Circuit m Boolean Inputs n Boolean Outputs 3

Hierarchical Design The function mapping inputs to outputs may be very complex To control complexity, we decompose the function into smaller pieces called blocks The blocks are subdivided into finer blocks The "leaves in the hierarchy are called primitive blocks Example: 6 input parity tree Top Level: 6 inputs, one output 2nd Level: Five 4-bit parity trees in two levels 3rd Level: Three 2-bit exclusive-or functions Primitive level: Four 2-input NANDs The design requires 5 X 3 X 4 = 60 two-input NAND gates 4

Reusable Functions and Design Whenever possible, we try to decompose a complex design into common, reusable function blocks These blocks are tested and well documented Computer-aided design (CAD) tools might include them in libraries Computer-aided manufacturing (CAM) tools might know how to manufacture and test them Other tools: Schematic Capture Logic Simulators Timing Verifiers Hardware Description Languages (HDL) 5

What is Design (Technology)? Design = specification, synthesis, analysis What do I want? Create Check Design Technology = Technology that enables design to occur in a timely, costeffective way (What happens if we can t design new products quickly?) Libraries Tools Methods 6

Top-Down versus Bottom-Up A Top-Down design proceeds from an abstract, high level specification to a more and more detailed design by decomposition and successive refinement A Bottom-Up design starts with detailed primitive elements and combines them into larger and larger and more complex functions Designs usually proceed from both directions simultaneously Top-Down design answers: What are we building? Bottom-Up design answers: How do we build it? Top-Down controls complexity while Bottom-Up controls the details 7

Analysis Procedure Switching Functions from Logic Diagrams Given a logic diagram, the analysis process provides a set of Boolean equations, a truth table, or a verbal explanation of circuit behavior. Procedure:. Determine that the circuit is combinational (no feedback loops), then: 2. Identify and label all gate outputs that are a function of the input variables. Obtain the Boolean functions for these labeled gate outputs. 3. Identify and label all gate outputs that are a function of inputs or previously labeled gates. Obtain Boolean functions for them. 4. Repeat Step 2 until all outputs are completed. 5. Back substitute until all functions are specified in terms of inputs only. 8

Analysis Example Step 2: Label all outputs of gates near inputs. Write Boolean equations for them: T = B + C T 2 = B E A B C D B E A B C D B E T T2 F 9 F

Analysis (Continued) A B C D B E T T2 T3 T4 Step 3: Identify and label all gate outputs that are a function of inputs or previously labeled gates. Obtain Boolean functions for them. T3 = D + T2 F Step 4: Repeat Step 3 until all done T4 = T T3 F = A + T4 20

Analysis (Continued) A B C D B E T T2 T3 T4 F Step 4: Back substitute until all functions are specified in terms of inputs only Substituting: F = A + T4 T4 = T T3 T3 = D + T2 T2 = B E T = B + C T3 = D + (B E) T4 = (B + C) (D + (B E)) F = A + (B + C) (D + (B E)) 2

Analysis Example: Code Converter A F2 B C D F w x F0 z y 22

Truth Tables from Logic Diagrams. Determine the number of input variables, n. There will be 2 n input vectors from zero to 2 (n-). Enter them in the table. 2. Label the outputs of selected gates with symbols and enter a column for each one in the table. 3. Obtain the truth table for the outputs of those gates that are a function of only input variables. 4. Proceed to fill in the outputs of all gates that are derived from inputs and previously calculated terms. 23

Truth Tables from Logic Diagrams Procedure: Determine the number of input variables, n. There will be 2 n input vectors from zero to 2 n. Enter them in the table. Label the outputs of selected gates with symbols and enter a column for each one in the table. Obtain the truth table for the outputs of those gates that are a function of only input variables. Proceed to fill in the outputs of all gates that are derived from inputs and previously calculated terms. Example: Find the function table for the code converter. 24

Code Converter Truth Table Four inputs give 6 input vectors. Start with F0, F and z. ABCD F0 F F2 w x y z 0000 000 0 000 0 00 0 0 000 00 0 00 0 0 0 0 000 00 0 00 0 0 0 0 00 0 0 0 0 0 0 25

Truth Table Fill-in Now we can calculate x, y, and F2. ABCD F0 F F2 w x y z 0000 0 0 0 000 0 0 000 0 0 00 0 0 000 0 00 0 0 0 00 0 0 0 0 0 0 0 000 0 0 0 00 0 0 00 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 26

Complete Entries Finally we can fill in w to complete the table: ABCD F0 F F2 w x y z 0000 0 0 0 0 000 0 0 0 000 0 0 0 00 0 0 0 000 0 0 00 0 0 0 00 0 0 0 0 0 0 0 000 0 0 0 00 0 0 00 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27

What Does the Circuit Do? By inspection, the output variable vector (w,x,y,z) is just the input variable vector (A,B,C,D) plus three. The function(s) F(A,B,C,D) = (w,x,y,z) are: ADD THREE TO THE INPUT VECTOR Function F has the meaning: ADD ONE TO THE UPPER TWO BITS Similarly, function F2 has the meaning: ADD ONE TO THE UPPER BIT Generally, it is not this obvious to figure out what the functions mean 28

Final Note (and warning) The use of "Don't Cares" in the original specification can cloud the analysis. Note that the functions for the "w" bit differ from the implementation in Ex. 3-2 of the book. The book used "Don't Cares" to simplify the logic. The example here did not. This can be seen by inspecting the two K-maps for the function w: w A C 0 3 2 4 5 7 6 X X X X 2 3 5 4 X X 8 9 0 D Book Fig. 4-8 B w A C 0 3 2 4 5 7 6 2 3 5 4 8 9 0 29 B D Notes Example

Logic Design: Functional Blocks Analysis: From a design to a specification of the behavior Logic diagram to equations Logic diagram to function table "Word description" of circuit operation Synthesis: From a specification to design implementation Define the problem Generate function table or equations Minimize the Boolean function Implement the circuit 30

Combinational Logic Implementation A combinational logic circuit has: A set of m Boolean inputs, A set of n Boolean outputs, and A function mapping inputs to outputs. We think of the function as n separate Boolean functions of m inputs Procedure: Treat each output as a separate function Minimize the equations for each function Implement each function independently Sometimes an implementation can share product or sum logic terms to arrive at a lower literal cost solution. 3

Design Procedure (MK 3.4) First, start with the specification of the circuit to be designed. Note: this can sometimes require a lot of work to complete the specification process, especially if it is poorly specified initially Second, follow these steps: We will study the design of a code converter to see these steps. Identify the inputs and outputs Derive truth table Obtain simplified Boolean equations Draw the logic diagram Check your work to verify correctness 32

Code Converter Design Example A code converter transforms one internal representation of data to another We will start with a table of the desired conversion and minimize the resulting multiple output Boolean function Sometimes terms can be shared to minimize the implementation cost The Problem: Design a BCD to Excess-3 code converter Specification: BCD code -- 4-bit patterns "0000" to "00" for digits 0 to 9 base 0 Excess-3 -- BCD code plus binary "00" for digits 0 to 9 base 0 33

Example: BCD to Excess 3 Function table: Input BCD A B C D Output Excess-3 w x y z 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Note: All BCD codes greater than "9" can be assigned "Don't Cares" in the K-Map. Such BCD codes are never possible. 34

Example (Cont.): BCD to Excess 3 Map functions and find minimum cost SOP equations for each z A D C 0 3 2 4 5 7 6 X X X 2 3 5 4 X X X 8 9 0 B y A D C 0 3 2 4 5 7 6 X X X 2 3 5 4 X X X 8 9 0 B x A C 0 3 2 4 5 7 6 X X X 2 3 5 4 X X X 8 9 0 B w A C 0 3 2 4 5 7 6 X X X 2 3 5 4 X X X 8 9 0 B D D 35

Example (Cont.): BCD to Excess 3 Next, we will manipulate the equations to expose some shared terms: The term (C + D) can be used more than once to simplify the implementation See Fig. 3-0 in Mano and Kime for the implementation 36

Functional Block: Decoders (MK 3.5) A Decoder converts n binary bits to a maximum of 2 n unique output lines. An m-to-n line decoder, where m < 2n, can be used to: Generate 2n (or fewer) minterms Select one-of 2n items Decoders are sometimes known as demultiplexers when enabled with a separate data-in line. 37

2-to-4 Line Decoder This device takes: n=2 input lines and decodes minterms for: m=2 n = 4 output lines. A A B B A B A A B B 38

2-to-4 Line Demultiplexer This device takes: n=2 input lines X and decodes minterms for: m=2 2 =4 output lines where each output is: ANDed with an input, X. If X is viewed as an Enable, all outputs are 0 for X = 0 and one output is for X =. If X is viewed as Data, then this data is sent to one or the outputs. A A A A A B B B B X X X X B 39

Implementing Logic with Decoders Decoders provide minterms directly. Simply "OR" the appropriate minterm outputs to make any logic function desired. Active low decoders behave as the first NAND gate in a NAND-NAND, Sum of Products implementation. Active high decoders behave as first stage AND gates in a AND-OR Sum of Products implementation. Two or more active high decoders driven from different bits of a binary code can be used to form minterms by "ANDING" their outputs. Similarly, active low decoders can be used to form minterms by "ORING" their outputs. 40

Example: F(A,B) = m(0,3) For this we use a 2-to-4 line decoder and sum minterms 0 and 3 with an OR gate: m3 F A m0 B 4

Example: F(X,Y,Z) = m(0,3,5,6) 42

Implementing Larger Minterms Minterm m5 is formed by "ANDING" the D3 outputs of each decoder. Similarly m0 is formed by "ANDING" the D0 outputs of each decoder. A B S S0 D3 D2 D D0 m5 m?? What minterm is formed by "ANDING" D (upper) and D2 (lower) outputs? C D S S0 D3 D2 D D0 m0 This works best with widely scattered, sparse minterms. 43

Functional Block: Encoders (MK 3.6) Encoders perform the "inverse" operation of decoders, taking a code in one format and encoding it into another format. Many encoders consist of just OR gates. For example an 8-to-3 binary encoder consists of three 4-input OR gates, OR2,OR and OR0. Input I i, i = 0,,7 is connected to an input on OR j if the binary representation of i has a in position j. A priority encoder is used to generate a code for the "most significant" bit set in a string of bits. This can be used to find the first one in a word, or to select external events in priority order. An example of a MSI priority encoder is the 74F48, 8 line to 3 line priority encoder. It can be cascaded to encode higher numbers of bits. 44

Encoder Example Encode 4 lines 0,, 2, 3 into the corresponding binary codes. 45

Review: Decoders and Encoders A Decoder converts n binary bits to a maximum of 2 n unique output lines. Decoders are sometimes know as demultiplexers when enabled with a separate data-in line. Decoders implement minterms directly. Use a decoder and an OR gate to form Sum-of-Minterms directly. Encoders perform the "inverse" operation of decoders, taking a code in one format and encoding it into another format. 46

Multiplexers (MK 3.7) A Multiplexer (MUX) is another common functional block. A Multiplexer uses n binary select bits to choose from a maximum of 2 n unique input lines. Like a decoder, it decodes minterms internally. Unlike a decoder, it has only one output line. The decoded minterms are used to select data from one of up to 2 n unique data input lines. The output of the multiplexer is the data input whose index is specified by the n bit code. 47

Example: A 4-to- multiplexer The 4-to- line Multiplexer uses the same minterm decoder core. It is like a demultiplexer with individual data input lines (instead of just one) and an output OR gate. S I3 I2 I I0 X S0 48

Multiplexer Versus Decoder I3 X A B X I2 X A B X I A B X S I0 A A B X S0 B Note how similar the two are internally. 49

Functions with Multiplexers It is possible to implement any Boolean function of n variables with a 2 n input multiplexer. Simply tie each input to the "" or "0" line as desired. It is also possible to implement any n+ variable function with a 2 n multiplexer. Simply use the (n+)st variable in true or complement form depending upon what the truth table requires. A Boolean function of more than n variables can be partitioned into several easily implemented subfunctions defined on a subset of the variables. The multiplexer will then select among these subfunctions. 50

Example: Gray to Binary Code The Gray code has adjacent elements separated by only one bit change. We wish to convert a 3-bit Gray code to a binary code. The function table on the right documents the required conversion. Gray A B C Binary x y z 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 The Gray to Binary Code Converter requires us to implement three separate, three-input Boolean functions. 5

Gray to Binary (Continued) First step: Let's get the function table into a logical order by reordering the input Gray code values in binary sequence: By inspection: x = F(A,B,C) = m (, 3, 5, 7) y = G(A,B,C) = m (, 2, 5, 6) z = H(A,B,C) = m (, 2, 4, 7) Gray A B C Binary x y z 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52

Gray to Binary (Continued) The K-Maps X A Z A B Y 0 3 2 4 5 7 6 A C C B 0 3 2 4 5 7 6 Note: C B 0 3 2 4 5 7 6 x(a,b,c) = C, is an easy function to implement. (No logic gates needed!) Function y(a,b,c) = B'C + B'C is a bit harder to implement. Function z(a,b,c) looks familiar. What is it? 53

Gray to Binary (Continued) We know that 2n to Multiplexers can be used to implement arbitrary functions of n bits. We simply connect the inputs to "0" or "" as needed. Use two eightinput multiplexers to implement functions for y and z: A B C 0 0 0 0 D7 D6 D5 D4 D3 D2 D D0 S2 S S0 Out 8-to- MUX Z A B C 0 0 0 0 D7 D6 D5 D4 D3 D2 D D0 S2 S S0 Out 8-to- MUX Y In this case, the MUX elements are acting like a "Read Only Memory" (ROM). 54

Other MUX Implementations We can also use two 4-to- MUX blocks and implement y and z. Suppose we factor out A and use B and C as the select inputs to the multiplexers Y A 00 0 B 0 0 0 D 0 D D 3 D 2 0 0 Z A 00 0 B 0 0 0 D 0 D D 3 D 2 0 0 C C A A A A 55

MUX Implementations (Cont.) Factoring out variable A leads to the following implementation with two, 4-to- Multiplexers: A A' A' A D3 D2 D D0 Out Z 0 0 D3 D2 D D0 Out Y B C S S0 4-to- MUX B C S S0 4-to- MUX As before, x = C. 56

MUX: (Cont.) Factoring Out C We could have factored out other variables. As in the book, we will factor out C and apply AB to the select inputs: Gray Binary A B C x y z 0 0 0 0 D 0 = C 0 D 0 = C 0 D 0 = C 0 0 0 0 0 D = C D = C' D = C' 0 0 0 0 0 0 D 2 = C 0 D 2 = C D 2 = C' 0 0 0 0 D 3 = C 0 D 3 = C' 0 D 3 = C 0 This is slightly larger than selecting A to factor out. 57

MUX: (Cont.) Factoring out B Gray Binary A B C x y z 0 0 0 0 x = "0" 0 y = B 0 z = B 0 0 0 0 0 x = "" y = B' z = B' 0 0 0 00 0 x = "0" 0 y = B z = B' 0 0 0 0 x = "" y = B' 0 z = B 0 Note: We re-arranged the table (fixing A and C and varying B from 0 to in each cell) to simplify this procedure. It still looks like factoring A was better. 58

MUX: (Cont.) Factoring out A Gray Binary A B C x y z 0 0 0 0 D0 = 0 0 D0 = 0 0 D0 = A 00 0 0 0 0 D = D = D = A' 0 0 0 0 0 D2 = 0 D2 = D2 = A' 0 0 0 0 D3 = 0 D3 = 0 0 D3 = A 0 Note: We re-arranged the table (fixing B and C and varying A from 0 to in each cell) to simplify this procedure. Factoring A is best! Note also that x = C holds. 59

Summary Know the functions performed by the following functional blocks: Decoders Demultiplexers Encoders Multiplexers Know how to implement Boolean functions using: Multiplexers Decoders 60

Functional Blocks: Addition Binary addition occurs frequently in digital and computer systems. In this section, we: Develop a Half-Adder (HA), a 2-input bitwise addition functional block, Develop a Full-Adder (FA), a 3-input bitwise addition functional block, Iterate full-adders using a ripple-carry to perform parallel binary addition, and Develop a Carry-Look-Ahead Adder CLA to improve performance. 6

Functional Block: Half-Adder A 2-input, -bit width binary adder that produces the following values: X 0 0 + Y + 0 + + 0 + C S 0 0 0 0 0 A half adder adds two bits to produce a two-bit sum. X Y The sum is expressed as a sum bit, S and a carry bit, C. 0 0 The half adder can be specified 0 as a combined truth table 0 for S and C: C 0 0 0 62 S 0 0

Logic Simplification: Half-Adder The K-Map for S, C is: This is a pretty trivial map! By inspection: S = S = X Y (X + X Y + Y) (X = + X Y) Y S X Y 0 2 3 C X Y 0 2 3 and C = X Y C = ( ( X Y) ) These equations lead to several implementations. 63

Five Implementations: Half-Adder We can derive following sets of equations for a half-adder: = + C (a) S = X Y + X Y C = X Y (b) S = (X + Y) (X C = X Y (c) S = ( C + X Y) C = X Y Y) (a), (b), and (e) are SOP, POS, and XOR implementations for S. + (d) S (X Y) C = (X + Y) (e) S = X Y C = X Y In (c), the C function is used as a term in the AND- NOR implementation of S, and in (d), the C function is used in a POS term for S. 64

Implementations: Half-Adder The most common half adder implementation (e) is: S = X Y C = X Y A NAND only implementation (equivalent to equation d) is: X Y C S C S = (X C = ( + Y)C ) (X Y ) X Y C S 65

Functional Block: Full-Adder A full adder is similar to a half adder, but includes a carry-in bit from lower stages. Like the halfadder, it computes a sum bit, S and a carry bit, C. For a carry-in (Z) of zero, it is the same as the half-adder: For a carry- in (Z) of one: Z 0 0 0 0 X 0 0 + Y + 0 + + 0 + C S 0 0 0 0 0 Z X 0 0 + Y + 0 + + 0 + C S 0 0 0 66

Design: Full-Adder Full-Adder Function Table: Full-Adder K-Map: X Y Z C S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 S Y C Y X 0 3 2 4 5 7 6 X 0 3 2 4 5 7 6 Z Z 67

Design: Full-Adder From the K-Map, we get: S = X Y Z + X Y Z + X Y Z C = X Y + X Z + Y Z The S function is the three-bit XOR function (Odd Function): S = X Y The Carry bit C is if both X and Y are (the sum is 2), or if the sum is and a carry-in (Z) occurs. Thus C can be re-written as: The term X Y is carry generate. The term X Y is carry propagate. Z C = X Y + (X Y)Z + X Y Z 68

Implementation: Full Adder Full Adder Schematic G Co Here X, Y, and Z, and C (from the previous pages) are A, B, C i and C o respectively. Also, G = Generate and P = Propagate. Note: This is really a combination of a 3-bit odd function (for S = sum) and Carry logic: (G = Generate) OR (P =Propagate AND C i = Carry In) Co = G + P Ci A B Ci P 69 S

Parallel Binary Adders To add more than one bit, we "bundle" sets of logical signals together and build devices that operate on the whole set in parallel. Example: 4-bit binary adder: Adds an input vector "A(3..0) " to "B(3..0) to get a sum S(3..0) thus: Description Subscript 3 2 0 Input Carry 0 0 C i Augend 0 A i Name Note: the carry out of Stage i becomes the carry in of Stage i+. Addend 0 0 B i Sum 0 S i Output Carry 0 0 C i+ 70

4-bit Ripple-Carry Binary Adder A four-bit Full Adder made from four -bit Full Adders: A(3) B(3) x y x y x y x y C(4) C(3) C(2) C() C(0) Co Ci Co Ci Co Ci Co Ci FA S A(2) A() A(0) B(2) B() B(0) FA S FA S FA S S(3) S(2) S() S(0) Here FA is a Full-Adder from before: Co S P Ci G A B 7

Carry Propagation & Delay One problem with the addition of binary numbers is the length of time to propagate the ripple carry from the least significant bit to the most significant bit. The gate-level propagation path for a 4-bit ripple carry adder of the last example: A(3) B(3) A(2) A() A(0) B(2) B() B(0) C(3) C(2) C() C(0) C(4) S(3) S(2) S() S(0) Note: The "long path" is from A(0) or B(0) though the network to either C(4) or S(3). 72

Carry Look-Ahead Given Stage i from a Full Adder, we know that there will be a carry generated when A i = B i = "", whether or not there is a carry-in. Alternately, there will be a carry propagated if the "Half-Sum" is "" and a carry-in, C i occurs. These two signal conditions are called Generate denoted Gi as G i, and Propagate denoted as P i respectively and are shown here: Ci+ Ai Bi Pi Si Ci 73

74 Carry Look-Ahead (Continued) By defining the equations for the Full Adder in term of the P i and G i, we have: And the output sum S(i) and carry C(i+) is defined as: Starting the stage numbering at zero, we have: where C 0 is a carry in to the least significant bit. i i i i i i B A G B A P = = 0 0 2 3 0 2 3 2 3 2 3 3 4 C P P P P G P P P G P P G P G C + + + + = i i i i i i i C P G C C P S + = = +

Carry Look-Ahead (Continued) Look at the following addition examples, all of which generate a carry of out of the third stage: xxx +xxx xxxx xx +0xx 0xxx x +00x 00xx +000 000x +0000 0000 Generate a carry in Stage3 Generate a carry in Stage2 and propagate it through Stage3 Generate a carry in Stage and propagate it through Stage2 and Stage3 Generate a carry in Stage0 and propagate it through Stage, Stage2 and Stage3 Use a carry into Stage0 and propagate it through Stage0, Stage, Stage2 and Stage3 75

Group Carry Look-Ahead Logic Figure 3-28 in the text shows how to implement a carry look-ahead circuit for four bits. This could be extended to more than four bits. In practice, though, it becomes more difficult to implement this over more than a few bits. The concept can be extended another level by considering a Group Generate (G 0-3 ) and Group Propagate (P 0-3 ) logic condition: G P 0-3 = = G P 3 P + P P 3 P G 2 + 0-3 3 2 0 Using these two equations: C4 = G0-3 + P0-3 C0 Thus, it is possible to have four 4-bit adders use one of the same carry look-ahead circuits to add 6 bits! P 3 P 2 G + P 3 P 2 P P 0 G 0 76

Complements Subtraction of numbers requires a different algorithm from that for addition Adding the complement of a number is equivalent to subtraction We will discuss two complements: Diminished Radix Complement Radix Complement Subtraction will be done by adding the complement of the subtrahend 77

Diminished Radix Complement Given a number N in Base r having n digits, the (r ) s-complement (called the Diminished Radix Complement) is defined as: (r n ) N Example: For r = 0, N = 2340, n = 4 (4 digits),we have: (r n ) = 0,000 = 99990 The 9's complement of 2340 is then: 99990-2340 = 87650 78

Binary 's Complement For r = 2, N = 000 2, n = 8 (8 digits): (r n ) = 256 - = 255 0 or 2 The 's complement of 000 2 is then: 000 00000 Since the 2 n factor consists of all 's and since 0 = and = 0, the one's complement is obtained by complementing each individual bit (bitwise NOT). 79

Radix Complement Given a number N in Base r having n digits, the r's complement (called the radix complement) is defined as: r n N for N 0 and 0 for N = 0 The radix complement is obtained by adding to the diminished radix complement Example: For r = 0, N = 234 0, n = 4 (4 digits), we have: r n = 0,000 0 The 0's complement of 234 is then 0,000-234 = 8766 0 or 8765 + (9's complement plus ) 80

Binary 2's Complement For r = 2, N = 000 2, n = 8 (8 digits), we have: (r n ) = 256 0 or 00000000 2 The 2's complement of 000 is then: 00000000 000 0000 Note the result is the 's complement plus 8

Alternate 2 s Complement Given: an n-bit binary number, beginning at the right and proceeding left: Copy all least significant 0 s Copy the first Complement all bits thereafter. 2 s Complement Example: 00000 Copy underlined bits: 00 and complement bits to the left: 0000 82

Subtraction with Radix Complements For n-digit, unsigned numbers M and N, find M N in base r: Add the r's complement of the subtrahend N to the minuend M: M + (r n N) = M N + r n If M > N, the sum produces end carry r n which is discarded; from above, M N remains. If M < N, the sum does not produce an end carry and, from above, is equal to r n ( N M ), the r's complement of ( N M ). To obtain the result (N M), take the r's complement of the sum and place a in front. 83

Unsigned 0 s Complement Subtraction Example Find 543 0 23 0 543 543 23 + 877 0 s comp 420 The carry of indicates that no correction of the result is required. 84

Unsigned 0 s Complement Subtraction Example 2 Find 23 0 543 0 23 23 543 + 457 580 0 s comp 520 The carry of 0 indicates that a correction of the result is required. Result = (520) 0 s comp 0 85

Unsigned 2 s Complement Subtraction Example Find 00000 2 00000 2 00000 00000 00000 + 00 2 s comp 000000 The carry of indicates that no correction of the result is required. 86

Unsigned 2 s Complement Subtraction Example 2 Find 00000 2 00000 2 00000 00000 0 00000 + 0000 2 s comp 0 000000 2 s comp The carry of 0 indicates that a correction of the result is required. Result = (000000) 87

Subtraction with Diminished Radix Complement For n-digit, unsigned numbers M and N, find M N in base r: Add the (r )'s complement of the subtrahend N to the minuend M: M + (r n N) = M N + r n If M > N, the result is excess by r n. The end carry r n when discarded removes r n, leaving a result short by. To fix this shortage, whenever and end carry occurs we all in the LSB position. This is called end-around carry. If M < N, the sum does not produce an end carry and, from above, is equal to r n ( N M ), the r 's complement of ( N M ). To obtain the result (N M), take the r 's complement of the sum and place a in front. 88

Unsigned s Complement Subtraction Example Find 00000 2 00000 2 00000 00000 00000 + 000 s comp 0000000 + 000000 The end-around carry occurs. 89

Unsigned s Complement Subtraction Example 2 Find 00000 2 00000 2 00000 00000 0 00000 s comp+ 000 00 000000 The carry of 0 indicates that a correction of the result is required. Result = (000000) s comp 90

Signed Integers Positive numbers and zero can be represented by unsigned n-digit, radix r numbers. We need a representation for negative numbers. To represent a sign (+ or ) we need exactly one more bit of information ( binary digit gives 2 = 2 elements which is exactly what is needed). Since computers use binary numbers, by convention, (and, for convenience), the most significant bit is interpreted as a sign bit: s a n 2 a 2 a a 0 where: s = 0 for Positive numbers s = for Negative numbers and a i = 0 or represent in some form the magnitude. 9

Signed Integer Representations Signed-Magnitude here the n digits are interpreted as a positive magnitude. Signed-Complement here the digits are interpreted as the rest of the complement of the number. There are two possibilities here: Signed One's Complement Uses 's Complement Arithmetic Signed Two's Complement Use 2's Complement Arithmetic 92

Signed Integer Representation Example r =2, n=3 Number Sign-Mag. 's Comp. 2's Comp. +3 0 0 0 +2 00 00 00 + 00 00 00 +0 000 000 000 0 00 0 0 2 0 0 0 3 00 0 4 00 93

Signed-Magnitude Arithmetic Addition: If signs are the same:. Add the magnitudes. 2. Check for overflow (a carry into the sign bit). 3. The sign of the result is the same. If the signs differ:. Subtract the subtrahend from the minuend 2. If a borrow occurs, take the two s complement of result and make the sign the complement of the sign of the minuend. 3. Overflow will never occur. Subtraction: Complement the sign bit of the number you are subtracting and follow the rules for addition. 94

Sign-Magnitude Examples 95

Signed-Complement Arithmetic Addition:. Add the numbers including the sign bits, discarding a carry out of the sign bits (2's Complement), or using an end-around carry ('s Complement). 2. If the sign bits were the same for both numbers and the sign of the result is different, an overflow has occurred. 3. The sign of the result is computed in step. Subtraction: Form the complement of the number you are subtracting and follow the rules for addition. 96

Signed 2 s Complement Examples 97

Signed s Complement Examples 98

2 s Complement Adder/Subtractor Subtraction can be accomplished by addition of the Two's Complement.. Complement each bit (One's Comp.) 2. Add one to the result. The following circuit computes A - B: When the Carry-In is, the 2 s comp of B is formed using XORs to form the s comp and adding the on C(0). A(3) B(3) x y x y x y C(4) C(3) C(2) C() Co Ci Co Ci Co Ci FA S A(2) A() A(0) B(2) B() B(0) FA S FA S Co x FA S y Ci C(0) S(3) S(2) S() S(0) 99

Overflow Detection 00

Binary Multiplication The binary digit multiplication table is trivial: (a b) b = 0 b = a = 0 0 0 a = 0 This is simply the Boolean AND function. Form larger products the same way we form larger products in base 0. 0

Review of Decimal Multiplication Perform base 0 multiplication by: Computing partial products, and Justifying and summing the partial products. To compute partial products: Multiply the row of multiplicand digits by each multiplier digit, one at a time. Partial product formation here require carries to be added more complex than binary 02

Example: (237 x 49) Base 0 Partial products are: 237 9, 237 4, and 237 Note that the partial product summation for n digit, base 0 numbers requires adding up to n digits (with carries). Note also n x m digit multiply generates up to an m+n digit result. 2 3 7 4 9 2 3 3 9 4 8 - + 2 3 7 - - 3 5 3 3 03

Binary Multiplication Algorithm We compute base 2 multiplication by: Computing partial products, and Justifying and summing the partial products. (same as decimal!) To compute partial products: Multiply the row of multiplicand digits by each multiplier digit, one at a time. With binary numbers, partial products are very simple! They are either: all zero (if the multiplier digit is zero), or the same as the multiplicand (if the multiplier digit is one). Note: No carries are added in partial product formation! 04

Example: (0 x 0) Base 2 Partial products are: 0 x 0, 0 x, and 0 x Note that the partial product summation for n digit, base 2 numbers requires adding up to n digits (with carries) 0 in a column. Note also n x m digit multiply generates up to an m + n digit result (same as decimal). 0 0 0 0 0 0 0 0 05