#!/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" \
  -D "$top/python/regs/carrier_addrtable.htm" \
  -P "$top/python/regs/carrier_addrtable.py" \
  "$top/gateware/rtl/wbgen/carrier_csr.wb"

"$top/scripts/wbgen2" \
  -D "$top/python/regs/masterfip_csr.htm" \
  -P "$top/python/regs/masterfip_csr.py" \
  -l vhdl \
  -V "$top/gateware/rtl/wbgen/masterfip_csr.vhd" \
  "$top/gateware/ip_cores/gw-masterfip/rtl/wbgen/masterfip_csr.wb"

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

