CPE 232 MIPS Arithmetic1 CPE 232 Computer Organization MIPS Arithmetic – Part I Dr. Gheith Abandah [Adapted from the slides of Professor Mary Irwin (www.cse.psu.edu/~mji)

Slides:



Advertisements
Similar presentations
Arithmetic for Computers
Advertisements

©UCB CPSC 161 Lecture 6 Prof. L.N. Bhuyan
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Fast Adders See: P&H Chapter 3.1-3, C Goals: serial to parallel conversion time vs. space tradeoffs design choices.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.
331 W07.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 7 ALU Design [Adapted from Dave Patterson’s UCB CS152 slides.
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.
Computer Structure - The ALU Goal: Build an ALU  The Arithmetic Logic Unit or ALU is the device that performs arithmetic and logical operations in the.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 6 - Logic &
CSE431 L03 MIPS Arithmetic Review.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 03: MIPS Arithmetic Review Mary Jane Irwin (
Computer Systems Organization: Lecture 3
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
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.
ECE 301 – Digital Electronics
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Week 7.1Spring :332:331 Computer Architecture and Assembly Language Spring 2005 Week 7 [Adapted from Dave Patterson’s UCB CS152 slides and Mary.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
VHDL Synthesis of a MIPS-32 Processor Bryan Allen Dave Chandler Nate Ransom.
CSE331 W07&8.1Irwin Fall 2007 PSU CSE 331 Computer Organization and Design Fall 2007 Week 7&8 Section 1: Mary Jane Irwin (
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Chapter 6-1 ALU, Adder and Subtractor
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
1  1998 Morgan Kaufmann Publishers Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
EEL-4713C Computer Architecture Introduction: the Logic Design Process
Computer Architecture Chapter 3 Instructions: Arithmetic for Computer Yu-Lun Kuo 郭育倫 Department of Computer Science and Information Engineering Tunghai.
CS.305 Computer Architecture Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly made available by Dr Mary.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
Ch3b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University There is logic to it andRd, Rs, RtRd
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers Section 2 citation and following credit line is.
1  2004 Morgan Kaufmann Publishers Performance is specific to a particular program/s –Total execution time is a consistent summary of performance For.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
C-H1 Lecture Adders Half adder. C-H2 Full Adder si is the modulo- 2 sum of ci, xi, yi.
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
Prof. Hsien-Hsin Sean Lee
Lec 11Systems Architecture1 Systems Architecture Lecture 11: Arithmetic for Computers Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Schematics adapted from those provided by the authors Hennessey and Patterson.
1 Lecture 11: Hardware for Arithmetic Today’s topics:  Logic for common operations  Designing an ALU  Carry-lookahead adder.
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.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
May 2, 2001System Architecture I1 Systems Architecture I (CS ) Lecture 11: Arithmetic for Computers * Jeremy R. Johnson May 2, 2001 *This lecture.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
CSE 340 Computer Architecture Spring 2016 MIPS Arithmetic Review.
Based on slides from D. Patterson and www-inst.eecs.berkeley.edu/~cs152/ COM 249 – Computer Organization and Assembly Language Chapter 3 Arithmetic For.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Mary Jane Irwin ( ) [Adapted from Computer Organization and Design,
Computer Arthmetic Chapter Four P&H.
Lecture Adders Half adder.
Arithmetic for Computers
XU, Qiang 徐強 [Adapted from UC Berkeley’s D. Patterson’s and
CS 314 Computer Organization Fall Chapter 3: Arithmetic for Computers
Topic 3b Computer Arithmetic: ALU Design
Systems Architecture I
Topic 3a Two’s Complement Representation
Topic 3b Computer Arithmetic: ALU Design
A 1-Bit Arithmetic Logic Unit
CSC3050 – Computer Architecture
COMS 361 Computer Organization
Presentation transcript:

CPE 232 MIPS Arithmetic1 CPE 232 Computer Organization MIPS Arithmetic – Part I Dr. Gheith Abandah [Adapted from the slides of Professor Mary Irwin ( which in turn Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, UCB]

CPE 232 MIPS Arithmetic2  32-bit signed numbers (2’s complement): two = 0 ten two = + 1 ten two = + 2,147,483,646 ten two = + 2,147,483,647 ten two = – 2,147,483,648 ten two = – 2,147,483,647 ten two = – 2 ten two = – 1 ten MIPS Number Representations maxint minint  Converting <32-bit values into 32-bit values copy the most significant bit (the sign bit) into the “empty” bits > > sign extend versus zero extend ( lb vs. lbu ) MSB LSB

CPE 232 MIPS Arithmetic3 MIPS Arithmetic Logic Unit (ALU)  Must support the Arithmetic/Logic operations of the ISA add, addi, addiu, addu sub, subu, neg mult, multu, div, divu sqrt and, andi, nor, or, ori, xor, xori beq, bne, slt, slti, sltiu, sltu 32 m (operation) result A B ALU 4 zeroovf 1 1  With special handling for sign extend – addi, addiu andi, ori, xori, slti, sltiu zero extend – lbu, addiu, sltiu no overflow detected – addu, addiu, subu, multu, divu, sltiu, sltu

CPE 232 MIPS Arithmetic4 Review: 2’s Complement Binary Representation 2’sc binarydecimal = -( ) = -2 3 = 1010 complement all the bits 1011 and add a 1  Note: negate and invert are different!  Negate

CPE 232 MIPS Arithmetic5 Binary Addition

CPE 232 MIPS Arithmetic6 Review: A Full Adder 1-bit Full Adder A B S carry_in carry_out S = A  B  carry_in (odd parity function) carry_out = A&B | A&carry_in | B&carry_in (majority function)  How can we use it to build a 32-bit adder?  How can we modify it easily to build an adder/subtractor? ABcarry_incarry_outS

CPE 232 MIPS Arithmetic7 A 32-bit Ripple Carry Adder/Subtractor  Remember 2’s complement is just complement all the bits add a 1 in the least significant bit A 0111  0111 B  + 1-bit FA S0S0 c 0 =carry_in c1c1 1-bit FA S1S1 c2c2 S2S2 c3c3 c 32 =carry_out 1-bit FA S 31 c A0A0 A1A1 A2A2 A 31 B0B0 B1B1 B2B2 B 31 add/sub B0B0 control (0=add,1=sub) B 0 if control = 0, !B 0 if control =

CPE 232 MIPS Arithmetic8 Overflow Detection  Overflow: the result is too large to represent in 32 bits  Overflow occurs when l adding two positives yields a negative l or, adding two negatives gives a positive l or, subtract a negative from a positive gives a negative l or, subtract a positive from a negative gives a positive  On your own: Prove you can detect overflow by: l Carry into MSB xor Carry out of MSB, ex for 4 bit signed numbers – –4 –

CPE 232 MIPS Arithmetic9  Need to support the logic operations ( and,nor,or,xor ) l Bit wise operations (no carry operation involved) l Need a logic gate for each function, mux to choose the output  Need to support the set-on-less-than instruction ( slt ) l Use subtraction to determine if (a – b) < 0 (implies a < b) l Copy the sign bit into the low order bit of the result, set remaining result bits to 0  Need to support test for equality ( bne, beq ) l Again use subtraction: (a - b) = 0 implies a = b l Additional logic to “nor” all result bits together  Immediates are sign extended outside the ALU with wiring (i.e., no logic needed) Tailoring the ALU to the MIPS ISA

CPE 232 MIPS Arithmetic10 MIPS ALU  Least-significant bits FunctionBnegateOperation and000 or001 add010 sub110 slt111

CPE 232 MIPS Arithmetic11 MIPS ALU  Most-significant bit FunctionBnegateOperation and000 or001 add010 sub110 slt111

CPE 232 MIPS Arithmetic12 MIPS ALU

CPE 232 MIPS Arithmetic13 Improving Addition Performance  The ripple-carry adder is slow

CPE 232 MIPS Arithmetic14 Carry-Lookahead Adder  Need fast way to find the carry

CPE 232 MIPS Arithmetic15 Carry-Lookahead Adder  Carry generate and carry propagate  g i = a i. b i  p i = a i + b i aiai bibi gigi pipi

CPE 232 MIPS Arithmetic16 Carry-Lookahead Adder Carry Equations: c1 = g0 + p0c0 c2 = g1 + p1c1 = g1 + p1g0 + p1p0c0 c3 = g2 + p2c2 = g2 + p2g1 + p2p1g0 + p2p1p0c0 c4 = g3 + p3c3 = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0

CPE 232 MIPS Arithmetic17 4-bit Carry-Lookahead Adder

CPE 232 MIPS Arithmetic18 Larger Carry-Lookahead Adders P = p0p1p2p3 G = g3 + g2p3 + g1p2p3 + g0p1p2p3