EECS 322 Computer Architecture The SPIM simulator CWRU
- Slides: 19
EECS 322: Computer Architecture The SPIM simulator CWRU EECS 322 March 8, 2000
Website and Homework Website (temporary) http: //sfo. ces. cwru. edu Problems from book (427 -432) 5. 1 -2, 5. 5 -6, 5. 9, 5. 14 -18, 5. 24 CWRU EECS 322 March 8, 2000
Von Neuman & Harvard Architectures (PH p. 35) ALU I/O Address bus ALU I/O Data bus instructions and instructions data Von Neuman architecture Area efficient but requires higher bus bandwidth because instructions and data must compete for memory. Harvard architecture was coined to describe machines with separate memories. Speed efficient: Increased parallelism. CWRU EECS 322 March 8, 2000
Recap: Single Cycle Implementation • Calculate instruction cycle time assuming negligible delays except: – memory (2 ns), ALU and adders (2 ns), register file access (1 ns) Adder 2: PC PC+signext(IR[15 -0]) <<2 Adder 1: PC + 4 Adder 3: Arithmetic ALU Single Cycle = 2 adders + 1 ALU + 4 muxes CWRU EECS 322 March 8, 2000
Multi-cycle Datapath Multi-cycle Single-cycle = 5 Muxes + 1 ALU + Controller + 4 Registers (A, B, MDR, ALUOut) = 4 Muxes + 1 ALU + 2 adders CWRU EECS 322 March 8, 2000
Single/Multi-Clock Comparison add = 6 ns = Fetch(2 ns)+Reg. R(1 ns)+ALU(2 ns)+Reg. W(2 ns) lw = 8 ns = Fetch(2 ns)+Reg. R(1 ns)+ALU(2 ns)+Mem. R(2 ns)+Reg. W(2 ns) sw = 7 ns = Fetch(2 ns)+Reg. R(1 ns)+ALU(2 ns)+Mem. W(2 ns) beq = 5 ns = Fetch(2 ns)+Reg. R(1 ns)+ALU(2 ns) j = 2 ns = Fetch(2 ns) Architectural improved performance without speeding up the clock! CWRU EECS 322 March 8, 2000
Microprogramming: program overview T 1 Fetch T 2 Fetch+1 Dispatch 1 T 3 Rformat 1 BEQ 1 JUMP 1 Mem 1 Dispatch 2 T 4 Rformat 1+1 T 5 LW 2 SW 2 LW 2+1 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. tar. gz win 95: ftp: //ftp. cs. wisc. edu/pub/spimwin. exe Main document Spim documentation Appendix A. 9 SPIM Patterson & Hennessy pages A-38 to A 75 ftp: //ftp. cs. wisc. edu/pub/spim_documentation. ps ftp: //ftp. cs. wisc. edu/pub/spimwin. ps Spim runnable code samples (Hello World. s, simplecalc. s, . . . ) http: //vip. cs. utsa. edu/classes/cs 2734 s 98/overview. html Other useful links http: //www. cs. wisc. edu/~larus/spim. html http: //www. cs. bilkent. edu. tr/~baray/cs 224/howspim 1. html CWRU EECS 322 March 8, 2000
MIPS registers and conventions Name $0 Number Conventional usage 0 Constant 0 $v 0 -$v 1 2 -3 Expression evaluation & function results $a 0 -$a 3 4 -7 Arguments 1 to 4 $t 1 -$t 9 8 -15, 24, 35 Temporary (not preserved across call) $s 0 -$s 7 16 -23 Saved Temporary (preserved across call) $k 0 -$k 1 26 -27 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. s Translated (1 to 1 mapping) addi $s 1, $0, 5 addi $17, $0, 5 #g = 5 addi $s 2, $0, -20 addi $18, $0, -20 #h = -20 addi $s 3, $0, 13 addi $19, $0, -20 #i = 13 addi $s 4, $0, 3 addi $20, $0, 3 #j = 3 add $t 0, $s 1, $s 2 add $8, $17, $18 #$t 0=g + h add $t 1, $s 3, $s 4 add $9, $19, $20 #$t 1=i + j sub $s 0, $t 1 sub $16, $8, $9 #f=(g+h)-(i+j) CWRU EECS 322 March 8, 2000
System call 1: print_int $a 0 • System calls are used to interface with the operating system to provide device independent services. • System call 1 converts the binary value in register $a 0 into ascii and displays it on the console. • This is equivalent in the C Language: printf(“%d”, $a 0) Assember. s Translated (1 to 1 mapping) li $v 0, 1 ori add $a 0, $s 0 add $4, $0, $16 #put value to print in $a 0 syscall $2, $0, 1 #print_int (system call 1) syscall CWRU EECS 322 March 8, 2000
System Services Service Code Arguments print_int 1 $a 0=integer print_float 2 $f 12=float Result print_double 3 $f 12=double print_string 4 $a 0=string read_int 5 $v 0=integer read_float 6 $f 0=float read_double 7 $f 0=double read_string 8 $a 0=buf, $a 1=len sbrk 9 $a 0=amount exit 10 $v 0=address CWRU EECS 322 March 8, 2000
System call 4: print_string $a 0 • System call 4 copies the contents of memory located at $a 0 to the console until a zero is encountered • This is equivalent in the C Language: printf(“%s”, $a 0) Assember. s. data. globl msg 3: Translated (1 to 1 mapping) Note the “z” in asciiz “n. The value of f is: ” . text msg 3 is just a label but must match li $v 0, 4 ori $2, $0, 4 #print_string la $a 0, msg 3 lui $4, 4097 #address of string syscall CWRU EECS 322 March 8, 2000
. asciiz data representations. data: items are place in the data segment which is not the same as the. text segment ! Assember. s msg 3: . asciiz “n. The va” Same as in assembler. s msg 3: . byte ‘n’, ’T’, ’h’, ‘e’, ‘ ‘, ‘v’, ‘a’, 0 Same as in assembler. s msg 3: . byte 0 x 0 a, 0 x 54, 0 x 68, 0 x 65. byte 0 x 20, 0 x 76, 0 x 61, 0 x 00 Same as in assembler. s msg 3: Big endian format . word 0 x 6568540 a, 0 x 00617620 Translated in the. data segment: 0 x 6568540 a 0 x 00617620 CWRU EECS 322 March 8, 2000
Memory layout: segments Reserved 0 x 00400000. text segment $sp = addi $17, 0, 5 addi $18, 0, -20 • • • . data segment top of . asciiz “The stack value of f is “. stack segment 0 x 7 fffffff • Segments allow the operating system to protect memory • Like Unix file systems: . text Execute only, . data R/W only CWRU EECS 322 March 8, 2000
Hello, World: hello. s # main( ) { # printf(”n. Hello World”n”); Note: alternating. text, . data, . text #}. globl main: #main has to be a global label addu $s 7, $0, $ra #save the return address in a global reg. . data. globl hello: . asciiz "n. Hello Worldn" #string to print. text li $v 0, 4 # print_str (system call 4) la $a 0, hello # $a 0=address of hello string syscall # Usual stuff at the end of the main addu $ra, $0, $s 7 #restore the return address jr $ra #return to the main program add $0, $0 #nop CWRU EECS 322 March 8, 2000
Simplecalc. s (PH p. 109) Order of. text and. data not important. globl main: addu $s 7, $0, $ra #save the return address addi $s 1, $0, 5 #g = 5 addi $s 2, $0, -20 #h = -20 addi $s 3, $0, 13 #i = 13 addi $s 4, $0, 3 #j = 3 add $t 0, $s 1, $s 2 #register $t 0 contains g + h add $t 1, $s 3, $s 4 #register $t 1 contains i + j sub $s 0, $t 1 #f = (g + h) - (i + j) li $v 0, 4 #print_str (system call 4) la $a 0, message # address of string syscall li $v 0, 1 #print_int (system call 1) add $a 0, $s 0 #put value to print in $a 0 syscall addu $ra, $0, $s 7 #restore the return address jr $ra #return to the main program add $0, $0 #nop. data. globl message: . asciiz "n. The value of f is: " #string to print CWRU EECS 322 March 8, 2000
Simplecalc. s without symbols (PH p. 109) 0 x 00400020 0 x 00400024 0 x 00400028 0 x 0040002 c 0 x 00400030 0 x 00400034 0 x 00400038 0 x 0040003 c 0 x 00400044 0 x 00400048 0 x 0040004 c 0 x 00400050 0 x 00400054 0 x 00400058 0 x 0040005 c 0 x 00400060 0 x 10010000 . text addu addi add sub ori lui syscall ori add syscall addu jr add. data. word $23, $0, $31 $17, $0, 5 $18, $0, -20 $19, $0, 13 $20, $0, 3 $8, $17, $18 $9, $19, $20 $16, $8, $9 $2, 0, 4 $4, 0 x 10010000 # addu $s 7, $0, $ra # addi $s 1, $0, 5 # addi $s 2, $0, -20 # addi $s 3, $0, 13 # addi $s 4, $0, 3 # add $t 0, $s 1, $s 2 # add $t 1, $s 3, $s 4 # sub $s 0, $t 1 #print_str (system call 4) # address of string $2, 1 $4, $0, $16 #print_int (system call 1) #put value to print in $a 0 $31, $0, $23 $31 $0, $0 #restore the return address #return to the main program #nop 0 x 6568540 a, 0 x 6 c 617620, 0 x 6 f 206575 0 x 2066, 0 x 203 a 7369, 0 x 0000 CWRU EECS 322 March 8, 2000
Single Stepping Values changes after the instruction! $pc $t 0 $8 $t 1 $9 $s 0 $16 $s 1 $17 $s 2 $18 $s 3 $19 $s 4 $20 $s 7 $23 $ra $31 00400020 ? ? 00400024 ? ? 400018 00400028 ? ? ? 5 ? ? ? 400018 0040002 c ? ? ? 5 ffffffec ? ? 400018 00400030 ? ? ? 5 ffffffec 0 d ? 400018 00400034 ? ? ? 5 ffffffec 0 d 3 400018 00400038 ffffff 1 ? ? 5 ffffffec 0 d ? 400018 0040003 c ? 10 ? 5 ffffffec 0 d ? 400018 0040 ? ? ffffffe 1 5 ffffffec 0 d ? 400018 CWRU EECS 322 March 8, 2000
- Spimsimulator
- Spim.sisa cloud
- Qcomments
- Spim vs spit
- I type mips
- Cwru safe ride
- Uhs cwru
- Myjourney cwru
- Cwru qualtrics
- Capstone meeting
- Case western reserve university case school of engineering
- Three bus architecture
- Apollo guidance computer emulator
- Computer hardware simulator
- Difference computer organization and architecture
- Register in computer organization
- Eee 322
- Me 322
- Ssis 322
- Mycin