From 933cec71c6f0194c352b582d762511c2cbf5b87e Mon Sep 17 00:00:00 2001
From: Erik Kooistra <kooistra@astron.nl>
Date: Thu, 22 Sep 2016 15:00:30 +0000
Subject: [PATCH] Succesfully added toolset 'rsp' to be able to use RadioHDL
 flow with ISE and Modelsim for Lofar RSP board firmware development under
 Linux.

---
 tools/hdltool_rsp.cfg                  |  2 +-
 tools/ise/hdl_libraries_ip_virtex4.txt | 46 +++++++------------
 tools/ise/ise_generic.sh               | 48 ++++++++++++++++++++
 tools/ise/ise_version.sh               | 30 +++++++++++++
 tools/ise/run_ise                      | 30 +++++++++++++
 tools/ise/set_ise                      | 51 +++++++++++++++++++++
 tools/modelsim/set_modelsim            |  1 +
 tools/oneclick/doc/hdltool_readme.txt  | 61 ++++++++++++++++++++++++++
 tools/setup_radiohdl.sh                |  1 +
 9 files changed, 239 insertions(+), 31 deletions(-)
 create mode 100755 tools/ise/ise_generic.sh
 create mode 100755 tools/ise/ise_version.sh
 create mode 100755 tools/ise/run_ise
 create mode 100755 tools/ise/set_ise

diff --git a/tools/hdltool_rsp.cfg b/tools/hdltool_rsp.cfg
index 9bbe333b95..3d6906edc0 100644
--- a/tools/hdltool_rsp.cfg
+++ b/tools/hdltool_rsp.cfg
@@ -1,6 +1,6 @@
 toolset_name = rsp
 lib_root_dir = $RSP
-technology_names = 
+technology_names = ip_virtex4
 build_dir = $HDL_BUILD_DIR
 tool_name_sim = modelsim
 tool_name_synth = ise
diff --git a/tools/ise/hdl_libraries_ip_virtex4.txt b/tools/ise/hdl_libraries_ip_virtex4.txt
index dde33ea0aa..e8e4c08ce9 100644
--- a/tools/ise/hdl_libraries_ip_virtex4.txt
+++ b/tools/ise/hdl_libraries_ip_virtex4.txt
@@ -1,33 +1,19 @@
+# Used by modelsim_config.py to create library paths in the HDL library project files
 # VHDL
-#altera = $MODEL_TECH_ALTERA_LIB/vhdl_libs/altera
-#altera_lnsim = $MODEL_TECH_ALTERA_LIB/vhdl_libs/altera_lnsim
-#altera_mf = $MODEL_TECH_ALTERA_LIB/vhdl_libs/altera_mf
-#altgxbf = $MODEL_TECH_ALTERA_LIB/vhdl_libs/altgxb
-#lpm = $MODEL_TECH_ALTERA_LIB/vhdl_libs/lpm
-#sgate = $MODEL_TECH_ALTERA_LIB/vhdl_libs/sgate
-#stratix = $MODEL_TECH_ALTERA_LIB/vhdl_libs/stratix
-#stratixgx = $MODEL_TECH_ALTERA_LIB/vhdl_libs/stratixgx
-#stratixiv = $MODEL_TECH_ALTERA_LIB/vhdl_libs/stratixiv
-#stratixiv_hssi = $MODEL_TECH_ALTERA_LIB/vhdl_libs/stratixiv_hssi
-#stratixiv_pcie_hip = $MODEL_TECH_ALTERA_LIB/vhdl_libs/stratixiv_pcie_hip
-#altgxb = $MODEL_TECH_ALTERA_LIB/vhdl_libs/altgxb
-#stratixgx_gxb = $MODEL_TECH_ALTERA_LIB/vhdl_libs/stratixgx_gxb
+unisim = $MODEL_TECH_XILINX_LIB/vhdl/unisim
+unimacro = $MODEL_TECH_XILINX_LIB/vhdl/unimacro
+simprim = $MODEL_TECH_XILINX_LIB/vhdl/simprim
+xilinxcorelib = $MODEL_TECH_XILINX_LIB/vhdl/XilinxCoreLib
+secureip = $MODEL_TECH_XILINX_LIB/vhdl/secureip
+aim = $MODEL_TECH_XILINX_LIB/vhdl/abel/aim
+pls = $MODEL_TECH_XILINX_LIB/vhdl/abel/pls
+cpld = $MODEL_TECH_XILINX_LIB/vhdl/cpld
 
 # Verilog
-#altera_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/altera_ver
-#altera_lnsim_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/altera_lnsim_ver
-#altera_mf_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/altera_mf_ver
-#altgxb_ver =  $MODEL_TECH_ALTERA_LIB/verilog_libs/altgxb_ver
-#lpm_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/lpm_ver
-#sgate_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/sgate_ver
-#stratix_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratix_ver
-#stratixgx_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixgx_ver
-#stratixgx_gxb_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixgx_gxb_ver
-#stratixiigx_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixiigx_ver
-#stratixiigx_hssi_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixiigx_hssi_ver
-#stratixiv_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixiv_ver
-#stratixiv_hssi_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixiv_hssi_ver
-#stratixiv_pcie_hip_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixiv_pcie_hip_ver
-#stratixv_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixv_ver
-#stratixv_hssi_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixv_hssi_ver
-#stratixv_pcie_hip_ver = $MODEL_TECH_ALTERA_LIB/verilog_libs/stratixv_pcie_hip_ver
+unisims_ver = $MODEL_TECH_XILINX_LIB/verilog/unisims_ver
+unimacro_ver = $MODEL_TECH_XILINX_LIB/verilog/unimacro_ver
+uni9000_ver = $MODEL_TECH_XILINX_LIB/verilog/uni9000_ver
+simprims_ver = $MODEL_TECH_XILINX_LIB/verilog/simprims_ver
+xilinxcorelib_ver = $MODEL_TECH_XILINX_LIB/verilog/XilinxCoreLib_ver
+aim_ver = $MODEL_TECH_XILINX_LIB/verilog/aim_ver
+cpld_ver = $MODEL_TECH_XILINX_LIB/verilog/cpld_ver
diff --git a/tools/ise/ise_generic.sh b/tools/ise/ise_generic.sh
new file mode 100755
index 0000000000..da0e9b1795
--- /dev/null
+++ b/tools/ise/ise_generic.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+###############################################################################
+#
+# Copyright (C) 2014
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+echo "Run ise_generic.sh"
+
+# Derive generic ISE tool version related paths from $ISE_DIR that gets defined in ise_version.sh
+
+# Add to the $PATH, only once to avoid double entries
+pathadd ${ISE_DIR}/bin/lin
+
+#WARNING:Place:957 - Placer has detected that XIL_PLACE_ALLOW_LOCAL_BUFG_ROUTING has been set. This environment variable
+#   has been deprecated. An ERROR in clock placement rules can be demoted to a WARNING by using the CLOCK_DEDICATED_ROUTE
+#   constraint on a specific component pin in the .ucf file.
+
+#set XIL_PLACE_ALLOW_LOCAL_BUFG_ROUTING=1
+
+# ERROR:Pack:1653 - At least one timing constraint is impossible to meet because
+#    component delays alone exceed the constraint. A timing constraint summary
+#    below shows the failing constraints (preceded with an Asterisk (*)). Please
+#    use the Timing Analyzer (GUI) or TRCE (command line) with the Mapped NCD and
+#    PCF files to identify which constraints and paths are failing because of the
+#    component delays alone. If the failing path(s) is mapped to Xilinx components
+#    as expected, consider relaxing the constraint. If it is not mapped to
+#    components as expected, re-evaluate your HDL and how synthesis is optimizing
+#    the path. To allow the tools to bypass this error, set the environment
+#    variable XIL_TIMING_ALLOW_IMPOSSIBLE to 1.
+
+set XIL_TIMING_ALLOW_IMPOSSIBLE=1
+
diff --git a/tools/ise/ise_version.sh b/tools/ise/ise_version.sh
new file mode 100755
index 0000000000..ccf15a3f3b
--- /dev/null
+++ b/tools/ise/ise_version.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+###############################################################################
+#
+# Copyright (C) 2016
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+ISE_VERSION=${1}
+echo "Select ISE version: ${ISE_VERSION}"
+
+# Set path to ISE version
+export ISE_DIR=/home/software/Xilinx/ISE/${ISE_VERSION}/ISE
+
+# Select the path to the technology libraries that is used in the [libraries] section of the modelsim.ini
+export MODEL_TECH_XILINX_LIB=/home/software/modelsim_xilinx_libs/ise/${ISE_VERSION}
diff --git a/tools/ise/run_ise b/tools/ise/run_ise
new file mode 100755
index 0000000000..d45fcf6ad1
--- /dev/null
+++ b/tools/ise/run_ise
@@ -0,0 +1,30 @@
+#!/bin/bash
+###############################################################################
+#
+# Copyright (C) 2016
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+# General tool and project settings
+# - use '. <script>.sh' to have the settings apply in this shell, otherwise they get lost when <script>.sh returns
+
+# Tool settings for selected target "rsp" 
+. ${RADIOHDL}/tools/ise/set_ise ${1:-}
+
+# Start the ISE GUI
+ise
diff --git a/tools/ise/set_ise b/tools/ise/set_ise
new file mode 100755
index 0000000000..c68df06cc8
--- /dev/null
+++ b/tools/ise/set_ise
@@ -0,0 +1,51 @@
+#!/bin/bash
+###############################################################################
+#
+# Copyright (C) 2016
+# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
+# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+###############################################################################
+
+# Purpose: Map command line argument to a tool version
+# Description:
+#   By using command line arguments like "rsp" to select the tool
+#   version it is easier to manage combinations of tool versions.
+
+# General tool and project settings
+# - use '. <script>.sh' to have the settings apply in this shell, otherwise they get lost when <script>.sh returns
+
+# Select target
+TOOLSET=${1:-}
+echo "Make tool settings for RadioHDL with :"
+echo "  - Tool setting: ${TOOLSET}"
+echo "  - Site setting: ${SITE-}"
+
+# Select tool version
+if [ "${SITE-}" = "USN" ]; then
+  echo "Optionally use site dependent toolset for ${TOOLSET}"
+
+else # default site
+  if [ "${TOOLSET}" = "rsp" ]; then
+    . ${RADIOHDL}/tools/ise/ise_version.sh 10.1.03
+  else
+    echo "error: unknown tool setting: ${TOOLSET} (choose 'rsp')"
+    exit 1
+  fi
+fi
+
+# Tool settings
+. ${RADIOHDL}/tools/ise/ise_generic.sh
diff --git a/tools/modelsim/set_modelsim b/tools/modelsim/set_modelsim
index 68d843941a..1e3fda3fbf 100755
--- a/tools/modelsim/set_modelsim
+++ b/tools/modelsim/set_modelsim
@@ -64,6 +64,7 @@ else  # default site
     # Next line may be needed, but comment it if it yields ld.so errors
     export LD_PRELOAD=/home/software/freetype2/usr/lib/libfreetype.so
   elif [ "${TOOLSET}" = "rsp" ]; then
+    . ${RADIOHDL}/tools/ise/ise_version.sh 10.1.03
     . ${RADIOHDL}/tools/modelsim/modelsim_version.sh 6.6c
   else
     echo "error: unknown tool setting: ${TOOLSET} (choose 'rsp', 'unb1', 'unb2' or 'unb2a')"
diff --git a/tools/oneclick/doc/hdltool_readme.txt b/tools/oneclick/doc/hdltool_readme.txt
index 2f55e9dfc4..87ee2bc6ce 100644
--- a/tools/oneclick/doc/hdltool_readme.txt
+++ b/tools/oneclick/doc/hdltool_readme.txt
@@ -16,6 +16,7 @@ Contents:
   k) How to start Quartus for UNB
   l) UniBoard2 device family
   m) Upgrading the IP for new version of Quartus or for another device family
+  n) How to use RadioHDL for Lofar RSP
   
 3) HDL environment configuration files
   a) Tools and libraries
@@ -128,6 +129,7 @@ direct definition in the .bashrc are:
   - the environment setup script can be kept in SVN
   - it makes it easier to ensure that all users apply the same RadioHDL environment settings, because all source the same environment setup script
   - it avoids that the .bashrc gets cluttered with various definitions
+  - different versions of a tool can be started and run simultaneously
 
 Some environment variables need to be set in the .bashrc, because they are not kept the setup script in SVN:
   
@@ -443,7 +445,66 @@ and the try to simulate a design, eg.:
   - unb2_minimal
   
 
+n) How to use RadioHDL for Lofar RSP
+
+* The Lofar Station firmware is kept in a separate SVN repository at:
+
+    https://svn.astron.nl/Station
+    
+  The firmware for the RSP board is kept in:
+    
+    https://svn.astron.nl/Station/trunk/RSP
+    
+  In setup_radiohdl.sh add the path to the local SVN checkout of the Station
+  firmware:
+  
+    export RSP=${SVN}/../Station/trunk/RSP
+
+  and add ${RADIOHDL}/tools/ise to the PATH environment variable.
+    
+* To compile the Xilinx ISE10.1.03 models with Modelsim 6.6c under linux do:
   
+  The compxlib adds the Xilinx libraries to the [libraries] section in the 
+  /home/software/Mentor/6.6c/modeltech/modelsim.ini file. Therefore make
+  sure to first copy this original installation modelsim.ini file, so that
+  we can restore it.
+      
+    cd /home/software/modelsim_xilinx_libs/ise/10.1.03
+    sudo mkdir vhdl
+    sudo mkdir verilog
+    sudo /home/software/Xilinx/ISE/10.1/ISE/bin/lin/compxlib -s mti_se -f all -l vhdl    -dir vhdl    -p /home/software/Mentor/6.6c/modeltech/linux_x86_64
+    sudo /home/software/Xilinx/ISE/10.1/ISE/bin/lin/compxlib -s mti_se -f all -l verilog -dir verilog -p /home/software/Mentor/6.6c/modeltech/linux_x86_64
+
+  Use the library mappings in the modelsim.ini that was modified by compxlib
+  to create:
+  
+    tools/ise/create hdl_libraries_ip_virtex4.txt
+  
+  The modelsim_config.py using hdl_libraries_ip_virtex4.txt to map the Xilinx
+  library files in each HDL library project files. Therefore the central 
+  mapping in the Modelsim installation modelsim.ini file is unwanted and not
+  needed.
+
+* Create tools/hdltool_rsp.cfg HDL tool configuration dictionary file for toolset 'rsp'
+
+* Create bash scripts to start up ISE based on the toolset 'rsp' in tools/ise:
+    run_ise
+        \--> set_ise
+                \--> ise_version.sh
+                \--> ise_generic.sh
+                     
+  This is similar as for other tools like Modelsim, Quartus. The advantage of 
+  this approach is that the tool settings are only made when the tool is ran 
+  and not in the .bashrc file. These bash scripts are kept in SVN and thus the
+  same tool settings are used by all engineers.
+  
+* To start the ISE GUI do:
+  > run_ise rsp &
+  
+* To start the Modelsim GUI do:
+  > run_modelsim rsp &
+
+
 3) HDL environment configuration files
 
 a) Tools and libraries
diff --git a/tools/setup_radiohdl.sh b/tools/setup_radiohdl.sh
index 54886b8db8..32149229e9 100755
--- a/tools/setup_radiohdl.sh
+++ b/tools/setup_radiohdl.sh
@@ -52,6 +52,7 @@ export PATH=${PATH}:\
 ${UPE}/base:\
 ${UNB}/Firmware/software/build:\
 ${RADIOHDL}/tools/quartus:\
+${RADIOHDL}/tools/ise:\
 ${RADIOHDL}/tools/modelsim
 
 fi
-- 
GitLab