Types¶
DirectivePointsDbu
module-attribute
¶
DirectivePointsDbu: TypeAlias = list[
PositionWithDirectionDbu
]
OrientationLike
module-attribute
¶
OrientationLike: TypeAlias = (
OrientationChar
| OrientationWord
| OrientationDegree
| Int
| Float
| None
)
OrientationTransition
module-attribute
¶
OrientationTransition: TypeAlias = tuple[
OrientationChar, OrientationChar
]
OrientationWord
module-attribute
¶
PortLike
module-attribute
¶
PortLike: TypeAlias = (
PositionDbu
| tuple[Dbu, Dbu, OrientationLike]
| Port
| DPort
)
PositionDbu
module-attribute
¶
PositionUm
module-attribute
¶
PositionWithDirectionDbu
module-attribute
¶
PositionWithDirectionDbu: TypeAlias = Annotated[
tuple[Dbu, Dbu, OrientationChar],
"x[dbu] y[dbu] d[n|e|s|w|o]",
]
PositionWithDirectionUm
module-attribute
¶
PositionWithDirectionUm: TypeAlias = Annotated[
tuple[Um, Um, OrientationChar], "x[um] y[um] d[neswo]"
]
StepDbu
¶
Bases: TypedDict
Attributes:
Name | Type | Description |
---|---|---|
dx |
NotRequired[Dbu]
|
|
dy |
NotRequired[Dbu]
|
|
x |
NotRequired[Dbu]
|
|
y |
NotRequired[Dbu]
|
|
DInstance
¶
Bases: ProtoTInstance[float]
, UMGeometricObject
An Instance of a KCell.
An Instance is a reference to a KCell with a transformation.
Attributes:
Name | Type | Description |
---|---|---|
_instance |
The internal |
|
ports |
DInstancePorts
|
Transformed ports of the KCell |
kcl |
Pointer to the layout object holding the instance |
|
d |
Helper that allows retrieval of instance information in um |
Methods:
Name | Description |
---|---|
__getitem__ |
Returns port from instance. |
__init__ |
Create an instance from a KLayout Instance. |
Attributes:
Name | Type | Description |
---|---|---|
cell |
DKCell
|
Parent KCell of the Instance. |
kcl |
|
|
parent_cell |
DKCell
|
Gets the cell this instance is contained in. |
ports |
DInstancePorts
|
Gets the transformed ports of the KCell. |
yaml_tag |
str
|
|
__getitem__
¶
Returns port from instance.
The key can either be an integer, in which case the nth port is returned, or a string in which case the first port with a matching name is returned.
If the instance is an array, the key can also be a tuple in the
form of c.ports[key_name, i_a, i_b]
, where i_a
is the index in
the instance.a
direction and i_b
the instance.b
direction.
E.g. c.ports["a", 3, 5]
, accesses the ports of the instance which is
3 times in a
direction (4th index in the array), and 5 times in b
direction
(5th index in the array).
Instance
¶
Bases: ProtoTInstance[int]
, DBUGeometricObject
An Instance of a KCell.
An Instance is a reference to a KCell with a transformation.
Attributes:
Name | Type | Description |
---|---|---|
_instance |
The internal |
|
ports |
InstancePorts
|
Transformed ports of the KCell |
kcl |
Pointer to the layout object holding the instance |
|
d |
Helper that allows retrieval of instance information in um |
Methods:
Name | Description |
---|---|
__getitem__ |
Returns port from instance. |
__init__ |
Create an instance from a KLayout Instance. |
to_yaml |
Convert the instance to a yaml representation. |
Attributes:
Name | Type | Description |
---|---|---|
cell |
KCell
|
Parent KCell of the Instance. |
kcl |
|
|
parent_cell |
KCell
|
Gets the cell this instance is contained in. |
ports |
InstancePorts
|
Gets the transformed ports of the KCell. |
yaml_tag |
str
|
|
__getitem__
¶
Returns port from instance.
The key can either be an integer, in which case the nth port is returned, or a string in which case the first port with a matching name is returned.
If the instance is an array, the key can also be a tuple in the
form of c.ports[key_name, i_a, i_b]
, where i_a
is the index in
the instance.a
direction and i_b
the instance.b
direction.
E.g. c.ports["a", 3, 5]
, accesses the ports of the instance which is
3 times in a
direction (4th index in the array), and 5 times in b
direction
(5th index in the array).
DKCell
¶
Bases: ProtoTKCell[float]
, UMGeometricObject
Cell with floating point units.
Methods:
Name | Description |
---|---|
__getitem__ |
Returns port from instance. |
__init__ |
Constructor of KCell. |
__lshift__ |
Convenience function for create_inst. |
create_inst |
|
create_port |
Create a port in the cell. |
get_cross_section |
|
Attributes:
Name | Type | Description |
---|---|---|
insts |
DInstances
|
Instances associated with the cell. |
ports |
DPorts
|
Ports associated with the cell. |
yaml_tag |
str
|
|
__init__
¶
__init__(
name: str | None = None,
kcl: KCLayout | None = None,
kdb_cell: Cell | None = None,
ports: Iterable[ProtoPort[Any]] | None = None,
info: dict[str, Any] | None = None,
settings: dict[str, Any] | None = None,
*,
base: TKCell | None = None
) -> None
Constructor of KCell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base
|
TKCell | None
|
If not |
None
|
name
|
str | None
|
Name of the cell, if None will autogenerate name to
"Unnamed_ |
None
|
kcl
|
KCLayout | None
|
KCLayout the cell should be attached to. |
None
|
kdb_cell
|
Cell | None
|
If not |
None
|
ports
|
Iterable[ProtoPort[Any]] | None
|
Attach an existing [Ports][kfactory.kcell.Ports] object to the KCell,
if |
None
|
info
|
dict[str, Any] | None
|
Info object to attach to the KCell. |
None
|
settings
|
dict[str, Any] | None
|
KCellSettings object to attach to the KCell. |
None
|
__lshift__
¶
__lshift__(cell: AnyTKCell) -> DInstance
Convenience function for create_inst.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell
|
AnyTKCell
|
The cell to be added as an instance |
required |
KCell
¶
Bases: ProtoTKCell[int]
, DBUGeometricObject
Cell with integer units.
Methods:
Name | Description |
---|---|
__getitem__ |
Returns port from instance. |
__init__ |
Constructor of KCell. |
__lshift__ |
Convenience function for create_inst. |
create_inst |
|
create_port |
Create a port in the cell. |
from_yaml |
Internal function used by the placer to convert yaml to a KCell. |
get_cross_section |
|
to_yaml |
Internal function to convert the cell to yaml. |
Attributes:
Name | Type | Description |
---|---|---|
insts |
Instances
|
Instances associated with the cell. |
ports |
Ports
|
Ports associated with the cell. |
yaml_tag |
str
|
|
__init__
¶
__init__(
name: str | None = None,
kcl: KCLayout | None = None,
kdb_cell: Cell | None = None,
ports: Iterable[ProtoPort[Any]] | None = None,
info: dict[str, Any] | None = None,
settings: dict[str, Any] | None = None,
*,
base: TKCell | None = None
) -> None
Constructor of KCell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base
|
TKCell | None
|
If not |
None
|
name
|
str | None
|
Name of the cell, if None will autogenerate name to
"Unnamed_ |
None
|
kcl
|
KCLayout | None
|
KCLayout the cell should be attached to. |
None
|
kdb_cell
|
Cell | None
|
If not |
None
|
ports
|
Iterable[ProtoPort[Any]] | None
|
Attach an existing [Ports][kfactory.kcell.Ports] object to the KCell,
if |
None
|
info
|
dict[str, Any] | None
|
Info object to attach to the KCell. |
None
|
settings
|
dict[str, Any] | None
|
KCellSettings object to attach to the KCell. |
None
|
__lshift__
¶
__lshift__(cell: AnyTKCell) -> Instance
Convenience function for create_inst.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell
|
AnyTKCell
|
The cell to be added as an instance |
required |
create_inst
¶
create_inst(
cell: AnyTKCell | int,
trans: Trans | Vector | ICplxTrans | None = None,
*,
a: Vector | None = None,
b: Vector | None = None,
na: int = 1,
nb: int = 1,
libcell_as_static: bool = False,
static_name_separator: str = "__"
) -> Instance
from_yaml
classmethod
¶
Internal function used by the placer to convert yaml to a KCell.
ProtoTKCell
¶
Bases: ProtoKCell[TUnit, TKCell]
, Generic[TUnit]
, ABC
Methods:
Name | Description |
---|---|
__copy__ |
Enables use of |
__eq__ |
|
__getattr__ |
If KCell doesn't have an attribute, look in the KLayout Cell. |
__getitem__ |
Returns port from instance. |
__hash__ |
Hash the KCell. |
__init__ |
|
__lshift__ |
|
auto_rename_ports |
Rename the ports with the schema angle -> "NSWE" and sort by x and y. |
cell_index |
Gets the cell index. |
circuit |
Create the circuit of the KCell in the given netlist. |
connectivity_check |
Create a ReportDatabase for port problems. |
convert_to_static |
Convert the KCell to a static cell if it is pdk KCell. |
create_inst |
|
create_port |
Proxy for [Ports.create_port][kfactory.kcell.Ports.create_port]. |
dbbox |
|
dcreate_inst |
Add an instance of another KCell. |
delete |
Delete the cell. |
destroyed |
|
draw_ports |
Draw all the ports on their respective layer. |
dup |
Copy the full cell. |
each_inst |
Iterates over all child instances (which may actually be instance arrays). |
each_overlapping_inst |
Gets the instances overlapping the given rectangle. |
each_touching_inst |
Gets the instances overlapping the given rectangle. |
flatten |
Flatten the cell. |
get_cross_section |
|
get_meta_data |
Read metadata from the KLayout Layout object. |
ibbox |
|
icreate_inst |
Add an instance of another KCell. |
insert |
Inserts a cell instance given by another reference. |
insert_vinsts |
Insert all virtual instances and create Instances of real KCells. |
l2n |
Generate a LayoutToNetlist object from the port types. |
layout |
|
library |
|
plot |
Display cell. |
read |
Read a GDS file into the existing KCell. |
set_meta_data |
Set metadata of the Cell. |
shapes |
|
show |
Stream the gds to klive. |
to_dtype |
Convert the kcell to a um kcell. |
to_itype |
Convert the kcell to a dbu kcell. |
transform |
Transforms the instance or cell with the transformation given. |
write |
Write a KCell to a GDS. |
Attributes:
Name | Type | Description |
---|---|---|
boundary |
DPolygon | None
|
|
ghost_cell |
bool
|
Returns a value indicating whether the cell is a "ghost cell". |
insts |
ProtoTInstances[TUnit]
|
|
kdb_cell |
Cell
|
|
name |
str
|
|
prop_id |
int
|
Gets the properties ID associated with the cell. |
_base
instance-attribute
¶
_base = TKCell(
kcl=kcl_,
info=Info(**info or {}),
settings=KCellSettings(**settings or {}),
kdb_cell=kdb_cell_,
ports=[base for port in ports] if ports else [],
vinsts=VInstances(),
)
ghost_cell
property
writable
¶
ghost_cell: bool
Returns a value indicating whether the cell is a "ghost cell".
__getattr__
¶
If KCell doesn't have an attribute, look in the KLayout Cell.
__getitem__
abstractmethod
¶
Returns port from instance.
__init__
¶
__init__(
*,
base: TKCell | None = None,
name: str | None = None,
kcl: KCLayout | None = None,
kdb_cell: Cell | None = None,
ports: Iterable[ProtoPort[Any]] | None = None,
info: dict[str, Any] | None = None,
settings: dict[str, Any] | None = None
) -> None
_get_ci
¶
_get_ci(
cell: ProtoTKCell[Any],
libcell_as_static: bool = False,
static_name_separator: str = "__",
) -> int
_ipython_display_
¶
Display a cell in a Jupyter Cell.
Usage: Pass the kcell variable as an argument in the cell at the end
auto_rename_ports
¶
auto_rename_ports(
rename_func: Callable[..., None] | None = None,
) -> None
Rename the ports with the schema angle -> "NSWE" and sort by x and y.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rename_func
|
Callable[..., None] | None
|
Function that takes Iterable[Port] and renames them. This can of course contain a filter and only rename some of the ports |
None
|
circuit
¶
Create the circuit of the KCell in the given netlist.
connectivity_check
¶
connectivity_check(
port_types: list[str] | None = None,
layers: list[int] | None = None,
db: ReportDatabase | None = None,
recursive: bool = True,
add_cell_ports: bool = False,
check_layer_connectivity: bool = True,
) -> ReportDatabase
Create a ReportDatabase for port problems.
Problems are overlapping ports that aren't aligned, more than two ports overlapping, width mismatch, port_type mismatch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port_types
|
list[str] | None
|
Filter for certain port typers |
None
|
layers
|
list[int] | None
|
Only create the report for certain layers |
None
|
db
|
ReportDatabase | None
|
Use an existing ReportDatabase instead of creating a new one |
None
|
recursive
|
bool
|
Create the report not only for this cell, but all child cells as well. |
True
|
add_cell_ports
|
bool
|
Also add a category "CellPorts" which contains all the cells selected ports. |
False
|
check_layer_connectivity
|
bool
|
Check whether the layer overlaps with instances. |
True
|
convert_to_static
¶
convert_to_static(recursive: bool = True) -> None
Convert the KCell to a static cell if it is pdk KCell.
create_inst
abstractmethod
¶
create_inst(
cell: ProtoTKCell[Any] | int,
trans: (
Trans
| Vector
| ICplxTrans
| DTrans
| DVector
| DCplxTrans
| None
) = None,
*,
a: Vector | DVector | None = None,
b: Vector | DVector | None = None,
na: int = 1,
nb: int = 1,
libcell_as_static: bool = False,
static_name_separator: str = "__"
) -> Instance | DInstance
create_port
¶
create_port(**kwargs: Any) -> ProtoPort[TUnit]
Proxy for [Ports.create_port][kfactory.kcell.Ports.create_port].
dcreate_inst
¶
dcreate_inst(
cell: ProtoTKCell[Any] | int,
trans: DTrans | DVector | DCplxTrans | None = None,
*,
a: DVector | None = None,
b: DVector | None = None,
na: int = 1,
nb: int = 1,
libcell_as_static: bool = False,
static_name_separator: str = "__"
) -> DInstance
Add an instance of another KCell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell
|
ProtoTKCell[Any] | int
|
The cell to be added |
required |
trans
|
DTrans | DVector | DCplxTrans | None
|
The integer transformation applied to the reference |
None
|
a
|
DVector | None
|
Vector for the array. Needs to be in positive X-direction. Usually this is only a Vector in x-direction. Some foundries won't allow other Vectors. |
None
|
b
|
DVector | None
|
Vector for the array. Needs to be in positive Y-direction. Usually this is only a Vector in x-direction. Some foundries won't allow other Vectors. |
None
|
na
|
int
|
Number of elements in direction of |
1
|
nb
|
int
|
Number of elements in direction of |
1
|
libcell_as_static
|
bool
|
If the cell is a Library cell (different KCLayout object), convert it to a static cell. This can cause name collisions that are automatically resolved by appending $1[..n] on the newly created cell. |
False
|
static_name_separator
|
str
|
Stringt to separate the KCLayout name from the cell name when converting library cells (other KCLayout object than the one of this KCell) to static cells (copy them into this KCell's KCLayout). |
'__'
|
Returns:
Type | Description |
---|---|
DInstance
|
The created instance |
dup
¶
dup() -> Self
Copy the full cell.
Sets _locked
to False
Returns:
Name | Type | Description |
---|---|---|
cell |
Self
|
Exact copy of the current cell.
The name will have |
each_inst
¶
Iterates over all child instances (which may actually be instance arrays).
each_overlapping_inst
¶
Gets the instances overlapping the given rectangle.
each_touching_inst
¶
Gets the instances overlapping the given rectangle.
flatten
¶
flatten(merge: bool = True) -> None
Flatten the cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
merge
|
bool
|
Merge the shapes on all layers. |
True
|
get_cross_section
abstractmethod
¶
get_cross_section(
cross_section: (
str
| dict[str, Any]
| Callable[..., CrossSection | DCrossSection]
| SymmetricalCrossSection
),
**cross_section_kwargs: Any
) -> TCrossSection[TUnit]
get_meta_data
¶
get_meta_data(
meta_format: Literal["v1", "v2", "v3"] | None = None,
) -> None
Read metadata from the KLayout Layout object.
icreate_inst
¶
icreate_inst(
cell: ProtoTKCell[Any] | int,
trans: Trans | Vector | ICplxTrans | None = None,
*,
a: Vector | None = None,
b: Vector | None = None,
na: int = 1,
nb: int = 1,
libcell_as_static: bool = False,
static_name_separator: str = "__"
) -> Instance
Add an instance of another KCell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell
|
ProtoTKCell[Any] | int
|
The cell to be added |
required |
trans
|
Trans | Vector | ICplxTrans | None
|
The integer transformation applied to the reference |
None
|
a
|
Vector | None
|
Vector for the array. Needs to be in positive X-direction. Usually this is only a Vector in x-direction. Some foundries won't allow other Vectors. |
None
|
b
|
Vector | None
|
Vector for the array. Needs to be in positive Y-direction. Usually this is only a Vector in x-direction. Some foundries won't allow other Vectors. |
None
|
na
|
int
|
Number of elements in direction of |
1
|
nb
|
int
|
Number of elements in direction of |
1
|
libcell_as_static
|
bool
|
If the cell is a Library cell (different KCLayout object), convert it to a static cell. This can cause name collisions that are automatically resolved by appending $1[..n] on the newly created cell. |
False
|
static_name_separator
|
str
|
Stringt to separate the KCLayout name from the cell name when converting library cells (other KCLayout object than the one of this KCell) to static cells (copy them into this KCell's KCLayout). |
'__'
|
Returns:
Type | Description |
---|---|
Instance
|
The created instance |
insert
¶
insert(
inst: Instance | CellInstArray | DCellInstArray,
property_id: int | None = None,
) -> Instance
Inserts a cell instance given by another reference.
insert_vinsts
¶
insert_vinsts(recursive: bool = True) -> None
Insert all virtual instances and create Instances of real KCells.
l2n
¶
plot
¶
read
¶
read(
filename: str | Path,
options: LoadLayoutOptions | None = None,
register_cells: bool = False,
test_merge: bool = True,
update_kcl_meta_data: Literal[
"overwrite", "skip", "drop"
] = "drop",
meta_format: Literal["v1", "v2", "v3"] | None = None,
) -> list[int]
Read a GDS file into the existing KCell.
Any existing meta info (KCell.info and KCell.settings) will be overwritten if a KCell already exists. Instead of overwriting the cells, they can also be loaded into new cells by using the corresponding cell_conflict_resolution.
Layout meta infos are ignored from the loaded layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str | Path
|
Path of the GDS file. |
required |
options
|
LoadLayoutOptions | None
|
KLayout options to load from the GDS. Can determine how merge conflicts are handled for example. See https://www.klayout.de/doc-qt5/code/class_LoadLayoutOptions.html |
None
|
register_cells
|
bool
|
If |
False
|
test_merge
|
bool
|
Check the layouts first whether they are compatible (no differences). |
True
|
update_kcl_meta_data
|
Literal['overwrite', 'skip', 'drop']
|
How to treat loaded KCLayout info. overwrite: overwrite existing info entries skip: keep existing info values drop: don't add any new info |
'drop'
|
meta_format
|
Literal['v1', 'v2', 'v3'] | None
|
How to read KCell metainfo from the gds. |
None
|
set_meta_data
¶
Set metadata of the Cell.
Currently, ports, settings and info will be set.
show
¶
show(
lyrdb: ReportDatabase | Path | str | None = None,
l2n: LayoutToNetlist | Path | str | None = None,
keep_position: bool = True,
save_options: SaveLayoutOptions | None = None,
use_libraries: bool = True,
library_save_options: SaveLayoutOptions | None = None,
) -> None
Stream the gds to klive.
Will create a temporary file of the gds and load it in KLayout via klive
transform
¶
transform(
inst: Instance,
trans: Trans | DTrans | ICplxTrans | DCplxTrans,
/,
*,
transform_ports: bool = True,
) -> Instance
transform(
trans: Trans | DTrans | ICplxTrans | DCplxTrans,
/,
*,
transform_ports: bool = True,
) -> None
transform(
inst_or_trans: (
Instance | Trans | DTrans | ICplxTrans | DCplxTrans
),
trans: (
Trans | DTrans | ICplxTrans | DCplxTrans | None
) = None,
/,
*,
transform_ports: bool = True,
) -> Instance | None
Transforms the instance or cell with the transformation given.
LayerEnum
¶
Bases: int
, Enum
Class for having the layers stored and a mapping int <-> layer,datatype.
This Enum can also be treated as a tuple, i.e. it implements __getitem__
and __len__
.
Attributes:
Name | Type | Description |
---|---|---|
layer |
int
|
layer number |
datatype |
int
|
layer datatype |
Methods:
Name | Description |
---|---|
__getitem__ |
Retrieve layer number[0] / datatype[1] of a layer. |
__init__ |
Just here to make sure klayout knows the layer name. |
__iter__ |
Allow for loops to iterate over the LayerEnum. |
__len__ |
A layer has length 2, layer number and datatype. |
__new__ |
Create a new Enum. |
__str__ |
Return the name of the LayerEnum. |
Attributes:
Name | Type | Description |
---|---|---|
datatype |
int
|
|
layer |
int
|
|
layout |
constant[Layout]
|
|
name |
str
|
|
KCLayout
¶
Bases: BaseModel
Small extension to the klayout.db.Layout.
It adds tracking for the KCell objects
instead of only the klayout.db.Cell
objects.
Additionally it allows creation and registration through create_cell
All attributes of klayout.db.Layout
are transparently accessible
Attributes:
Name | Type | Description |
---|---|---|
editable |
Whether the layout should be opened in editable mode (default: True) |
|
rename_function |
Callable[..., None]
|
function that takes an iterable object of ports and renames them |
Methods:
Name | Description |
---|---|
__getattr__ |
If KCLayout doesn't have an attribute, look in the KLayout Cell. |
__getitem__ |
Retrieve a cell by name(str) or index(int). |
__init__ |
Create a new KCLayout (PDK). Can be based on an old KCLayout. |
__repr__ |
|
__setattr__ |
Use a custom setter to automatically set attributes. |
assign |
Assign a new Layout object to the KCLayout object. |
cell |
Decorator to cache and auto name the cell. |
clear |
Clear the Layout. |
clear_kcells |
Clears all cells in the Layout object. |
create_cell |
Create a new cell in the library. |
create_layer_enclosure |
Create a new LayerEnclosure in the KCLayout. |
delete_cell |
Delete a cell in the kcl object. |
delete_cell_rec |
Deletes a KCell plus all subcells. |
delete_cells |
Delete a sequence of cell by indexes. |
dkcell |
Create a new cell based ont he pdk's layout object. |
dup |
Create a duplication of the |
find_layer |
Try to find a registered layer. Throws a KeyError if it cannot find it. |
get_cell |
Retrieve a cell by name(str) or index(int). |
get_component |
|
get_dcross_section |
Get a cross section by name or specification. |
get_enclosure |
Gets a layer enclosure by name specification or the layerenclosure itself. |
get_icross_section |
Get a cross section by name or specification. |
get_meta_data |
Read KCLayout meta info from the KLayout object. |
get_symmetrical_cross_section |
Get a cross section by name or specification. |
kcell |
Create a new cell based ont he pdk's layout object. |
layerenum_from_dict |
Create a new LayerEnum from this KCLayout. |
layout_cell |
Get a cell by name or index from the Layout object. |
read |
Read a GDS file into the existing Layout. |
rebuild |
Rebuild the KCLayout based on the Layout object. |
register_cell |
Register an existing cell in the KCLayout object. |
set_layers_from_infos |
Create a new LAYER enum based on the pdk's kcl. |
set_meta_data |
Set the info/settings of the KCLayout. |
to_dbu |
Convert Shapes or values in dbu to DShapes or floats in um. |
to_um |
Convert Shapes or values in dbu to DShapes or floats in um. |
top_kcell |
Return the top KCell if there is a single one. |
top_kcells |
Return the top KCells. |
vcell |
Decorator to cache and auto name the cell. |
vkcell |
Create a new cell based ont he pdk's layout object. |
write |
Write a GDS file into the existing Layout. |
Attributes:
Name | Type | Description |
---|---|---|
constants |
Constants
|
|
cross_sections |
CrossSectionModel
|
|
dbu |
float
|
Get the database unit. |
decorators |
Decorators
|
|
default_cell_output_type |
type[KCell | DKCell]
|
|
dkcells |
DKCells
|
DKCells is a mapping of int to DKCell. |
enclosure |
KCellEnclosure
|
|
factories |
Factories[AnyTKCell]
|
|
future_cell_name |
str | None
|
|
info |
Info
|
|
infos |
LayerInfos
|
|
interconnect_cml_path |
Path | str | None
|
|
kcells |
KCells
|
KCells is a mapping of int to KCell. |
layer_enclosures |
LayerEnclosureModel
|
|
layer_stack |
LayerStack
|
|
layers |
type[LayerEnum]
|
|
layout |
Layout
|
|
library |
Library
|
|
name |
str
|
|
netlist_layer_mapping |
dict[LayerEnum | int, LayerEnum | int]
|
|
rename_function |
Callable[..., None]
|
|
settings |
KCellSettings
|
|
sparameters_path |
Path | str | None
|
|
thread_lock |
RLock
|
|
tkcells |
dict[int, TKCell]
|
|
virtual_factories |
Factories[VKCell]
|
|
default_cell_output_type
class-attribute
instance-attribute
¶
interconnect_cml_path
instance-attribute
¶
netlist_layer_mapping
class-attribute
instance-attribute
¶
tkcells
class-attribute
instance-attribute
¶
__getattr__
¶
If KCLayout doesn't have an attribute, look in the KLayout Cell.
__getitem__
¶
Retrieve a cell by name(str) or index(int).
Attrs
obj: name of cell or cell_index
__init__
¶
__init__(
name: str,
layer_enclosures: (
dict[str, LayerEnclosure]
| LayerEnclosureModel
| None
) = None,
enclosure: KCellEnclosure | None = None,
infos: type[LayerInfos] | None = None,
sparameters_path: Path | str | None = None,
interconnect_cml_path: Path | str | None = None,
layer_stack: LayerStack | None = None,
constants: type[Constants] | None = None,
base_kcl: KCLayout | None = None,
port_rename_function: Callable[
..., None
] = rename_clockwise_multi,
copy_base_kcl_layers: bool = True,
info: dict[str, MetaData] | None = None,
default_cell_output_type: type[KCell | DKCell] = KCell,
) -> None
Create a new KCLayout (PDK). Can be based on an old KCLayout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the PDK. |
required |
layer_enclosures
|
dict[str, LayerEnclosure] | LayerEnclosureModel | None
|
Additional KCellEnclosures that should be available except the KCellEnclosure |
None
|
enclosure
|
KCellEnclosure | None
|
The standard KCellEnclosure of the PDK. |
None
|
infos
|
type[LayerInfos] | None
|
A LayerInfos describing the layerstack of the PDK. |
None
|
sparameters_path
|
Path | str | None
|
Path to the sparameters config file. |
None
|
interconnect_cml_path
|
Path | str | None
|
Path to the interconnect file. |
None
|
layer_stack
|
LayerStack | None
|
maps name to layer numbers, thickness, zmin, sidewall_angle. if can also contain material properties (refractive index, nonlinear coefficient, sheet resistance ...). |
None
|
constants
|
type[Constants] | None
|
A model containing all the constants related to the PDK. |
None
|
base_kcl
|
KCLayout | None
|
an optional basis of the PDK. |
None
|
port_rename_function
|
Callable[..., None]
|
Which function to use for renaming kcell ports. |
rename_clockwise_multi
|
copy_base_kcl_layers
|
bool
|
Copy all known layers from the base if any are defined. |
True
|
info
|
dict[str, MetaData] | None
|
Additional metadata to put into info attribute. |
None
|
__setattr__
¶
Use a custom setter to automatically set attributes.
If the attribute is not in this object, set it on the Layout object.
_cells
¶
cell
¶
cell(
*,
set_settings: bool = ...,
set_name: bool = ...,
check_ports: bool = ...,
check_instances: CheckInstances | None = ...,
snap_ports: bool = ...,
add_port_layers: bool = ...,
cache: Cache[int, Any] | dict[int, Any] | None = ...,
basename: str | None = ...,
drop_params: list[str] = ...,
register_factory: bool = ...,
overwrite_existing: bool | None = ...,
layout_cache: bool | None = ...,
info: dict[str, MetaData] | None = ...,
post_process: Iterable[Callable[[K], None]] = ...,
debug_names: bool | None = ...,
tags: list[str] | None = ...
) -> Callable[
[KCellFunc[KCellParams, K]], KCellFunc[KCellParams, K]
]
cell(
*,
output_type: type[K],
set_settings: bool = ...,
set_name: bool = ...,
check_ports: bool = ...,
check_instances: CheckInstances | None = ...,
snap_ports: bool = ...,
add_port_layers: bool = ...,
cache: Cache[int, Any] | dict[int, Any] | None = ...,
basename: str | None = ...,
drop_params: list[str] = ...,
register_factory: bool = ...,
overwrite_existing: bool | None = ...,
layout_cache: bool | None = ...,
info: dict[str, MetaData] | None = ...,
post_process: Iterable[Callable[[K], None]] = ...,
debug_names: bool | None = ...,
tags: list[str] | None = ...
) -> Callable[
[KCellFunc[KCellParams, AnyTKCell]],
KCellFunc[KCellParams, K],
]
cell(
_func: KCellFunc[KCellParams, K] | None = None,
/,
*,
output_type: type[K] | None = None,
set_settings: bool = True,
set_name: bool = True,
check_ports: bool = True,
check_instances: CheckInstances | None = None,
snap_ports: bool = True,
add_port_layers: bool = True,
cache: Cache[int, Any] | dict[int, Any] | None = None,
basename: str | None = None,
drop_params: Sequence[str] = ("self", "cls"),
register_factory: bool = True,
overwrite_existing: bool | None = None,
layout_cache: bool | None = None,
info: dict[str, MetaData] | None = None,
post_process: Iterable[Callable[[K], None]] = tuple(),
debug_names: bool | None = None,
tags: list[str] | None = None,
) -> (
KCellFunc[KCellParams, K]
| Callable[
[KCellFunc[KCellParams, K]],
KCellFunc[KCellParams, K],
]
| Callable[
[KCellFunc[KCellParams, AnyTKCell]],
KCellFunc[KCellParams, K],
]
)
Decorator to cache and auto name the cell.
This will use functools.cache
to cache the function call.
Additionally, if enabled this will set the name and from the args/kwargs of the
function and also paste them into a settings dictionary of the
KCell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_type
|
type[K] | None
|
The type of the cell to return. |
None
|
set_settings
|
bool
|
Copy the args & kwargs into the settings dictionary |
True
|
set_name
|
bool
|
Auto create the name of the cell to the functionname plus a string created from the args/kwargs |
True
|
check_ports
|
bool
|
Check uniqueness of port names. |
True
|
check_instances
|
CheckInstances | None
|
Check for any complex instances. A complex instance is a an instance that has a magnification != 1 or non-90° rotation. Depending on the setting, an error is raised, the cell is flattened, a VInstance is created instead of a regular instance, or they are ignored. |
None
|
snap_ports
|
bool
|
Snap the centers of the ports onto the grid (only x/y, not angle). |
True
|
add_port_layers
|
bool
|
Add special layers of netlist_layer_mapping to the ports if the port layer is in the mapping. |
True
|
cache
|
Cache[int, Any] | dict[int, Any] | None
|
Provide a user defined cache instead of an internal one. This can be used for example to clear the cache. expensive if the cell is called often). |
None
|
basename
|
str | None
|
Overwrite the name normally inferred from the function or class name. |
None
|
drop_params
|
Sequence[str]
|
Drop these parameters before writing the [settings][kfactory.kcell.KCell.settings] |
('self', 'cls')
|
register_factory
|
bool
|
Register the resulting KCell-function to the factories |
True
|
layout_cache
|
bool | None
|
If true, treat the layout like a cache, if a cell with the
same name exists already, pick that one instead of using running the
function. This only works if |
None
|
overwrite_existing
|
bool | None
|
If cells were created with the same name, delete other
cells with the same name. Can be globally configured through
|
None
|
info
|
dict[str, MetaData] | None
|
Additional metadata to put into info attribute. |
None
|
post_process
|
Iterable[Callable[[K], None]]
|
List of functions to call after the cell has been created. |
tuple()
|
debug_names
|
bool | None
|
Check on setting the name whether a cell with this name already exists. |
None
|
tags
|
list[str] | None
|
Tag cell functions with user defined tags. With this, cell functions
can then be retrieved with |
None
|
clear
¶
clear(keep_layers: bool = True) -> None
Clear the Layout.
If the layout is cleared, all the LayerEnums and
create_cell
¶
Create a new cell in the library.
This shouldn't be called manually. The constructor of KCell will call this method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The (initial) name of the cell. |
required |
allow_duplicate
|
bool
|
Allow the creation of a cell with the same name which
already is registered in the Layout.
This will create a cell with the name |
False
|
args
|
str
|
additional arguments passed to
|
()
|
Returns:
Type | Description |
---|---|
Cell
|
klayout.db.Cell: klayout.db.Cell object created in the Layout |
create_layer_enclosure
¶
create_layer_enclosure(
sections: Sequence[
tuple[LayerInfo, int] | tuple[LayerInfo, int, int]
] = [],
name: str | None = None,
main_layer: LayerInfo | None = None,
dsections: (
Sequence[
tuple[LayerInfo, float]
| tuple[LayerInfo, float, float]
]
| None
) = None,
) -> LayerEnclosure
Create a new LayerEnclosure in the KCLayout.
delete_cells
¶
Delete a sequence of cell by indexes.
dkcell
¶
Create a new cell based ont he pdk's layout object.
dup
¶
find_layer
¶
find_layer(info: LayerInfo) -> LayerEnum
find_layer(
*args: int | str | LayerInfo,
**kwargs: int | str | LayerInfo | bool
) -> LayerEnum | int
Try to find a registered layer. Throws a KeyError if it cannot find it.
Can find a layer either by name, layer and datatype (two args), LayerInfo, or all three of layer, datatype, and name.
get_cell
¶
Retrieve a cell by name(str) or index(int).
Attrs
obj: name of cell or cell_index cell_type: type of cell to return
get_component
¶
get_component(
spec: str, **cell_kwargs: Any
) -> ProtoTKCell[Any]
get_component(
spec: KCellSpec,
*,
output_type: type[K] | None = None,
**cell_kwargs: Any
) -> ProtoTKCell[Any]
get_dcross_section
¶
get_dcross_section(
cross_section: (
str
| SymmetricalCrossSection
| CrossSectionSpec[float]
| DSymmetricalCrossSection
),
) -> DCrossSection
Get a cross section by name or specification.
get_enclosure
¶
get_enclosure(
enclosure: str | LayerEnclosure | LayerEnclosureSpec,
) -> LayerEnclosure
Gets a layer enclosure by name specification or the layerenclosure itself.
get_icross_section
¶
get_icross_section(
cross_section: (
str
| SymmetricalCrossSection
| CrossSectionSpec[int]
| DSymmetricalCrossSection
),
) -> CrossSection
Get a cross section by name or specification.
get_meta_data
¶
Read KCLayout meta info from the KLayout object.
get_symmetrical_cross_section
¶
get_symmetrical_cross_section(
cross_section: (
str
| SymmetricalCrossSection
| CrossSectionSpec[int]
| DSymmetricalCrossSection
),
) -> SymmetricalCrossSection
Get a cross section by name or specification.
kcell
¶
Create a new cell based ont he pdk's layout object.
layout_cell
¶
Get a cell by name or index from the Layout object.
read
¶
read(
filename: str | Path,
options: LoadLayoutOptions | None = None,
register_cells: bool | None = None,
test_merge: bool = True,
update_kcl_meta_data: Literal[
"overwrite", "skip", "drop"
] = "skip",
meta_format: Literal["v1", "v2", "v3"] | None = None,
) -> LayerMap
Read a GDS file into the existing Layout.
Any existing meta info (KCell.info and KCell.settings) will be overwritten if a KCell already exists. Instead of overwriting the cells, they can also be loaded into new cells by using the corresponding cell_conflict_resolution.
This will fail if any of the read cells try to load into a locked KCell.
Layout meta infos are ignored from the loaded layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str | Path
|
Path of the GDS file. |
required |
options
|
LoadLayoutOptions | None
|
KLayout options to load from the GDS. Can determine how merge conflicts are handled for example. See https://www.klayout.de/doc-qt5/code/class_LoadLayoutOptions.html |
None
|
register_cells
|
bool | None
|
If |
None
|
test_merge
|
bool
|
Check the layouts first whether they are compatible (no differences). |
True
|
update_kcl_meta_data
|
Literal['overwrite', 'skip', 'drop']
|
How to treat loaded KCLayout info. overwrite: overwrite existing info entries skip: keep existing info values drop: don't add any new info |
'skip'
|
meta_format
|
Literal['v1', 'v2', 'v3'] | None
|
How to read KCell metainfo from the gds. |
None
|
register_cell
¶
register_cell(
kcell: AnyTKCell, allow_reregister: bool = False
) -> None
Register an existing cell in the KCLayout object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kcell
|
AnyTKCell
|
KCell 56 be registered in the KCLayout |
required |
allow_reregister
|
bool
|
Overwrite the existing KCell registration with this one. Doesn't allow name duplication. |
False
|
set_layers_from_infos
¶
Create a new LAYER enum based on the pdk's kcl.
to_dbu
¶
to_dbu(
other: (
float
| DPoint
| DVector
| DBox
| DPolygon
| DPath
| DText
| None
),
) -> (
int
| Point
| Vector
| Box
| Polygon
| Path
| Text
| None
)
Convert Shapes or values in dbu to DShapes or floats in um.
to_um
¶
to_um(
other: (
int
| Point
| Vector
| Box
| Polygon
| Path
| Text
| None
),
) -> (
float
| DPoint
| DVector
| DBox
| DPolygon
| DPath
| DText
| None
)
Convert Shapes or values in dbu to DShapes or floats in um.
vcell
¶
vcell(
_func: Callable[KCellParams, VKCell] | None = None,
/,
*,
set_settings: bool = True,
set_name: bool = True,
check_ports: bool = True,
add_port_layers: bool = True,
cache: Cache[int, Any] | dict[int, Any] | None = None,
basename: str | None = None,
drop_params: Sequence[str] = ("self", "cls"),
register_factory: bool = True,
) -> (
Callable[KCellParams, VKCell]
| Callable[
[Callable[KCellParams, VKCell]],
Callable[KCellParams, VKCell],
]
)
Decorator to cache and auto name the cell.
This will use functools.cache
to cache the function call.
Additionally, if enabled this will set the name and from the args/kwargs of the
function and also paste them into a settings dictionary of the
KCell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
set_settings
|
bool
|
Copy the args & kwargs into the settings dictionary |
True
|
set_name
|
bool
|
Auto create the name of the cell to the functionname plus a string created from the args/kwargs |
True
|
check_ports
|
bool
|
Check whether there are any non-90° ports in the cell and throw a warning if there are |
True
|
snap_ports
|
Snap the centers of the ports onto the grid (only x/y, not angle). |
required | |
add_port_layers
|
bool
|
Add special layers of netlist_layer_mapping to the ports if the port layer is in the mapping. |
True
|
cache
|
Cache[int, Any] | dict[int, Any] | None
|
Provide a user defined cache instead of an internal one. This can be used for example to clear the cache. |
None
|
rec_dicts
|
Allow and inspect recursive dictionaries as parameters (can be expensive if the cell is called often). |
required | |
basename
|
str | None
|
Overwrite the name normally inferred from the function or class name. |
None
|
drop_params
|
Sequence[str]
|
Drop these parameters before writing the [settings][kfactory.kcell.KCell.settings] |
('self', 'cls')
|
register_factory
|
bool
|
Register the resulting KCell-function to the factories |
True
|
vkcell
¶
vkcell(name: str | None = None) -> VKCell
Create a new cell based ont he pdk's layout object.
write
¶
write(
filename: str | Path,
options: SaveLayoutOptions | None = None,
set_meta_data: bool = True,
convert_external_cells: bool = False,
autoformat_from_file_extension: bool = True,
) -> None
Write a GDS file into the existing Layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str | Path
|
Path of the GDS file. |
required |
options
|
SaveLayoutOptions | None
|
KLayout options to load from the GDS. Can determine how merge conflicts are handled for example. See https://www.klayout.de/doc-qt5/code/class_LoadLayoutOptions.html |
None
|
set_meta_data
|
bool
|
Make sure all the cells have their metadata set |
True
|
convert_external_cells
|
bool
|
Whether to make KCells not in this KCLayout to |
False
|
autoformat_from_file_extension
|
bool
|
Set the format of the output file
automatically from the file extension of |
True
|
DPort
¶
Bases: ProtoPort[float]
A port is the photonics equivalent to a pin in electronics.
In addition to the location and layer that defines a pin, a port also contains an orientation and a width. This can be fully represented with a transformation, integer and layer_index.
Attributes:
Name | Type | Description |
---|---|---|
name |
str | None
|
String to name the port. |
width |
float
|
The width of the port in dbu. |
trans |
Trans
|
Transformation in dbu. If the port can be represented in 90° intervals this is the safe way to do so. |
dcplx_trans |
DCplxTrans
|
Transformation in micrometer. The port will autoconvert between trans and dcplx_trans on demand. |
port_type |
str
|
A string defining the type of the port |
layer |
LayerEnum | int
|
Index of the layer or a LayerEnum that acts like an integer, but can contain layer number and datatype |
info |
Info
|
A dictionary with additional info. Not reflected in GDS. Copy will make a (shallow) copy of it. |
d |
Info
|
Access port info in micrometer basis such as width and center / angle. |
kcl |
KCLayout
|
Link to the layout this port resides in. |
Methods:
Name | Description |
---|---|
__init__ |
Create a port from dbu or um based units. |
copy |
Get a copy of a port. |
copy_polar |
Get a polar copy of the port. |
Attributes:
Name | Type | Description |
---|---|---|
center |
|
|
cross_section |
DCrossSection
|
|
mirror_x |
|
|
orientation |
|
|
width |
float
|
Width of the port in um. |
x |
float
|
X coordinate of the port in um. |
y |
float
|
Y coordinate of the port in um. |
__init__
¶
__init__(
name: str | None = None,
*,
width: float,
layer: LayerEnum | int,
trans: Trans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: float,
layer: LayerEnum | int,
dcplx_trans: DCplxTrans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: float,
layer: LayerEnum | int,
port_type: str = "optical",
orientation: float,
center: tuple[float, float] = (0, 0),
mirror_x: bool = False,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: float,
layer_info: LayerInfo,
trans: Trans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: float,
layer_info: LayerInfo,
dcplx_trans: DCplxTrans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: float,
layer_info: LayerInfo,
port_type: str = "optical",
orientation: float,
center: tuple[float, float] = (0, 0),
mirror_x: bool = False,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
cross_section: DCrossSection | SymmetricalCrossSection,
port_type: str = "optical",
orientation: float,
center: tuple[float, float],
mirror_x: bool = False,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
cross_section: DCrossSection | SymmetricalCrossSection,
trans: Trans | str,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...,
port_type: str = "optical"
) -> None
__init__(
name: str | None = None,
*,
cross_section: DCrossSection | SymmetricalCrossSection,
dcplx_trans: DCplxTrans | str,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...,
port_type: str = "optical"
) -> None
__init__(*, port: ProtoPort[Any]) -> None
__init__(
name: str | None = None,
*,
width: float | None = None,
layer: int | None = None,
layer_info: LayerInfo | None = None,
port_type: str = "optical",
trans: Trans | str | None = None,
dcplx_trans: DCplxTrans | str | None = None,
orientation: float = 0,
center: tuple[float, float] = (0, 0),
mirror_x: bool = False,
port: ProtoPort[Any] | None = None,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] | None = None,
cross_section: (
DCrossSection | SymmetricalCrossSection | None
) = None,
base: BasePort | None = None
) -> None
Create a port from dbu or um based units.
copy
¶
copy(
trans: Trans | DCplxTrans = R0,
post_trans: Trans | DCplxTrans = R0,
) -> DPort
Get a copy of a port.
Transformation order which results in copy.trans
:
- Trans: trans * port.trans * post_trans
- DCplxTrans: trans * port.dcplx_trans * post_trans
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trans
|
Trans | DCplxTrans
|
an optional transformation applied to the port to be copied. |
R0
|
post_trans
|
Trans | DCplxTrans
|
transformation to apply to the port after copying. |
R0
|
Returns:
Name | Type | Description |
---|---|---|
port |
DPort
|
a copy of the port |
copy_polar
¶
copy_polar(
d: float = 0,
d_orth: float = 0,
orientation: float = 180,
mirror: bool = False,
) -> DPort
Get a polar copy of the port.
This will return a port which is transformed relatively to the original port's transformation (orientation, angle and position).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
float
|
The distance to the old port |
0
|
d_orth
|
float
|
Orthogonal distance (positive is positive y for a port which is facing angle=0°) |
0
|
orientation
|
float
|
Relative angle to the original port, in degrees. |
180
|
mirror
|
bool
|
Whether to mirror the port relative to the original port. |
False
|
Port
¶
Bases: ProtoPort[int]
A port is the photonics equivalent to a pin in electronics.
In addition to the location and layer that defines a pin, a port also contains an orientation and a width. This can be fully represented with a transformation, integer and layer_index.
Attributes:
Name | Type | Description |
---|---|---|
name |
str | None
|
String to name the port. |
width |
int
|
The width of the port in dbu. |
trans |
Trans
|
Transformation in dbu. If the port can be represented in 90° intervals this is the safe way to do so. |
dcplx_trans |
Transformation in micrometer. The port will autoconvert between trans and dcplx_trans on demand. |
|
port_type |
str
|
A string defining the type of the port |
layer |
LayerEnum | int
|
Index of the layer or a LayerEnum that acts like an integer, but can contain layer number and datatype |
info |
Info
|
A dictionary with additional info. Not reflected in GDS. Copy will make a (shallow) copy of it. |
d |
Info
|
Access port info in micrometer basis such as width and center / angle. |
kcl |
KCLayout
|
Link to the layout this port resides in. |
Methods:
Name | Description |
---|---|
__init__ |
Create a port from dbu or um based units. |
copy |
Get a copy of a port. |
copy_polar |
Get a polar copy of the port. |
Attributes:
Name | Type | Description |
---|---|---|
cross_section |
CrossSection
|
|
dcplx_trans |
|
|
width |
int
|
Width of the port in um. |
x |
int
|
X coordinate of the port in dbu. |
y |
int
|
Y coordinate of the port in dbu. |
__init__
¶
__init__(
*,
name: str | None = None,
width: int,
layer: LayerEnum | int,
trans: Trans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
*,
name: str | None = None,
width: int,
layer: LayerEnum | int,
dcplx_trans: DCplxTrans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: int,
layer: LayerEnum | int,
port_type: str = "optical",
angle: int,
center: tuple[int, int],
mirror_x: bool = False,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: int,
layer_info: LayerInfo,
trans: Trans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: int,
layer_info: LayerInfo,
dcplx_trans: DCplxTrans | str,
kcl: KCLayout | None = None,
port_type: str = "optical",
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
width: int,
layer_info: LayerInfo,
port_type: str = "optical",
angle: int,
center: tuple[int, int],
mirror_x: bool = False,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
cross_section: CrossSection | SymmetricalCrossSection,
port_type: str = "optical",
angle: int,
center: tuple[int, int],
mirror_x: bool = False,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...
) -> None
__init__(
name: str | None = None,
*,
cross_section: CrossSection | SymmetricalCrossSection,
trans: Trans | str,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...,
port_type: str = "optical"
) -> None
__init__(
name: str | None = None,
*,
cross_section: CrossSection | SymmetricalCrossSection,
dcplx_trans: DCplxTrans | str,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] = ...,
port_type: str = "optical"
) -> None
__init__(*, port: ProtoPort[Any]) -> None
__init__(
name: str | None = None,
*,
width: int | None = None,
layer: int | None = None,
layer_info: LayerInfo | None = None,
port_type: str = "optical",
trans: Trans | str | None = None,
dcplx_trans: DCplxTrans | str | None = None,
angle: int | None = None,
center: tuple[int, int] | None = None,
mirror_x: bool = False,
port: ProtoPort[Any] | None = None,
kcl: KCLayout | None = None,
info: dict[str, int | float | str] | None = None,
cross_section: (
CrossSection | SymmetricalCrossSection | None
) = None,
base: BasePort | None = None
) -> None
Create a port from dbu or um based units.
copy
¶
copy(
trans: Trans | DCplxTrans = R0,
post_trans: Trans | DCplxTrans = R0,
) -> Port
Get a copy of a port.
Transformation order which results in copy.trans
:
- Trans: trans * port.trans * post_trans
- DCplxTrans: trans * port.dcplx_trans * post_trans
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trans
|
Trans | DCplxTrans
|
an optional transformation applied to the port to be copied. |
R0
|
post_trans
|
Trans | DCplxTrans
|
transformation to apply to the port after copying. |
R0
|
Returns:
Name | Type | Description |
---|---|---|
port |
Port
|
a copy of the port |
copy_polar
¶
Get a polar copy of the port.
This will return a port which is transformed relatively to the original port's transformation (orientation, angle and position).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
int
|
The distance to the old port |
0
|
d_orth
|
int
|
Orthogonal distance (positive is positive y for a port which is facing angle=0°) |
0
|
angle
|
int
|
Relative angle to the original port (0=0°,1=90°,2=180°,3=270°). |
2
|
mirror
|
bool
|
Whether to mirror the port relative to the original port. |
False
|