Lab 7: Introduction to Instruction Set Simulators
Introduction
An instruction set simulator reads in an executable program and simulates the execution of that program. Then based on the simulation, will output various information about the execution (e.g. address trace, cache performance, etc...).
Intel 8051 Simulator
The following is a high level simulator for the Intel 8051 written in C++. The simulator allows a user to simulate simple programs written for the 8051. The simulator provides statistics on instructions executed, instructions executed per second, execution cycles required by the 8051, and average instructions per second for an 8051 executing the same program. The following are not supported: input ports, interrupts, movx instructions.
Source Files
i8051.h
i8051.cc
main.cc
Makefile
8051sim.tar.gz (Contains all files)
Test Files
negcnt.c
negcnt.hex
P0 = 64, 65, 66, 67, 68, 69, 70, 71, 72, 73
gcd.c
gcd.hex
P0 = 36, 25, 14, 3, 1
int2bin.c
int2bin.hex
P0 = 0, 1, 0, 1, 0, 1, 0, 1
cast.c
cast.hex
P0 = 01H, P1 = 23H, P2 = 45H, P3 = 67H
divmul.c
divmul.hex
P0 = 10, 4, 134
fib.c
fib.hex
P0 = 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
sort.c
sort.hex
P0 = 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
sqroot.c
sqroot.hex
P0 = 9, P1 = 16, P2 = 25, P3 = 5
xram.c
xram.hex
/I8051_XRM/XRAM(...) = 1, 2, 3, 4, ...
How to Use the Instruction Set Simulatior
Modes
To use the simulator, edit i8051.h and uncomment
the PORTS, DEBUG, DEBUG_PC, and/or DETAIL macros to enable the respective
output. Modify the macro PROGRAM_COMPLETION to the appropriate completion condition. If
there is no program completion condition do not define PROGRAM_COMPLETION.
If defined, a trace of all instructions executed
by the simulator will be outputted to the output file
specified by the user.
If defined and DEBUG is defined the PC for each
instruction executed will be outputted to the output file.
If defined, anytime one of the output ports of
the 8051 changes all ports will be printed out.
The simulator will continue executing the provided program until either the
user hit Ctrl-C or the program completion condition is met. The program
completion condition can be set by defining a macro PROGRAM_COMPLETION
located in i8051.h to indicate the program
completion condition, e.g., RAM[P0] == 0x01.
If defined, more information regarding each
instruction will outputted to the output file.
SimpleScalar
SimpleScalar is a suite of tools consisting of a compiler, assembler, linker, and simulation environment for the SimpleScalar architecture. The SimpleScalar architecture is a superset of the MIPS architecture. SimpleScalar takes a binary compiled for the SimpleScalar architecute and simulates it's exeuction on one of the several procesor simulators provided.
Compilation
This has been taken care of for you. The corresponding output are the .out files.
Generating an Assembly File
Generating a Trace File
Simulators
Functional Simulator
NAME
DESCRIPTION
sim-fast
The fastest, least detailed simulator which does no time
accounting, only functional simulation. It executes each
instruction serially, simulating no instructions in
parallel. It is optimized for raw speed, assumes no caches
or instruction checking.
sim-safe
This simulator also performs functional simulation, but
checks for correct alignment and access permissions for
each memory reference.
Cache Simulator
NAME
DESCRIPTION
sim-cache
Functional cache simulator. The simulator enables the
user to specify various cache configurations and outputs
the performacne of the cache.
sim-cheetah
Functional cache simulator based on the Cheetah cache
simulator. The Cheetah engine simulates multiple cache
configurations with a single simulation. It also
simulates fully associative caches efficently.
Profiler
NAME
DESCRIPTION
sim-profile
Functional simulator that produces profile information. It
can generate detailed profiles on instruction classes and
addresses, text symbols, memory accesses, branches, and
data segment symbols.
To run any of the simulators:
For more information on SimpleScalar and additional flags for various simulators you can refer to the Technical Report.
Lab Objective
You should try using both the 8051 simulator and simplescalar. This
is your chance to familiarize yourself with these tools, so if you
need to use them in later projects you'll have an advantage.
8051 Simulator
SimpleScalar