-
Notifications
You must be signed in to change notification settings - Fork 298
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
[circt-lec] Fixed equivalence check for multiple outputs #5358
Conversation
19707fe
to
6389c1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks a lot for catching that bug! I'll defer to someone else on whether the failing test is appropriate - it might be worth getting verify-diagnostics
working on circt-lec
, which may offer a slightly nicer way to handle tests checking for equivalence check failure, but in my opinion that's not really within the scope of this PR (I'm happy to do it in a separate PR so this can be rebased on top, as I'm about to do it in #4647 which is architecturally very similar to circt-lec
).
6389c1d
to
c720936
Compare
Thank you for checking. |
This is an interesting idea - my main concern here (and with the current approach) would be that if |
The "not" utility can be used for expected error exit codes, like "not circt-opt ....", if that helps? Haven't looked at what's going on in this PR (verify-diagnostics interaction might not be quite what we want? Can look tomorrow if unsure) but anyway just FYI that's useful tool for this sort of thing. |
Thanks! My thinking re: verify-diagnostics is that we want to be able to distinguish between a non-zero return code as a result of non-equivalence (which doesn't currently emit an error, but obviously an easy change), and as a result of some other error being emitted if a breaking change is made (although there might be a nicer way to handle this I'm not aware of?). However, just using |
Adapted solver constraints to ensure all outputs must be equal.
c720936
to
8b57046
Compare
Thanks. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Currently the solver of the equivalence check creates a separate not equal constraint for each output of the processed module(s). Consequently, the constraint system becomes unsatisfiable as soon as at least one of the outputs is equivalent, causing the equivalence check for the entire module to pass. This PR changes the constraints to make them unsatisfiable iff all outputs are equivalent, by solving for the disjunction of the not equal expressions.
This also adds a test case, checking that two non-equivalent circuits do not pass the comparison. This turned out to be more complicated than I was expecting. When checking the output of
circt-opt
forc1 != c2
the test will still fail, because it produces a non-zero exit code for non-equivalent circuits. The best thing I could come up with was checking for equivalence and marking the test as expected to fail.