Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions amaranth/lib/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from .. import tracer
from ..hdl._ast import Shape, ShapeCastable, Const, Signal, Value, ValueCastable
from ..hdl._dsl import Module
from ..hdl._ir import Elaboratable
from .._utils import final
from .meta import Annotation, InvalidAnnotation
Expand Down Expand Up @@ -1401,6 +1402,9 @@ def connect(m, *args, **kwargs):
a connection cannot be made.
"""

if not isinstance(m, Module):
raise TypeError(f"The initial argument must be a module, not {m!r}")

objects = {
**{index: arg for index, arg in enumerate(args)},
**{keyword: arg for keyword, arg in kwargs.items()}
Expand Down
9 changes: 9 additions & 0 deletions tests/test_lib_wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,15 @@ def test_connect_multi_some_in_pairs(self):
a=Signal(),
b=Signal()))

def test_bug_1435_missing_module(self):
sig = Signature({"a": Out(1)})
p = sig.create()
q = sig.flip().create()

with self.assertRaisesRegex(TypeError,
r"^The initial argument must be a module, not <PureInterface: .+>$"):
connect(p, q)


class ComponentTestCase(unittest.TestCase):
def test_basic(self):
Expand Down