Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ExportVerilog] Fix ifdef of macro w/ Verilog name #7947

Merged

Conversation

seldridge
Copy link
Member

Add a utility function to sv.macro.decl that can be used to get its
Verilog textual macro identifier name. This is added for convenience to
avoid having to repeat the patter of getting its optional Verilog name or
symbol name.

This is done to fix an issue related to lowering of FIRRTL inline layers
where the LowerLayers pass generates new sv.macro.decl symbols that
will replace existing firrtl.layer symbols. However, it relies on a
namespace to generate these and will result in suffixed symbol names. (It
could obviously do more work to conserve symbols or generate in-pass
invalid IR with duplicate symbols.) Nonetheless, the real bug here is
that the ExportVerilog conversion is not doing the right thing with the
Verilog name attribute.

@seldridge seldridge requested a review from darthscsi as a code owner December 4, 2024 22:49
@uenoku
Copy link
Member

uenoku commented Dec 4, 2024

LGTM!

Add a utility function to `sv.macro.decl` that can be used to get its
Verilog textual macro identifier name.  This is added for convenience to
avoid having to repeat the patter of getting its optional Verilog name or
symbol name.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Fix a bug in the emission of `sv.ifdef` (and its procedural variant) where
the symbol name was always used instead of using the symbol name only if a
Verilog name was not specified.

This is done to fix an issue related to lowering of FIRRTL inline layers
where the `LowerLayers` pass generates new `sv.macro.decl` symbols that
will replace existing `firrtl.layer` symbols.  However, it relies on a
namespace to generate these and will result in suffixed symbol names.  (It
could obviously do more work to conserve symbols or generate in-pass
invalid IR with duplicate symbols.)  Nonetheless, the real bug here is
that the `ExportVerilog` conversion is not doing the right thing with the
Verilog name attribute.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge force-pushed the dev/seldridge/fix-ifdef-text-macro-identifier-emission branch from cce54c5 to 79c2d41 Compare December 4, 2024 23:10
@seldridge seldridge merged commit 79c2d41 into main Dec 4, 2024
2 checks passed
@seldridge seldridge deleted the dev/seldridge/fix-ifdef-text-macro-identifier-emission branch December 4, 2024 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants