Instruction Set Design

Similar documents
Typical Processor Execution Cycle

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

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

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

software hardware Which is easier to change/design???

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

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

Instruction Set Architecture. "Speaking with the computer"

Instruction Set Principles and Examples. Appendix B

Instruction Set Architecture (ISA)

COSC 6385 Computer Architecture. Instruction Set Architectures

Chapter 2. Instruction Set Design. Computer Architectures. software. hardware. Which is easier to change/design??? Tien-Fu Chen

Lecture 4: Instruction Set Architecture

Instruction Set Architectures

Computer Architecture. The Language of the Machine

Computer Organization CS 206 T Lec# 2: Instruction Sets

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

Chapter 2 Instruction: Language of the Computer

EC-801 Advanced Computer Architecture

Overview of Today s Lecture: Review Instruction Sets, Performance

Lecture 3: Instruction Set Architecture

The MIPS Instruction Set Architecture

CSCE 5610: Computer Architecture

Overview of Today s Lecture

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

CPU Architecture and Instruction Sets Chapter 1

COMPUTER ORGANIZATION & ARCHITECTURE

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

ECE 486/586. Computer Architecture. Lecture # 7

COMP3211/COMP9211 Computer Architecture. Lecturer: Sri Parameswaran LiC: Oliver Diessel Demonstrators: Liang Tang & George Gong

2012 David Black- Schaffer 1

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

EC 413 Computer Organization

Overview of Today s Lecture

ECE232: Hardware Organization and Design

Chapter 2: Instructions How we talk to the computer

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

CHAPTER 5 A Closer Look at Instruction Set Architectures

ECE 486/586. Computer Architecture. Lecture # 8

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

Instruction Sets: Characteristics and Functions Addressing Modes

CHAPTER 5 A Closer Look at Instruction Set Architectures

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

Lecture Topics. Branch Condition Options. Branch Conditions ECE 486/586. Computer Architecture. Lecture # 8. Instruction Set Principles.

CHAPTER 5 A Closer Look at Instruction Set Architectures

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

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

COS 140: Foundations of Computer Science

Lecture 4: Instruction Set Design/Pipelining

Computer Organization MIPS ISA

CS4617 Computer Architecture

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

Chapter 2A Instructions: Language of the Computer

Instructions: Language of the Computer

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CMSC Computer Architecture Lecture 2: ISA. Prof. Yanjing Li Department of Computer Science University of Chicago

Reminder: tutorials start next week!

CHAPTER 2: INSTRUCTION SET PRINCIPLES. Prepared by Mdm Rohaya binti Abu Hassan

CS/ECE/752 Chapter 2 Instruction Sets Instructor: Prof. Wood

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 2. Instruction Set Principles and Examples. In-Cheol Park Dept. of EE, KAIST

History of the Intel 80x86

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

Instructions: Language of the Computer

Assembly Language Design

Graduate Computer Architecture. Chapter 2. Instruction Set Principles

Understand the factors involved in instruction set

Computer Systems Architecture I. CSE 560M Lecture 3 Prof. Patrick Crowley

General Purpose Processors

Computer Hardware Generations

Instruction Set II. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 7. Instruction Set. Quiz. What is an Instruction Set?

ESE 545 Computer Architecture Instruction Set Design CA: ISA Design

CPE300: Digital System Architecture and Design

Review: Organization. CS152 Computer Architecture and Engineering Lecture 2. Review of MIPS ISA and Design Concepts

Instruction Set Architecture

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 4. The Processor

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

CA226 Advanced Computer Architecture

Evolution of ISAs. Instruction set architectures have changed over computer generations with changes in the

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

Chapter 13 Reduced Instruction Set Computers

Real instruction set architectures. Part 2: a representative sample

From CISC to RISC. CISC Creates the Anti CISC Revolution. RISC "Philosophy" CISC Limitations

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Topics in computer architecture

COSC 6385 Computer Architecture - Instruction Set Principles

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 4. The Processor

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

COMPUTER HARDWARE. Instruction Set Architecture

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

Processor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Instruction Set Design and Architecture

Systems Architecture I

EITF20: Computer Architecture Part2.2.1: Pipeline-1

Computer Architecture

Transcription:

Instruction Set Design software instruction set hardware CPE442 Lec 3 ISA.1

Instruction Set Architecture Programmer's View ADD SUBTRACT AND OR COMPARE... 01010 01110 10011 10001 11010... CPU Memory I/O Computer Program (Instructions) Computer's View Princeton (Von Neumann) Architecture --- Data and Instructions mixed in same memory ("stored program computer") --- Program as data (dubious advantage) --- Storage utilization --- Single memory interface Harvard Architecture --- Data & Instructions in separate memories --- Has advantages in certain high performance implementations CPE442 Lec 3 ISA.2

Basic Issues in Instruction Set Design --- What operations (and how many) should be provided LD/ST/INC/BRN sufficient to encode any computation But not useful because programs too long! --- How (and how many) operands are specified Most operations are dyadic (eg, A <- B + C) Some are monadic (eg, A <- ~B) --- How to encode these into consistent instruction formats Instructions should be multiples of basic data/address widths Typical instruction set: 32 bit word basic operand addresses are 32 bits long basic operands, like integers, are 32 bits long in general case, instruction could reference 3 operands (A := B + C) challenge: encode operations in a small number of bits! CPE442 Lec 3 ISA.3

Instruction Execution Cycle Instruction Fetch Obtain instruction from program storage Instruction Decode Determine required actions and instruction size Operand Fetch Locate and obtain operand data Execute Compute result value or status Result Store Deposit results in storage for later use Next Instruction Determine successor instruction CPE442 Lec 3 ISA.4

What Must be Specified? Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction Instruction Format or Encoding how is it decoded? Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Data type and Size Operations what are supported Successor instruction jumps, conditions, branches - fetch-decode-execute is implicit! CPE442 Lec 3 ISA.5

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported CPE442 Lec 3 ISA.6

Basic ISA Classes Accumulator: 1 address add A acc acc + mem[a] 1+x address addx A acc acc + mem[a + x] Stack: 0 address add tos tos + next General Purpose Register: 2 address add A B EA(A) EA(A) + EA(B) 3 address add A B C EA(A) EA(B) + EA(C) Load/Store: 3 address add Ra Rb Rc Ra Rb + Rc load Ra Rb store Ra Rb Ra mem[rb] mem[rb] Ra Comparison: Bytes per instruction? Number of Instructions? Cycles per instruction? CPE442 Lec 3 ISA.7

Comparing Number of Instructions Code sequence for C = A + B for four classes of instruction sets: Stack Accumulator Register Register (register-memory) (load-store) Push A Load A Load R1,A Load R1,A Push B Add B Add R1,B Load R2,B Add Store C Store C, R1 Add R3,R1,R2 Pop C Store C,R3 CPE442 Lec 3 ISA.8

General Purpose Registers Dominate All recent machines use general purpose registers Advantages of registers registers are faster than memory registers are easier for a compiler to use - e.g., (A*B) (C*D) (E*F) can do multiplies in any order registers can hold variables - memory traffic is reduced, so program is sped up (since registers are faster than memory) - code density improves (since register named with fewer bits than memory location) CPE442 Lec 3 ISA.9

Examples of Register Usage Number of memory addresses per typical ALU instruction 0 3 Maximum number of operands per typical ALU instruction Examples RISC - SPARC, MIPS, Precision Architecture, Power PC Register to Register Architectures 1 2 Intel 80x86, Motorola 68000 family Register to Memory Architectures 3 3 VAX family (also has 2-operand formats) Memory to Memory Architectures CPE442 Lec 3 ISA.10

Pros and Cons of Number Memory Operands/Operands Register Register: 0 memory operands/instr, 3 (register) operands/instr + Simple, fixed-length instruction encoding. Simple code generation model. Instructions take similar numbers of clocks to execute Higher instruction count than architectures with memory references in instructions. Some instructions are short and bit encoding may be wasteful. Register Memory (1,2) + Data can be accessed without loading first. Instruction format tends to be easy to encode and yields good density. Operands are not equivalent since a source operand in a binary operation is destroyed. Encoding a register number and a memory Address in each instruction may restrict the number of registers. Clocks per instruction varies by operand location. Memory Memory (3,3) + Most compact. Doesn t waste registers for temporaries. Large variation in instruction size, especially for three-operand instructions. Also, large variation in work per instruction. Memory accesses create memory bottleneck. CPE442 Lec 3 ISA.11

Summary on Instruction Classes Expect new instruction set architecture to use general purpose registers Pipelining => Expect it to use load store variant of GPR ISA CPE442 Lec 3 ISA.12

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported CPE442 Lec 3 ISA.13

Addressing Modes Addressing mode Example Meaning Register Add R4,R3 R4 R4+R3 Immediate Add R4,#3 R4 R4+3 Displacement Add R4,100(R1) R4 R4+Mem[100+R1] Register indirect Add R4,(R1) R4 R4+Mem[R1] Indexed Add R3,(R1+R2) R3 R3+Mem[R1+R2] Direct or absolute Add R1,(1001) R1 R1+Mem[1001] Memory indirect Add R1,@(R3) R1 R1+Mem[Mem[R3]] Auto-increment Add R1,(R2)+ R1 R1+Mem[R2]; R2 R2+d Auto-decrement Add R1, (R2) R2 R2 d; R1 R1+Mem[R2] Scaled Add R1,100(R2)[R3] R1 R1+Mem[100+R2+R3*d] CPE442 Lec 3 ISA.14

Addressing Mode Usage --- In Benchmarks, 17% to 43% of references use Displacement --- Register deferred (indirect): 13% avg, 3% to 24% --- Scaled: 7% avg, 0% to 16% --- Memory indirect: 3% avg, 1% to 6% --- Misc: 2% avg, 0% to 3% CPE442 Lec 3 ISA.15

Displacement Address Size 50% to 60% of displacements fit within 8 bits 75% to 80% fit within 16 bits Int. Avg. FP Avg. 30% 25% 20% 15% 10% 5% 0% 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Average of 5 programs from SPECint92 and Average of 5 programs from SPECfp92 X-axis is in powers of 2 (the number of bits of Displacements in a reference) 1% of addresses > 16-bits CPE442 Lec 3 ISA.16

Addressing Summary Data Addressing modes that are important: Displacement, Immediate, Register Indirect Displacement size should be 12 to 16 bits Immediate size should be 8 to 16 bits CPE442 Lec 3 ISA.17

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported CPE442 Lec 3 ISA.18

Typical Operations Data Movement Arithmetic Logical Shift Control (Jump/Branch) Subroutine Linkage Interrupt Synchronization String Load (from memory) Store (to memory) memory-to-memory move register-to-register move input (from I/O device) output (to I/O device) push, pop (to/from stack) integer (binary + decimal) or FP Add, Subtract, Multiply, Divide not, and, or, set, clear shift left/right, rotate left/right unconditional, conditional call, return trap, return test & set (atomic r-m-w) search, translate CPE442 Lec 3 ISA.19

Top 10 80x86 Instructions Rank instruction Integer Average Percent total executed 1 load 22% 2 conditional branch 20% 3 compare 16% 4 store 12% 5 add 8% 6 and 6% 7 sub 5% 8 move register-register 4% 9 call 1% 10 return 1% Total 96% Simple instructions dominate instruction frequency CPE442 Lec 3 ISA.20

Methods of Testing Condition Condition Codes Processor status bits are set as a side-effect of arithmetic instructions (possibly on Moves) or explicitly by compare or test instructions. ex: add r1, r2, r3 bz label Condition Register Ex: cmp r1, r2, r3 bgt r1, label Compare and Branch Ex: bgt r1, r2, label CPE442 Lec 3 ISA.21

Condition Codes Setting CC as side effect can reduce the # of instructions X:... SUB r0, #1, r0 BRP X vs. X:... SUB r0, #1, r0 CMP r0, #0 BRP X But also has disadvantages: --- not all instructions set the condition codes which do and which do not often confusing! e.g., shift instruction sets the carry bit --- dependency between the instruction that sets the CC and the one that tests it: to overlap their execution, may need to separate them with an instruction that does not change the CC ifetch read compute write Old CC read New CC computed ifetch read compute write CPE442 Lec 3 ISA.22

Conditional Branch Distance Int. Avg. FP Avg. 40% 35% 30% 25% 20% 15% 10% 5% 0% 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bits of Branch Dispalcement Distance from branch in instructions 2i => Š ±2 i-1 & > 2 i-2 25% of integer branches are > 2 & Š 4 or -2 to -4 & CPE442 Lec 3 ISA.23

Conditional Branch Addressing PC-relative since most branches At least 8 bits suggested (± 128 instructions) Compare Equal/Not Equal most important for integer programs LT/GE 7% 40% GT/LE 7% 23% Int Avg. FP Avg. EQ/NE 37% 86% 0% 20% 40% 60% 80% 100% Frequency of comparison types in branche s CPE442 Lec 3 ISA.24

Operation Summary Support these simple instructions, since they will dominate the number of instructions executed: load, store, add, subtract, move register-register, and, shift, compare equal, compare not equal, branch (with a PC-relative address at least 8-bits long), jump, call, return; CPE442 Lec 3 ISA.25

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported CPE442 Lec 3 ISA.26

Data Types Bit: 0, 1 Bit String: sequence of bits of a particular length 4 bits is a nibble 8 bits is a byte 16 bits is a half-word (VAX: word) 32 bits is a word (VAX: long word) Character: ASCII 7 bit code EBCDIC 8 bit code UNICODE 16 bit code Decimal: digits 0-9 encoded as 0000b thru 1001b two decimal digits packed per 8 bit byte Integers: 1 byte - 8 bytes in size Sign & Magnitude: 0X vs. 1X 1's Complement: 0X vs. 1(~X) 2's Complement: 0X vs. (1's comp) + 1 Positive #'s same in all First 2 have two zeros Last one usually chosen CPE442 Lec 3 ISA.27 Floating Point: Single Precision Double Precision M x R E Extended Precision mantissa exponent base How many +/- #'s? Where is decimal pt? How are +/- exponents represented?

Operand Size Usage Doubleword 0% 69% Word 31% 74% Int Avg. Halfword 0% 19% FP Avg. Byte 0% 7% 0% 20% 40% 60% 80% Frequency of refere nce by size Support these data sizes and types: 8-bit, 16-bit, 32-bit integers and 32-bit and 64-bit IEEE 754 floating point numbers CPE442 Lec 3 ISA.28

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported CPE442 Lec 3 ISA.29

Instruction Format If have many memory operands per instructions and many addressing modes, need an Address Specifier per operand If have load-store machine with 1 address per instr. and one or two addressing modes, then just encode addressing mode in the opcode CPE442 Lec 3 ISA.30

Generic Examples of Instruction Formats Variable: Instruction Word length Fixed: Hybrid: ALU instructions can have variable lengths, 2 to16 bytes Depending on number of memory operands All instructions have fixed length lengths, e.g., 4 bytes Instructions of the same type have fixed length, different types have different length CPE442 Lec 3 ISA.31

MIPS Addressing Modes/Instruction Formats Fixed size format example Register (direct) op rs rt rd register Immediate op rs rt immed Displacement op rs rt Displ. Memory register + PC-relative op rs rt immed Memory PC + CPE442 Lec 3 ISA.32

Hybrid Format CPE442 Lec 3 ISA.33

Summary of Instruction Formats If code size is most important, use variable length instructions If performance is most important, use fixed length instructions CPE442 Lec 3 ISA.34

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported o The IA-32 ISA Text pp 137-144 CPE442 Lec 3 ISA.35

CPE442 Lec 3 ISA.36

CPE442 Lec 3 ISA.37

CPE442 Lec 3 ISA.38

CPE442 Lec 3 ISA.39

CPE442 Lec 3 ISA.40

See the complexity of the IA-32 ISA and compare it with the MIPS ISA to be discussed next CPE442 Lec 3 ISA.41

Topics to be covered Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Operations Instruction Format or Encoding how is it decoded? Data type and Size what are supported o The IA-32 ISA Text pp 137-144 o Instruction Set Metrics o Summary CPE442 Lec 3 ISA.42

Instruction Set Metrics Design-time metrics: Can it be implemented, in how long, at what cost? Can it be programmed? Ease of compilation? Static Metrics: How many bytes does the program occupy in memory? Dynamic Metrics: How many instructions are executed? How many bytes does the processor fetch to execute the program? How many clocks are required per instruction? CPI How "lean" a clock is practical? Best Metric: Time to execute the program! Inst. Count Cycle Time NOTE: this depends on instructions set, processor organization, and compilation techniques. CPE442 Lec 3 ISA.43

Lecture Summary: ISA Use general purpose registers with a load-store architecture; Support these addressing modes: displacement (with an address offset size of 12 to 16 bits), immediate (size 8 to 16 bits), and register deferred; Support these simple instructions, since they will dominate the number of instructions executed: load, store, add, subtract, move registerregister, and, shift, compare equal, compare not equal, branch (with a PC-relative address at least 8-bits long), jump, call, and return; Support these data sizes and types: 8-bit, 16-bit, 32-bit integers and 64- bit IEEE 754 floating point numbers; Use fixed instruction encoding if interested in performance and use variable instruction encoding if interested in code size; Provide at least 16 general purpose registers plus separate floatingpoint registers, be sure all addressing modes apply to all data transfer instructions, and aim for a minimalist instruction set. CPE442 Lec 3 ISA.44