laylight tour
0/25
4/4

Basics · 4 of 4

Constants

Numbers repeated throughout a program are hard to change. define gives a value a name:

define wg_width = 500nm
define wg_len: size = 20um    # the type is optional

A top-level constant can be used anywhere in the file, even above its definition: laylight evaluates constants in the order of their dependencies (a constant that depends on itself is an error). Constants cannot be changed.

Two more things you will meet in programs:

  • define dbu = 1nm sets the database unit, the grid all coordinates are rounded to in the output. It is optional and defaults to 1 nm.
  • Line breaks matter in one place: an operator cannot start a line. A line ending in a + continues on the next line, but a line starting with + b does not continue the one before.

Exercise

Introduce constants for the waveguide width and the spacing, named wg_width and pitch, and use them in Bus. Then change the design through them: make all three waveguides 800 nm wide and 4 µm apart.

loading compiler…

Edit the code, watch the layout, then press Submit to check your solution against the exercise.

Compiling…