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

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

Closed
programmerjake opened this issue Apr 1, 2020 · 0 comments · Fixed by #346
Closed

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

programmerjake opened this issue Apr 1, 2020 · 0 comments · Fixed by #346
Labels
Milestone

Comments

@programmerjake
Copy link
Contributor

programmerjake commented Apr 1, 2020

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()
@whitequark whitequark added the bug label Apr 1, 2020
programmerjake added a commit to programmerjake/nmigen-1 that referenced this issue Apr 2, 2020
whitequark pushed a commit that referenced this issue Apr 2, 2020
…hdl.verilog.convert and compat.run_simulation

Fixes #344
@whitequark whitequark added this to the 0.3 milestone Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants