If ``True``, the domain uses an asynchronous reset, and registers within this domain
are initialized to their reset state when reset level changes. Otherwise, registers
are initialized to reset state at the next clock cycle when reset is asserted.
+ local : bool
+ If ``True``, the domain will propagate only downwards in the design hierarchy. Otherwise,
+ the domain will propagate everywhere.
Attributes
----------
else:
return "{}_{}".format(domain_name, signal_name)
- def __init__(self, name=None, reset_less=False, async_reset=False):
+ def __init__(self, name=None, reset_less=False, async_reset=False, local=False):
if name is None:
try:
name = tracer.get_var_name()
self.async_reset = async_reset
+ self.local = local
+
def rename(self, new_name):
self.name = new_name
self.clk.name = self._name_for(new_name, "clk")
subfrag._propagate_domains_up(hierarchy + (hier_name,))
# Second, classify subfragments by domains they define.
- for domain in subfrag.iter_domains():
- domain_subfrags[domain].add((subfrag, name, i))
+ for domain_name, domain in subfrag.domains.items():
+ if domain.local:
+ continue
+ domain_subfrags[domain_name].add((subfrag, name, i))
# For each domain defined by more than one subfragment, rename the domain in each
# of the subfragments such that they no longer conflict.
- for domain, subfrags in domain_subfrags.items():
+ for domain_name, subfrags in domain_subfrags.items():
if len(subfrags) == 1:
continue
raise DomainError("Domain '{}' is defined by subfragments {} of fragment '{}'; "
"it is necessary to either rename subfragment domains "
"explicitly, or give names to subfragments"
- .format(domain, ", ".join(names), ".".join(hierarchy)))
+ .format(domain_name, ", ".join(names), ".".join(hierarchy)))
if len(names) != len(set(names)):
names = sorted("#{}".format(i) for f, n, i in subfrags)
"some of which have identical names; it is necessary to either "
"rename subfragment domains explicitly, or give distinct names "
"to subfragments"
- .format(domain, ", ".join(names), ".".join(hierarchy)))
+ .format(domain_name, ", ".join(names), ".".join(hierarchy)))
for subfrag, name, i in subfrags:
- self.subfragments[i] = \
- (DomainRenamer({domain: "{}_{}".format(name, domain)})(subfrag), name)
+ domain_name_map = {domain_name: "{}_{}".format(name, domain_name)}
+ self.subfragments[i] = (DomainRenamer(domain_name_map)(subfrag), name)
# Finally, collect the (now unique) subfragment domains, and merge them into our domains.
for subfrag, name in self.subfragments:
- for domain in subfrag.iter_domains():
- self.add_domains(subfrag.domains[domain])
+ for domain_name, domain in subfrag.domains.items():
+ if domain.local:
+ continue
+ self.add_domains(domain)
def _propagate_domains_down(self):
# For each domain defined in this fragment, ensure it also exists in all subfragments.
self.assertEqual(sync.name, "sync")
self.assertEqual(sync.clk.name, "clk")
self.assertEqual(sync.rst.name, "rst")
+ self.assertEqual(sync.local, False)
pix = ClockDomain()
self.assertEqual(pix.name, "pix")
self.assertEqual(pix.clk.name, "pix_clk")
with self.assertRaises(ValueError,
msg="Clock domain name must be specified explicitly"):
ClockDomain()
+ cd_reset = ClockDomain(local=True)
+ self.assertEqual(cd_reset.local, True)
def test_with_reset(self):
pix = ClockDomain()