diff --git a/core/modelsim_config b/core/modelsim_config
index 4d61e7cff5f45e2cd32a13d6399155398fee1a25..7f1fb06bb9c927f33cc168c573c291a1ab5596d5 100755
--- a/core/modelsim_config
+++ b/core/modelsim_config
@@ -231,9 +231,21 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
                     for lib_clause, lib_work in tech_dict.items():
                         fp.write('%s = %s\n' % (lib_clause, lib_work))
 
+                # . all used libs for this lib_name
+                use_lib_names          = self.derive_all_use_libs('sim', lib_name)
+                use_lib_dicts          = self.libs.get_configfiles(key='hdl_lib_name', values=use_lib_names)
+                use_lib_build_sim_dirs = self.get_lib_build_dirs('sim', lib_dicts=use_lib_dicts)
+                use_lib_clause_names   = self.libs.get_key_values('hdl_library_clause_name', use_lib_dicts)
+                for lib_clause, lib_dir in zip(use_lib_clause_names, cm.listify(use_lib_build_sim_dirs)):
+                    lib_work = os.path.join(lib_dir, 'work')
+                    fp.write('%s = %s\n' % (lib_clause, lib_work))
+
                 # . not used vendor technology libs are not compiled but are mapped to work to avoid compile error when mentioned in the LIBRARY clause
                 for removed_lib in sorted(self.removed_libs):
-                    fp.write('%s = work\n' % self.removed_libs[removed_lib]['hdl_library_clause_name'])
+                    # Only map library to work if it does not exist as a libraries that is used. It might be the case that two libraries with the same
+                    # name exist for multiple technologies causing it to show up in the "use_lib_clause_names" list as well as in the "removed_libs" list.
+                    if self.removed_libs[removed_lib]['hdl_library_clause_name'] not in use_lib_clause_names:
+                        fp.write('%s = work\n' % self.removed_libs[removed_lib]['hdl_library_clause_name'])
 
                 # . unavailable used libs are not compiled but are mapped to work to avoid compile error when mentioned in the LIBRARY clause
                 for unavailable_use_name in sorted(self.unavailable_use_libs):
@@ -244,15 +256,6 @@ class ModelsimConfig(hdl_libraries_wizard.HdlLibrariesWizard):
                     else:
                         fp.write('%s_lib = work\n' % unavailable_use_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_configfiles(key='hdl_lib_name', values=use_lib_names)
-                use_lib_build_sim_dirs = self.get_lib_build_dirs('sim', lib_dicts=use_lib_dicts)
-                use_lib_clause_names   = self.libs.get_key_values('hdl_library_clause_name', use_lib_dicts)
-                for lib_clause, lib_dir in zip(use_lib_clause_names, cm.listify(use_lib_build_sim_dirs)):
-                    lib_work = os.path.join(lib_dir, 'work')
-                    fp.write('%s = %s\n' % (lib_clause, lib_work))
-
                 # . work
                 fp.write('work = work\n')