Repository navigation
Conversation
record_dict_pkg uses VHDL-2019 reflection to convert a value of any record type to a dict_t, so no conversion function has to be written or generated for each record. It is opt-in through add_record_dict(), which requires VHDL-2019 and a simulator whose supports_vhdl_reflection() is true, currently NVC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
to_dict is now a generic function, instantiated once per record type
and called with the record:
function to_dict is new to_dict generic map (record_t => packet_t);
dict := to_dict(packet);
A function can't take packet'reflect directly. A mirror is an access
type, and an access type parameter must be of class variable, whose
actual must be a variable name, not an expression. Before, every call
needed a mirror variable and std.reflection. Now the function reflects
its own parameter, so each call is one expression and users never see
mirrors. The instantiation remains since VHDL has no implicit
instantiation of generic subprograms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Riviera-PRO supports VHDL-2019 reflection, so it reports supports_vhdl_reflection() and runs the acceptance test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Riviera-PRO rejects chained mirror calls, returns simple_name in lower case, gives time values in units of the resolution limit and indexes descending arrays by their actual index, where NVC indexes from 'left upwards. Handle each so the package runs on both simulators. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the library to vunit/vhdl/reflection and rename add_record_dict() to add_reflection(), so the opt-in covers further packages built on VHDL-2019 reflection rather than only record_dict_pkg. The package name and its API are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A package instantiated in an architecture is made visible with a use clause naming the instance, such as use my_inst.all. The dependency scanner read my_inst as a library and warned "failed to find library 'my_inst'". Skip use clauses that name a package instantiated in the same file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reflection_queue_pkg is a generic package with push(queue, value) and pop(queue) for its type t. A value can't be rebuilt from its parts in VHDL, so push copies the value into a store owned by the instance and pushes an instance id and a handle onto the queue. pop checks the id, takes the value out of the store and frees its handle for reuse. The instance id is the number of a pointer that each instance allocates, since 'path_name of the store is the same for all instances on NVC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Closing: a generic, symmetric push and pop can't be built on reflection. VHDL-2019 reflection can read a value but not create one, and neither NVC nor Riviera-PRO allows |
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.
Draft, depends on #1239. Until #1239 merges, the diff also shows its commits. The changes of this PR are the last three commits. "Don't treat a use of a local package instance as a library" is the same scanner fix as in #1242, cherry-picked so this branch builds without warnings on its own.
This adds
pushandpopfor values of any type on aqueue_t:How it works
Reflection can read a value but not create one, and
t'image/t'valuearen't allowed on a generic type. Both NVC and Riviera-PRO reject them: "non-representable type T" and "Illegal prefix for attribute 'IMAGE". So a value can't be rebuilt from data on the queue.Instead,
pushcopies the value into a store owned by the package instance and pushes two integers: an instance id and a handle.poppops both, checks the id, takes the value out of the store and frees the handle for reuse. The store is a protected type with a growing array of pointers tot, so unconstrained types such asinteger_vectorwork too.queue_pkgtypes on the same queue, in order.vunit_lib:reflection_queue_pkglogger, with the location of thepopcall.'path_nameof the store, but NVC (1.23-devel and master) gives the same path for every instance of the generic package (:tb:store), while Riviera-PRO includes the instance (:work:a_pkg:store).Open questions for review
reflection_queue_pkgshould change.encode/decodeor a copy of the queue doesn't copy the values, the Python bridge would only see two integers, andflushleaves the values in the store. Is that acceptable, or should these be documented harder or guarded?vunit/vhdl/reflection/and enabled byadd_reflection()for now.Testing
vunit/vhdl/reflection/run.pywith VHDL-2019: 12/12 on NVC 1.23-devel and Riviera-PRO 2026.04. That's 6 new tests plus the 6record_dict_pkgtests. They cover:record_dict_pkgsupports;integer_vector);push_integer/push_stringand another type;This PR was written with the help of an AI assistant (Claude).
🤖 Generated with Claude Code