! Data range can be too small!! Addressable memory is small!! Only room for 16 instruction opcodes! CSE 30321!

Similar documents
MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types

Instruction Set Architecture. "Speaking with the computer"

Math 230 Assembly Programming (AKA Computer Organization) Spring MIPS Intro

Lecture 4: MIPS Instruction Set

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

Chapter 2A Instructions: Language of the Computer

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Computer Architecture. MIPS Instruction Set Architecture

55:132/22C:160, HPCA Spring 2011

Chapter 2. Instructions:

Lecture 3 Machine Language. Instructions: Instruction Execution cycle. Speaking computer before voice recognition interfaces

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

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

Review of instruction set architectures

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Instructions: Language of the Computer

ECE 154A Introduction to. Fall 2012

Chapter 2: Instructions:

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

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

EC 413 Computer Organization

The MIPS Instruction Set Architecture

ECE232: Hardware Organization and Design

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Instructions: Language of the Computer

Computer Architecture

Computer Organization MIPS ISA

ECE 486/586. Computer Architecture. Lecture # 7

Reduced Instruction Set Computer (RISC)

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

Lectures 02, 03 Introduction to Stored Programs"

Lecture 5: Instruction Set Architectures II. Take QUIZ 2 before 11:59pm today over Chapter 1 Quiz 1: 100% - 29; 80% - 25; 60% - 17; 40% - 3

Computer Architecture

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

Computer Architecture. The Language of the Machine

Instruction Set Principles and Examples. Appendix B

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

CS3350B Computer Architecture MIPS Instruction Representation

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

Concocting an Instruction Set

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

Lecture 4: Instruction Set Architecture

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

EC-801 Advanced Computer Architecture

Chapter 3. Instructions:

CENG3420 Lecture 03 Review

Topic Notes: MIPS Instruction Set Architecture

Reduced Instruction Set Computer (RISC)

Instructions: Language of the Computer

CS222: MIPS Instruction Set

Instruction Set Architecture (ISA)

Instruction Set Architectures

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

EEC 581 Computer Architecture Lecture 1 Review MIPS

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

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

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

Chapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Reminder: tutorials start next week!

Forecast. Instructions (354 Review) Basics. Basics. Instruction set architecture (ISA) is its vocabulary. Instructions are the words of a computer

CSEE 3827: Fundamentals of Computer Systems

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction

Architecture I. Computer Systems Laboratory Sungkyunkwan University

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

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

ECE232: Hardware Organization and Design

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

MIPS%Assembly% E155%

ISA: The Hardware Software Interface

Lectures 3-4: MIPS instructions

Instruction Set Design and Architecture

CS3350B Computer Architecture MIPS Introduction

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:

Lecture 3: Instruction Set Architecture

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

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

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

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

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

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

Instruction Set Architecture

Lecture 5: Procedure Calls

LECTURE 2: INSTRUCTIONS

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions

COSC 6385 Computer Architecture. Instruction Set Architectures

Instruction Set Architectures Part I: From C to MIPS. Readings:

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

CS3350B Computer Architecture

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

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

ECE331: Hardware Organization and Design

Transcription:

1! 2! Recap and Readings!! Context!! Lecture 01:!! Introduction to the course!! Lectures 02-03:!! Fundamental principals that we will discuss and apply in class using very simplified case study! Lecture 05-06" Motivation and Background of MIPS ISA!! Lecture 04:!! How to quantify impact of design decisions!! Lecture 05: (MIPS ISA)!! Apply / revisit ideas introduced in Lectures 02, 03, but use context of modern ISA!! Use benchmark techniques from Lecture 04 with this material and throughout the rest of the course!! Readings!! H&P: Chapters 2.1-2.3, 2.5-2.7! 3! Processor components! Multicore processors and programming! Motivation: Why MIPS?! Processor comparison!! Shortcomings of the simple processor!! Only 16 bits for data and instruction! vs.!! Data range can be too small!! Addressable memory is small!! Only room for 16 instruction opcodes! CSE 30321!! MIPS ISA: 32-bit RISC processor!! A representative RISC ISA!! (RISC Reduced Instruction Set Computer)!! A fixed-length, regularly encoded instruction set and uses a load/store data model!! Used by NEC, Cisco, Silicon Graphics, Sony, Nintendo! Writing more! efficient code! The right HW for the right application! HLL code translation!! and more! 4!

!! MIPS processor:! 5! A quick look: more complex ISAs!!! 6-instruction processor:! Add instruction: 0010 ra3ra2ra1ra0 rb3rb2rb1rb0 rc3rc2rc1rc0! Add Ra, Rb, Rc specifies the operation RF[a]=RF[b] + RF[c]! Assembly: add $9, $7, $8 # add rd, rs, rt: RF[rd] = RF[rs]+RF[rt]! 6! A quick look: more complex ISAs!!! 6-instruction processor:! Sub instruction: 0111 ra3ra2ra1ra0 rb3rb2rb1rb0 rc3rc2rc1rc0! SUB Ra, Rb, Rc specifies the operation RF[a]=RF[b] RF[c]!!! A MIPS subtract! Assembly: sub $9, $7, $8 # sub rd, rs, rt: RF[rd] = RF[rs]-RF[rt]!!!!!!!!!!!!!!!!!!!!(add: op+func)! 31 26 25 21 20 16 15 11 10 6 5 0 op (6) rs (5) rt (5) rd (5) shamt (5) funct (6)!!!!!!!!!!! 31 26 25 21 20 16 15 11 10 6 5 0 op (6) rs (5) rt (5) rd (5) shamt (5) funct (6) Machine:! B: 000000 00111 01000 01001 xxxxx 100000 D: 0 7 8 9 x 32 Instruction! Encoding! Machine:! B: 000000 00111 01000 01001 xxxxx 100010 D: 0 7 8 9 x 34 Instruction! Encoding! 7! A quick look: more complex ISAs! Datapath! 8! A quick look: more complex ISAs! Datapath! Path of Add from start to finish.! Path of Add from start to finish.!

Note:!! In class, we will work with somewhat simplified version of MIPS ISA!! Reduced instruction set makes HWs, etc. much more manageable!! However, not dissimilar to early ARMs!! Taking less sophisticated processing power to places where there was none is significant! We!ll discuss MIPS more in a bit..."...but 1st, a few slides on ISAs in general.# 9! 10! Instructions Sets!! Instruction set architecture is the structure of a computer that a machine language programmer (or a compiler) must understand to write a correct (timing independent) program for that machine!! IBM introducing 360 (1964)!! an instruction set specifies a processor#s functionality!! what operations it supports!! what storage mechanisms it has & how they are accessed!! how the programmer/compiler communicates programs to processor! ISA = interface between HLL and HW!...! ISAs may have different sytnax (6-instruction vs. MIPS), but can still support the same general types of operations (i.e. Reg-Reg)! 11! Instruction Set Architecture!! Instructions must have some basic functionality:!! Access memory (read and write)!! Perform ALU operations (add, multiply, etc.)!! Implement control flow (jump, branch, etc.)!! I.e. to take you back to the beginning of a loop!! Largest difference is in accessing memory!! Operand location!! (stack, memory, register)!! Addressing modes!! (computing memory addresses)!! (Let#s digress on the board and preview how MIPS does a load)!! (Compare to 6-instruction processor?)! 12! What makes a good instruction set!! implementability!! supports a (performance/cost) range of implementations!! implies support for high performance implementations!! programmability! A bit more on this one...!! easy to express programs (for human and/or compiler)!! backward/forward compatibility!! implementability & programmability across generations!! e.g., x86 generations: 8086, 286, 386, 486, Pentium, Pentium II, Pentium III, Pentium 4...!! think about these issues as we discuss aspects of ISAs!

Example: Range of Cost Implementations! 32-bit ARM not unlike 32-bit MIPS! ARM and Thumb-2 Instruction Set Quick Reference Card Operation Assembler S updates Action Multiply Multiply MUL{S} Rd, Rm, Rs N Z C* Rd := (Rm * Rs)[31:0] and accumulate MLA{S} Rd, Rm, Rs, Rn N Z C* Rd := (Rn + (Rm * Rs))[31 MIPS: Add $9, $7, $8 # add rd, rs, rt: RF[rd] = RF[rs]+RF[rt]" Simplified (16-bit) ARMs available too! http://www.arm.com/products/processors/technologies/instruction-set-architectures.php" A L U b u s nenout DBE ALE A[31:0] Address Register 32-bit ALU ABE Address Incrementer Register Bank (31 x 32-bit registers) (6 status registers) A b u s P C b u s Write Data Register nenin 32 x 8 Multiplier Barrel Shifter D[31:0] I n c r e m e n t e r b u s B b u s Scan Control Instruction Decoder & Control Logic Instruction Pipeline & Read Data Register & Thumb Instruction Decoder DBGRQI BREAKPTI DBGACK ECLK nexec ISYNC BL[3:0] APE MCLK nwait nrw MAS[1:0] nirq nfiq nreset ABORT ntrans nmreq nopc SEQ LOCK ncpi CPA CPB nm[4:0] TBE TBIT HIGHZ http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0210c/index.html" 13! 14! Programmability!! a history of programmability!! pre - 1975: most code was hand-assembled!! 1975 1985: most code was compiled!! but people thought that hand-assembled code was superior!! 1985 present: most code was compiled! Programming literally sitting down and writing machine code!! and compiled code was at least as good as hand-assembly! over time, a big shift in what programmability means! http://www.arm.com/images/pro-a7tdmi-s.gif" http://www.arm.com/images/armpp/nook2_%281%29.jpg" 15! pre-1975: Human Programmability!! focus: instruction sets that were easy for humans to program!! ISA semantically close to high-level language (HLL)!! closing the semantic gap!! semantically heavy complex instructions!! e.g., the VAX had instructions for polynomial evaluation!! people thought computers would someday execute HLL directly!! never materialized! Let#s look at an example! A! The Quadratic Forumla! x = "b ± b 2 " 4ac 2a Approach 1:! Approach 2:! QUAD_Plus X1, a, b, c! QUAD_Minus X2, a, b, c! or! QUAD X1, X2, a, b, c! Generally requires more specialized HW# Mult R1, b, b! Mult R2, a, c! Multi R2, R2, 4! Sub R3 R1, R2! Sqrt R3, R3! Mult, R4, a, 2! Mult R5, b, -1! Add R6, R5, R3! Div R6, R6, R4! Sub R7, R5, R3! Div R7, R7, R4! Provides primitives, not solutions# 16!

17! Present Day: Compiled Assembly! Dependencies:!! Language dependent!! Machine independent!! Somewhat language dependent!! Largely machine independent!! Small language dependencies!! Machine dependencies slight!! (I.e. register counts/types)!! Highly machine dependent!! Language independent! Pass! Front-end per! language! Intermediate representation! High-level! optimizations! Global! optimizer! Code! generator! Function:! Transform language to common, intermediate form! For example, procedure inlining and loop transformations! Including global and local optimization + register allocation! Detailed instruction selection and machinedependent optimizations (assembler next?)! 18! Instruction Formats!! fixed length (most common: 32-bits)!! (plus) easy for pipelining (e.g. overlap) and for multiple issue (superscalar)!! don#t have to decode current instruction to find next instruction!! (minus) not compact!! Does the MIPS add waste bits?! Operation! Address! Field 1!! variable length!! (plus) more compact!! (minus) hard (but do-able) to efficiently decode!! (important later)! Address! Field 2! Address! Field 3! Operation &! Address! Address! Address! Address!.! # of operands! Specifier 1! Field 1! Specifier n! Field n! 19! Operations!! arithmetic and logical:!! add, mult, and, or, xor, not!! data transfer:!! move, load, store!! control:!! conditional branch, jump, call, return!! system:!! syscall, traps!! floating point:!! add, mul, div, sqrt!! decimal:!! addd, convert (not common today)!! string:!! move, compare (also not common today)!! multimedia:!! e.g., Intel MMX/SSE and Sun VIS!! vector:!! arithmetic/data transfer, but on vectors of data! If no instruction for HLL operation, can fake it -- i.e. lots of adds instead of multiply.! Examples...! 20! Internal Storage Model!! choices!! stack!! accumulator!! memory-memory!! register-memory!! register-register (also called load/store )!! running example:!! add C, A, B (C := A + B)!

21! Storage Model: Stack! push A S[++TOS] = M[A];! push B S[++TOS] = M[B];! add T1=S[TOS--]; T2=S[TOS--]; S[++TOS]=T1+T2;! pop C M[C] = S[TOS--];! 22! Storage Model: Register-Register (Ld/St)! load R1,A R1 = M[A];! load R2,B R2 = M[B];! add R3,R1,R2 R3 = R1 + R2;! store C,R3 M[C] = R3;!! operands implicitly on top-of-stack (TOS)!! ALU operations have zero explicit operands!! (plus) code density (top of stack implicit)!! (minus) memory, pipelining bottlenecks (why?)!! mostly 1960#s & 70#s!! x86 uses stack model for FP!! (bad backward compatibility problem)!! JAVA bytecodes also use stack model!! load/store architecture: ALU operations on regs only!! (minus) poor code density!! (plus) easy decoding, operand symmetry!! (plus) deterministic length ALU operations!! (plus) fast decoding helps pipelining (later)!! 1960#s and onwards!! RISC machines: Alpha, MIPS, PowerPC (but also Cray)! Introduction to MIPS ISA!! Next:!! More specifics about:!! MIPS instruction syntax!! Register usage! 23! 24! MIPS Registers (R2000/R3000)!!! 32x32-bit GPRs (General purpose registers)! "! $0 = $zero (therefore only 31 GPRs)! "! $1 = $at (reserved for assembler)! "! $2 - $3 = $v0 - $v1 (return values)! "! $4 - $7 = $a0 - $a3 (arguments)! "! $8 - $15 = $t0 - $t7 (temporaries)! "! $16 - $23 = $s0 - $s7 (saved)! "! $24 - $25 = $t8 - $t9 (more temporaries)! "! $26 - $27 = $k0 - $k1 (reserved for OS)! r 0 r 1 r 31 b n-1... b 0 PC HI LO 32 bits 0... "! $28 = $gp (global pointer)! "! $29 = $sp (stack pointer)! "! $30 = $fp (frame pointer)! "! $31 = $ra (return address)!! 32x32-bit floating point registers (paired double precision)! HI, LO, PC! Status, Cause, BadVAddr, EPC Let#s think ahead a bit...!

25!! Programmer visibility!! Procedure calls! Board digression! 26! Memory Organization!!! Addressable unit:! "! smallest number of consecutive bits (word length) can be accessed in a single operation! "! Example, n=8, byte addressable! Addr 0 1 n bits... Given 1K bit memory, 16 bit word addressable: i b n-1...... b 0 How many words? 64 words 2 k -1 How many address bits? 6 bits!"#$ % &'()*+','!"#$ %-. &'(/*0+' 1234'5+0+'(/*0-67780++6(90':0:;8/' B! C! 27! MIPS: Most data items are contained in words,a word is 32 bits or 4 bytes. Registers hold 32 bits of data 0 4 8 C Effect of Byte Addressing! 32 bits of data 32 bits of data 32 bits of data 32 bits of data 0 1 2 3 8 bits of data 8 bits of data 8 bits of data 8 bits of data 28! A View from 10 Feet Above!! Instructions are characterized into basic types!! Each type interpret a 32-bit instruction differently!! 3 types of instructions:!! R type!! I type!! J type!! Look at both assembly and machine code! #! 2 32 bytes with byte addresses from 0 to 2 32-1 #! 2 30 words with byte addresses 0, 4, 8,... 2 32-4 #! Words are aligned #! What are the least 2 significant bits of a word address? D!

29! R-Type: Assembly and Machine Format!!! R-type: All operands are in registers! Assembly: add $9, $7, $8 # add rd, rs, rt: RF[rd] = RF[rs]+RF[rt]!!!!!!!!!!!!!!!!!!!!(add: op+func)! 31 26 25 21 20 16 15 11 10 6 5 0 Machine:! op (6) rs (5) rt (5) rd (5) shamt (5) funct (6) B: 000000 00111 01000 01001 xxxxx 100000 D: 0 7 8 9 x 32 30!!! All instructions have 3 operands!!! All operands must be registers!!! Operand order is fixed (destination first)!!! Example:"!C code:!a = B - C;!! (Assume that A, B, C are stored in registers s0, s1, s2.)!!mips code:! sub $s0, $s1, $s2!!machine code: 000000 10001 10010 10000 xxxxx 100010!!! Other R-type instructions! R-type Instructions! "! addu, mult, and, or, sll, srl,! 31! I-Type Instructions!! I-type: One operand is an immediate value and others are in registers Example: addi $s2, $s1, 128 # addi rt, rs, Imm # RF[18] = RF[17]+128 32! I-Type Instructions: Another Example!! I-type: One operand is an immediate value and others are in registers Example: lw <+.='.$!<*>&'''''?'RF[19] = DM[RF[8]+32] 31 26 25 21 20 16 15 0 Op (6) rs (5) rt (5) Address/Immediate value (16) B: 001000 10001 10010 0000000010000000 D: 8 17 18 128 31 26 25 21 20 16 15 0 Op (6) rs (5) rt (5) Address/Immediate value (16) B: 100011 01000 10011 0000000000100000 D: 35 8 19 32 How about load the next word in memory?

33! I-Type Instructions: Yet Another Example!! I-type: One operand is an immediate value and others are in registers Example: Again: bne $t0, $t1, Again # if (RF[8]!=RF[9]) PC=PC+4+Imm*4 # else PC=PC+4!@A/'BCDE&' 31 26 25 21 20 16 15 0 Op (6) rs (5) rt (5) Address/Immediate value (16) B: 00101 01000 01001 1111111111111111 D: 5 8 9-1 34! J-Type Instructions!!! J-type: only one operand: the target address! Example: j 3 # PC = (PC+4)[31:28] Target 00 (Why 00?)! 31 26 25 0 Op (6) Target address (26) B: 000010 00000000000000000000000011 D: 2 3 Pseudo-direct Addressing 3F-8096*)G0'67780++)"H' 35! Example: Memory Access Instructions!! MIPS is a Load/Store Architecture (a hallmark of RISC)!! Only load/store type instructions can access memory!! Example:!A = B + C;!! Assume: A, B, C are stored in memory, $s2, $s3, and $s4 contain the addresses of A, B and C, respectively.!! lw $t0, 0($s3)!! RF[8]=DM[RF[19]]!! lw $t1, 0($s4)!! RF[9]=DM[RF[20]]!! add $t2, $t0, $t1!! # RF[10]=RF[8]+RF[9]!! sw $t2, 0($s2)!! DM[RF[18]]=RF[10]!! sw has destination last!! What is the instruction type of sw?! 36! Summary of MIPS Instruction Formats!!!All MIPS instructions are 32 bits (4 bytes) long.!!!r-type:! 31 26 25 21 20 16 15 11 10 6 5 0 op (6) rs (5) rt (5) rd (5) shamt (5) funct (6)!!I-Type:! 31 26 25 21 20 16 15 0 Op (6) rs (5) rt (5) Address/Immediate value (16)!!J-type! 31 26 25 0 Op (6) Target address (26)

37! More on MIPS ISA!! How to get constants into the registers?!! Zero used very frequently => $0 is hardwired to zero!! if used as an argument, zero is passed!! if used as a target, the result is destroyed!! Small constants are used frequently (~50% of operands) " A = A + 5; (addi $t0, $t0, 5)!! "!! slti $8, $18, 10!!!! andi $29, $29, 6!!! ori $29, $29, 4!! What about larger constants?!! How about procedure calls?!! Other features on assembly programming! More Discussion & Examples! 38! E!