hdl.dsl: reject name mismatch in m.domains.<name> +=
.
This would violate invariants later in the elaboration process. Fixes #282.
This commit is contained in:
parent
86b57fe6b6
commit
3df429703c
|
@ -118,6 +118,10 @@ class _ModuleBuilderDomainSet:
|
|||
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)
|
||||
|
||||
|
||||
|
|
|
@ -716,6 +716,12 @@ class DSLTestCase(FHDLTestCase):
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue