1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.

Slides:



Advertisements
Similar presentations
Chapter Three.
Advertisements

1 Chapter Three Last revision: 4/17/ Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Chapter 3 Arithmetic for Computers
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Arithmetic II CPSC 321 E. J. Kim. Today’s Menu Arithmetic-Logic Units Logic Design Revisited Faster Addition Multiplication (if time permits)
1  2004 Morgan Kaufmann Publishers Chapter Three.
Arithmetic II CPSC 321 Andreas Klappenecker. Any Questions?
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
Chapter Four Arithmetic and Logic Unit
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
Arithmetic III CPSC 321 Andreas Klappenecker. Any Questions?
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
EGRE 426 Fall 09 Chapter Three
CS/COE0447 Computer Organization & Assembly Language
Computing Systems Basic arithmetic for computers.
1 ECE369 Sections 3.5, 3.6 and ECE369 Number Systems Fixed Point: Binary point of a real number in a certain position –Can treat real numbers as.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
1  1998 Morgan Kaufmann Publishers Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
Computing Systems Designing a basic ALU.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
1  2004 Morgan Kaufmann Publishers Performance is specific to a particular program/s –Total execution time is a consistent summary of performance For.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
1  2004 Morgan Kaufmann Publishers Lets Build a Processor Almost ready to move into chapter 5 and start building a processor First, let’s review Boolean.
Computer Architecture Lecture Notes Spring 2005 Dr. Michael P. Frank Competency Area 4: Computer Arithmetic.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
Prof. Hsien-Hsin Sean Lee
Arithmetic-Logic Units. Logic Gates AND gate OR gate NOT gate.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
1 Arithmetic Where we've been: –Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: –Implementing the Architecture.
Computer Arthmetic Chapter Four P&H. Data Representation Why do we not encode numbers as strings of ASCII digits inside computers? What is overflow when.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Computer Arthmetic Chapter Four P&H.
Integer Division.
CS 232: Computer Architecture II
CS/COE0447 Computer Organization & Assembly Language
William Stallings Computer Organization and Architecture 7th Edition
Arithmetic Where we've been:
Arithmetic Logical Unit
Computer Arithmetic Multiplication, Floating Point
ECEG-3202 Computer Architecture and Organization
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Presentation transcript:

1 ECE369 Chapter 3

2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area

3 ECE369 Multiplication: Implementation

4 ECE369 Example

5 ECE369 Second version

6 ECE369 Example

7 ECE369 Final version

8 ECE369 Example

9 ECE369 Division Even more complicated –Can be accomplished via shifting and addition/subtraction More time and more area Negative numbers: Even more difficult There are better techniques, we won’t look at them

10 ECE369 Division: First version

11 ECE369 Example

12 ECE369 Division (7÷2)

13 ECE369 Division: Second version

14 ECE369 Improved Division

15 ECE369 Number Systems Fixed Point: Binary point of a real number in a certain position –Can treat real numbers as integers, do the addition or subtraction normally –Conversion to fixed point (4 binary digits) Addition or division rule Keep multiplying fraction by 2, anytime there is a carry out insert 1 otherwise insert 0 and then left shift (= ) Scientific notation: –3.56*10^8 (not 35.6*10^7) –May have any number of fraction digits (floating)

16 ECE369 Floating point (a brief look) We need a way to represent –Numbers with fractions, e.g., –Very small numbers, e.g., –Very large numbers, e.g., x 10 9 Representation: –Sign, exponent, fraction: (–1) sign x fraction x 2 exponent –More bits for fraction gives more accuracy –More bits for exponent increases range IEEE 754 floating point standard: –single precision: 8 bit exponent, 23 bit fraction –double precision: 11 bit exponent, 52 bit fraction

17 ECE369 IEEE 754 floating-point standard 1.f x 2 e 1.s 1 s 2 s 3 s 4…. s n x2 e Leading “1” bit of significand is implicit Exponent is “biased” to make sorting easier –All 0s is smallest exponent, all 1s is largest –Bias of 127 for single precision and 1023 for double precision If exponent bits are all 0s and if mantissa bits are all 0s, then zero If exponent bits are all 1s and if mantissa bits are all 0s, then +/- infinity

18 ECE369 Single Precision –summary: (–1) sign x (1+significand) x 2 (exponent – bias) Example: 11/100 = 11/10 2 = 0.11 = 1.1x10 -1 –Decimal: -.75 = -3/4 = -3/2 2 –Binary: -.11 = -1.1 x 2 -1 –IEEE single precision: –exponent-bias=-1 => exponent = 126 =

19 ECE369 Opposite Way SignExponentFraction x x2 -2 =0.25

20 ECE369 Floating point addition 1.610x x x x x x x10 2

21 ECE369 Floating point addition

22 ECE369 Add and

23 ECE369 Multiplication

24 ECE369 Floating point multiply To multiply two numbers –Add the two exponent (remember access 127 notation) –Produce the result sign as exor of two signs –Multiply significand portions –Results will be 1x.xxxxx… or 01.xxxx…. –In the first case shift result right and adjust exponent –Round off the result –This may require another normalization step

25 ECE369 Multiplication and

26 ECE369 Floating point divide To divide two numbers –Subtract divisor’s exponent from the dividend’s exponent (remember access 127 notation) –Produce the result sign as exor of two signs –Divide dividend’s significand by divisor’s significand portions –Results will be 1.xxxxx… or 0.1xxxx…. –In the second case shift result left and adjust exponent –Round off the result –This may require another normalization step

27 ECE369 Floating point complexities Operations are somewhat more complicated (see text) In addition to overflow we can have “underflow” Accuracy can be a big problem –IEEE 754 keeps two extra bits, guard and round –Four rounding modes –Positive divided by zero yields “infinity” –Zero divide by zero yields “not a number” –Other complexities Implementing the standard can be tricky Not using the standard can be even worse –See text for description of 80x86 and Pentium bug!

28 ECE369 Lets Build a Processor, Introduction to Instruction Set Architecture First Step Into Your Project !!! How could we build a 1-bit ALU for add, and, or? Need to support the set-on-less-than instruction (slt) –slt is an arithmetic instruction –produces a 1 if a < b and 0 otherwise –use subtraction: (a-b) < 0 implies a < b Need to support test for equality (beq $t5, $t6, Label) –use subtraction: (a-b) = 0 implies a = b How could we build a 32-bit ALU? 32 operation result a b ALU Must Read Appendix

29 ECE369 One-bit adder Takes three input bits and generates two output bits Multiple bits can be cascaded c out = a.b + a.c in + b.c in sum = a b c in

30 ECE369 Building a 32 bit ALU

31 ECE369 Two's complement approach: just negate b and add. How do we negate? A very clever solution: What about subtraction (a – b) ? 000 = and 001 = or 010 = add 000 = and 001 = or 010 = add 110 = subtract

32 ECE369 Supporting Slt Can we figure out the idea? 000 = and 001 = or 010 = add 110 = subtract 111 = slt

33 ECE369 Test for equality Notice control lines 000 = and 001 = or 010 = add 110 = subtract 111 = slt Note: Zero is a 1 if result is zero!

34 ECE369 How about “a nor b” 000 = and 001 = or 010 = add 110 = subtract 111 = slt

35 ECE369 Big Picture

36 ECE369 Conclusion We can build an ALU to support an instruction set –key idea: use multiplexor to select the output we want –we can efficiently perform subtraction using two’s complement –we can replicate a 1-bit ALU to produce a 32-bit ALU Important points about hardware –all of the gates are always working –speed of a gate is affected by the number of inputs to the gate –speed of a circuit is affected by the number of gates in series (on the “critical path” or the “deepest level of logic”) Our primary focus: comprehension, however, –Clever changes to organization can improve performance (similar to using better algorithms in software) How about my instruction smt (set if more than)???

37 ECE369 ALU Summary We can build an ALU to support addition Our focus is on comprehension, not performance Real processors use more sophisticated techniques for arithmetic Where performance is not critical, hardware description languages allow designers to completely automate the creation of hardware!

38 ECE369 Optional Reading

39 ECE369 Overflow

40 ECE369 Formulation

41 ECE369 A Simpler Formula ?

42 ECE369 Problem: Ripple carry adder is slow! Is a 32-bit ALU as fast as a 1-bit ALU? Is there more than one way to do addition? Can you see the ripple? How could you get rid of it? c1 = a0b0 + a0c0 + b0c0 c2 = a1b1 + a1c1 + b1c1c2 = c3 = a2b2 + a2c2 + b2c2c3 = c4 = a3b3 + a3c3 + b3c3c4 = Not feasible! Why?

43 ECE369 Carry Bit

44 ECE369 Generate/Propagate aiai bibi c i aiai bibi

45 ECE369 Generate/Propagate (Ctd.)

46 ECE369 Carry-look-ahead adder Motivation: –If we didn't know the value of carry-in, what could we do? –When would we always generate a carry? g i = a i. b i –When would we propagate the carry? p i = a i + b i Did we get rid of the ripple? c1 = g0 + p0c0 c2 = g1 + p1c1 c2 = g1 + p1g0 + p1p0c0 c3 = g2 + p2c2 c3 = g2 + p2g1 + p2p1g0 + p2p1p0c0 c4 = g3 + p3c3 c4 = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0 Feasible! Why? c1 = a0b0 + a0c0 + b0c0 c2 = a1b1 + a1c1 + b1c1c2 = c3 = a2b2 + a2c2 + b2c2c3 = c4 = a3b3 + a3c3 + b3c3c4 = a3 a2 a1 a0 b3 b2 b1 b0

47 ECE369 A 4-bit carry look-ahead adder Generate g and p term for each bit Use g’s, p’s and carry in to generate all C’s Also use them to generate block G and P CLA principle can be used recursively

48 ECE Bit CLA

49 ECE369 Gate Delay for 16 bit Adder

50 ECE bit carry lookahead adder