CWRU EECS 322 March 8, 2000 The SPIM simulator EECS 322: Computer Architecture.

Slides:



Advertisements
Similar presentations
Lecture 9: MIPS Instruction Set
Advertisements

MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
Introduction to SPIM Simulator
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
SPIM Tutorial CSE 410 Computer Systems. Introduction SPIM: MIPS simulator –Reads/executes assembly source programs Does not execute binaries Download.
5Z032 Processor Design SPIM, a MIPS simulator Henk Corporaal
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
ECE 232 L6.Assemb.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 6 MIPS Assembly.
ELEN 468 Advanced Logic Design
SPIM and MIPS programming
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
MIPS Assembly Language Programming
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Ch. 8 Functions.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 4 Assembly Language Programming 2.
1 Computer Architecture MIPS Simulator and Assembly language.
The University of Adelaide, School of Computer Science
Procedure call frame: Hold values passed to a procedure as arguments
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
ECE 0142 Recitation #5.
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Assembly Language II CPSC 321 Andreas Klappenecker.
ECE 232 L7.Simul.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 7 MIPS Assembly.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
Intro to Computer Architecture
RISC Concepts, MIPS ISA and the Mini–MIPS project
Appendix A: MIPS Assembly Language. Instruction Format R-type I-type J-type.
CDA 3101 Fall 2012 Introduction to Computer Organization Instruction Set Architecture MIPS Instruction Format 04 Sept 2013.
Memory/Storage Architecture Lab Computer Architecture MIPS Instruction Set Architecture ( Supporting Procedures )
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
CWRU EECS 322 February 12, 2001 EECS 322 The SPIM simulator Instructor: Francis G. Wolff Case Western Reserve University This presentation.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 7: MIPS Instructions III
OCC - CS/CIS CS116-Ch00-Orientation Morgan Kaufmann Publishers ( Augmented & Modified by M.Malaty) 1CS 116 Fall 2003 Not quite finished Creating.
Procedure Basics Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Procedure Support From previous study of high-level languages,
R3000/001 Assembly Programming using MIPS R3000 CPU R3000 CPU Chip Manufactured by IDT What is MIPS R3000 Processor? A 32-bit RISC CPU developed by MIPS.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
EECS 322: Computer Architecture
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
Computer Architecture CSE 3322 Lecture 4 crystal.uta.edu/~jpatters/cse3322 Assignments due 9/15: 3.7, 3.9, 3.11.
All code must be commented! Each problem part (1,2,3a,3b,…) will be in a separate file: problem_1.s …. You may be asked to demonstrate your program. You.
CWRU EECS 3141 EECS 314: Load, Store, Arrays and Pointers Instructor: Francis G. Wolff Case Western Reserve University This presentation.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
1 Lecture 6: Assembly Programs Today’s topics:  Large constants  The compilation process  A full example  Intro to the MARS simulator.
Function Calling. Mips Assembly Call and Return Steps for procedure calling –Save the return address –Jump to the procedure (function) –Execute the procedure.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic4: Procedures José Nelson Amaral.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 12 Procedure Calling.
CWRU EECS 318 EECS 318 CAD Computer Aided Design LECTURE 7: Multicycle CPU Instructor: Francis G. Wolff Case Western Reserve University.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Lecture 7: MARS, Computer Arithmetic
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Assembly Programming using MIPS R3000 CPU
MIPS coding.
Instructions - Type and Format
MPIS Instructions Functionalities of instructions Instruction format
ECE232: Hardware Organization and Design
The University of Adelaide, School of Computer Science
Lecture 7: Examples, MARS, Arithmetic
MIPS function continued
COMS 361 Computer Organization
Assembly Programming using MIPS R3000 CPU
MIPS coding.
Computer Architecture
Introduction Lab1 A crash course in assembler programming
Program Assembly.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

CWRU EECS 322 March 8, 2000 The SPIM simulator EECS 322: Computer Architecture

CWRU EECS 322 March 8, 2000 Website and Homework Homework Website (temporary) Problems from book ( ) 5.1-2, 5.5-6, 5.9, , 5.24

CWRU EECS 322 March 8, 2000 Von Neuman & Harvard Architectures (PH p. 35) Harvard architecture was coined to describe machines with separate memories. Speed efficient: Increased parallelism. instructions data ALUI/OALUI/O instructions and data Data busAddress bus Von Neuman architecture Area efficient but requires higher bus bandwidth because instructions and data must compete for memory.

CWRU EECS 322 March 8, 2000 Recap: Single Cycle Implementation Calculate instruction cycle time assuming negligible delays except: –memory (2ns), ALU and adders (2ns), register file access (1ns) Single Cycle = 2 adders + 1 ALU + 4 muxes Adder1: PC  PC + 4 Adder2: PC  PC+signext(IR[15-0]) <<2 Adder3: Arithmetic ALU

CWRU EECS 322 March 8, 2000 Multi-cycle Datapath Multi-cycle= 5 Muxes + 1 ALU + Controller + 4 Registers (A,B,MDR,ALUOut) Single-cycle= 4 Muxes + 1 ALU + 2 adders

CWRU EECS 322 March 8, 2000 add= 6ns = Fetch(2ns)+RegR(1ns)+ALU(2ns)+RegW(2ns) lw= 8ns = Fetch(2ns)+RegR(1ns)+ALU(2ns)+MemR(2ns)+RegW(2ns) sw = 7ns = Fetch(2ns)+RegR(1ns)+ALU(2ns)+MemW(2ns) beq = 5ns = Fetch(2ns)+RegR(1ns)+ALU(2ns) j = 2ns = Fetch(2ns) Single/Multi-Clock Comparison Architectural improved performance without speeding up the clock!

CWRU EECS 322 March 8, 2000 Microprogramming: program overview Mem1Rformat1BEQ1JUMP1 Fetch Fetch+1 LW2SW2 LW2+1 Rformat1+1 Dispatch 1 Dispatch 2 T1T2T3T4T5T1T2T3T4T5

CWRU EECS 322 March 8, 2000 The Spim Simulator Spim download: ftp://ftp.cs.wisc.edu/pub/spim unix: ftp://ftp.cs.wisc.edu/pub/spim/spim.tar.gz win95: ftp://ftp.cs.wisc.edu/pub/spim/spimwin.exe Spim documentation Appendix A.9 SPIM Patterson & Hennessy pages A-38 to A75 ftp://ftp.cs.wisc.edu/pub/spim/spim_documentation.ps ftp://ftp.cs.wisc.edu/pub/spim/spimwin.ps Spim runnable code samples (Hello World.s, simplecalc.s,...) Other useful links Main document

CWRU EECS 322 March 8, 2000 MIPS registers and conventions Name Number Conventional usage $0 0 Constant 0 $v0-$v1 2-3 Expression evaluation & function results $a0-$a3 4-7 Arguments 1 to 4 $t1-$t9 8-15,24,35 Temporary (not preserved across call) $s0-$s Saved Temporary (preserved across call) $k0-$k Reserved for OS kernel $gp 28 Pointer to global area $sp 29 Stack pointer $fp 30 Frame pointer $ra 31 Return address (used by function call)

CWRU EECS 322 March 8, 2000 MIPS Register Name translation # calculate f = (g + h) - (i + j) (PH p. 109, file: simplecalc.s) Assember.sTranslated (1 to 1 mapping) addi$s1, $0, 5addi $17, $0, 5#g = 5 addi$s2, $0, -20addi $18, $0, -20#h = -20 addi$s3, $0, 13addi $19, $0, -20#i = 13 addi$s4, $0, 3addi $20, $0, 3#j = 3 add$t0, $s1, $s2add $8, $17, $18#$t0=g + h add$t1, $s3, $s4add $9, $19, $20#$t1=i + j sub$s0, $t0, $t1sub $16, $8, $9#f=(g+h)-(i+j)

CWRU EECS 322 March 8, 2000 System call 1: print_int $a0 System calls are used to interface with the operating system to provide device independent services. System call 1 converts the binary value in register $a0 into ascii and displays it on the console. This is equivalent in the C Language: printf(“%d”, $a0) Assember.sTranslated (1 to 1 mapping) li$v0, 1ori $2, $0, 1 #print_int (system call 1) add$a0,$0,$s0add $4,$0,$16 #put value to print in $a0 syscallsyscall

CWRU EECS 322 March 8, 2000 System Services Service Code Arguments Result print_int 1 $a0=integer print_float 2 $f12=float print_double 3 $f12=double print_string 4 $a0=string read_int 5 $v0=integer read_float 6 $f0=float read_double 7 $f0=double read_string 8 $a0=buf, $a1=len sbrk 9 $a0=amount $v0=address exit 10

CWRU EECS 322 March 8, 2000 System call 4: print_string $a0 System call 4 copies the contents of memory located at $a0 to the console until a zero is encountered This is equivalent in the C Language: printf(“%s”, $a0) Assember.sTranslated (1 to 1 mapping).data.globl msg3 msg3:.asciiz “\nThe value of f is: ”.text li$v0, 4ori $2, $0, 4 #print_string la$a0,msg3lui $4,4097 #address of string syscallsyscall Note the “z” in asciiz msg3 is just a label but must match

CWRU EECS 322 March 8, 2000.asciiz data representations.data: items are place in the data segment which is not the same the same as the.text segment ! Assember.s msg3:.asciiz “\nThe va” Same as in assembler.s msg3:.byte ‘\n’,’T’,’h’, ‘e’, ‘ ‘, ‘v’, ‘a’, 0 Same as in assembler.s msg3:.byte 0x0a, 0x54, 0x68, 0x65.byte 0x20, 0x76, 0x61, 0x00 Same as in assembler.s msg3:.word 0x a, 0x Translated in the.data segment: 0x a 0x Big endian format

CWRU EECS 322 March 8, 2000 Memory layout: segments Segments allow the operating system to protect memory Like Unix file systems:.text Execute only,.data R/W only.data segment.text segment Reserved.stack segment 0x x7fffffff.asciiz “The value of f is “ addi $17,0,5 addi $18,0,-20 $sp = top of stack

CWRU EECS 322 March 8, 2000 Hello, World: hello.s # main( ) { #printf(”\nHello World”\n”); # }.globl main main:#main has to be a global label addu$s7, $0, $ra#save the return address in a global reg..data.globlhello hello:.asciiz "\nHello World\n"#string to print.text li$v0, 4# print_str (system call 4) la$a0, hello# $a0=address of hello string syscall # Usual stuff at the end of the main addu$ra, $0, $s7#restore the return address jr$ra#return to the main program add$0, $0, $0#nop Note: alternating.text,.data,.text

CWRU EECS 322 March 8, 2000.globl main main:addu$s7, $0, $ra#save the return address addi$s1, $0, 5#g = 5 addi$s2, $0, -20#h = -20 addi$s3, $0, 13#i = 13 addi$s4, $0, 3#j = 3 add$t0, $s1, $s2#register $t0 contains g + h add$t1, $s3, $s4#register $t1 contains i + j sub$s0, $t0, $t1#f = (g + h) - (i + j) li$v0, 4#print_str (system call 4) la$a0, message # address of string syscall li$v0, 1#print_int (system call 1) add$a0, $0, $s0#put value to print in $a0 syscall addu$ra, $0, $s7#restore the return address jr$ra#return to the main program add$0, $0, $0#nop.data.globlmessage message:.asciiz "\nThe value of f is: "#string to print Simplecalc.s (PH p. 109) Order of.text and.data not important

CWRU EECS 322 March 8, 2000.text 0x addu$23, $0, $31# addu$s7, $0, $ra 0x addi$17, $0, 5# addi$s1, $0, 5 0x addi$18, $0, -20# addi$s2, $0, -20 0x c addi$19, $0, 13# addi$s3, $0, 13 0x addi$20, $0, 3# addi$s4, $0, 3 0x add$8, $17, $18# add$t0, $s1, $s2 0x add$9, $19, $20# add$t1, $s3, $s4 0x c sub$16, $8, $9# sub$s0, $t0, $t1 0x ori$2, 0, 4#print_str (system call 4) 0x lui$4, 0x # address of string 0x syscall 0x c ori$2, 1#print_int (system call 1) 0x add$4, $0, $16#put value to print in $a0 0x syscall 0x addu$31, $0, $23#restore the return address 0x c jr$31#return to the main program 0x add$0, $0, $0#nop.data 0x word 0x a, 0x6c617620, 0x6f word0x , 0x203a7369, 0x Simplecalc.s without symbols (PH p. 109)

CWRU EECS 322 March 8, 2000 Single Stepping $pc $t0$t1$s0$s1$s2$s3$s4$s7$ra $8$9 $16$17$18$19$20$23$ ???????? ??????? ???5??? c ???5ffffffec?? ???5ffffffec0d? ???5ffffffec0d ffffff1 ??5ffffffec0d? c ?10?5ffffffec0d? ??ffffffe15ffffffec0d? Values changes after the instruction!