L8/9: Arithmetic Structures

Similar documents
CMPUT 329. Circuits for binary addition

Chapter 5 Arithmetic Circuits

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

Digital Integrated Circuits A Design Perspective. Arithmetic Circuits. Jan M. Rabaey Anantha Chandrakasan Borivoje Nikolic.

Carry Look Ahead Adders

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

Digital Integrated Circuits A Design Perspective. Arithmetic Circuits. Jan M. Rabaey Anantha Chandrakasan Borivoje Nikolic.

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

EECS150. Arithmetic Circuits

Binary addition by hand. Adding two bits

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

CMPEN 411 VLSI Digital Circuits Spring Lecture 19: Adder Design

Solutions for Appendix C Exercises

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

1 Short adders. t total_ripple8 = t first + 6*t middle + t last = 4t p + 6*2t p + 2t p = 18t p

CprE 281: Digital Logic

CS 140 Lecture 14 Standard Combinational Modules

Homework 4 due today Quiz #4 today In class (80min) final exam on April 29 Project reports due on May 4. Project presentations May 5, 1-4pm

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

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

14:332:231 DIGITAL LOGIC DESIGN

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design

Hardware Design I Chap. 4 Representative combinational logic

Hw 6 due Thursday, Nov 3, 5pm No lab this week

ISSN (PRINT): , (ONLINE): , VOLUME-4, ISSUE-10,

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

3. Combinational Circuit Design

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

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

Combinational Logic Design Arithmetic Functions and Circuits

VLSI Design. [Adapted from Rabaey s Digital Integrated Circuits, 2002, J. Rabaey et al.] ECE 4121 VLSI DEsign.1

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

L2: Combinational Logic Design (Construction and Boolean Algebra)

Adders, subtractors comparators, multipliers and other ALU elements

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters

EECS 427 Lecture 8: Adders Readings: EECS 427 F09 Lecture 8 1. Reminders. HW3 project initial proposal: due Wednesday 10/7

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

CSEE 3827: Fundamentals of Computer Systems. Combinational Circuits

Adders, subtractors comparators, multipliers and other ALU elements

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

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

EECS150 - Digital Design Lecture 22 - Arithmetic Blocks, Part 1

EFFICIENT MULTIOUTPUT CARRY LOOK-AHEAD ADDERS

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Lecture 8: Sequential Multipliers

Number representation

Chapter 5. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 5 <1>

Lecture 4. Adders. Computer Systems Laboratory Stanford University

L2: Combinational Logic Design (Construction and Boolean Algebra)

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences

Combinational Logic. By : Ali Mustafa

EECS150 - Digital Design Lecture 25 Shifters and Counters. Recap

The equivalence of twos-complement addition and the conversion of redundant-binary to twos-complement numbers

Arithmetic Circuits How to add and subtract using combinational logic Setting flags Adding faster

EECS150 - Digital Design Lecture 10 - Combinational Logic Circuits Part 1

Bit-Sliced Design. EECS 141 F01 Arithmetic Circuits. A Generic Digital Processor. Full-Adder. The Binary Adder

VLSI Arithmetic. Lecture 9: Carry-Save and Multi-Operand Addition. Prof. Vojin G. Oklobdzija University of California

Digital Integrated Circuits A Design Perspective

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops

CprE 281: Digital Logic

UNIT II COMBINATIONAL CIRCUITS:

CSE477 VLSI Digital Circuits Fall Lecture 20: Adder Design

Module half adder module half_adder(output S,C,input x,y); xor(s,x,y); and(c,x,y); endmodule

Arithmetic Circuits-2

L2: Combinational Logic Design (Construction and Boolean Algebra)

Computer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process

Lecture 11: Adders. Slides courtesy of Deming Chen. Slides based on the initial set from David Harris. 4th Ed.

EECS Components and Design Techniques for Digital Systems. FSMs 9/11/2007

Numbers and Arithmetic

Arithmetic Circuits-2

Where are we? Data Path Design

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Systems I: Computer Organization and Architecture

CMSC 313 Lecture 17. Focus Groups. Announcement: in-class lab Thu 10/30 Homework 3 Questions Circuits for Addition Midterm Exam returned

Part II Addition / Subtraction

Where are we? Data Path Design. Bit Slice Design. Bit Slice Design. Bit Slice Plan

Part II Addition / Subtraction

EECS150 - Digital Design Lecture 11 - Shifters & Counters. Register Summary

Review. EECS Components and Design Techniques for Digital Systems. Lec 18 Arithmetic II (Multiplication) Computer Number Systems

L15: Custom and ASIC VLSI Integration

14:332:231 DIGITAL LOGIC DESIGN. 2 s-complement Representation

ECE 645: Lecture 3. Conditional-Sum Adders and Parallel Prefix Network Adders. FPGA Optimized Adders

Review: Designing with FSM. EECS Components and Design Techniques for Digital Systems. Lec09 Counters Outline.

Lecture 12: Adders, Sequential Circuits

ECE/CS 552: Introduction To Computer Architecture 1. Instructor:Mikko H Lipasti. Fall 2010 University i of Wisconsin-Madison

Computer Architecture 10. Fast Adders

Class Website:

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

Problem Set 6 Solutions

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

CSE 20 Discrete Math. Algebraic Rules for Propositional Formulas. Summer, July 11 (Day 2) Number Systems/Computer Arithmetic Predicate Logic

CMSC 313 Lecture 18 Midterm Exam returned Assign Homework 3 Circuits for Addition Digital Logic Components Programmable Logic Arrays

ECE 2300 Digital Logic & Computer Organization

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

Outline. EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits) Combinational Logic (CL) Defined

Lecture 7: Logic design. Combinational logic circuits

EE141- Spring 2004 Digital Integrated Circuits

EE141-Fall 2010 Digital Integrated Circuits. Announcements. An Intel Microprocessor. Bit-Sliced Design. Class Material. Last lecture.

Lecture 12: Adders, Sequential Circuits

Transcription:

L8/9: Arithmetic Structures Acknowledgements: Materials in this lecture are courtesy of the following sources and are used with permission. Rex Min Kevin Atkinson Prof. Randy Katz (Unified Microelectronics Corporation Distinguished Professor in Electrical Engineering and Computer Science at the University of California, Berkeley) and Prof. Gaetano Borriello (University of Washington Department of Computer Science & Engineering) from Chapter 2 of R. Katz, G. Borriello. Contemporary Logic Design. 2nd ed. Prentice-Hall/Pearson Education, 25. J. Rabaey, A. Chandrakasan, B. Nikolic, Digital Integrated Circuits: A Design Perspective Prentice Hall/Pearson, 23. L8/9: 6. Spring 26 Introductory Digital Systems Laboratory

Number Systems Basics How to represent negative numbers? Three common schemes: sign-magnitude, ones complement, twos complement Sign-magnitude: MSB = for positive, for negative Range: -(2 N- ) to (2 N- ) Two representations for zero: & Simple multiplication but complicated addition/subtraction _ Ones complement: if N is positive then its negative is N Example: = 7, = -7 Range: -(2 N- ) to (2 N- ) Two representations for zero: & Subtraction implemented as addition and negation L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 2

Twos Complement Representation Twos complement = bitwise complement = = -7 = = 7 Asymmetric range: -2 N- to 2 N- - Only one representation for zero Simple addition and subtraction Most common representation 4-4 4-4 3 (-3) -3 3 7-7 - [Katz5] L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 3

Overflow Conditions Add two positive numbers to get a negative number or two negative numbers to get a positive number - - -2-2 -3 2-3 2-4 -4 3 3-5 -5 4 4-6 -6 5 5-7 6-7 6-8 7-8 7 5 5 3 = -8! -7-2 = 7! -7 3-2 -8 7 If carry in to sign equals carry out then can ignore carry out, otherwise have overflow L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 4

Binary Full Adder A B C i A Full Adder B S CI S C o CO S = A B C i = ABC i ABC i ABC i ABC i C o = AB C i (AB) S CI CI A B A B CO L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 5

Ripple Carry Adder Structure B 3 A 3 B 2 A 2 B A B A C o,3 Full C o,2 Full C o, Full C o, Adder Adder Adder Full Adder C i, S 3 S 2 S S Worst case propagation delay linear with the number of bits t adder = (N-)t carry t sum L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 6

Extension to Subtraction Under twos complement, subtracting B is the same as adding the bitwise complement of B then adding Combination addition/subtraction system: _ mux selects B for addition, B for subtraction B 3 B 3 B 2 B 2 B B B B A 3 A 2 A A C o,3 C o,2 C o, C o, Add/Subtract S 3 S 2 S S Add for subtraction using carry in Overflow occurs if carry in to sign bit differs from final carry out overflow L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 7

Comparator (one approach) B 3 B 3 B 2 B 2 B B B B A 3 A 2 A A C o,3 C o,2 C o, C o, S 3 S 2 S S N true if negative result Z true if zero result A < B = N A = B = Z A B = Z N L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 8

Alternate Adder Logic Formulation How to Speed up the Critical (Carry) Path? (How to Build a Fast Adder?) A B C in Full Adder C o S Generate (G) = AB Propagate (P) = A B Note: can also use P = A B for C o L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 9

Carry Bypass Adder A B A B A 2 B 2 A 3 B 3 P G P G P 2 G 2 P 3 G 3 Can compute P, G in parallel for all bits C i, C o, C o, C o,2 C o,3 BP= P P P 2 P 3 P G P 2 G 2 P 3 G 3 P G C i, Co, C o, C o,2 C o,3 Key Idea: if (P P P 2 P 3 ) then C o,3 = C i, L8/9: 6. Spring 26 Introductory Digital Systems Laboratory

6-bit Carry Bypass Adder BP= P P P 2 P 3 BP= P 4 P 5 P 6 P 7 BP= P 8 P 9 P P BP= P 2 P 3 P 4 P 5 C i, C o, C o, C o,2 C o,3 C o,4 C o,5 C o,6 C o,7 C o,8 C o, C o,9 C o, C o,2 C o,3 C o,4 C o,5 Assume the following for delay each gate: P, G from A, B: delay unit P, G, C i to C o or Sum for a : delay unit 2: mux delay: delay unit What is the worst case propagation delay for the 6-bit adder? L8/9: 6. Spring 26 Introductory Digital Systems Laboratory

Critical Path Analysis BP= P P P 2 P 3 BP2= P 4 P 5 P 6 P 7 BP3= P 8 P 9 P P BP4= P 2 P 3 P 4 P 5 C i, C o, C o, C o,2 C o,3 C o,4 C o,5 C o,6 C o,7 C o,8 C o, C o,9 C o, C o,2 C o,3 C o,4 C o,5 For the second stage, is the critical path: BP2 = or BP2 =? Message: Timing Analysis is Very Tricky Must Carefully Consider Data Dependencies For False Paths L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 2

Carry Lookahead Adder C = G P C Re-express the carry logic as follows: C2 = G P C = G P G P P C C3 = G2 P2 C2 = G2 P2 G P2 P G P2 P P C C4 = G3 P3 C3 = G3 P3 G2 P3 P2 G P3 P2 P G P3 P2 P P C Each of the carry equations can be implemented in a two-level logic network Variables are the adder inputs and carry in to stage Ripple effect has been eliminated! L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 3

Carry Lookahead Logic Ai Bi Ci Pi Si Gi Adder with propagate and generate outputs Later stages have increasingly complex logic C P G C P P G P G C C2 C P P P2 G P P2 G P2 G2 C3 C P P P2 P3 G P P2 P3 G P2 P3 G2 P3 C4 G3 L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 4

Block Generate and Propagate G j:i and P j:i denote the Generate and Propagate functions, respectively, for a group of bits from positions i to j. We call them Block Generate and Block Propagate. G j:i equals if the group generates a carry independent of the incoming carry. P j:i equals if an incoming carry propagates through the entire group. For example, G 3:2 is equal to if a carry is generated at bit position 3, or if a carry out is generated at bit position 2 and propagates through position 3. G 3:2 = G 3 P 3 G 2. P 3:2 is true if an incoming carry propagates through both bit positions 2 and 3. P 3:2 = P 3 P 2 C 2 = (G P G ) (P P )C = G : P : C C 4 = G 3 P 3 G 2 P 3 P 2 G P 3 P 2 P G P 3 P 2 P P C = (G 3 P 3 G 2 ) (P 3 P 2 )C o, = G 3:2 P 3:2 C 2 = G 3:2 P 3:2 (G : P : C ) = G 3: P 3: C The carry out of a 4-bit block can thus be computed using only the block generate and propagate signals for each 2-bit section, plus the carry in to bit. The same formulation will be used to generate the carry out signals for a 6-bit adder using the block generate and propagate from 4-bit sections. L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 5

More Definitions ( gp, ) ( g', p' ) = ( g pg', pp' ) The above dot operator obeys the associative property, but it is not commutative (G 3:2,P 3:2 ) = (G 3,P 3 ) (G 2,P 2 ) ( C o3,, ) = (( G 3, P 3 ) ( G 2, P 2 ) ( G, P ) ( G, P )) ( C i,, ) ( G 3:, P 3: ) = [( G 3, P 3 ) ( G 2, P 2 )] [( G, P ) ( G, P )] = ( G 3:2, P 3:2 ) ( G :, P : ) ( C ok, ), = (( G, k P ) ( k G, k P ) ( k G, P )) C i (, ), L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 6

Logarithmic Look-Ahead Adder A F A A 2 A 3 A 4 A 5 A 6 A 7 t p : O(N) A A A 2 A 3 F A 4 A 5 A 6 t p :O(log 2 N) A 7 L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 7

6-bit Kogge-Stone Tree Adder Sum Logic (A, B ) (A, B ) (A2, B 2 ) (A3, B 3 ) (A4, B 4 ) (A5, B 5 ) (A6, B 6 ) (A7, B 7 ) (A8, B 8 ) (A9, B 9 ) (A, B ) (A, B ) (A2, B 2 ) (A3, B 3 ) (A4, B 4 ) (A5, B 5 ) S S S2 S3 S4 S5 S6 S7 S8 S9 S S S2 S3 S4 S5 Propagate, Generate Logic L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 8

Adder Performance Ripple Bypass Select Lookahead Delay vs. number of bits L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 9

Addition of M, N-bit N Numbers IN N- IN N- IN2 N- IN3 N- INM- N- IN N-2 IN N-2 IN2 N-2 IN3 N-2 INM- N-2 IN IN IN2 IN3 INM- IN IN IN2 IN3 INM- C in = C in = C in = C in = L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 2

6-bit Carry Lookahead Schematic 8 configured for AB: M =, S 3- = A 3: B 3: A 7:4 B 7:4 A :8 B :8 A 5:2 B 5:2 C n C 8 n4 C n C 8 n4 C n C 8 n4 C n C 8 n4 P G P G P G P G S 3: P 3: S 7:4 S :8 S 5:2 C in G 3: P G P G P2 G2 P3 G3 82 C n Cnx Cny Cnz G P 82 computes C in for later stages, using block G & P from earlier stages L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 2

Binary Multiplication x 3 x 2 x x y Partial product computation is simple (single and gate) x 3 x 2 x x y z HA HA x 3 x 2 x x y 2 z HA x 3 x 2 x x y 3 z 2 HA z 7 z 6 z 5 z 4 z 3 L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 22

A Serial (Magnitude) Multiplier Shift/LD D D D D Q Q Q Q xbus [7] [6] [5] [4] xbus 8 add_out 8 Shift rst D Q acc_out x 3 D Q [3] 8 Shift x 2 x x D Q D Q D Q CLK [2] [] [] Shift/LD D Q Y yreg D Q D Q Y Y 2 D Q Y 3 CLK CLK LD D Q CLK XY L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 23

Timing Diagram CLK Shift xreg x3 x2 x x x3 x2 x x x3 x2 x x x3 x2 x x x3 x2 x x yreg y y y2 y3 y y2 y3 X y2 y3 X X y3 X X X y y y2 y3 Acc_out Accum_ Accum_2 Accum_3 X*Y PRODUCT PRODUCT L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 24

Verilog of Serial Multiplier module serialmult(shift, clk, x, y, xy); input shift, clk; input [3:] x, y; output [7:] xy; reg [7:] xreg; reg [3:] yreg; reg [7:] xbus, acc_out, xy_int; wire[7:] add_out; assign add_out = xbus acc_out; assign xy = xy_int; always @ (yreg[] or xreg) begin if (yreg[] == 'b) xbus = 8'b; else xbus = xreg; end always @ (posedge clk) begin if (shift == 'b) begin xreg <= {4'b, x}; yreg <= y; acc_out <= 8'b; xy_int <= add_out; end else begin xreg <= {xreg[6:], 'b}; yreg <= {y[3], yreg[3:]}; acc_out <= add_out; xy_int <= xy; end // if shift end // always endmodule L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 25

Simulation L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 26

Twos Complement Multiplication x 3 x 2 x x y x 3 x 2 x x y z HA x 3 x 2 x x y 2 z HA x 3 x 2 x x y 3 z 2 HA HA z 7 z 6 z 5 z 4 z 3 L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 27

Summary Performance of arithmetic blocks dictate the performance of a digital system Architectural and logic transformations can enable significant speed up (e.g., adder delay from O(N) to O(log 2 (N)) Similar concepts and formulation can be applied at the system level Timing analysis is tricky: watch out for false paths! Area-Delay trade-offs (serial vs. parallel implementations) L8/9: 6. Spring 26 Introductory Digital Systems Laboratory 28