def getITermBoxes(iterm): iterm_boxes = [] inst = iterm.getInst() mterm = iterm.getMTerm() master_ox, master_oy = inst.getMaster().getOrigin() inst_ox, inst_oy = inst.getOrigin() px, py = master_ox + inst_ox, master_oy + inst_oy orient = inst.getOrient() transform = odb.dbTransform(orient, odb.Point(px, py)) mpins = mterm.getMPins() if len(mpins) > 1: print("Warning:", len(mpins), "mpins for iterm", inst.getName(), mterm.getName()) for i in range(len(mpins)): mpin = mpins[i] boxes = mpin.getGeometry() iterm_boxes += boxes2Rects(boxes, transform) # filter duplications # TODO: OpenDB bug? duplicate mpins for some reason iterm_boxes_set = set() iterm_boxes_uniq = [] for box in iterm_boxes: rect = box['rect'] llx, lly = rect.ll() urx, ury = rect.ur() set_item = (box['layer'].getName(), llx, lly, urx, ury) if not set_item in iterm_boxes_set: iterm_boxes_set.add(set_item) iterm_boxes_uniq.append(box) return iterm_boxes_uniq
def getAllBoxes(iterm): inst = iterm.getInst() px, py = inst.getOrigin() orient = inst.getOrient() transform = odb.dbTransform(orient, odb.Point(px, py)) mterm = iterm.getMTerm() mpins = mterm.getMPins() boxes = [] for i in range(len(mpins)): mpin = mpins[i] geometries = mpin.getGeometry() for box in geometries: # llx, lly = box.xMin(), box.yMin() # urx, ury = box.xMax(), box.yMax() ll = odb.Point(box.xMin(), box.yMin()) ur = odb.Point(box.xMax(), box.yMax()) transform.apply(ll) transform.apply(ur) layer = box.getTechLayer() boxes.append((layer, ll, ur)) return boxes
def transformRect(rect, orient): transform = odb.dbTransform(orient) rect_ll = odb.Point(*rect.ll()) rect_ur = odb.Point(*rect.ur()) transform.apply(rect_ll) transform.apply(rect_ur) rect = odb.Rect(rect_ll, rect_ur) return rect
def getInstObs(inst): master = inst.getMaster() master_ox, master_oy = master.getOrigin() inst_ox, inst_oy = inst.getOrigin() px, py = master_ox + inst_ox, master_oy + inst_oy orient = inst.getOrient() transform = odb.dbTransform(orient, odb.Point(px, py)) obstructions = master.getObstructions() rects = boxes2Rects(obstructions, transform) for rect in rects: rect["type"] = "obstruction" return rects
def getBiggestBox(iterm): inst = iterm.getInst() px, py = inst.getOrigin() orient = inst.getOrient() transform = odb.dbTransform(orient, odb.Point(px, py)) mterm = iterm.getMTerm() mpins = mterm.getMPins() # label biggest mpin biggest_mpin = None biggest_size = -1 for i in range(len(mpins)): mpin = mpins[i] box = mpin.getGeometry()[ 0] # assumes there's only one; to extend and get biggest llx, lly = box.xMin(), box.yMin() urx, ury = box.xMax(), box.yMax() area = (urx - llx) * (ury - lly) if area > biggest_size: biggest_size = area biggest_mpin = mpin main_mpin = biggest_mpin box = main_mpin.getGeometry()[0] ll = odb.Point(box.xMin(), box.yMin()) ur = odb.Point(box.xMax(), box.yMax()) # x = (ll.getX() + ur.getX())//2 # y = (ll.getY() + ur.getY())//2 # if VERBOSE: print(x, y) transform.apply(ll) transform.apply(ur) layer = box.getTechLayer() return [(layer, ll, ur)]