Download presentation
Presentation is loading. Please wait.
1
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
2
Integer multiplication Pencil and paper binary multiplication 1000 (multiplicand) 1001 (multiplier)x
3
Integer multiplication 1000 (multiplicand) 1001 (multiplier) 1000 x Pencil and paper binary multiplication
4
Integer multiplication 1000 (multiplicand) 1001 (multiplier) 1000 00000 x Pencil and paper binary multiplication
5
Integer multiplication 1000 (multiplicand) 1001 (multiplier) 1000 00000 x 000000 Pencil and paper binary multiplication
6
Integer multiplication 1000 (multiplicand) 1001 (multiplier) 1000 00000 1000000 x 000000 Pencil and paper binary multiplication
7
Integer multiplication 1000 (multiplicand) 1001 (multiplier) 1001000 (product) 1000 00000 +1000000 x 000000 (partial products) Pencil and paper binary multiplication
8
Integer multiplication Pencil and paper binary multiplication Key elements Examine multiplier bits from right to left Shift multiplicand left one position each step Simplification: each step, add multiplicand to running product total, but only if multiplier bit = 1 1000 (multiplicand) 1001 (multiplier) 1001000 (product) 1000 00000 +1000000 x 000000 (partial products)
9
a 4 a 3 a 2 a 1 a 0 x 4 x 3 x 2 x 1 x 0 x a 4 x 0 a 3 x 0 a 2 x 0 a 1 x 0 a 0 x 0 a 4 x 1 a 3 x 1 a 2 x 1 a 1 x 1 a 0 x 1 a 4 x 2 a 3 x 2 a 2 x 2 a 1 x 2 a 0 x 2 a 4 x 3 a 3 x 3 a 2 x 3 a 1 x 3 a 0 x 3 a 4 x 4 a 3 x 4 a 2 x 4 a 1 x 4 a 0 x 4 p0p0 p1p1 p9p9 p2p2 p3p3 p4p4 p5p5 p6p6 p7p7 p8p8 + ax 0 2 0 ax 1 2 1 ax 2 2 2 ax 3 2 3 ax 4 2 4 Multiplication using Combinational Circuit
10
Integer multiplication Initialize product register to 0 1000 (multiplicand) 1001 (multiplier) 00000000 (running product)
11
Integer multiplication Multiplier bit = 1: add multiplicand to product 1000 1001 (multiplier) +1000 00000000 00001000 (new running product) (multiplicand)
12
Integer multiplication Shift multiplicand left 1001 (multiplier) +1000 00000000 00001000 10000(multiplicand)
13
Integer multiplication Multiplier bit = 0: do nothing 1001 (multiplier) +1000 00000000 10000(multiplicand) 00001000
14
Integer multiplication Shift multiplicand left 1001 (multiplier) +1000 00000000 100000(multiplicand) 00001000
15
Integer multiplication Multiplier bit = 0: do nothing 1001 (multiplier) +1000 00000000 100000(multiplicand) 00001000
16
Integer multiplication Shift multiplicand left 1001 (multiplier) +1000 00000000 1000000(multiplicand) 00001000
17
Integer multiplication Multiplier bit = 1: add multiplicand to product 1001 (multiplier) +1000 00000000 00001000 1000000(multiplicand) +1000000 01001000 (product)
18
Multiplication using Sequential Circuit 32-bit hardware implementation Multiplicand loaded into right half of multiplicand register Product register initialized to all 0’s Repeat the following 32 times If multiplier register LSB=1, add multiplicand to product Shift multiplicand one bit left Shift multiplier one bit right LSB
19
Integer multiplication Algorithm
20
Floating point representation Floating point (fp) numbers represent reals Example reals: 5.6745, 1.23 x 10 -19, 345.67 x 10 6 Floats and doubles in C Fp numbers are in signed magnitude representation of the form (-1) S x M x B E where S is the sign bit (0=positive, 1=negative) M is the mantissa (also called the significand) B is the base (implied) E is the exponent Example: 22.34 x 10 -4 S=0 M=22.34 B=10 E=-4
21
Floating point representation Fp numbers are normalized in that M has only one digit to the left of the “decimal point” Between 1.0 and 9.9999… in decimal Between 1.0 and 1.1111… in binary Simplifies fp arithmetic and comparisons Normalized: 5.6745 x 10 2, 1.23 x 10 -19 Not normalized: 345.67 x 10 6, 22.34 x 10 -4, 0.123 x 10 -45 In binary format, normalized numbers are of the form Leading 1 in 1.M is implied (-1) S x 1.M x B E
22
Floating point representation tradeoffs Representing a wide enough range of fp values with enough precision (“decimal” places) given limited bits More E bits increases the range More M bits increases the precision A larger B increases the range but decreases the precision The distance between consecutive fp numbers is not constant! BEBE B E+1 B E+2 …… S 32 bits E??M?? (-1) S x 1.M x B E
23
Floating point representation tradeoffs Allowing for fast arithmetic implementations Different exponents requires lining up the significands; larger base increases the probability of equal exponents Handling very small and very large numbers 0 exponent overflow exponent underflow exponent overflow representable positive numbers (S=0) representable negative numbers (S=1)
24
Biased exponent notation 111…111 represents the most positive E and 000…000 represents the most negative E for sorting/comparing purposes To get correct signed value for E, need to subtract a bias of 011…111 Biased fp numbers are of the form (-1) S x 1.M x B E-bias Example: assume 8 bits for E Bias is 01111111 = 127 Largest E represented by 11111111 which is 255 – 127 = 128 Smallest E represented by 00000000 which is 0 – 127 = -127
25
IEEE 754 floating point standard Created in 1985 in response to the wide range of fp formats used by different companies Has greatly improved portability of scientific applications B=2 Single precision (sp) format (“float” in C) Double precision (dp) format (“double” in C) SEM 1 bit8 bits23 bits SEM 1 bit11 bits52 bits
26
IEEE 754 floating point standard Exponent bias is 127 for sp and 1023 for dp Fp numbers are of the form (-1) S x 1.M x 2 E-bias 1 in mantissa and base of 2 are implied Sp form is (-1) S x 1.M 22 M 21 …M 0 x 2 E-127 and value is (-1) S x (1+(M 22 x2 -1 ) +(M 21 x2 -2 )+…+(M 0 x2 -23 )) x 2 E-127 Sp example Number is –1.1000…000 x 2 1-127 =-1.5 x 2 -126 =1.763 x 10 -38 1000000011000…000 SEM
27
IEEE 754 floating point standard Denormalized numbers Allow for representation of very small numbers Identified by E=0 and a non-zero M Format is (-1) S x 0.M x 2 -bias-1 Smallest positive dp denormalized number is 0.00…01 x 2 -1022 = 2 -1074 smallest positive dp normalized number is 1.0 x 2 -1023 Hardware support is complex, and so often handled by software 0 exponent overflow exponent underflow exponent overflow representable positive numbers representable negative numbers
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.