-
Notifications
You must be signed in to change notification settings - Fork 639
Basic model checking API #1499
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
Basic model checking API #1499
Conversation
Also, I should mention that this can't be merged until FIRRTL 1.4 releases and we update the FIRRTL dependency accordingly (https://github.com/freechipsproject/firrtl/milestone/15) |
Since these are usable in contexts other than formal property checking (e.g. simulation), I would suggest |
It's notable that your actually code takes a If I understand correctly, SV properties can also take a name of the property. Is there any way to capture that in this API? |
Not presently, since the underlying FIRRTL generated will have no way of associating that tag. But I think there is a lot of interest in making it possible to add labels/tags to FIRRTL statements: if we get that done then this feature should be a simple addition. As I understand from the 06/22 Chisel dev meeting notes, enabling statement tags is something that @ekiwi is investigating? |
Hi Tom, thanks a lot for working on this!
I was initially thinking about just placing these statements in the
The plan should be to reimplement the existing One thing that needs to be addressed is the fact that the "legacy"
I am going to work on adding some verification function to Chisel (probably
This would be cool! It should probably be a library similar to chisel-test.
My research is eventually going to take me into that direction. I might be able to add a SMTLib + Btor2 backend to Firrtl in the next couple of months. Writing a new model checker in Scala will take a lot longer.
Yes. We are basically all in agreement that we want to have names for statements (many are also interested in being able to annotate statements). But we are bike shedding the syntax at the moment. Once these statements have a name we could also add an option to generate a named property when emitting verification statements to SystemVerilog. However, this is not supported by the open source version of |
I think that adding features like this to the core language (rather than a library) and relying on simple hardware translations has significant downsides. Specifically, this actually makes it harder to emit an idiomatic SVA assertion that reflects the user's intent. |
Does |
The problem with a naive implementation of You can circumvent this problem by ensuring that |
After investigating this for a day, I think it would be a mistake for Chisel to provide a built-in The use of the |
I see what you're getting at, but I actually think this is a good opportunity for Chisel to provide some safe defaults that address some of these pitfalls of Similarly, for formal we could have a safe defaults All that said, perhaps this stuff just belongs in a separate library, which users can optionally bring on for convenience. As long as Chisel facilitates |
Could we try just adding |
Should it be a |
Good point, that would be best! |
@albert-magyar Can we make another Firrtl 1.4 snapshot? I don't think these CI tests can pass until the Firrtl 1.4 snapshot includes the model checking API. https://github.com/freechipsproject/firrtl/commits/v1.4-20200603-SNAPSHOT |
The build process is supposed to use FIRRTL master (you can see the build step here cloning FIRRTL and publishing it locally). However, I can reproduce this not working locally... Looking into it. |
I haven't looked to closely at all the code changes in here, but it looks good so far. I think the one other step would be to make the builtin |
@albert-magyar That requires some knowledge of how your pass that replaces asserts with when + printf + stop works. One corner case that I can think of is when you use assert with varargs you should probably emit a when + printf + assert and then your pass will replace the assert with a stop. |
`generateFirrtl` has been cut from Chisel
I concur with Kevin here. We should consider how this new assert should interact with the old assert, but I think it could just as easily be in a follow-up to this toehold PR. Once we have a basic foundation in place and users can start experimenting with formal, there will be plenty of time to work through all the cool features that we could potentially add to figure out which ones are most worthy. |
@seldridge I appreciate you fixing the treadle/firrtl snapshot clobbering thing! It looks like there might be some lingering deprecation warning issues from treadle? https://app.circleci.com/pipelines/github/freechipsproject/chisel3/1925/workflows/0a062e7b-0b2a-4c44-bedb-7b08b8ef0702/jobs/7188/steps |
No problem, @tdb-alcorn. Sorry about that. There's a series of issues here that are fixed:
However, one commit sneaked through FIRRTL CI and is causing problems, but the following is in the pipeline to fix it: I believe that the appropriate interlocks are in place to prevent this happening again. 🤞 |
Alright, the current reason for CI failure is that there are too many scalastyle warnings. If the number of warnings exceeds 40, CI will fail. I believe that this PR introduced some Scalastyle errors (which can be checked with |
Thanks for figuring this out! I'm on it |
@seldridge sorry to keep bugging you The build is failing to find package repositories. I don't think (?) I could have caused this in the last two commits (they were all just style fixes). Here's the error:
|
That looks like flaky CI. 🤷♀️ I restarted it... |
I've updated the PR description and release notes above to reflect the actual state of the PR. |
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
Can we merge this? |
@albert-magyar Wanted to manually squash some commits and keep the style changes in a separate commit before merging. |
Yes, we just got the CI resolved with #1519. Sorry to make you go in circles with this, but if you can rebase on master and drop the scalastyle-related changes, I can merge it straight away. |
@albert-magyar Done. After CI passes (🤞) we should be good to go |
@tdb-alcorn Can please remove all of the |
Woops, I forgot I had added those. Removed now. |
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.
A small style change.
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!
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
This change add
assert(), assume(), cover()
statements under a newchisel3.experimental.verification
package. These objects generate their FIRRTL counterparts. This is a follow-up to the new model checking statements added to FIRRTL.A Chisel user will access these new affordances by importing the verification package as a namespace, to avoid clashing with the existing
chisel3.assert
.In the future we might like to add other affordances like
past(signal, n)
, and a formal testing backend hook to run Symbiyosys (complementary to the existing Chisel testing backends). We may also consider creating opinionated but user-friendly classes for doing model checking, analogous to the differences betweenModule
andRawModule
.Related issue: #984
Type of change: feature request
Impact: API addition (no impact on existing code)
Development Phase: implementation
Release Notes
Adds
assert(), assume(), cover()
statements to a newchisel3.experimental.verification
library. These statements generate their FIRRTL counterparts, which in turn emit their Verilog counterparts. Note that only SystemVerilog's immediate statements are supported. These new statements form the foundation of a new model checking interface that may be extended in future releases.