advent-of-code/2020/day2/vhdl/run.sh

27 lines
797 B
Bash
Executable file

#!/usr/bin/bash
set -eu
INPUT=$(readlink --canonicalize-existing "$1")
MODE=${2:-}
workdir=workdir
GHDLFLAGS="--std=08 --workdir=$workdir"
cd "$(dirname "${BASH_SOURCE[0]}")"
mkdir -p workdir
if [[ $MODE = "--synth" ]]; then
for step in 1 2; do
ghdl remove $GHDLFLAGS
ghdl synth $GHDLFLAGS -gCOUNTER_WIDTH=12 -gSTEP="$step" parser.vhd verifier.vhd top.vhd -e top > top_syn.vhd 2>/dev/null
ghdl analyze $GHDLFLAGS top_syn.vhd sim.vhd day2.vhdl
ghdl elab-run $GHDLFLAGS day2 -gSTEP="$step" --wave="$workdir/synth$step.ghw" --ieee-asserts=disable < "$INPUT"
done
else
ghdl remove $GHDLFLAGS
ghdl analyze $GHDLFLAGS parser.vhd verifier.vhd top.vhd sim.vhd day2.vhd
for step in 1 2; do
ghdl elab-run $GHDLFLAGS day2 -gSTEP="$step" --wave="$workdir/sim$step.ghw" < "$INPUT"
done
fi