sort-of got layout positions ok
[soclayout.git] / experiments7 / utils.py
index 62ba52822df58da982d3e925efc96f298b7d7a7a..04f9cdea684e6051f48d7919230a4b8af616e91f 100644 (file)
@@ -34,7 +34,8 @@ class Module(object):
     def __init__(self, cell, editor, width=None, height=None, submodules=None,
                  pin_width=2.0, pin_height=2.0, pin_suffix='.0',
                  pin_layer=None, north_pins=None, east_pins=None,
-                 south_pins=None, west_pins=None, pads=None, **kwargs):
+                 south_pins=None, west_pins=None, pads=None,
+                 orientation=None, **kwargs):
         """
         Creates a module.
 
@@ -55,6 +56,7 @@ class Module(object):
         :param south_pins: ditto (for the south side),
         :param west_pins: ditto (for the west side),
         :param pads: dictionary of {net: list of layers} for creating pads,
+        :param orientation: when placed, should be orientated/mirrored etc.
         :param kwargs: extra parameters to be implemented in derived classes.
         """
         self.editor = editor
@@ -82,6 +84,8 @@ class Module(object):
         self.south_pins = south_pins or []
         self.west_pins = west_pins or []
 
+        self.orientation = orientation or Transformation.Orientation.ID
+
         self.pads = pads or {}
 
         self._submodules = []
@@ -92,6 +96,7 @@ class Module(object):
                     else submodule
                 )
 
+
     @property
     def name(self):
         return self.cell.getName()
@@ -143,6 +148,22 @@ class Module(object):
         """
         return DbU.toLambda(dbu)
 
+    @property
+    def ab_x(self):
+        return self.from_dbu(self.ab.getXMin())
+
+    @property
+    def ab_y(self):
+        return self.from_dbu(self.ab.getYMin())
+
+    @property
+    def ab_width(self):
+        return self.from_dbu(self.ab.getWidth())
+
+    @property
+    def ab_height(self):
+        return self.from_dbu(self.ab.getXHeight())
+
     def compute_ab(self):
         """ Compute default abutment box without placement. """
         etesian = Etesian.EtesianEngine.create(self.cell)
@@ -346,7 +367,7 @@ class Module(object):
 
         # place submodule
         instance.setTransformation(Transformation(
-            self.to_dbu(x), self.to_dbu(y), Transformation.Orientation.ID
+            self.to_dbu(x), self.to_dbu(y), submodule.orientation,
         ))
         instance.setPlacementStatus(Instance.PlacementStatus.FIXED)