Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26)

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

Lecture Topics. Announcements. Today: The MIPS ISA (P&H ) Next: continued. Milestone #1 (due 1/26) Milestone #2 (due 2/2)

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division

Lecture 8: Addition, Multiplication & Division

Tailoring the 32-Bit ALU to MIPS

ECE260: Fundamentals of Computer Engineering

Unsigned Binary Integers

Unsigned Binary Integers

ECE260: Fundamentals of Computer Engineering

Review: MIPS Organization

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

MIPS Integer ALU Requirements

Fast Arithmetic. Philipp Koehn. 19 October 2016

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

Integer Multiplication and Division

MIPS Instruction Set

CS3350B Computer Architecture MIPS Instruction Representation

Computer Architecture

Arithmetic for Computers

ECE331: Hardware Organization and Design

CENG3420 L05: Arithmetic and Logic Unit

CPS 104 Computer Organization and Programming

ECE232: Hardware Organization and Design

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

ECE 30 Introduction to Computer Engineering

CENG 3420 Lecture 05: Arithmetic and Logic Unit

Computer Architecture. Chapter 3: Arithmetic for Computers

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

MACHINE LANGUAGE. To work with the machine, we need a translator.

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

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

The MIPS Instruction Set Architecture

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

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

CSEE 3827: Fundamentals of Computer Systems

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

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Number Systems and Their Representations

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Lecture Topics. Announcements. Today: Single-Cycle Processors (P&H ) Next: continued. Milestone #3 (due 2/9) Milestone #4 (due 2/23)

Instructions: Language of the Computer

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

Chapter 4. The Processor

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

Reduced Instruction Set Computer (RISC)

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

COMP 303 Computer Architecture Lecture 6

EECS150 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3

Reduced Instruction Set Computer (RISC)

MIPS Instruction Format

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Computer Architecture. The Language of the Machine

Review of Last lecture. Review ALU Design. Designing a Multiplier Shifter Design Review. Booth s algorithm. Today s Outline

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

ELCT 501: Digital System Design

Chapter 2A Instructions: Language of the Computer

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

COMPUTER ORGANIZATION AND DESIGN

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

Chapter 3 Arithmetic for Computers

More complicated than addition. Let's look at 3 versions based on grade school algorithm (multiplicand) More time and more area

Number Systems and Computer Arithmetic

ECE331: Hardware Organization and Design

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

Flow of Control -- Conditional branch instructions

Arithmetic and Logical Operations

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

MIPS Instruction Reference

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

M2 Instruction Set Architecture

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

Processor (I) - datapath & control. Hwansoo Han

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Examples of branch instructions

CENG 3420 Lecture 06: Datapath

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal.

COMPUTER ARITHMETIC (Part 1)

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

CSCI 402: Computer Architectures

CS61C : Machine Structures

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

Assembly Programming

MIPS History. ISA MIPS Registers

Thomas Polzer Institut für Technische Informatik

Week 7: Assignment Solutions

Sheet For the following C code: a = b + c; b = a + c; d = a b; Write an equivalent assembly MIPS program. Solution:

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

Lecture 10: Simple Data Path

Chapter 4. The Processor

CPS311 - COMPUTER ORGANIZATION. A bit of history

Computer Architecture. MIPS Instruction Set Architecture

Computer Architecture. Lecture 2 : Instructions

F. Appendix 6 MIPS Instruction Reference

Xuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015.

Instructions: Language of the Computer

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

9 Multiplication and Division

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

UCB CS61C : Machine Structures

Transcription:

Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: The MIPS ISA (P&H 2.1-2.14) 1 Announcements Consulting hours Milestone #1 (due 1/26) Milestone #2 (due 2/2) 2 1

Review: Integer Operations Internal representation unsigned integers signed integers Operations arithmetic operations bitwise operations shift operations 3 Review: Operations on Integers Arithmetic operations: addition, subtraction multiplication, division Bitwise (logical) operations: AND, OR, XOR, Shift operations: SLL, SRL, SRA, 4 2

Bitwise Operations Almost all processors support: AND OR XOR Some processors support additional ops: NAND, NOR ANDN, ORN, XORN 5 Shift Operations Almost all processors support: SLL (shift left logical) SRL (shift right logical) SRA (shift right arithmetic) Some processors support additional ops: ROL (rotate left) ROR (rotate right) 6 3

Arithmetic Operations Almost all processors support: Addition Subtraction Most processors support additional ops: Multiplication Division 7 Combined Adder/Subtractor (4 bits) B3 B2 B1 B0 SUB A3 A2 A1 A0 A B A B A B A B Carry Cout FA Cin Cout FA Cin Cout FA Cin Cout FA Cin S S S S S3 S2 S1 S0 SUB control signal: 0 means Add, 1 means Subtract 8 4

Multiplication Requires a series of steps (sequential circuit) First approach: based on paper and pencil assume 4 bit values assume positive values product is twice as long as operands multiplicand multiplier product 1000 1001 1000 0000 0000 1000 1001000 9 Multiplication Algorithm Initialize 64-bit product to zero Repeat if bit 0 of multiplier is 1, add multiplicand to product shift multiplicand left 1 shift multiplier right 1 10 5

Multiplication Hardware Since product is 64 bits, use 64-bit adder and extend multiplicand to 64 bits with zeroes 11 Multiplication Hardware Extend with 0's Initialize to 0 12 6

Example (4-bit operands) 13 Improved Multiplication Initialize 64-bit product: zeroes in upper half, multiplier in lower half 14 7

Improved Multiplication No need for register to hold multiplier: place in lower 32 bits of product No need for double-length register to hold multiplicand 32-bit adder (instead of 64-bit adder) Shift product and multiplier at same time (equivalent to shifting multiplicand left) 15 Improved Multiplication Signed operands: work with 31-bit operands, "calculate" sign of product positive: sign bits the same negative: sign bits different Overflow: product must "fit" into lower 32 bits of 64-bit register; result is too large if upper 32 bits are not the same as the sign bit of the result (bit 31) 16 8

Faster Multiplier Unroll the loop: 31 32-bit adders least significant bit of each sum is one bit in the product the other 31 bits and the carry out are the input to the next adder 17 Faster Multiplier Organize adders to minimize delay 18 9

Division Again, series of steps First approach: based on paper and pencil assume 4 bit values assume positive values dividend is larger than divisor quotient dividend 1001 1000 1001010-1000 divisor 10 101 1010-1000 remainder 10 19 Division Hardware Initially divisor in left half Initially dividend 20 10

Example (4 bit operands) 21 Improved Division One cycle per partial-remainder subtraction Same circuit as multiplication 22 11

Faster Divider Can t use parallel hardware as in multiplier, since subtraction is conditional on sign of remainder Faster dividers (such as SRT division) generate multiple quotient bits per step Uses a table to look up next guess Table must be accurate Still require multiple steps 23 MIPS Integer Circuits Math unit: addition and subtraction bitwise operations Shift unit: shift operations Multiply and Divide unit: multiplication and division 24 12

MIPS Math Unit Inputs: 32-bit operands 4-bit operation code Outputs: 32-bit result 1-bit zero flag 1-bit overflow flag 25 MIPS Math Unit Handles addition, subtraction and bitwise operations: ADD, ADDU SUB, SUBU AND, OR, XOR, NOR SLT, SLTU ADDU, SUBU do not set the overflow flag SLT, SLTU produce 0 or 1 26 13

MIPS Shift Unit Handles shift operations: SLL SRL SRA No provision for rotates (but can be done with a series of instructions) 27 MIPS Multiply Circuit Handles unsigned and signed multiply Circuit has two special registers to hold the result: HI and LO Product must be moved from LO to general purpose register 28 14

MIPS Multiply Circuit Unsigned multiplication: LO contains product HI contains zeroes (overflow otherwise) Signed multiplication: LO contains product Overflow if bit 31 (leftmost bit of LO) does not match all bits of HI 29 MIPS Divide Circuit Uses same circuitry as multiplication LO contains the quotient HI contains the remainder Circuit does not detect overflow or division by zero (must be handled by software) 30 15

MIPS ISA The MIPS was originally developed at Stanford (by Hennessy's group) Spun off to commercial company Typical RISC microprocessor small number of instructions only 32 general purpose registers 31 MIPS R-format Instructions op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Instruction fields op: operation code (opcode) rs: first source register number rt: second source register number rd: destination register number shamt: shift amount (00000 for now) funct: function code (extends opcode) 32 16

R-format Example op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits add $t0, $s1, $s2 special $s1 $s2 $t0 0 add 0 17 18 8 0 32 000000 10001 10010 01000 00000 100000 00000010001100100100000000100000 2 = 02324020 16 33 MIPS I-format Instructions op rs rt constant or address 6 bits 5 bits 5 bits 16 bits Instruction fields rs: first source register number rt: destination or source register number Constant: 2 15 to +2 15 1 Address: offset added to base address in rs Compromise: different formats complicate decoding, but allow uniform 32-bit instructions 34 17