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

[FIRRTL] Add a new FIRRTL annotation to specify type lowering behavior of module body #7751

Merged
merged 5 commits into from
Dec 5, 2024

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Oct 30, 2024

Add a new annotation to control type lowering behavior for internal signals
within a module, separate from the port convention. This allows more fine-grained
control over how aggregate types are handled inside modules.

The new annotation works similarly to ConventionAnnotation but applies to
internal signals rather than module ports. It supports the same conventions
and includes an 'includeHierarchy' option to apply the setting to all
modules in the hierarchy.

@uenoku uenoku marked this pull request as draft October 30, 2024 17:15
@uenoku uenoku force-pushed the dev/hidetou/convention-atr branch 2 times, most recently from 2160b4d to c61bffc Compare October 30, 2024 17:24
@uenoku uenoku marked this pull request as ready for review October 30, 2024 17:25
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@uenoku uenoku force-pushed the dev/hidetou/convention-atr branch 2 times, most recently from 2c369d2 to 96b6abd Compare November 14, 2024 15:04
@uenoku uenoku changed the title [FIRRTL] Extend Convention to specify type lowering for body [FIRRTL] Add a new FIRRTL annotation to specify type lowering behavior of module body Nov 14, 2024
@uenoku uenoku force-pushed the dev/hidetou/convention-atr branch from 96b6abd to 315832d Compare November 14, 2024 15:08
…r of module body

This allows more fine-grained control over how types are lowered in different contexts.

This also adds an "includeHierarchy" option to Convention annotations that
allows applying the convention to all modules in the hierarchy below the
annotated module.
@uenoku uenoku force-pushed the dev/hidetou/convention-atr branch from 315832d to 35a3766 Compare November 14, 2024 16:06
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The includeHierarchy field seems unnecessary. I also think this is unnecessary for the Convention annotation. My reasoning here is that convention is really supposed to "Port Lowering ABI". This is something that is only defined on public modules and everything else is up to the compiler to decide.

Is there a request for includeHierarchy and/or is there a way that we could avoid this and handle it entirely from Chisel, e.g., add some builder state which indicates what the convention is within a scope and then apply it to all modules under that scope?

That said, I am fine with delaying this for now as long as this never becomes a part of an implied ABI that a user relies on.

firrtl.matchingconnect %port, %r : !firrtl.vector<uint<8>, 1>
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, exhaustive test. 👍

@uenoku
Copy link
Member Author

uenoku commented Dec 5, 2024

The includeHierarchy field seems unnecessary. I also think this is unnecessary for the Convention annotation. My reasoning here is that convention is really supposed to "Port Lowering ABI". This is something that is only defined on public modules and everything else is up to the compiler to decide.

Fair point, I'm totally fine to drop includeHierachy for Convention annotation. For body type lowering, it's useful to annotate the annotation for design module and ensure that module bodies in the design is scalarized.

add some builder state which indicates what the convention is within a scope and then apply it to all modules under that scope?

That would be great. If we can mark every module in design with this annotation in Chisel, we really don't need includeHierachy.

There will never be no ABI change regarding body lowering. The intention of the annotation is more like per-module compiler option used in LowerTypes.

@uenoku
Copy link
Member Author

uenoku commented Dec 5, 2024

I updated to remove includeHierarchy from convention attr and clean up the annotation application. Body type lowering annotation still has includeHierarchy since it looks not worth modifying chisel internal for this specific annotation.

@uenoku uenoku force-pushed the dev/hidetou/convention-atr branch from 110c916 to 388787b Compare December 5, 2024 02:19
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is interesting about these changes is that we could move in a direction of removing the CLI options for aggregate preservation and instead rely on the annotations / attributes. As a middle ground, it may be better to change the CLI (in a follow-on) to apply the annotations or do it as a part of parsing.

This is more of a thought than a definite direction we should go.

@uenoku uenoku merged commit 0c1465d into main Dec 5, 2024
4 checks passed
@uenoku uenoku deleted the dev/hidetou/convention-atr branch December 5, 2024 07:29
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