Sample Undergraduate Lecture: MIPS Instruction Set Architecture Jason D. Bakos Optics/Microelectronics Lab Department of Computer Science University of.

Slides:



Advertisements
Similar presentations
Advanced Computer Architectures Laboratory on DLX Pipelining Vittorio Zaccaria.
Advertisements

10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
Pipeline Computer Organization II 1 Hazards Situations that prevent starting the next instruction in the next cycle Structural hazards – A required resource.
Lecture Objectives: 1)Define pipelining 2)Calculate the speedup achieved by pipelining for a given number of instructions. 3)Define how pipelining improves.
ELEN 468 Advanced Logic Design
CSE 340 Computer Architecture Spring 2014 MIPS ISA Review
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
1 RISC Pipeline Han Wang CS3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 4.6.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University RISC Pipeline See: P&H Chapter 4.6.
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
The Processor: Datapath & Control
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 18 - Pipelined.
1  2004 Morgan Kaufmann Publishers Chapter Six. 2  2004 Morgan Kaufmann Publishers Pipelining The laundry analogy.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Computer ArchitectureFall 2007 © October 3rd, 2007 Majd F. Sakr CS-447– Computer Architecture.
Computer Structure - Datapath and Control Goal: Design a Datapath  We will design the datapath of a processor that includes a subset of the MIPS instruction.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
CPEN Digital System Design Chapter 10 – Instruction SET Architecture (ISA) © Logic and Computer Design Fundamentals, 4 rd Ed., Mano Prentice Hall.
Shift Instructions (1/4)
Lec 9: Pipelining Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University.
Appendix A Pipelining: Basic and Intermediate Concepts
ECE 4436ECE 5367 ISA I. ECE 4436ECE 5367 CPU = Seconds= Instructions x Cycles x Seconds Time Program Program Instruction Cycle CPU = Seconds= Instructions.
S. Barua – CPSC 440 CHAPTER 5 THE PROCESSOR: DATAPATH AND CONTROL Goals – Understand how the various.
COSC 3430 L08 Basic MIPS Architecture.1 COSC 3430 Computer Architecture Lecture 08 Processors Single cycle Datapath PH 3: Sections
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
Computer architecture Lecture 11: Reduced Instruction Set Computers Piotr Bilski.
Automobile Manufacturing 1. Build frame. 60 min. 2. Add engine. 50 min. 3. Build body. 80 min. 4. Paint. 40 min. 5. Finish.45 min. 275 min. Latency: Time.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 12 Overview and Concluding Remarks.
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
CSE 340 Computer Architecture Summer 2014 Basic MIPS Pipelining Review.
CS.305 Computer Architecture Enhancing Performance with Pipelining Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from.
Oct. 25, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Alternative Instruction Sets * Jeremy R. Johnson Wed. Oct. 25, 2000.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
1 A single-cycle MIPS processor  An instruction set architecture is an interface that defines the hardware operations which are available to software.
ECE 15B Computer Organization Spring 2011 Dmitri Strukov Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy,
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
Computer Organization Rabie A. Ramadan Lecture 3.
Oct. 18, 2000Machine Organization1 Machine Organization (CS 570) Lecture 4: Pipelining * Jeremy R. Johnson Wed. Oct. 18, 2000 *This lecture was derived.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Introduction to Computer Organization Pipelining.
Lecture 9. MIPS Processor Design – Pipelined Processor Design #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
CSCE 212 Chapter 6 Enhancing Performance with Pipelining Instructor: Jason D. Bakos.
MIPS Processor.
Pipelining: Implementation CPSC 252 Computer Organization Ellen Walker, Hiram College.
Lecture 17: 10/31/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Computer Architecture & Operations I
Computer Architecture & Operations I
Electrical and Computer Engineering University of Cyprus
Computer Organization
CS 230: Computer Organization and Assembly Language
CSCI206 - Computer Organization & Programming
Morgan Kaufmann Publishers
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Prof. Sirer CS 316 Cornell University
CS170 Computer Organization and Architecture I
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
CSCI206 - Computer Organization & Programming
COMS 361 Computer Organization
Computer Architecture
Prof. Sirer CS 316 Cornell University
COMP541 Datapaths I Montek Singh Mar 18, 2010.
COMS 361 Computer Organization
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
COMS 361 Computer Organization
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
MIPS Processor.
Presentation transcript:

Sample Undergraduate Lecture: MIPS Instruction Set Architecture Jason D. Bakos Optics/Microelectronics Lab Department of Computer Science University of Pittsburgh

University of PittsburghMIPS Instruction Set Architecture2 Outline Instruction Set Architecture MIPS ISA –Instruction set –Instruction encoding/representation –Example code Pipelining –Concepts –Hazards Pipeline enhancements: performance

University of PittsburghMIPS Instruction Set Architecture3 Instruction Set Architecture Instruction Set Architecture (ISA) –Usually defines a “family” of microprocessors Examples: Intel x86 (IA32), Sun Sparc, DEC Alpha, IBM/360, IBM PowerPC, M68K, DEC VAX –Formally, it defines the interface between a user and a microprocessor ISA includes: –Instruction set –Rules for using instructions Mnemonics, functionality, addressing modes –Instruction encoding ISA is a form of abstraction –Low-level details of microprocessor are “invisible” to user

University of PittsburghMIPS Instruction Set Architecture4 Instruction Set Architecture ISA => abstraction is a misnomer Many processor implementation details are revealed through ISA Example: –Motorola 6800 / Intel 8085 (1970s) 1-address architecture: ADDA (A) = (A) + (addr) –Intel x86 (1980s) 2-address architecture: ADD EAX, EBX (A) = (A) + (B) –MIPS (1990s) 3-address architecture: ADD $2, $3, $4 ($2) = ($3) + ($4) –Advancements in fabrication technology

University of PittsburghMIPS Instruction Set Architecture5 MIPS Architecture Design “philosophies” for ISAs: RISC vs. CISC Execution time = –instructions per program * cycles per instruction * seconds per cycle MIPS is implementation of a RISC architecture MIPS R2000 ISA –Designed for use with high-level programming languages small set of instructions and addressing modes, easy for compilers –Minimize/balance amount of work (computation and data flow) per instruction allows for parallel execution –Load-store machine large register set, minimize main memory access –fixed instruction width (32-bits), small set of uniform instruction encodings minimize control complexity, allow for more registers

University of PittsburghMIPS Instruction Set Architecture6 MIPS Instructions MIPS instructions fall into 5 classes: –Arithmetic/logical/shift/comparison –Control instructions (branch and jump) –Load/store –Other (exception, register movement to/from GP registers, etc.) Three instruction encoding formats: –R-type (6-bit opcode, 5-bit rs, 5-bit rt, 5-bit rd, 5-bit shamt, 6-bit function code) –I-type (6-bit opcode, 5-bit rs, 5-bit rt, 16-bit immediate) –J-type (6-bit opcode, 26-bit pseudo-direct address)

University of PittsburghMIPS Instruction Set Architecture7 MIPS Addressing Modes MIPS addresses register operands using 5-bit field –Example: ADD $2, $3, $4 MIPS addresses branch targets as signed instruction offset –relative to next instruction (“PC relative”) –in units of instructions (words) –held in 16-bit offset in I-type –Example: BEQ $2, $3, 12 Immediate addressing –Operand is help as constant (literal) in instruction word –Example: ADDI $2, $3, 64

University of PittsburghMIPS Instruction Set Architecture8 MIPS Addressing Modes (con’t) MIPS addresses jump targets as register content or 26-bit “pseudo-direct” address –Example: JR $31, J 128 MIPS addresses load/store locations –base register + 16-bit signed offset (byte addressed) Example: LW $2, 128($3) –16-bit direct address (base register is 0) Example: LW $2, 4092($0) –indirect (offset is 0) Example: LW $2, 0($4)

University of PittsburghMIPS Instruction Set Architecture9 Example Instructions ADD $2, $3, $4 –R-type A/L/S/C instruction –Opcode is 0’s, rd=2, rs=3, rt=4, func= – JALR $3 –R-type jump instruction –Opcode is 0’s, rs=3, rt=0, rd=31 (by default), func= – ADDI $2, $3, 12 –I-type A/L/S/C instruction –Opcode is , rs=3, rt=2, imm=12 –

University of PittsburghMIPS Instruction Set Architecture10 Example Instructions BEQ $3, $4, 4 –I-type conditional branch instruction –Opcode is , rs=00011, rt=00100, imm=4 (skips next 4 instructions) – SW $2, 128($3) –I-type memory address instruction –Opcode is , rs=00011, rt=00010, imm= – J 128 –J-type pseudodirect jump instruction –Opcode is , 26-bit pseudodirect address is 128/4 = 32 –

University of PittsburghMIPS Instruction Set Architecture11 Pseudoinstructions Some MIPS instructions don’t have direct hardware implementations –Ex: abs $2, $3 Resolved to: –bgez $3, pos –sub $2, $0, $3 –j out –pos: add $2, $0, $3 –out: … –Ex: rol $2, $3, $4 Resolved to: –addi $1, $0, 32 –sub $1, $1, $4 –srlv $1, $3, $1 –sllv $2, $3, $4 –or $2, $2, $1

University of PittsburghMIPS Instruction Set Architecture12 MIPS Code Example for (i=0;i<n;i++) a[i]=b[i]+10; xor $2,$2,$2# zero out index register (i) lw $3,n# load iteration limit sll $3,$3,2# multiply by 4 (words) li $4,a# get address of a (assume < 2 16 ) li $5,b# get address of b (assume < 2 16 ) loop:add $6,$5,$2# compute address of b[i] lw $7,0($6)# load b[i] addi $7,$7,10# compute b[i]=b[i]+10 add $6,$4,$2# compute address of a[i] sw $7,0($6)# store into a[i] addi $2,$2,4# increment i blt $2,$3,loop# loop if post-test succeeds

University of PittsburghMIPS Instruction Set Architecture13 Pipeline Implementation Idea: –Goal of MIPS: CPI <= 1 –Some instructions take longer to execute than others –Don’t want cycle time to depend on slowest instruction –Want 100% hardware utilization –Split execution of each instruction into several, balanced “stages” –Each stage is a block of combinational logic –Latency of each stage fits within 1 clock cycle –Insert registers between each pipeline stage to hold intermediate results –Execute each of these steps in parallel for a sequence of instructions –“Assembly line” This is called pipelining

University of PittsburghMIPS Instruction Set Architecture14 MIPS ISA MIPS pipeline stages –Fetch (F) read next instruction from memory, increment address counter assume 1 cycle to access memory –Decode (D) read register operands, resolve instruction in control signals, compute branch target –Execute (E) execute arithmetic/resolve branches –Memory (M) perform load/store accesses to memory, take branches assume 1 cycle to access memory –Write back (W) write arithmetic results to register file

University of PittsburghMIPS Instruction Set Architecture15 Hazards Hazards are data flow problems that arise as a result of pipelining –Limits the amount of parallelism, sometimes induces “penalties” that prevent one instruction per clock cycle –Structural hazards Two operations require a single piece of hardware Structural hazards can be overcome by adding additional hardware –Control hazards Conditional control instructions are not resolved until late in the pipeline, requiring subsequent instruction fetches to be predicted –Flushed if prediction does not hold (make sure no state change) Branchhazards can use dynamic prediction/speculation, branch delay slot –Data hazards Instruction from one pipeline stage is “dependant” of data computed in another pipeline stage

University of PittsburghMIPS Instruction Set Architecture16 Hazards Data hazards –Register values “read” in decode, written during write-back RAW hazard occurs when dependent inst. separated by less than 2 slots Examples: –ADD $2,$X,$X(E)ADD $2,$X,$X (M)ADD $2,$3,$4 (W) –ADD $X,$2,$X(D)…… –…ADD $X,$2,$X (D)… –……ADD $X,$2,$3 (D) –In most cases, data generated in same stage as data is required (EX) Data forwarding –ADD $2,$X,$X(M)ADD $2,$X,$X (W)ADD $2,$3,$4 (out-of-pipe) –ADD $X,$2,$X(E)…… –…ADD $X,$2,$X (E)… –……ADD $X,$2,$3 (E)

University of PittsburghMIPS Instruction Set Architecture17 “Load” Hazards Stalls required when data is not produced in same stage as it is needed for a subsequent instruction –Example: LW $2, 0($X) (M) ADD $X, $2(E) When this occurs, insert a “bubble” into EX state, stall F and D LW $2, 0($X) (W) NOOP (M) ADD $X, $2 (E) –Forward from W to E

University of PittsburghMIPS Instruction Set Architecture18 Pipelined Architecture fetchdecodeexecutememorywrite back

University of PittsburghMIPS Instruction Set Architecture19 Example add $6,$5,$2 lw $7,0($6) addi $7,$7,10 add $6,$4,$2 sw $7,0($6) addi $2,$2,4 blt $2,$3,loop add $6,$5,$2 FDEMW FDEMW FD EMW FDEMW FDEMW FDEMW FDEMW 13 FDEMW instructions, cycles, CPI =.73

University of PittsburghMIPS Instruction Set Architecture20 Pipeline Enhancements Assume we add branch predictor –Branch predictor success rate = 85% –Penalty for bad prediction = 3 cycles –Profiler tells us that 10% of instructions executed are branches –Branch speedup = (cycles before enhancement) / (cycles after enhancement) = 3 / [.15(3) +.85(1)] = 2.3 –Amdahl’s Law: –Speedup = 1 / ( /2.3) = 1.06 –6% improvement

University of PittsburghMIPS Instruction Set Architecture21 Summary Instruction Set Architecture –ISA is revealing (fabrication technology, architectural implementation) –MIPS ISA Pipelining –Pipeline concepts –Hazards –Example