Conversation
Collaborator
Author
|
Added a test that deallocates returned multi-key dicts. It needs the |
eval_dict/call_dict (aliased eval/call) return a new dict_t from a Python dict with str keys: int, float, str, bool, list of int and nested dict values. arg/kwarg accept a dict_t and write it as a Python dict literal. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Needs the new_dict fix of VUnit/vunit#1229. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ru551n
force-pushed
the
python-dict-support
branch
from
October 4, 2026 10:37
eb80a64 to
066b263
Compare
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.
Depends on: VUnit/vunit#1229
Motivation
Python code naturally exchanges configuration and results as dicts. VUnit's
dict_t(string keys, mixed-type values) is the VHDL counterpart, but the bridge could not pass one in either direction.API
eval_dict/call_dictreturn a newdict_t(aliased aseval/call; no ambiguity with the existingeval/calloverloads). The caller owns and deallocates it. Values:int-> integer,float-> real (bit exact),str-> string,bool-> boolean, list ofint->integer_vector_ptr_tref, nesteddict-> nesteddict_tref.None, out-of-range ints, non-strkeys and other values are errors; after a reported failure an empty dict is returned. NVC, GHDL and Questa only (Riviera-PRO/Active-HDL report that they require them), likeinteger_array_tresults.arg(dict_t)/kwarg(kw, dict_t)write a Python literal{"key": value, ...}using only the public dict_pkg API (num_keys,get_key,get_value_type, getters). Values: integer, real, string, boolean, std_ulogic, integer_vector, real_vector, integer_vector_ptr_t, nested dict. Other types fail like other unconvertible arguments. Text only, so it works on all simulators.Python side:
KIND_DICTand_dict_resultinruntime.pyserialise the dict into the existing byte-result path (no native changes). The generatedpython_pkg.vhdis regenerated from the template.Tests
New cases in
tests/tb_python_pkg_bridge.vhd: every value type and nested dicts, exact reals, error cases, arg/kwarg, a round trip VHDL dict -> Python -> VHDL, an unconvertible value, and a group&with a dict kwarg. Full suite: 113 of 113 pass on NVC and on GHDL,pytest tests/test_python_bridge.py85 passed.Notes: tests do not deallocate multi-key dicts because
new_dictafterdeallocateof a grown dict fails in VUnit's dict_pkg (recycled pool arrays are longer than requested). Reals are sent as an exact mantissa/exponent because NVC'sreal'valuemisparses multi-digit exponents.🤖 Generated with Claude Code