#!/bin/bash

prg=$0
if [ ! -e "$prg" ]; then
  case $prg in
    (*/*) exit 1;;
    (*) prg=$(command -v -- "$prg") || exit;;
  esac
fi
dir=$(
  cd -P -- "$(dirname -- "$prg")" && pwd -P
) || exit
prg=$dir/$(basename -- "$prg") || exit 

top=`echo "$prg" | sed 's/fmcmasterfip\/.*/fmcmasterfip/'`


"$top/scripts/wbgen2" \
  -P "$top/python/regs/masterfip_addrtable.py" \
  -D "$top/python/regs/masterfip_addrtable.htm" \
  -l vhdl \
  -V "$top/gateware/rtl/fmc_masterfip_csr_pts.vhd" \
  "$top/gateware/rtl/wbgen/fmc_masterfip_csr.wb"

"$top/scripts/wbgen2" \
  -D "$top/python/regs/carrier_addrtable.htm" \
  -P "$top/python/regs/carrier_addrtable.py" \
  "$top/gateware/rtl/wbgen/carrier_csr.wb"


