From 48f36d23dd4a8e43b21c7fdbaa7abdcc0d40d4d4 Mon Sep 17 00:00:00 2001
From: Erik Kooistra <kooistra@astron.nl>
Date: Mon, 8 Jun 2015 13:55:15 +0000
Subject: [PATCH] Key hdl_lib_excludes now only applies to synthesis to avoid
 Modelsim compile error on library clause in e.g. tech_ddr_stratixiv.vhd.

---
 tools/oneclick/base/hdl_config.py      | 21 ++++++++++++---------
 tools/oneclick/base/modelsim_config.py |  6 ------
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/tools/oneclick/base/hdl_config.py b/tools/oneclick/base/hdl_config.py
index d20e8b26fe..e88cef3131 100644
--- a/tools/oneclick/base/hdl_config.py
+++ b/tools/oneclick/base/hdl_config.py
@@ -104,20 +104,23 @@ class HdlConfig:
     def get_used_libs(self, build_type, lib_dict, arg_exclude_libs=[]):
         """Get the list of used HDL libraries from the lib_dict and remove the excluded libs.
            - 'hdl_lib_uses_synth' and 'hdl_lib_uses_sim' define the used libraries that are directly used in this library
-           - 'hdl_lib_excludes' defines the libraries that must be excluded
+           - 'hdl_lib_excludes' defines the libraries that must be excluded for synthesis
         """
-        # use list() to take local copy, to avoid next that default empty list argument arg_exclude_libs=[] gets disturbed
-        exclude_libs = list(arg_exclude_libs)
+        # Get use_libs
         if 'hdl_lib_uses_synth' in lib_dict:
             use_libs = lib_dict['hdl_lib_uses_synth'].split()
         if build_type=='sim':
             if 'hdl_lib_uses_sim' in lib_dict:
-                use_libs += lib_dict['hdl_lib_uses_sim'].split()
-        if 'hdl_lib_excludes' in lib_dict:
-            exclude_libs += lib_dict['hdl_lib_excludes'].split()
-        for exclude_lib in exclude_libs:
-            if exclude_lib in use_libs:
-                use_libs.remove(exclude_lib)
+                use_libs += lib_dict['hdl_lib_uses_sim'].split()                
+        # For synthesis remove exclude_libs from use_libs
+        # use list() to take local copy, to avoid next that default empty list argument arg_exclude_libs=[] gets disturbed
+        exclude_libs = list(arg_exclude_libs)
+        if build_type=='synth':
+            if 'hdl_lib_excludes' in lib_dict:
+                exclude_libs += lib_dict['hdl_lib_excludes'].split()
+            for exclude_lib in exclude_libs:
+                if exclude_lib in use_libs:
+                    use_libs.remove(exclude_lib)
         return use_libs, exclude_libs
       
     def derive_all_use_libs(self, build_type, lib_name, arg_exclude_libs=[]):
diff --git a/tools/oneclick/base/modelsim_config.py b/tools/oneclick/base/modelsim_config.py
index 30ee59d199..b4a2b39d29 100755
--- a/tools/oneclick/base/modelsim_config.py
+++ b/tools/oneclick/base/modelsim_config.py
@@ -151,12 +151,6 @@ class ModelsimConfig(hdl_config.HdlConfig):
                 # . not used vendor technology libs are not compiled but are mapped to work to avoid compile error when mentioned in the LIBRARY clause
                 for tech_dict in self.removed_dicts:
                     fp.write('%s = work\n' % tech_dict['hdl_library_clause_name'])
-                # . excluded libs are not compiled but are mapped to work to avoid compile error when mentioned in the LIBRARY clause
-                if 'hdl_lib_excludes' in lib_dict:
-                    exclude_libs = lib_dict['hdl_lib_excludes'].split()
-                    for exclude_lib_name in exclude_libs:
-                        exclude_lib_dict = self.libs.get_dicts('hdl_lib_name', exclude_lib_name)
-                        fp.write('%s = work\n' % exclude_lib_dict['hdl_library_clause_name'])
                 # . all used libs for this lib_name
                 use_lib_names = self.derive_all_use_libs('sim', lib_name)
                 use_lib_dicts = self.libs.get_dicts('hdl_lib_name', use_lib_names)
-- 
GitLab