Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Components, parameters & pins

A design is a set of component definitions. One of them is the root, the design’s top-level component, which the file opens at. Everything you draw goes into the body of some definition. A chip drawn as a single flat drawing is one definition whose body holds all of its channels, points and regions.

Export fabricates the component that is open, which need not be the root. A subassembly opened on its own exports as a device of its own. See Export for the dialog and what its files are named.

Component definitions and placements

A component definition is a template. Placing it inside another definition’s body creates a child that refers back to it, so editing the definition updates every placement of it at once.

Two placements of one definition are independent children. Position (pos), rotation (rot) and layer belong to the placement, and the shape belongs to the definition. The viewport marks a placement’s position with an amber diamond while you hover or select it. Each placement also sets its own args: one value for each parameter of the definition. An argument you leave unset falls back to the parameter’s default.

A component cannot place itself, directly or through a chain of others. A placement that would close such a loop is refused when you make it.

Deleting a definition is refused while it is the root, and while another definition places it.

Parameters

A parameter is an input to the definition, a value that whoever places it can set. It has a name, a type, and usually a default.

There are four types:

  • Number: a real value. A length is in micrometres and an angle in radians. The inspector shows a parameter whose unit is an angle in degrees.
  • Int: a whole number, for counts such as the turns in a meander.
  • Vec2: a pair, read with .x and .y.
  • Bool: true or false.

A parameter with no default reads (required), and every placement of the definition must supply an argument for it.

Every parameter and computed value of a built-in has a unit and a one-line description, which the inspector shows when you hover its name. You give your own component’s parameters and computed values a unit and a description from the ✎ button on their rows (Inspector). A value of 0 switches a feature off where the description says so: a radius of 0 is a sharp corner, and a length of 0 removes its feature.

Computed values

A computed value is a name bound to an expression over the component’s parameters and its other computed values. Use one to write a relationship once and use it at every child that needs it. Examples are a chamber’s area from its width and length, or a meander’s total length from its pitch and turn count.

Its type follows from the expression, so you never set it.

Some built-ins also report values they work out while drawing, such as a count of the features they place. These show beside the computed values, in the same form, but have no expression. The component computes them, and no expression can read them.

Expressions on a child

A child’s pos, rot and layer, and each of a placed component’s args, hold either a plain value or an expression. The expression belongs to the component you are editing, so it reads that component’s parameters and computed values. This is how a value reaches a child. In a Chip with the parameters length and gap, a placed Chamber whose length argument is length follows the chip’s value, and a second one at pos vec2(length + gap, 0) stays beside the first.

A parameter’s default can be an expression too, over the parameters listed before it. A placement that leaves the argument unset works the default out from its own arguments.

A parameter that sets a number of pins takes a plain value only (see Pin counts). A child whose position is an expression stays where it is when you drag it.

The expression language

An expression computes a value and does nothing else. There is nothing to assign, no loops, and no functions of your own.

Numbers carry units. 250um, 0.5mm, 2cm, 800nm, 45deg, 45° and 1.2rad are all literals. The suffix converts the value to micrometres or radians, so 0.5mm and 500um are the same value. pi, tau and e are constants.

Operators are arithmetic (+, -, *, /, %), comparison (==, !=, <, <=, >, >=) and boolean (&&, ||, !). Division always produces a Number, so 3 / 2 is 1.5.

Conditionals are written if cond then a else b, and both arms must have the same type.

Functions are a fixed set: vec2, min, max, abs, clamp, sqrt, pow, floor, ceil, round, sin, cos, tan, atan2. A name counts as a function only when a ( follows it, so a parameter may be called min without shadowing anything.

An expression sees the parameters and computed values of the component it is written in, and nothing else. It cannot read a child, a sibling or the component that placed this one. Values pass downward, through arguments.

An expression that does not parse never takes effect. One that parses but does not type-check leaves the component unresolvable until you fix it. See Inspector for where the reason is shown.

Pins

A pin is a connection point a component exposes to whoever places it. Pins are the only part of a component that another component can attach to. A channel in the parent attaches to a pin, and everything behind the pin stays inside the definition and changes with it. A component can also expose one of its compartments as a socket, so whoever places it can put components inside it. See Regions & compartments.

You make a pin by exposing a terminal, which is a point or a pin of a component you placed. Exposing a point in the body publishes that point. Exposing a placed component’s pin forwards that pin outward under the same name. Every terminal is drawn as an amber circle, and an exposed one gets an amber ring around the circle. Unexpose removes the pin. See Inspector for the controls.

A pin’s name is separate from the label of the point behind it. The two start equal, and while they are equal the inspector shows one name. They differ only after you rename the pin. Renaming or deleting a pin is refused while another component refers to it.

Pin counts

Some built-in components have a number of pins set by a parameter. A ChannelBank with n set to 6 has the pins inlet_0 to inlet_5 and outlet_0 to outlet_5. Such a parameter cannot be an expression. You type a number, or tick a checkbox for a switch such as inlet_manifold. A switch applies as soon as you click it.

Lowering the count removes the pins at the end of the run. It also removes the channels, bore requests and port marks on those pins in the component you are editing. The status bar names what was deleted, and one undo restores the count and everything with it. The change is refused while one of those pins is exposed as a pin of your component. Unexpose it first.

World ports

A terminal marked world port is open to the outside, as an inlet or an outlet. The viewport draws an amber burst around its disc: a ring with short rays pointing outward. Every other terminal is an interior connection, sealed inside the assembled chip.

The mark is on the terminal, which need not be a pin, so a point does not have to be exposed to be a port. A port leaves the chip through the bottom face of the stack or the top face of its top layer, so the marked point sits on one of those faces. To make a port, select a terminal, use Make port in its detail and pick stack bottom or stack top. This adds a point on that face under or over the terminal, joins the two with a bore request, and marks the new point. Where the terminal or a point of its bore is already on that face, the button reads Mark as port and marks that point without adding anything. Remove port clears the mark and deletes the point and request that Make port added. The port takes the marked point’s name, so renaming the point renames the port. A world port also carries a drive: atmosphere, a pressure or a flow rate. The flow solve runs from the drives. See Flow.

The same controls are on a terminal inside a component you placed, reached from the Body tree. This lets you open a port on a library part without editing the part. The controls are also on a point’s or a pin’s right-click menu, as Make port, Make port at top and Remove port.

A wall tap cannot be a world port, because the port’s hole would sit across the chamber wall, half in the chamber and half in the material around it. Make port is greyed on a wall tap, including a chamber’s inlet and outlet reached from the Body tree, and hovering it says why. Draw a short channel from the tap to a free point and make that point the port instead.

The built-in components mark nothing as a world port. The design that places them decides which inlets reach the outside, so you set ports on your own top-level component.

Connections between components

Two pins never merge into one point. To join two placed components you draw a channel between their pins, however short.

A pin named by two or more channel ends is a shared junction, so you make a fan-in by pointing several channel ends at one pin.

Library components

A design can place components from another .exw file it links, its library. A library component is read-only: you set its arguments at each placement but cannot edit the definition. See Libraries.

See also