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

[firtool] Run LowerFormalToHW pass when emitting SV #7837

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

fabianschuiki
Copy link
Contributor

Add the LowerFormalToHW pass to the HW-to-SV pipeline of firtool. This will make any verif.formal ops be emitted as additional top-level modules, which is in line with what circt-test also does.

In the future we may want to have additional controls in firtool to disable emission of these formal tests. (But we would likely do this by removing them early in the pipeline to open up new optimization possibilities rather than not emitting them at the final stage.)

This creates a small amount of churn in the directories.fir test which was sensitive to any kind of folder running, e.g. through the dialect conversion or greedy rewriter framework. The latter one is used by the formal op lowering, and it's probably a good idea to not have tests fail when a very common optimization runs.

Add the `LowerFormalToHW` pass to the HW-to-SV pipeline of firtool. This
will make any `verif.formal` ops be emitted as additional top-level
modules, which is in line with what circt-test also does.

In the future we may want to have additional controls in firtool to
disable emission of these formal tests. (But we would likely do this by
removing them early in the pipeline to open up new optimization
possibilities rather than not emitting them at the final stage.)

This creates a small amount of churn in the `directories.fir` test which
was sensitive to _any_ kind of folder running, e.g. through the dialect
conversion or greedy rewriter framework. The latter one is used by the
formal op lowering, and it's probably a good idea to not have tests fail
when a very common optimization runs.
@fabianschuiki fabianschuiki added FIRRTL Involving the `firrtl` dialect verif labels Nov 19, 2024
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

; MLIR_OUT-DAG: [[OBJ3:%.+]] = om.object @MemorySchema
; MLIR_OUT-DAG: om.constant "baz_m_ext" : !om.string
; MLIR_OUT-DAG: om.constant #om.integer<3 : ui64> : !om.integer
; MLIR_OUT: om.class.fields [[OBJ1]], [[OBJ2]], [[OBJ3]] : !om.class.type<@MemorySchema>, !om.class.type<@MemorySchema>, !om.class.type<@MemorySchema>

Copy link
Member

Choose a reason for hiding this comment

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

This is fine. However, this test in appropriately combined directory testing with OM testing. (Apparently, my past self thought the same thing: #5224 (comment))

If it's cleaner, in a follow-on, to either (1) factor this out of this test or (2) just delete this part of the test, then that would be good. @prithayan: Do you have any thoughts here?

Copy link
Contributor Author

@fabianschuiki fabianschuiki Nov 25, 2024

Choose a reason for hiding this comment

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

Yeah that would be great! I'll land this for now. Let's see what @prithayan thinks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the messy lit tests and missing out your original review @seldridge , I think it makes sense to remove the testing from here. I added the om classes just because the original test was checking for the metadata verbatim ops, which will be replaced by the OM. I will take up the task to cleanup the tests.

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

Successfully merging this pull request may close these issues.

3 participants