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

Obscure AssertionError when assigning an io pin to the output of an instance #398

x44203 opened this issue Jun 3, 2020 · 0 comments


Copy link

x44203 commented Jun 3, 2020


from nmigen import *
from import *
from nmigen_boards import versa_ecp5_5g as FPGA

class Test(Elaboratable):
    def elaborate(self, platform):
        broken = True
        if broken:
            platform.add_resources([Resource("test", 0, Pins("A6"))])
            platform.add_resources([Resource("test", 0, Pins("A6", dir="o"))])

        pin = platform.request("test")

        m = Module()
        m.submodules += Instance("OSCG", o_OSC=pin) # It is important that this is an output
        return m

if __name__ == "__main__":

fails with

python                                                                                       1 ✘  21:04:46 
Traceback (most recent call last):
  File "", line 20, in <module>
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/build/", line 90, in build
    plan = self.prepare(elaboratable, name, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/build/", line 162, in prepare
    fragment._propagate_ports(ports=self.iter_ports(), all_undef_as_ports=False)
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/hdl/", line 462, in _propagate_ports
    self._prepare_use_def_graph(parent, level, uses, defs, ios, self)
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/hdl/", line 436, in _prepare_use_def_graph
    subfrag._prepare_use_def_graph(parent, level, uses, defs, ios, top)
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/hdl/", line 428, in _prepare_use_def_graph
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/hdl/", line 396, in add_defs
    assert defs[sig] is self

setting broken to 'False' makes it compile just fine.
Similar issues are in #320 and #191

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