8000 [ExportVerilog] Add LTL and Verif dialect support by fabianschuiki · Pull Request #5256 · llvm/circt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[ExportVerilog] Add LTL and Verif dialect support #5256

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
May 27, 2023

Conversation

fabianschuiki
Copy link
Contributor

Add support for emitting the assert, assume, and cover ops from the verif dialect, and property and sequence expressions from the ltl dialect directly in ExportVerilog. In the future we may want to build up AST-like ops in the SV dialect for this, simplify ExportVerilog, and add a lowering from Verif/LTL to SV separately. Doing so would allow us to do more involved conversions and leverage more syntactic sugar upon emission, and would declutter ExportVerilog. In their current form the LTL and Verif dialects are simple enough to emit directly though, so this is what this commit does for now.

The new verif assert-like ops can be used either in a procedural region, where they will emit as immediate assert(x) when possible, or a graph region like a module, where they will emit as assert property. We'll be able to add lowering options later to have more control over which flavor of assertions we want.

The properties and sequences in Verilog form a separate kind of expression tree that doesn't really mix with boolean expressions all that much. Therefore, this commit introduces a new PropertyEmitter inspired by the ExprEmitter which handles property and sequence expression trees.

@fabianschuiki fabianschuiki force-pushed the fschuiki/export-verilog-ltl-verif-support branch 2 times, most recently from 238451a to 82d7590 Compare May 24, 2023 21:52
@fabianschuiki fabianschuiki force-pushed the fschuiki/add-ltl-verif-dialects branch from 717a63c to 845b24d Compare May 24, 2023 23:24
@fabianschuiki fabianschuiki force-pushed the fschuiki/export-verilog-ltl-verif-support branch from 82d7590 to 580a15a Compare May 24, 2023 23:24
@dtzSiFive
Copy link
Contributor

In the future we may want to build up AST-like ops in the SV dialect for this, simplify ExportVerilog, and add a lowering from Verif/LTL to SV separately

Yes this would be great 👍 .

Copy link
Contributor
@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

Generally LGTM! Focused on the printing.

Added some suggestions, be sure to drop all the debug prints, the error diagnostics seem worth addressing as well, especially since encountering in test.

@fabianschuiki fabianschuiki force-pushed the fschuiki/export-verilog-ltl-verif-support branch from c1dad90 to 1f22d7e Compare May 25, 2023 18:32
@fabianschuiki fabianschuiki force-pushed the fschuiki/add-ltl-verif-dialects branch from 845b24d to 3e7ed1d Compare May 25, 2023 18:32
Copy link
Contributor
@darthscsi darthscsi left a comment

Choose a reason for hiding this comment

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

Nice! Perhaps file an issue to remove assert, assume, and cover from SV.

@uenoku
Copy link
Member
uenoku commented May 26, 2023

Looks awesome, great work! Maybe in the future we might want to introduce a variable declaration into LTL and spill multiply used expressions. Since currently all the expressions are expanded, it's easy to construct exponential example. Though I guess it's a bit artificial but it could be a problem when we started using LTL heavily, e.g:

  hw.module @Sequences(%a: i1) {
    %0 = ltl.concat %a, %a : i1, i1
    %1 = ltl.concat %0, %0 : !ltl.sequence, !ltl.sequence
    %2 = ltl.concat %1, %1 : !ltl.sequence, !ltl.sequence
    %3 = ltl.concat %2, %2 : !ltl.sequence, !ltl.sequence
    %4 = ltl.concat %3, %3 : !ltl.sequence, !ltl.sequence
    %5 = ltl.concat %4, %4 : !ltl.sequence, !ltl.sequence
    verif.assert %5 : !ltl.sequence
    hw.output
  }

current output:

  assert property (a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0
                   a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0
                   a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0
                   a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0
                   a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0 a ##0
                   a ##0 a ##0 a ##0 a);   

@fabianschuiki fabianschuiki force-pushed the fschuiki/add-ltl-verif-dialects branch from 3e7ed1d to e62a2b3 Compare May 26, 2023 22:30
@fabianschuiki fabianschuiki force-pushed the fschuiki/export-verilog-ltl-verif-support branch from 1f22d7e to 3b0036e Compare May 26, 2023 22:30
@fabianschuiki
Copy link
Contributor Author
fabianschuiki commented May 26, 2023

Haha nice one @uenoku! I hadn't thought of passing the same value multiple times to concat to create an exponential blow-up in the output. You're totally right, we should introduce a property and sequence declaration op that can be used to move the definitions behind a name. Then PrepareForEmission could also move multiply-used values behind such a declaration to reduce the output size.

Added #5286 to track this.

Base automatically changed from fschuiki/add-ltl-verif-dialects to main May 27, 2023 01:22
Add support for emitting the assert, assume, and cover ops from the
`verif` dialect, and property and sequence expressions from the `ltl`
dialect directly in ExportVerilog. In the future we may want to build up
AST-like ops in the SV dialect for this, simplify ExportVerilog, and add
a lowering from Verif/LTL to SV separately. Doing so would allow us to
do more involved conversions and leverage more syntactic sugar upon
emission, and would declutter ExportVerilog. In their current form the
LTL and Verif dialects are simple enough to emit directly though, so
this is what this commit does for now.

The new `verif` assert-like ops can be used either in a procedural
region, where they will emit as immediate `assert(x)` when possible, or
a graph region like a module, where they will emit as `assert property`.
We'll be able to add lowering options later to have more control over
which flavor of assertions we want.

The properties and sequences in Verilog form a separate kind of
expression tree that doesn't really mix with boolean expressions all
that much. Therefore, this commit introduces a new `PropertyEmitter`
inspired by the `ExprEmitter` which handles property and sequence
expression trees.
@fabianschuiki fabianschuiki force-pushed the fschuiki/export-verilog-ltl-verif-support branch from 3b0036e to fe3224d Compare May 27, 2023 01:24
@fabianschuiki fabianschuiki merged commit eb5090b into main May 27, 2023
@fabianschuiki fabianschuiki deleted the fschuiki/export-verilog-ltl-verif-support branch May 27, 2023 01:24
7BAE
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.

4 participants
0