diff --git a/Makefile b/Makefile index 31fa8b4..9852fa0 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,16 @@ ######### .PHONY: develop build build-verilator install dependencies-linux dependencies-macos dependencies-win copy-verilator copy-verilator-win update-verilator-config +VERILATOR_CMAKE_ARGS := \ + -DCMAKE_CXX_STANDARD=23 \ + -DCMAKE_INSTALL_PREFIX=verilator + +ifneq ($(OS),Windows_NT) +VERILATOR_CMAKE_ARGS += \ + -DFLEX_EXECUTABLE=/usr/bin/flex \ + -DFLEX_INCLUDE_DIR=/Library/Developer/CommandLineTools/usr/include +endif + develop: ## install dependencies and build library uv pip install -e .[develop] @@ -26,7 +36,7 @@ dependencies-win: build-verilator: ## build verilator git submodule update --init --recursive - cmake -B build src -DCMAKE_CXX_STANDARD=17 -DCMAKE_INSTALL_PREFIX=verilator + cmake -B build src $(VERILATOR_CMAKE_ARGS) cmake --build build --config Release -j 3 cmake --install build @@ -52,16 +62,16 @@ lint-py: ## lint python with ruff python -m ruff format --check verilator lint-docs: ## lint docs with mdformat and codespell - python -m mdformat --check README.md - python -m codespell_lib README.md + python -m mdformat --check README.md + python -m codespell_lib README.md fix-py: ## autoformat python code with ruff python -m ruff check --fix verilator python -m ruff format verilator fix-docs: ## autoformat docs with mdformat and codespell - python -m mdformat README.md - python -m codespell_lib --write README.md + python -m mdformat README.md + python -m codespell_lib --write README.md lint: lint-py lint-docs ## run all linters lints: lint diff --git a/README.md b/README.md index de26d1f..1766022 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ verilator-cli build sv/*.sv --includes sv --top-module top --exe sv/sim_sv.cpp ``` ## License + This software is licensed under the Apache 2.0 license. See the [LICENSE](LICENSE) file for details. Verilator is Copyright 2003-2026 by Wilson Snyder. Verilator is free software subject to either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0. diff --git a/pyproject.toml b/pyproject.toml index 166217d..aaad580 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [build-system] requires = [ "hatchling", + "systemc", ] build-backend = "hatchling.build" @@ -12,7 +13,7 @@ authors = [ description = "Python wrapping/binding for verilator" readme = "README.md" license = { text = "Apache-2.0" } -version = "5.44.0" +version = "5.48.0" requires-python = ">=3.10" keywords = [] @@ -27,7 +28,9 @@ classifiers = [ "Programming Language :: Python :: 3.14", ] -dependencies = [] +dependencies = [ + "systemc", +] [project.optional-dependencies] cli = [ @@ -60,7 +63,7 @@ Repository = "https://github.com/dau-dev/verilator-python" Homepage = "https://github.com/dau-dev/verilator-python" [tool.bumpversion] -current_version = "5.44.0" +current_version = "5.48.0" commit = true tag = true commit_args = "-s" @@ -155,6 +158,11 @@ exclude = [ "/pyproject.toml", ] +[tool.hatch.build.targets.wheel.shared-data] +"verilator/include" = "include/verilator" +"verilator/lib" = "lib/verilator" +"verilator/share" = "share/verilator" + [tool.pytest.ini_options] addopts = [ "-vvv", diff --git a/src b/src index 8df584c..4e853d8 160000 --- a/src +++ b/src @@ -1 +1 @@ -Subproject commit 8df584ca1ddde5c8afbd15dc5fdcb677a78f9af2 +Subproject commit 4e853d8cb6a51b5b96fe61cc2c1891b10f78972c diff --git a/verilator/__init__.py b/verilator/__init__.py index 39b8519..db0c354 100644 --- a/verilator/__init__.py +++ b/verilator/__init__.py @@ -1 +1 @@ -__version__ = "5.44.0" +__version__ = "5.48.0" diff --git a/verilator/cli.py b/verilator/cli.py index ccda2f2..e956445 100644 --- a/verilator/cli.py +++ b/verilator/cli.py @@ -24,9 +24,27 @@ def _get_verilator() -> str: verilator_exe = str((verilator_root / "bin" / "verilator").resolve()) environ["VERILATOR_ROOT"] = str(verilator_root.as_posix()) environ["CXXFLAGS"] = environ.get("CXXFLAGS", "--std=c++20 -DVL_TIME_CONTEXT") + _set_systemc_env() return verilator_exe +def _set_systemc_env() -> None: + """Point Verilator at the bundled ``systemc`` Python package's headers/libs. + + Resolved at runtime so the paths are correct regardless of where ``systemc`` + was installed during the build (build isolation, different venvs, etc.). + Existing ``SYSTEMC_INCLUDE`` / ``SYSTEMC_LIBDIR`` env vars take precedence. + """ + if environ.get("SYSTEMC_INCLUDE") and environ.get("SYSTEMC_LIBDIR"): + return + try: + import systemc + except ImportError: + return + environ.setdefault("SYSTEMC_INCLUDE", systemc.include_path()) + environ.setdefault("SYSTEMC_LIBDIR", systemc.lib_path()) + + def verilator(argv): build_cmd = [ _get_verilator(), diff --git a/verilator/tests/module/ff_tb.sv b/verilator/tests/module/ff_tb.sv index 60776c6..f307d5b 100755 --- a/verilator/tests/module/ff_tb.sv +++ b/verilator/tests/module/ff_tb.sv @@ -23,7 +23,7 @@ program ff_tb(ff_ifc.bench ds); /* begin testing */ repeat(v.iter) begin - int _ = v.randomize(); + static int _ = v.randomize(); ds.reset = 1'b0; ds.valid_i = 1'b1;