
#!/bin/sh

# The following environment variables must be set at the command line.
# TIMING_FILE=filename
# Filename does not have extensions.
#
# TIMING_CACHE_SIZE=cache_size
# cache size can be 'null' or 'none'
#
# TIMING_OUTPUT_DIRECTORY=directory
# This is where all the output files will be created.
#
# The verbose flag for the timing analyser.
# VERBOSE=-v
VERBOSE=

# This is the pcompiler part.
cd pcompiler
pcompiler $TIMING_FILE.s $TIMING_FILE
cd ..

# Now copy the .path file to the 'staticsim' directory and the .inf
# file to the 'mod_timing' directory.
cp pcompiler/$TIMING_FILE.path staticsim/
cp pcompiler/$TIMING_FILE.inf C++TA/Expts/

# The staticsim part
cd staticsim
staticsim -t $TIMING_FILE > static_temp.txt 2>&1
epilogue < $TIMING_FILE.ist > temp.ist
cp temp.ist ../C++TA/Expts/$TIMING_FILE.ist
cd ../C++TA/Expts/

# The Timing Analyser part
echo "---------------------------------------------" > $TIMING_OUTPUT_DIRECTORY/outputs_$TIMING_FILE\_$TIMING_CACHE_SIZE.txt
echo "Timing Analysis Results." >> $TIMING_OUTPUT_DIRECTORY/outputs_$TIMING_FILE\_$TIMING_CACHE_SIZE.txt
echo "Filename = $TIMING_FILE.s" >> $TIMING_OUTPUT_DIRECTORY/outputs_$TIMING_FILE\_$TIMING_CACHE_SIZE.txt
echo "Cache Size = $TIMING_CACHE_SIZE" >> $TIMING_OUTPUT_DIRECTORY/outputs_$TIMING_FILE\_$TIMING_CACHE_SIZE.txt
echo "---------------------------------------------" >> $TIMING_OUTPUT_DIRECTORY/outputs_$TIMING_FILE\_$TIMING_CACHE_SIZE.txt
time.bin $VERBOSE $TIMING_FILE >> $TIMING_OUTPUT_DIRECTORY/outputs_$TIMING_FILE\_$TIMING_CACHE_SIZE.txt 2>&1
