DbU, DataBase, UpdateSession, Box, Transformation, Instance, Pad, Pin,
NetExternalComponents,
)
-from plugins import RSavePlugin
-class Module:
+class SessionManager(object):
+ """
+ Context manager for a GO update session. See Hurricane reference manual
+ for an info on Hurricane::UpdateSession class.
+ """
+
+ def __enter__(self):
+ UpdateSession.open()
+
+ def __exit__(self, *args):
+ UpdateSession.close()
+
+
+class Module(object):
_layer_cache = {}
_instances = None
def name(self):
return self.cell.getName()
+ @name.setter
+ def name(self, name):
+ self.cell.setName(name)
+
def __str__(self):
return self.name
"""
return DbU.toLambda(dbu)
- def place_and_route(self):
- """ Places and routes. """
- UpdateSession.open()
-
+ def place(self):
+ """ Places the current cell. """
etesian = Etesian.EtesianEngine.create(self.cell)
etesian.place()
+ def route(self):
+ """ Routes the current cell. """
katana = Katana.KatanaEngine.create(self.cell)
katana.digitalInit()
katana.runGlobalRouter(Katana.Flags.NoFlags)
katana.finalizeLayout()
result = katana.isDetailedRoutingSuccess()
katana.destroy()
-
- UpdateSession.close()
return result
+ def place_and_route(self):
+ """ Places and routes. """
+ self.place()
+ return self.route()
+
def create_pin_series(self, net, direction, name=None,
status=Pin.PlacementStatus.FIXED, layer=None,
x=None, y=None, width=2.0, height=2.0,
def init_abutment_box(self):
""" Create the abutment box with object's initial values. """
- UpdateSession.open()
self.ab = Box(0, 0, self.to_dbu(self.width), self.to_dbu(self.height))
- UpdateSession.close()
def create_pins(self):
""" Creates all pins set on Module object creation. """
return 0
return last_y
- UpdateSession.open()
-
for pins, direction in (
(self.north_pins, Pin.Direction.NORTH),
(self.east_pins, Pin.Direction.EAST),
net, direction, name=name, layer=layer, x=x, y=y,
**pin_config)
- UpdateSession.close()
-
def create_pads_for_net(self, net, layers):
"""
Creates a series of pads for a given net.
def create_pads(self):
""" Create all pads for a given Module object. """
- UpdateSession.open()
-
for net, layers in self.pads.items():
self.create_pads_for_net(net, layers)
- UpdateSession.close()
-
def do_submodules(self):
- """ Execute submodules and gather their status. """
+ """
+ Execute submodules and gather their status.
+
+ :return: True if all submodules executed successfully, False otherwise.
+ """
for submodule, x, y in self.submodules:
- # execute submodule
if not submodule.do():
return False
def do(self):
""" Main routine. """
- if not self.do_submodules():
- return False
-
- self.init_abutment_box()
-
- self.create_pins()
-
- if self.editor:
- self.editor.setCell(self.cell)
-
- result = self.place_and_route()
-
- self.create_pads()
-
- RSavePlugin.ScriptMain(editor=self.editor, cell=self.cell)
- return result
+ raise NotImplementedError('You need to implement the `do` method.')