#!/bin/bash #clear - removes the compilation directory before start #no_comp - skips compilation #vcd run with vcd #200 run 200 us. This is an optioanlly parameter. Default is 100 us. if [ "$1" = "clear" ] ; then #clear any former compilation results rm -fr work shift fi if [ -d "work" ] ; then echo "work directory exists" else mkdir work fi comp_skip="no" ghdl_vcd="no" ghdl_time="100" #build the simulation command while (( "$#" )); do if [ "$1" = vcd ] ; then ghdl_vcd="yes" else if [ "$1" = "no_comp" ] ; then comp_skip="yes" else #checks for time validity - has to be a number echo $1 | grep "^[0-9]*$" >> /dev/null if [ $? -eq 0 ] ; then ghdl_time=$1 fi fi fi shift done ghdl_run="./tx_tb --stop-time="${ghdl_time}"us --assert-level=error" if [ "$ghdl_vcd" = "yes" ] ; then ghdl_run=${ghdl_run}" --vcdgz=ghdl.vcd.gz" fi ghdl_run=${ghdl_run}" >& ghdl.log" if [ "$comp_skip" = "yes" ] ; then #If compilation is skipped, run can only start if the executable exists. ls -l tx_tb > /dev/null else ghdl -a --ieee=synopsys --workdir=work --work=work ../RTL/tx.vhd ../TB/tx_tb.vhd > cmp.log fi if [ $? -eq 0 ] ; then #compilation ended or need to be skipped if [ -e "tx_tb" ] ; then #erase the executable file, if it exists rm -f tx_tb fi ghdl -e --workdir=work --ieee=synopsys tx_tb if [ -e "tx_tb" ] ; then echo "compilation and elaboration ended okay" eval $ghdl_run fi else less cmp.log fi