Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.14
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Third-party examples and testbenches retain their original licenses.
4 changes: 3 additions & 1 deletion examples/TinyALU_SystemC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ 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

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) \
Expand Down
4 changes: 3 additions & 1 deletion examples/adder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ 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

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) \
Expand Down
10 changes: 6 additions & 4 deletions examples/basic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions examples/tinyalu_reg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)" \
Expand Down Expand Up @@ -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
$(MAKE) -C model_hdl clean PYTHON="$(PYTHON)" SIM=icarus || true
27 changes: 27 additions & 0 deletions src/vpi.icc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
Loading