FLayout cell functionality
from numpy import linspace, pi, stack, cos, sin
triangle = fl.cell(
name='triangle',
shapes={(19, 0): [fl.polygon([(6, 0), (10, -2), (10, 1)])]}
)
@fl.pcell
def circle(
name="circle",
radius: float = 0.1,
layer: pya.LayerInfo = pya.LayerInfo(1, 0),
num_points=64,
):
t = linspace(0, 2 * pi, num_points, endpoint=False)
xy = stack([radius * cos(t), radius * sin(t)], -1)
cell = fl.cell(
name,
shapes={layer: [xy]},
)
return cell
lib = fl.library(
"lib",
pcells=[circle],
cells=[triangle],
description="my library",
)
ref = reference(triangle)
print(f"{type(ref).__name__}(cell={ref.cell.name}, trans={ref.trans})")
ref = reference(triangle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(cell={ref.cell.name}, trans={ref.trans})")
ref = reference(lib, triangle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(lib={ref.lib.name()}, cell={ref.cell.name}, trans={ref.trans})")
ref = reference(lib, triangle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(lib={ref.lib.name()}, cell={ref.cell.name}, trans={ref.trans})")
ref = reference(circle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(cell={ref.cell.name}, trans={ref.trans})")
ref = reference(lib, circle, fl.transform(mag=2.0, rot=90.0, x=3, y=3))
print(f"{type(ref).__name__}(lib={ref.lib.name()}, cell={ref.cell.name}, trans={ref.trans})")
my_cell = fl.cell(
name='my_cell',
shapes={(19, 0): [fl.polygon([(0, 0), (5, 0), (5, 5), (0, 5)])]}
)
my_cell
copy_tree(triangle, my_cell)
my_cell
layout = fl.layout()
add_cells_to_layout(layout, cells=[my_cell, triangle, circle()])
fig =flbk.draw_layout(None, layout)
bio.show(fig)
add_pcells_to_layout(layout, pcells=[circle])
layout