This page explains the compilation, elaboration and run the UART project.
-
The first part of the bash script is the option clear. If entered, it must be the first parameter, as opposed to the other ones. If the switch is given, the GHDL compilation directory is removed.
Note: the shift command must follow, in case more switches are given by the user.
if [ "$1" = "clear" ] ; then
#clear any former compilation results
rm -fr work
shift
fi
-
Next the presence of the work directory is checked.
if [ -d "work" ] ; then
echo "work directory exists"
else
mkdir work
fi
-
Last before running GHDL commands, comes the input switches handling:
compilation skip, generate waves in VCD format and simulation run time.
Note: the usage of grep command to make sure a valid number was given. The output is piped to /dev/null and the status code, returned by grep, is checked.
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="./rx_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"
...
To return to the main project type:
Main .
|