#!/bin/sh

PROJECT="mips_top"
DIST_FILE="./files.dist"
DIST_DIR="./release/mips.r12"

# ---------------------------------------------------------------
mkdir -p $DIST_DIR/src
mkdir -p $DIST_DIR/sim
mkdir -p $DIST_DIR/doc
mkdir -p $DIST_DIR/bsp
mkdir -p $DIST_DIR/tools

cp -a ../bsp/* $DIST_DIR/bsp/
cp -a ../doc/*.pdf $DIST_DIR/doc/
cp -a ../doc/*.txt $DIST_DIR/doc/
cp -a ../tools/* $DIST_DIR/tools/

cp -a ./tmpl/notes.txt $DIST_DIR/
cp -a ./tmpl/gpl-3.0.txt $DIST_DIR/
cp -a ./tmpl/tb_mips_top.wdo $DIST_DIR/sim/
cp -a ./tmpl/hello.flash.bin $DIST_DIR/sim/
cp -a ./tmpl/mips_sys.vhd $DIST_DIR/src/

for i in $(cat -s $DIST_FILE); do
  echo $i;
  cp -a $i $DIST_DIR/src/
done;

# Delete CVS directories
rm -r $(find release/ -name CVS)

# ---------------------------------------------------------------
# Generate testbench do-file
echo "vlib work" > $DIST_DIR/sim/tb_$PROJECT.fdo

for i in $(cat -s $DIST_FILE); do
  echo "vcom -explicit  -93 \"../src/$(basename $i)\"" >> $DIST_DIR/sim/tb_$PROJECT.fdo
done;
echo "vsim -t 1ps -lib work tb_$PROJECT" >> $DIST_DIR/sim/tb_$PROJECT.fdo

echo "do {tb_mips_top.wdo}" >> $DIST_DIR/sim/tb_$PROJECT.fdo
echo "view wave" >> $DIST_DIR/sim/tb_$PROJECT.fdo
echo "view structure" >> $DIST_DIR/sim/tb_$PROJECT.fdo
echo "view signals" >> $DIST_DIR/sim/tb_$PROJECT.fdo
echo "run 1600us" >> $DIST_DIR/sim/tb_$PROJECT.fdo

# ---------------------------------------------------------------
