CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry...

27
CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE UNIVERSITY, WILBERFORCE, OH 1

Transcript of CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry...

Page 1: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

CPS3340 COMPUTER

ARCHITECTURE Fall Semester, 2013

CPS3340 COMPUTER

ARCHITECTURE Fall Semester, 2013

09/19/2013

Lecture 7: 32-bit ALU, Fast Carry Lookahead

Instructor: Ashraf YaseenDEPARTMENT OF MATH & COMPUTER SCIENCECENTRAL STATE UNIVERSITY, WILBERFORCE, OH

1

Page 2: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Review

Last Class Addition and Subtraction 1-bit ALU

This Class 32-bit ALU Fast Carry Lookahead

Next Class Computer Clock

Page 3: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

32-bit ALU

ripple carry

Page 4: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Subtraction

Subtraction can be done by adding a and b’s negate and 1

By selecting ^b (Binvert = 1) and setting CarryIn to 1 in the least significant bit of the ALU, we get two’s complement subtraction of b from a instead of addition of b to a

A 1-bit ALU that performs AND, OR, and addition on a and b or a and -b

Page 5: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Other functions

These four operations (add, subtract, AND, OR) are found in the ALU of almost every computer, and the operations of most MIPS instructions can be performed by this ALU

But, the design of the ALU is incomplete, NOR function Support for set on less than instruction (slt) Handle overflow Test of zero (equality test to support

conditional branch instructions)

5

Page 6: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

NOR

Ainvert =1, Binvert =1, Operation =00

Page 7: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Set on less than

Set on less than (slt) For comparison of two integers a and b Least significant bit

1 if a < b 0 otherwise

Other bits 0

Page 8: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Set on less than

Page 9: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Handling Overflow

Page 10: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

32-bit ALU

Bit 0-30: normal 1-bit ALU

Bit 31: 1-bit ALU with overflow detection

Page 11: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Final 32-bit ALU

Bnegate Every time we want the ALU to subtract, we

set both CarryIn and Binvert to 1 Otherwise, both CarryIn and Binvert are set

to 0 NOR operation: Binvert is 1, but CarryIn is Don’t

Care We can combine CarryIn and Binvert to a

single line of Bnegate

Page 12: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Test of Zero

We want to quickly test if two integers are equal

Design a single signal of Zero

Page 13: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Final 32-bit ALU

Page 14: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

ALU Control Signals

Page 15: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Symbol of ALU

Page 16: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Faster Addition

Carry Lookahead Speeding up addition Determining the carry in to the high-order

bits sooner Key mechanism

Hardware executes in parallel

Page 17: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Explanation of Carry Lookahead

Try to remember

CarryOuti+1=CarryIni Abbreviation of ci for CarryIni

Then c2 can be evaluated faster without waiting for c1

How about c30? Grows rapidly with the number of bits Very complex

Page 18: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Fast Carry Using the First Level of Abstraction

Consider

Generate (gi) and Propagate (pi)

Then

Page 19: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Generates and Propagates

Why gi is called generate? when gi is 1

ci+1 is “generated” Why pi is called propagate?

when gi is 0 and pi is 1

ci+1 is “propagated” from ci

Page 20: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

4-bit CarryIn

Page 21: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

A Plumbing Analog

Wrenches open and close valves

ci+1 will be full if the nearest generate

value gi is on or pi is on and there is

water further upstream c0 can result in a carry

out without the help of any generates but the help of all propagates

Page 22: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Second Level of Abstraction Super Propagate

Super Generate

Carryin for 16-bit adder

Page 23: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Four 4-bit ALUs with Carry Lookahead to form a 16-bit adder

Page 24: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Example of Fast Carry Lookahead

Consider adding two 16-bit integers a and b

generate gi=ai·bi and propagate pi=ai+bi

Super generate and Super Propagate

Page 25: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Example of Fast Carry Lookahead (cont.)

Finally

How many “steps”? step 1: produce generate and propagate step 2: produce super generate and super

propagate step 3: produce carryout much faster than adder without fast carry

lookahead

Page 26: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

Summary

1-bit ALU Logic Functions Arithmetic Functions

32-bit ALU Set on less than Test of Zero

Fast Carry Look ahead

Page 27: CPS3340 COMPUTER ARCHITECTURE Fall Semester, 2013 09/19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &

What I want you to do

Review Appendix C Work on your assignment 2