Exporting Layouts to GDSII

Once a LayoutView is made, we can write it and all its dependencies (layout views of instances to child cells) to a GDSII file.

wg = i3.Waveguide()
layout = wg.Layout()

layout.write_gdsii('waveguide.gds')

The user unit and the database unit (GDSII grid) can also be specified. By default, the value of the user unit is extracted from TECH.METRICS.UNIT and the value of the database unit is extracted from TECH.METRICS.GRID. The user unit should always be an integer multiple of the grid.

layout.write_gdsii('waveguide.gds', unit=1e-6, grid=5e-9)

It’s also possible to map the IPKISS layers onto GDSII layer numbers and data-types, with the layer_map variable. This can be a dictionary or LayerMap object. By default, it is extracted from TECH.GDSII.EXPORT_LAYER_MAP. See Technology/GDSII for more info.

For example, let’s say we want to change the GDSII layer and datatype to which the waveguide core layer (TECH.PROCESS.WG, TECH.PURPOSE.LF.LINE) is written to layer 5 and datatype 2. Then, we can copy the layer map from the technology (so as to maintain the mapping for all other layers) and modify it as shown below:

from ipkiss.process.layer_map import GenericGdsiiPPLayerOutputMap

# We make a copy so that we can freely modify it.
pplayer_map = dict(i3.TECH.GDSII.LAYERTABLE)
pplayer_map[i3.TECH.PROCESS.WG, i3.TECH.PURPOSE.LF.LINE] = (5, 2)

output_layer_map = GenericGdsiiPPLayerOutputMap(pplayer_map=pplayer_map)

# Now, we use it to write our GDS:
layout.write_gdsii('waveguide.gds', layer_map=output_layer_map)

write_gdsii

class ipkiss3.all.LayoutView
Parameters:
view_name: String that contains only alphanumeric characters from the ASCII set or contains _$. ASCII set is extended on PY3.

The name of the view

write_gdsii(filename_or_stream, unit=<ipkiss3.technology.TechValue object>, grid=<ipkiss3.technology.TechValue object>, layer_map=<ipkiss3.technology.TechValue object>, filter=<ipkiss3.technology.TechValue object>, timestamp=None)

Writes a LayoutView, including all its dependencies to a GDSII file.

Parameters:
filename_or_streamstring , file object

When a string is provided, a file object will be created When a stream of file object is passed, this will be used The file object should be binary and set in write mode.

unitpositive number

The User units to be used in the GDSII file. By default, the value is extracted from TECH.METRICS.UNIT

gridpositive number

The database units (grid) to be used in the GDSII file. By default, the value is extracted from TECH.METRICS.GRID the user unit should be an integer multiple of the grid

layer_mapdict or LayerMap object

A dictionary-like object to map the IPKISS layers onto GDSII layer numbers and data-types.

filter: Filter

Optional, a filter to be applied instead of the default.

timestamp: datetime.datetime or None

Optional, a fixed timestamp to apply to the library and all cells written. If None, the current date and time will be used.

Returns:
When running from a script, the method returns nothing.
When running in an IPython Notebook, the method returns a FileLink object that the user can use to
download the generated GDSII file.

FileOutputGdsii

class ipkiss3.all.FileOutputGdsii

Writes GDS2 output to a file.

The constructor takes the filename. The write() method streams the GDS2 data to the file

Parameters:
fixed_time_stamp: ( datetime ), optional, *None allowed*

Fix the time stamp to a specific value.If None (default), the actual local time at the time of writing the GDSIIare used. Otherwise, specify a datetime.datetime object or a float (e.g. 0.0 for 1/1/1970)

userefcache: ( bool, bool_ or int ), optional

Use a cache for efficiency; might not work in some cases

echo: ( bool, bool_ or int ), optional

when True, additional information is logged

layer_map: optional

layer map between Layer objects and output layers

name_filter: Filter, optional

filter class which is applied to all names

filter: Filter, optional

filter class which is applied to all output items

o_stream: optional

output stream

OutputGdsii

class ipkiss3.all.OutputGdsii

Writes GDS output to a stream

Parameters:
fixed_time_stamp: ( datetime ), optional, *None allowed*

Fix the time stamp to a specific value.If None (default), the actual local time at the time of writing the GDSIIare used. Otherwise, specify a datetime.datetime object or a float (e.g. 0.0 for 1/1/1970)

userefcache: ( bool, bool_ or int ), optional

Use a cache for efficiency; might not work in some cases

echo: ( bool, bool_ or int ), optional

when True, additional information is logged

layer_map: optional

layer map between Layer objects and output layers

name_filter: Filter, optional

filter class which is applied to all names

filter: Filter, optional

filter class which is applied to all output items

o_stream: optional

output stream

Notes

In general, as GDSII Structure name, the name of the PCell object is used.

For reproducibility, the views are sorted:

  • First the top-level views are exported and then the dependent views

  • Views are sorted first by their name (cell name) and then by their created attribute. created is set when creating the object or when reading a cell from a GDSII file.

In case a cell has multiple layout views which are actively used, for the default view the name of the PCell will be used and otherwise the view class will be added as a suffix. E.g. if a cell with name cell1 has 3 layout views with classes Layout, LayoutAlternate1 and LayoutAlternate2, and Layout is the default view, then the Layout view will be exported as cell1 and the others as cell1_LayoutAlternate1 and cell1_LayoutAlternate2.

In case there is a collision between cells with identical names that originate from multiple libraries (e.g. read from separate GDSII files), then

  • If all cellviews are equal then one cellview is kept with the original name. For example, cells that are part of layouts loaded with i3.GDSCell and were added to the unprefixed_library property of GDSCell or its default i3.TECH.PCELLS.LIB library, will be re-used in this way.

  • Otherwise, the names are altered to avoid the collision: the first view will be exported as above, the second with a suffix _1, the third with _2, and so forth.

collect(item, **kwargs)

collects an item for output

collect_Library(library, **kwargs)

Collect a Library to GDSII.

Collects the default layout views of the top-level cells

Parameters:
library: Library

the library to collect