CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B

Size: px
Start display at page:

Download "CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B"

Transcription

1 CPE 335 Computer Organization MIPS Arithmetic Part I Content from Chapter 3 and Appendix B Dr. Iyad Jafar Adatped from Dr. Gheith Abandah Slides CPE 232 MIPS Arithmetic 1

2 MIPS Number Representations Computer programs calculate both positive a negative numbers. One approach is to use the sign and magnitude representation. Use separate bit for the sign Shortcomings: Where to put the sign? Positive and negative zeros! Need complex hardware to perform arithmetic Alternative: use the complement notation; specifically the two s complement! CPE 232 MIPS Arithmetic 2

3 MIPS Number Representations 32-bit signed numbers (2 s complement): MSB two = 0 ten two = + 1 ten maxint two = + 2,147,483,646 ten two = + 2,147,483,647 ten two = 2,147,483,648 8 ten two = 2,147,483,647 ten two = 2 ten minint two = 1 ten two LSB If we use N bits to represent a signed number using two s complement, then The maximum number is 2 N-1 1 The minimum number is -2 N-1 ten CPE 232 MIPS Arithmetic 3

4 Review: 2 s Complement Binary Representation Negate 1011 and add a complement all the bits -2 3 = -(2 3-1) = = 2 sc binary decimal CPE 232 MIPS Arithmetic 4

5 MIPS Number Representations Converting signed numbers to decimal ( ) 2 = -1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 + 1*2^3 + 2^2 + 1*2^1 + 0*2^0 = -2 Converting <32-bit values into 32-bit values Sign Extension: copy the most significant bit (the sign bit) into the empty bits > > Zero Extension: place zeros in the extended bits > > CPE 232 MIPS Arithmetic 5

6 MIPS Number Representation How to negate a number? There e is no special instruction Suppose we have x = - x sub $s0, $zero, $s0 This is in contrast to complementing a number! x = ~x Bitwise complement of x There is no single instruction Recall the XOR operation x 1 = x addi $t0, $zero, -1 xor $s0, $s0, $t0 CPE 232 MIPS Arithmetic 6

7 MIPS Instruction Support for Signed numbers add vs addu, sub vs subu, and addi vs addiu Addition/subtraction o is performed ed in the same manner Is overflow exception generated? lb vs lbu lb sign extend the additional bits lbu zero extend the additional bits slt vs sltu and slti vs sltiu slt and slti perform signed comparison with a constant sltu and sltiu perform unsigned comparison with a constant CPE 232 MIPS Arithmetic 7

8 Example Suppose that $s0 = $s1 = then what is the value stored in $t0 in the following cases : slt $t0, $s1, $s0 Signed comparison $t0 = 0 since $s1 = 1 and $s0 = -1 sltu $t0, $s1, $s0 Unsigned comparison $t0 = 1 since $s1 = 1 and $s0 = 2^32-1 CPE 232 MIPS Arithmetic 8

9 Binary Addition Binary addition is simple! = 0 and 0 carry = 1 and 0 carry = 1 and 0 carry = 0 and 1 carry Add corresponding bits and propagate the carry, if any, to the next bit. CPE 232 MIPS Arithmetic 9

10 Review: A Full Adder A B carry_in A B carry_in carry_out S bit Full Adder carry_out S S=A B carry_in carry_out = A&B A&carry_in B&carry_in How can we use it to build a 32-bit adder? How can we modify it easily to build an adder/subtractor? CPE 232 MIPS Arithmetic 10

11 A 32-bit Ripple Carry Adder/Subtractor Remember 2 s complement is just complement all the bits control (0=add,1=sub) B 0 if control = 0,!B 0 if control = 1 B 0 add a 1 in the least significant ifi bit Subtraction is equivalent to adding the negative of the number add/sub B 0 B 1 B 2 A 0 A 1 A 2 c 0 =carry_in 1-bit FA S 0 c 1 1-bit FA S 1 c 2 1-bit FA S 2... c 3 c 31 1-bit FA S 31 A B 31 B c 32=carry_ out CPE 232 MIPS Arithmetic 11 A 31

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

13 Improving Addition Performance The ripple-carry adder is slow We have to wait until the carry is propagated to the final position in order to read out the addition/subtraction result. Carry generation is associated with two levels of gates at each bit position (Co i = A i B i + A i Cin i + B i Cin i ). Total delay = gate delay x 2 x number of bits Example: 16 bit adder delay is 32 delay units CPE 232 MIPS Arithmetic 13

14 Carry-Lookahead Adder Need fast way to find the carry Design a separate unit that computes carries for different bits in parallel! CPE 232 MIPS Arithmetic 14

15 Carry-Lookahead Adder In a 4 bit adder, the equations of the carries are c1 = (b0. c0) + (a0. c0) + (a0. b0) c2 = (b1. c1) + (a1. c1) + (a1. b1) c3 = (b2. c2) + (a2. c2) + (a2. b2) c4 = (b3. c3) + (a3. c3) + (a3. b3) By substitution c2 = (a1. a0. b0) + (a1. a0. c0) + (a1. b0. c0) + (b1. a0. b0) + (b1. a0. c0 ) + (b1. b0. c0) + (a1.b1) c3 = (b2. a1. a0. b0) + (b2. a1. a0. c0) + (b2. a1. b0. c0) + (b2. b1. a0. b0) + (b2. b1. a0. c0 ) + (b2. b1. b0. c0) + (b2. a1. b1) + (a2. a1. a0. b0) + (a2. a1. a0. c0) + (a2. a1. b0. c0) + (a2. b1. a0. b0) + (a2. b1. a0. c0 ) + (a2. b1. b0. c0) + (a2. a1. b1) + (a2.b2) c4 = Imagine the equation if the adder is 32 bits??. CPE 232 MIPS Arithmetic 15

16 Carry-Lookahead Adder We can reduce the logic cost by simple simplification ci+1 = (bi. ci) + (ai. ci) + (ai. bi) = (ai. bi) + (ai + bi). ci = gi + pi. ci gi : carry generate pi : carry propagate Carry equations for 4 bit adder c1 = g0 + p0. c0 c2 = g1 + (p1. g0) + (p1. p0. c0) c3 = g2 + (p2. g1) + (p2. p1. g0) + (p2. p1. p0. c0) c4 = g3 + (p3. g2) + (p3. p2. g1) + (p3. p2. p1. g0) + (p3. p2. p1. p0. c0) Delay to generate c4 is 3 gate delay Still cost is high for larger adders!!! CPE 232 MIPS Arithmetic 16

17 Carry-Lookahead Adder- Second level of Abstraction Assume 16 bit adder that consists of 4 single 4-bit adders with carry-lookahead implementation c4 g0 p0 c0 c3 c2 c1 a0 b bit carry lookahead adder s0 CPE 232 MIPS Arithmetic 17

18 Carry-Lookahead Adder- Second level of Abstraction Need to generate the carry propagate and generate signals at higher level Think of each 4-bit adder block as a single unit that can either generate or propagate a carry. Super propagate signals P0 = p3 p2 p1 p0 P1 = p7 p6 p5 p4 P2 = p11 p10 p9 p8 P3 = p15 p14 p13 p12 Super generate signals G0 = g3+(p3 g2)+(p3 p2 g1)+(p3 p2 p1 g0) G1 = g7+(p7 g6)+(p7 p6 g5)+(p7 p6 p5 g4) G2 = g11+(p11 g10)+(p11 p10 g9)+(p11 p10 p9 g8) G3 = g15+(p15 g14)+(p15 p14 g13)+(p15 p14 p13 g12) CPE 232 MIPS Arithmetic 18

19 Carry-Lookahead Adder- Second level of Abstraction Carry signal at higher levels are C1 = G0 + (P0 c0) C2 = G1 + (P1 G0) + (P1 P0 c0) P0 0) C3 = G2 + (P2 G1) + (P2 P1 G0) + (P2 P1 P0 c0) C4 = G3 + (P3 G2) + (P3 P2 G1) + (P3 P2 P1 G0) + (P3 P2 P1 P0 c0) Each supper carry signal is two level implementation in terms of Pi and Gi Pi is one level of gates while Gi is two and expressed in terms of pi and gi pi and gi are one level of gates Total delay is = 5 16-bit CLA is 5 times faster than the 16-bit ripple carry adder CPE 232 MIPS Arithmetic 19

20 MIPS Arithmetic Logic Unit (ALU) Need to support the logic operations Need to support arithmetic operations Need to support the set-on-less-than instruction Need to support test for equality Immediates are sign or zero extended outside the ALU with wiring (i.e., no logic needed) CPE 232 MIPS Arithmetic 20

21 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 A B zero ovf 1 1 ALU 32 4 m (operation) result 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 Arithmetic 21

22 MIPS Arithmetic Logic Unit (ALU) Start with 1-bit ALU Can easily implement the logic instruction AND and OR since they map directly to hardware. Perform all possible operations in parallel then use a multiplexer to select the result based on the instruction type. The control signal Operation is issued by the control unit CPE 232 MIPS Arithmetic 22

23 MIPS Arithmetic Logic Unit (ALU) For the ADD instruction, use a full adder. The CarryIn input will be used later on to expand the 1-bit ALU to n- Bit. Expand the multiplexer inputs and select lines to accommodate for the add instruction. CPE 232 MIPS Arithmetic 23

24 MIPS Arithmetic Logic Unit (ALU) For the subtract instruction, we use 2 s complement subtraction. We need to complement B and add 1. Define Binvert to select between B and B and set CarryIn to 1. CPE 232 MIPS Arithmetic 24

25 MIPS Arithmetic Logic Unit (ALU) Combine Binvert and CarryIn in one signal Bnegate since they have the same value all the time. CPE 232 MIPS Arithmetic 25

26 MIPS Arithmetic Logic Unit (ALU) Supporting the NOR operation requires no separate gate. Use Demorgan s theorem and the AND gate and define the signal Ainvert (A+B) = A.B CPE 232 MIPS Arithmetic 26

27 MIPS Arithmetic Logic Unit (ALU) Constructing 32-bit ALU Replicate the 1-bit ALU and connect the CarryIn signals All cells receive the same control signals CPE 232 MIPS Arithmetic 27

28 MIPS Arithmetic Logic Unit (ALU) Supporting the SLT instruction Expand the multiplexer for one more input. Subtract the two registers and feed the sign bit (the result of bit 31) back to the least significant bit. The slt input of the multiplexer is connected to 0 for remaining bits. CPE 232 MIPS Arithmetic 28 LSB MSB

29 MIPS Arithmetic Logic Unit (ALU) 32-bit ALU with SLT support. CPE 232 MIPS Arithmetic 29

30 MIPS Arithmetic Logic Unit (ALU) Supporting conditional branch instructions Need to generate a signal that indicates whether the result is zero or not. Simply OR the result bits and take the complement. This signal will be used to make the selection between the branch address and the PC. Example on using the Zero signal to select the address for BEQ instruction CPE 232 MIPS Arithmetic 30

31 MIPS Arithmetic Logic Unit (ALU) Final ALU with overflow detection CPE 232 MIPS Arithmetic 31

32 MIPS Arithmetic Logic Unit (ALU) Control signals values and corresponding operations Ainvert Bnegate Operation Instruction ti AND OR ADD SUB SLT NOR CPE 232 MIPS Arithmetic 32

Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers Chapter 3 Arithmetic for Computers 1 Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing the Architecture operation

More information

Review: MIPS Organization

Review: MIPS Organization 1 MIPS Arithmetic Review: MIPS Organization Processor Memory src1 addr 5 src2 addr 5 dst addr 5 write data Register File registers ($zero - $ra) bits src1 data src2 data read/write addr 1 1100 2 30 words

More information

Arithmetic for Computers

Arithmetic for Computers MIPS Arithmetic Instructions Cptr280 Dr Curtis Nelson Arithmetic for Computers Operations on integers Addition and subtraction; Multiplication and division; Dealing with overflow; Signed vs. unsigned numbers.

More information

Number Systems and Their Representations

Number Systems and Their Representations Number Representations Cptr280 Dr Curtis Nelson Number Systems and Their Representations In this presentation you will learn about: Representation of numbers in computers; Signed vs. unsigned numbers;

More information

Computer Architecture Set Four. Arithmetic

Computer Architecture Set Four. Arithmetic Computer Architecture Set Four Arithmetic Arithmetic Where we ve been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What

More information

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides Chapter 3 Arithmetic for Computers 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

CENG 3420 Lecture 05: Arithmetic and Logic Unit

CENG 3420 Lecture 05: Arithmetic and Logic Unit CENG 3420 Lecture 05: Arithmetic and Logic Unit Bei Yu byu@cse.cuhk.edu.hk CENG3420 L05.1 Spring 2017 Outline q 1. Overview q 2. Addition q 3. Multiplication & Division q 4. Shift q 5. Floating Point Number

More information

CENG3420 L05: Arithmetic and Logic Unit

CENG3420 L05: Arithmetic and Logic Unit CENG3420 L05: Arithmetic and Logic Unit Bei Yu byu@cse.cuhk.edu.hk (Latest update: January 25, 2018) Spring 2018 1 / 53 Overview Overview Addition Multiplication & Division Shift Floating Point Number

More information

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4 Part I: a Program: Compiler, Linker, Assembler, Loader Lecture 4 Program Translation Hierarchy C program Com piler Assem bly language program Assem bler Object: Machine language module Object: Library

More information

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions Outline EEL-4713 Computer Architecture Multipliers and shifters Multiplication and shift registers Chapter 3, section 3.4 Next lecture Division, floating-point 3.5 3.6 EEL-4713 Ann Gordon-Ross.1 EEL-4713

More information

MIPS Integer ALU Requirements

MIPS Integer ALU Requirements MIPS Integer ALU Requirements Add, AddU, Sub, SubU, AddI, AddIU: 2 s complement adder/sub with overflow detection. And, Or, Andi, Ori, Xor, Xori, Nor: Logical AND, logical OR, XOR, nor. SLTI, SLTIU (set

More information

Computer Architecture. Chapter 3: Arithmetic for Computers

Computer Architecture. Chapter 3: Arithmetic for Computers 182.092 Computer Architecture Chapter 3: Arithmetic for Computers Adapted from Computer Organization and Design, 4 th Edition, Patterson & Hennessy, 2008, Morgan Kaufmann Publishers and Mary Jane Irwin

More information

Chapter Three. Arithmetic

Chapter Three. Arithmetic Chapter Three 1 Arithmetic Where we've been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing

More information

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic 5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner Topic 3: Arithmetic These slides are mostly taken verbatim, or with minor changes, from those

More information

We are quite familiar with adding two numbers in decimal

We are quite familiar with adding two numbers in decimal Addition We are quite familiar with adding two numbers in decimal What about adding two binary numbers? If we use the two s complement method to represent binary numbers, addition can be done in a straightforward

More information

Chapter 3. ALU Design

Chapter 3. ALU Design COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 ALU Design Review - A MIPS ALU Implementation add/subt A 0 op B 0 A 1 less + result 0 Zero detect (slt, slti,sltiu,sltu,

More information

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support Components of an ISA EE 357 Unit 11 MIPS ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

F. Appendix 6 MIPS Instruction Reference

F. Appendix 6 MIPS Instruction Reference F. Appendix 6 MIPS Instruction Reference Note: ALL immediate values should be sign extended. Exception: For logical operations immediate values should be zero extended. After extensions, you treat them

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary February 2018 ENCM 369 Winter 2018 Section

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed. Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah NUMBER OPERATIONS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 3810: Computer Organization Overview Homework 4 is due tonight Verify your uploaded file before the

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly) Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

TSK3000A - Generic Instructions

TSK3000A - Generic Instructions TSK3000A - Generic Instructions Frozen Content Modified by Admin on Sep 13, 2017 Using the core set of assembly language instructions for the TSK3000A as building blocks, a number of generic instructions

More information

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

ECE Exam I February 19 th, :00 pm 4:25pm

ECE Exam I February 19 th, :00 pm 4:25pm ECE 3056 Exam I February 19 th, 2015 3:00 pm 4:25pm 1. The exam is closed, notes, closed text, and no calculators. 2. The Georgia Tech Honor Code governs this examination. 3. There are 4 questions and

More information

Assembly Programming

Assembly Programming Designing Computer Systems Assembly Programming 08:34:48 PM 23 August 2016 AP-1 Scott & Linda Wills Designing Computer Systems Assembly Programming In the early days of computers, assembly programming

More information

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 MIPS/SPIM General Purpose Registers Powers of Two 0 $zero all bits are zero 16 $s0 local variable 1 $at assembler temporary 17 $s1 local

More information

Q1: /30 Q2: /25 Q3: /45. Total: /100

Q1: /30 Q2: /25 Q3: /45. Total: /100 ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam One September 19 th 2013 This is a closed book, closed note texam. Calculators are not permitted. Please work the exam in pencil and

More information

Tailoring the 32-Bit ALU to MIPS

Tailoring the 32-Bit ALU to MIPS Tailoring the 32-Bit ALU to MIPS MIPS ALU extensions Overflow detection: Carry into MSB XOR Carry out of MSB Branch instructions Shift instructions Slt instruction Immediate instructions ALU performance

More information

MIPS Instruction Reference

MIPS Instruction Reference Page 1 of 9 MIPS Instruction Reference This is a description of the MIPS instruction set, their meanings, syntax, semantics, and bit encodings. The syntax given for each instruction refers to the assembly

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Arithmetic for Computers Addition and Subtraction Gate Logic and K-Map Method Constructing a Basic ALU Arithmetic Logic Unit

More information

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA EE 357 Unit 11 MIPS ISA Components of an ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

Review. Steps to writing (stateless) circuits: Create a logic function (one per output)

Review. Steps to writing (stateless) circuits: Create a logic function (one per output) MIPS ALU Review Steps to writing (stateless) circuits: Create a truth table Go through all different combinations of inputs For each row, generate each output based on the problem description Create a

More information

COMP MIPS instructions 2 Feb. 8, f = g + h i;

COMP MIPS instructions 2 Feb. 8, f = g + h i; Register names (save, temporary, zero) From what I have said up to now, you will have the impression that you are free to use any of the 32 registers ($0,..., $31) in any instruction. This is not so, however.

More information

Computer Architecture. MIPS Instruction Set Architecture

Computer Architecture. MIPS Instruction Set Architecture Computer Architecture MIPS Instruction Set Architecture Instruction Set Architecture An Abstract Data Type Objects Registers & Memory Operations Instructions Goal of Instruction Set Architecture Design

More information

MIPS Instruction Format

MIPS Instruction Format MIPS Instruction Format MIPS uses a 32-bit fixed-length instruction format. only three different instruction word formats: There are Register format Op-code Rs Rt Rd Function code 000000 sssss ttttt ddddd

More information

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

ECE468 Computer Organization & Architecture. The Design Process & ALU Design ECE6 Computer Organization & Architecture The Design Process & Design The Design Process "To Design Is To Represent" Design activity yields description/representation of an object -- Traditional craftsman

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

CS352H: Computer Systems Architecture

CS352H: Computer Systems Architecture CS352H: Computer Systems Architecture Lecture 4: Instruction Set Architectures III + MIPS ALU September 10, 2008 University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell

More information

Basic Arithmetic (adding and subtracting)

Basic Arithmetic (adding and subtracting) Basic Arithmetic (adding and subtracting) Digital logic to show add/subtract Boolean algebra abstraction of physical, analog circuit behavior 1 0 CPU components ALU logic circuits logic gates transistors

More information

Computer Architecture. The Language of the Machine

Computer Architecture. The Language of the Machine Computer Architecture The Language of the Machine Instruction Sets Basic ISA Classes, Addressing, Format Administrative Matters Operations, Branching, Calling conventions Break Organization All computers

More information

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

More information

MIPS Instruction Set

MIPS Instruction Set MIPS Instruction Set Prof. James L. Frankel Harvard University Version of 7:12 PM 3-Apr-2018 Copyright 2018, 2017, 2016, 201 James L. Frankel. All rights reserved. CPU Overview CPU is an acronym for Central

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering MIPS Instruction Set James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy MIPS Registers MIPS

More information

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the machine. Reduced number of cycles needed per instruction.

More information

Chapter 3: part 3 Binary Subtraction

Chapter 3: part 3 Binary Subtraction Chapter 3: part 3 Binary Subtraction Iterative combinational circuits Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary adder-subtractors Signed binary

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Week 10: Assembly Programming

Week 10: Assembly Programming Week 10: Assembly Programming Arithmetic instructions Instruction Opcode/Function Syntax Operation add 100000 $d, $s, $t $d = $s + $t addu 100001 $d, $s, $t $d = $s + $t addi 001000 $t, $s, i $t = $s +

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering MIPS Instruction Set James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy MIPS Registers MIPS

More information

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction

More information

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit Nurul Hazlina 1 1. Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit Nurul Hazlina 2 Introduction 1. Digital circuits are frequently used for arithmetic operations 2. Fundamental

More information

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

ECE232: Hardware Organization and Design. Computer Organization - Previously covered ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Programming the processor

Programming the processor CSC258 Week 9 Logistics This week: Lab 7 is the last Logisim DE2 lab. Next week: Lab 8 will be assembly. For assembly labs you can work individually or in pairs. No matter how you do it, the important

More information

UCB CS61C : Machine Structures

UCB CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 07 Introduction to MIPS : Decisions II Lecturer SOE Dan Garcia 2011-09-12 Hello to Dr Mauro Sgarzi from Italy!! Researchers at Microsoft

More information

Integer Multiplication and Division

Integer Multiplication and Division Integer Multiplication and Division COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture MIPS Functions July 1, 2014 Review I RISC Design Principles Smaller is faster: 32 registers, fewer instructions Keep it simple: rigid syntax, fixed instruction length MIPS Registers: $s0-$s7,$t0-$t9, $0

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed. Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

CS/COE 0447 Example Problems for Exam 2 Spring 2011

CS/COE 0447 Example Problems for Exam 2 Spring 2011 CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4-bit numbers 3 and 5 with the fast shift-add multipler. Use the table below. List the multiplicand (M) and product

More information

The MIPS Instruction Set Architecture

The MIPS Instruction Set Architecture The MIPS Set Architecture CPS 14 Lecture 5 Today s Lecture Admin HW #1 is due HW #2 assigned Outline Review A specific ISA, we ll use it throughout semester, very similar to the NiosII ISA (we will use

More information

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J.

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J. CS61C Negative Numbers and Logical Operations cs 61C L7 Number.1 Lecture 7 February 10, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html Review 1/2

More information

MIPS Reference Guide

MIPS Reference Guide MIPS Reference Guide Free at PushingButtons.net 2 Table of Contents I. Data Registers 3 II. Instruction Register Formats 4 III. MIPS Instruction Set 5 IV. MIPS Instruction Set (Extended) 6 V. SPIM Programming

More information

ECE 30 Introduction to Computer Engineering

ECE 30 Introduction to Computer Engineering ECE 30 Introduction to Computer Engineering Study Problems, Set #6 Spring 2015 1. With x = 1111 1111 1111 1111 1011 0011 0101 0011 2 and y = 0000 0000 0000 0000 0000 0010 1101 0111 2 representing two s

More information

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization Five classic components CS/COE0447: Computer Organization and Assembly Language I am like a control tower I am like a pack of file folders Chapter 3 I am like a conveyor belt + service stations I exchange

More information

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization CS/COE0447: Computer Organization and Assembly Language Chapter 3 Sangyeun Cho Dept. of Computer Science Five classic components I am like a control tower I am like a pack of file folders I am like a conveyor

More information

Arithmetic Logic Unit. Digital Computer Design

Arithmetic Logic Unit. Digital Computer Design Arithmetic Logic Unit Digital Computer Design Arithmetic Circuits Arithmetic circuits are the central building blocks of computers. Computers and digital logic perform many arithmetic functions: addition,

More information

Binary Adders: Half Adders and Full Adders

Binary Adders: Half Adders and Full Adders Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

More information

CSE 141 Computer Architecture Summer Session Lecture 2 Performance, ALU. Pramod V. Argade

CSE 141 Computer Architecture Summer Session Lecture 2 Performance, ALU. Pramod V. Argade CSE 141 Computer Architecture Summer Session 1 24 Lecture 2 Performance, ALU Pramod V. Argade CSE141: Introduction to Computer Architecture Instructor: TA: Pramod V. Argade (p2argade@cs.ucsd.edu) Office

More information

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA EE 352 Unit 3 MIPS ISA Instruction Set Architecture (ISA) Defines the software interface of the processor and memory system Instruction set is the vocabulary the HW can understand and the SW is composed

More information

CENG 3420 Lecture 06: Datapath

CENG 3420 Lecture 06: Datapath CENG 342 Lecture 6: Datapath Bei Yu byu@cse.cuhk.edu.hk CENG342 L6. Spring 27 The Processor: Datapath & Control q We're ready to look at an implementation of the MIPS q Simplified to contain only: memory-reference

More information

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu CENG 342 Computer Organization and Design Lecture 6: MIPS Processor - I Bei Yu CEG342 L6. Spring 26 The Processor: Datapath & Control q We're ready to look at an implementation of the MIPS q Simplified

More information

UCB CS61C : Machine Structures

UCB CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 10 Introduction to MIPS Decisions II Lecturer SOE Dan Garcia Obama sweeps 8 th state in a row; it s getting tight! 2008 02 13 In what

More information

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University Computer Architecture Chapter 3 Fall 2005 Department of Computer Science Kent State University Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point

More information

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2) Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into

More information

Computer Architecture Experiment

Computer Architecture Experiment Computer Architecture Experiment Jiang Xiaohong College of Computer Science & Engineering Zhejiang University Architecture Lab_jxh 1 Topics 0 Basic Knowledge 1 Warm up 2 simple 5-stage of pipeline CPU

More information

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix

More information

Chapter 4 Arithmetic

Chapter 4 Arithmetic Computer Eng 1 (ECE290) Chapter 4 Arithmetic Functions and Circuits HOANG Trang Reference: 2008 Pearson Education, Inc. Lecture note of Prof.Donna J.Brown Overview Binary adders Half and full adders Ripple

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Boolean Algebra Boolean algebra is the basic math used in digital circuits and computers.

More information

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26) Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: continued 1 Announcements Consulting hours Introduction to Sim Milestone #1 (due 1/26) 2 1 Overview: Integer Operations Internal representation

More information

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck! CSC B58 Winter 2017 Final Examination Duration 2 hours and 50 minutes Aids allowed: none Last Name: Student Number: UTORid: First Name: Question 0. [1 mark] Read and follow all instructions on this page,

More information

ECE 15B Computer Organization Spring 2010

ECE 15B Computer Organization Spring 2010 ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 7: Procedures I Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy, and classes taught by and

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5

More information

CS61C Machine Structures. Lecture 10 - MIPS Branch Instructions II. 2/8/2006 John Wawrzynek. (www.cs.berkeley.edu/~johnw)

CS61C Machine Structures. Lecture 10 - MIPS Branch Instructions II. 2/8/2006 John Wawrzynek. (www.cs.berkeley.edu/~johnw) CS61C Machine Structures Lecture 10 - MIPS Branch Instructions II 2/8/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L10 MIPS Branch II (1) Compiling C if into

More information

Fast Arithmetic. Philipp Koehn. 19 October 2016

Fast Arithmetic. Philipp Koehn. 19 October 2016 Fast Arithmetic Philipp Koehn 19 October 2016 1 arithmetic Addition (Immediate) 2 Load immediately one number (s0 = 2) li $s0, 2 Add 4 ($s1 = $s0 + 4 = 6) addi $s1, $s0, 4 Subtract 3 ($s2 = $s1-3 = 3)

More information

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic

More information

Computer Organization MIPS ISA

Computer Organization MIPS ISA CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization

More information

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter

More information

UCB CS61C : Machine Structures

UCB CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Guest Lecturer Alan Christopher Lecture 08 MIPS Instruction Representation I 2014-02-07 BOINC MORE THAN JUST SETI@HOME BOINC (developed here

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures $2M 3D camera Lecture 8 MIPS Instruction Representation I Instructor: Miki Lustig 2014-09-17 August 25: The final ISA showdown: Is ARM, x86, or

More information

M2 Instruction Set Architecture

M2 Instruction Set Architecture M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. High level languages, Assembly languages and object code. Translating and starting a program. Subroutine

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Chapter 3 Part 2 Combinational Logic Design

Chapter 3 Part 2 Combinational Logic Design University of Wisconsin - Madison ECE/Comp Sci 352 Digital Systems Fundamentals Kewal K. Saluja and Yu Hen Hu Spring 2002 Chapter 3 Part 2 Combinational Logic Design Originals by: Charles R. Kime and Tom

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #8: MIPS Memory & Decisions 2006-07-10 CS 61C L08 MIPS Memory (1) Andy Carle Review In MIPS Assembly Language: Registers replace C

More information