def _subtract_keepout_from_hole_grid( self, gather_holes_cell: gdspy.library.Cell) -> gdspy.library.Cell: """Given a cell with all the holes, subtract the keepout region. Then return a new cell with the result. Args: gather_holes_cell (gdspy.library.Cell): Holds a grid of all the holes for cheesing. Returns: gdspy.library.Cell: Newly created cell that holds the difference of holes minus the keep=out region. """ # subtact the keepout, note, Based on user options, # the keepout (no_cheese) cell may not be in self.lib. temp_keepout_chip_layer_cell = f'temp_keepout_{self.chip_name}_{self.layer}' temp_keepout_cell = self.lib.new_cell(temp_keepout_chip_layer_cell, overwrite_duplicate=True) temp_keepout_cell.add(self.nocheese_gds) diff_holes = gdspy.boolean(gather_holes_cell.get_polygonsets(), temp_keepout_cell.get_polygonsets(), 'not', max_points=self.max_points, precision=self.precision, layer=self.layer, datatype=self.datatype_cheese + 1) diff_holes_cell_name = f'TOP_{self.chip_name}_{self.layer}_Cheese_diff' diff_holes_cell = self.lib.new_cell(diff_holes_cell_name, overwrite_duplicate=True) diff_holes_cell.add(diff_holes) self.lib.remove(temp_keepout_chip_layer_cell) return diff_holes_cell
def _move_to_under_top_chip_layer_name(self, a_cell: gdspy.library.Cell): """Move the cell to under TOP_<chip name>_<layer number>. Args: a_cell (gdspy.library.Cell): A GDSPY cell. """ chip_only_top_chip_layer_name = f'TOP_{self.chip_name}_{self.layer}' if chip_only_top_chip_layer_name in self.lib.cells: if a_cell.get_bounding_box() is not None: self.lib.cells[chip_only_top_chip_layer_name].add( gdspy.CellReference(a_cell)) else: self.lib.remove(a_cell)
def _subtract_from_ground_and_move_under_top_chip_layer( self, diff_holes_cell: gdspy.library.Cell): """Get the existing chip_only_top_name cell, then add the holes to it. Also, add ground_cheesed_cell under chip_only_top_name Args: diff_holes_cell (gdspy.library.Cell): New cell with cheesed ground """ #chip_only_top_name = f'TOP_{self.chip_name}' chip_only_top_layer_name = f'TOP_{self.chip_name}_{self.layer}' #if chip_only_top_name in self.lib.cells: if chip_only_top_layer_name in self.lib.cells: if diff_holes_cell.get_bounding_box() is not None: self.lib.cells[chip_only_top_layer_name].add( gdspy.CellReference(diff_holes_cell)) ground_cheese_cell = self._subtract_holes_from_ground( diff_holes_cell) #Move to under Top_main_layer (Top_chipname_#) self._move_to_under_top_chip_layer_name(ground_cheese_cell) else: self.lib.remove(diff_holes_cell)