fpa algorithm

Upload: raj-kumar

Post on 03-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 fpa algorithm

    1/22

    A N I M P R O V E D A L G O R I T H M F O R

    H I G H - S P E E D F L O A T I N G - P O I N T A D D I T I O N

    N h o n T . Q u a c h a n d M i c h a e l J . F l y n n

    T e c h n i c a l R e p o r t : C S L - T R - 9 0 - 4 4 2

    A u g u s t 1 9 9 0

    T h i s w o r k w a s s u p p o r t e d b y N S F c o n t r a c t N o . M I P 8 8 - 2 2 9 6 1 .

  • 7/28/2019 fpa algorithm

    2/22

    A N I M P R O V E D A L G O R I T H M F O R

    H I G H - S P E E D F L O A T I N G - P O I N T A D D I T I O N

    b y

    N h o n T . Q u a c h a n d M i c h a e l J . F l y n n

    T e c h n i c a l R e p o r t : C S L - T R - 9 0 - 4 4 2

    A u g u s t 1 9 9 0

    C o m p u t e r S y s t e m s L a b o r a t o r y

    D e p a r t m e n t s o f E l e c t r i c a l E n g i n e e r i n g a n d C o m p u t e r S c i e n c e

    S t a n f o r d U n i v e r s i t y

    S t a n f o r d , C a l i f o r n i a 9 4 3 0 5 - 4 0 5 5

    A b s t r a c t

    T h i s p a p e r d e s c r i b e s a n i m p r o v e d , I E E E c o n f o r m i n g o a t i n g - p o i n t a d d i t i o n a l g o r i t h m .

    T h i s a l g o r i t h m h a s o n l y o n e a d d i t i o n s t e p i n v o l v i n g t h e s i g n i c a n d i n t h e w o r s t - c a s e p a t h ,

    h e n c e o e r i n g a c o n s i d e r a b l e s p e e d a d v a n t a g e o v e r t h e e x i s t i n g a l g o r i t h m s , w h i c h t y p i c a l l y

    r e q u i r e t w o t o t h r e e a d d i t i o n s t e p s .

    K e y W o r d s a n d P h r a s e s : I m p r o v e d o a t i n g - p o i n t a d d i t i o n a l g o r i t h m , o a t i n g - p o i n t

    h a r d w a r e d e s i g n , I E E E r o u n d i n g

  • 7/28/2019 fpa algorithm

    3/22

    C o p y r i g h t

    c

    1 9 9 6

    b y

    N h o n T . Q u a c h a n d M i c h a e l J . F l y n n

  • 7/28/2019 fpa algorithm

    4/22

    C o n t e n t s

    1 I n t r o d u c t i o n 1

    2 A B r i e f R e v i e w o f F P A d d i t i o n A l g o r i t h m 1

    3 T h e N e w A l g o r i t h m 3

    3 . 1 G e n e r a l I d e a s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    3 . 2 L o g i c E q u a t i o n f o r C

    i n

    f o r t h e R T N M o d e : . . . . . . . . . . . . . . . . . . 4

    3 . 2 . 1 G e n e r a l E q u a t i o n f o r C

    i n

    : . . . . . . . . . . . . . . . . . . . . . . . . 5

    3 . 2 . 2 A p p l y i n g C

    i n

    t o t h e T h r e e C a s e s . . . . . . . . . . . . . . . . . . . . 5

    3 . 2 . 3 M e r g i n g C a s e 1 a n d C a s e 2 . . . . . . . . . . . . . . . . . . . . . . . 1 1

    4 S u m m a r y 1 2

    5 A c k n o w l e d g e m e n t 1 2

    A N o t a t i o n 1 3

    B C

    i n

    f o r o t h e r r o u n d i n g M o d e s 1 5

    B . 1 R o u n d t o 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    B . 2 R o u n d t o + 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 5

    B . 3 R o u n d t o , 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6

    i i i

  • 7/28/2019 fpa algorithm

    5/22

    L i s t o f F i g u r e s

    1 E x p l a n a t i o n o f t h e G e n e r a l A p p r o a c h f o r t h e R T N M o d e . . . . . . . . . . . 4

    2 H a r d w a r e f o r R o u n d t o P o s i t i v e I n n i t y . . . . . . . . . . . . . . . . . . . . . 1 6

    i v

  • 7/28/2019 fpa algorithm

    6/22

    L i s t o f T a b l e s

    1 S t e p s i n C o n v e n t i o n a l F P A d d i t i o n A l g o r i t h m s . . . . . . . . . . . . . . . . . 2

    2 S t e p s i n t h e P r e s e n t F P A d d i t i o n A l g o r i t h m . . . . . . . . . . . . . . . . . . 3

    3 T r u t h T a b l e f o r t h e R o u n d t o N e a r e s t M o d e . . . . . . . . . . . . . . . . . . 5

    4 T r u t h T a b l e f o r D e t e r m i n i n g G u a r d , R o u n d , a n d S t i c k y B i t s i n C a s e 2 a . . . 8

    5 T r u t h T a b l e f o r D e t e r m i n i n g G u a r d , R o u n d , a n d S t i c k y B i t s i n C a s e 2 b . . . 9

    v

  • 7/28/2019 fpa algorithm

    7/22

    1 I n t r o d u c t i o n

    F l o a t i n g - p o i n t F P a d d i t i o n i s o n e o f t h e m o s t f r e q u e n t a r i t h m e t i c o p e r a t i o n s i n s c i e n t i c

    c o m p u t i n g . D e s p i t e i t s c o n c e p t u a l s i m p l i c i t y , F P a d d i t i o n i n m o s t h i g h - s p e e d a r i t h m e t i c

    u n i t s t o d a y h a s r o u g h l y t h e s a m e l a t e n c y a s F P m u l t i p l i c a t i o n . T h i s i s l a r g e l y b e c a u s e m o s t

    e x i s t i n g F P a d d i t i o n a l g o r i t h m s r e q u i r e t w o t o t h r e e a d d i t i o n s t e p s i n v o l v i n g t h e s i g n i c a n d

    a s e x p l a i n e d b e l o w , a r e l a t i v e l y t i m e - c o n s u m i n g o p e r a t i o n . I n t h i s p a p e r , w e d e s c r i b e a

    n e w F P a d d i t i o n a l g o r i t h m . T h e a l g o r i t h m h a s o n l y o n e s i g n i c a n d a d d i t i o n s t e p i n t h e

    w o r s t c a s e p a t h , h e n c e o e r i n g a c o n s i d e r a b l e s p e e d a d v a n t a g e o v e r e a r l i e r a l g o r i t h m s . W e

    b r i e y r e v i e w t h e s e e x i s t i n g F P a d d i t i o n a l g o r i t h m s i n S e c t i o n 2 a n d p r e s e n t o u r s i n

    S e c t i o n 3 . C o n c l u d i n g r e m a r k s a r e g i v e n i n S e c t i o n 4 . A p p e n d i x A i s a c o l l e c t e d r e v i e w o f

    t h e n o t a t i o n u s e d i n t h i s p a p e r .

    2 A B r i e f R e v i e w o f F P A d d i t i o n A l g o r i t h m

    A n F P a d d i t i o n o p e r a t i o n c o n s i s t s o f t h e f o l l o w i n g s t e p s 1 :

    1 . E x p o n e n t s u b t r a c t i o n E S : S u b t r a c t t h e e x p o n e n t s a n d d e n o t e t h e d i e r e n c e E

    a

    ,

    E

    b

    = d

    2 . A l i g n m e n t A l i g n : R i g h t s h i f t t h e s i g n i c a n d o f t h e s m a l l e r o p e r a n d b y d b i t s . D e n o t e

    t h e l a r g e r e x p o n e n t E

    f

    3 . S i g n i c a n d a d d i t i o n S A : P e r f o r m a d d i t i o n o r s u b t r a c t i o n a c c o r d i n g t o t h e e e c t i v e

    o p e r a t i o n , E

    o

    , w h i c h i s t h e a r i t h m e t i c o p e r a t i o n a c t u a l l y c a r r i e d o u t b y t h e a d d e r i n

    t h e F P u n i t .

    4 . C o n v e r s i o n C o n v : C o n v e r t t h e r e s u l t t o s i g n - m a g n i t u d e r e p r e s e n t a t i o n i f t h e r e s u l t

    i s n e g a t i v e . T h e c o n v e r s i o n i s d o n e w i t h a n a d d i t i o n s t e p . D e n o t e t h e r e s u l t S

    f

    5 . L e a d i n g o n e d e t e c t i o n L O D : C o m p u t e t h e a m o u n t o f l e f t o r r i g h t s h i f t n e e d e d a n d

    d e n o t e i t E

    n

    E

    n

    i s p o s i t i v e f o r a r i g h t s h i f t a n d n e g a t i v e o t h e r w i s e .

    6 . N o r m a l i z a t i o n N o r m : N o r m a l i z e t h e s i g n i c a n d b y s h i f t i n g E

    n

    b i t s a n d a d d E

    n

    t o

    E

    f

    7 . R o u n d i n g R o u n d : P e r f o r m I E E E r o u n d i n g 2 b y a d d i n g 1 " w h e n n e c e s s a r y t o t h e

    L S B o f S

    f

    . T h i s s t e p m a y c a u s e a n o v e r o w , r e q u i r i n g a r i g h t s h i f t . T h e e x p o n e n t ,

    E

    f

    , i n t h i s c a s e h a s t o b e i n c r e m e n t e d b y 1 .

    T h e a b o v e a l g o r i t h m A l g o r i t h m A 1 i s s l o w b e c a u s e t h e c o m p o s i n g s t e p s i n t h e a d d i t i o n

    o p e r a t i o n a r e e s s e n t i a l l y p e r f o r m e d s e r i a l l y . W e c a n i m p r o v e t h e a l g o r i t h m i n t h e f o l l o w i n g

    w a y s :

    1 . I n A l g o r i t h m A 1 , t h e C o n v s t e p i s o n l y n e e d e d w h e n t h e r e s u l t i s n e g a t i v e a n d c a n

    b e a v o i d e d b y s w a p p i n g t h e s i g n i c a n d s . B y e x a m i n i n g t h e s i g n o f t h e r e s u l t o f t h e

    E S s t e p , w e c a n s w a p t h e s i g n i c a n d s a c c o r d i n g l y s o t h a t t h e s m a l l e r s i g n i c a n d i s

    1

  • 7/28/2019 fpa algorithm

    8/22

    s u b t r a c t e d f r o m t h e l a r g e r o n e . I n t h e c a s e o f e q u a l e x p o n e n t s , t h e r e s u l t m a y s t i l l b e

    n e g a t i v e a n d r e q u i r e s a c o n v e r s i o n . B u t n o r o u n d i n g i s n e e d e d i n t h i s c a s e . H e n c e ,

    r o u n d i n g a n d c o n v e r s i o n a r e m a d e m u t u a l l y e x c l u s i v e b y t h e s w a p p i n g s t e p , a l l o w i n g

    u s t o c o m b i n e t h e m . N o t e t h a t a n a s s o c i a t e d a d v a n t a g e o f s w a p p i n g i s t h a t o n l y a

    s h i f t e r i s n o w n e e d e d .

    2 . T h e L O D s t e p c a n b e p e r f o r m e d i n p a r a l l e l w i t h t h e S A s t e p , r e m o v i n g i t f r o m t h e

    c r i t i c a l p a t h . T h i s o p t i m i z a t i o n i s i m p o r t a n t w h e n a m a s s i v e l e f t s h i f t i s r e q u i r e d a s

    a r e s u l t o f s i g n i c a n d c a n c e l l a t i o n i n t h e c a s e o f a n e e c t i v e s u b t r a c t i o n .

    3 . S o f a r , w e h a v e b e e n a b l e t o r e d u c e t h e n u m b e r o f s t e p s d o w n t o : E S , S w a p , A l i g n ,

    S A k L O D , C o n v k R o u n d , a n d N o r m t h e s y m b o l k " i n d i c a t e s t h a t t h e s t e p s c a n

    b e e x e c u t e d i n p a r a l l e l . A l g o r i t h m A 1 c a n b e f u r t h e r o p t i m i z e d b y r e c o g n i z i n g t h a t

    t h e A l i g n a n d t h e N o r m s t e p s a r e m u t u a l l y e x c l u s i v e . N o r m a l i z a t i o n r e q u i r i n g a l a r g e

    n u m b e r o f l e f t s h i f t s i s n e e d e d o n l y w h e n d 1 . C o n v e r s e l y , a l i g n m e n t r e q u i r i n g a

    l a r g e n u m b e r o f r i g h t s h i f t s i s n e e d e d o n l y w h e n d 1 . B y d i s t i n g u i s h i n g t h e s e t w o

    c a s e s , o n l y o n e f u l l l e n g t h s h i f t , e i t h e r t h e a l i g n m e n t o r t h e n o r m a l i z a t i o n o n e , i s i n

    t h e c r i t i c a l p a t h 3 .

    T h e s t e p s i n A l g o r i t h m A 1 a n d t h i s i m p r o v e d a l g o r i t h m A l g o r i t h m A 2 a r e s u m m a r i z e d

    i n T a b l e 1 . I n A l g o r i t h m A 2 , t h e P r e d s t e p i n t h e d 1 p a t h p r e d i c t s w h e t h e r a o n e - b i t

    r i g h t s h i f t i s n e e d e d t o a l i g n t h e s i g n i c a n d s . N o t e t h a t A l g o r i t h m A 2 i n c r e a s e s t h e s p e e d

    b y e x e c u t i n g m o r e s t e p s i n p a r a l l e l , r e q u i r i n g t h e r e f o r e m o r e h a r d w a r e .

    T a b l e 1 : S t e p s i n C o n v e n t i o n a l F P A d d i t i o n A l g o r i t h m s .

    A l g o r i t h m A 1 A l g o r i t h m A 2

    d 1 a n d E e c t i v e S u b t r a c t i o n O t h e r s

    E S P r e d + S w a p E S + S w a p

    A l i g n A l i g n

    S A S A k L O D S A

    C o n v C o n v k R o u n d R o u n d

    L O D

    N o r m N o r m

    R o u n d s e l e c t s e l e c t

    A l g o r i t h m A 2 i s c o m m o n l y u s e d , i n o n e f o r m o r a n o t h e r , i n t o d a y ' s h i g h - p e r f o r m a n c e

    F P a r i t h m e t i c u n i t s 4 , 5 , 6 . F r o m t h e a b o v e d i s c u s s i o n , w e s e e t h a t A l g o r i t h m A 2 r e q u i r e s

    2 a d d i t i o n s t e p s i n v o l v i n g t h e s i g n i c a n d s i n t h e c r i t i c a l p a t h s i n b o t h t h e d 1 a n d t h e

    d 1 p a t h s S A a n d R o u n d

    2

  • 7/28/2019 fpa algorithm

    9/22

    3 T h e N e w A l g o r i t h m

    3 . 1 G e n e r a l I d e a s

    T h e k e y i d e a s b e h i n d o u r a p p r o a c h c a n b e s u m m a r i z e d a s f o l l o w s .

    I n A l g o r i t h m A 2 , t h e S A s t e p r e q u i r e s o n e o f t h e s i g n i c a n d s t o b e 2 ' s c o m p l e m e n t e d

    i n t h e c a s e o f a n e e c t i v e s u b t r a c t i o n . W e o b s e r v e d t h a t t h i s c o m p l e m e n t a t i o n s t e p

    a n d t h e r o u n d i n g o n e a r e m u t u a l l y e x c l u s i v e a n d c a n t h e r e f o r e b e c o m b i n e d .

    I n t h e I E E E r o u n d t o n e a r e s t R T N m o d e , c o m p u t i n g A + B a n d A + B + 1 i s s u c i e n t

    t o a c c o u n t f o r a l l t h e n o r m a l i z a t i o n p o s s i b i l i t i e s t o b e d i s c u s s e d b e l o w .

    1

    B y s e l e c t i n g

    t h e r e s u l t s u s i n g C

    i n

    c o m p u t e d b a s e d o n t h e l o w e r o r d e r b i t s o f t h e s i g n i c a n d s ,

    c o m p l e m e n t a t i o n a n d r o u n d i n g c a n b e d o n e s i m u l t a n e o u s l y , s a v i n g o n e a d d i t i o n s t e p .

    T a b l e 2 : S t e p s i n t h e P r e s e n t F P A d d i t i o n A l g o r i t h m .

    T h e N e w A l g o r i t h m

    d 1 a n d E e c t i v e S u b t r a c t i o n O t h e r s

    P r e d + S w a p E S + S w a p

    S A k C o n v k R o u n d k L O D A l i g n

    N o r m S A k R o u n d

    s e l e c t s e l e c t

    H e n c e , t h e c h a l l e n g e i s i n d e r i v i n g t h e e q u a t i o n f o r C

    i n

    . S i n c e i n F P a d d i t i o n , n o r m a l i z a -

    t i o n o f t h e r e s u l t m a y r e q u i r e a o n e - b i t r i g h t s h i f t , n o s h i f t , o r a l e f t s h i f t w h i c h m a y b e o f a s

    m a n y b i t s a s t h e l e n g t h o f t h e s i g n i c a n d , C

    i n

    n e e d s t o a c c o u n t f o r a l l t h e s e n o r m a l i z a t i o n

    p o s s i b i l i t i e s , s u c h t h a t t h e n a l s e l e c t e d r e s u l t w i l l a p p e a r t o b e r o u n d e d p r o p e r l y .

    B e c a u s e t h e s i g n i c a n d i s 5 3 - b i t a n d b e c a u s e a r i g h t s h i f t o f u p t o 5 2 b i t s m a y b e n e e d e d

    d u r i n g a l i g n m e n t , a 1 0 5 - b i t a d d e r i s p o t e n t i a l l y n e e d e d . S i n c e w e a r e o n l y c o n c e r n e d w i t h

    t h e h i g h e r o r d e r 5 3 - b i t , w e u s e a 5 3 - b i t a d d e r i n t h e i n t e r e s t o f h a r d w a r e e c i e n c y . I n t h e

    c a s e o f c o m p l e m e n t a t i o n , a 1 " n e e d s t o b e a d d e d a t t h e b i t p o s i t i o n 1 0 5 . H o w f a r l e f t i n t o

    t h e h i g h e r o r d e r b i t t h i s c o m p l e m e n t i n g 1 " b i t , C

    c

    , p r o p a g a t e s a n d w h e t h e r i t r e a c h e s t h e

    a d d e r , c l e a r l y d e p e n d s o n t h e l o w e r o r d e r b i t s o f t h e s h i f t e d s i g n i c a n d . W h e n C

    c

    d o e s

    r e a c h t h e a d d e r , i t i s a d d e d t o t h e L " b i t p o s i t i o n . T h e r o u n d i n g 1 " b i t C

    r

    , o n t h e o t h e r

    h a n d , i s a l w a y s a d d e d t o t h e r o u n d i n g b i t p o s i t i o n R " F i g . 1 .

    W h e n t h e b i t p a t t e r n o f t h e s h i f t e d s i g n i c a n d i s s u c h t h a t C

    c

    r e a c h e s t h e r e a l a d d e r , t h e

    g u a r d b i t G , t h e r o u n d b i t R , a n d t h e s t i c k y b i t s , m u s t a l l b e z e r o ; t h e r e f o r e , n o r o u n d i n g

    i s r e q u i r e d . H e n c e , c o m p l e m e n t a t i o n a n d r o u n d i n g , a s f a r a s t h e a d d e r i s c o n c e r n e d , a r e

    1

    I n t h e r o u n d t o p o s i t i v e a n d n e g a t i v e i n n i t y R T P I a n d R T N I m o d e s , i t i s n e c e s s a r y t o c o m p u t e n o t

    o n l y A + B a n d A + B + 1 , b u t a l s o A + B + 2 , m a k i n g i t h a r d e r t h a n t h e R T N m o d e . A r o w o f h a l f a d d e r

    h a s t o b e u s e d t o a d d 2 " t o A + B . T h i s c a s e i s d i s c u s s e d i n m o r e d e t a i l i n t h e a p p e n d i x .

    3

  • 7/28/2019 fpa algorithm

    10/22

    m u t u a l l y e x c l u s i v e a n d c a n b e c o m b i n e d . T a b l e 2 l i s t s t h e s t e p s i n t h e n e w a l g o r i t h m . T h e

    n u m b e r o f s i g n i c a n d a d d i t i o n s t e p i n b o t h p a t h s h a v e b e e n r e d u c e d t o o n e .

    W h i l e i t i s c l e a r t h a t t h i s a r g u m e n t h o l d s f o r t h e c a s e s w h e n t h e r e s u l t o f t h e S A s t e p

    n e e d s a l e f t s h i f t a n d n e e d s n o s h i f t , i t i s l e s s s o f o r t h e c a s e w h e n t h e r e s u l t n e e d s a o n e - b i t

    r i g h t s h i f t , b e c a u s e r o u n d i n g i n t h i s c a s e r e q u i r e s a d d i n g 2 " , n o t 1 " , t o A + B . T h e

    e x p l a n a t i o n l i e s i n t h e d e n i t i o n o f t h e R T N m o d e .

    2

    I n t h e c a s e o f a o n e - b i t r i g h t s h i f t , i t

    i s o n l y n e c e s s a r y t o a d d 2 " t o A + B w h e n t h e L b i t o f A + B i s 1 " b e c a u s e a f t e r t h e

    r i g h t s h i f t , t h e L b e c o m e s t h e G b i t . H e n c e , a d d i n g 1 " t o t h e L o f A + B c a u s e s t h e c a r r y

    i n t o t h e N n e x t t o L S B b i t , t o b e t r u e , e q u i v a l e n t t o a d d i n g 2 " t o A + B

    I m p l e m e n t i n g t h e r o u n d t o z e r o m o d e i s e a s y b e c a u s e a s i m p l e t r u n c a t i o n s u c e s i n

    t h i s c a s e a n d n o r o u n d i n g i s n e e d e d . F o r t h e R T P I a n d R T N I m o d e s , t h e s i t u a t i o n i s m o r e

    c o m p l i c a t e d a n d w e t r e a t t h e m i n A p p e n d i x B t o a v o i d d i g r e s s i o n . T h e l o g i c e q u a t i o n f o r

    C

    i n

    f o r t h e R T N m o d e , w h i c h i s t h e d e f a u l t I E E E r o u n d i n g m o d e , w i l l b e d e r i v e d b e l o w .

    d

    Cin

    MUX

    . . . .

    . . . .

    n-bit compound adder

    n-1a0a a

    n-2

    n-1bn-2b0b b i-1 i

    b . . . .bi+1

    Cc Cr

    bi+2

    sb1

    F i g u r e 1 : E x p l a n a t i o n o f t h e G e n e r a l A p p r o a c h f o r t h e R T N M o d e .

    3 . 2 L o g i c E q u a t i o n f o r C

    i n

    f o r t h e R T N M o d e :

    T o d e r i v e t h e l o g i c e q u a t i o n f o r C

    i n

    , w e d i e r e n t i a t e 3 c a s e s . C a s e 1 i s w h e n E

    o

    i s a d d i t i o n ,

    c a s e 2 w h e n E

    o

    i s s u b t r a c t i o n a n d d 1 a n d c a s e 3 w h e n E

    o

    i s s u b t r a c t i o n a n d d 1

    I n t h e a c t u a l i m p l e m e n t a t i o n t o b e d e s c r i b e d i n t h e f o l l o w i n g s e c t i o n , c a s e s 1 a n d 2 a r e

    m e r g e d t o f o r m o n e p a t h , c o n t r o l l e d b y g

    i n

    i . e . , g

    i n

    p l a y i n g t h e r o l e o f C

    i n

    . C a s e 3 f o r m s

    a n o t h e r p a t h c o n t r o l l e d b y l

    i n

    i . e . , l

    i n

    p l a y i n g t h e r o l e o f C

    i n

    . I n w h a t f o l l o w s , w e r s t

    d e r i v e a g e n e r i c e q u a t i o n f o r C

    i n

    a n d t h e n a p p l y i t t o t h e t h r e e c a s e s t o a r r i v e a t t h e l

    i n

    a n d g

    i n

    e q u a t i o n s .

    2

    T h e R T N m o d e r o u n d s u p a n u m b e r i n a l l c a s e s e x c e p t a t i e , w h e n c e i t r o u n d s u p w h e n t h e L S B i s o d d

    a n d t r u n c a t e s w h e n t h e L S B i s e v e n .

    4

  • 7/28/2019 fpa algorithm

    11/22

    3 . 2 . 1 G e n e r a l E q u a t i o n f o r C

    i n

    :

    A s d e n e d i n A p p e n d i x A , C

    r

    i s t h e b i t n e e d e d t o p e r f o r m r o u n d i n g . I t c a n b e d e t e r m i n e d

    f r o m T a b l e 3 . F r o m t h e t a b l e ,

    C

    r

    = S _ L 1

    T a b l e 3 : T r u t h T a b l e f o r t h e R o u n d t o N e a r e s t M o d e

    L G S C

    r

    0 0 0 x

    0 0 1 x

    0 1 0 0

    0 1 1 1

    1 0 0 x

    1 0 1 x

    1 1 0 1

    1 1 1 1

    T h e e q u a t i o n f o r C

    c

    c a n b e w r i t t e n a s

    C

    c

    = G R s

    T h i s i s b e c a u s e o n l y w h e n t h e G b i t , t h e R b i t , a n d t h e s b i t a r e a l l z e r o d o e s C

    c

    r e a c h

    t h e a d d e r . N o t e t h a t i n t h e c a s e o f a n e e c t i v e s u b t r a c t i o n , t h e e q u a t i o n s f o r G , R , a n d s

    h a v e t o b e w r i t t e n w i t h c o m p l e m e n t a t i o n t a k e n i n t o a c c o u n t .

    T h e e q u a t i o n f o r C

    i n

    i s s i m p l y

    C

    i n

    = G C

    r

    _ C

    c

    3 . 2 . 2 A p p l y i n g C

    i n

    t o t h e T h r e e C a s e s

    1 C a s e 1 : E

    o

    i s a d d i t i o n S i n c e E

    o

    i s a d d i t i o n , n o c o m p l e m e n t a t i o n o f e i t h e r o p e r a n d i s

    n e e d e d ; t h e r e f o r e , C

    c

    = 0 . W e f u r t h e r d i e r e n t i a t e t w o c a s e s : r e s u l t n e e d i n g n o r i g h t

    s h i f t i . e . , n o n o r m a l i z a t i o n i s n e e d e d a n d r e s u l t n e e d i n g a o n e - b i t r i g h t s h i f t . I n t h e

    c a s e o f a d d i t i o n , o n l y t h e s e t w o c a s e s a r e p o s s i b l e b e c a u s e t h e v a l u e o f a n o r m a l i z e d

    s i g n i c a n d r a n g e s b e t w e e n 1 , 2 .

    a R e s u l t n e e d i n g n o r i g h t s h i f t N R S T h i s c a s e o c c u r s w h e n t h e r e i s n o

    c a r r y - o u t f r o m t h e g a d d e r w i t h c a r r y - i n = 0 . T h e l o g i c e q u a t i o n i s

    N R S = E

    o

    g

    0

    o u t

    T h e l o g i c e q u a t i o n s f o r L , G , a n d S a r e

    L = a

    n , 1

    b

    n , 1

    5

  • 7/28/2019 fpa algorithm

    12/22

    S = R _ s = b

    n + 1

    _ s

    G = b

    n

    F r o m E q . 1 , w e h a v e

    C

    r

    = S _ L = b

    n + 1

    _ s _ a

    n , 1

    b

    n , 1

    C

    i n

    i n t h i s c a s e i s

    C

    i n

    = G C

    r

    = b

    n

    b

    n + 1

    _ s _ a

    n , 1

    b

    n , 1

    b R e s u l t n e e d i n g o n e b i t r i g h t s h i f t O R S T h i s c a s e o c c u r s w h e n E

    o

    i s

    a d d i t i o n a n d t h e r e i s a c a r r y - o u t f r o m t h e a d d e r . T h e l o g i c e q u a t i o n i s

    O R S = E

    o

    g

    0

    o u t

    B e c a u s e t h e r e s u l t n e e d s a o n e - b i t r i g h t s h i f t , t h e e q u a t i o n s f o r L , G , a n d S m u s t

    t a k e i t i n t o a c c o u n t . W e h a v e :

    L = a

    n , 2

    b

    n , 2

    a

    n , 1

    b

    n , 1

    S = b

    n

    _ b

    n + 1

    _ s

    G = a

    n , 1

    b

    n , 1

    S o t h a t C

    r

    b e c o m e s

    C

    r

    = S _ L

    = b

    n

    _ b

    n + 1

    _ s _ a

    n , 2

    b

    n , 2

    a

    n , 1

    b

    n , 1

    a n d

    C

    i n

    = G C

    r

    = a

    n , 1

    b

    n , 1

    b

    n

    _ b

    n + 1

    _ s _ a

    n , 2

    b

    n , 2

    a

    n , 1

    b

    n , 1

    U s i n g t h e i d e n t i t y x y z x y = x y z a n d s i m p l i f y i n g , w e g e t

    C

    i n

    = a

    n , 1

    b

    n , 1

    b

    n

    _ b

    n + 1

    _ s _ a

    n , 2

    b

    n , 2

    2 C a s e 2 : E

    o

    i s s u b t r a c t i o n a n d d 1 : W e a g a i n d i e r e n t i a t e t w o c a s e s : r e s u l t

    n e e d i n g n o l e f t s h i f t a n d r e s u l t n e e d i n g o n e l e f t s h i f t . O n l y t h e s e t w o c a s e s a r e

    p o s s i b l e b e c a u s e d 1 . T h e f o l l o w i n g e x a m p l e c l a r i e s t h i s p o i n t .

    6

  • 7/28/2019 fpa algorithm

    13/22

    E x a m p l e 1 :

    1 . 1 0 0 0 0 0 0 0 0 0 0 1 . 0 0 0 0 0 0 0 0 0 0 0

    0 . 0 1 1 1 1 1 1 1 1 1 1 0 . 0 1 1 1 1 1 1 1 1 1 1

    1 . 1 0 0 0 0 0 0 0 0 0 0 1 . 0 0 0 0 0 0 0 0 0 0 0

    1 . 1 0 0 0 0 0 0 0 0 0 0 1 . 1 0 0 0 0 0 0 0 0 0 0

    1 1+ +

    1 1 . 0 0 0 0 0 0 0 0 0 0 1 1 0 . 1 0 0 0 0 0 0 0 0 0 1

    a R e s u l t n e e d s n o l e f t s h i f t b R e s u l t n e e d s o n e l e f t s h i f t

    E x a m p l e s 1 a a n d 1 b s h o w w h a t c a n h a p p e n t o t h e s i g n i c a n d s . T h e e x p o n e n t s

    d i e r b y 2 a n d t h e s i g n i c a n d o f t h e s m a l l e r o p e r a n d h a s t o b e r i g h t s h i f t e d b y 2 b i t s .

    I n b o t h e x a m p l e s , t h e o v e r o w b i t i s i g n o r e d . T h e s i g n i c a n d i n E x a m p l e 1 b n e e d s

    a o n e - b i t l e f t s h i f t t o n o r m a l i z e t h e r e s u l t w h i l e t h a t i n E x a m p l e 1 a d o e s n o t .

    a R e s u l t n e e d i n g n o l e f t s h i f t N L S T h i s c a s e i s s i m i l a r t o t h e a d d i t i o n c a s e

    w i t h n o r i g h t s h i f t . T h e r e i s a c o m p l i c a t i o n , h o w e v e r . T h e c o m p l i c a t i o n a r i s e s

    f r o m t h e c o m p l e m e n t a t i o n o f t h e s m a l l e r s i g n i c a n d b e c a u s e E

    o

    i s s u b t r a c t i o n .

    T h e e q u a t i o n f o r G , R , a n d s c a n b e w r i t t e n w i t h t h e h e l p o f T a b l e 4 . T h e

    c o l u m n s i n t h e t a b l e s h o w s t h e b

    n

    , b

    n + 1

    , a n d s b i t s a f t e r t h e a l i g n m e n t s t e p ,

    t h e 1 ' s c o m p l e m e n t s t e p , a n d t h e 2 ' s c o m p l e m e n t s t e p . T h e 1 ' s c o m p l e m e n t a n d

    t h e 2 ' s c o m p l e m e n t s t e p s a r e r e q u i r e d b e c a u s e E

    o

    i s s u b t r a c t i o n . T h e m e a n i n g

    o f p r o p a n d k i l l a r e a s f o l l o w s . R e c a l l t h e d e n i t i o n o f t h e s b i t , w h i c h i s t h e

    O R i n g o f a l l t h e s h i f t e d b

    i

    b i t s ; a 0 " m e a n s t h a t a l l t h e s h i f t e d b i t s a r e z e r o .

    A f t e r 1 ' s c o m p l e m e n t a t i o n , s m e a n s r s t c o m p l e m e n t i n g t h e b

    i

    b i t s a n d t h e n

    O R i n g t h e m . T h e c a s e o f s = 0 a f t e r 1 ' s c o m p l e m e n t a t i o n a l l o w s a c a r r y - i n t o

    b e p r o p a g a t e d a n d i s d e n o t e d p r o p . S i m i l a r l y , a n s = 1 m e a n s t h a t a t l e a s t o n e

    o f t h e b i t m u s t b e 1 . A f t e r 1 ' s c o m p l e m e n t a t i o n , t h i s m e a n s t h a t a t l e a s t o n e o f

    t h e b i t s m u s t b e 0 . T h i s b i t p a t t e r n d o e s n o t a l l o w a 1 " t o b e p r o p a g a t e d a n d

    i s d e n o t e d k i l l i n t h e t a b l e . T h e a f t e r 2 ' s c o m p l e m e n t " c o l u m n i s o b t a i n e d b y

    a d d i n g t h e c o m p l e m e n t i n g 1 " t o t h e a f t e r 1 ' s c o m p l e m e n t " c o l u m n , c r e a t i n g

    a n e x t r a c o l u m n C

    c

    i n t h e p r o c e s s . D u r i n g t h e 2 ' s c o m p l e m e n t p r o c e s s , a d d i n g

    1 " t o a s t i c k y b i t t u r n s i t f r o m a p r o p c o n d i t i o n i n t o a 0 " a n d a k i l l c o n d i t i o n

    i n t o a 1 " .

    F r o m T a b l e 4 , w e k n o w t h a t C

    c

    i s o n l y t r u e w h e n b

    n

    , b

    n + 1

    , a n d s a r e a l l z e r o .

    H e n c e ,

    L = C

    c

    a

    n , 1

    b

    n , 1

    = b

    n

    b

    n + 1

    s a

    n , 1

    b

    n , 1

    T h e e q u a t i o n s f o r S a n d G c a n b e w r i t t e n b a s e d o n t h e s a m e t a b l e . F r o m t h e

    t a b l e ,

    S = R _ s = b

    n + 1

    _ s

    7

  • 7/28/2019 fpa algorithm

    14/22

    T a b l e 4 : T r u t h T a b l e f o r D e t e r m i n i n g G u a r d , R o u n d , a n d S t i c k y B i t s i n C a s e 2 a .

    A f t e r S h i f t i n g A f t e r 1 ' s C o m p l e m e n t A f t e r 2 ' s C o m p l e m e n t

    b

    n

    b

    n + 1

    s b

    n

    b

    n + 1

    s C

    c

    G R s

    0 0 0 1 1 p r o p 1 0 0 0

    0 0 1 1 1 k i l l 0 1 1 1

    0 1 0 1 0 p r o p 0 1 1 0

    0 1 1 1 0 k i l l 0 1 0 1

    1 0 0 0 1 p r o p 0 1 0 0

    1 0 1 0 1 k i l l 0 0 1 1

    1 1 0 0 0 p r o p 0 0 1 0

    1 1 1 0 0 k i l l 0 0 0 1

    G = b

    n

    b

    n + 1

    s

    F r o m E q . 1 ,

    C

    r

    = S _ L

    = b

    n + 1

    _ s _ b

    n

    b

    n + 1

    s a

    n , 1

    b

    n , 1

    a n d

    C

    i n

    = G C

    r

    _ C

    c

    = b

    n

    b

    n + 1

    s b

    n + 1

    _ s _ b

    n

    b

    n + 1

    s a

    n , 1

    b

    n , 1

    _ b

    n

    b

    n + 1

    s

    = b

    n

    b

    n + 1

    _ s _ b

    n

    b

    n + 1

    s a

    n , 1

    b

    n , 1

    _ b

    n

    b

    n + 1

    s

    S i m p l i f y i n g , w e h a v e

    C

    i n

    = b

    n

    _ b

    n

    b

    n + 1

    s a

    n , 1

    b

    n , 1

    2

    T h i s c a s e o c c u r s w h e n N L S = E

    o

    h

    b

    n

    _ b

    n + 1

    _ s g

    1

    0

    _ b

    n

    _ b

    n + 1

    _ s g

    0

    0

    i

    . T h i s i s

    b e c a u s e w h e n t h e c o m p l e m e n t i n g 1 " d o e s n o t r e a c h t h e a d d e r i . e . , i f b

    n

    _ b

    n + 1

    _ s

    i s t r u e , t h e n g

    0

    0

    t h e M S B o f t h e r e s u l t o f t h e a d d e r w i t h c a r r y - i n = 0 s h o u l d

    b e e x a m i n e d ; o t h e r w i s e , g

    1

    0

    t h e a d d e r w i t h c a r r y - i n = 1 s h o u l d b e e x a m i n e d .

    T h e r e i s a p o t e n t i a l c o n f u s i o n i n t h e l o g i c e q u a t i o n s i n v o l v i n g t h e b

    n , 1

    t e r m

    b e c a u s e o f t h e c o m p l e m e n t a t i o n . I f t h e a

    n , 1

    b

    n , 1

    t e r m i s o b t a i n e d f r o m t h e

    a d d e r c i r c u i t r y , t h e n t h e r e i s n o n e e d t o i n v e r t b

    n , 1

    b e c a u s e t h e a d d e r c o n t r o l

    l o g i c h a s d o n e s o f o r u s . I f , o n t h e o t h e r h a n d , t h e a

    n , 1

    b

    n , 1

    t e r m i s t o

    b e i m p l e m e n t e d l o c a l l y , t h e n a l l b

    n , 1

    a n d b

    n , 2

    t e r m s i n t h e l o g i c e q u a t i o n s

    n e e d t o b e i n v e r t e d . T h r o u g h o u t t h i s p a p e r , w e a s s u m e t h a t t h e b

    n , 1

    a n d b

    n , 2

    t e r m s a r e o b t a i n e d f r o m t h e a d d e r c i r c u i t r y . T o m a k e i t e x p l i c i t , w e d e n o t e

    S

    g 1

    = a

    n , 1

    b

    n , 1

    a n d S

    g 2

    = a

    n , 2

    b

    n , 2

    . T h e s u b s c r i p t g i n d i c a t e s t h a t t h e

    8

  • 7/28/2019 fpa algorithm

    15/22

    s i g n a l i s o b t a i n e d f r o m t h e g a d d e r a n d s u b s c r i p t l f r o m t h e l a d d e r . H e n c e ,

    E q . 2 b e c o m e s

    C

    i n

    = b

    n

    _ b

    n

    b

    n + 1

    s S

    g 1

    b R e s u l t n e e d i n g o n e b i t l e f t s h i f t O L S T h i s c a s e o c c u r s w h e n

    O L S = E

    o

    h

    b

    n

    _ b

    n + 1

    _ s g

    1

    0

    _ b

    n

    _ b

    n + 1

    _ s g

    0

    0

    i

    T a b l e 5 : T r u t h T a b l e f o r D e t e r m i n i n g G u a r d , R o u n d , a n d S t i c k y B i t s i n C a s e 2 b .

    A f t e r S h i f t i n g A f t e r 2 ' s C o m p l e m e n t C

    r

    L C

    r

    _ C

    c

    L C

    r

    b

    n

    b

    n + 1

    s C

    c

    G L R G s S C

    i n

    q

    0 0 0 1 0 0 0 0 1 0

    0 0 1 0 1 1 1 1 1 0

    0 1 0 0 1 1 0 1 1 0

    0 1 1 0 1 0 1 0 0 1

    1 0 0 0 1 0 0 0 0 1

    1 0 1 0 0 1 1 1 0 1

    1 1 0 0 0 1 0 0 0 0

    1 1 1 0 0 0 1 0 0 0

    T h e e q u a t i o n i n t h i s c a s e c a n b e d e r i v e d a s i n t h e p r e v i o u s c a s e , b u t i s c o n c e p t u -

    a l l y m o r e c o m p l i c a t e d b e c a u s e o f t h e o n e - b i t l e f t s h i f t . W e d e v e l o p t h e e q u a t i o n

    f o r C

    i n

    u s i n g T a b l e 5 . T h e A f t e r 2 ' s C o m p l e m e n t " c o l u m n i s o b t a i n e d i n t h e

    s a m e m a n n e r a s t h a t i n T a b l e 4 . A f t e r a o n e - b i t l e f t s h i f t , t h e G b i t b e c o m e s t h e

    L b i t , t h e R b i t b e c o m e s t h e G b i t , a n d t h e s b i t b e c o m e s t h e n a l S b i t .

    T o p e r f o r m r o u n d i n g , C

    r

    i s o b t a i n e d b a s e d o n t h e v a l u e s o f t h e G a n d t h e S

    b i t s t h e o r i g i n a l R a n d s b i t s . R e c a l l i n g t h e d e n i t i o n o f C

    i n

    , w h i c h i s e q u a l

    t o G C

    r

    _ C

    c

    , a f t e r t h e o n e - b i t n o r m a l i z a t i o n s h i f t , i t b e c o m e s L C

    r

    _ C

    c

    C

    i n

    = L C

    r

    _ C

    c

    = b

    n

    b

    n + 1

    _ s

    T h e q b i t i s t h e b i t t h a t n e e d s t o b e s h i f t e d i n , i n c a s e o f a l e f t s h i f t b e c a u s e w e

    h a v e a n a d d e r o f o n l y 5 3 - b i t . I t s l o g i c e q u a t i o n i s s i m p l y t h e m o d 2 s u m o f t h e

    C

    r

    b i t a n d t h e L b i t t h e o r i g i n a l G b i t .

    q = L C

    r

    = b

    n

    b

    n + 1

    s _ b

    n

    b

    n + 1

    3 C a s e 3 : E

    o

    i s s u b t r a c t i o n a n d d 1 : W e a g a i n h a v e 2 c a s e s : r e s u l t n e e d i n g n o

    l e f t s h i f t a n d r e s u l t n e e d i n g m a n y l e f t s h i f t s . T h e f o l l o w i n g e x a m p l e i l l u s t r a t e s t h e s e

    t w o c a s e s .

    9

  • 7/28/2019 fpa algorithm

    16/22

    E x a m p l e 2 :

    1 . 1 1 1 1 1 1 1 1 1 1 0 1 . 0 0 0 0 0 0 0 0 0 0 0

    0 . 1 1 1 1 1 1 0 0 0 0 0 0 . 1 1 1 1 1 1 1 1 1 1 1

    1 . 1 1 1 1 1 1 1 1 1 1 0 1 . 0 0 0 0 0 0 0 0 0 0 0

    1 . 0 0 0 0 0 0 1 1 1 1 1 1 . 0 0 0 0 0 0 0 0 0 0 0

    1 1+ +

    1 1 . 0 0 0 0 0 0 1 1 1 1 0 1 0 . 0 0 0 0 0 0 0 0 0 0 1

    a R e s u l t n e e d s n o l e f t s h i f t b R e s u l t n e e d s m a n y l e f t s h i f t s

    I n b o t h e x a m p l e s , t h e e x p o n e n t s d i e r b y 1 a n d a o n e - b i t r i g h t s h i f t i s n e e d e d t o a l i g n

    t h e s i g n i c a n d s . T h e o v e r o w 1 " i n b o t h c a s e s i s s i m p l y d i s c a r d e d . I n E x a m p l e 2 a ,

    n o n o r m a l i z a t i o n i s n e e d e d w h i l e a 1 1 - b i t l e f t s h i f t i s r e q u i r e d f o r n o r m a l i z a t i o n i n

    E x a m p l e 2 b , w h i c h s h o w s t h a t i t i s p o s s i b l e f o r a m a n y - b i t l e f t s h i f t t o o c c u r e v e n

    w h e n t h e r e i s a o n e - b i t r i g h t s h i f t d u r i n g s i g n i c a n d a l i g n m e n t .

    a R e s u l t n e e d i n g n o l e f t s h i f t T h i s c a s e i s b a s i c a l l y t h e s a m e a s t h e s e c o n d c a s e

    C a s e 2 a b u t c a n b e s i m p l i e d b e c a u s e b o t h b

    n + 1

    a n d s e q u a l z e r o .

    L = b

    n

    S

    l 1

    S = 0

    G = b

    n

    l

    0

    0

    C

    r

    = S _ L

    = b

    n

    S

    l 1

    a n d

    C

    i n

    = G C

    r

    _ C

    c

    = l

    0

    0

    b

    n

    S

    l 1

    _ b

    n

    b R e s u l t n e e d i n g m a n y b i t s o f l e f t s h i f t M L S M L S m a y o c c u r i n t w o c a s e s ,

    a s i l l u s t r a t e d i n E x a m p l e 2 . C a s e 1 i s w h e n t h e e x p o n e n t s a r e e q u a l , w h i c h c a n

    b e p r e d i c t e d b y e x a m i n i n g t h e L S B s o f t h e e x p o n e n t s E

    a h 0 i

    a n d E

    b h 0 i

    . C a s e

    2 i s w h e n t h e e x p o n e n t s d i e r b y 1 a n d t h e s i g n i c a n d o f t h e s m a l l e r o p e r a n d

    n e e d s t o b e r i g h t s h i f t e d b y o n e b i t . T h e r i g h t s h i f t e d b i t i s c a l l e d t h e b

    n

    b i t . B u t

    f o r C a s e 2 , t h e C

    c

    b i t a l w a y s r e a c h e s t h e a d d e r i n d e p e n d e n t o f t h e b

    n

    b i t . T h i s

    i s b e c a u s e w h e n b

    n

    = 0 , C

    c

    w i l l r e a c h t h e a d d e r a n d w h e n b

    n

    = 1 , C

    c

    r e a c h e s t h e

    b

    n

    b i t , c a u s i n g t h e c a r r y i n t o a d d e r t o b e t r u e . H e n c e , a l l w e n e e d i s t o d e t e c t

    t h e r s t c a s e .

    1 0

  • 7/28/2019 fpa algorithm

    17/22

    C

    i n

    = E

    a h 0 i

    E

    b h 0 i

    W e s t i l l n e e d t o d e r i v e t h e e q u a t i o n f o r t h e b i t t o b e s h i f t e d i n . T h e e q u a t i o n i s

    s i m p l y

    q = b

    n

    F o r a n n - b i t a d d e r a n d a d - b i t l e f t s h i f t , t h i s b i t w i l l o c c u p y t h e b i t p o s i t i o n n , d

    r e c a l l t h a t o u r n u m b e r i n g c o n v e n t i o n s t a r t s f r o m 0 , s o t h a t t h e L S B i s a t b i t

    n , 1

    T h e e q u a t i o n f o r l

    i n

    c a n b e o b t a i n e d b y O R i n g C a s e s 3 a a n d 3 b ,

    l

    i n

    = l

    0

    0

    b

    n

    S

    l 1

    _ b

    n

    _ E

    a h 0 i

    E

    b h 0 i

    3 . 2 . 3 M e r g i n g C a s e 1 a n d C a s e 2

    F r o m t h e p r e c e d i n g s e c t i o n , t h e e q u a t i o n f o r g

    i n

    i s

    g

    i n

    = O R S S

    g 1

    b

    n

    _ b

    n + 1

    _ s _ S

    g 2

    _

    N X S

    h

    E

    o

    b

    n

    b

    n + 1

    _ s _ S

    g 1

    _ E

    o

    b

    n

    _ b

    n

    b

    n + 1

    s S

    g 1

    i

    _

    O L S b

    n

    b

    n + 1

    _ s

    w h e r e

    O R S = E

    o

    g

    0

    o u t

    N X S = N R S _ N L S = E

    o

    g

    0

    o u t

    _ E

    o

    h

    b

    n

    _ b

    n + 1

    _ s g

    1

    0

    _ b

    n

    _ b

    n + 1

    _ s g

    0

    0

    i

    a n d

    O L S = E

    o

    h

    b

    n

    _ b

    n + 1

    _ s g

    1

    0

    _ b

    n

    _ b

    n + 1

    _ s g

    0

    0

    i

    S u b s t i t u t i n g a n d s i m p l i f y i n g , w e g e t

    g

    i n

    = E

    o

    h

    g

    0

    o u t

    S

    g 1

    b

    n

    _ b

    n + 1

    _ s _ S

    g 2

    _ g

    0

    o u t

    b

    n

    b

    n + 1

    _ s _ S

    g 1

    i

    _

    E

    o

    n

    b

    n

    b

    n + 1

    s _ g

    0

    0

    h

    b

    n

    b

    n + 1

    _ s _ b

    n

    b

    n + 1

    s S

    g 1

    i

    _ g

    0

    0

    b

    n

    b

    n + 1

    s

    o

    T h e n a l C

    i n

    , w h i c h s e l e c t s b e t w e e n t h e r e s u l t s o f t h e l a n d t h e g p a t h s , i s t r u e w h e n

    E

    o

    i s s u b t r a c t i o n a n d t h e t r u e a b s o l u t e d i e r e n c e o f t h e e x p o n e n t d i s l e s s t h a n o r

    e q u a l t o 1 . C

    i n

    i s t r u e w h e n s e l e c t i n g t h e l p a t h .

    1 1

  • 7/28/2019 fpa algorithm

    18/22

    4 S u m m a r y

    A n e w o a t i n g - p o i n t a d d i t i o n a l g o r i t h m h a s b e e n p r e s e n t e d . T h i s a l g o r i t h m h a s

    o n l y o n e a d d i t i o n s t e p i n v o l v i n g t h e s i g n i c a n d i n t h e c r i t i c a l p a t h w h i l e p e r f o r m i n g

    f u l l I E E E r o u n d i n g . I n o a t i n g - p o i n t a d d i t i o n , 2 ' s c o m p l e m e n t a t i o n o f o n e o f t h e

    s i g n i c a n d s i s n e e d e d i n t h e c a s e o f a n e e c t i v e s u b t r a c t i o n . T h e k e y i d e a s p r e s e n t e d

    i n t h i s p a p e r a r e : r s t , c o m p l e m e n t a t i o n a n d r o u n d i n g a r e m u t u a l l y e x c l u s i v e a n d

    c a n b e c o m b i n e d . S e c o n d , f o r t h e r o u n d t o n e a r e s t m o d e , p r e - c o m p u t i n g A + B a n d

    A + B + 1 i s e n o u g h t o a c c o u n t f o r a l l t h e n o r m a l i z a t i o n p o s s i b i l i t i e s s e e S e c t i o n 3 .

    r o u n d t o i n n i t y m o d e s a r e m o r e d i c u l t t o s p e e d u p t h a n t h e r o u n d t o n e a r e s t m o d e ;

    t h e y r e q u i r e s a n e x t r a r o w o f h a l f - a d d e r t o p e r f o r m r o u n d i n g c o r r e c t l y s e e A p p e n d i x

    B

    5 A c k n o w l e d g e m e n t

    T h e a u t h o r s w o u l d l i k e t o t h a n k N a o f u m i T a k a g i f o r h i s v a l u a b l e c o m m e n t s o n a n

    e a r l y v e r s i o n o f t h i s p a p e r .

    R e f e r e n c e s

    1 S . W a s e r a n d M . J . F l y n n , I n t r o d u c t i o n t o A r i t h m e t i c f o r D i g i t a l S y s t e m s D e s i g n -

    e r s . N e w - Y o r k : H o l t s , R i n e h a r t a n d W i n s t o n , 1 9 8 2 .

    2 T h e I n s t i t u t e o f E l e c t r i c a l a n d E l e c t r o n i c s E n g i n e e r s , I n c . , 3 4 5 E a s t 4 7 t h S t r e e t ,

    N e w Y o r k , N Y 1 0 0 1 7 , U S A , A N S I I E E E S t d 7 5 4 - 1 9 8 5 : I E E E S t a n d a r d f o r B i n a r y

    F l o a t i n g - P o i n t A r i t h m e t i c , 1 9 8 5 .

    3 M . P . F a r m w a l d , O n t h e D e s i g n o f H i g h P e r f r o m a n c e D i g i t a l A r i t h m e t i c U n i t s

    P h D t h e s i s , S t a n f o r d U n i v e r s i t y , A u g . 1 9 8 1 .

    4 B . J . B e n s c h n e i d e r , W . J . B o w h i l l , E . M . C o o p e r , M . N . G a v r i e l o v , P . E .

    G r o n o w s k i , V . K . M a h e s h w a r i , V . P e n g , J . D . P i c k h o l t z , a n d S . S a m u d r a l a ,

    A P i p e l i n e d 5 0 - M h z C M O S 6 4 - b i t F l o a t i n g - P o i n t A r i t h m e t i c P r o c e s s o r , " I E E E

    T r a n s a c t i o n s o n C o m p u t e r s , v o l . 2 4 , n o . 5 , p p . 1 3 1 7 1 3 2 3 , O c t . 1 9 8 9 .

    5 P . Y . L u , A . J a i n , J . K u n g , a n d P . H . A n g , A 3 2 - M F L O P 3 2 b C M O S F l o a t i n g -

    P o i n t P r o c e s s o r , " i n I n P r o c . o f t h e I E E E I n t e r n a t i o n a l S o l i d - S t a t e C i r c u i t C o n -

    f e r e n c e , p p . 2 8 2 9 , 1 9 8 8 .

    6 M . B i r m a n , A . S a m u e l s , G . C h u , T . C h u k , L . H u , J . M c L e o d , a n d J . B a r n s ,

    D e v e l o p i n g t h e W T L 3 1 7 0 3 1 7 1 S p a r c F l o a t i n g - P o i n t C o p r o c e s s o r , " I E E E M i c r o ,

    p p . 5 5 6 4 , F e b . 1 9 9 0 .

    1 2

  • 7/28/2019 fpa algorithm

    19/22

    A N o t a t i o n

    I n a l p h a b e t i c a l o r d e r , t h i s i s a l i s t o f t h e s y m b o l s u s e d i n t h i s p a p e r :

    _ L o g i c a l O R . L o w e s t p r e c e d e n c e .

    E x c l u s i v e O R s u m m o d 2 . P r e c e d e n c e h i g h e r t h a n _ , b u t l o w e r t h a n A N D

    J u x t a p o s i t i o n A N D . H i g h e s t p r e c e d e n c e .

    A = a

    0

    a

    1

    a

    2

    a

    2 n , 1

    S i g n i c a n d o f t h e l a r g e r i n m a g n i t u d e o p e r a n d . a

    0

    i s t h e

    h i d d e n o n e b i t . a

    n

    = a

    n + 1

    = a

    n + 2

    = = a

    2 n , 1

    = 0 b e c a u s e n o r i g h t s h i f t o f A

    i s n e e d e d .

    A l i g n T h e a l i g n m e n t s t e p i n t h e a d d i t i o n o p e r a t i o n .

    B = b

    0

    b

    1

    b

    2

    b

    2 n , 1

    S i g n i c a n d o f t h e s m a l l e r i n m a g n i t u d e o p e r a n d . b

    0

    i s t h e h i d -

    d e n o n e b i t . b

    n

    ; b

    n + 1

    ; ; b

    2 n , 1

    m a y n o t b e e q u a l t o z e r o a f t e r a l i g n m e n t . W h e n

    E

    o

    i s s u b t r a c t i o n s o t h a t c o m p l e m e n t a t i o n o f t h e s m a l l e r o p e r a n d i s n e e d e d , b

    i

    f o r i n + 2 i s b e f o r e c o m p l e m e n t a t i o n .

    C

    c

    A b i t n e e d s t o b e a d d e d t o t h e L S B t o p e r f o r m c o m p l e m e n t a t i o n .

    C

    i n

    T h i s s i g n a l s e l e c t s b e t w e e n t h e r e s u l t s f r o m t h e g p a t h a n d t h e l p a t h .

    C

    r

    A b i t t h a t n e e d s t o b e a d d e d t o t h e G b i t t o p e r f o r m I E E E r o u n d i n g .

    d M a g n i t u d e o f t h e e x p o n e n t d i e r e n c e .

    E

    o

    E e c t i v e o p e r a t i o n . E

    o

    = 0 f o r a d d i t i o n a n d E

    o

    = 1 f o r s u b t r a c t i o n .

    E

    a

    E x p o n e n t o f t h e l a r g e r o p e r a n d .

    E

    a h 0 i

    L S B o f E

    a

    E

    b

    E x p o n e n t o f t h e s m a l l e r o p e r a n d .

    E

    b h 0 i

    L S B o f E

    b

    E

    f

    E x p o n e n t o f t h e r e s u l t o p e r a n d .

    E

    n

    A m o u n t o f s h i f t s n e e d e d d u r i n g t h e a l i g n m e n t s t e p . E

    n

    i s p o s i t i v e i f t h e s i g n i c a n d

    n e e d s a r i g h t s h i f t a n d n e g a t i v e o t h e r w i s e .

    E S T h e s i g n i c a n d a d d i t i o n s t e p i n t h e a d d i t i o n o p e r a t i o n .

    G G u a r d b i t o f t h e r e s u l t t o b e r o u n d e d .

    g

    0

    g

    1

    g

    2

    g

    2 n , 1

    T h e n a l s u m r e s u l t o f t h e a d d e r i n t h e d 1 p a t h o r w h e n E

    o

    i s

    a d d i t i o n . T h i s p a t h i s d e n o t e d t h e g p a t h .

    g

    1

    0

    g

    1

    1

    g

    1

    2

    g

    1

    2 n , 1

    T h e i n t e r m e d i a t e s u m r e s u l t o f t h e a d d e r w i t h c a r r y - i n = 1 i n t h e

    d 1 p a t h a n d w h e n E

    o

    i s a d d i t i o n . T h i s p a t h i s d e n o t e d t h e l p a t h .

    g

    0

    0

    g

    0

    1

    g

    0

    2

    g

    0

    2 n , 1

    T h e i n t e r m e d i a t e s u m r e s u l t o f t h e a d d e r w i t h c a r r y - i n = 0 i n t h e g

    p a t h .

    g

    i n

    T h i s s i g n a l s e l e c t s t h e r e s u l t b e t w e e n g

    0

    0

    g

    0

    1

    g

    0

    2

    g

    0

    2 n , 1

    a n d g

    1

    0

    g

    1

    1

    g

    1

    2

    g

    1

    2 n , 1

    g

    0

    o u t

    C a r r y - o u t f r o m t h e g a d d e r w i t h c a r r y - i n = 0 .

    1 3

  • 7/28/2019 fpa algorithm

    20/22

    L L e a s t s i g n i c a n d b i t o f t h e r e s u l t t o b e r o u n d e d .

    l

    0

    l

    1

    l

    2

    l

    2 n , 1

    T h e n a l s u m r e s u l t o f t h e a d d e r i n t h e d 1 p a t h .

    l

    0

    0

    l

    0

    1

    l

    0

    2

    l

    0

    2 n , 1

    T h e i n t e r m e d i a t e s u m r e s u l t o f t h e a d d e r w i t h c a r r y - i n = 0 i n t h e d 1

    p a t h .

    l

    1

    0

    l

    1

    1

    l

    1

    2

    l

    1

    2 n , 1

    T h e i n t e r m e d i a t e s u m r e s u l t o f t h e a d d e r w i t h c a r r y - i n = 1 i n t h e d 1

    p a t h .

    l

    i n

    T h i s s i g n a l s e l e c t s b e t w e e n l

    1

    0

    l

    1

    1

    l

    1

    2

    l

    1

    2 n , 1

    a n d l

    0

    0

    l

    0

    1

    l

    0

    2

    l

    0

    2 n , 1

    L O D T h e l e a d i n g o n e d e t e c t i o n s t e p i n t h e a d d i t i o n o p e r a t i o n .

    L S B L e a s t s i g n i c a n t b i t .

    M L S I n d i c a t e t h a t a m a n y - b i t l e f t s h i f t i s n e e d e d i n t h e c a s e o f a s u b t r a c t i o n .

    M S B M o s t s i g n i c a n t b i t .

    N N e x t t o L S B

    N L S I n d i c a t e t h a t n o s h i f t o f t h e r e s u l t i s n e e d e d i n t h e c a s e o f a s u b t r a c t i o n .

    N R S I n d i c a t e t h a t n o r i g h t s h i f t o f t h e r e s u l t i s n e e d e d i n t h e c a s e o f a n a d d i t i o n .

    N X S = N R S _ N L S

    n L e n g t h o f t h e s i g n i c a n d , e q u a l t o 5 3 .

    N o r m T h e s i g n i c a n d n o r m a l i z a t i o n s t e p i n t h e a d d i t i o n o p e r a t i o n .

    O L S I n d i c a t e s t h a t a o n e - b i t l e f t s h i f t i s n e e d e d i n c a s e o f a s u b t r a c t i o n .

    O R S I n d i c a t e s t h a t a o n e - b i t r i g h t s h i f t i s n e e d e d i n t h e c a s e o f a d d i t i o n .

    P r e d T h e p r e d i c t i o n s t e p i n t h e a d d i t i o n o p e r a t i o n . T h i s s t e p i s u s e d t o a l i g n t h e

    s i g n i c a n d s i n c a s e o f d 1

    q T h e b i t t o b e s h i f t e d i n w h e n a l e f t s h i f t i s n e e d e d d u r i n g n o r m a l i z a t i o n .

    R o u n d T h e r o u n d i n g s t e p i n t h e a d d i t i o n o p e r a t i o n .

    R R o u n d b i t o r r o u n d b i t p o s i t i o n .

    s = b

    n + 2

    _ b

    n + 3

    _ _ b

    2 n , 1

    S F i n a l s t i c k y b i t o f a s i g n i c a n d t o b e r o u n d e d .

    S

    a

    S i g n i c a n d o f t h e l a r g e r i n m a g n i t u d e o p e r a n d .

    S A S i g n i c a n d a d d i t i o n .

    S

    b

    S i g n i c a n d o f t h e s m a l l e r i n m a g n i t u d e o p e r a n d .

    S

    E

    S i g n o f t h e r e s u l t .

    S

    f

    S i g n i c a n d o f t h e r e s u l t o p e r a n d .

    S

    g 1

    = a

    n , 1

    b

    n , 1

    f r o m t h e g a d d e r .

    S

    g 2

    = a

    n , 2

    b

    n , 2

    f r o m t h e g a d d e r .

    S

    l 1

    = a

    n , 1

    b

    n , 1

    f r o m t h e l a d d e r .

    S

    l 2

    = a

    n , 2

    b

    n , 2

    f r o m t h e l a d d e r .

    1 4

  • 7/28/2019 fpa algorithm

    21/22

    B C

    i n

    f o r o t h e r r o u n d i n g M o d e s

    F o r a l l o t h e r r o u n d i n g m o d e s , t h e e q u a t i o n s f o r C

    i n

    , O R S , N X S , a n d O L S a r e t h e

    s a m e a s t h o s e f o r t h e R T N m o d e . O n l y t h e e q u a t i o n s f o r g

    i n

    , l

    i n

    , a n d q d i e r . I n t h i s

    a p p e n d i x , w e d e v e l o p t h e e q u a t i o n s f o r t h e t h r e e o t h e r I E E E r o u n d i n g m o d e s .

    B . 1 R o u n d t o 0

    g

    i n

    = E

    o

    b

    n

    _ b

    n + 1

    _ s

    l

    i n

    = E

    o

    b

    n

    I n c a s e o f a r i g h t s h i f t d u r i n g n o r m a l i z a t i o n , t h e q b i t i s

    q = b

    n

    s _ b

    n + 1

    _ b

    n

    b

    n + 1

    s

    o r m o r e c o n c i s e l y ,

    q = b

    n

    s _ b

    n + 1

    B . 2 R o u n d t o + 1

    R o u n d t o i n n i t y i s m u c h t o u g h e r t o s p e e d u p t h a n R T N . T h i s i s b e c a u s e w h e n a

    r i g h t s h i f t i s r e q u i r e d , a s i n t h e c a s e o f a n e e c t i v e a d d i t i o n , o n e h a s t h e p o s s i b i l i t y

    o f a d d i n g 0 , 1 , a n d 2 .

    3

    A l e s s e c i e n t w a y t o i m p l e m e n t t h i s m o d e i s t o u s e t h r e e

    a d d e r s , s i m u l t a n e o u s l y c o m p u t i n g t h e t h r e e r e s u l t s a t t h e s a m e t i m e .

    R e f e r r i n g b a c k t o F i g . 1 , w e r e c o g n i z e t h a t

    O n e o n l y h a s a p r o b l e m w h e n t h e L S B , L i n F i g . 1 , i s z e r o b e c a u s e t h e c a s e o f

    L = 1 c a n b e t r e a t e d i n t h e s a m e w a y a s t h e R T N m o d e .

    I n t h e c a s e o f L = 0 , p r e - c o m p u t i n g A + B , A + B + 1 , a n d A + B + 2 i s

    n o t a p r o b l e m b e c a u s e t h e t h r e e c a s e s c a n b e r e d u c e d d o w n t o t w o : A + B a n d

    A + B + 2 . T h e c a s e o f A + B + 1 c a n b e a c c o u n t e d f o r b y i n c r e m e n t i n g t h e A + B

    c a s e , b e c a u s e L = 0 s o t h e r e i s n o c a r r y p r o p a g a t i o n . T o c o m p u t e A + B + 2 ,

    o n e n e e d s t o u s e a r o w o f h a l f a d d e r , a s s h o w n i n F i g . 2 . B y m o d i f y i n g t h e l o g i c

    e q u a t i o n f o r g

    i n

    s l i g h t l y , t h e R T P I a n d R T N I m o d e s c a n b e i m p l e m e n t e d i n a

    s i m i l a r m a n n e r a s t h e R T N m o d e .

    3

    R o u n d t o n e a r e s t d o e s n o t h a v e t h i s p r o b l e m b e c a u s e i t s d e n i t i o n a o r d s a s i m p l e i m p l e m e n t a t i o n , a s

    p o i n t e d o u t i n t h e m a i n t e x t , S e c t i o n 3 . 2 . 3 .

    1 5

  • 7/28/2019 fpa algorithm

    22/22

    n bit Half Adder

    n bit Adder G,R,S,V

    F i g u r e 2 : H a r d w a r e f o r R o u n d t o P o s i t i v e I n n i t y .

    U s i n g a s i m i l a r a p p r o a c h a s t h a t f o r t h e R T N m o d e a n d t h e a b o v e a r g u m e n t , w e

    a r r i v e d a t t h e f o l l o w i n g l o g i c e q u a t i o n f o r g

    i n

    :

    g

    i n

    = O R S S

    E

    a

    n , 1

    b

    n , 1

    _ b

    n

    _ b

    n + 1

    _ s _

    N X S

    n

    E

    o

    S

    E

    _ b

    n

    b

    n + 1

    s _ E

    o

    h

    a

    n , 1

    b

    n , 1

    _ S

    E

    b

    n

    _ b

    n + 1

    _ s

    i o

    _

    O L S S

    E

    b

    n

    _ S

    E

    b

    n

    b

    n + 1

    s

    w h e r e O R S , N X S , a n d O L S a r e a s d e n e d i n S e c t i o n 3 . 2 . 3 i n t h e m a i n t e x t . S

    E

    i s

    t h e s i g n o f t h e r e s u l t . S i m i l a r l y ,

    l

    i n

    = S

    E

    l

    0

    0

    b

    n

    _ b

    n

    T h e e q u a t i o n f o r t h e q b i t i s

    q = S

    E

    b

    n

    _ S

    E

    b

    n

    b

    n + 1

    _ s

    F o r t h e c a s e o f M L S , b e c a u s e b

    n + 1

    = s = 0 , t h e e q u a t i o n r e d u c e s t o

    q = b

    n

    B . 3 R o u n d t o , 1

    B e c a u s e t h i s c a s e i s s y m m e t r i c a l a b o u t t h e s i g n t o t h e c a s e o f R T P I , a l l w e n e e d t o

    d o i s t o r e v e r s e t h e s i g n o f S

    E

    i n t h e e q u a t i o n s f o r g

    i n

    a n d l

    i n

    T h e e q u a t i o n f o r t h e q b i t , f o r e x a m p l e , i s

    q = S

    E

    b

    n

    _ S

    E

    b

    n

    b

    n + 1

    _ s

    1 6