Skip to content
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

Fragment.get should detect cycles in elaboration #592

Closed
Ravenslofty opened this issue Feb 10, 2021 · 5 comments
Closed

Fragment.get should detect cycles in elaboration #592

Ravenslofty opened this issue Feb 10, 2021 · 5 comments
Milestone

Comments

@Ravenslofty
Copy link
Contributor

Ravenslofty commented Feb 10, 2021

While watching a stream by @awygle I noticed Fragment.get() has a while True loop to chain elaborate calls. This could be improved by detecting possible loops in elaboration, in the event that some elaboration-time metaprogramming has a bug that causes a cycle.

For example, the following test case will never complete elaborating:

from nmigen import *
from nmigen.back import verilog

class Example(Elaboratable):
    def elaborate(self, platform):
        return self

e = Example()
print(verilog.convert(e))
@awygle
Copy link
Collaborator

awygle commented Feb 10, 2021

Doesn't this run into the halting problem, in the general case? We could do something like a recursion limit.

@whitequark
Copy link
Member

whitequark commented Feb 10, 2021

@awygle has a good point.

@awygle
Copy link
Collaborator

awygle commented Feb 10, 2021

We could also detect the specific case @Ravenslofty calls out above - seems like a reasonably common failure mode.

@whitequark whitequark added this to the 0.3 milestone Dec 11, 2021
@whitequark
Copy link
Member

whitequark commented Dec 11, 2021

@awygle I agree.

@Ravenslofty
Copy link
Contributor Author

Ravenslofty commented Dec 11, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants