Language Reference

Laylight DSL

A concise, declarative language for layouts that compiles to GDSII.

The Laylight DSL describes a layout as cells made of shapes, instances and markers. It is declarative first: names can be used before they are defined and placements are resolved when needed, with for / if for the parts that are naturally procedural. Lengths and angles carry units, and placing one port on another lines up their directions.

import "tech.lyl"

cell Waveguide(length = 10um, width = 500nm) {
    marker {
        input  { at core.left_center with type = "waveguide", direction = "input" }
        output { at core.right_center with type = "waveguide", direction = "output" }
    }

    layer si { shape rect with length, width as core.left_center at self.origin }
}

cell Chain {
    place {
        place Waveguide at self.origin as a
        place Waveguide with length = 20um at a.marker.output[0] as b
    }
}

Try it in the DSL playground: the compiler runs in the browser and the result is drawn with the Laylight viewer.

Reuse cells from GDS

Import a cell from an existing GDS library and place it alongside source cells:

import "vendor/components.gds" cell "MMI$1" as ImportedMMI
cell Chip { place ImportedMMI.origin at (100um, 50um) }

The import keeps child cells and GDS layers, converts coordinates to the design's DBU, and restores Laylight marker metadata when present. Importing GDS Cells covers selecting cells, aliases, placement, supported elements and binary files in the browser.

Shapes

Geometry comes from 17 built-in shape primitives: rectangles, polygons, circles, ellipses, rings, racetracks and other closed shapes; paths, straights, bends, S-bends, Bézier curves and tapers for waveguides; and polygon text. Most of them have variants chosen by optional parameters, such as rounded corners, outlines, sectors, path end styles and taper profiles. Shape Primitives describes each one, with live previews and the equivalent calls in gdsfactory, gdstk, Luceda IPKISS and Nazca. Shapes combine with boolean operations (union, intersection, difference, xor) and grow or shrink with dilation and erosion; see Boolean and Morphological Operations.

Cross-sections

A cross-section names the layers across a waveguide or a wire: core, slab, cladding, heater, electrodes. Waveguide primitives take one where they take a width, and draw every section along the same centerline; ports placed on their ends take the cross-section, and connected ports must agree. See Cross-Sections.

define xsection rib(width = 700nm, slab = 2um) {
    si   width
    slab width + 2 * slab
    with min_radius = 25um
}

cell Bend {
    shape euler with min_radius = 25um, width = rib, angle = 90deg as b.start at self.origin
}

Tools

The laylight command-line tool (Installation Guide) checks, compiles and formats files:

laylight check mmi.lyl
laylight build mmi.lyl -o mmi.gds
laylight decompile mmi.gds -o mmi.lyl --layers tech.lyl
laylight fmt *.lyl
  • ir prints the evaluated layout (the Laylight IR) as text.
  • blackbox publishes cells as blackboxes, and unbox puts the real cells back.
  • lsp runs the language server for editors (Editor support): diagnostics, completion, hover with evaluated values, rename, formatting. The VS Code extension in packages/laylight-vscode uses it and adds a live layout preview.

The language is specified in docs/laylight-dsl/spec.md in the repository.

On this page