Skip to content

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

Open
@the6p4c

Description

@the6p4c

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():
    yield

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

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions