Docsity

Complement Adder and Subtractor - Computer Architecture - Lecture Slides, Slides of Computer Architecture and Organization

Partial preview of the text

Download Complement Adder and Subtractor - Computer Architecture - Lecture Slides and more Slides Computer Architecture and Organization in PDF only on Docsity!

1

Example: Overflow in fixed point addition

+1110.

c 1100

s 11001.

+6.

c 11.

s 16.

C36.A

+72B.

c 1010

s 1361.D

Base 2 Base 8 Base 16

2

Binary bit adders

For a binary adder the sum bit,

sj =x j yj cj +x j yj cj +x j yj c j +x j y j c j

And the carry bit

cj+1=x j yj +x j cj +y j cj

These can be computed using

  • Ripple Carry Adder
  • Carry Lookahead Adder

4

Complement adder/subtractor

To perform subtraction using an

unsigned adder

  • Complement the second input
  • Supply overflow detection

hardware

5

Base b Radix Complement Subtractor

Base b Adder

(b-1)’s complement

x

y

x-y

7

2’s complement Adder/Subtracter

c (^) o

s 1 s (^) o

a (^) m-1 b (^) m-1 a 1 b 1 a 0 b (^0)

C m-

s (^) m-

C m c^1 …

c (^2) FA FA FA

q m-1 q 1 q 0

Subtract control r

8

Carry Lookahead Adder

  • This results in faster addition by

generating or propagating the carry bits

  • Two logical variables G (^) j( generate)and

P j(propagate) are defined as,

G j=x^ jy^ j

P j=x j+y j

  • Hence the carry out will be

c j+1 =G j+P jc j

 - multiplicand x3 x2 x1 x Digital Multiplication Schema - multiplier y3 y2 y1 y - (xy 0 ) 4 (xy 0 ) 3 (xy 0 ) 2 (xy 0 ) 1 (xy 0 ) 0 pp - (xy 1 ) 4 (xy 1 ) 3 (xy 1 ) 2 (xy 1 ) 1 (xy 1 ) 0 pp - (xy 2 ) 4 (xy 2 ) 3 (xy 2 ) 2 (xy 2 ) 1 (xy 2 ) 0 pp 
  • (xy 3 ) 4 (xy 3 ) 3 (xy 3 ) 2 (xy 3 ) 1 (xy 3 ) 0 pp
    • p 7 p 6 p 5 p 4 p 3 p 2 p 1 p

11

Multiplication

• Digital multiplication is based on

addition and shifting of digits

• The hardware involves a

combination of parallel and

sequential operations

13

Unsigned Series Parallel

Multiplier Hardware

Partial Product

m+1 digit adder

b (^) j Multiplier digit

0

a (^) m-1a (^) m-2 … a^1 a (^0)

Product register p 2m digits wide

14

Multiplication Procedure

  1. Clear product shift register p
  2. Initialize multiplier digit j=
  3. Find the partial product abj
  4. Add partial product to upper half of p
  5. Increment j=j+1, if j=m go to step 8
  6. Shift p right 1 digit
  7. Repeat from step 3
  8. The 2-m digit product is in the p register

16

2’s complement multiplication hardware

m-bit multiplicand 0 m-bit multiplier

m=1-bit adder

2m-bit accumulator

m-1 bits

Sign extension

subtract

Carry in

17

Booth Recoding Table

yi yi-1 zi Value Situation

0 0 0 0 String of zeros

0 1 1 +1 End of string of

1s

1 0 1 -1 Begin string of

1s

1 1 0 0 String of 1s

19

Unsigned binary divide hardware

Dividend left shift register

Divisor register

subtractor

quotient register

Positive result

load 0

Left shift

2 m bit dividend m bit register divisor

m bit quotient

20

Integer division

  1. Clear upper half of dividend register and put dividend in lower half. Initialize quotient counter bit to 0
  2. Shift dividend register left 1 bit
  3. If difference is +ve, put it into upper half of dividend and shift 1 into quotient. If –ve, shift 0 into quotient
  4. If quotient bits<m, goto step 2
  5. m-bit quotient is in quotient register and m-bit remainder is in upper half of dividend register