-
Notifications
You must be signed in to change notification settings - Fork 195
Avoid name and keyword collisions in generated verilog. #2229
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
Conversation
xls/codegen/block_stitching_pass.cc
Outdated
@@ -501,8 +501,10 @@ absl::StatusOr<bool> BlockStitchingPass::RunInternal( | |||
return absl::UnimplementedError( | |||
"Splitting outputs is not supported by block stitching."); | |||
} | |||
// std::string top_block_name(options.codegen_options.module_name().value_or( | |||
// SanitizeVerilogIdentifier(context.top_block()->name()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
@@ -357,6 +359,10 @@ std::string SanitizeIdentifier(std::string_view name) { | |||
sanitized[i] = '_'; | |||
} | |||
} | |||
if ((system_verilog ? SystemVerilogKeywords() : VerilogKeywords()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just add a comment to note that our policy is to put an underscore suffix on any keyword collisions? (Similar to the explainer comment above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, great fix! Can see how the system for naming hangs together more effectively now too.
fe69f71
to
29e5587
Compare
Add a name uniquer on ModuleBuilder to prevent accidental collisions of identifiers in verilog modules (regs, wires, etc). Other fixes, cleanups: * xls::verilog::SanitizeIdentifier renamed to SanitizeVerilogIdentifier to distinguish it from other uses of sanitize. * SanitizeVerilogIdentifier now sanitizes keywords. * Raise an error if port names collide rather than silently renaming because port names are part of the interface and should not be changed. * Don't call SanitizeVerilogIdentifer during block creation. We have a separate pass which handes that (NameLeagalizationPass). Fixes #2209. Fixes #805 PiperOrigin-RevId: 762532280
29e5587
to
80ba281
Compare
Avoid name and keyword collisions in generated verilog.
Add a name uniquer on ModuleBuilder to prevent accidental collisions of identifiers in verilog modules (regs, wires, etc).
Other fixes, cleanups:
xls::verilog::SanitizeIdentifier renamed to SanitizeVerilogIdentifier to distinguish it from other uses of sanitize.
SanitizeVerilogIdentifier now sanitizes keywords.
Raise an error if port names collide rather than silently renaming because port names are part of the interface and should not be changed.
Don't call SanitizeVerilogIdentifer during block creation. We have a separate pass which handes that (NameLeagalizationPass).
Fixes #2209.
Fixes #805