Table of Contents

1. eSimu Simulation Integration
2. Full Simulation Estimation
3. Windowed Estimation

1. eSimu Simulation Integration

Information exchange between WSim and eSimu is based on traces. When compiled with eSimu mode, extra options for WSim are available. The main WSim option is the trace filename: --esimu=[filename]. The flow of information is illustrated on the next Figure.

eSimu integration in the simulation process

Figure III.1.  eSimu integration in the simulation process


From a standard WSim simulation script the only thing to add is the --esimu=[filename] that starts the eSimu trace recording tool.

	
#! /bin/sh

## =============Conf=====================
WSIM=wsim-wsn430-esimu
WTRC=wtracer

LOG="--logfile=wsim.log --verbose=2"
TRC="--trace=wsim.trc"
UI="--ui"
MODE="--mode=time --modearg=30s"

ESIMU=esimu-ng
CALIB=wsn430.conf
EOPT="--esimu=wsim.etr"
## ======================================

## ============ Simulation ==============
ELF=./wsn430-leds.elf
WS1="${WSIM} ${UI} ${MODE} ${LOG} ${TRC} ${EOPT} $-ELF"

xterm -T wsim-1 -e "${WS1}" 
## ======================================

## ============ Traces ==================
${WTRC} --in=wsim.trc --out=wsim.vcd --format=vcd
## ======================================
      

In order to gather power and cycle precises performance estimation from the execution traces a platform dependant configuration file is needed. A basic configuration file can be found for wsn430 models in the eSimu source repository:

	${git}/esimu/platforms/wsn430/wsn430.conf

Defining and refining a platform power consumption is rather easy but not all platforms have been described nor calibrated precisely at this time. The repository will be completed and users are encouraged to contribute if they refine platform models or can calibrate some of the files.

2. Full Simulation Estimation

Full simulation estimation is the easiest way to go. The --esimu-start option in WSim will start eSimu trace generation from the beginning and stop the trace at the end of the simulation.

To add full simulation trace the option can simply be added in the previous script at the following place:

	
EOPT="--esimu-start --esimu=wsim.etr"
    

Although full simulation traces are very easy to use they can generate huge files (hundreds of megabytes to gigabytes). The output is heavily buffered but still slows down the simulation.

3. Windowed Estimation

eSimu traces do not need to contain the whole execution path if you are only interested in portions of code. eSimu traces can be started and stopped from the embedded code using special instructions. This measurement mode explicitly adds instructions to the application binary and is thus intrusive. However the added instruction are chosen so that they do not have any side effect and are equivalent to a nop (no operation).

The MSP430 target has been modified to add eSimu start and stop capabilities. These two actions are available using the following code in your application:

      
#define ESIMU_START()   __asm__ __volatile__ ("mov r4,r4")
#define ESIMU_STOP()    __asm__ __volatile__ ("mov r5,r5")
    

These instructions are equivalent to a nop (a nop on the MSP430 is actually translated to MOV #0, R3.

eSimu start and stop calls can be used in a loop body or called multiple times within the same simulation.