This would violate invariants later in the elaboration process.
Fixes #282.
if not isinstance(domain, ClockDomain):
raise TypeError("Only clock domains may be added to `m.domains`, not {!r}"
.format(domain))
+ if domain.name != name:
+ raise NameError("Clock domain name {!r} must match name in `m.domains.{} += ...` "
+ "syntax"
+ .format(domain.name, name))
self._builder._add_domain(domain)
msg="Only clock domains may be added to `m.domains`, not 1"):
m.domains += 1
+ def test_domain_add_wrong_name(self):
+ m = Module()
+ with self.assertRaises(NameError,
+ msg="Clock domain name 'bar' must match name in `m.domains.foo += ...` syntax"):
+ m.domains.foo = ClockDomain("bar")
+
def test_lower(self):
m1 = Module()
m1.d.comb += self.c1.eq(self.s1)