Lec 12Systems Architecture1 Systems Architecture Lecture 12: Design of the MIPS ALU Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.

Slides:



Advertisements
Similar presentations
Systems Architecture Lecture 5: MIPS Instruction Set
Advertisements

Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19,
Arithmetic CPSC 321 Computer Architecture Andreas Klappenecker.
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
ECE 232 L8.Arithm.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 8 Computer.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 6 - Logic &
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
June 18, 2001Systems Architecture II1 Systems Architecture II Systems Architecture I Review * Jeremy R. Johnson June 18, 2001 * Most figures from Computer.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lec 15Systems Architecture1 Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
IT253: Computer Organization
1 Ó1998 Morgan Kaufmann Publishers Chapter 4 計算機算數.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers Section 2 citation and following credit line is.
CPE 232 MIPS Arithmetic1 CPE 232 Computer Organization MIPS Arithmetic – Part I Dr. Gheith Abandah [Adapted from the slides of Professor Mary Irwin (
1  2004 Morgan Kaufmann Publishers Performance is specific to a particular program/s –Total execution time is a consistent summary of performance For.
Computer Architecture Lecture 15 Fasih ur Rehman.
Arithmetic Operations
1  2004 Morgan Kaufmann Publishers Lets Build a Processor Almost ready to move into chapter 5 and start building a processor First, let’s review Boolean.
Addition, Subtraction, Logic Operations and ALU Design
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
Lec 11Systems Architecture1 Systems Architecture Lecture 11: Arithmetic for Computers Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
ECE/CS 552: Arithmetic I Instructor:Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes partially based on set created by Mark Hill.
Arithmetic-Logic Units. Logic Gates AND gate OR gate NOT gate.
July 2, 2001Systems Architecture I1 Systems Architecture II (CS 282) Lab 3: State Elements, Registers, and Memory * Jeremy R. Johnson Monday July 2, 2001.
Computer Arthmetic Chapter Four P&H. Data Representation Why do we not encode numbers as strings of ASCII digits inside computers? What is overflow when.
Csci136 Computer Architecture II Lab#5 Arithmetic Review ALU Design Ripple Carry Adder & Carry lookahead HW #4: Due on Feb 22, before class Feb.16, 2005.
Pirouz Bazargan SabetDecember 2003 Effective Implementation of a 32-bit RISC Processor Pirouz Bazargan Sabet University of Paris 6 - LIP6 - ASIM
May 2, 2001System Architecture I1 Systems Architecture I (CS ) Lecture 11: Arithmetic for Computers * Jeremy R. Johnson May 2, 2001 *This lecture.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
MIPS Arithmetic and Logic Instructions
May 22, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 14: A Simple Implementation of MIPS * Jeremy R. Johnson Mon. May 17, 2000.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Computer System Design Lecture 3
Computer Architecture & Operations I
Computer Arthmetic Chapter Four P&H.
Combinational Circuits
Somet things you should know about digital arithmetic:
Computer Architecture & Operations I
Systems Architecture I
CS352H: Computer Systems Architecture
Instructors: Randy H. Katz David A. Patterson
ECE/CS 552: Arithmetic and Logic
Systems Architecture I
5. Combinational circuits
CSE Winter 2001 – Arithmetic Unit - 1
MISP Assembly.
Systems Architecture I (CS ) Lecture 16: Exceptions
Systems Architecture Lecture 5: MIPS Instruction Set
Systems Architecture I
Systems Architecture I
Systems Architecture II
The University of Adelaide, School of Computer Science
Systems Architecture I
Systems Architecture I
COMS 361 Computer Organization
Instructor: Mozafar Bag-Mohammadi University of Ilam
Combinational Circuits
Logical instructions And rd rs rt Nor rd rs rt Or rd rs rt
Systems Architecture I (CS ) Lecture 17: Exceptions
Systems Architecture I
MIPS Assembly.
Systems Architecture II
Systems Architecture I
Logical Instructions And rd rs rt Nor rd rs rt Or rd rs rt
Presentation transcript:

Lec 12Systems Architecture1 Systems Architecture Lecture 12: Design of the MIPS ALU Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all figures from Computer Organization and Design: The Hardware/Software Approach, Third Edition, by David Patterson and John Hennessy, are copyrighted material (COPYRIGHT 2004 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED).

Lec 12Systems Architecture2 Introduction Objective: To learn what operations are performed by the Arithmetic Logic Unit (ALU) and to learn how the MIPS ALU is implemented. Topics –MIPS logical operations –Full Adder –1-But ALU –The design of the MIPS 32-Bit ALU –Overflow and Overflow Detection –Carry Lookahead

Lec 12Systems Architecture3 Addition and Subtraction Carry-ripple adder

Lec 12Systems Architecture4 Overflow Detection Overflow occurs in the following situations

Lec 12Systems Architecture5 Logical Operations Shift left << sll Shift right >> srl Shift right arithmetic sra Bitwise and & and, andi Bitwise or | or, ori Bitwise complement (not) ~ not (pseudo) Exclusive or ^ xor, xori

Lec 12Systems Architecture6 Representation of Shift Instruction Example sll$t2, $s0, 8 # $t2 = $s0 << 8 $t2 = $10, $s0 = $ op rs rt rd shamt func

Lec 12Systems Architecture7 Example use of Logical Operations Int data; struct { unsigned int ready: 1; unsigned int enable: 1; unsigned int receivedByte: 8; } receiver; … data = receiver.receivedByte; receiver.ready = 0; receiver.enable = 1; Assume data in $s0 receiver in $s1 sll $s0, $s1, 22 srl $s0, $s0, 24 andi $s1, $s1, 0xfffe ori $s1, $s1, 0x | receivedByte | enable | ready

Lec 12Systems Architecture8 Building Blocks

Lec 12Systems Architecture9 Full Adder Sum = parity(a, b, CarryIn) –a xor b xor c + a  b  c  a xor b xor c CarryOut = majority(a, b, CarryIn) –b  CarryIn + a  CarryIn + a  b + a  b  CarryIn  –b  CarryIn + a  CarryIn + a  b b a CarryIn Sum

Lec 12Systems Architecture10 One-Bit ALU

Lec 12Systems Architecture11 Building a 32-Bit ALU Chain 32 1-Bit ALUs

Lec 12Systems Architecture12 Supporting Subtraction Subtraction is equivalent to adding the inverse –In two’s complement a + b + 1

Lec 12Systems Architecture13 Overflow and SLT Modify last 1-Bit ALU –SLT set if (a < b)  a - b < 0 –Check sign bit after subtraction –Check overflow in last 1-Bit ALU –Need to take overflow into account for SLT

Lec 12Systems Architecture14 Overflow and SLT Overflow? –How do we check for overflow? –What do we do with slt if we encounter overflow?

Lec 12Systems Architecture15 Overflow and SLT When adding two positive numbers and a final carry out is produced, is this overflow? –Yes! This is intuitive. When adding two negative numbers and a final carry out is produced, is this overflow? –No! Recall 2’s complement sign extend proof and the (x + -x) example. –A final carry out is expected. Notice the carry in to the most significant (sign) bit ALU in each case and derive an overflow formula that will work in all cases. When overflow occurs, what happens to the SLT signal? Derive this as well.

Lec 12Systems Architecture16 32-Bit ALU with Sub and Slt

Lec 12Systems Architecture17 Support Beq a = b  a - b = 0 Zero = (Result31 +    + Result0)

Lec 12Systems Architecture18 Final 32-Bit ALU

Lec 12Systems Architecture19 Carry Lookahead Adder Why is it easy to add in your head? Why is it harder to add ? If there are no carries (or if we can figure them out a priori), we can compute the additions themselves in parallel. As it stands now, we must ripple the carries through each ALU, causing a linear time addition. This extra time is spent propagating the carry out to the next carry in. By computing the carry in advance, we can improve addition to logarithmic time.

Lec 12Systems Architecture20 Carry Lookahead Adder In binary addition there are only a few possible cases: –1 + 1 (a = b = 1) –0 + 0 (a = b = 0) –0 + 1 or (a xor b) Notice! –The a = b = 1 case will always produce a carry out (Cout = 1), regardless of the carry in –The a = b = 0 case will never produce a carry out (Cout = 0), regardless of the carry in –The a xor b case will result in Cout = Cin The result is the carry status (generate, kill, propagate) Carry status signals can be combined (for example, generate followed by a kill is a kill)

Lec 12Systems Architecture21 Carry Lookahead Adder if (a i-1 = b i-1 =0) then c i = 0 “kill” if (a i-1 = b i-1 =1) then c i = 1 “generate” if (a i-1  b i-1 ) then c i = c i-1 “propagate” + a i-1 b i-1 c i-1 cici

Lec 12Systems Architecture22 Carry Lookahead Adder We can logically define these carry status signals as: –Generate Signal Gi = Ai AND Bi –Propagate Signal Pi = Ai XOR Bi Now how do we compute Carry Out?

Lec 12Systems Architecture23 Carry Lookahead Adder Cout i = G i OR (P i AND Cin i ) But recall that Cin i is really the previous Cout i-1, and we can compute that as G i-1 OR (P i-1 AND Cin i-1 ) How did we define G and P? Can you write the recursive formula in terms of A and B only? If so, we can compute this fast.

Lec 12Systems Architecture24 Combined Carry Status x i = kill if (a i-1 = b i-1 ) x i = generate if (a i-1 = b i-1 ) x i = propagate if (a i-1  b i-1 ) y i = y i-1  x i = x 1    x i FA i-1 FA i + aiai bibi c i+1 + a i-1 b i-1 c i-1

Lec 12Systems Architecture25 Calculating Carry from Carry Status Lemma: –y i = kill  c i = 0 –y i = generate  c i = 1 –y i = propagate does not occur Proof: 1y i = kill  x i = kill  c i = 0 or –x i = propagate and y i-1 = kill and c i = majority(c i-1, a i, b i ) = c i-1 = kill (by induction) 2y i = generate  x i = generate  c i = 1 or –x i = propagate and y i-1 = generate and c i = majority(c i-1, a i, b i ) = 1 (by induction) 3y i = propagate  x i = propagate and y i-1 = propagate, which by induction leads to a contradiction

Lec 12Systems Architecture26 Characterize Carry in Parallel Fast (parallel computation of y i in log time) x0 x1 x2 x3 x4 x5 x6 x7 [0,1] [1,2] [2,3] [3,4] [4,5] [5,6] [6,7] [0,2] [0,3] [1,4] [2,5] [3,6] [4,7] [0,0] [0,1] [0,2] [0,3] [0,4] [0,5] [0,6] [0,7]