Repository: cocotb/cocotb

Issue:
Icarus: Rename VPI library from gpivpi to libvpi for consistency
All other simulators using VPI use a library named "libvpi", for Icarus it's named gpivpi. There seems to be no technical reason for this discrepancy. Rename it for consistency.


Discussion:
I think the technical reason is that icarus comes with `libvpi.a`, and this avoids a name collision.

Even though the collision no longer matters, for clarity I think we should pick a different name elsewhere. `libcocotbvpi` or `libgpivpi` are both reasonable.

Dropping the `lib` prefix for Icarus is also not unreasonable given we also replace the `.so` suffix
``libcocotbvpi`` would align nicely with the VHPI library name that we use since #1168.

Resolving patch:
diff --git a/cocotb/_build_libs.py b/cocotb/_build_libs.py
--- a/cocotb/_build_libs.py
+++ b/cocotb/_build_libs.py
@@ -61,10 +61,10 @@ def get_ext_filename(self, ext_name):
 
         filename_short = os.path.join(head, tail_split[0] + "." + _get_lib_ext_name())
 
-        # icarus requires vpl extension, gpivpi is default in Makefiles
+        # icarus requires vpl extension
         if "icarus" in filename:
-            filename_short = filename_short.replace("libvpi.so", "gpivpi.vpl")
-            filename_short = filename_short.replace("libvpi.dll", "gpivpi.vpl")
+            filename_short = filename_short.replace("libcocotbvpi.so", "libcocotbvpi.vpl")
+            filename_short = filename_short.replace("libcocotbvpi.dll", "libcocotbvpi.vpl")
 
         return filename_short
 
@@ -250,8 +250,8 @@ def _get_common_lib_ext(include_dir, share_lib_dir, sim_define):
 def _get_vpi_lib_ext(
     include_dir, share_lib_dir, sim_define, extra_lib=[], extra_lib_dir=[]
 ):
-    libvpi = Extension(
-        os.path.join("cocotb", "libs", sim_define.lower(), "libvpi"),
+    libcocotbvpi = Extension(
+        os.path.join("cocotb", "libs", sim_define.lower(), "libcocotbvpi"),
         define_macros=[("VPI_CHECKING", "1")] + [(sim_define, "")],
         include_dirs=[include_dir],
         libraries=["gpi", "gpilog"] + extra_lib,
@@ -264,7 +264,7 @@ def _get_vpi_lib_ext(
         extra_compile_args=_extra_cxx_compile_args,
     )
 
-    return libvpi
+    return libcocotbvpi
 
 
 def _get_vhpi_lib_ext(


Test patch:
diff --git a/tests/test_cases/issue_253/Makefile b/tests/test_cases/issue_253/Makefile
--- a/tests/test_cases/issue_253/Makefile
+++ b/tests/test_cases/issue_253/Makefile
@@ -46,19 +46,19 @@ $(COCOTB_RESULTS_FILE):
 notset_top_level: $(SIM_BUILD)/sim.vvp $(CUSTOM_SIM_DEPS) $(COCOTB_LIBS) $(COCOTB_VPI_LIB)
 	PYTHONPATH=$(LIB_DIR):$(COCOTB_PY_DIR):$(PWD):$(NEW_PYTHONPATH) $(LIB_LOAD) MODULE=$(MODULE) \
 	COCOTB_SIM=1 TESTCASE=issue_253_notset TOPLEVEL= \
-	vvp -M $(LIB_DIR) -m gpivpi $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
+	vvp -M $(LIB_DIR) -m libcocotbvpi $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
 	mkdir -p $@_result && mv results.xml $@_result/
 
 empty_top_level: $(SIM_BUILD)/sim.vvp $(CUSTOM_SIM_DEPS) $(COCOTB_LIBS) $(COCOTB_VPI_LIB)
 	PYTHONPATH=$(LIB_DIR):$(COCOTB_PY_DIR):$(PWD):$(NEW_PYTHONPATH) $(LIB_LOAD) MODULE=$(MODULE) \
 	COCOTB_SIM=1 TESTCASE=issue_253_empty TOPLEVEL="" \
-	vvp -M $(LIB_DIR) -m gpivpi $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
+	vvp -M $(LIB_DIR) -m libcocotbvpi $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
 	mkdir -p $@_result && mv results.xml $@_result/
 
 no_top_level: $(SIM_BUILD)/sim.vvp $(CUSTOM_SIM_DEPS) $(COCOTB_LIBS) $(COCOTB_VPI_LIB)
 	PYTHONPATH=$(LIB_DIR):$(COCOTB_PY_DIR):$(PWD):$(NEW_PYTHONPATH) $(LIB_LOAD) MODULE=$(MODULE) \
 	COCOTB_SIM=1 TESTCASE=issue_253_none \
-	vvp -M $(LIB_DIR) -m gpivpi $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
+	vvp -M $(LIB_DIR) -m libcocotbvpi $(SIM_BUILD)/sim.vvp $(SIM_ARGS) $(EXTRA_ARGS) $(PLUSARGS)
 	mkdir -p $@_result && mv results.xml $@_result/
 
 endif