diff --git a/run.sh b/run.sh index 5373cb0c3b692cbe4e4b881f813e19f7d8d59954..41cc768280cef026da551c1c8b8acbdaf391fd70 100755 --- a/run.sh +++ b/run.sh @@ -26,7 +26,14 @@ function main () { # Check if first arg was provided. if [[ $1 != "" ]] then - execute_single_file $@ + # Check that required number of args were provided. + if [[ $# -lt 8 ]] + then + # Not enough arguments. Display help. + display_help + else + execute_single_file $@ + fi else execute_all_files $@ fi @@ -62,16 +69,16 @@ function execute_single_file () { # Run input file on example cache simulator file. echo "" echo -e "${color_blue}Running input file on \"wmucachelab/csim-ref\". Runtime args:${color_reset}" - echo -e "${color_blue} -v -s 1 -E 2 -b 1 -t $file${color_reset}" -# ./wmucachelab/csim-ref -v -s 2 -E 1 -b 1 -t $file - ./wmucachelab/csim-ref -v -s 1 -E 2 -b 1 -t $file + echo -e "${color_blue} $@${color_reset}" + ./wmucachelab/csim-ref $@ +# ./wmucachelab/csim-ref -v -s 1 -E 2 -b 1 -t $file # Run input file on compiled C code. echo "" echo -e "${color_blue}Running input file on Python code. Runtime args:${color_reset}" - echo -e "${color_blue} -v -s 1 -E 2 -b 1 -t $file${color_reset}" -# python3 main.py -v -s 2 -E 1 -b 1 -t $file - python3 main.py -v -s 1 -E 2 -b 1 -t $file + echo -e "${color_blue} $@${color_reset}" + python3 main.py $@ +# python3 main.py -v -s 1 -E 2 -b 1 -t $file else echo -e "${color_red}Failed to determine absolute path for input file.${color_reset}" @@ -113,4 +120,23 @@ function get_absolute_path () { } +function display_help () { + echo "" + echo "Cache Simulator" + echo "Description:" + echo " Runs two cache simulator programs." + echo " First one is a premade, \"correct\" simulator with proper results." + echo " The second one is this custom Python implementation." + echo " Run one after another to compare results." + echo "" + echo "Options:" + echo " -s <#> Number of set bits for cache." + echo " -E <#> Number of lines per set for cache." + echo " -b <#> Number of block offset bits for cache." + echo " -t <file> Input file to use as trace." + echo " -v Optional verbose flag." + echo "" +} + + main $@