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

Simulator with non-passive sync process and no clock added runs indefinitely without emitting a warning #442

the6p4c opened this issue Jul 21, 2020 · 2 comments


Copy link

the6p4c commented Jul 21, 2020

Take the following example, some basic synchronous logic and an even more basic sync process for the simulator:

from nmigen import *
from nmigen.back.pysim import *

class Design(Elaboratable):
    def elaborate(self, platform):
        m = Module()

        s = Signal()
        m.d.sync += s.eq(1)

        return m

def proc():

sim = Simulator(Design())
# whoops, forgot to sim.add_clock(1e-9)

Since no clock is added to the simulator instance, the code never exits. It's a pretty easy line to miss and difficult to debug since it seems as if the simulator just... does nothing.

A warning when running the simulator with a sync process and no clock would be quite useful. A passive sync process obviously does not cause this - perhaps the warning should be raised on the first yield if the clock is undriven.

Copy link

whitequark commented Jul 21, 2020

I don't think this is necessarily a bug. You could be driving a clock yourself, or you could be testing async logic, etc. So I expect this to have rather annoying false positives.

Copy link

Oh wait, you mean warning if you are waiting on an undriven signal. We can do that, yeah.

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

No branches or pull requests

2 participants