From: Luke Kenneth Casson Leighton Date: Tue, 21 Apr 2020 18:18:57 +0000 (+0000) Subject: move get_net_connections to Module in utils.py X-Git-Tag: partial-core-ls180-gdsii~126 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4438fdc18cd53c4ad039fe4388250ffb67927f42;p=soclayout.git move get_net_connections to Module in utils.py --- diff --git a/experiments7/doAlu16.py b/experiments7/doAlu16.py index 19bf8f7..66f4043 100755 --- a/experiments7/doAlu16.py +++ b/experiments7/doAlu16.py @@ -157,7 +157,7 @@ class ALU16(Module): self.create_pins() - find = self.get_net_connections(['add_o(1)', 'sub_o(1)', 'o(1)'], + find = self.get_net_connections(['o(15)'], ['clk', 'rst', 'op']) print (find) sys.exit(0) @@ -194,40 +194,6 @@ class ALU16(Module): self.save() return result - def get_net_connections(self, find, already_found): - res = set() - search_more = [] - for inst in self.cell.getInstances(): - if (inst.getPlacementStatus() != - Instance.PlacementStatus.UNPLACED): - continue - print ("instance", inst) - for plug in inst.getConnectedPlugs(): - netname = plug.getNet().getName() - if netname in already_found: - continue - if plug.getNet().getName() in find: - print ("plug", plug, plug.getNet().getName()) - for p in plug.getNet().getPlugs(): - c = p.getInstance() - if (c.getPlacementStatus() != - Instance.PlacementStatus.UNPLACED): - continue - print ("notplaced", c) - for pc in c.getConnectedPlugs(): - print ("plug", pc) - pn = pc.getNet().getName() - if pn not in find and pn not in already_found: - search_more.append(pn) - res.add(c) - print() - if search_more: - print("more", search_more) - new_found = find + already_found - more = self.get_net_connections(search_more, new_found) - res.update(more) - return res - def scriptMain(editor=None, **kwargs): coriolis_setup() diff --git a/experiments7/utils.py b/experiments7/utils.py index cfaf56e..4dcb889 100644 --- a/experiments7/utils.py +++ b/experiments7/utils.py @@ -435,6 +435,10 @@ class Module(object): raise NotImplementedError('You need to implement the `build` method.') + def get_net_connections(self, to_find, already_found): + inst = self.cell.getInstances() + return get_net_connections(inst, to_find, already_found) + class Config: @@ -468,3 +472,39 @@ class Config: if self._priority is not None: Cfg.Configuration.popDefaultPriority() + +def get_net_connections(instances, find, already_found): + res = set() + new = set() + search_more = [] + for inst in instances: + if (inst.getPlacementStatus() != + Instance.PlacementStatus.UNPLACED): + continue + #print ("instance", inst) + for plug in inst.getConnectedPlugs(): + netname = plug.getNet().getName() + if netname in already_found: + continue + if plug.getNet().getName() in find: + #print ("plug", plug, plug.getNet().getName()) + for p in plug.getNet().getPlugs(): + c = p.getInstance() + if (c.getPlacementStatus() != + Instance.PlacementStatus.UNPLACED): + continue + #print ("notplaced", c) + for pc in c.getConnectedPlugs(): + #print ("plug", pc) + pn = pc.getNet().getName() + if pn not in find and pn not in already_found: + search_more.append(pn) + new.add(c) + res.update(new) + if search_more: + print("more", search_more) + new_found = find + already_found + more = get_net_connections(new, search_more, new_found) + res.update(more) + + return res