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

Open
x44203 opened this issue Jun 3, 2020 · 0 comments
Labels

Comments

@x44203
Copy link

x44203 commented Jun 3, 2020

Executing

from nmigen import *
from nmigen.build 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"))])
        else:
            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__":
    FPGA.VersaECP55GPlatform().build(Test())

fails with

python mcve-assert-defs.py                                                                                       1 ✘  21:04:46 
Traceback (most recent call last):
  File "mcve-assert-defs.py", line 20, in <module>
    FPGA.VersaECP55GPlatform().build(Test())
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/build/plat.py", line 90, in build
    plan = self.prepare(elaboratable, name, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/build/plat.py", 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/ir.py", 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/ir.py", 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/ir.py", line 428, in _prepare_use_def_graph
    add_defs(value._lhs_signals())
  File "/home/user/.local/lib/python3.8/site-packages/nmigen/hdl/ir.py", line 396, in add_defs
    assert defs[sig] is self
AssertionError

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
Labels
Development

No branches or pull requests

2 participants