ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

Similar documents
ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

ECE232: Hardware Organization and Design

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

CS 351 Exam 2 Mon. 11/2/2015

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

MIPS%Assembly% E155%

CS 61c: Great Ideas in Computer Architecture

Computer Architecture. The Language of the Machine

ECE 30 Introduction to Computer Engineering

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

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

Reduced Instruction Set Computer (RISC)

Course Administration

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

Lecture 5: Procedure Calls

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

Computer Architecture. MIPS Instruction Set Architecture

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

The MIPS Instruction Set Architecture

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

ECE331: Hardware Organization and Design

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

Instructions: Language of the Computer

MIPS Reference Guide

Reduced Instruction Set Computer (RISC)

CS3350B Computer Architecture MIPS Introduction

Lecture 4: MIPS Instruction Set

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

M2 Instruction Set Architecture

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Computer Architecture I Midterm I

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

MIPS Coding Snippets. Prof. James L. Frankel Harvard University. Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved.

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

MIPS Instruction Set

ECE232: Hardware Organization and Design

MIPS Assembly Programming

Levels of Programming. Registers

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

Chapter Three. Arithmetic

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

CS3350B Computer Architecture

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

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

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

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

SPIM Instruction Set

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

CS/COE1541: Introduction to Computer Architecture

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

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

Computer Organization & Design

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

IEEE Standard for Floating-Point Arithmetic: 754

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

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

Computer Architecture. Chapter 3: Arithmetic for Computers

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

CS3350B Computer Architecture MIPS Instruction Representation

ECE331: Hardware Organization and Design

TSK3000A - Generic Instructions

CS61C L10 MIPS Instruction Representation II, Floating Point I (6)

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

MIPS Assembly Language. Today s Lecture

EE 361 University of Hawaii Fall

Numeric Encodings Prof. James L. Frankel Harvard University

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

We will study the MIPS assembly language as an exemplar of the concept.

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

ECE 15B Computer Organization Spring 2010

ece4750-tinyrv-isa.txt

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Arithmetic. Chapter 3 Computer Organization and Design

MIPS (SPIM) Assembler Syntax

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm


Thomas Polzer Institut für Technische Informatik

Compiling Techniques

University of California at Santa Barbara. ECE 154A Introduction to Computer Architecture. Quiz #1. October 30 th, Name (Last, First)

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

Computer Architecture

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

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

CO Computer Architecture and Programming Languages CAPL. Lecture 13 & 14

ECE 154A Introduction to. Fall 2012

instructions aligned is little-endian

Chapter 2A Instructions: Language of the Computer

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

Transcription:

ECE 331 Hardware Organization and Design Professor Jay Taneja UMass ECE - jtaneja@umass.edu Discussion 5 2/22/2018

Today s Discussion Topics Program Concepts Floating Point Floating Point Conversion Floating Point Special Cases

1 M I P S Reference Data CORE INSTRUCTION SET OPCODE FOR- / FUNCT NAME, MNEMONIC MAT OPERATION (in Verilog) (Hex) Add add R R[rd] = R[rs] + R[rt] (1) 0 / 20 hex Add Immediate addi I R[rt] = R[rs] + SignExtImm (1,2) 8 hex Add Imm. Unsigned addiu I R[rt] = R[rs] + SignExtImm (2) 9 hex Add Unsigned addu R R[rd] = R[rs] + R[rt] 0 / 21 hex And and R R[rd] = R[rs] & R[rt] 0 / 24 hex And Immediate andi I R[rt] = R[rs] & ZeroExtImm (3) c hex if(r[rs]==r[rt]) Branch On Equal beq I 4 PC=PC+4+BranchAddr (4) hex if(r[rs]!=r[rt]) Branch On Not Equal bne I 5 PC=PC+4+BranchAddr (4) hex Jump j J PC=JumpAddr (5) 2 hex Jump And Link jal J R[31]=PC+8;PC=JumpAddr (5) 3 hex Jump Register jr R PC=R[rs] 0 / 08 hex R[rt]={24 b0,m[r[rs] Load Byte Unsigned lbu I 24 +SignExtImm](7:0)} (2) hex Load Halfword R[rt]={16 b0,m[r[rs] lhu I 25 Unsigned +SignExtImm](15:0)} (2) hex Load Linked ll I R[rt] = M[R[rs]+SignExtImm] (2,7) 30 hex NAME NUMBER USE $zero 0 The Constant Value 0 $at 1 Assembler Temporary $v0-$v1 2-3 Values for Function Results and Expression Evaluation $a0-$a3 4-7 Arguments $t0-$t7 8-15 Temporaries $s0-$s7 16-23 Saved Temporaries $t8-$t9 24-25 Temporaries $k0-$k1 26-27 Reserved for OS Kernel $gp 28 Global Pointer $sp 29 Stack Pointer $fp 30 Frame Pointer $ra 31 Return Address Load Upper Imm. lui I R[rt] = {imm, 16 b0} f hex Load Word lw I R[rt] = M[R[rs]+SignExtImm] (2) 23 hex Nor nor R R[rd] = ~ (R[rs] R[rt]) 0 / 27 hex Or or R R[rd] = R[rs] R[rt] R[rt](15:0) (2) 0 / 25 hex Or Store Immediate Word sw I R[rt] M[R[rs]+SignExtImm] = ZeroExtImm = R[rt] (3) (2) 2b d hex Subtract sub R R[rd] = R[rs] - R[rt] (1) 0 / 22 hex 0 / 23

Program Concepts Program Counter ($pc) register that contains the address of the instruction currently being executed Stack Pointer ($sp) register that contains the address of the top of the stack (memory set aside for a program s computations) Frame Pointer ($fp) register that contains the address of the previous top of the stack from before the current procedure

Parts of a Floating Point Number -0.9876 x 10-3 Exponent Sign of mantissa Location of decimal point Mantissa Sign of exponent Base Mantissa is also called Significand ECE232: Floating Point 12

Single Precision Format Note that the exponent has no explicit sign bit Base? 32 bits M: Mantissa (23 bits) E: Exponent (8 bits) S: Sign of mantissa (1 bit) ECE232: Floating Point 13

Working with normalization (single precision) S {0,1} (1-bit) 1 E 254 (8-bits unsigned integer); Bias = 127 0.0000 0000 0000 0000 0000 000 f base-2 < 0.1111 1111 1111 1111 1111 111 Formula provides for the full range of possible floating point numbers. F S = (-1) 1. f * 2 E-Bias 2-2 2-1 2 0 2 1 2 2 2 3 0.25 0.5 1.0 2.0 4.0 8.0 ECE232: Floating Point 17

IEEE Floating-Point Format single: 8 bits double: 11 bits S Exponent single: 23 bits double: 52 bits Fraction x = (-1) S (1+ Fraction) 2 (Exponent -Bias) S: sign bit (0 Þ non-negative, 1 Þ negative) Normalize significand: 1.0 significand < 2.0 Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit) Significand is Fraction with the 1. restored Exponent: excess representation: actual exponent + Bias Ensures exponent is unsigned Single: Bias = 127; Double: Bias = 1203 1023 ECE232: Floating Point 18

Categories of Floating Point Representation Depending on the value of the exponent and fraction, the floating point number can take on different meanings ECE232: Floating Point 22

An0ther Single precision example 0 10000010 11010000000000000000000 1.1101 2 130 127 = 3 0 = positive mantissa +1.1101 2 x 2 3 = 1110.1 2 = 14.5 10 ECE232: Floating Point 10

Floating Point Special Representations S E-127 F = (-1) 1. f * 2 1 1. < 2 f 1 E 254 (single precision) Single Precision Double Precision Object represented Exponent Fraction Exponent Fraction 0 0 0 0 0 0 nonzero 0 nonzero ± denormalized number 1-254 Anything 1-2046 Anything ± floating point number 255 0 2047 0 ± infinity 255 nonzero 2047 nonzero NaN (not a number) ECE232: Floating Point 15

1 M I P S Reference Data CORE INSTRUCTION SET OPCODE FOR- / FUNCT NAME, MNEMONIC MAT OPERATION (in Verilog) (Hex) Add add R R[rd] = R[rs] + R[rt] (1) 0 / 20 hex Add Immediate addi I R[rt] = R[rs] + SignExtImm (1,2) 8 hex Add Imm. Unsigned addiu I R[rt] = R[rs] + SignExtImm (2) 9 hex Add Unsigned addu R R[rd] = R[rs] + R[rt] 0 / 21 hex And and R R[rd] = R[rs] & R[rt] 0 / 24 hex And Immediate andi I R[rt] = R[rs] & ZeroExtImm (3) c hex if(r[rs]==r[rt]) Branch On Equal beq I 4 PC=PC+4+BranchAddr (4) hex if(r[rs]!=r[rt]) Branch On Not Equal bne I 5 PC=PC+4+BranchAddr (4) hex Jump j J PC=JumpAddr (5) 2 hex Jump And Link jal J R[31]=PC+8;PC=JumpAddr (5) 3 hex Jump Register jr R PC=R[rs] 0 / 08 hex R[rt]={24 b0,m[r[rs] Load Byte Unsigned lbu I 24 +SignExtImm](7:0)} (2) hex Load Halfword R[rt]={16 b0,m[r[rs] lhu I 25 Unsigned +SignExtImm](15:0)} (2) hex Load Linked ll I R[rt] = M[R[rs]+SignExtImm] (2,7) 30 hex NAME NUMBER USE $zero 0 The Constant Value 0 $at 1 Assembler Temporary $v0-$v1 2-3 Values for Function Results and Expression Evaluation $a0-$a3 4-7 Arguments $t0-$t7 8-15 Temporaries $s0-$s7 16-23 Saved Temporaries $t8-$t9 24-25 Temporaries $k0-$k1 26-27 Reserved for OS Kernel $gp 28 Global Pointer $sp 29 Stack Pointer $fp 30 Frame Pointer $ra 31 Return Address Load Upper Imm. lui I R[rt] = {imm, 16 b0} f hex Load Word lw I R[rt] = M[R[rs]+SignExtImm] (2) 23 hex Nor nor R R[rd] = ~ (R[rs] R[rt]) 0 / 27 hex Or or R R[rd] = R[rs] R[rt] R[rt](15:0) (2) 0 / 25 hex Or Store Immediate Word sw I R[rt] M[R[rs]+SignExtImm] = ZeroExtImm = R[rt] (3) (2) 2b d hex Subtract sub R R[rd] = R[rs] - R[rt] (1) 0 / 22 hex 0 / 23

Floating Point Special Representations S E-127 F = (-1) 1. f * 2 1 1. f < 2 There are two Zeroes, ±0, and two Infinities ± NaN (Not-a-Number) may have a sign and have a non-zero fraction - used for program diagnostics NaNs and Infinities have all 1s in the Exp field, E=255. F+ =, F/ =0 ECE232: Floating Point 14 Source: I. Koren, Computer Arithmetic Algorithms, 2nd Edition, 2002

IEEE Floating-Point Format single: 8 bits double: 11 bits S Exponent single: 23 bits double: 52 bits Fraction x = (-1) S (1+ Fraction) 2 (Exponent -Bias) S: sign bit (0 Þ non-negative, 1 Þ negative) Normalize significand: 1.0 significand < 2.0 Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit) Significand is Fraction with the 1. restored Exponent: excess representation: actual exponent + Bias Ensures exponent is unsigned Single: Bias = 127; Double: Bias = 1203 ECE232: Floating Point 18

An0ther Single precision example 0 10000010 11010000000000000000000 1.1101 2 130 127 = 3 0 = positive mantissa +1.1101 2 x 2 3 = 1110.1 2 = 14.5 10 ECE232: Floating Point 10

Floating Point Special Representations S E-127 F = (-1) 1. f * 2 1 1. f < 2 There are two Zeroes, ±0, and two Infinities ± NaN (Not-a-Number) may have a sign and have a non-zero fraction - used for program diagnostics NaNs and Infinities have all 1s in the Exp field, E=255. F+ =, F/ =0 ECE232: Floating Point 14 Source: I. Koren, Computer Arithmetic Algorithms, 2nd Edition, 2002

Floating Point Special Representations S E-127 F = (-1) 1. f * 2 1 1. < 2 f 1 E 254 (single precision) Single Precision Double Precision Object represented Exponent Fraction Exponent Fraction 0 0 0 0 0 0 nonzero 0 nonzero ± denormalized number 1-254 Anything 1-2046 Anything ± floating point number 255 0 2047 0 ± infinity 255 nonzero 2047 nonzero NaN (not a number) ECE232: Floating Point 15