• Tidak ada hasil yang ditemukan

DIGITAL HARDWARE ARITHMETIC CS 2600 - CSE-IITM

N/A
N/A
Protected

Academic year: 2025

Membagikan "DIGITAL HARDWARE ARITHMETIC CS 2600 - CSE-IITM"

Copied!
68
0
0

Teks penuh

(1)

DIGITAL HARDWARE ARITHMETIC

CS 2600

(2)

The Two's Complement Representation

 Range of numbers in two’s complement method:

-2 2 n

-1

  X X   2 - 1 2 1 n

-1

 Slightly asymmetric one more negative number

 Slightly asymmetric - one more negative number

 2 n

-1

(represented by 10 0) does not have a

 -2 (represented by 10….0) does not have a positive equivalent

 A complement operation for this number will result in an overflow indication

 There is a unique representation for 0 un qu p n n f

(3)

0011 3 +  1011 -5

1110 2

0101 5 +  1101 -3

1 0010 2

0000 0001

1110 -2

1111

1 0010 2

0010 1111

1110

-1 0 +1

1101 0011

+1

+2 1

-2

+3 +4 -4

3

0100

1100

+4

+5 -3

-5

0101 1011

+5 -6 +6

0111 0110 1010

+7 -7 -8

0001 1 0111 7

1000 0111 0110

0001 1

1001

+ 1111 -1 1 0000 0

0111 7 +  1101 -3

1 0100 4 0100 4

(4)

• Example ‐ (two’s complement)      

01001 9

01001   9      

11001  ‐7      

 1  00010   2  

– Carry‐out discarded ‐ does not  indicate overflow

• In general, if X and Y have  opposite signs ‐ no overflow opposite signs ‐ no overflow  can occur regardless of 

h th th i t

whether there is a carry‐out or 

not

(5)

 If X and Y have the same sign and result has different sign - overflow occurs

different sign overflow occurs

 Examples - (two’s complement)

 Examples (two s complement)

10111 -9 10111 -9

1 01110 14 = -18 mod 32

 Carry-out and overflow

01001 9  01001 9

 00111 7 0 10000 -16 = 16 mod 32

 No carry-out but overflow

(6)

0101 5 +  0011 3

 No carry-out but overflow

8 d 16 +  0011 3

1000 -8 -> 8 mod 16

1011 -5  1100 4

 Carry-out and overflow 9 d 16

+  1100 -4

1 0111 7  -9 mod 16

C f f (f )

));

( )

( (

C or

S  MSB A  MSB B

Condition for overflow (for logic implementation):

));

( )

( (

C or

S  MSB A  MSB B

(7)

 s

i

= x

i

 y

i

 c

i

Full adder

T

D

= 1 (or 2);

 s

i

x

i

 y

i

 c

i

 c

i+1

= x

i

. y

i

+ c

i

. ( x

i

+ y

i

) T

D

= 2;

A 3 i/ XOR t f S d SOP f f C

T

D

1 (or 2);

Ripple-Carry Adder

Assume 3-i/p XOR gate for Si and SOP form for Ci+1

Ripple Carry Adder

c

4

1 ;

 

 C n C n

O T T

D/C

= 2N;

D/S

= 2N-1;

T 2N+2

1 1 1

1 1

1     

 

 x n y n S n x n y n S n

O T

D/O

= 2N+2

(8)

Subtraction

 Subtract operation, X-Y, is performed by adding the complement of Y g p to X

 In the two's complement system - p y X-Y = X + (Y+1) -

 This still requires only a single adder operation, since 1 is added through the forced carry input since 1 is added through the forced carry input to the binary adder

Use EX_OR to produce complement (use one I/P bit as flag):

- Show how ??

- Show how ??

- draw Ckt.

(9)

May use XOR Instead of MUX

 s

i

= x

i

 y

i

 c

i

 s

i

x

i

 y

i

 c

i

 c

i+1

= x

i

. y

i

+ c

i

. ( x

i

+ y

i

)

X

Y X KN..(KN-1) YN..(2N-1) X N..(2N-1) Y0..(N-1) X 0..(N-1)

YKN..(KN-1)

N-bit RCA

C0 CN

N-bit RCA C2N

N-bit RCA

CKN C(K-1)N

S 0..(N-1) S N..(2N-1)

S KN..(KN-1)

Cascade of K N‐bit RCAs also possible – but delay is large

(10)

Look‐Ahead Adder

i i i

i i

i

x y G x y

P   ,  ; Let

i i

i

C P G

c

C P

S

 + +

x

i

y

i

S

i

Pi

i i i

i

G P C

c

1

 

C

+

C

i G

C

i1

i

G

i

and P

i

are termed:

Carry Generate y and Carry Propagate y p g

(11)

Examples: 74283 - a 4-bit binary full adder with fast carry

+

i

+

i

y x

s

i

hs

i

Carry

1 1

i i

y x

c

i i i i

y x

p

y x g

 :

propagate : generate

Carry Look ahead

Logic

1 1

y x

i i i

i

i i

i

c p g

c

y x

p

1

: carry

: propagate

0 0

y x

c

0

Two Conditions:

1) C

i+1

=1 if g

i

=1

0

1) C

i+1

1 if g

i

1

2) C

i+1

=1 if C

i

=1 and p

i

=1

C P G

C

1

G

0

P

0

C

0

C  

0 0 1 0

1 1

2

G P G P P C

C   

(12)

74283 – contd.

i i i

i i

i i

i

i

x y x y x y p g

hs    (  )( . ) 

) (

) (

)

1

(

i i

i

i i i

i i

c g

p

c p p

g c

 i.e. when g

i

=1, p

i

=1

)

(

i i

i

g

p

)

(

0 0

0

1

p g c

c  

)) (

( )

( g c p g p g c

p

c   

) )(

(

)) (

( )

(

0 0

1 0

1 1

0 0

0 1

1 1

1 1

2

c g

g p

g p

c g

p g

p c

g p

c

) )(

)(

(

) (

0 0

1 2

0 1

2 1

2 2

2 2

2 3

p g

g g

p g

g p

g p

c g

p c

) )(

)(

(

2 1 2 1 0 2 1 0 0

2

g p g g p g g g p

p      

) )(

(

3 2 3 2 1

3

4

p g p g g p

c    

) )(

(

g

3

 g

2

 g

1

 p

0

g

3

 g

2

 g

1

 g

0

 c

0
(13)

Carry-Look-Ahead - FAST Adders

 G

i

= x

i

y

i -

generated carry ;

 P

i

= x

i

+ y y

i

- propagated carry p p g y

 c

i+1

= x

i

y

i

+ c

i

( x

i

+ y

i

) = G

i

+ c

i

P

i

 Substituting

i i

i i

i i

i i

i i

i G c P c G G P c P P

c  1  1 1 ;   1   1  1 1

 Further substitutions - i i i i i i i i i i i

P P

c P

G G

c P

c G

c  1   1  1 ;   1   1   1  1

 All carries can be calculated in parallel, using:

x

n-1

, x

n-2

,..., x

0

, y

n-1

, y

n-2

,…, y

0

, and forced carry c

0

Method called: “Carry Look Ahead or Propagation” for Fast Adder design

(14)

1 1 1

2

C P P G

P G

C P G

C

C P G

C

Compare overall delay,

t i i it

1 1 2 3 1

2 3 2

3 3

4

1 1 2 1

2 2

2 2 2

3

C P P P G

P P G

P G

C

C P P G

P G

C P G

C

w.r.t. previous circuits

+ 4

G P

C

5

C

5

4 4

B A

+

G

4

P

4

5

C

4

5

+

P

4

S

4

3 3

B A

+

G

4

P

4

C

4

C

3

P

4

2

B A

4 4

G

P C

3

+

P

2

S

3 B2

A +

4 4

G

P C

2

C

+ +

2

P

1

S

S

2

C

1 1

B A

C1 1

+ S

1

C1

(15)

Example - 4-bit Adder

- Draw Ckt Draw Ckt.

- How many gates ?

- Delay:

For C

i

’s: T

D

= 3; S

i

= 3 + 2 = 5.

F RCA T 8

For RCA: T

D/RCA

= 8;

(16)

X 0 Y0

X 1 Y1

X N-1

YN-1

S

1

S

0

S

N-1

PL CC0 FA PL

C C C

G0 P0 G1 P1

GN-1 PN-1

C

1

C

2

C

N-1

CN

Carry lookahead logic

Carry lookahead Fast Adder

(17)

Delay of Carry-Look-Ahead Adders

 

G -

delay of a single gate

 At each stage g

 Delay of 

G

for generating all Pi and Gi

 Delay of 2 y 

G

for generating all g g c

i

(two-level gate ( g implementation)

 Delay of 2 

G

for generating sum digits s

i

in parallel (two- level gate implementation)

level gate implementation)

 Total delay of 5 

G

regardless of n - number of bits in each operand p

 Large n (=32) - large number of gates with large fan-in

 Fan-in - number of gate inputs, n+1 here

 Span of look-ahead must be reduced at expense of speed

speed

(18)

Reducing Span

 n stages divided into groups separate carry look

 n stages divided into groups - separate carry-look- ahead in each group

 Groups interconnected by ripple-carry method

 Groups interconnected by ripple carry method

 Equal-sized groups - modularity - one circuit designed

 Commonly - group size 4 selected - n/4 groups

 4 is factor of most word sizes

 Technology-dependent constraints (number of input/output pins)

 IC ddi t 4 di it ith l k h d i t

 ICs adding two 4 digits sequences with carry-look-ahead exist

»  G needed to generate all Pi and Gi

» 2 2   G G needed to propagate a carry through a group once the needed to propagate a carry through a group once the Pi,Gi, c

0

are available

» (n/4)2  G needed to propagate carry through all groups

» 2  G needed to generate sum outputs

 Total - ( 2(n/4)+3 ) 

G

= ( (n/2)+3 ) 

G -

a reduction of almost 75% compared to 2n 

G

in a ripple carry adder

75% compared to 2n 

G

in a ripple-carry adder

(19)

X 0..(N-1) Y0..(N-1)

X N..(2N-1) YN..(2N-1)

X KN..(KN-1) YKN..(KN-1)

N-bit LAC-FA

C0 CN

N-bit LAC-FA C2N

N-bit LAC-FA

CKN C(K-1)N

LAC-FA

S LAC-FA

S C

S KN (KN-1)

Cascade of K N‐bit LAC‐FAs also possible

S 0..(N-1) S N..(2N-1)

KN..(KN-1)

Comparison of the Delay of different systems

Adder C4 C8 C12 C16 S15 C28 C32 S31

RCA 8 16 24 32 31 56 64 63

LAC-FA 3 5 7 9 10 15 17 18

??

(20)

Speed-up for higher level carry bits

Let:

0 1

2 3 1

2 3 2

3 3

* 0

1 2 3

* P P P P ; G G P G P P G P P P G ;

P o  o    

Let:

0

*

*

C 4

, G P C

Then  o  o

4 5

6 7 5

6 7 6

7 7

* 1 4

5 6 7

*

1 P P P P ; G G P G P P G P P P G ;

P     

If:

0

* 0

* 1

* 0

* 1

* 1 4

* 1

* 1

C 8

, G P C G P G P P C

Then     

12

* 3

* 3 16

8

* 2

* 2

12 ; C

C

, G P C G P C

Similarly    

(21)

16-bit 2-level Carry-look-ahead Adder

 n=16 4 groups

 n=16 - 4 groups

 Outputs:

 Inputs to a carry look ahead generator with G o * , G 1 * , G 2 * , G 3 * , P 0 * , P 1 * , P 2 * , P 3 * ;

 Inputs to a carry-look-ahead generator with

outputs c

4

, c

8

, c

12
(22)

; C

4

 G

o*

 P

o*

C

0

4

* 0

* 1

* 0

* 1

* 1 4

* 1

* 1

C 8

 G  P C  G  P G  P P C

*

*

*

*

*

*

*

*

*

*

*

8

* 2

* 2

C 12

,

C P

P P

G P

P G

P G

C P

G

Similarly  

*

*

0 0

1 2

0 1

2 1

2 2

C G P C

C P

P P

G P

P G

P G

0

* 0

* 1

* 2

* 3

*

* 1

* 2

* 3

* 1

* 2

* 3

* 2

* 3

* 3

12 3

3

C 16

C P

P P

P G

P P

P G

P P

G P

G

C P

G

0 0

1 2

3 1

2 3

1 2

3 2

3

3 P G P P G P P P G P P P P C

G    o 

Expression/Output

(4-stage block) Implementation

Delay Total Delay

15

:

12

 C

(4-stage block) Delay

C

1 1

*

* i

i

P

G ;

5 2 7 ;

15

:

12

 C C

2; 1 3; 2

C

i = 4, 8, 12, 16 2

5

*

*

; G

i

P

i

15

:

Si 2 + 1 = 3 8

S

8 1

7

15

For LAC-L1, delays are: C16 -> 9, S15 -> 10

(23)

X 0..(N-1) Y0..(N-1)

X N..(2N-1) YN..(2N-1)

X KN..(KN-1) YKN..(KN-1)

N-bit LAC-FA

C0 CN

N-bit LAC-FA C2N

N-bit LAC-FA

CKN C(K-1)N

S 0..(N-1) S N..(2N-1)

S KN..(KN-1)

Cascade of K N(=16)‐bit HLG&P‐CAs also possible

K = 2;; K = 4;

Bit Delay

(K = 1) C16 5

;

Bit Delay

(K = 2) C32 7

(K   1) C16 5

(K = 2) C28, C32 5 + 2 = 

7

(K = 2) C28 ‐‐> C31 7 + 2 = 9

(K   2) C32 7

(K = 3) C44, C48 7 + 2 = 9 (K = 4) C60, C64 9 + 2 = 

11

( ) 28 31

(K = 2) S31 9 + 1 = 

10

(K = 4) C60 ‐‐> C63 11 + 2 =13

(K = 4) S63 13+ 1 = 

14

(24)

Comparison of the Delay of different systems

Adder C4 C8 C16 S15 C32 S31 C64 S63

RCA 8 16 32 31 64 63 128 127

LAC-FA 3 5 9 10 17 18 33 34

HLG&P 5 8 7 10 11 14

HLG&P‐

CA

- - 5 8 7 10 11 14

??

*

*

*

*

*

*

*

*

*

*

*

*

*

*

12

* 3

* 3

C 16  G  P C L2 – HLG&P CA

*

*

*

*

0

* 0

* 1

* 2

* 3

*

* 1

* 2

* 3

* 1

* 2

* 3

* 2

* 3

* 3

C P

G

C P

P P

P G

P P

P G

P P

G P

G    o 

0

*

* 0

*

* ;

where

C P

G o 

*

* 1

* 2

* 3

* 1

* 2

* 3

* 2

* 3

* 3

*

* ;

,

G P

P P

G P

P G

P G

G

where

o

o    

* 0

* 1

* 2

* 3

*

* 0

1 2

3 1

2 3

2 3

3 ;

P P

P P

P

o o

(25)

*

*

*

*

*

*

*

*

*

*

*

*

*

*

12

* 3

* 3

C

16

 G  P C

0

*

* 0

*

*

0

* 0

* 1

* 2

* 3

*

* 1

* 2

* 3

* 1

* 2

* 3

* 2

* 3

* 3

; C P

G

C P

P P

P G

P P

P G

P P

G P

G

o

o

Delay for C

16

: 5 Delay for S : 12

*

*

*

*

*

*

*

*

*

*

*

*

0 0

; ,

G P

P P

G P

P G

P G

G

where

o

Delay for S

63

: 12 Delay for C

64

: 7

* 0

* 1

* 2

* 3

*

* 0

1 2

3 1

2 3

2 3

3

;

P P

P P

P

G P

P P

G P

P G

P G

G

o o

(26)

Comparison of the Delay of different FAST ADDER systems

Adder C4 C8 C16 S15 C32 S31 C64 S63

Adder C4 C8 C16 S15 C32 S31

RCA 8 16 32 31 64 63 128 127

LAC-FA 3 5 9 10 17 18 33 34

HLG&P‐

CA

- - 5 8 7 10 11 14

2nd 5 7 7 12

2

LEVEL HLG&P-

CA

5 7 7 12

CA

(27)

Other Advanced Adders:

- Pipelined

- Manchester Adder

- Carry-Skip/Carry Select - Parallel Prefix

C dd W ll t

- Carry-save adders – Wallace tree -

(28)

1 1 0 1 x 1 0 1 1 ---

MULTIPLIER UNIT

1 1 0 1 1 1 0 1 0 0 0 0 1 1 0 1

_____________

1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1

 Three types of high-speed multipliers:

 Sequential multiplier - generates partial products sequentially and adds each newly generated

product to previously accumulated partial product

 Parallel multiplier - generates partial products in parallel, accumulates using a fast multi-operand adder

 Array multiplier array of identical cells

 Array multiplier - array of identical cells

generating new partial products; accumulating

them simultaneously

(29)

PP

i-1,j+1

m

m

j

q

i

q

i

C

in

C

out

PP

i,j

Typical Cell of an Array Multiplier

Typical Cell of an Array Multiplier

(30)

For Sequential circuit binary Multiplier:

Need - ADDER and Shift-right Registrar (SR) modules.

The control circuit requires a clock;

The control circuit requires a clock;

Multiplixer to decide:

- Add zero (only SR) Or

- Add and shift (SR)Add and shift (SR).

Result to be held in 2-K bit SR.

Result to be held in 2 K bit SR.

(31)

Unsigned Binary Multiplication

(32)

Flowchart for Unsigned Binary

Multiplication p

(33)

Execution of Example p

(34)

Booth’s Algorithm for unsigned multiplication p

Two basic principles:

- Strings of 0’s require no addition – only shift

St i f 1’ b i i l t t t

- String of 1’s may be given special trreatment:

001110 (+14) --> 010000 - 000010 (16 - 2);

1’s from K-bit posn. to M-bit posn:

Treat as

:

2

K+1

– 2

M

;;

In the above example K = 3, M = 1;

h ( l i li d)

4 1

Thus M (Multiplicand) X 14 = M X 2

4

= M X 2

1

; Obtain result by: y

M << 4 - M << 1 // view as C-code.

(35)

Take a example: multiplier = 30; Multiplicand = 45

(30) > 32 2 =>

Change Multiplier to:

(30) --> 32 – 2 =>

0011110  0100000 (32) 1111110 ( 2)

Change Multiplier to:

0 (+1) 0 0 0 0 0 0 0 0 0 0 (-1) 0

1111110 (-2) ---

0 0 0 0 0 (-1) 0

0 1 0 1 1 0 1

0 +1 0 0 0 -1 0

- - - - - - - - -

0 0 0 0 0 0 0

1 1 1 1 1

1 0 1 0 0 1 1

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 1 0 1 1 0 1

0 0 0 0 0 0 0

- - - - - - - - - - - - - -

0 0 1 0 1 0 1 0 0 0 1 1 0

(36)

Good multiplier for coding:

0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 …..

Worst case multiplier:

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ………

Mult 0 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 0 0

Coded Coded

Mult.

0

+1 -1 +1 0 -1 0 +1 0 0 -1 +1 -1 +1 0 -1 0 0
(37)

Three rules for Booth’s algm. implementation with operation on the multiplicand:

- For the LSB = 1 in a string of 1’s in a multiplier:

Subtract the multiplicand from the partial product;

- For the first bit-0 (prior to a 1) in a string of 0’s, the multiplicand is added to the partial product.

- For any pair of identical bit-pair in the mutliplier, the partial product is unchanged.

0 0 1 1 1 1 0 

0 +1 0 0 0 1 0 0 +1 0 0 0 -1 0 Multiplier Bits

Bit i Bit (i 1) O / Bit P tt

Bit i Bit (i-1) Opn. / Bit Pattern

0 0 0 x M Shift only; String of Zeros

0 1 +1 M Add d Shift E d f

0 1 +1 x M Add and Shift; End of a

String of Ones

1 0 -1 x M Subtract and Shift

; Beginning

1 0 1 x M Subtract and Shift

; Beginning

of a String of Ones

1 1 0 x M Shift only; String of Ones

(38)

Booth’s Algorithm

(39)

Example of Booth’s Algorithm p g

(40)

Execution of Example – Booth Multiplier

+13  01101

6  11010  0 1 +1 1 0

p p

-6  11010  0 -1 +1 -1 0

0 1 1 0 1

0 -1 +1 -1 0

- - - - - - - - -

0 0 0 0 0 0 0

1 1 1

1 1 1 0 0 1 1

1 1 1

1 1 1 0 0 1 1

0 0 0 1 1 0 1

1

1 1 1 0 0 1 1

0 0 0 0 0 0 0

- - - - - - - - - - - -

1 1 1 1 1 0 1 1 0 0 1 0

(41)

Fast Multiplication done by:

- Bit-pair recoding

- Carry-save Addition of Summands

F t L k h d C ( ith b th b ) - + Fast Look ahead Carry (with both above) - Pipelined and Booth Array Tree

- etc.

(42)

BIT-PAIR RECODING OF MULTIPLIERS

Observe this:

-6  11010  0 -1 +1 -1 0

Observe this:

Consider the pair of (+1, -1):

==> (+1, -1)*M = 2xM – M = M

==> (0, +1) *M;

Thus: (+1, -1) == (0, +1);

which is also independent of the bit position “i”.

Booth Pair Equiv. to Recoded pair

( 0)(0 2)

(+1, 0)(0, +2)

(-1, +1)(0, -1)

(0 0)(0 0)

(0, 0)(0, 0)

( 0, 1)(0, 1)

(+1, 1)--

(-1, 0)(0, -2)

(43)

BIT-PAIR RECODING OF MULTIPLIERS

Booth Pair Equiv.

to Recoded pair

( ) ( )

Multiplier Bits

Bit i Bit (i 1)

(+1, 0) (0, +2)

(-1, +1)(0, -1)

(0 0)(0 0)

Bit i Bit (i-1)

0 0 0 x M

0 1 +1 x M

(0, 0) (0, 0)

( 0, 1)(0, 1)

(+1, 1)--

0 1 +1 x M

1 0 -1 x M

(+1, -1)(0, +1)

(-1, 0)(0, -2)

1 1 0 x M

-6  1 1 1 0 1 0  0 0 -1 +1 -1 0

0 0 -1 0 -2

(44)

Execution of Example –

Booth’s Recoded Multiplier

+13  01101

-6  11010  0 -1 +1 -1 0  0 0 -1 0 -2 +13  01101; +26  011010; -26  100110;

-13  10011;

0 1 1 0 1

0 0 -1 0 -2

- - - - - - - - -

1 1 1 1 1 1 0 0 1 1 0

0 0 0

0 0 0 0 0 0 0

0 0 0

0 0 0 0 0 0 0

1 1 1 1 1 0 0 1 1

0

0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0

- - - - - - - - - - - -

1 1 1 1 1 0 1 1 0 0 1 0

(45)

03

Unsigned Binary Division

03 243

63 +13  1101  DIVISOR;

274  100010010  DIVIDEND

54

189 

1 0 1 0 1

274  100010010  DIVIDEND

1 1 0 1 1 0 0 0 1 0 0 1 0

- 1 1 0 1

_ _ _ _ _

1 0 0 0 0

- 1 1 0 1

21

274

13 1 1 0 1

_ _ _ _ _

1 1 1 0

14 26 

- 1 1 0 1

_ _ _ _ _

13 -

14

01

1

(46)

Unsigned Binary Division g y

Divisor M

Subtract or

Add

Shift Left

Dividend Q

(47)

Flowchart for Unsigned Binary Division

(48)

ALGO. for RESTORING DIVISION

Load Divisor in Reg. M;

Load Dividend in Reg. Q;

Set Reg. A = 0;

Repeat n times:

• Shift (left) A & Q (one bit posn.)

• A = A – M;

• If sgn(A) == 1 (-ve A) If sgn(A) 1 ( ve A) o Set Q

0

= 0;

o A = A + M;

Else

o Set Q

0

= 1; ANS:

End - Quotient is in Reg. Q;

R i i R A

- Rem. is in Reg. A.

(49)

OPN. REG. A REG. Q

INIT. 0 0 0 0 0 1 0 0 0

Dividend

I

S. L. 0 0 0 0 1 0 0 0

SUB 1 1 1 1 0

Rstr 0 0 0 0 1 0 0 0 0

Dividend, Q = 1000;

Divisor

Rstr 0 0 0 0 1 0 0 0 0

II

S. L. 0 0 0 1 0 0 0 0

SUB 1 1 1 1 1

Divisor, M = 11.

Rstr 0 0 0 1 0 0 0 0 0

- M = 11101

III

S. L. 0 0 1 0 0 0 0 0

SUB 0 0 0 0 1

Set-Q 0 0 0 0 1 0 0 0 1

Set-Q0 0 0 0 0 1 0 0 0 1

S. L. 0 0 0 1 0 0 0 1

Result, in decimal ??

IV SUB 1 1 1 1 1

Rstr 0 0 0 1 0 0

decimal ??

Quotient

= 02 ;

Final

Result 0 0 0 1 0 0 0 1 0

REM Q

02 ;

Rem = 02.

(50)

Repeat n times:

How to improve the Algo. ??

• Shift (left) A & Q (one bit posn.) If A is +ve,

Opns :

• A = A – M;

• If sgn(A) == 1 (-ve A) Opns. :

- S.L. (A);

S bt t M

If A is -ve, Opns. :

If sgn(A) 1 ( ve A) o Set Q

0

= 0;

o A = A + M;

- Subtract M;

 (2A – M) - A + M

- S.L. (A+M);

Else

o Set Q

0

= 1;

- Subtract M;

 (2A + 2M) – M End

( )

= 2A + M

(51)

How to improve the Algo. ??

If A is ve If A is +ve,

Opns. :

If A is -ve, Opns. :

A M - S.L. (A);

- Subtract M;

- A + M

- S.L. (A+M);

- Subtract M;

 (2A – M)

 (2A + 2M) – M

= 2A + M

(52)

Step 1: Repeat n times:

1. If sgn(A) == 0

- Shift (left) A & Q (1-bit posn ) Shift (left) A & Q (1 bit posn.) - A = A – M;

else

Shift (left) A & Q (1 bit posn )

i - Shift (left) A & Q (1-bit posn.)

- A = A + M;

2 If (A) 0

RESTORING DIVISION

Repeat n times:

• Shift (left) A & Q (1 bit posn.) 2. If sgn(A) == 0

o Set Q

0

= 1;

o else Q

0

= 0;

• A = A – M;

End

Step 2: If sgn(A) == 1

• If sgn(A) == 1 (-ve A) o Set Q

0

= 0;

o A = A + M;

p g ( )

A = A + M;

o A = A + M;

Else

o Set Q = 1;

NON_RESTORING DIVISION

o Set Q

0

= 1;

End

(53)

OPN. REG. A REG. Q

INIT. 0 0 0 0 0 1 0 0 0

S L 0 0 0 0 1 0 0 0

Dividend

I

S. L. 0 0 0 0 1 0 0 0

SUB 1 1 1 1 0

Set Q0 1 1 1 1 0 0 0 0 0

Dividend, Q = 1000;

Q0

II

S. L. 1 1 1 0 0 0 0 0

ADD 1 1 1 1 1

Divisor, M = 11.

II ADD 1 1 1 1 1

Set Q0 1 1 1 1 1 0 0 0 0

S 0 0 0 0

- M =

III

S. L. 1 1 1 1 0 0 0 0

ADD 0 0 0 0 1

Set-Q0 0 0 0 0 1 0 0 0 1

11101 M

Set Q0 0 0 0 0 1 0 0 0 1

IV

S. L. 0 0 0 1 0 0 0 1

SUB 1 1 1 1 1

IV SUB 1 1 1 1 1

Set-Q0 1 1 1 1 1 0 0 1 0

ADD

0 0 0 1 0 0 0 1 0

ADD

0 0 0 1 0 0 0 1 0

Final Result 0 0 0 1 0 0 0 1 0

REM Q

(54)
(55)

IEEE 32-bit single precision

Floating Point Numbers

S E’

(excess-127 Rep.) M

IEEE 32 bit single precision

0/1 8 23

IEEE 64-bit single precision

|M| = 52

|E| = 11 |M| = 52

|E| = 11

Density of Floating Point Numbers

(56)

SEM Field

 C i d it d f ti

 Common case - signed-magnitude fraction

 Floating-point format - sign bit S, e bits of exponent E m bits of unsigned fraction M (m+e+1=n)

E, m bits of unsigned fraction M (m+e+1=n)

 Value of (S,E,M) :

( )

( (-1)

0

=1 ; (-1)

1

=-1 )

 Maximal value - M max = 1- ulp

 ulp -Unit in the last position - weight of the least-

f b f h f l f d

significant bit of the fractional significand

 Usually (not always) ulp = 2

-m
(57)

In IEEE 32-bit single precision;

E is a “signed exponent”, E’ is in excess-127 Representation E is a signed exponent , E is in excess 127 Representation

2 '

0

; 127 '  E 

E

The end values are reserved for special use:

; 128 127

255 '

0

E E

; 127 126

; 127 '

; 254 '

1

E

E E

E

;  126  E  127 ;

Range,

for Exponent: For Mantissa: p 38

127

126 .... 2 ] 10 2

[     [ 2  23 ]  10  7

In IEEE 64-bit single precision;

2046 '

1

; 1023

'  E   E 

E

Range,

for Exponent: For Mantissa:  1022  E  1023 ;

308 1023

1022 .... 2 ] 10

2

[     [ 2  53 ]  10  16

(58)

Floating-Point Formats of Three Machines g

(59)

Binary Normalized Mantissa (IEEE):

1.<xxxx ..23 bits….xxxx>

0 10001000 .0010110 …….

Numerical Value (unnormalized): = +0.0010110…. x 29

0 10000101 .0110 …….

Numerical Value (Normalized): = +1.0110…. x 26

1 00101000 .001010 …….

Numerical Value (Normalized): = -1.001010…. x 2-87

(60)

Special Values :

Both

E’ = 0 AND M = 0 ZERO VALUE;

E’ = 255 AND M = 0 INFINITY;

possible are

and

0  

E’= 0 and M <> 0  denormal numbers;

possible are

2 126

.

0  

 M

E’= 255 and M <> 0  NaN;

0 0 ;  1

Exceptions :

Underflow, Overflow, Divide by zero and

Inexact  Result that requires rounding in order to be q g represented in one of the normal formats;

Invalid  0/0 and sqrt(-1) are attempted.

Invalid  0/0 and sqrt( 1) are attempted.

Special values are set to the results.

(61)

Algms. For ADD/SUB, MULT/DIV, in normalized floating point opens.

ADD/SUB MULT. DIV.

Make

smaller exp = large exp.,

Add the E’s and subtract 127

Subtract the E’s and add 127

by shifting opn.

Perform ADD/SUB on

i ( l

Mult. the

Mantissas and get h i

Div. The Mantissas and get the sign

mantissas (get result

with sign) the sign

Normalize the result value, if necessary, i ll th th b

in all the three cases above.

(62)

Floating point addition

(63)

Floating point addition

(64)

FP Addition & Subtraction Flowchart

(65)

Circuitry for Addition/Subtraction

(66)

Floating Point Multiplication

(67)

Floating Point Division

(68)

Referensi

Dokumen terkait

Table 3 — Step 2 results Source: Researcher’s own construction Activities Results 2.1 Stage 1 — Operational practices Toolbox lean 2.2 Partial implementation of LM for the

Test Results for the Implementation of Learning Video Media No Trial Subjects Validity Test Results % Description 1 Learning Media Expert Trial 96 % Very good 2 Trial of Early

• The d-bit is needed only to place the result of an operation into WREG; the default is d = 1 • If the third operand a-bit is a 0, then the access bank is used for the register file

Conclusions Based on the research results it can be concluded as follows: 1 The implementation of the learning process for Indonesian language teachers and digital literacy for