-
Notifications
You must be signed in to change notification settings - Fork 53
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 of Component Inlining/ Possible Bug in Component Inlining #1569
Comments
Interesting! I haven't read the example carefully yet but one passing thought about the new proposed control program: I think it somewhat makes sense but the big question is how do you build a group to enable the assignments in On the limitation with different bindings: Yup, this is a known limitation that this is because we don't have a clear way to inline different assignments to the control program of the
The discussion in the inlining PR and the original issue might shed more light on the challenges: #829 |
I would also suggest running the design with Verilator to see if it still produces the wrong answer |
Thanks for the response. Running the design with Verilator produces the same inconsistency in results.
Yeah, I'm not sure how we would make assignments active for the exact same time as the component's control program. Of course, if the control program is static, then it would be quite easy: we could just define a static group with a latency equal to that of the control program that contains the assignments we want. But that's not a solution in general. For dynamic control, I can't think of a good solution right now.
If, in
How do we make sure that |
@calebmkim we should probably address this as a part of #1813? |
Sounds good-- I thin this shouldn't be too difficult if we are end up implementing a general |
Example
The following program runs differently when we inline vs. don't inline (it's kinda complicated sorry, and here are the full files a.futil.txt, a.json.txt):
With inlining:
fud e --to dat --through icarus-verilog -s verilog.data a.json a.futil --from calyx -s calyx.flags "-x inline:always"
m
ends up with value6
Without inlining
fud e --to dat --through icarus-verilog -s verilog.data a.json a.futil --from calyx
m
comes out with value0
.Explanation
After some investigating, the problem it seems is that in
invoke a(...)(...);
the connections inside the (...) should only be active when theinvoke
is active (I believe). However, the way inlining currently works is that it adds a wirea_in, a_in2
etc. for each port ina
and a continuous assignment that assigns toa_in
as a continuous assignment in themain
component. The problem is, that we don't wanta_in
to be assigned continuously in the main component. We only want it assigned when theinvoke
is happening.One bright side I discovered this when I was testing inlining heuristics and I was running into a limitation in inlining: namely, we cannot invoke instances when the bindings are different (e.g., if we invoke
invoke a(...)(...);
inmain
twice, but the bindings inside(...)
are different, then inlining doesn't work). The reason for this, I believe, is because the continuous assignments toa_in
,a_in2
, etc. can't conflict, but if there are different bindings for different invokes, then they would. So if we solve this bug, then we would also probably solve this limitation of inlining as well.Conclusion
It almost seems like when we inline
invoke a(...)(...)
, it should be replaced by:par { //a's control flow; // the assignments inside (...)(...) }
Also, lmk if this doesn't make sense and I can try to clarify. Or perhaps a synchronous discussion would be helpful.
The text was updated successfully, but these errors were encountered: