if ports is None:
fragment._propagate_ports(ports=(), all_undef_as_ports=True)
else:
+ if not isinstance(ports, tuple) and not isinstance(ports, list):
+ msg = "`ports` must be either a list or a tuple, not {!r}"\
+ .format(ports)
+ if isinstance(ports, Value):
+ msg += " (did you mean `ports=(<signal>,)`, rather than `ports=<signal>`?)"
+ raise TypeError(msg)
mapped_ports = []
# Lower late bound signals like ClockSignal() to ports.
port_lowerer = DomainLowerer(fragment.domains)
msg="Only signals may be added as ports, not (const 1'd1)"):
f.prepare(ports=(Const(1),))
+ def test_port_not_iterable(self):
+ f = Fragment()
+ with self.assertRaises(TypeError,
+ msg="`ports` must be either a list or a tuple, not 1"):
+ f.prepare(ports=1)
+ with self.assertRaises(TypeError,
+ msg="`ports` must be either a list or a tuple, not (const 1'd1)" +
+ " (did you mean `ports=(<signal>,)`, rather than `ports=<signal>`?)"):
+ f.prepare(ports=Const(1))
+
class FragmentDomainsTestCase(FHDLTestCase):
def test_iter_signals(self):
cd1 = ClockDomain()