Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:

Slides:



Advertisements
Similar presentations
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Binary Arithmetic Binary addition Binary subtraction
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Floating Point Numbers
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
1  2004 Morgan Kaufmann Publishers Chapter Three.
Chapter 6 Arithmetic. Addition Carry in Carry out
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
CPSC 321 Computer Architecture ALU Design – Integer Addition, Multiplication & Division Copyright 2002 David H. Albonesi and the University of Rochester.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Simple Data Type Representation and conversion of numbers
Computer Organization and Architecture Computer Arithmetic Chapter 9.
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 Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
Computer Arithmetic.
Computing Systems Basic arithmetic for computers.
ECE232: Hardware Organization and Design
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Spring 2006 University of Ilam.
Multiplication of signed-operands
L/O/G/O CPU Arithmetic Chapter 7 CS.216 Computer Architecture and Organization.
Figure 1.1 Block diagram of a digital computer. Functional Units.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Ilam University.
CSC 221 Computer Organization and Assembly Language
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
Integer Operations Computer Organization and Assembly Language: Module 5.
Chapter 8 Computer Arithmetic. 8.1 Unsigned Notation Non-negative notation  It treats every number as either zero or a positive value  Range: 0 to 2.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Lecture 9: Floating Point
CS/COE0447 Computer Organization & Assembly Language
William Stallings Computer Organization and Architecture 7th Edition
CSCE 350 Computer Architecture
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Morgan Kaufmann Publishers Arithmetic for Computers
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Signed Number Representations  Sign-Magnitude Example: + 5 = – 5 = Range:  2’s Complement Example: + 5 = – 5 = S Magnitude –7 ≤ N ≤ +7–(2 n –1 –1) ≤ N ≤ +(2 n –1 –1) 0 Magnitude 1 2’s Complement 1 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Signed Number Representations  2’s Complement Range: Exercise: Calculate the range for 8 bits –(2 n –1 ) ≤ N ≤ +(2 n –1 –1) 8 Combinations 2 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept.  Used to represent integers, both positive & negative  Distinguish: “2’s Comp. System” from “2’s Comp. Operation” Example: Represent the number +5 in 2’s Comp. System Correct:Incorrect: +5 = ( ) 2 ( ) 2 2’s Complement System 3 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. 2’s Complement System Example: Given a number represented in 2’s comp. system, write an algorithm to square it. Answer 1) 2) 3) 4 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept.  Bit-by-bit addition, with carry propagation.  Unsigned Binary Operands: ●Produces unsigned binary ●Possible overflow (Cy = 1)  Signed 2’s Comp. Operands: ●Produces 2’s complement ●Possible overflow C y  C y-1 +. Addition / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. –. . +. Subtraction  2’s Complement Addition  Unsigned Binary Operands: ●If Cy = 1, result is unsigned binary ●If Cy = 0, result is negative (2’s comp) ●No overflow  Signed 2’s Comp. Operands: ●Produces 2’s complement ●Possible overflow C y  C y-1 –.  / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. × Multiplication  Bit-by-bit Multiplication  Unsigned Binary Operands ●Unsigned result ●2n-bit result from n × n bits operands ●No overflow ●Partial Sum × Partial Sum = 7 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier × Control Unit ALU 8 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier Control Unit 0 1 Add Load × ALU 9 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier 0 1 Control Unit Shift Left Shift Right 1 1 × ALU 10 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier 1 1 × Shift Left Shift Right Control Unit ALU 11 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier 1 1 × Add Load Shift Left Shift Right Control Unit ALU 12 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier 1 1 × Shift Left Shift Right Control Unit ALU 13 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication Multiplicand Product Multiplier 1 1 × Control Unit  Delay: Number of Clocks =.... Clocks ALU 14 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication M M M M Multiplicand Product Multiplier  Delay: Number of Clocks =.... Clocks Control Unit m m ALU Clock 15 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication M M M M p p p p Multiplicand Product Multiplier  Delay: Number of Clocks =.... Clocks Control Unit 0 m m m ALU Clock 16 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication 0 0 M M M M p p p p p p Multiplicand Product Multiplier  Delay: Number of Clocks =.... Clocks Control Unit 0 0 m m ALU Clock 17 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication 0 M M M M p p p p p p p Multiplicand Product Multiplier  Delay: Number of Clocks =.... Clocks Control Unit m ALU Clock 18 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Multiplication M M M M p p p p Multiplicand Product Multiplier  Delay: Number of Clocks =.... Clocks Control Unit ALU Clock 19 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Multiplication  ALU Size? 20 / × Partial Sum Partial Sum: Partial Sum Partial Sum: Partial Sum Partial Sum: Partial Sum Partial Sum: :03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Signed Multiplication  Signed 2’s Comp. Operands: ●Convert negative operands to positive values ●Perform unsigned multiplication ●Negate the result if the two operands differ in sign 21 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Division  Subtract Divisor & Drop a Bit  Unsigned Binary Operands ●Unsigned result ●2n-bit Dividend by n-bit divisor  n-bit quotient and n-bit remainder ●Possible overflow (big quotient) ♦ Divide by zero ♦ Quotient ≥ 2 n.. │ / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder (Dividend) Quotient 0 0 Control Unit ALU │ – – – – – / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder (Dividend) Quotient 0 0 Control Unit ALU │ – – – – – Subtract Load 24 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient 0 0 Control Unit ALU │ – – – – – Add Load Shift Left 0 Shift Right 25 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient 0 0 Control Unit ALU │ – – – – – Subtract Load 26 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient 0 0 Control Unit ALU │ – – – – – Shift Left 1 Shift Right 27 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – Subtract Load 28 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – Shift Left 1 Shift Right 29 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – Subtract Load 30 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – Add Load Shift Left 0 Shift Right 31 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – Subtract Load 32 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – Shift Left 1 Shift Right 33 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Sequential Division Divisor Remainder Quotient Control Unit ALU │ – – – – – How many times was the Divisor & Quotient shifted? How many clocks? 34 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Signed Division  Signed 2’s Comp. Operands: ●Convert negative operands to positive values ●Perform unsigned division ●Negate the result (?) if the two operands differ in sign ♦ Which result? Quotient or remainder or both? ●Dividend = Quotient × Divisor + Remainder ♦ Example: 16 ÷ 3 ●Rule: Dividend & Remainder must have the same sign 35 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Floating Point  Scientific Notation Example: (10.5 × 10 – 7 is not good)  Normalized Scientific Notation Example: (0.105 × 10 – 5 is not good)  Binary Numbers Example: ( × 2 – 5 is not good) (Normalized). × 10. × 2 36 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Floating Point  Sign & Magnitude  Overflow: The exponent is too large to be represented  Underflow: The exponent is too small to be represented  Single & Double Precision. × 2± S Exponent Fraction 32 bits ± ? 37 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. IEEE 754 Floating Point Standard  Single Precision:  Biased Exponent S Exponent Fraction 32 bits 1 bit 8 bits 23 bits = (biased by 127) 0 + – 38 / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. IEEE 754 Floating Point Standard  Implicit ‘1’ 1.01 × 2 0 Examples: 75 = – 0.75 = 0.0 = ? S Exponent Fraction This bit is always 1 No need to store it, hence implicit ( ) – ( ) / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. IEEE 754 Floating Point Standard  Reserved Bit Patterns ●Zero: ●± Infinity: ●Others like denormalized number and Not-a-Number / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Floating-Point Addition / Subtraction  Need to Align Decimal Points Example: Add Normalized Forms: Align Decimal Point: Perform Addition: Normalize Result: 0.5 = ( ) 2 = = ( ) 2 = 0 × 2 – / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Floating-Point Multiplication  Need to Account for Biased Exponents Example: Multiply 0.5 × Normalized Forms: Multiply Fractions: Add Exponents: Sub Extra Bias: Round & Normalize: 0.5 = ( ) 2 = = ( ) 2 = × – / 41 11:03 AM

Princess Sumaya University – Computer Organization & Design Computer Engineering Dept. Chapter 3