FLayout core factories yielding native klayout datastructures.
layer(19, 0)
my_point = point(3, 5)
my_point
my_vector = vector(3, 5)
my_vector
my_box = box((0, 0), (5, 10))
my_box
A simple polygon is a polygon without holes. You can create this by using fl.polygon
and only specifying a hull.
my_simple_poly = polygon(
hull=[(0, -2), (5, -2), (1, 2)],
)
my_simple_poly
General Polygons (with holes) can be specified by also specifying a holes
keyword in fl.polygon
:
my_poly = polygon(
hull=[(0, 0), (6, 0), (6, 4), (0, 3)],
holes=[[(3, 1), (4, 1), (4, 2), (3, 2)]]
)
my_poly
my_path = path([(3.0, 4.0), (6.0, -1.0)], 1.2)
my_path
my_cell = cell(
name="cell0",
shapes={
(10, 0): [my_simple_poly, my_poly],
(19, 0): [my_path],
},
)
my_cell
Child cells can also be added to a cell:
my_other_poly = polygon([(10, 0), (11, 0), (11, 0), (10, 5)])
my_other_cell = cell(
name="cell1",
shapes={(0, 0): [my_other_poly]},
child_cells=[my_cell],
)
my_other_cell
One can apply transformations to the child cell as well:
my_third_poly = polygon([(0, 0), (6, 0), (6, 4), (0, 5)])
my_third_cell = cell(
name="cell2",
shapes={(0, 0): [my_third_poly]},
child_cells=[
(my_other_cell, transform(mirrx=True, x=12.0, y=3.0)),
],
)
my_third_cell
The combination of a child cell and a transformation is called an instance
of a cell (sometimes also called a reference):
inst = next(my_third_cell.each_inst()) # get the only instance
inst
Finally, a layout is a collection of multiple cells. If a cell is not a sub cell of another cell, it will be considered a top-level cell. Moreover, one cannot have cyclic references within a layout.
Let's create a layout with two top-level cells:
my_independent_cell = cell(
name='independent_cell',
shapes={(19, 0): [polygon([(6, 0), (10, -2), (10, 0)])]}
)
# even though we specify four cells for our layout, only two of them are independent
# i.e. some of the cells we are added are actually child cells of other cells
# top level cells in this case are 'my_independent_cell' and 'my_third_cell'
my_layout = layout(cells=[my_independent_cell, my_cell, my_other_cell, my_third_cell])
# my_layout = layout(cells=[my_independent_cell, my_third_cell]) # equivalent
my_layout