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
[FIRRTL][LowerLayers] Clean up names of artifacts generated by layers #6733
Conversation
rwy7
commented
Feb 21, 2024
- Layer module name: move into helper.
- Layer instance name:
- don't put the parent module name in the instance name,
- lowercase each part of the instance name, not just the first word.
- Layer file name: move into helper.
- Captured port names: don't prefix the port name with an underscore.
We need a verifier that bans layernames which are empty or include an underscore. |
Good catch. If this is going to be a problem with the ABI, then we should put it in the spec. |
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.
Output looks way better. It is totally reasonable to drop the leading _
and to simplify the naming of the instances.
Some comments about how to further simplify things in the review.
- Layer module name: move into helper. - Layer instance name: - don't put the parent module name in the instance name, - lowercase each part of the instance name, not just the first word. - Layer file name: move into helper. - Captured port names: don't prefix the port name with an underscore.
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.
LGTM
auto operandName = getFieldName(FieldRef(operand, 0), true); | ||
const auto &[portName, _] = getFieldName(FieldRef(operand, 0), true); |
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.
Nice cleanup.
auto moduleName = newModule.getModuleName(); | ||
auto instanceName = | ||
(Twine((char)tolower(moduleName[0])) + moduleName.drop_front()).str(); | ||
auto instanceName = instanceNameForLayer(layerBlock.getLayerName()); |
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.
This is so much cleaner. 💯
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.
LGTM, nice work!
|
||
/// For all layerblocks `@A::@B::@C` in a circuit called Circuit, | ||
/// the output filename is `layers_Circuit_A_B_C.sv`. | ||
static SmallString<32> fileNameForLayer(StringRef circuitName, |
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.
Does this change for FIRRTL 4.0?
abi.md presently reads:
filename = "layers_" , module , "_", root , { "_" , nested } , ".sv" ;
(module not circuit)
Is this going to work for public modules that aren't the main module as-is?
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.
I think this pass does not do the right thing for public modules. This happens to work now for the main module. The pass should be updated to emit the collateral for all public modules in a follow-on. Good catch, Will.
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.
Opened an issue: #6748