hdl.ir: raise DomainError if a domain is used but not defined.

Before this commit, a KeyError would be raised elsewhere in guts of
hdl.ir, which is not helpful.
This commit is contained in:
whitequark 2019-08-03 15:31:00 +00:00
parent fdb0c5a6bc
commit fc846532c7
2 changed files with 19 additions and 5 deletions

View file

@ -380,6 +380,15 @@ class FragmentDomainsTestCase(FHDLTestCase):
self.assertEqual(f1.domains, {"cd": cd})
self.assertEqual(f2.domains, {"cd": cd})
def test_propagate_missing(self):
s1 = Signal()
f1 = Fragment()
f1.add_driver(s1, "sync")
with self.assertRaises(DomainError,
msg="Domain 'sync' is used but not defined"):
f1._propagate_domains(missing_domain=lambda name: None)
def test_propagate_create_missing(self):
s1 = Signal()
f1 = Fragment()