diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0c725ee..fdbe192 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,16 +60,16 @@ jobs: - name: Ensure lockfile exists run: | if [ ! -f uv.lock ]; then - uv lock + uv lock --python "${{ matrix.python-version }}" else uv lock --check fi - 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 + 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 diff --git a/.python-version b/.python-version index e4fba21..6324d40 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.12 +3.14 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. diff --git a/examples/TinyALU_SystemC/Makefile b/examples/TinyALU_SystemC/Makefile index ba05098..a0a8652 100644 --- a/examples/TinyALU_SystemC/Makefile +++ b/examples/TinyALU_SystemC/Makefile @@ -19,7 +19,8 @@ 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_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 RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py @@ -27,6 +28,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 ad371a6..b4b0198 100644 --- a/examples/adder/Makefile +++ b/examples/adder/Makefile @@ -23,7 +23,8 @@ 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_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 RESULTS_CHECKER := $(CURDIR)/../../tools/check_cocotb_results.py @@ -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 adbebdc..367f210 100644 --- a/examples/basic/Makefile +++ b/examples/basic/Makefile @@ -33,12 +33,13 @@ 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 = $(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 @@ -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 4499a57..abd45d2 100644 --- a/examples/tinyalu_reg/Makefile +++ b/examples/tinyalu_reg/Makefile @@ -35,10 +35,11 @@ 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)) +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)" \ @@ -210,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 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; }