API Reference
Complete reference for every class and function in the Rosette Python API.
Unstable API
Rosette is pre-1.0. Function signatures, class interfaces, and behavior may change between releases without notice.
from rosette import *
# Create a simple cell
cell = Cell("my_design")
cell.add_polygon(Polygon.rect(Point.origin(), 10, 5), Layer(1, 0))
write_gds("output.gds", cell)
# Route between ports
route = Route(Layer(1, 0), width=0.5, bend_radius=5.0)
route.start_at_port(port_a)
route.to(50, 0)
route.end_at_port(port_b)
cell = route.to_cell("my_route")In user projects (after rosette init), components are local:
from components import waveguide, bend, mmi_1x2For library development, import from rosette.components:
from rosette.components import waveguide, bend, mmi_1x2attributeDEFAULT_LAYERSlist[dict]= [{'name': 'silicon', ...}, {'name': 'metal', ...}, {'name': 'text', ...}]Default layer definitions used as fallback when rosette.toml has no [layers]
section. Contains three layers: silicon (1/0), metal (10/0), text (100/0).
I/O
funcread_gds(path) -> LibraryRead a GDS file and return a Library.
Example
lib = read_gds("input.gds")
for cell in lib.cells():
print(cell.name)parampathstr | PathPath to the GDS file.
Returns
LibraryA Library containing all cells from the GDS file.
funcwrite_gds(path, design, cells=None, *, quiet=False, verbose=False) -> NoneWrite a Cell or Library to a GDS file.
When writing a Cell built using Instance references (via cell.at()),
child cells are automatically collected. A build summary is printed
to stderr by default.
Example
# Auto-collection (recommended):
top = Cell("top")
top.add_ref(gc_cell.at(0, 0))
write_gds("output.gds", top)
# Suppress output for batch processing:
write_gds("output.gds", top, quiet=True)parampathstr | PathOutput file path.
paramdesignCell | LibraryCell or Library to write.
paramcellslist[Cell] | None= NoneOptional list of child cells. If None and design is a Cell,
child cells are auto-collected from Instance references.
paramquietbool= FalseIf True, suppress the build summary.
paramverbosebool= FalseIf True, print detailed build info including port positions.
Returns
NoneConfiguration
funcload_layer_map(config_path=None) -> LayerMapLoad layer definitions from rosette.toml.
Reads the [layers] section which maps semantic names to GDS layer
numbers with optional display properties (color, fill, opacity).
Example
layers = load_layer_map()
layers.silicon.layer # Layer(1, 0)
layers.silicon.color # "#ff69b4"paramconfig_pathstr | Path | None= NoneOptional explicit path to rosette.toml. If None, searches
from current directory upward.
Returns
LayerMapLayerMap with named layer access.
DRC
funcload_drc_rules(config_path=None) -> DrcRulesLoad DRC rules from rosette.toml.
Searches for rosette.toml in the current directory and parent directories.
Rules are defined per-layer in the [drc.layers] section (supporting
min_width, min_spacing, min_area, angles, min_edge_length,
max_width, and no_self_intersection), and inter-layer rules in the
[[drc.rules]] array.
Example
rules = load_drc_rules()
result = run_drc(cell, rules)paramconfig_pathstr | Path | None= NoneOptional explicit path to rosette.toml. If None, searches
from current directory upward.
Returns
DrcRulesDrcRules built from the configuration.
funcrun_drc(cell, rules, library=None) -> DrcResultRun DRC on a cell.
Example
rules = load_drc_rules()
result = run_drc(cell, rules)
if result.passed:
print("DRC passed!")
else:
for v in result.violations:
print(f" {v.message}")paramcellCellThe cell to check.
paramrulesDrcRulesDRC rules to apply.
paramlibraryLibrary | None= NoneLibrary containing referenced cells (required if cell has refs).
Returns
DrcResultDrcResult with violations and statistics.
Design Checks
funcload_checks_config(config_path=None) -> ChecksConfigLoad design checks config from rosette.toml.
Reads the [checks] section. If absent, returns a ChecksConfig
with sensible defaults.
Example
config = load_checks_config()
result = run_checks(cell, config)paramconfig_pathstr | Path | None= NoneOptional explicit path to rosette.toml. If None, searches
from current directory upward.
Returns
ChecksConfigChecksConfig built from the configuration.
funcrun_checks(cell, config=None, library=None) -> ChecksResultRun design checks on a cell.
Runs all design checks: connectivity (unconnected ports, width/angle mismatch) and bend radius (below minimum, auto-reduced). Ports on the top-level cell are treated as external I/O and are not flagged as unconnected.
When called with a Cell built using Instance references, child cells are automatically collected into a Library for hierarchy resolution.
Example
config = ChecksConfig(min_bend_radius=5.0)
result = run_checks(cell, config)
if not result.passed:
for v in result.violations:
print(f" {v.message}")paramcellCellThe cell to check.
paramconfigChecksConfig | None= NoneChecks configuration. Defaults to ChecksConfig().
paramlibraryLibrary | None= NoneLibrary containing referenced cells. If None and cell has Instance
tracking, a Library is auto-built.
Returns
ChecksResultChecksResult with violations and statistics.
DFM
funcload_dfm_config(config_path=None) -> tuple[DfmConfig, GaussianModel, list[Layer]]Load DFM configuration from rosette.toml.
Reads the [dfm] section which configures the virtual nanofabrication
prediction tool.
Example
config, model, layers = load_dfm_config()
result = run_dfm(cell, layers=layers, model=model, config=config)paramconfig_pathstr | Path | None= NoneOptional explicit path to rosette.toml. If None, searches
from current directory upward.
Returns
tuple[DfmConfig, GaussianModel, list[Layer]]Tuple of (config, model, layers) where layers is the list of layers to predict (empty list means all layers).
funcrun_dfm(cell, layers, model=None, config=None, library=None) -> DfmResultRun DFM prediction on a cell.
Rasterizes each specified layer, applies the fabrication prediction model, and extracts contour polygons representing the predicted fabricated geometry.
Example
result = run_dfm(cell, layers=[Layer(1, 0)])
for lp in result.layers:
print(f" Layer {lp.layer}: {lp.input_polygon_count} -> {lp.predicted_polygon_count}")paramcellCellThe cell to predict.
paramlayerslist[Layer]Layers to process.
parammodelGaussianModel | None= NoneThe prediction model. Defaults to GaussianModel(sigma=0.08).
paramconfigDfmConfig | None= NoneDFM configuration. Defaults to DfmConfig().
paramlibraryLibrary | None= NoneLibrary containing referenced cells (required if cell has refs).
Returns
DfmResultDfmResult with per-layer predictions and statistics.
funcadd_dfm_predictions(cell, result, datatype_offset=100) -> NoneAdd DFM predicted polygons to a cell on offset layers.
For each layer in the DFM result, adds the predicted polygons to the cell
on a new layer with the same number but datatype offset by datatype_offset.
This makes it easy to visualize designed vs predicted geometry side-by-side.
Example
result = run_dfm(cell, layers=[Layer(1, 0)])
add_dfm_predictions(cell, result)
write_gds("output.gds", cell)
# Layer 1/0 = designed, Layer 1/100 = predictedparamcellCellThe cell to add predicted polygons to (modified in-place).
paramresultDfmResultDFM prediction result from run_dfm.
paramdatatype_offsetint= 100Offset added to the original datatype.
Returns
NoneGeometry Utilities
funcarc_points(center, radius, start_angle, end_angle, num_points=64) -> list[Point]Generate points along a circular arc.
paramcenterPointCenter point of the arc.
paramradiusfloatRadius of the arc.
paramstart_anglefloatStarting angle in degrees (0 = +X direction).
paramend_anglefloatEnding angle in degrees.
paramnum_pointsint= 64Number of points to generate.
Returns
list[Point]List of points along the arc.
funcoffset_polygon(centerline, width) -> PolygonCreate a polygon from a centerline and uniform width.
The polygon is created by offsetting the centerline perpendicular to the path direction at each point, forming a "ribbon" shape.
paramcenterlinelist[Point]List of points defining the centerline path (minimum 2 points).
paramwidthfloatWidth of the polygon.
Returns
PolygonA closed polygon.
funcoffset_polygon_varying(centerline, widths) -> PolygonCreate a polygon from a centerline with varying width.
Similar to offset_polygon, but allows specifying a different width at each
centerline point for tapered or variable-width shapes.
paramcenterlinelist[Point]List of points defining the centerline path.
paramwidthslist[float]Width at each centerline point (must have same length as centerline).
Returns
PolygonA closed polygon.
funcpath_length(points) -> floatCalculate the total length of a polyline path.
parampointslist[Point]List of points defining the path.
Returns
floatSum of distances between consecutive points.
funcfresnel_c(t) -> floatFresnel cosine integral C(t).
Used for generating Euler (clothoid) spiral bends. C(t) = integral from 0 to t of cos(pi/2 * u^2) du.
paramtfloatUpper limit of integration.
Returns
floatfuncfresnel_s(t) -> floatFresnel sine integral S(t).
Used for generating Euler (clothoid) spiral bends. S(t) = integral from 0 to t of sin(pi/2 * u^2) du.
paramtfloatUpper limit of integration.
Returns
float