Repository navigation
Conversation
yavs calls a VHPIDIRECT foreign subprogram by the last word of its attribute and loads libraries given with --load, like NVC. The bridge serves it with the NVC attributes, a --load run flag and the configuration in the run environment. yavs is provided by the vunit-yavs package. Its default source encoding takes a non-ASCII character of a UTF-8 source as one character, not as UTF-8 bytes, which the docs point out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yavs comes from a simulator package, so the bridge should not list it. The next commit lets a simulator package describe how it loads the bridge. This reverts commit b36e497. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A simulator provided by a VUnit package is unknown to the table of the
bridge. Its interface class now describes itself: foreign_language_interface
names the binding ("VHPIDIRECT", "FLI" or "VHPI") and
native_library_hooks(library_file) returns the simulator hooks that make
it load the library. The bridge adds the configuration to the run
environment those hooks give. The attributes take precedence over the
table, which stays for the built-in simulators. A simulator with neither
fails with an error naming the two attributes, and bad attribute values
fail with what is wrong.
The Windows check of the simulator executable only applies to the
built-in simulators, whose executable the bridge knows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A "Simulator packages" page for simulator authors describes foreign_language_interface and native_library_hooks, with the README, the requirements and the news fragment pointing to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ru551n
commented
Oct 29, 2026
| reads a source as one character per code point needs an option to read it as | ||
| bytes (Latin-1) for non-ASCII string literals to reach Python unchanged. | ||
|
|
||
| yavs is a simulator served this way, by its package ``vunit-yavs``. |
Collaborator
Author
There was a problem hiding this comment.
Do not mention yavs here.
Comment on lines
+54
to
+57
| The bridge passes a VHDL string to Python as UTF-8 bytes, one character per | ||
| byte, which is what NVC and GHDL make of a UTF-8 source file. A simulator that | ||
| reads a source as one character per code point needs an option to read it as | ||
| bytes (Latin-1) for non-ASCII string literals to reach Python unchanged. |
| @@ -0,0 +1 @@ | |||
| A simulator provided by a VUnit package is supported when its simulator interface class defines `foreign_language_interface` and `native_library_hooks(library_file)`, which say how it loads the bridge. See "Simulator packages" in the documentation. | |||
Collaborator
Author
There was a problem hiding this comment.
Shorten this and only point to the docs
Comment on lines
+43
to
+44
| # The simulators of the table, named as a user knows them | ||
| SUPPORTED_SIMULATORS = "NVC, GHDL, Questa/ModelSim or Riviera-PRO" |
Collaborator
Author
There was a problem hiding this comment.
This should be called BUILTIN_SIMULATORS or something
Comment on lines
+97
to
+100
| raise PythonBridgeError( | ||
| f"The vunit-python-bridge package requires {SUPPORTED_SIMULATORS}, " | ||
| f"it is not supported for {simulator_name}" | ||
| ) |
Collaborator
Author
There was a problem hiding this comment.
This needs to be reworked, such that we add simulators to the list from VUnit, which in turn loads them from the simulator specific packages.
| # override, the Questa/ModelSim and Aldec interfaces use vsim. The executable of a simulator | ||
| # from a VUnit package is not known here. | ||
| if simulator_name in ("nvc", "ghdl"): | ||
| name = os.environ.get(simulator_name.upper(), simulator_name) |
Collaborator
Author
There was a problem hiding this comment.
Why do we need upper case here?
…he news fragment Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The bridge starts from the built-in simulators and adds every simulator class of VUnit, for instance from a simulator package, that defines foreign_language_interface and native_library_hooks. The selected simulator is looked up in that list. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A simulator class of another package that is half defined no longer breaks a project. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ter one Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: a simulator provided by a VUnit package should not need an entry in a per-simulator table of the bridge.
What: the bridge builds its list of simulators from VUnit: it starts from the built-in simulators (
BUILTIN_SIMULATORS: NVC, GHDL, Questa/ModelSim, Riviera-PRO) and adds every simulator class VUnit knows, for instance from a simulator package, that definesforeign_language_interface("VHPIDIRECT","FLI"or"VHPI") andnative_library_hooks(library_file), a dict ofregister_simulator_hookskeyword arguments saying how the simulator loads the library. These take precedence over a built-in simulator of the same name, and the bridge adds its configurationrun_envon top of theirs. Only the selected simulator is checked and has its hooks called: if it is not in the list, defines only one attribute, has an unknown interface, or hooks that are not a dict of known keys, it fails with an error naming the simulator, the cause and the fix. A half-defined class of another simulator is ignored. A "Simulator packages" docs page describes the protocol for simulator authors.How tested (Linux, Python 3.13, VUnit 5.0.0.dev16): unit tests 137 passed (fake simulator classes in a fake and a real VUnit simulator factory); ruff 0.17.0, license headers and
sphinx-build -Wclean.tests/run.py136 of 137 with the expected failure verified,file_base7 of 7, example 19 of 19, on NVC 1.23-devel and GHDL 7.0.0-dev mcode.Known limits: no CI job for a package simulator. Windows untested for package simulators; the Windows 64-bit check of the simulator executable only covers NVC, GHDL, Questa/ModelSim and Riviera-PRO.
🤖 Generated with Claude Code