8000 [Verif] Add pass to lower symbolic values by fabianschuiki · Pull Request #8422 · llvm/circt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Verif] Add pass to lower symbolic values #8422

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

fabianschuiki
Copy link
Contributor

Add the LowerSymbolicValues pass which converts verif.symbolic_value ops either to a black box instance or to a wire declaration with a (* anyseq *) attribute. The former is useful since most formal tools have a way of treating black boxes as internal port boundaries, such that black box output ports behave the same as top-level input ports. The latter is useful for interoperability with Yosys which has a custom Verilog attribute "anyseq" that marks a wire declaration as a symbolic value.

@fabianschuiki fabianschuiki marked this pull request as ready for review April 16, 2025 22:59
Add the `LowerSymbolicValues` pass which converts `verif.symbolic_value`
ops either to a black box instance or to a wire declaration with a
`(* anyseq *)` attribute. The former is useful since most formal tools
have a way of treating black boxes as internal port boundaries, such
that black box output ports behave the same as top-level input ports.
The latter is useful for interoperability with Yosys which has a custom
Verilog attribute "anyseq" that marks a wire declaration as a symbolic
value.
@fabianschuiki fabianschuiki force-pushed the fschuiki/lower-symbolic-values branch from ad5d4fe to 3a045c3 Compare April 16, 2025 23:42
Copy link
Member
@dobios dobios left a comment

Choose a reason for hiding this comment

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

Looks great! This is super useful and hopefully enables these formal tests to be used in downstream SV tools! I just wanted to make sure I understand the tooling correctly, so I left some small comments about that.

@@ -306,6 +306,8 @@ LogicalResult firtool::populateHWToSV(mlir::PassManager &pm,
const FirtoolOptions &opt) {
pm.nestAny().addPass(verif::createStripContractsPass());
pm.addPass(verif::createLowerFormalToHWPass());
pm.addPass(
Copy link
Member

Choose a reason for hiding this comment

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

Just making sure I understand this right, does opt.shouldExtractTestCode() state that test code should be lowered or should be removed? If it means that it should be lowered, shouldn't this pass only be run if we want to generate "formal verification" SV and symbolic values should be outright removed otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ExtractTestCode is a FIRRTL-specific pass that moves assert/assume/cover statements into a separate Verilog file/module that can then be bound into the original location. As long as we create any asserts/assumes/covers before that pass runs, everything should be good 👍

%3 = verif.symbolic_value : !hw.array<6xi7>
dbg.variable "x3", %3 : !hw.array<6xi7>
}

Copy link
Member

Choose a reason for hiding this comment

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

Is there also a test for when we should remove symbolic values when lowering to SV?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently there's no mode for the pass that removes symbolic values. I'm not entirely sure how that would look like. Replacing with a constant feels wrong, and otherwise I don't know what we could put there instead of the symbolic value. Do you have any ideas?

@fabianschuiki fabianschuiki merged commit 539bba9 into main Apr 22, 2025
5 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/lower-symbolic-values branch April 22, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0