find connections through plugs
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 21 Apr 2020 17:54:56 +0000 (17:54 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 21 Apr 2020 17:54:56 +0000 (17:54 +0000)
experiments7/doAlu16.py

index 591e6b7b039c6fbe7462f5572087a46db5c9a55c..71d465b59d4bc4a0e38fc22fe8a89b1e93d687e3 100755 (executable)
@@ -157,39 +157,14 @@ class ALU16(Module):
 
             self.create_pins()
 
-        print (dir(self.cell))
-        for net in self.cell.getNets():
-            print (net.getName())
-        print (self.cell.getNet("a(0)"))
-        print (dir(self.cell.getNet("a(0)")))
-        net = self.cell.getNet("a(2)")
-        print (list(net.getPlugs()))
-        for plug in net.getPlugs():
-            print (plug, dir(plug))
-            components = list(plug.getConnexComponents())
-            pc = plug.getCell()
-            print ("plug cell", pc)
-            mnet = plug.getMasterNet()
-            print ("mstnet", mnet)
-
-        for inst in self.cell.getInstances():
-            for net in self.cell.getNets():
-                plug = inst.getPlug(net)
-                if net.getName() == "a(2)":
-                    print ("net", net, "plug", plug)
-                    #print (list(net.getPlugs()))
-                    continue
-                    icell = inst.getMasterCell()
-                    print (dir(inst))
-                    print (dir(icell))
-                    #if len(list(icell.getInstances())) > 0:
-                        #continue # already placed, do not include it
-                    #print (list(icell.getOccurrences()))
-                    for net in icell.getNets():
-                        print ("inst", icell, "has nets", net.getName())
-                        plug = inst.getPlug(net)
-                        print ("plug", plug, dir(plug))
+        find = self.get_net_connections(['add_o(0)', 'sub_o(0)', 'o(0)'],
+                                        ['clk', 'rst'])
+        print (find)
         sys.exit(0)
+        find = self.get_net_connections(['o_next(0)'],
+                                        ['clk', 'vss', 'vdd', 'rst'])
+        print (find)
+
         if self.editor:
             self.editor.setCell(self.cell)
 
@@ -219,6 +194,40 @@ 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()