Skip to content

run_simulation doesn't call elaborate before trying to set domains #344

Closed
@programmerjake

Description

@programmerjake

It crashes:

Traceback (most recent call last):
  File "src/test_run_simulation_bug.py", line 28, in <module>
    test1()
  File "src/test_run_simulation_bug.py", line 24, in test1
    vcd_name="test_run_simulation_bug.vcd")
  File "/home/jacob/projects/nmigen/nmigen/compat/sim/__init__.py", line 22, in run_simulation
    fragment.domains += ClockDomain("sync")
AttributeError: 'MyModule' object has no attribute 'domains'

nMigen version: 2d1e12d

Failing code:

from nmigen import Signal, Module, Elaboratable
from nmigen.compat.sim import run_simulation


class MyModule(Elaboratable):
    def __init__(self):
        self.a = Signal()

    def elaborate(self, platform):
        m = Module()
        m.d.sync += self.a.eq(~self.a)
        return m


def test1():
    dut = MyModule()

    def generator():
        for _i in range(10):
            print((yield dut.a))
            yield

    run_simulation(dut, generator(),
                   vcd_name="test_run_simulation_bug.vcd")


if __name__ == '__main__':
    test1()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions