def test_autplacer():
    lib = Library()
    mask = ChipArray("chip_array", 25e6, 25e6, 3, 4, lib)
    mask.pack_grid(lib.pop("align"))
    mask.pack_grid(lib.pop(".*"))
    mask.write("chip_array.gds")
    klive.show("chip_array.gds")
Exemple #2
0
def show(component: Component, **kwargs) -> None:
    """write component GDS and shows it in klayout

    Args:
        component
    """
    if isinstance(component, pathlib.Path):
        component = str(component)
        return klive.show(component)
    elif isinstance(component, str):
        return klive.show(component)
    elif hasattr(component, "path"):
        return klive.show(component.path)
    elif component is None:
        raise ValueError(
            "Component is None, make sure that your function returns the component"
        )

    elif isinstance(component, Component):
        gdspath = write_gds(component, **kwargs)
        klive.show(gdspath)
    else:
        raise ValueError(
            f"Component is {type(component)}, make sure pass a Component or a path"
        )
    clear_cache()
def show(component: Component,
         gdspath: PosixPath = CONFIG["gdspath"],
         **kwargs) -> None:
    """write component GDS and shows it in klayout

    Args:
        component
        gdspath: where to save the gds
    """
    if isinstance(component, pathlib.Path):
        component = str(component)
        return klive.show(component)
    elif isinstance(component, str):
        return klive.show(component)
    elif hasattr(component, "path"):
        return klive.show(component.path)
    elif component is None:
        raise ValueError(
            "Component is None, make sure that your function returns the component"
        )

    elif isinstance(component, Component):
        write_gds(
            component,
            gdspath,
            **kwargs,
        )
        klive.show(gdspath)
    else:
        raise ValueError(
            f"Component is {type(component)}, make sure pass a Component or a path"
        )
def show(component, gdspath=CONFIG["gdspath"], add_ports_to_all_cells=False, **kwargs):
    """ write component GDS and shows it in klayout

    Args:
        component
        gdspath: where to save the gds
    """
    if isinstance(component, pathlib.Path):
        component = str(component)
    if isinstance(component, str):
        return klive.show(component)
    if component is None:
        raise ValueError(
            "Component is None, make sure that your function returns the component"
        )
    write_gds(
        component, gdspath, add_ports_to_all_cells=add_ports_to_all_cells, **kwargs
    )
    klive.show(gdspath)
Exemple #5
0
"""autoplacer - placing gds components"""


from pp.autoplacer.auto_placer import AutoPlacer
from pp.autoplacer.library import Library
from pp.autoplacer.chip_array import ChipArray
from pp.autoplacer.cell_list import CellList
from pp.autoplacer.yaml_placer import place_from_yaml

__all__ = ["AutoPlacer", "Library", "CellList", "ChipArray", "place_from_yaml"]


if __name__ == "__main__":
    from pp import klive

    lib = Library()
    mask = ChipArray("chip_array", 25e6, 25e6, 3, 4, lib)
    mask.pack_grid(lib.pop("align"))
    mask.pack_grid(lib.pop(".*"))
    mask.write("chip_array.gds")
    klive.show("chip_array.gds")
Exemple #6
0
def show(filename):
    """ Show a GDS file using KLive """
    klive.show(filename)
    D = pg.import_gds(gdspath)
    D = pg.extract(D, layers=[layer])
    for e in D.elements:
        print(e.x, e.y)


def csv2port(csvpath):
    """ loads and reads ports from a CSV file
    returns a dict
    """
    ports = {}
    with open(csvpath, "r") as csvfile:
        rows = csv.reader(csvfile, delimiter=",", quotechar="|")
        for row in rows:
            ports[row[0]] = row[1:]

    return ports


if __name__ == "__main__":
    import os
    from pp import CONFIG

    name = "mmi1x2_WM1"
    gdspath = os.path.join(CONFIG["lib"], name, name + ".gds")
    csvpath = os.path.join(CONFIG["lib"], name, name + ".ports")
    klive.show(gdspath)
    # read_port_markers(gdspath, layer=66)
    p = csv2port(csvpath)
    print(p)