ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

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

MIPS Instruction Reference

The MIPS Instruction Set Architecture

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

MIPS Reference Guide

EECE 417 Computer Systems Architecture

F. Appendix 6 MIPS Instruction Reference

MIPS Instruction Set

Project Part A: Single Cycle Processor

LECTURE 10. Pipelining: Advanced ILP

Final Project: MIPS-like Microprocessor

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

Computer Architecture. The Language of the Machine

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

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

CS 351 Exam 2 Mon. 11/2/2015

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

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

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

ECE Exam I February 19 th, :00 pm 4:25pm

Computer Architecture Experiment

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

MIPS Instruction Format

Mips Code Examples Peter Rounce

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC)

MIPS Instructions: 64-bit Core Subset

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

Q1: /30 Q2: /25 Q3: /45. Total: /100

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

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

ENE 334 Microprocessors

M2 Instruction Set Architecture

Computer Architecture. Chapter 3: Arithmetic for Computers


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

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

Midterm. Sticker winners: if you got >= 50 / 67

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

MIPS PROJECT INSTRUCTION SET and FORMAT

CS 4200/5200 Computer Architecture I

Flow of Control -- Conditional branch instructions

Alexandria University

RTL Model of a Two-Stage MIPS Processor

EE108B Lecture 3. MIPS Assembly Language II

Examples of branch instructions

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

MIPS Assembly Language. Today s Lecture

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

RISC Processor Design

CENG 3420 Lecture 06: Datapath

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Patrick Murray 4/17/2012 EEL4713 Assignment 5

TSK3000A - Generic Instructions

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

Review: MIPS Organization

The MIPS R2000 Instruction Set

Implementing the Control. Simple Questions

Lab 4 Report. Single Cycle Design BAOTUNG C. TRAN EEL4713C

For More Practice FMP

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

Programmable Machines

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

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

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

SPIM Instruction Set

Assembly Programming

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

Microprogramming. Microprogramming

bits 5..0 the sub-function of opcode 0, 32 for the add instruction

Programmable Machines

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

Computer Architecture

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

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

CS3350B Computer Architecture Winter 2015

Exam in Computer Engineering

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

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Instruction Set Principles. (Appendix B)

Materials: 1. Projectable Version of Diagrams 2. MIPS Simulation 3. Code for Lab 5 - part 1 to demonstrate using microprogramming

ece4750-parc-isa.txt

INSTRUCTION SET COMPARISONS

Programming the processor

Computer Architecture. MIPS Instruction Set Architecture

CS 61c: Great Ideas in Computer Architecture

RISC Design: Multi-Cycle Implementation

Instructions: Language of the Computer

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

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

Chapter 2. Instructions:

Materials: 1. Projectable Version of Diagrams 2. MIPS Simulation 3. Code for Lab 5 - part 1 to demonstrate using microprogramming

MIPS Assembly Language

CPE 335. Basic MIPS Architecture Part II

CS61C : Machine Structures

CS3350B Computer Architecture MIPS Instruction Representation

CS61c MIDTERM EXAM: 3/17/99

Transcription:

ICS 233 COMPUTER ARCHITECTURE MIPS Processor Design Multicycle Implementation Lecture 23 1 Add immediate unsigned Subtract unsigned And And immediate Or Or immediate Nor Shift left logical Shift right logical Load upper immediate Load word Store word Load byte Store byte Branch on equal (zero) Branch on not equal (zero) CPI in a Multicycle CPU Q) : Using the SPECINT2000 instruction mix shown in Figure, what is the CPI, assuming that each state in the multicycle CPU requires 1 clock cycle? Add Core MIPS Add immediate Add unsigned Name add addi addu addiu subu and andi or ori nor sll srl Lui lw sw lbu sb beq bne Integer 7% 12% 3% 3% 7% 2% 3% 2% 24% 9% FI.pt. 2 2% 2% 2% 5% 15% 2% Core MIPS Jump and link Jump register Set less than Set less than immediate Set less than unsigned Set less than imm. Uns. Arithmetic core + MIPS-32 FP add double FP subtract double FP mutiply double FP divide double Load word to FP double Store word to FP double Shift right arithmetic Load half Branch less than zero 6% Lecture Slides 2% on Computer 5% multiply Branch greater or equal zero Branch less or equal zero Name jal Jr Slt Slti Sltu Sltiu Name add.d sub.d mul.d div.d l.d s.d sra lhu bltz bgez blez mul Integer 2% Integer FI.pt. FI.pt. 8% 3% 8% 15% 7% 2 1

CPI in a Multicycle CPU Given the number of clock cycles for each instruction class : Loads: 5 Stores: 4 ALU instructions: 4 Branches: 3 Jumps: 3 From the figure, the integer mix is 25% loads ( load byte + 24% load word), 1 stores ( store byte + 9% store word), 1 branches (6% beq, 5% bne), 2% jumps ( jal + jr), and 52% ALU (all the rest of the mix, which we assume to be ALU instructions). 3 Multi-Cycle Implementation CPU clock cycles = Instruction count i x CPI i The CPI is given by the following: CPI = CPU Clock Cycles = instruction count i x CPI i Instruction count Instruction count The ratio instruction count i Instruction count is simply the instruction frequency for the instruction class i Hence we can write, CPI = 0.25 x 5 + 0.10 x 4 + 0.52 x 4 + 0.11 x 3 + 0.02 x 3 = 4.12 This CPI is better than the worst-case CPI of 5.0 when all the instructions take the same number of clock cycles. The multicycle design is probably also more cost-effective, since it uses fewer separate components in the datapath. 4 2

Multi-Cycle Implementation - Control Defining the Control Two different techniques to specify the control. Finite State Machines (FSMs) : The first technique is based on finite state machines that graphically. are usually represented Micrprogramming : The second technique, called microprogramming, uses a programming representation for control. Both of these techniques represent the control in a form that allows the detailed implementation using gates, ROMs, or PLAs to be synthesized by a CAD system. 5 Multi-Cycle Implementation Control Alternate methods for specifying and implementing control 6 3

Multi-Cycle Control - FSM Finite State Machine (FSM) to specify the multicycle control A finite state machine consists of a set of states and directions on how to change states. The directions are defined by a next-state function, which maps the current state and the inputs to a new state. When we use a finite state machine for control, each state also specifies a set of outputs that are asserted when the machine is in that state. The implementation of a finite state machine usually assumes that all outputs that are not explicitly asserted are deasserted. Similarly, the correct operation of the datapath depend on the fact that a signal that is not the explicitly asserted is deasserted, rather than acting as a don t care. 7 Multi-Cycle Control - FSM The finite state control essentially corresponds to the five steps of execution. Each state in the finite state machine will take 1 clock cycle. The finite state machine will consist of several parts. Since the first two steps of execution are identical for every instruction, the initial two states of the finite state machine will be common for all instructions. Step 3 through 5 differ, depending on the opcode. After the execution of the last step for a particular instruction class, the finite state machine will return to the initial state to begin fetching the next instruction. The finite state machine has four arcs existing state 1, corresponding to the four instruction classes: memory reference, R-type, branch on equal, and jump. This process of branching to different states depending on the instruction is called decoding, since the choice of the next state, and hence the actions that follow, depend on the instruction class. 8 4

Multi-Cycle Control - FSM High level view of the Finite State Machine Control 9 Multi-Cycle Implementation - Control State 0 State 1 10 5

Multi-Cycle Implementation - Control From State 1 State 2 State 3 State 5 State 4 To State 0 11 Multi-Cycle Implementation - Control From State 1 State 6 State 7 Lecture Slides on To Computer State 0 12 6

Multi-Cycle Implementation - Control From State 1 State 8 To State 0 13 Multi-Cycle Implementation - Control From State 1 State 9 To State 0 14 7

Multi-Cycle Control - FSM State 0 State 1 State 2 State 6 State 8 State 9 State 3 State 5 State 7 State 4 Complete Finite State Machine Control for the datapath 15 Multi-Cycle Control - FSM A finite state machine can be implemented with a temporary register that holds the current state and a block of combinatorial logic that determines both the datapath signals to be asserted as well as the next state. The combinatorial control logic for the finite state machine of the figure is implemented both with a ROM (read-only memory) and a PLA (programmable logic array). The style of finite state machine in the figure is called a Moore machine, after Edward Moore. Its identifying characteristics is that the output depends only on the current state. For a Moore machine, the box labeled combinatorial control logic can be split into two pieces. One piece has the control output and only the state input, while the other has only the next-state output. 16 8

Multi-Cycle Control - FSM Finite State Machine Controller 17 Multi-Cycle Implementation An alternative style of machine is a Mealy machine, named after George Mealy. The Mealy machine allows both the input and the current state to be used to determine the output. Moore machines have potential implementation advantages in speed and size of the control unit. The speed advantages arise because the control outputs, which are needed early in the clock cycle, do not depend on the inputs, but only on the current state. 18 9

Multi-Cycle Implementation Exceptions An exception is an unexpected event from within the processor; Example : arithmetic overflow An interrupt is an event that also causes an unexpected change in control flow but comes from outside of the processor. Type of event I/O device request Invoke the operating system from user program Arithmetic overflow Using an undefined instruction Hardware malfunctions From where? External Internal Internal Internal Either MIPS terminology Interrupt Exception Exception Exception Exception or interrupt 19 Multi-Cycle Implementation - Exceptions How Exceptions Are Handled The two types of exceptions that our current implementation can generate are execution of an undefined instruction and an arithmetic overflow. The basic action that the machine must perform when an exception occurs is to save the address of the offending instruction in the exception program counter (EPC) and then transfer control to the operating system at some specified address. The operating system can then take the appropriate action, which may involve providing some service to the user program, taking some predefined action in response to an overflow, or stopping the execution of the program and reporting an error. After performing whatever action is required because of the exception, the operating system can terminate the program or may continue its execution, using the EPC to determine where to restart the execution of the program. 20 10

Multi-Cycle Implementation - Exceptions For the operating system to handle the exception, it must know the reason for the exception, in addition to the instruction that caused it. There are two main methods used to communicate the reason for an exception. The method used in the MIPS architecture is to include a status register (called the Cause register), which holds a field that indicates the reason for the exception. A second method is to use vectored interrupts. In a vectored interrupt, the address to which control is transferred is determined by the cause of the exception. For example, to accommodate the two exception types, we define the following two exception vector addresses: Exception type Undefined instruction Arithmetic overflow Exception vector address ( in hex) C000 0000 hex C000 0020 hex 21 Multi-Cycle Implementation - Exceptions The operating system knows the reason for the exception by the address at which it is initiated. The addresses are separated by 32 bytes or 8 instructions, and the operating system must record the reason for the exception and may perform some limited processing in this sequence. When the exception is not vectored, a single entry point for all exceptions can be used, and the operating system decodes the status register to find the cause. We can perform the processing required for exceptions by adding a few extra registers and control signals to our basic implementation and by slightly extending the finite state machine. 22 11

Multi-Cycle Implementation - Exceptions Need to add two additional registers to the datapath: EPC: A 32-bit register used to hold the address of the affected instruction. (Such a register is needed even exceptions are vectored.) Cause: A register used to record the cause of the exception. In the MIPS architecture, this register is 32- bits, although some bits are currently unused. Assume that the low-order bit of this register encodes the two possible exception sources: undefined instruction = 0 and arithmetic overflow =1. 23 Multi-Cycle Implementation - Exceptions need to add two control signals to cause the EPC and Cause registers to be written; call these EPCWrite and CauseWrite. In addition, we will need a 1-bit control signal to set the loworder bit of the Cause register appropriately; call this signal IntCause. Finally, we will need to be able to write the exception address, which is the operating system entry point for exception handling, into the PC; in the MIPS architecture, this address is 8000 0180 hex. (the SPIM simulator for MIPS uses 8000 0080 hex.) Currently, the PC is fed from the output of a three-way multiplexor, which is controlled by the signal PCSource. We can change this to a four-way multiplexor, with additional input wired to the constant value 8000 0180 hex. Then PCSource can be set to 11 two to select this value to be written into the PC. 24 12

Multi-Cycle Implementation - Exceptions Because the PC is incremented during the first cycle of every instruction, we cannot adjust the value of the PC into the EPC, since the value in the PC will be the instruction address plus 4. However, we can use the ALU to subtract 4 from the PC and write the output into the EPC. This requires no additional control signals or paths, since we can use the ALU to subtract, and the constant 4 is already a selectable ALU input. The data write port of the EPC, therefore, is connected to the ALU output. 25 Multi-Cycle Implementation Exceptions Multicycle datapath wih the addition needed to implement exceptions 26 13

Multi-Cycle Implementation- Exceptions State 0 State 1 State 2 State 6 State 8 State 9 State 3 State 5 State 7 State 11 State 10 State 4 FSM with the additional states to handle exception detection 27 Reading Assignments Chapter 5 : Sections 5.1 to 5.9 Also Refer CD 28 14