Compiling and Running Your Own Programs
Assuming that you have installed Simics as detailed in the Simics installation guide, this page will guide you through compiling and executing an example program on Simics. We will use the example programs put up to help you get started, which can be found as indicated the files page.
Building an example program
- Decide on a local directory to build in; we will assume that you use ~/compsys for the rest of these instructions.
- Copy the example files into ~/compsys.
- Make sure the script run.sh is marked as executable.
- Do make example_timer to build the timer example.
host$ make example_timer /it/kurs/compsys/mips-devel/bin/mips-idt-elf-gcc -EL -G0 -mips32 -ggdb -Wall -Werror -I/it/kurs/compsys/HT2004//include -o example_timer.o -c example_timer.c /it/kurs/compsys/mips-devel/bin/mips-idt-elf-gcc -EL -G0 -mips32 -ggdb -Wall -Werror -I/it/kurs/compsys/HT2004//include -o asm.o -c asm.S /it/kurs/compsys/mips-devel/bin/mips-idt-elf-gcc -EL -G0 -mips32 -ggdb -Wall -Werror -I/it/kurs/compsys/HT2004//include -o debug.o -c debug.c /it/kurs/compsys/mips-devel/bin/mips-idt-elf-ld -Ttext 80020000 -EL -G0 -mips32 -o example_timer example_timer.o asm.o debug.o
- Check the results:
host$ ls asm.o example_timer.c* run.sh~* asm.S* example_timer.elf* run.sh* debug.c* example_timer.o run.simics~* debug.o example_uart.c* run.simics* example_syscall.c* i8259.c* syscall.S* example_timer* Makefile*
- Note that we have a new file called "example_timer".
Run the program in Simics
We have provided a simple mechanism to help you run programs in Simics, in the form of the run.sh script. To use this to run the program you just compiled, do the following:
- Set the environment variable $SIMICS to the location of your Simics installation. For bash, assuming that simics is installed in the standard location, you do:
host$ export SIMICS=~/simics
- Then use the run.sh script to start a Simics with example_timer as the program to run:
host$ ./run.sh example_timer
- This will start a Simics running the example timer program you just built.
If you want to use this mechanism from other directories, you need to copy the files run.sh and run.simics to the new directory.