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 {
param {
length size = 10um
width size = 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
place 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.
Shapes
Geometry comes from 16 built-in shape primitives: rectangles, polygons, circles, ellipses, rings, racetracks and other closed shapes; paths, 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.
Tools
The Rust workspace ships the compiler and its tools:
cargo run -p laylight-cli -- check samples/lyl/mmi.lyl
cargo run -p laylight-cli -- build samples/lyl/mmi.lyl -o mmi.gds
cargo run -p laylight-cli -- decompile mmi.gds -o mmi.lyl --layers samples/lyl/tech.lyl
cargo run -p laylight-cli -- fmt samples/lyl/*.lyl
irprints the evaluated layout (the Laylight IR) as text.laylight-lspis the language server: diagnostics, completion, hover with evaluated values, rename, formatting. The VS Code extension inpackages/laylight-vscodeuses it and adds a live layout preview.
The language is specified in docs/laylight-dsl/spec.md in the repository.