Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 (2003 ) 손재락 (20047046)

Slides:



Advertisements
Similar presentations
Instructor: Tor Aamodt
Advertisements

SimpleScalar Tutorial
Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
5Z032 Processor Design SPIM, a MIPS simulator Henk Corporaal
SPIM and MIPS programming
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
MIPS Assembly Language Programming
Ch. 8 Functions.
The University of Adelaide, School of Computer Science
Apr. 12, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 6: Branching and Procedures in MIPS* Jeremy R. Johnson Wed. Apr. 12, 2000.
Faculty of Computer Science © 2006 CMPUT 229 Why Computer Architecture? An Introduction to CMPUT 229.
ECE 0142 Recitation #5.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Calling Conventions See: P&H 2.8, 2.12.
Embedded Systems Programming Introduction to cross development techniques.
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
20/06/2015CSE1303 Part B lecture notes 1 Functions, part 2 Lecture B15 Lecture notes, section B15.
MIPS Assembler Programming
Chapter 6 Programming in Machine Language The LC-3 Simulator
Gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and.
SimpleScalar Tool Set, Version 2 CSE 323 Department of Computer Engineering.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture # 1 SPIM & MIPS Programming. SPIM SPIM is a MIPS32 simulator that reads and executes assembly language program written for SPIM. Platform -Unix,
Lec 4Systems Architecture1 Systems Architecture Lecture 4: Compilers, Assemblers, Linkers & Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:
Report1 Sim-profile 을 이용한 LI 벤치마크 과목명 : 컴퓨터 구조 특론 교수님 : 이상정 교수님 팀 원 : 강명숙, 박장수.
CDA 3101 Spring 2016 Introduction to Computer Organization
ECE 15B Computer Organization Spring 2011 Dmitri Strukov Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy,
1 간단한 C 프로그램 김희자, 최정욱. 2 목차 예제 소스 코드 컴파일 어셈블리 언어 Dlite 디버거 수행.
SimpleScalar 설치 및 사용법 순천향대학교 정보기술공학부 이상정.
CS252: Systems Programming Ninghui Li Based on Slides by Gustavo Rodriguez-Rivera Topic 2: Program Structure and Using GDB.
Instructor: Prof. Hany H Ammar, LCSEE, WVU
??? ple r B Amulya Sai EDM14b005 What is simple scalar?? Simple scalar is an open source computer architecture simulator developed by Todd.
Spec2000 Optimization Level Result Report 순천향대학교.
Computer Architecture & Operations I
Prof. Hsien-Hsin Sean Lee
순천향대학교 전산학과 SimpleScalar 예제 프로그램 순천향대학교 전산학과
Lecture 6: Assembly Programs
MIPS Instruction Set Advantages
Introduction to Lab #1 José Nelson Amaral.
CSCE 212Honors Computer Organization
Debugging with gdb gdb is the GNU debugger on our CS machines.
Homework Reading Machine Projects Labs PAL, pp ,
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
32-bit MIPS ISA.
Topic 2e High-Level languages and Systems Software
Adventures in Assembly Land
Prof. Hakim Weatherspoon
Instructions - Type and Format
Jeremy R. Johnson Wed. Apr. 5, 2000
ECE232: Hardware Organization and Design
MIPS coding.
The University of Adelaide, School of Computer Science
Computer Organization and Design Assembly & Simulation
Computer Organization and Design Assembly & Compilation
CNT4704: Analysis of Computer Communication Network Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Fall 2011.
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Systems Architecture I
Program and memory layout
MIPS I/O and Interrupt.
Assemblers, Linkers, and Loaders
10/6: Lecture Topics C Brainteaser More on Procedure Call
Where is all the knowledge we lost with information? T. S. Eliot
Generalities for Assembly Language
Adventures in Assembly Land
Adventures in Assembly Land
CSCE 212Honors Computer Organization
Assemblers, Linkers, and Loaders
Topic 2b ISA Support for High-Level Languages
Presentation transcript:

Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 (2003 ) 손재락 (20047046)

구현 환경 CPU : P-Ⅲ 866Mhz Memory : 256㎆ OS : Red Hat Linux 7.3 $DIR : /edu

설치 내용 시뮬레이터 : simplesim-3v0d GNU utilities : gnu binutils-2.5.2 C 컴파일러 : gcc-2.6.3

예제프로그램 fibo.c #include <stdio.h> #include <time.h> void fib2(int n); void input(); void main() { clock_t a,b; a = clock(); input(); b = clock(); printf("수행시간 = %f \n",(double)(b-a)/CLK_TCK); }

예제프로그램 void input() { int n; printf("몇번째 피보나찌 수열을 구하시겠습니까? : "); scanf("%d",&n); if(n<0) printf("ERROR : 0보다 큰정수를 입력해주세요..."); printf("\n몇번째 피보나찌 수열을 구하시겠습니까? : "); } fib2(n);

예제프로그램 void fib2(int n) { long f[1000]; f[0] = 0; if(n > 0) for(int i = 2; i<=n; i++) f[i] = f[i-1] + f[i-2]; } printf("%d\n",f[n]);

컴파일 예 sslittle-na-sstrix-gcc –o fibo.ss fibo.c sslittle-na-sstrix-gcc –S fibo.c cat fibo.s .file 1 "fibo.c" # GNU C 2.6.3 [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C # Cc1 defaults: # -mgas -mgpOPT # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1): # -quiet -dumpbase -o

컴파일 예 gcc2_compiled.: __gnu_compiled_c: .rdata .align 2 $LC0: .ascii "\274\366\307\340\275\303\260\243 = %f \n\000" .sdata .align 3 $LC1: .word 0x00000000 # 60 .word 0x404e0000 .text .globl main .end fib2

컴파일 예 $LC2: .ascii "\270\356\271\370\302\260 \307\307\272\270\263\252\302\356" .ascii " \274\366\277\255\300\273 \261\270\307\317\275\303\260\332" .ascii "\275\300\264\317\261\356? : \000" .sdata .align 2 $LC3: .ascii "%d\000" .rdata $LC4: .ascii "ERROR : 0\272\270\264\331 \305\253\301\244\274\366\270\246" .ascii " \300\324\267\302\307\330\301\326\274\274\277\344...\000" $LC5: .ascii "\n\270\356\271\370\302\260 \307\307\272\270\263\252\302\356"

컴파일 예 .text .align 2 .globl input .sdata $LC6: .ascii "%d\n\000" .globl fib2 .comm i,4 .loc 1 10 .ent main

컴파일 예 main: .frame $fp,32,$31 # vars= 8, regs= 2/0, args= 16, extra= 0 .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,32 sw $31,28($sp) sw $fp,24($sp) move $fp,$sp jal __main jal clock sw $2,16($fp) jal input sw $2,20($fp) lw $2,20($fp) lw $3,16($fp) subu $2,$2,$3 mtc1 $2,$f0 #nop

컴파일 예 cvt.d.w $f0,$f0 l.d $f2,$LC1 div.d $f0,$f0,$f2 la $4,$LC0 dmfc1 $6,$f0 jal printf $L1: move $sp,$fp # sp not trusted here lw $31,28($sp) lw $fp,24($sp) addu $sp,$sp,32 j $31 .end main .loc 1 20 .ent input input: .frame $fp,32,$31 # vars= 8, regs= 2/0, args= 16, extra= 0

컴파일 예 .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,32 sw $31,28($sp) sw $fp,24($sp) move $fp,$sp la $4,$LC2 jal printf la $4,$LC3 addu $5,$fp,16 jal scanf lw $2,16($fp) bgez $2,$L3 la $4,$LC4 la $4,$LC5

컴파일 예 $L3: lw $4,16($fp) jal fib2 $L2: move $sp,$fp # sp not trusted here lw $31,28($sp) lw $fp,24($sp) addu $sp,$sp,32 j $31 .end input .loc 1 34 .ent fib2 fib2: .frame $fp,4024,$31 # vars= 4000, regs= 2/0, args= 16, extra= 0 .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,4024

컴파일 예 sw $31,4020($sp) sw $fp,4016($sp) move $fp,$sp sw $4,4024($fp) lw $2,4024($fp) blez $2,$L5 li $2,0x00000001 # 1 sw $2,20($fp) li $2,0x00000002 # 2 sw $2,i $L6: lw $2,i lw $3,4024($fp) slt $2,$3,$2 beq $2,$0,$L9 j $L7 $L9:

컴파일 예 move $3,$2 sll $2,$3,2 addu $4,$fp,16 addu $3,$2,$4 move $2,$3 lw $3,i move $4,$3 sll $3,$4,2 addu $3,$3,$4 subu $4,$3,4 move $3,$4 lw $4,i move $5,$4 sll $4,$5,2 addu $5,$fp,16 addu $4,$4,$5 subu $5,$4,8 move $4,$5

컴파일 예 lw $3,0($3) lw $4,0($4) addu $3,$3,$4 sw $3,0($2) $L8: lw $3,i move $3,$2 sw $3,i j $L6 $L7: $L5: lw $2,4024($fp) sll $2,$3,2 addu $3,$fp,16 addu $2,$2,$3 la $4,$LC6

컴파일 예 lw $5,0($3) jal printf $L4: move $sp,$fp # sp not trusted here lw $31,4020($sp) lw $fp,4016($sp) addu $sp,$sp,4024 j $31 .end fib2

sim-safe 수행 예 /edu/simplesim-3.0/sim-safe fibo.ss > fibo2.txt sim-safe: SimpleScalar/PISA Tool Set version 3.0 of August, 2003. Copyright (c) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC. All Rights Reserved. This version of SimpleScalar is licensed for academic non-commercial use. No portion of this work may be used by any commercial entity, or for any commercial purpose, without the prior written permission of SimpleScalar, LLC (info@simplescalar.com). sim: command line: ./sim-safe ../bin/fibo.ss sim: simulation started @ Mon Apr 26 22:45:50 2004, options follow: sim-safe: This simulator implements a functional simulator. This functional simulator is the simplest, most user-friendly simulator in the simplescalar tool set. Unlike sim-fast, this functional simulator checks for all instruction errors, and the implementation is crafted for clarity rather than speed.

sim-safe 수행 예 # -config # load configuration from a file # -dumpconfig # dump configuration to a file # -h false # print help message # -v false # verbose operation # -d false # enable debug message # -i false # start in Dlite debugger -seed 1 # random number generator seed (0 for timer seed) # -q false # initialize and terminate immediately # -chkpt <null> # restore EIO trace execution from <fname> # -redir:sim <null> # redirect simulator output to file (non-interactive only) # -redir:prog <null> # redirect simulated program output to file -nice 0 # simulator scheduling priority -max:inst 0 # maximum number of inst's to execute sim: ** starting functional simulation ** 몇번째 피보나찌 수열을 구하시겠습니까? : 55 수행시간 = 0.000000

sim-safe 수행 예 sim: ** simulation statistics ** sim_num_insn 10969 # total number of instructions executed sim_num_refs 5180 # total number of loads and stores executed sim_elapsed_time 1 # total simulation time in seconds sim_inst_rate 10969.0000 # simulation speed (in insts/sec) ld_text_base 0x00400000 # program text (code) segment base ld_text_size 94944 # program text (code) size in bytes ld_data_base 0x10000000 # program initialized data segment base ld_data_size 12288 # program init'ed `.data' and uninit'ed `.bss' size in bytes ld_stack_base 0x7fffc000 # program stack segment base (highest address in stack) ld_stack_size 16384 # program initial stack size ld_prog_entry 0x00400140 # program entry point (initial PC) ld_environ_base 0x7fff8000 # program environment base address address ld_target_big_endian 0 # target executable endian-ness, non-zero if big endian

sim-safe 수행 예 mem.page_count 35 # total number of pages allocated mem.page_mem 140k # total size of memory pages allocated mem.ptab_misses 35 # total first level page table misses mem.ptab_accesses 644930 # total page table accesses mem.ptab_miss_rate 0.0001 # first level page table miss rate

Dlite! 디버거 사용 예 [kop98@kop simplesim-3.0]$ ./sim-safe -i ../bin/fibo.ss sim-safe: SimpleScalar/PISA Tool Set version 3.0 of August, 2003. Copyright (c) 1994-2003 by Todd M. Austin, Ph.D. and SimpleScalar, LLC. All Rights Reserved. This version of SimpleScalar is licensed for academic non-commercial use. No portion of this work may be used by any commercial entity, or for any commercial purpose, without the prior written permission of SimpleScalar, LLC (info@simplescalar.com). sim: command line: ./sim-safe -i ../bin/fibo.ss sim: simulation started @ Mon Apr 26 23:04:44 2004, options follow: sim-safe: This simulator implements a functional simulator. This functional simulator is the simplest, most user-friendly simulator in the simplescalar tool set. Unlike sim-fast, this functional simulator checks for all instruction errors, and the implementation is crafted for clarity rather than speed.

Dlite! 디버거 사용 예 # -config # load configuration from a file # -dumpconfig # dump configuration to a file # -h false # print help message # -v false # verbose operation # -d false # enable debug message # -i true # start in Dlite debugger -seed 1 # random number generator seed (0 for timer seed) # -q false # initialize and terminate immediately # -chkpt <null> # restore EIO trace execution from <fname> # -redir:sim <null> # redirect simulator output to file (non-interacti ve only) # -redir:prog <null> # redirect simulated program output to file -nice 0 # simulator scheduling priority -max:inst 0 # maximum number of inst's to execute sim: ** starting functional simulation ** [ 0] 0x00400140: lw r16,0(r29)

Dlite! 디버거 사용 예 DLite! > dis main 0x004001f0: addiu r29,r29,-32 0x004001f8: sw r31,28(r29) 0x00400200: sw r30,24(r29) 0x00400208: addu r30,r0,r29 0x00400210: jal 0x400728 0x00400218: jal 0x400950 0x00400220: sw r2,16(r30) 0x00400228: jal 0x4002c0 0x00400230: jal 0x400950 0x00400238: sw r2,20(r30) 0x00400240: lw r2,20(r30) 0x00400248: lw r3,16(r30) 0x00400250: subu r2,r2,r3 0x00400258: mtc1 r2,f0 0x00400260: cvt.d.w f0,f0 0x00400268: l.d f2,-32768(r28)

Dlite! 디버거 사용 예 DLite! > dis fib2 0x004003a0: addiu r29,r29,-4024 0x004003a8: sw r31,4020(r29) 0x004003b0: sw r30,4016(r29) 0x004003b8: addu r30,r0,r29 0x004003c0: sw r4,4024(r30) 0x004003c8: sw r0,16(r30) 0x004003d0: lw r2,4024(r30) 0x004003d8: blez r2,0x400510 0x004003e0: addiu r2,r0,1 0x004003e8: sw r2,20(r30) 0x004003f0: addiu r2,r0,2 0x004003f8: sw r2,-31744(r28) 0x00400400: lw r2,-31744(r28) 0x00400408: lw r3,4024(r30) 0x00400410: slt r2,r3,r2 0x00400418: beq r2,r0,0x400428

Dlite! 디버거 사용 예 DLite! > break 0x004^H^[[3~ Dlite: error: too many arguments DLite! > break 0x00400240 breakpoint #1 set @ @0x00400240:@0x00400241, class: exec DLite! > cont 몇번째 피보나찌 수열을 구하시겠습니까? : 10 55 Stopping at code breakpoint #1 @ 0x00400240... [ 9372] 0x00400240: lw r2,20(r30)

Dlite! 디버거 사용 예 DLite! > iregs PC: 0x00400238 NPC: 0x00400240 HI: 0x00025800 LO: 0x00020d00 FCC: 0x00000000 $r0: 0/0x00000000 $r1: 268435466/0x1000000a $r2: 3000/0x00000bb8 $r3: 0/0x00000000 $r4: 2400/0x00000960 $r5: 0/0x00000000 $r6: 0/0x00000000 $r7: 0/0x00000000 $r8: 600/0x00000258 $r9: 0/0x00000000 $r10: 0/0x00000000 $r11: 1342177280/0x50000000 $r12: 0/0x00000000 $r13: 0/0x00000000 $r14: 0/0x00000000 $r15: 2147446575/0x7fff6f2f $r16: 1/0x00000001 $r17: 2147450884/0x7fff8004 $r18: 2147450892/0x7fff800c $r19: 0/0x00000000 $r20: 0/0x00000000 $r21: 0/0x00000000 $r22: 0/0x00000000 $r23: 0/0x00000000 $r24: 5/0x00000005 $r25: 0/0x00000000 $r26: 0/0x00000000 $r27: 0/0x00000000 $r28: 268476480/0x1000a040 $r29: 2147450824/0x7fff7fc8 $r30: 2147450824/0x7fff7fc8 $r31: 4194872/0x00400238

Dlite! 디버거 사용 예 DLite! > step [ 9373] 0x00400248: lw r3,16(r30) [ 9374] 0x00400250: subu r2,r2,r3 DLite! > iregs PC: 0x00400248 NPC: 0x00400250 HI: 0x00025800 LO: 0x00020d00 FCC: 0x00000000 $r0: 0/0x00000000 $r1: 268435466/0x1000000a $r2: 3000/0x00000bb8 $r3: 3000/0x00000bb8 $r4: 2400/0x00000960 $r5: 0/0x00000000 $r6: 0/0x00000000 $r7: 0/0x00000000 $r8: 600/0x00000258 $r9: 0/0x00000000

Dlite! 디버거 사용 예 $r10: 0/0x00000000 $r11: 1342177280/0x50000000 $r14: 0/0x00000000 $r15: 2147446575/0x7fff6f2f $r16: 1/0x00000001 $r17: 2147450884/0x7fff8004 $r18: 2147450892/0x7fff800c $r19: 0/0x00000000 $r20: 0/0x00000000 $r21: 0/0x00000000 $r22: 0/0x00000000 $r23: 0/0x00000000 $r24: 5/0x00000005 $r25: 0/0x00000000 $r26: 0/0x00000000 $r27: 0/0x00000000 $r28: 268476480/0x1000a040 $r29: 2147450824/0x7fff7fc8 $r30: 2147450824/0x7fff7fc8 $r31: 4194872/0x00400238 DLite! > dump $r28-32416 0x100021a0: 00 00 00 00 00 00 00 40 00 00 00 00 00 00 f0 bf [.......@........] 0x100021b0: 00 00 00 00 00 00 f0 3f 00 00 00 00 00 00 00 40 [.......?.......@] 0x100021c0: 00 00 00 00 00 00 f0 bf 00 00 00 00 00 00 f8 ff [................] 0x100021d0: 9c 75 00 88 3c e4 37 7e 59 f3 f8 c2 1f 6e a5 01 [.u..<.7~Y....n..]

Dlite! 디버거 사용 예 DLite! > cont 수행시간 = 0.000000 sim: ** simulation statistics ** sim_num_insn 12740 # total number of instructions executed sim_num_refs 5848 # total number of loads and stores executed sim_elapsed_time 280 # total simulation time in seconds sim_inst_rate 45.5000 # simulation speed (in insts/sec) ld_text_base 0x00400000 # program text (code) segment base ld_text_size 94944 # program text (code) size in bytes ld_data_base 0x10000000 # program initialized data segment base ld_data_size 12288 # program init'ed `.data' and uninit'ed `.bs s' size in bytes ld_stack_base 0x7fffc000 # program stack segment base (highest addres s in stack) ld_stack_size 16384 # program initial stack size ld_prog_entry 0x00400140 # program entry point (initial PC)

Dlite! 디버거 사용 예 ld_environ_base 0x7fff8000 # program environment base address address ld_target_big_endian 0 # target executable endian-ness, non-zero if big endian mem.page_count 34 # total number of pages allocated mem.page_mem 136k # total size of memory pages allocated mem.ptab_misses 34 # total first level page table misses mem.ptab_accesses 654066 # total page table accesses mem.ptab_miss_rate 0.0001 # first level page table miss rate [kop98@kop simplesim-3.0]$