Computer Architecture Lecture 15 Fasih ur Rehman.

10
Computer Architecture Lecture 15 Fasih ur Rehman

Transcript of Computer Architecture Lecture 15 Fasih ur Rehman.

Page 1: Computer Architecture Lecture 15 Fasih ur Rehman.

Computer Architecture

Lecture 15Fasih ur Rehman

Page 2: Computer Architecture Lecture 15 Fasih ur Rehman.

Last Class

• Arithmetic– Representation– Signed numbers– Operations and their implementation

Page 3: Computer Architecture Lecture 15 Fasih ur Rehman.

Today’s Agenda

• Arithmetic operations

Page 4: Computer Architecture Lecture 15 Fasih ur Rehman.

Overflow (Examples)

Page 5: Computer Architecture Lecture 15 Fasih ur Rehman.

Overflow

• Overflow in case of addition can only occur when both the operands have same sign.

• Condition for Overflow• Overflow happens when (at MSB)

Carry in ≠ Carry out• Normally, overflow is referred to ‘V’ flag in status

register

Page 6: Computer Architecture Lecture 15 Fasih ur Rehman.

Addition/subtraction of signed numbers

si =ci +1 =

13

7+ Y

1

00010

1

1

00110

11

0

01101001

0

0

0

0

1

1

1

1

00001111

Example:

10= = 0

01 1

11 1 0 0

1

1 1 10

Legend for stage i

xi yi Carry-in ci Sum s i Carry-out ci+1

X

Z

+ 6 0+xiyisi

Carry-outci+1

Carry-inci

xiyicixiyicixiyicixiyici x i yi ciÅ Å=+ + +

yicixicixiyi+ +

Page 7: Computer Architecture Lecture 15 Fasih ur Rehman.

Logic for Single Stage

Page 8: Computer Architecture Lecture 15 Fasih ur Rehman.

n – bit Ripple Carry Adder

Page 9: Computer Architecture Lecture 15 Fasih ur Rehman.

Cascade for k n – bit Adders

Page 10: Computer Architecture Lecture 15 Fasih ur Rehman.

Summary

• Overflow• Addition• Adders