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] Lower firrtl.formal to verif.formal #7836

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

fabianschuiki
Copy link
Contributor

Add a lowering from firrtl.formal to verif.formal in the FIRRTL-to-HW conversion. The lowering creates a verif.formal op that simply instantiates the module pointed to by firrtl.formal, with symbolic values providing the inputs to the module. We may want to inline the instance in the future, but that is purely cosmetic.

This now allows FIR files to contain formal unti tests that can be lowered to HW through firtool and then executed using circt-test.

Add a lowering from `firrtl.formal` to `verif.formal` in the
FIRRTL-to-HW conversion. The lowering creates a `verif.formal` op that
simply instantiates the module pointed to by `firrtl.formal`, with
symbolic values providing the inputs to the module. We may want to
inline the instance in the future, but that is purely cosmetic.

This now allows FIR files to contain `formal` unti tests that can be
lowered to HW through `firtool` and then executed using `circt-test`.
@fabianschuiki fabianschuiki added the FIRRTL Involving the `firrtl` dialect label Nov 19, 2024
Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

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

LGTM!

auto builder = OpBuilder::atBlockEnd(topLevelModule);
auto newFormalOp = builder.create<verif::FormalOp>(
oldFormalOp.getLoc(), oldFormalOp.getNameAttr());
newFormalOp->setDiscardableAttrs(oldFormalOp.getParametersAttr());
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we want some ODS verified dictionary attribute for the verif.formal op instead of using a discardable attribute?

Copy link
Contributor Author

@fabianschuiki fabianschuiki Nov 21, 2024

Choose a reason for hiding this comment

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

We should definitely do that. I'll add that in a follow-up PR.

@fabianschuiki fabianschuiki merged commit 4b6f499 into main Nov 21, 2024
4 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/lower-firrtl-formal branch November 21, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIRRTL Involving the `firrtl` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants