Skip to main content

std::layout

std::layout is the standard library module that builds layout: geometry constructors, instance placement, bounding boxes, dimensions, and helpers for working with rectangles.

Importing​

Nothing in std::layout is in scope by default. Import the names a module calls with a grouped use at the top of the file:

use std::layout::{crect, inst, rect};

cell pad(w: Float, h: Float) {
pub let metal = rect("met1", x0=0., y0=0., w=w, h=h);
}

cell top() {
let p = inst(pad(100., 80.), x=0., y=0.);
let keepout = crect(x0=p.x - 20., y0=p.y - 20., w=140., h=120.);
}

A use applies only to the file that declares it, so each module imports what it calls. You can also call an item by its full path, as in std::layout::rect("met1"), or import it under another name with use std::layout::rect as r;. A module may declare its own item named rect or inst; to use the std::layout one as well, import it under an alias or call it by full path. See imports for the full use syntax.

rect, crect, polygon, path, text, inst, bbox, and dimension are implemented by the compiler. They can only be called, so a reference that isn't a call, such as let f = rect;, is an error. The rectangle helpers are ordinary Argon functions.

The examples below assume the names they call are imported. Signatures use the built-in notation.

Geometry​

These constructors add geometry to the current cell. Coordinate arguments are Float expressions.

rect​

rect(layer: String, x0?, y0?, x1?, y1?, w?, h?, x0i?, y0i?, x1i?, y1i?) -> Rect

Draws an axis-aligned rectangle on a layer.

ArgumentTypeRequirementDescription
layerStringRequired, positionalA drawing layer from the technology file.
x0FloatOptional keywordConstrains the left edge.
y0FloatOptional keywordConstrains the bottom edge.
x1FloatOptional keywordConstrains the right edge.
y1FloatOptional keywordConstrains the top edge.
wFloatOptional keywordConstrains the width, x1 - x0.
hFloatOptional keywordConstrains the height, y1 - y0.
x0iFloatOptional fallbackInitial left edge, used when x0 is otherwise free.
y0iFloatOptional fallbackInitial bottom edge, used when y0 is otherwise free.
x1iFloatOptional fallbackInitial right edge, used when x1 is otherwise free.
y1iFloatOptional fallbackInitial top edge, used when y1 is otherwise free.

Returns Rect. The rectangle.

let gate = rect("poly", x0=0., y0=0., w=80., h=400.);

Give enough values or constraints to pin the rectangle down. If you drag an under-constrained rectangle in the GUI, it adds the missing initial values.

crect​

crect(x0?, y0?, x1?, y1?, w?, h?, layer?, x0i?, y0i?, x1i?, y1i?) -> Rect

Creates a construction rectangle: usable in constraints and as bounds, but not exported.

ArgumentTypeRequirementDescription
x0FloatOptional keywordConstrains the left edge.
y0FloatOptional keywordConstrains the bottom edge.
x1FloatOptional keywordConstrains the right edge.
y1FloatOptional keywordConstrains the top edge.
wFloatOptional keywordConstrains the width.
hFloatOptional keywordConstrains the height.
layerStringOptional keywordOptional layer to associate with the rectangle.
x0iFloatOptional fallbackInitial value for x0.
y0iFloatOptional fallbackInitial value for y0.
x1iFloatOptional fallbackInitial value for x1.
y1iFloatOptional fallbackInitial value for y1.

Returns Rect. The construction rectangle. It takes part in constraints but is left out of layout export.

let bounds = crect(x0=0., y0=0., w=1000., h=800.);

polygon​

polygon(layer: String, points: Int, x0?, y0?, …, x0i?, y0i?, …) -> Polygon

Creates a polygon with a fixed number of vertices, each constrained on its own.

ArgumentTypeRequirementDescription
layerStringRequired, positionalA drawing layer.
pointsIntRequired, positionalNumber of vertices. Coordinate indices run from 0 to points - 1.
xNFloatOptional keywordx coordinate of vertex N.
yNFloatOptional keywordy coordinate of vertex N.
xNiFloatOptional fallbackInitial x coordinate of vertex N.
yNiFloatOptional fallbackInitial y coordinate of vertex N.

Returns Polygon. The polygon.

let triangle = polygon("met1", 3,
x0=0., y0=0.,
x1=100., y1=0.,
x2=50., y2=80.,
);

path​

path(layer: String, points: Int, width?, begin_extension?, end_extension?, x0?, y0?, …) -> Path

Creates a constant-width path along a centerline.

ArgumentTypeRequirementDescription
layerStringRequired, positionalA drawing layer.
pointsIntRequired, positionalNumber of centerline points.
widthFloatOptional keywordFull width of the path. Must not solve to a negative value.
begin_extensionFloatOptional keywordHow far the path extends past its first point.
end_extensionFloatOptional keywordHow far the path extends past its last point.
xNFloatOptional keywordx coordinate of centerline point N.
yNFloatOptional keywordy coordinate of centerline point N.
widthiFloatOptional fallbackInitial width.
begin_extensioniFloatOptional fallbackInitial begin extension.
end_extensioniFloatOptional fallbackInitial end extension.
xNi / yNiFloatOptional fallbackInitial coordinates of centerline point N.

Returns Path. The path.

let route = path("met2", 2, width=20., x0=0., y0=0., x1=300., y1=0.);

text​

text(value: String, layer: String, x: Float, y: Float) -> ()

Places a text label on a layer.

ArgumentTypeRequirementDescription
valueStringRequired, positionalThe text.
layerStringRequired, positionalLayer for the label.
xFloatRequired, positionalx coordinate of the label origin.
yFloatRequired, positionaly coordinate of the label origin.

Returns (). Nothing; the label is added to the current cell.

text("VDD", "text.label", 40., 80.);

Hierarchy​

inst​

inst(cell: Cell, reflect?, angle?, x?, y?, xi?, yi?, construction?) -> Inst

Places a cell in the current scope.

ArgumentTypeRequirementDescription
cellCellRequired, positionalThe cell value to place, such as inverter(1200., 2000., 4).
reflectBoolOptional; falseMirror the cell before rotating and translating it.
angleIntOptional; 0Rotation in degrees: 0, 90, 180, or 270.
xFloatOptional keywordx position.
yFloatOptional keywordy position.
xiFloatOptional fallbackInitial x position.
yiFloatOptional fallbackInitial y position.
constructionBoolOptional; falseWhen true, leave the instance out of layout export and of the parent bounding box.

Returns Inst. The instance, with its position and the public fields of its cell.

let placed = inst(inverter(1200., 2000., 4), x=100., y=50., angle=90);

bbox​

bbox(value: Cell | Inst) -> Rect

Returns the bounding box of a cell or a placed instance, as a construction rectangle.

ArgumentTypeRequirementDescription
valueCell | InstRequired, positionalA cell value, measured in its own coordinates, or an instance, measured after placement.

Returns Rect. A construction rectangle around the layout geometry.

let child = inverter(1200., 2000., 4);
let local = bbox(child);
let placed = inst(child, x=100., y=50.);
let transformed = bbox(placed);

Construction-only geometry does not count toward the bounding box.

Dimensions​

dimension​

dimension(p: Float, n: Float, value: Float, coord: Float, pstop: Float, nstop: Float, horizontal: Bool) -> ()

Adds an equality constraint together with the dimension label the GUI draws for it.

ArgumentTypeRequirementDescription
pFloatRequired, positionalCoordinate on the positive side of the measurement.
nFloatRequired, positionalCoordinate on the negative side.
valueFloatRequired, positionalThe constraint: p - n must equal this.
coordFloatRequired, positionalWhere the dimension line sits, on the perpendicular axis.
pstopFloatRequired, positionalWhere the extension line on the positive side ends.
nstopFloatRequired, positionalWhere the extension line on the negative side ends.
horizontalBoolRequired, positionaltrue for a horizontal measurement, false for vertical.

Returns (). Nothing; the constraint and its label are added to the current cell.

Prefer the GUI for dimensions

The Dimension tool fills in the orientation and label-placement arguments from the edges you click, and writes the call as std::layout::dimension(...). In hand-written source, use eq unless you want a visible dimension.

Rectangle helpers​

These functions are written in Argon on top of rect and crect.

use std::layout::{array, center_rects, crect, rect};

cell via_row(n: Int) {
let met1 = rect("met1", x0=0., y0=0., w=400., h=60.);
let cut = crect(layer="via1", x0=0., y0=0., w=20., h=20.);
let vias = array(cut, n, 40., 0.);
center_rects(vias, met1);
}

intersection​

intersection(rect1: Rect, rect2: Rect) -> Rect

The overlap of two rectangles, as a construction rectangle.

ArgumentTypeRequirementDescription
rect1RectRequiredFirst rectangle.
rect2RectRequiredSecond rectangle.

Returns Rect. A construction rectangle whose lower edges are the larger of the two inputs' and whose upper edges are the smaller.

If the rectangles don't overlap, the result is inverted rather than empty: this computes edge expressions and doesn't test for overlap.

union​

union(rect1: Rect, rect2: Rect) -> Rect

The smallest construction rectangle containing both inputs.

ArgumentTypeRequirementDescription
rect1RectRequiredFirst rectangle.
rect2RectRequiredSecond rectangle.

Returns Rect. A construction rectangle from the smaller lower edges and the larger upper edges.

array​

array(r: Rect, n: Int, xpitch: Float, ypitch: Float) -> Rect

Draws a row of rectangles and returns its bounds.

ArgumentTypeRequirementDescription
rRectRequiredTemplate. Each copy has its layer, width, and height.
nIntRequiredNumber of copies. Below one, the result is a zero-size rectangle.
xpitchFloatRequiredx pitch between copies.
ypitchFloatRequiredy pitch between copies.

Returns Rect. A construction rectangle around the row.

array2​

array2(r: Rect, nx: Int, ny: Int, xpitch: Float, ypitch: Float) -> Rect

Draws a grid of rectangles and returns its bounds.

ArgumentTypeRequirementDescription
rRectRequiredTemplate, copied at every position.
nxIntRequiredNumber of columns.
nyIntRequiredNumber of rows.
xpitchFloatRequiredx pitch.
ypitchFloatRequiredy pitch.

Returns Rect. A construction rectangle around the grid.

max_array​

max_array(r: Rect, w: Float, h: Float, xpitch: Float, ypitch: Float) -> Rect

Draws the largest grid of rectangles that fits in a given width and height.

ArgumentTypeRequirementDescription
rRectRequiredTemplate.
wFloatRequiredAvailable width.
hFloatRequiredAvailable height.
xpitchFloatRequiredx pitch.
ypitchFloatRequiredy pitch.

Returns Rect. The bounds from array2, or a zero-size rectangle if nothing fits.

eq_rect​

eq_rect(r1: Rect, r2: Rect) -> ()

Constrains two rectangles to coincide.

ArgumentTypeRequirementDescription
r1RectRequiredFirst rectangle.
r2RectRequiredSecond rectangle.

Returns (). Nothing; four edge constraints are added.

center_rects​

center_rects(r1: Rect, r2: Rect) -> ()

Constrains two rectangles to share a center.

ArgumentTypeRequirementDescription
r1RectRequiredFirst rectangle.
r2RectRequiredSecond rectangle.

Returns (). Nothing; two center constraints are added.

crect2rect​

crect2rect(r: Rect) -> Rect

Draws a rectangle with the same layer and edges as a construction rectangle.

ArgumentTypeRequirementDescription
rRectRequiredThe construction rectangle. It must have a layer.

Returns Rect. The drawn rectangle.