-
Notifications
You must be signed in to change notification settings - Fork 612
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
Bool: add implication operator |-> #1500
base: main
Are you sure you want to change the base?
Conversation
I'm not sure if this is something we should add to the When there are no temporal operators, |
Thanks for pointing me to that Stack Overflow discussion. While However, I am very open to using |
Another possible alternative would be |
Bikeshed comment: Scala operator precedence should annoyingly be considered when choosing the leading character of new infix operators... |
5e3e7d1
to
9c6b727
Compare
Thanks for pointing be to this Schuyler! These are the SV operator precedences (high to low):
|
9c6b727
to
90c9102
Compare
How about just |
Thanks! I forgot about that.
As far as I can tell My goal here is to provide a simple boolean operator that - while very useful in a verification context - can also easily be used for synthesizable hardware. |
OK. I have to correct this. While an answer to the StackOverflow question linked above claims that
reading the spec a little more makes clear that Wow, seems like there is a lot to consider and I do not have any clear preference anymore. |
90c9102
to
c843c06
Compare
No strong prefs here, either, except to say that I would like some form of this operator to help me write more idiomatic assertions. |
c843c06
to
7dd1e7b
Compare
Echoing @albert-magyar's comments (#1499 (comment)), I think we should organize all of these sequence and property-adjacent operators into a separate package. It seems desirable to capture these expressions in Scala ASTs so that we can easily provide multiple implementations rather than immediately mapping them to hardware, destroying that information and requiring it to be re-inferred in the FIRRTL. It also helps notionally separate the "hardware design" operations from the "property specification" operations. |
The implication operator that I am trying to implement here is supposed to be a "hardware design" operation, it does not have anything to do with sequences and is not temporal. My bad for starting with a syntax that is used for SVA sequences. |
Running
The majority are used in the context of an assertion, however, I don't think there is a reason to only restrict the implication operator to assertions since it only is a shorthand for |
This also is more-or-less a perfect example of the kind of "collateral" that conveys information that is not fully captured in the IR that can be fluently captured with annotations. The interface between SVA and standard SV operators is at the atomic proposition level; this interface can translate robustly to targets. The general theme of late has been to do lots of things with annotations; this fits that pattern about as well as any other use case. I am not certainly not the biggest proponent of supporting things via annotations in general, but I think assertions intended to translate to rich downstream representations (that we will likely never fully re-implement) are a better fit than most things.
While this is technically true, it is harder to reason about outside of an assertion context because you have to sensibly reason about the consequence of the negation of the implication by specifying a hardware behavior. I would argue that the this... ...is less clear than using basic booleans. However, that is clearly a matter of taste. There are certainly arguments for and against including of the bitstring operators that Chisel currently lacks. |
I agree that anything that has multi-cycle semantics including the (Note that adding SVA sequences to rocket-chip would prohibit the use with open-source |
I think @albert-magyar's argument is that it is not more clear. Obviously this is opinion so I'd defer to designers on it. A mild concern I have is that having
It doesn't if we support multiple backends for the sequences which is what I was trying to promote in my earlier comment (#1500 (comment)). Some temporal sequence support captured into an alternative AST and linked to the FIRRTL via annotations could be lowered to FIRRTL for backends like Yosys while enabling direct SVA emission on proprietary flows. |
Yeah, I admit that the name was potentially chosen poorly. It is very sad that I want to point out that without any of the other SVA operators, afaik
I have been investigating this option for the last couple of days and I have come to the conclusion that while it is possible, it would probably take around 3-4 months of full time work to get this working well. Checkout |
@hcook and @johningalls-sifive , did you 👍 on @jackkoenig's comment because you agree that The first question is important in order to decide whether we should just close this PR. |
I thumbs-up'd for this:
|
I write a lot of my |
I agree the pattern is a common one in circuit creation beyond just writing assertions, and if calling it out with a unique operator provides benefit to downstream tool consumers than I am all for adding an easy way to express it. I don't find that the particular example of And I am contrasting this circuit use case to I think And finally I don't think my stylistic disapproval of a secondary use case should prevent progress on the original primary one |
The proposed change is never seen by any downstream tool, it is just syntactic sugar. (also, for any half-way decent logic optimizer,
I think I agree with your assessment that an Currently we use a regular UInt<1> signal to feed our assertions, thus adding an The other option floated by @jackkoenig and @albert-magyar would be pretty complicated if the sole purpose is adding syntactic sugar for |
I think maybe we are talking at cross purposes here. I definitely got a little too general in my original response, sorry for that; I was incorrectly mixing my thoughts on #1499 into this. Here is my actual position:
An alternative is to add import chisel3.assertions._
...
assert(a |-> b) This in some way mirrors SVA, where the use of |
Seems like there aren't enough people in favor of this. |
Can I suggest reconsidering this idea, perhaps with the hopefully least controversial approach of adding a method named I agree with Kevin's remark that this is useful independent of a more fully featured assertion API. |
I'm happy with |
(Some of these Utils probably should be added to the Chisel standard library, some of them could use some improvements, like |
Related issue: #1499
Type of change: new operator
Impact: API addition (no impact on existing code)
Development Phase: implementation
Release Notes
a |-> b
as a short hand for!a || b