def test_6(self): # instantiate and register the library tl = PCellTestLib() lib = pya.Library.library_by_name("PCellTestLib") param = { "w": 3.0, "h": 8.0, "l": pya.LayerInfo(3, 0) } pcell_var = lib.layout().create_cell("Box", param) self.assertEqual(lib.layout().begin_shapes(pcell_var.cell_index(), lib.layout().layer(3, 0)).shape().__str__(), "box (-1500,-4000;1500,4000)")
def test_5(self): # instantiate and register the library tl = PCellTestLib() lib = pya.Library.library_by_name("PCellTestLib") pcell_decl_id = lib.layout().pcell_id("Box") param = { "w": 3.0, "h": 7.0, "l": pya.LayerInfo(2, 0) } pcell_var_id = lib.layout().add_pcell_variant(pcell_decl_id, param) self.assertEqual(lib.layout().begin_shapes(pcell_var_id, lib.layout().layer(2, 0)).shape().__str__(), "box (-1500,-3500;1500,3500)")
def test_7(self): # instantiate and register the library tl = PCellTestLib() ly = pya.Layout(True) ly.dbu = 0.01 param = { "w": 4.0, "h": 8.0, "l": pya.LayerInfo(4, 0) } cell = ly.create_cell("Box", "PCellTestLib", param) self.assertEqual(ly.begin_shapes(cell, ly.layer(4, 0)).shape().__str__(), "box (-200,-400;200,400)")
def test_gds2_options(self): opt = pya.LoadLayoutOptions() lm = pya.LayerMap() lm.map(pya.LayerInfo(1, 0), 2, pya.LayerInfo(42, 17)) opt.set_layer_map(lm, True) opt.gds2_allow_multi_xy_records = True self.assertEqual(opt.gds2_allow_multi_xy_records, True) opt.gds2_allow_multi_xy_records = False self.assertEqual(opt.gds2_allow_multi_xy_records, False) opt.gds2_allow_big_records = True self.assertEqual(opt.gds2_allow_big_records, True) opt.gds2_allow_big_records = False self.assertEqual(opt.gds2_allow_big_records, False) opt.gds2_box_mode = 1 self.assertEqual(opt.gds2_box_mode, 1) opt.gds2_box_mode = 2 self.assertEqual(opt.gds2_box_mode, 2)
def __init__(self): # Important: initialize the super class super(cross, self).__init__() # Parameters self.param("layer", self.TypeLayer, "Layer", default = pya.LayerInfo(1, 0)) self.param("type", self.TypeInt, "Type", default = 0, choices = [["Solid", 0],["Dashed", 1],["Dashed Inverted", 2]]) self.param("width", self.TypeDouble, "Width [um]", default = 10) self.param("length", self.TypeDouble, "Length [um]", default = 100) self.param("invert", self.TypeBoolean, "Hole", default = False) self.param("border", self.TypeDouble, " Border Width [um]", default = 10)
def get_technology(verbose=False, query_activecellview_technology=False): if verbose: print("get_technology()") from .._globals import KLAYOUT_VERSION technology = {} # defaults: technology['DevRec'] = pya.LayerInfo(68, 0) technology['Waveguide'] = pya.LayerInfo(1, 0) technology['Si'] = pya.LayerInfo(1, 0) technology['PinRec'] = pya.LayerInfo(69, 0) technology['Lumerical'] = pya.LayerInfo(733, 0) technology['Text'] = pya.LayerInfo(10, 0) technology_name = 'EBeam' lv = pya.Application.instance().main_window().current_view() if lv == None: # no layout open; return a default technology print("No view selected") technology['dbu'] = 0.001 technology['technology_name'] = technology_name # Get library names technology['libraries'] = get_library_names(technology_name) return technology # "lv.active_cellview().technology" crashes in KLayout 0.24.10 when loading a GDS file (technology not defined yet?) but works otherwise if KLAYOUT_VERSION > 24 or query_activecellview_technology or lv.title != '<empty>': technology_name = lv.active_cellview().technology return get_technology_by_name(technology_name)
def test_5_Layout(self): ly = pya.Layout() ci1 = ly.add_cell("c1") ci2 = ly.add_cell("c2") linfo = pya.LayerInfo() linfo.layer = 16 linfo.datatype = 1 lindex = ly.insert_layer(linfo) linfo = pya.LayerInfo() linfo.layer = 16 linfo.datatype = 2 ldummy = ly.insert_layer(linfo) c1 = ly.cell(ci1) c2 = ly.cell(ci2) c1.shapes(lindex).insert(pya.Box(10, -10, 50, 40)) self.assertEqual(c1.bbox().to_s(), "(10,-10;50,40)") self.assertEqual(c1.bbox_per_layer(lindex).to_s(), "(10,-10;50,40)") self.assertEqual(c1.bbox_per_layer(ldummy).to_s(), "()") c1.swap(lindex, ldummy) self.assertEqual(c1.bbox_per_layer(lindex).to_s(), "()") self.assertEqual(c1.bbox_per_layer(ldummy).to_s(), "(10,-10;50,40)") c1.clear(lindex) c1.clear(ldummy) self.assertEqual(c1.bbox_per_layer(lindex).to_s(), "()") self.assertEqual(c1.bbox_per_layer(ldummy).to_s(), "()") c1.shapes(lindex).insert(pya.Box(10, -10, 50, 40)) self.assertEqual(c1.bbox_per_layer(lindex).to_s(), "(10,-10;50,40)") self.assertEqual(c1.bbox_per_layer(ldummy).to_s(), "()") c1.clear_shapes() self.assertEqual(c1.bbox_per_layer(lindex).to_s(), "()") self.assertEqual(c1.bbox_per_layer(ldummy).to_s(), "()")
def __init__(self, cell_name): # getting main references of the application app = pya.Application.instance() mw = app.main_window() self.lv = mw.current_view() self.cv = None self.cell = None self.region_ph = Region() self.region_el = Region() #this insures that lv and cv are valid objects if (self.lv == None): self.cv = mw.create_layout(1) self.lv = mw.current_view() else: self.cv = self.lv.active_cellview() # find or create the desired by programmer cell and layer layout = self.cv.layout() layout.dbu = 0.001 if (layout.has_cell(cell_name)): self.cell = layout.cell(cell_name) else: self.cell = layout.create_cell(cell_name) info = pya.LayerInfo(1, 0) info2 = pya.LayerInfo(2, 0) self.layer_ph = layout.layer(info) # photoresist layer self.layer_el = layout.layer(info2) # e-beam lithography layer # clear this cell and layer self.cell.clear() # setting layout view self.lv.select_cell(self.cell.cell_index(), 0) self.lv.add_missing_layers() # design parameters that were passed to the last # self.draw(...) call are stored here as ordered dict self.design_pars = OrderedDict()
class LAYERS: photo = pya.LayerInfo(0, 0, "photo") ebeam = pya.LayerInfo(2, 0, "ebeam") photo_neg = pya.LayerInfo(9, 0, "photo_neg") crystal = pya.LayerInfo(8, 0, "crystal") bridge_patches = pya.LayerInfo(20, 0, "bridge_patches") bridges = pya.LayerInfo(30, 0, "bridges")
def __init__(self): # Important: initialize the super class super(PhC_L3c, self).__init__() self.param("a", self.TypeDouble, "lattice constant (microns)", default=0.720) self.param("n", self.TypeInt, "Number of holes in x and y direction", default=30) self.param("r", self.TypeDouble, "hole radius (microns)", default=0.181) self.param("wg_dis", self.TypeInt, "Waveguide distance (number of holes)", default=3) self.param("n_bus", self.TypeInt, "Bus number, 1 or 2 ", default=2) self.param("n_vertices", self.TypeInt, "Vertices of a hole", default=32) self.param("S1x", self.TypeDouble, "S1x shift", default=0.337) self.param("S2x", self.TypeDouble, "S2x shift", default=0.27) self.param("S3x", self.TypeDouble, "S3x shift", default=0.088) self.param("S4x", self.TypeDouble, "S4x shift", default=0.323) self.param("S5x", self.TypeDouble, "S5x shift", default=0.173) TECHNOLOGY = get_technology_by_name('EBeam') self.param("layer", self.TypeLayer, "Layer", default=TECHNOLOGY['Waveguide']) self.param("pinrec", self.TypeLayer, "PinRec Layer", default=TECHNOLOGY['PinRec']) self.param("devrec", self.TypeLayer, "DevRec Layer", default=TECHNOLOGY['DevRec']) self.param("textl", self.TypeLayer, "Text Layer", default=TECHNOLOGY['Text']) self.param("etch", self.TypeLayer, "oxide etch layer", default=pya.LayerInfo(12, 0))
def __init__(self): # Important: initialize the super class super(PhC_W1wg, self).__init__() self.param("a", self.TypeDouble, "lattice constant (microns)", default=0.744) self.param("n", self.TypeInt, "Number of holes in x and y direction", default=30) self.param("r", self.TypeDouble, "hole radius (microns)", default=0.179) self.param("wg_dis", self.TypeInt, "Waveguide distance (number of holes)", default=2) self.param("n_vertices", self.TypeInt, "Vertices of a hole", default=32) self.param("etch_condition", self.TypeInt, "Etch = 1, No Etch = 2", default=1) TECHNOLOGY = get_technology_by_name('EBeam') self.param("layer", self.TypeLayer, "Layer", default=TECHNOLOGY['Waveguide']) self.param("pinrec", self.TypeLayer, "PinRec Layer", default=TECHNOLOGY['PinRec']) self.param("devrec", self.TypeLayer, "DevRec Layer", default=TECHNOLOGY['DevRec']) self.param("textl", self.TypeLayer, "Text Layer", default=TECHNOLOGY['Text']) self.param("etch", self.TypeLayer, "oxide etch layer", default=pya.LayerInfo(12, 0))
def __init__(self): # Important: initialize the super class super(Circle, self).__init__() # declare the parameters self.param("l", self.TypeLayer, "Layer", default=pya.LayerInfo(1, 0)) self.param("s", self.TypeShape, "", default=pya.DPoint(0, 0)) self.param("r", self.TypeDouble, "Radius", default=0.1) self.param("n", self.TypeInt, "Number of points", default=64) # this hidden parameter is used to determine whether the radius has changed # or the "s" handle has been moved self.param("ru", self.TypeDouble, "Radius", default=0.0, hidden=True) self.param("rd", self.TypeDouble, "Double radius", readonly=True)
def test_6_Layout_props2(self): ly = pya.Layout(True) pv = [[17, "a"], ["b", [1, 5, 7]]] pid = ly.properties_id(pv) # does not work? @@@ # pv = { 17: "a", "b": [ 1, 5, 7 ] } # pid2 = ly.properties_id( pv ) # self.assertEqual( pid, pid2 ) ci1 = ly.add_cell("c1") ci2 = ly.add_cell("c2") linfo = pya.LayerInfo() linfo.layer = 16 linfo.datatype = 1 lindex = ly.insert_layer(linfo) c1 = ly.cell(ci1) c2 = ly.cell(ci2) tr = pya.Trans() inst = c2.insert(pya.CellInstArray(c1.cell_index(), tr)) self.assertEqual(inst.parent_cell.name, c2.name) self.assertEqual(inst.cell.name, c1.name) self.assertEqual(repr(inst.layout()), repr(ly)) s1 = c1.shapes(lindex).insert(pya.Box(10, -10, 50, 40), pid) s2 = c1.shapes(lindex).insert(pya.Box(10, -10, 50, 40)) self.assertEqual(repr(s1.property(17)), "\'a\'") s1.set_property(5, 23) s1.delete_property(17) self.assertEqual(repr(s1.property(17)), "None") self.assertEqual(str(s1.property(5)), "23") self.assertEqual(repr(s2.property(17)), "None") self.assertEqual(repr(inst.property("a")), "None") inst.set_property("a", 33) self.assertEqual(str(inst.property("a")), "33") inst.delete_property("a") self.assertEqual(repr(inst.property("a")), "None") # cell properties self.assertEqual(repr(c1.property(17)), "None") c1.prop_id = pid self.assertEqual(c1.prop_id, pid) self.assertEqual(repr(c1.property(17)), "\'a\'") c1.set_property(5, 23) c1.delete_property(17) self.assertEqual(repr(c1.property(17)), "None") self.assertEqual(str(c1.property(5)), "23")
def place(self, dest, layer_i=-1, region_name=None): if (layer_i != -1): r_cell = Region(dest.begin_shapes_rec(layer_i)) for primitive in self.primitives.values(): primitive.place(r_cell, region_name=region_name) temp_i = dest.layout().layer(pya.LayerInfo(PROGRAM.LAYER1_NUM, 0)) dest.shapes(temp_i).insert(r_cell) dest.layout().clear_layer(layer_i) dest.layout().move_layer(temp_i, layer_i) dest.layout().delete_layer(temp_i) else: for primitive in self.primitives.values(): primitive.place(dest, region_name=region_name)
def get_layer(self, name: str, purpose: str = ''): """Creates LayerInfo object Creates a pya.LayerInfo object to find layer indexes in the current layout. :param name: name of the layer :param purpose: if not empty then layer and purpose are separate :return: pya.LayerInfo about the layer """ if purpose: layer = self.layermap[name][purpose] else: layer = self.layermap[name.split('.')[0]][name.split('.')[1]] return pya.LayerInfo(int(layer[0]), int(layer[1]), name)
def simple_create(grids=4): t0 = time.time() layout = pya.Layout() ipc.trace_pyainsert(layout, debug_file) layout.dbu = 0.001 TOP = layout.create_cell('TOP') l1 = layout.insert_layer(pya.LayerInfo(1, 0)) for i in range(grids): for j in range(grids): box = pya.DBox(0, 0, 10, 10) box.move(15 * i, 15 * j) TOP.shapes(l1).insert(box) print(time.time() - t0)
def __init__(self): # Important: initialize the super class super(Ebend, self).__init__() # declare the parameters self.param("l", self.TypeLayer, "Layer", default=pya.LayerInfo(1, 0)) self.param("s", self.TypeShape, "", default=pya.DPoint(0, 0)) self.param("rmin", self.TypeDouble, "Min Radius", default=1) self.param("w", self.TypeDouble, "Width", default=1) self.param("theta", self.TypeDouble, "Total bending angle", default=3.14) self.param("n", self.TypeInt, "Number of points", default=50)
def __init__(self): self.layout = pya.Layout() self.layout.dbu = 0.001 self.top = self.layout.create_cell("TOP") self.layer_index = self.layout.insert_layer(pya.LayerInfo(15,99)) self.lib = pya.Library.library_by_name("Basic") if self.lib == None: raise Exception("Unknown lib 'Basic'") self.pcell_decl = self.lib.layout().pcell_declaration("TEXT"); if self.pcell_decl == None: raise Exception("Unknown PCell 'TEXT'")
def place( self, dest, layer_i=-1 ): r_cell = None if( layer_i != -1 ): r_cell = Region( dest.begin_shapes_rec( layer_i ) ) # how to interpret destination if( layer_i == -1 ): dest += self.metal_region dest -= self.empty_region else: temp_i = dest.layout().layer( pya.LayerInfo(PROGRAM.LAYER1_NUM,0) ) dest.shapes( temp_i ).insert( r_cell + self.metal_region - self.empty_region ) dest.layout().clear_layer( layer_i ) dest.layout().move_layer( temp_i, layer_i ) dest.layout().delete_layer( temp_i )
def __init__(self): # set the description self.description = "PCell test lib" # create the PCell declarations self.layout().register_pcell("Box", BoxPCell()) sb_index = self.layout().add_cell("StaticBox") l10 = self.layout().insert_layer(pya.LayerInfo(10, 0)) sb_cell = self.layout().cell(sb_index) sb_cell.shapes(l10).insert(pya.Box(0, 0, 100, 200)) # register us with the name "MyLib" self.register("PCellTestLib")
def __init__(self): # Important: initialize the super class super(Square, self).__init__() # declare the parameters #LayerParameters self.param("l", self.TypeLayer, "First Marker layer", default = pya.LayerInfo(1, 0, "MarkerFM")) self.param("side_a", self.TypeDouble, "Size of Square", default = 10.0) #debuging self.param("debug", self.TypeBoolean, "Debug output", choices = [["No", False],["Yes", True]], default= True)
def __init__(self): # Important: initialize the super class super(Arrow, self).__init__() # declare the parameters self.param("l", self.TypeLayer, "Layer", default = pya.LayerInfo(1, 0)) self.param("hb", self.TypeShape, "", default = pya.DPoint(0.5, -6)) self.param("hh", self.TypeShape, "", default = pya.DPoint(0, 4)) self.param("ha", self.TypeShape, "", default = pya.DPoint(2.2314069574087765, 0)) self.param("b", self.TypeDouble, "Body length", default = 6) self.param("h", self.TypeDouble, "Head length", default = 4) self.param("a", self.TypeDouble, "Head angle", default = 45) self.param("w", self.TypeDouble, "Body width", default = 1) self.param("b_", self.TypeDouble, "Body length", default = 6, hidden = True) self.param("h_", self.TypeDouble, "Head length", default = 4, hidden = True) self.param("a_", self.TypeDouble, "Head angle", default = 45, hidden = True) self.param("w_", self.TypeDouble, "Body width", default = 1, hidden = True)
def test_8(self): # instantiate and register the library tl = PCellTestLib() lib = pya.Library.library_by_name("PCellTestLib") ly = pya.Layout(True) ly.dbu = 0.01 param = { "w": 2.0, "h": 6.0, "l": pya.LayerInfo(5, 0) } pcell_var = lib.layout().create_cell("Box", param) pcell_var.name = "BOXVAR" cell = ly.create_cell("BOXVAR", "PCellTestLib") self.assertEqual(cell.begin_shapes_rec(ly.layer(5, 0)).shape().__str__(), "box (-100,-300;100,300)")
def __init__(self): # Important: initialize the super class super(CPW, self).__init__() # declare the parameters self.param("l", self.TypeLayer, "Layer", default = pya.LayerInfo(1, 0)) self.param("s", self.TypeShape, "", default = pya.DPath(0, 0)) self.param("w", self.TypeDouble, "Center Conductor width", default = 10) self.param("g", self.TypeInt, "Gap Width", default = 6) self.param("name", self.TypeString, "Name", default= "cpw") # this hidden parameter is used to determine whether the radius has changed # or the "s" handle has been moved self.param("length", self.TypeDouble, "Length", default=0.0, readonly=True) self.param("frequency", self.TypeDouble, "Frequency", default = 0.0, readonly= True) self.param("impedance", self.TypeDouble, "Impedance", default = 50., readonly = True)
def __init__(self): # Important: initialize the super class super(phc_test, self).__init__() self.param("a", self.TypeDouble, "lattice constant (microns)", default = 0.744) self.param("n", self.TypeInt, "Number of holes in x and y direction", default = 5) self.param("r", self.TypeDouble, "hole radius (microns)", default = 0.179) self.param("n_sweep", self.TypeInt, "Different sizes of holes", default = 13) self.param("n_vertices", self.TypeInt, "Vertices of a hole", default = 32) TECHNOLOGY = get_technology_by_name('EBeam') self.param("layer", self.TypeLayer, "Layer", default = TECHNOLOGY['Waveguide']) self.param("pinrec", self.TypeLayer, "PinRec Layer", default = TECHNOLOGY['PinRec']) self.param("devrec", self.TypeLayer, "DevRec Layer", default = TECHNOLOGY['DevRec']) self.param("textl", self.TypeLayer, "Text Layer", default = TECHNOLOGY['Text']) self.param("etch", self.TypeLayer, "oxide etch layer", default = pya.LayerInfo(12, 0))
def get_parameters(self): # prepare a set of parameter declarations param = [] param.append( pya.PCellParameterDeclaration( "l", pya.PCellParameterDeclaration.TypeLayer, "Layer", pya.LayerInfo(0, 0))) param.append( pya.PCellParameterDeclaration( "w", pya.PCellParameterDeclaration.TypeDouble, "Width", 1.0)) param.append( pya.PCellParameterDeclaration( "h", pya.PCellParameterDeclaration.TypeDouble, "Height", 1.0)) return param
def __init__(self): # Important: initialize the super class super(checkerboard, self).__init__() # Parameters self.param("layer", self.TypeLayer, "Layer", default=pya.LayerInfo(1, 0)) self.param("width", self.TypeDouble, "Width [um]", default=10) self.param("num", self.TypeInt, "Number", default=5) self.param("invert", self.TypeBoolean, "Hole", default=False) self.param("border", self.TypeDouble, " Border Width [um]", default=10)
def __init__(self): # Important: initialize the super class super(circle, self).__init__() # Parameters self.param("layer", self.TypeLayer, "Layer", default=pya.LayerInfo(1, 0)) self.param("diameter", self.TypeDouble, "Diameter [um]", default=1) self.param("vertices", self.TypeInt, "Vertices", default=8) self.param("invert", self.TypeBoolean, "Hole", default=False) self.param("border", self.TypeDouble, " Border Width [um]", default=10)
def test_3(self): # instantiate and register the library tl = PCellTestLib() ly = pya.Layout(True) ly.dbu = 0.01 c1 = ly.create_cell("c1") lib = pya.Library.library_by_name("PCellTestLib") pcell_decl_id = lib.layout().pcell_id("Box") param = { "w": 4.0, "h": 8.0, "l": pya.LayerInfo(1, 0) } pcell_var_id = ly.add_pcell_variant(lib, pcell_decl_id, param) pcell_var = ly.cell(pcell_var_id) pcell_inst = c1.insert(pya.CellInstArray(pcell_var_id, pya.Trans())) self.assertEqual(ly.begin_shapes(c1.cell_index(), ly.layer(1, 0)).shape().__str__(), "box (-200,-400;200,400)")
def place(self, dest, layer_i=None, region_name=None): if (region_name == None): metal_region = self.metal_region empty_region = self.empty_region else: metal_region = self.metal_regions[region_name] empty_region = self.empty_regions[region_name] if type(dest) is Cell and layer_i is not None: r_cell = Region(dest.begin_shapes_rec(layer_i)) temp_i = dest.layout().layer(pya.LayerInfo(PROGRAM.LAYER1_NUM, 0)) dest.shapes(temp_i).insert(r_cell + metal_region - empty_region) dest.layout().clear_layer(layer_i) dest.layout().move_layer(temp_i, layer_i) dest.layout().delete_layer(temp_i) elif type(dest) is Region: dest += metal_region dest -= empty_region