From 3509b30f64b9645133159c823271b96b3234de45 Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 13:29:58 +0200 Subject: [PATCH 1/9] Fix path issue --- examples/TinyALU_SystemC/Makefile | 2 +- examples/adder/Makefile | 2 +- examples/basic/Makefile | 8 ++++---- examples/tinyalu_reg/Makefile | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/TinyALU_SystemC/Makefile b/examples/TinyALU_SystemC/Makefile index ba05098..48125f1 100644 --- a/examples/TinyALU_SystemC/Makefile +++ b/examples/TinyALU_SystemC/Makefile @@ -19,7 +19,7 @@ COCOTB_LIBPYTHON = $(shell $(COCOTB_CMD) --libpython 2>/dev/null || echo "") COCOTB_LIBPYTHON_DIR = $(dir $(COCOTB_LIBPYTHON)) COCOTB_PYTHON_BIN = $(shell $(COCOTB_CMD) --python-bin 2>/dev/null || echo "python3") COCOTB_LIB_DIR = $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null || echo "") -COCOTB_VPI_ICARUS = $(COCOTB_LIB_DIR)/libcocotbvpi_icarus.vpl +COCOTB_VPI_ICARUS = $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null || echo "") RESULTS_FILE := $(CURDIR)/results.xml RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py diff --git a/examples/adder/Makefile b/examples/adder/Makefile index ad371a6..401ca3a 100644 --- a/examples/adder/Makefile +++ b/examples/adder/Makefile @@ -23,7 +23,7 @@ COCOTB_LIBPYTHON = $(shell $(COCOTB_CMD) --libpython 2>/dev/null || echo "") COCOTB_LIBPYTHON_DIR = $(dir $(COCOTB_LIBPYTHON)) COCOTB_PYTHON_BIN = $(shell $(COCOTB_CMD) --python-bin 2>/dev/null || echo "python3") COCOTB_LIB_DIR = $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null || echo "") -COCOTB_VPI_ICARUS = $(COCOTB_LIB_DIR)/libcocotbvpi_icarus.vpl +COCOTB_VPI_ICARUS = $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null || echo "") RESULTS_FILE := $(CURDIR)/results.xml RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py diff --git a/examples/basic/Makefile b/examples/basic/Makefile index adbebdc..58eec16 100644 --- a/examples/basic/Makefile +++ b/examples/basic/Makefile @@ -35,10 +35,10 @@ COCOTB_PYTHON_BIN = $(shell $(COCOTB_CMD) --python-bin 2>/dev/null || echo "p COCOTB_LIB_DIR = $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null || echo "") # VPI library paths -COCOTB_VPI_VERILATOR = $(COCOTB_LIB_DIR)/libcocotbvpi_verilator.so -COCOTB_VPI_QUESTA = $(COCOTB_LIB_DIR)/libcocotbvpi_modelsim.so -COCOTB_VPI_XCELIUM = $(COCOTB_LIB_DIR)/libcocotbvpi_ius.so -COCOTB_VPI_ICARUS = $(COCOTB_LIB_DIR)/libcocotbvpi_icarus.vpl +COCOTB_VPI_VERILATOR = $(shell $(COCOTB_CMD) --lib-name-path vpi verilator 2>/dev/null || echo "") +COCOTB_VPI_QUESTA = $(shell $(COCOTB_CMD) --lib-name-path vpi questa 2>/dev/null || echo "") +COCOTB_VPI_XCELIUM = $(shell $(COCOTB_CMD) --lib-name-path vpi xcelium 2>/dev/null || echo "") +COCOTB_VPI_ICARUS = $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null || echo "") # ------------------------------------------------------------------------------ # Build Configurations diff --git a/examples/tinyalu_reg/Makefile b/examples/tinyalu_reg/Makefile index 4499a57..8d9df95 100644 --- a/examples/tinyalu_reg/Makefile +++ b/examples/tinyalu_reg/Makefile @@ -35,7 +35,7 @@ SIM_EXE := $(BUILD_DIR)/TINYALU_REG_SC COCOTB_CMD := $(PYTHON) -m cocotb_tools.config COCOTB_LIB_DIR := $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null) -VPI_SO := $(COCOTB_LIB_DIR)/libcocotbvpi_icarus.vpl +VPI_SO := $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null) COCOTB_LIBPYTHON := $(shell $(COCOTB_CMD) --libpython 2>/dev/null) COCOTB_LIBPYTHON_DIR := $(dir $(COCOTB_LIBPYTHON)) From 848c48991cc7551b581cc7fcd1d5360898098a24 Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 13:45:53 +0200 Subject: [PATCH 2/9] Fix failing tests --- examples/TinyALU_SystemC/Makefile | 1 + examples/adder/Makefile | 2 ++ examples/basic/Makefile | 2 ++ examples/tinyalu_reg/Makefile | 2 ++ 4 files changed, 7 insertions(+) diff --git a/examples/TinyALU_SystemC/Makefile b/examples/TinyALU_SystemC/Makefile index 48125f1..ecb31f3 100644 --- a/examples/TinyALU_SystemC/Makefile +++ b/examples/TinyALU_SystemC/Makefile @@ -27,6 +27,7 @@ RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py COCOTB_ENV = \ PYTHONPATH=.:$$PYTHONPATH \ PYGPI_PYTHON_BIN=$(COCOTB_PYTHON_BIN) \ + GPI_USERS="$(COCOTB_LIBPYTHON);$(COCOTB_PYGPI_ENTRY)" \ COCOTB_TEST_MODULES=testbench \ COCOTB_RESULTS_FILE=$(RESULTS_FILE) \ COCOTB_RANDOM_SEED=$(RANDOM_SEED) \ diff --git a/examples/adder/Makefile b/examples/adder/Makefile index 401ca3a..b4b0198 100644 --- a/examples/adder/Makefile +++ b/examples/adder/Makefile @@ -23,6 +23,7 @@ COCOTB_LIBPYTHON = $(shell $(COCOTB_CMD) --libpython 2>/dev/null || echo "") COCOTB_LIBPYTHON_DIR = $(dir $(COCOTB_LIBPYTHON)) COCOTB_PYTHON_BIN = $(shell $(COCOTB_CMD) --python-bin 2>/dev/null || echo "python3") COCOTB_LIB_DIR = $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null || echo "") +COCOTB_PYGPI_ENTRY = $(shell $(COCOTB_CMD) --pygpi-entry-point 2>/dev/null || echo "") COCOTB_VPI_ICARUS = $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null || echo "") RESULTS_FILE := $(CURDIR)/results.xml @@ -31,6 +32,7 @@ RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py COCOTB_ENV = \ PYTHONPATH=.:$$PYTHONPATH \ PYGPI_PYTHON_BIN=$(COCOTB_PYTHON_BIN) \ + GPI_USERS="$(COCOTB_LIBPYTHON);$(COCOTB_PYGPI_ENTRY)" \ COCOTB_TEST_MODULES=tb \ COCOTB_RESULTS_FILE=$(RESULTS_FILE) \ COCOTB_RANDOM_SEED=$(RANDOM_SEED) \ diff --git a/examples/basic/Makefile b/examples/basic/Makefile index 58eec16..367f210 100644 --- a/examples/basic/Makefile +++ b/examples/basic/Makefile @@ -33,6 +33,7 @@ COCOTB_LIBPYTHON = $(shell $(COCOTB_CMD) --libpython 2>/dev/null || echo "") COCOTB_LIBPYTHON_DIR = $(dir $(COCOTB_LIBPYTHON)) COCOTB_PYTHON_BIN = $(shell $(COCOTB_CMD) --python-bin 2>/dev/null || echo "python3") COCOTB_LIB_DIR = $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null || echo "") +COCOTB_PYGPI_ENTRY = $(shell $(COCOTB_CMD) --pygpi-entry-point 2>/dev/null || echo "") # VPI library paths COCOTB_VPI_VERILATOR = $(shell $(COCOTB_CMD) --lib-name-path vpi verilator 2>/dev/null || echo "") @@ -58,6 +59,7 @@ ICARUS_LDFLAGS = $(SYSTEMC_LDFLAGS) $(BASE_LDFLAGS) BASE_COCOTB_ENV = \ PYTHONPATH=.:$$PYTHONPATH \ PYGPI_PYTHON_BIN=$(COCOTB_PYTHON_BIN) \ + GPI_USERS="$(COCOTB_LIBPYTHON);$(COCOTB_PYGPI_ENTRY)" \ COCOTB_TEST_MODULES=tb \ COCOTB_RESULTS_FILE=$(RESULTS_FILE) \ COCOTB_RANDOM_SEED=$(RANDOM_SEED) diff --git a/examples/tinyalu_reg/Makefile b/examples/tinyalu_reg/Makefile index 8d9df95..1b50b6a 100644 --- a/examples/tinyalu_reg/Makefile +++ b/examples/tinyalu_reg/Makefile @@ -39,6 +39,7 @@ VPI_SO := $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null) COCOTB_LIBPYTHON := $(shell $(COCOTB_CMD) --libpython 2>/dev/null) COCOTB_LIBPYTHON_DIR := $(dir $(COCOTB_LIBPYTHON)) +COCOTB_PYGPI_ENTRY := $(shell $(COCOTB_CMD) --pygpi-entry-point 2>/dev/null) RESULTS_FILE := $(CURDIR)/results_$(MODEL).xml RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py @@ -117,6 +118,7 @@ else PATH="$$(dirname "$(PYTHON)"):$$PATH" \ PYTHONHOME= \ PYGPI_PYTHON_BIN="$(PYTHON)" \ + GPI_USERS="$(COCOTB_LIBPYTHON);$(COCOTB_PYGPI_ENTRY)" \ COCOTB_TEST_MODULES=tests.testbench \ COCOTB_RESULTS_FILE="$(RESULTS_FILE)" \ COCOTB_RANDOM_SEED="$(RANDOM_SEED)" \ From 8d0e59616a797cc39e8d59a17af5e060836f763e Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 14:02:48 +0200 Subject: [PATCH 3/9] Update vpi.icc for cocotb 2.1.0 --- src/vpi.icc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/vpi.icc b/src/vpi.icc index 386ce22..3d7d3ac 100644 --- a/src/vpi.icc +++ b/src/vpi.icc @@ -636,6 +636,7 @@ PLI_INT32 vpi_get(PLI_INT32 property, vpiHandle object) { } auto itH = g_handles.find(object); + if (property == vpiType) { return (itH != g_handles.end()) ? itH->second->vpi_type : 0; } @@ -648,7 +649,33 @@ PLI_INT32 vpi_get(PLI_INT32 property, vpiHandle object) { return 1; } + // cocotb 2.1 queries VPI signedness for integer objects. + if (property == vpiSigned) { + if (itH == g_handles.end()) { + return 0; + } + + switch (itH->second->kind) { + case SigInt32: + case SigInt4: + return 1; + + case SigBool: + case SigUInt3: + case SigUInt4: + case SigUInt5: + case SigUInt8: + case SigUInt9: + case SigUInt16: + case SigUInt32: + case SigUnknown: + default: + return 0; + } + } + if (property == vpiTimePrecision || property == vpiTimeUnit) return -9; + return 0; } From da3e23d0127d8e27f0a13dfc12350427ee0abb72 Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 14:06:53 +0200 Subject: [PATCH 4/9] Minor fix --- examples/TinyALU_SystemC/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/TinyALU_SystemC/Makefile b/examples/TinyALU_SystemC/Makefile index ecb31f3..a0a8652 100644 --- a/examples/TinyALU_SystemC/Makefile +++ b/examples/TinyALU_SystemC/Makefile @@ -19,6 +19,7 @@ COCOTB_LIBPYTHON = $(shell $(COCOTB_CMD) --libpython 2>/dev/null || echo "") COCOTB_LIBPYTHON_DIR = $(dir $(COCOTB_LIBPYTHON)) COCOTB_PYTHON_BIN = $(shell $(COCOTB_CMD) --python-bin 2>/dev/null || echo "python3") COCOTB_LIB_DIR = $(shell $(COCOTB_CMD) --lib-dir 2>/dev/null || echo "") +COCOTB_PYGPI_ENTRY = $(shell $(COCOTB_CMD) --pygpi-entry-point 2>/dev/null || echo "") COCOTB_VPI_ICARUS = $(shell $(COCOTB_CMD) --lib-name-path vpi icarus 2>/dev/null || echo "") RESULTS_FILE := $(CURDIR)/results.xml From abc45f2f08a64fe5e940659f71c1fb9d31306de6 Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 14:18:35 +0200 Subject: [PATCH 5/9] Fix CI Python setup --- .github/workflows/ci.yaml | 2 +- examples/tinyalu_reg/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0c725ee..78caddb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,7 +67,7 @@ jobs: - name: Run tests on Python ${{ matrix.python-version }} run: | - uv venv + uv venv --python "${{ matrix.python-version }}" source .venv/bin/activate uv sync --locked --all-extras --dev diff --git a/examples/tinyalu_reg/Makefile b/examples/tinyalu_reg/Makefile index 1b50b6a..abd45d2 100644 --- a/examples/tinyalu_reg/Makefile +++ b/examples/tinyalu_reg/Makefile @@ -212,4 +212,4 @@ help: .PHONY: clean clean: rm -rf build_hdl build_rtl build_tlm traces results*.xml sim_build __pycache__ tests/__pycache__ - $(MAKE) -C model_hdl clean PYTHON="$(PYTHON)" || true \ No newline at end of file + $(MAKE) -C model_hdl clean PYTHON="$(PYTHON)" SIM=icarus || true \ No newline at end of file From 132d1a2032def6d0aaa53518c7248b219b8fc6e2 Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 14:29:09 +0200 Subject: [PATCH 6/9] Fix Python setup --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 78caddb..0a793ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -69,7 +69,7 @@ jobs: run: | uv venv --python "${{ matrix.python-version }}" source .venv/bin/activate - uv sync --locked --all-extras --dev + uv sync --python "${{ matrix.python-version }}" --locked --all-extras --dev # Run standalone examples through their public default target. for ex in basic adder TinyALU_SystemC; do From 84aa5c76a35801c151c5d7fcaf479ad5f98e40aa Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 14:42:50 +0200 Subject: [PATCH 7/9] Fix lockfile issue --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a793ea..fdbe192 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,7 +60,7 @@ jobs: - name: Ensure lockfile exists run: | if [ ! -f uv.lock ]; then - uv lock + uv lock --python "${{ matrix.python-version }}" else uv lock --check fi From 78b79ffa46c58af0f5f72a3c4a596c2f1dfcba5c Mon Sep 17 00:00:00 2001 From: Arora Bhavay Date: Tue, 15 Sep 2026 14:48:54 +0200 Subject: [PATCH 8/9] Change Python version to 3.14 --- .python-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.python-version b/.python-version index e4fba21..6324d40 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.12 +3.14 From 2ba73bfbb15c4b7cab11a658cefa2dcd6a095066 Mon Sep 17 00:00:00 2001 From: Bhavay Arora Date: Tue, 15 Sep 2026 14:54:00 +0200 Subject: [PATCH 9/9] Update README file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27c5d3b..c33075d 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Additional signal types can be added as needed. - SystemC 3.0.2 - CMake 3.15 or newer -- Python 3.11 or newer +- Python 3.12 or newer - uv Install the Python dependencies (including **cocotb 2.x** and @@ -156,4 +156,4 @@ make -C examples/tinyalu_reg run-sc-tlm-target-wait RANDOM_SEED=12345 ## License This project is released under the applicable open-source license. -Third-party examples and testbenches retain their original licenses. \ No newline at end of file +Third-party examples and testbenches retain their original licenses.