-
Notifications
You must be signed in to change notification settings - Fork 52
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
[Semantics] with
groups and if
/while
#1699
Comments
Awesome; thanks for writing this up! Just a teensy bit of pedantry:
To be clear, our compiler doesn't compile things this way—it just semantically reserves the right to do so. So, semantically, a
To put it just slightly differently, the main reason we can think of for the current policy ("
This seems like a good direction to me. It is similar to (but cleaner than) option 1 in #1438 (comment). Basically, our policy needs two parts:
Consider this program (based on #1633):
The idea in this example is that So I guess my remaining questions are:
|
I feel like I may be going around in circles a bit, but this was oversimplified somewhat:
This imaginary optimization is quite a bit more complicated than I made it sound for dynamic With that complexity in mind, one could argue reasonably that:
However, I think that argument is incompatible with the goal of letting |
I'm going to centralize the conversation about this topic to this issue. First off, some context:
Next, a summary from the synchronous discussion: The core problem that we were trying to solve with Next up, we wanted the ability to have "zero-cycle transitions" when we had a lot of nested
This lead to the requirement that conflicts can occur anywhere in the scope of the Given this context, we had two desiderata:
Note that these two correspond to the two different problems with |
Awesome; thanks for the summary, @rachitnigam. Here is a bit more summary from the synchronous discussion, leading up to a concrete proposal to consider. The Performance Cost of
|
I've missed the synchronous discussion for this, but I just want to make sure I'm understanding what the current situation is, especially reading #1732. GoalsIt seems that, we have two eventual goals:
Implications of these goalsIn order to support 2, it seems like the only place where this combinational logic (i.e., the logic that In this case, it seems like we should probably be looking for some sort of requirement on the continuous assignments that trigger A port is stable iff:
The possible bugs that we've been able to think of (e.g., in #1438) involve the fact that the continuous assignments are not being unconditionally assigned to, and something like the above^ requirements would make them safe from that. |
Yep, I think that is exactly right! FWIW, I think that is the Faustian element of this deal: if we decide we don't like I would love to hear more opinions about whether people like this particular trade-off.
Yes, exactly. Your stability requirements definitely seem sufficient and they are simple rules to follow, so that's great. It may be possible to have "tighter" requirements (i.e., to allow some conditional assignments), but it's not clear if we need that relaxation. |
Making this an issue instead of a discussion to avoid discussion blindness, but we can move that if preferred. This is based on a conversation @sampsyo and I had today.
My current understanding of the semantics for
with
groups is that they are always active during the execution of the body. We could make this choice for the purpose of an adversarial overlap analysis to avoid possible group conflicts, however, this doesn't make a whole lot of sense given that awith
statement is necessarily a combinational group and so can only really be evaluated at the top of the group.The condition of the loop is generally stable-ish in these contexts, i.e. a combinational component immediately driven by stable inputs, and the actual value (not necessarily the value output by the comb group) used to branch must be stable during the execution of the loop/conditional body. One argument for keeping the
with
assignments active during the body execution is that the condition of the body that is often realized by a register could be replaced with the conditional guard itself, however we cannot take this as the "true" semantics ofwhile
/if
because this could cause the body to exit prematurely.the above would skip the actual work on the last cycle. It is also easy enough to construct examples that would prematurely exit an
if
block or (depending on compilation) to switch from the true to false branch mid way through execution.So clearly the condition computed by the comb group needn't be stable/unchanging during the body execution---otherwise the while loop would not be able to update their counters/conditions during their execution---but if the compiler can prove or otherwise convince itself that the condition is stable after a point it may be computed early and stored in a register to provide a stable condition.
All this suggests that the semantics of a
while
loop should be that the condition is computed in the "instant" between the conclusion of the body and the start of the next loop (or exit) and that methods of computing the condition early are optimizations to avoid an extra cycle.If that is the agreed upon semantics, then it does not seem that there is a clear reason to mandate that the
with
assignments be active during the body evaluation.@sampsyo please chime in if I missed anything!
The text was updated successfully, but these errors were encountered: