Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Mar 2, 2023
1 parent 18b70dd commit c957eb0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -56,15 +56,15 @@ It provides you a common syntax for design (KLayout, gdstk, Ansys Lumerical, tid

![tool interfaces](https://i.imgur.com/9fNLRvJ.png)

Multiple Silicon Photonics foundries have gdsfactory PDKs available. Talk to your foundry to access their gdsfactory PDK.
Multiple Photonic foundries have gdsfactory PDKs available. Talk to your foundry to access their gdsfactory PDK.

You can also access:

- instructions on [how to build your own PDK](https://gdsfactory.github.io/gdsfactory/notebooks/08_pdk.html)
- instructions on [how to import a PDK from a library of fixed GDS cells](https://gdsfactory.github.io/gdsfactory/notebooks/09_pdk_import.html)
- open source PDKs available on GitHub
- [UBCPDK](https://gdsfactory.github.io/ubc/README.html)
- [skywater130](https://gdsfactory.github.io/skywater130/README.html)
- instructions on [how to build your own PDK](https://gdsfactory.github.io/gdsfactory/notebooks/08_pdk.html)
- instructions on [how to import a PDK from a library of fixed GDS cells](https://gdsfactory.github.io/gdsfactory/notebooks/09_pdk_import.html)

## Installation

Expand Down
57 changes: 36 additions & 21 deletions docs/notebooks/09_pdk_import.py
@@ -1,17 +1,19 @@
# ---
# jupyter:
# jupytext:
# custom_cell_magics: kql
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.14.4
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.2
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Import PDK
#
# ## Import PDK in GDS format
Expand All @@ -35,7 +37,7 @@
# - `Component.write_gds()` saves GDS
# - `Component.write_gds_metadata()` save GDS + YAML metadata

# +
# %% vscode={"languageId": "python"}
from typing import Dict, Tuple

# Lets generate the script that we need to have to each GDS cell into gdsfactory
Expand All @@ -51,46 +53,57 @@

c = gf.components.mzi()
c
# -

# %% [markdown]
# You can write **GDS** files only

# %% vscode={"languageId": "python"}
gdspath = c.write_gds("extra/mzi.gds")

# %% [markdown]
# Or **GDS** with **YAML** metadata information (ports, settings, cells ...)

# %% vscode={"languageId": "python"}
gdspath = c.write_gds_with_metadata("extra/mzi.gds")

# %% [markdown]
# This created a `mzi.yml` file that contains:
# - ports
# - cells (flat list of cells)
# - info (function name, module, changed settings, full settings, default settings)

# %% vscode={"languageId": "python"}
c.metadata.keys()

# %% [markdown]
# You can read GDS files into gdsfactory thanks to the `import_gds` function
#
# `import_gds` reads the same GDS file from disk without losing any information

# +
# %% vscode={"languageId": "python"}
gf.clear_cache()

c = gf.import_gds(gdspath, read_metadata=True)
c
# -

# %% vscode={"languageId": "python"}
c2 = gf.import_gds(gdspath, name="mzi_sample", read_metadata=True)
c2

# %% vscode={"languageId": "python"}
c2.name

# %% vscode={"languageId": "python"}
c3 = gf.routing.add_fiber_single(c2)
c3

# %% vscode={"languageId": "python"}
gdspath = c3.write_gds_with_metadata("extra/pdk.gds")

# %% vscode={"languageId": "python"}
gf.labels.write_labels.write_labels_klayout(gdspath, layer_label=gf.LAYER.LABEL)

# %% [markdown]
# ### add ports from pins
#
# Sometimes the GDS does not have YAML metadata, therefore you need to figure out the port locations, widths and orientations.
Expand All @@ -106,24 +119,31 @@
#
# Lets add pins, save a GDS and then import it back.

# %% vscode={"languageId": "python"}
c = gf.components.straight(
decorator=gf.add_pins.add_pins
) # add pins inside the component
c

# %% vscode={"languageId": "python"}
gdspath = c.write_gds("extra/wg.gds")

# %% vscode={"languageId": "python"}
gf.clear_cache()
c2 = gf.import_gds(gdspath)
c2

# %% vscode={"languageId": "python"}
c2.ports # import_gds does not automatically add the pins

# %% vscode={"languageId": "python"}
c3 = gf.import_gds(gdspath, decorator=gf.add_ports.add_ports_from_markers_inside)
c3

# %% vscode={"languageId": "python"}
c3.ports

# %% [markdown]
# Foundries provide PDKs in different formats and commercial tools.
#
# The easiest way to import a PDK into gdsfactory is to
Expand Down Expand Up @@ -159,9 +179,10 @@
#
# Then you can add the information about the GDS files and the Layers inside that package

# %% vscode={"languageId": "python"}
print(lyp_to_dataclass(PATH.klayout_lyp))

# +
# %% vscode={"languageId": "python"}
# lets create a sample PDK (for demo purposes only) using GDSfactory
# if the PDK is in a commercial tool you can also do this. Make sure you save a single pdk.gds

Expand All @@ -174,22 +195,27 @@
)
sample_pdk_cells.write_gds("extra/pdk.gds")
sample_pdk_cells
# -

# %% vscode={"languageId": "python"}
sample_pdk_cells.get_dependencies()

# %% vscode={"languageId": "python"}
# we write the sample PDK into a single GDS file
gf.clear_cache()
gf.write_cells.write_cells(
gdspath="extra/pdk.gds", dirpath="extra/gds", recursively=True
)

# %% vscode={"languageId": "python"}
print(gf.write_cells.get_import_gds_script("extra/gds"))

# %% [markdown]
# You can also include the code to plot each fix cell in the docstring.

# %% vscode={"languageId": "python"}
print(gf.write_cells.get_import_gds_script("extra/gds", module="samplepdk.components"))

# %% [markdown]
# ## Import PDK from other python packages
#
# You can Write the cells to GDS and use the
Expand All @@ -206,18 +232,7 @@
# - review your code with your colleagues and other gdsfactory developers to get feedback. This is key to get better at coding gdsfactory.
# - get rid of any warnings you see.

# ## Foundry PDKs
#
# You can build PDKs for different foundries. PDKs contain some foundry IP (layer stack, Design Rules) and are available only under and NDA.
# For accessing the gdsfactory PDK please contact your foundry for access.
#
#
# Some PDKs are open source and publicly available:
#
# - [ubcpdk](https://github.com/gdsfactory/ubc)
# - [sky130](https://github.com/gdsfactory/skywater130)
#
#
# %% [markdown]
# ## Build your own PDK
#
# You can create a PDK as a python library using a cookiecutter template. For example, you can use this one.
Expand Down

0 comments on commit c957eb0

Please sign in to comment.