From e894e1796437afe7f7b92f504b364ef25a850422 Mon Sep 17 00:00:00 2001
From: Recolic Keghart <root@recolic.net>
Date: Mon, 3 Sep 2018 09:07:02 +0800
Subject: [PATCH] support new board

---
 gen_tcl.sh          | 11 +++++++++++
 template/Vivadofile |  3 +++
 vivado-wrapper      |  3 ++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gen_tcl.sh b/gen_tcl.sh
index 1d36ef5..fd8ce19 100755
--- a/gen_tcl.sh
+++ b/gen_tcl.sh
@@ -60,6 +60,17 @@ elif [[ $1 == gui ]]; then
     echo "open_project ${xpr}
     `find ${proj_dir}/*.srcs -regex '^.*\.s?vh?$' -exec echo add_files \{\} \;`
     start_gui"
+elif [[ $1 == init-project ]]; then
+    proj_name="$2"
+    proj_dir="$3"
+    part_name="$4" # xc7a100tcsg324-1
+    echo "# Generated by Vivado wrapper, licensed under GPL 3.0
+    # Copyright (C) Recolic Keghart <root@recolic.net>
+    create_project ${proj_name} ${proj_dir} -part ${part_name}
+    file mkdir ${proj_dir}/${proj_name}.srcs/constrs_1/new
+    close [ open ${proj_dir}/${proj_name}.srcs/constrs_1/new/constraint.xdc w ]
+    add_files -fileset constrs_1 ${proj_dir}/${proj_name}.srcs/constrs_1/new/constraint.xdc"
+    rm -f ${proj_dir}/${proj_name}.srcs/constrs_1/new/constraint.xdc
 else
     echo "Usage: $0 build <xpr path> <run_name_synth> <run_name_impl> <to_step> <top module name> <threads_num>
        $0 burn <xpr path> <run_name_impl> <top_module_name> <dev_name(Ex:xc7a100t_0)>"
diff --git a/template/Vivadofile b/template/Vivadofile
index 599d22e..8dae57e 100644
--- a/template/Vivadofile
+++ b/template/Vivadofile
@@ -22,6 +22,9 @@ top_modules=(
 # top_module=test_main
 top_module=
 
+# Name of your board in vivado
+board="xc7a100tcsg324-1"
+
 #
 # Optional options
 #
diff --git a/vivado-wrapper b/vivado-wrapper
index 6ae897c..b6fca66 100755
--- a/vivado-wrapper
+++ b/vivado-wrapper
@@ -132,12 +132,13 @@ function get_constraint_of_module () {
 function generate_real_project () {
     [[ "$constr_path" == '' ]] && constr_path="$(pwd)/$(get_constraint_of_module $top_module)"
     cp -r "$my_path/template/project" "$temp_dir/"
+    # todo: use new init-project to generate if template not exist
     _real_proj_src="$temp_dir/project/temp_project.srcs"
     for src in `echo ${sources[@]}`; do
         mkdir -p "$_real_proj_src/sources_1/new/$(dirname "$src")"
         ln -s "$(pwd)/$src" "$_real_proj_src/sources_1/new/$src"
     done
-    rm "$_real_proj_src/constrs_1/new/constraint.xdc"
+    rm -f "$_real_proj_src/constrs_1/new/constraint.xdc"
     ln -s "$constr_path" "$_real_proj_src/constrs_1/new/constraint.xdc"
     echo "real_project generated at $temp_dir"
 }
-- 
GitLab