Overview
Laylight is a language and compiler for semiconductor layout, built first for photonic integrated circuits.
Laylight describes layouts as code in a language made for them. You write devices as cells of shapes on process layers, place them by their anchors and ports, and compile the result into a mask layout, a netlist or a 3D model. The compiler, its geometry engine and its tools are written in Rust, run on the command line, in your editor and in the browser, and are designed around four ideas.
Dedicated syntax
A small, declarative language whose grammar knows cells, layers, shapes, ports and units, free of the constraints of a general-purpose language like Python. It describes devices in 26% fewer tokens and 11% fewer lines of code than gdsfactory, gdstk and KLayout.
Efficient geometry
A compiled evaluator and a boolean and morphology engine written for layout data, benchmarked against gdsfactory, gdstk and KLayout on large layouts.
DRC as a first-class citizen
Design rules checked where the geometry still has its meaning, avoiding the false errors and slow runs of DRC on polygonized curves.
Write once, compile anywhere
One source, one intermediate representation, many back ends: GDSII today, OASIS in development, 3D models and simulation inputs through back ends such as PSVFab.
Results at a glance
Two benchmarks measure the first two ideas against gdsfactory, gdstk and KLayout: how much code a device takes, and how fast layouts are built, combined and read.
Less code
Seventeen silicon photonic devices and circuits from published papers, from bends and splitters to an arrayed waveguide grating, a lithium niobate modulator, a III-V laser and an optical phased array, were each written in Laylight and in the three Python tools, so that all four build the same layout. Laylight needs 26% fewer tokens and 11% fewer lines of code on average: 21%, 24% and 34% fewer tokens than gdsfactory, gdstk and KLayout, and 13%, 6% and 15% fewer lines. The devices are in the examples.
26%fewer tokens
21% vs gdsfactory · 24% vs gdstk · 34% vs KLayout
11%fewer lines of code
13% vs gdsfactory · 6% vs gdstk · 15% vs KLayout
Faster
Building and writing a test chip of 40,000 distinct ring resonators takes Laylight 0.44 s: 5 times less than gdstk, 15 times less than KLayout and 325 times less than gdsfactory, and with a boolean operation per device it is still 3.3 times faster than gdstk. On the largest flat layouts its boolean operations run about 10 to 20 times faster than KLayout's and gdsfactory's and 7.5 to 420 times faster than gdstk's (whose XOR of 1.44 million rectangles was stopped after 10 minutes), and it reads and flattens a 247 MB GDS file in 0.2 s, 2.2 times faster than gdstk.
Time, lower is better, and how many times Laylight's time the others take · logarithmic scale · Apple M3 Max
- Laylight
- gdstk, KLayout, gdsfactory
Generating 40,000 distinct ring resonators
- Laylight437 ms
- gdstk2.20 s · 5.0×
- KLayout6.50 s · 15×
- gdsfactory142.1 s · 325×
The same, with a boolean operation per device
- Laylight3.34 s
- gdstk11.1 s · 3.3×
- KLayout43.1 s · 13×
- gdsfactory232.3 s · 70×
AND of two layers of 1,440,000 rectangles
- Laylight590 ms
- gdstk248.3 s · 421×
- KLayout5.98 s · 10×
- gdsfactory6.14 s · 10×
AND of two layers of 10,000 rings
- Laylight308 ms
- gdstk2.31 s · 7.5×
- KLayout3.10 s · 10×
- gdsfactory3.15 s · 10×
Reading and flattening a 247 MB GDS file
- Laylight195 ms
- gdstk429 ms · 2.2×
- KLayout1.40 s · 7.2×
- gdsfactory3.08 s · 16×
All sizes and operations are on the performance page.
A language made for layout
Layout libraries for Python inherit Python's syntax and execution model: devices are classes or decorated functions, geometry is drawn by calling methods in the right order, lengths are bare floats and positions are computed by hand. Laylight makes these concepts part of the language. Lengths carry units and are checked, shapes are placed by putting an anchor on an anchor, a cell lists all of its process layers, and boolean and morphological operations are expressions. for and if cover the regular and conditional parts. The result is short (26% fewer tokens than the Python tools), reads like a description of the device and is checked before anything is drawn. Read more.
Geometry that scales
Cells are evaluated by a compiled evaluator, and every combination of parameters becomes one cell, generated once. Booleans, growing and shrinking run on the integer database grid with snap rounding, so results are exact to the grid and robust against degenerate input, and the engine indexes large inputs spatially and spreads them over all cores to stay fast as layouts grow. The layout database behind the compiler and the viewer reads and flattens large GDS files in a single pass. The results above summarize the benchmarks; Efficient Geometry has all of them.
Design rules where the geometry has meaning
GDS has no curves: every bend, ring and spline becomes a polygon of short edges, and traditional DRC has to work on those edges, which produces false errors, hides real ones and slows verification down. Laylight knows that a bend is an arc of a given radius and width, and how far its polygon may deviate from it, so rules on curves can be checked exactly, inside the compiler, with errors that point to the line of source that caused them. Read more.
One source, many targets
Evaluation produces the Laylight IR, a complete and self-contained description of the layout: layers, cells with their parameters, shapes on the integer grid, instances and arrays, ports and other markers, and connections. Back ends compile the IR to GDSII (today) and OASIS (in development), to a netlist for LVS, and, through tools such as the PSVFab process emulator, to 3D models of the fabricated structure or meshes for simulation. Read more.
Plenty of examples
Laylight comes with fifteen complete silicon photonic devices, passive and active, each reproducing a structure from a published paper: waveguide bends and converters, splitters, interferometers and grating couplers, an arrayed waveguide grating, microring resonators and modulators, heaters, a spiral delay line, a lithium niobate modulator, a germanium modulator and a III-V-on-silicon laser. Two more examples are circuits routed between such devices: a fiber-array test structure and an optical phased array. Every example has a page with the paper it follows, its parameters and the layout compiled in your browser, and one click opens it in the DSL playground to change it. Each device is also written in gdsfactory, gdstk and KLayout, so the pages double as a side-by-side comparison, and the examples build on each other as a small library would: the Mach-Zehnder interferometers import the MMI splitter, the heaters the spiral delay line.
| Example | Type | After | What it shows |
|---|---|---|---|
| Waveguides and bends | Passive | Bogaerts & Selvaraja, IEEE Photonics J. 2011 | Rib and strip waveguides, circular, Euler and S-bends, and a rib-to-strip converter for compact bends. |
| 1×2 MMI splitter | Passive | Sheng et al., IEEE Photonics J. 2012 | A multimode interference splitter with tapered access waveguides, the building block of the interferometers. |
| Mach-Zehnder interferometers | Passive | Horst et al., Opt. Express 2013 | A balanced and an unbalanced MZI built from two MMIs, with delay arms widened to 1 µm by parabolic tapers. |
| Grating couplers | Passive | Taillaert et al., JJAP 2006; Bozzola et al., Opt. Express 2015; Van Laere et al., PTL 2007 | Uniform, apodized and focusing grating couplers that couple a single-mode fiber to silicon waveguides, from three published designs. |
| Broadband directional coupler | Passive | Lu et al., Opt. Express 2015 | A 50/50 directional coupler made broadband by an asymmetric phase-control section between two symmetric coupling sections. |
| Waveguide crossing | Passive | Ma et al., Opt. Express 2013 | A low-loss single-etch crossing of four identical tapers, each given by its widths at 13 points along 4.5 µm. |
| Arrayed waveguide grating | Passive | Pathak et al., Opt. Lett. 2013 | A 12-channel, 400 GHz demultiplexer: two star couplers in Rowland mounting joined by 40 arms whose lengths step by 14.96 µm. |
| Microring and Euler racetrack resonators | Passive | Xu et al., Opt. Express 2008; Zhang et al., Photonics Res. 2020 | A 1.5 µm-radius all-pass microring and an ultrahigh-Q racetrack with Euler bends and a concentric pulley coupler at one bend. |
| Thermo-optic phase shifters | Passive | Jacques et al., Opt. Express 2019; Densmore et al., Opt. Express 2009 | A straight TiN heater over a strip waveguide and a compact folded double-spiral waveguide under a meander heater, both with bond pads. |
| Spiral delay line | Passive | Hong et al., Photonics Res. 2022 | Two interleaved Archimedean spirals of a 2 µm multimode waveguide, joined by an Euler S-bend, with bent tapers to single-mode input and output. |
| p-i-n variable optical attenuator | Active | Park et al., Opt. Express 2010 | A 0.5 mm silicon rib waveguide between p++ and n++ strips 4 µm apart, attenuating by free-carrier injection, with two probe pads. |
| Carrier-injection microring modulator | Active | Xu et al., Opt. Express 2007 | A 5 µm silicon microring with a p-i-n diode, p++ inside and n++ outside the ring, wired to ground-signal-ground pads. |
| Thin-film lithium niobate modulator | Active | Kharel et al., Optica 2021 | A Mach-Zehnder modulator in thin-film lithium niobate whose travelling-wave electrodes carry rows of T-shaped segments that cut microwave loss. |
| Germanium electro-absorption modulator | Active | Srinivasan et al., JLT 2016 | A germanium strip butt-coupled to tapered silicon waveguides, with a lateral p-i-n junction contacted through doped silicon and wired to two probe pads. |
| III-V-on-silicon DFB laser | Active | Keyvaninia et al., Opt. Lett. 2013 | A III-V gain mesa bonded over a silicon waveguide with a quarter-wave-shifted grating, tapering at both ends to pass the light into silicon. |
| Fiber-array test structure | Circuit | Van Laere et al., PTL 2007; Horst et al., Opt. Express 2013 | The unbalanced MZI wired to focusing grating couplers at the 127 µm pitch of a fiber array, with a loopback between two couplers to calibrate their loss. |
| Optical phased array | Circuit | Doylend et al., Opt. Express 2011 | Sixteen channels split by a tree of MMIs, phase-tuned by heaters 100 µm apart and brought together onto grating emitters 3.5 µm apart. |
The Language Reference adds a live preview of every shape primitive and operation, and the playground holds smaller samples of the language itself.
Learn it with the Tour
The Tour teaches Laylight from scratch, in 37 short interactive lessons in eight chapters that cover the whole language. Every lesson explains one idea and sets an exercise: you edit the code next to the layout it compiles to and the layout it should become, the compiler runs in your browser and checks your result, hints help when you are stuck, and your progress and code are kept in the browser. Nothing has to be installed.
| Chapter | What it teaches | Lessons |
|---|---|---|
| Basics | Cells, layers, shapes, units and constants: the parts of every Laylight program. | Hello, layout · Layers · Numbers and units · Constants |
| Shapes and placement | Anchors, relative placement and the geometric primitives: rect, polygon, circle, ring, path, arc and taper. | Anchors · Placing shapes on shapes · Polygons · Circles and rings · Paths · Arcs and tapers |
| Cells and instances | Reuse geometry: place cells, give them parameters and attributes, rotate and mirror them. | Instances · Parameters · Attributes · Rotate, mirror, offset |
| Markers and ports | Name points of a cell, connect components port to port and check the connections. | Markers · Port to port · Several locations · Connection checks |
| Loops and values | Generate layouts with for and if, compute with built-in functions and build up lists. | For loops · Conditions · Built-in functions · Variables and lists |
| Shape operations | Combine shapes with + - & | ^, grow and shrink them by a length, keep helper shapes out of the layout, and chain operations with parentheses. | Combining shapes · Cutting holes · Overlaps · Growing and shrinking · Helper shapes · Chaining operations |
| Cross-sections and routing | Describe the layers across a waveguide once, change between cross-sections, carry them through ports, and connect ports with paths and S-bends. | Cross-sections · Offsets and parameters · Changing cross-section · Ports and cross-sections · Routing with paths · Fan-out |
| Libraries and projects | Import shared components and build complete devices. | Imports · Project: ring resonator · Project: splitter tree |
The last project brings the chapters together: a binary tree of 1×2 MMI splitters joined by S-bends, built level by level from a list of the ports still to be fed. This is the layout it builds:
MMITree, the last project of the Tour (Project: splitter tree), compiled in your browserOpen the lessonStart the TourGet started
- Take the Tour: an interactive course that teaches the language in short exercises, with the compiler running in your browser.
- Try code in the DSL playground, or in VS Code with the extension in
packages/laylight-vscode: diagnostics, completion and a live layout preview. - Look things up in the Language Reference, with every shape primitive and operation.
The command-line tool covers the whole flow; download it for Linux, macOS or Windows from the Installation Guide:
laylight check ring.lyl # syntax, types, units and evaluation
laylight build ring.lyl -o ring.gds # compile to GDSII
laylight ir ring.lyl # print the Laylight IR
laylight netlist ring.lyl # connectivity as JSON; `lvs` compares it
laylight fmt ring.lyl # format in place
laylight decompile chip.gds -o chip.lyl
laylight blackbox ring.lyl -o ring.lyir # publish outline and ports; `unbox` restores the cellThe first version of Laylight was a Python library based on KLayout. It is now a second front end of the compiler: its devices build Laylight IR, which the same back end compiles to GDSII. It is documented under Python Library.