Assignment 1: Pipelining Implementation at SPIM Simulator

Similar documents
QtSPIM and MARS : MIPS Simulators

Computer Systems and Architecture

SPIM Instruction Set

MIPS and QTSPIM Recap. MIPS Architecture. Cptr280. Dr Curtis Nelson. Cptr280, Autumn

MIPS Architecture and Assembly Language Overview

Assembly labs start this week. Don t forget to submit your code at the end of your lab section. Download MARS4_5.jar to your lab PC or laptop.

ECE 250 / CS 250 Computer Architecture. Procedures

SPIM & MIPS Programming

MIPS Processor Overview

MIPS function continued

COMP2421 COMPUTER ORGANZATION. Lab 3

Review Session 1 Fri. Jan 19, 2:15 pm 3:05 pm Thornton 102

MIPS Assembly Language Guide

MIPS Assembly Language Programming

Course Administration

MIPS Assembly (Functions)

MIPS Assembly Language Programming

SPIM & MIPS Programming

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

Patterson PII. Solutions

EECS 322 The SPIM simulator

MIPS Assembly Programming

Graduate Institute of Electronics Engineering, NTU. SPIM and MIPS Asm. Presenter: 沈文中 (TA) Date: 2004/10/13

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

SPIM & MIPS. Department of Information and Management. Computer Organization and Structure 年 9 月 29 日星期 一

CS 316: Procedure Calls/Pipelining

MIPS Assembly Language

MIPS (SPIM) Assembler Syntax

USING A SIMULATOR. QUICK INTRODUCTION From various sources For cs470

MIPS Assembly (FuncDons)

Computer Architecture

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

CS3350B Computer Architecture Quiz 3 March 15, 2018

COE608: Computer Organization and Architecture

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

Introduction to MIPS Processor

CS3350B Computer Architecture MIPS Introduction

CS232 Final Exam May 5, 2001

MIPS Assembly (FuncDons)

ECE 30 Introduction to Computer Engineering

ECE 473 Computer Architecture and Organization Project: Design of a Five Stage Pipelined MIPS-like Processor Project Team TWO Objectives

Fibonacci Numbers. An Exercise in Assembly Language Programming. Andreas Klappenecker. September 7, 2004

CS3350B Computer Architecture

OPEN BOOK, OPEN NOTES. NO COMPUTERS, OR SOLVING PROBLEMS DIRECTLY USING CALCULATORS.

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Lecture 7: Examples, MARS, Arithmetic

CENG3420 Lecture 03 Review

CSE 378 Final Exam 3/14/11 Sample Solution

MIPS Functions and Instruction Formats

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

COMPUTER ORGANIZATION AND DESIGN

Common Problems on Homework

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

MIPS Procedure Calls. Lecture 6 CS301

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

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

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

CSCE 513 Computer Architecture, Fall 2018, Assignment #2, due 10/08/2018, 11:55PM

Introduction to Assembler Language Programming

Compiling Techniques

Homework 2 - Solutions (Assembly Language and Machine Language) Maximum points : 40 points

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number

Lecture 6: Assembly Programs

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

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

Programming with QtSpim: A User s Manual

Computer Architecture Homework #1 Due: September 7, 2007 (F) (4 PM in ITT 305 mailbox or under my office door, ITT 313)

Computer Systems and Networks

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

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

Control Instructions

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number

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

Assembler. Lecture 8 CS301

CSc 256 Midterm 1 Fall 2011

Solutions for Chapter 2 Exercises

More C functions and Big Picture [MIPSc Notes]

MIPS Assembly Language

Field 6-Bit Op Code rs Field rt Field 16-bit Immediate field

Pipelining and Caching. CS230 Tutorial 09

ECE/CS 314 Fall 2003 Homework 2 Solutions. Question 1

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

CS 110 Computer Architecture MIPS Instruction Formats

/ : Computer Architecture and Design Fall Midterm Exam October 16, Name: ID #:

Thomas Polzer Institut für Technische Informatik

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

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

Chapter 3. Instructions:

ECE 3056: Architecture, Concurrency, and Energy of Computation. Sample Problem Sets: Pipelining

CSE/EEE 230 Computer Organization and Assembly Language

Homework 4 - Solutions (Floating point representation, Performance, Recursion and Stacks) Maximum points: 80 points

ECE Sample Final Examination

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

MIPS Reference Guide

Lecture 7: MIPS Functions Part 2. Nested Function Calls. Lecture 7: Character and String Operations. SPIM Syscalls. Recursive Functions

EN164: Design of Computing Systems Lecture 11: Processor / ISA 4

CSE 378 Midterm Sample Solution 2/11/11

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Transcription:

Assignment 1: Pipelining Implementation at SPIM Simulator Due date: 11/26 23:59 Submission: icampus (Report, Source Code) SPIM is a MIPS processor simulator, designed to run assembly language code for this architecture. Although the MIPS architecture is designed to support the pipelining, the current version of SPIM does not support the pipelining. In this project, you must modify the SPIM simulator such that it can output the number of cycles required to complete all the instructions in an input assembly code. Requirements Use the 5-stage (IF, ID, EX, MEM, and WB) in-order single issue MIPS pipelined architecture described in the text book. Assume no cache miss, i.e., the latency of each instruction is 5 cycles if there are no pipeline stalls by hazard. Arithmetic and logical instructions determine the value of destination register in the EX stage. Load and store instructions determine the value of destination register in the MEM stage. The decision of branch (direction/target) and jump (target address) are determined in the ID stage. Use the 'static not-taken' policy for branch prediction. The pipelined version must detect data and control hazards and must calculate the required execution cycles considering the forwarding and pipeline stalls. Process only the core instructions and the two additional instructions (lb, mul). https://inst.eecs.berkeley.edu/~cs61c/resources/mips_green_sheet.pdf A pseudo-instruction such as blt and move will be translated into a core instruction by SPIM. See CPU/parser.y. Treat the syscall as nop. Even if the last instruction does not update any register at the WB stage (e.g. syscall, sw, b, and j), the program can be complete after the WB stage of the instruction. So, you need to count the 5 cycles of syscall to output the total number of execution cycles. Don t count the cycles consumed before entering the main function. Use our Homework Linux server! SPIM Source Code Download The SPIM source code can be downloaded from the following site. Download the Linux version. http://pages.cs.wisc.edu/~larus/spim/spim.html

It can be easily downloaded through the following command. $ wget http://www.cs.wisc.edu/~larus/spim/spim.tar.gz After downloading the code, two programs (spim and xspim) are provided. Only spim is used in this assignment. How to Build SPIM 1. Go to the spim directory. 2. Modify the Configure file. Change the path of libc.a as shown below. 3. Run make command. You must set the path of "EXCEPTION_DIR" as shown in the figure. How to Use SPIM SPIM supports the following two modes. Use the default mode (asm) to simulate pseudo-instructions.

Options -bare : simulate a bare MIPS machine without pseudo-instruction or the additional modes provided by the assembler -asm : simulate the virtual MIPS machine provided by assembler (This is the default) -file [assembly_file] : load and execute the assembly code in the file In this assignment, we use only the following command. $./spim -file [filename] Assembler Syntax Comment : begin with # Label : at the beginning of the line followed by a colon String : enclosed in double-quotes( ) Special characters : follow C convention SPIM start execution from main label. Directives.text <addr> : text segments.data <addr> : data segments.ascii str : string.asciiz str : null-terminated string.byte b1, b2,, bn : byte.double,.float : floating point.half,.word : integer System Calls ($v0) Service Code Arguments Result print_int 1 $a = integer print_float 2 $f12 = float print_double 3 $f12 = double print_string 4 $a0 = string read_int 5 integer (in $v0) read_float 6 float (in $f0) read_double 7 double (in $f0) read_string 8 $a0 = buffer, $a1 = length sbrk 9 $a0 = amount address (in $v0) exit 10

Example Example file (fib.s) main:.text li $a0,1 jal fib li $v0,10 syscall # execution starts here # call fib # exit() fib: sub $sp,$sp,12 # save registers on stack sw $a0,0($sp) sw $s0,4($sp) sw $ra,8($sp) bgt $a0,1,notone move $v0,$a0 # fib(0)=0, fib(1)=1 j fret # if n<=1 notone: sub $a0,$a0,1 # param = n-1 jal fib # compute fib(n-1) move $s0,$v0 # save fib(n-1) sub $a0,$a0,1 # set param to n-2 jal fib # and make recursive call add $v0,$v0,$s0 # add fib(n-2) fret: lw $a0,0($sp) # restore registers lw $s0,4($sp) lw $ra,8($sp) add $sp,$sp,12 jr $ra Execution history

Execution result of SPIM (It must be added to your report) Program execution order 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ori $4, $0, 1 IF ID EX MEM WB jal 0x00400034 IF ID EX MEM WB addi $29, $29, -12 IF ID EX MEM WB sw $4, 0($29) IF ID EX MEM WB sw $16, 4($29) IF ID EX MEM WB sw $31, 8($29) IF ID EX MEM WB slti $1, $4, 2 IF ID EX MEM WB beq $1, $0, 12 IF ID EX MEM WB addu $2, $0, $4 IF ID EX MEM WB j 0x0040006c IF ID EX MEM WB lw $4, 0($29) IF ID EX MEM WB lw $16, 4($29) IF ID EX MEM WB lw $31, 8($29) IF ID EX MEM WB addi $29, $29, 12 IF ID EX MEM WB jr $31 IF ID EX MEM WB ori $2, $0, 10 IF ID EX MEM WB syscall IF ID EX MEM WB How to Connect to Homework Server You can use an SSH (Secure SHell) client program to connect to the homework server. You can use any kind of SSH client. Recommended SSH clients are: For Windows, recommended SSH client is putty. Download Link: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html For macos or Linux, use ssh command on a shell. You can connect to the homework server as following: In case of putty (Windows): 1. Input IP address (115.145.178.78) and port number (1100), then press Open button.

2. In the case that a security alert appears, press Yes or 예 button to allow the connection. 3. Input your ID and password. ID is a string combined with s and your student ID (ex. s2017123456). Initial password is same as your ID. 4. If it is first connection, you have to change your password.

In case of ssh command (macos, Linux): 1. Run ssh command with three arguments (ID, IP address and port number) on a shell. ID is a string combined with s and your student ID (ex. s2017123456). 2. In the case that a security alert appears, input yes to allow the connection. 3. Input your password. Initial password is same as your ID. 4. If it is first connection, you have to change your password. What to Submit (Deadline: 11/26 23:59) Report The report should be written in PDF file (*.pdf). How to Submit: Rename the report into yourstudentid.pdf and upload it at icampus. The report should: analyze the SPIM simulator and explain how it works. describe the modifications from the original SPIM simulator code. explain how to calculate the number of cycles. show the results of the example codes, fib.s, count.s, and hello.s.

[IMPORTANT] Do not just write, use the pictures appropriately. If the report file cannot be opened with a pdf reader, you will get no points. The source code of modified SPIM simulator For the sake of fairness, you must use our homework server. All the commands on the homework server will be logged, which can be used to hunt out cheating. Don t upload the final source code after you edit it at your PC. You have to use the Linux editor (vi or vim) in Homework Server. We will check the log file. How to Submit: Make an archive file (yourstudentid.zip) of your source code and leave it on your home folder of homework server. You don t need to submit the code to icampus. I will regard the modified time (ctime) of yourstudentid.zip as the submission time. For all the program blocks (functions, loops, if-then-else, etc) and the variables that you implemented, you should add proper comments. If enough comments are not provided, I will not give any points. You don t need to add comments on the given source code of SPIM simulator which you did not make. The output of the simulator is the number of cycles required to perform for a given assembly file. Remove the executable files and submit it $ make clean Notice If I would find two or more source codes which are much alike, all the corresponding students will fail this course. At the Homework server, we can monitor all your operations such as shell commands and logging IP. So, we can secure evidence of your cheating. If your program satisfies only a subset of the specified requirements, you can get a partial point. To get a partial point, specify the list of complete functions of your program. One day delay has -20 points penalty. If you have any questions, send e-mail to or visit TA (lhy920806@gmail.com, room# 85465).