Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical issue remains for register types declared exclusively inside nested regfiles.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR deduplicates generated register/regfile classes and adds nested regfile support.
Changes:
- Shares type dictionaries for class deduplication.
- Emits nested regfile and regfile-array members.
- Preserves per-addrmap type scoping.
File summaries
| File | Summary |
|---|---|
src/peakrdl_halcpp/templates/addrmap.h.j2 |
Implements deduplication and nested regfile generation; nested register types may still be omitted, causing compilation failures. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| {# ======== 2. Generate the registers from the register files ======== #} | ||
| {% for rf in halnode.halchildren(children_type=HalRegfileNode, skip_buses=skip_buses, unique_orig_type=True) %} | ||
| {% for r in rf.halchildren(children_type=HalRegNode, skip_buses=skip_buses, unique_orig_type=True) %} | ||
| {% for r in rf.halchildren(children_type=HalRegNode, skip_buses=skip_buses, unique_orig_type=True, type_dict=reg_types) %} |
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.
Summary
This PR fixes C++ redefinition errors in the generated code when a
regorregfiletype is instantiated more than once within an addrmap. It also adds code generation forregfileinstances and arrays nested inside otherregfiles.Follow-up to #20, which fixed duplicate register classes within a single regfile.
Problem
unique_orig_type=Trueonly deduplicates within a singlehalchildren()call. A register type used directly in the addrmap and inside a regfile, or inside several different regfile types, is emitted once per loop, and the generated header does not compile.haldescendants()without deduplication, so each instance of the same regfile type produces another class definition.regfileinstances inside aregfile. The template already iterates over the children of a regfile but only emits members for registers, so nested regfiles and regfile arrays are silently missing.Changes
All changes are in
src/peakrdl_halcpp/templates/addrmap.h.j2:reg_typesandregfile_typesand pass them astype_dicttohalchildren()/haldescendants(). Each register and regfile class is now emitted exactly once per addrmap (same idea as the existingseen_enum_names).regfileinstances andregfilearrays as static members of the enclosing regfile class, analogous to the existing declarations in the addrmap class (halcpp::RegfileArrayNodefor arrays).No changes to the Python code or the C++ headers are required, because the existing
type_dictparameter andhalcpp::RegfileArrayNodeare reused. Deduplication is scoped per addrmap namespace, so child addrmaps still generate their own classes.Testing
The RDL below instantiates register and regfile types on several hierarchy levels and contains a nested regfile array and a child addrmap. The generated headers compile with
g++ -std=c++17.RDL used for the deeper hierarchy test