def finalize(self, *args, **kwargs): if not self.finalized: self.finalized = True # finalize existing submodules before finalizing us subfragments = self._collect_submodules() self.do_finalize(*args, **kwargs) # finalize submodules created by do_finalize subfragments += self._collect_submodules() # resolve clock domain name conflicts needs_renaming = set() for (mod_name1, f1), (mod_name2, f2) in combinations(subfragments, 2): f1_names = set(cd.name for cd in f1.clock_domains) f2_names = set(cd.name for cd in f2.clock_domains) common_names = f1_names & f2_names if common_names: if mod_name1 is None or mod_name2 is None: raise ValueError("Multiple submodules with local clock domains cannot be anonymous") if mod_name1 == mod_name2: raise ValueError("Multiple submodules with local clock domains cannot have the same name") needs_renaming |= common_names for mod_name, f in subfragments: for cd in f.clock_domains: if cd.name in needs_renaming: rename_clock_domain(f, cd.name, mod_name + "_" + cd.name) # sum subfragments for mod_name, f in subfragments: self._fragment += f
def finalize(self, *args, **kwargs): if not self.finalized: self.finalized = True # finalize existing submodules before finalizing us subfragments = self._collect_submodules() self.do_finalize(*args, **kwargs) # finalize submodules created by do_finalize subfragments += self._collect_submodules() # resolve clock domain name conflicts needs_renaming = set() for (mod_name1, f1), (mod_name2, f2) in combinations(subfragments, 2): f1_names = set(cd.name for cd in f1.clock_domains) f2_names = set(cd.name for cd in f2.clock_domains) common_names = f1_names & f2_names if common_names: if mod_name1 is None or mod_name2 is None: raise ValueError( "Multiple submodules with local clock domains cannot be anonymous" ) if mod_name1 == mod_name2: raise ValueError( "Multiple submodules with local clock domains cannot have the same name" ) needs_renaming |= common_names for mod_name, f in subfragments: for cd in f.clock_domains: if cd.name in needs_renaming: rename_clock_domain(f, cd.name, mod_name + "_" + cd.name) # sum subfragments for mod_name, f in subfragments: self._fragment += f
def _collect_submodules(self): r = [] for name, submodule, cd_remapping in self._submodules: f = submodule.get_fragment() for old, new in cd_remapping.items(): rename_clock_domain(f, old, new) r.append((name, f)) self._submodules = [] return r
def transform_fragment(self, f): for old, new in self._rc_cd_remapping.items(): rename_clock_domain(f, old, new)
def transform_fragment(self, i, f): for old, new in self.cd_remapping.items(): rename_clock_domain(f, old, new)