ID photo of Ciro Santilli taken in 2013 right eyeCiro Santilli OurBigBook logoOurBigBook.com  Sponsor 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
vhdl/run
#!/usr/bin/env bash

# No point in using Makefile, since we don't have
# one generated output per input without GCC.

set -e

cc='ghdl'
cflags='--std=08'
in_ext='.vhdl'
in_suffix='_tb'

get_prefix() {
  prefix="$1"
  prefix="${prefix%$in_ext}"
  prefix="${prefix%$in_suffix}"
  echo "$prefix"
}

analyze_or_run() {
  prefix="$(get_prefix "$1")"
  if [ -r "${prefix}${in_ext}" ]; then
    $cc -a $cflags "${prefix}${in_ext}"
  fi
  if [ -r "${prefix}${in_suffix}${in_ext}" ]; then
    $cc -a $cflags "${prefix}${in_suffix}${in_ext}"
    $cc -e $cflags "${prefix}${in_suffix}"
    $cc -r $cflags "${prefix}${in_suffix}" --assert-level=error --vcd="${prefix}.vcd"
  fi
}

$cc -a $cflags "common${in_ext}"
if [ $# -gt 0 ]; then
  analyze_or_run "$1"
else
  for f in *${in_suffix}${in_ext}; do
    echo "$f"
    analyze_or_run "$f"
  done
fi