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 Inline Formal Test ops #7374

Merged
merged 38 commits into from
Aug 14, 2024
Merged

Conversation

dobios
Copy link
Member

@dobios dobios commented Jul 23, 2024

The goal of this PR is to add a new set of inline formal test ops to FIRRTL:

FIRRTL version 4.0.0

circuit Foo:
  public module Foo:
    input data : UInt<32>
    input c : UInt<1>
    output out : UInt<32>
    ;; Foo body

  module FooTest:
      ;; example test
      inst foo of Foo
      ;; symbolic input -- maps to input in btor2
      input s_foo_c : UInt<1>
      input s_foo_data : UInt<32> 
      ;; feed the symbolic inputs to the instance
      connect foo.c, s_foo_c 
      connect foo.data, s_foo_data
      ;; example assertion that uses the symbolic inputs and outputs
      intrinsic(circt_verif_assert, intrinsic(
        circt_ltl_implication : UInt<1>, s_foo_c, eq(foo.out, s_foo_data))
      )

  formal testFormal of FooTest, bound = 20
  
  

These new ops will then be lowered to the existing verif.formal op in a future PR.

@dobios dobios added the FIRRTL Involving the `firrtl` dialect label Jul 24, 2024
@dobios dobios marked this pull request as ready for review July 24, 2024 01:41
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

Awesome! Parser and Op definitions generally look great. It would be also necessary to modify firrtl-spec. Regarding FIRRTL dialect representation there are several things to consider since FormalOp is a first operation which is not FModuleOp but could contain mots of FIRRTL ops:

  1. InstanceGraph -- FormalOp has an instance op so we would need to create an edge from FormalOp to the referenced module. Probably need to implement ModuleOpInterface.
  2. FModuleOp pass -- LowerIntrinsics, ExpandWhen etc. are currently FModuleOp pass so we need to find a way to run them on FormalOp

lib/Dialect/FIRRTL/Import/FIRParser.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Import/FIRParser.cpp Outdated Show resolved Hide resolved
lib/Dialect/FIRRTL/Import/FIRParser.cpp Outdated Show resolved Hide resolved
include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td Outdated Show resolved Hide resolved
dobios and others added 2 commits July 24, 2024 13:35
Co-authored-by: Hideto Ueno <uenoku.tokotoko@gmail.com>
@mmaloney-sf
Copy link
Contributor

@uenoku commented:

It would be also necessary to modify firrtl-spec.

Feel free to reach out to me if you want to offload the FIRRTL spec work to me.

@dobios dobios force-pushed the dev/dobios/firrtl-inline-formal branch from ed0e993 to a5b6f2a Compare July 24, 2024 22:57
@dobios dobios changed the title [FIRRTL] Add Formal Test intent op to FIRRTL [FIRRTL] Add Inline Formal Test ops Jul 26, 2024
@dobios dobios marked this pull request as draft July 31, 2024 00:31
@dobios dobios marked this pull request as ready for review August 8, 2024 20:57
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

The new design looks fantastic! Thank you for iterating on this! The implementation looks great to me except for few nits regarding ReferableDeclOp.

"firrtl::FModuleOp", "firrtl::LayerBlockOp",
"firrtl::WhenOp", "firrtl::MatchOp", "sv::IfDefOp"]>]> {}

def FormalOp : FIRRTLOp<"formal", [
HasParent<"firrtl::CircuitOp">,
DeclareOpInterfaceMethods<SymbolUserOpInterface>,
Copy link
Member

Choose a reason for hiding this comment

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

I think it needs Symbol as well.

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

LGTM, can you check whether we should first change FIRRTL-spec or merge the PR?

@dobios
Copy link
Member Author

dobios commented Aug 14, 2024

Firrtl spec is updated, so I guess we're good to go!

@dobios dobios merged commit 351b62f into main Aug 14, 2024
4 checks passed
@dobios dobios deleted the dev/dobios/firrtl-inline-formal branch August 14, 2024 23:40
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.

3 participants