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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
layer | String | Required, positional | A drawing layer from the technology file. |
x0 | Float | Optional keyword | Constrains the left edge. |
y0 | Float | Optional keyword | Constrains the bottom edge. |
x1 | Float | Optional keyword | Constrains the right edge. |
y1 | Float | Optional keyword | Constrains the top edge. |
w | Float | Optional keyword | Constrains the width, x1 - x0. |
h | Float | Optional keyword | Constrains the height, y1 - y0. |
x0i | Float | Optional fallback | Initial left edge, used when x0 is otherwise free. |
y0i | Float | Optional fallback | Initial bottom edge, used when y0 is otherwise free. |
x1i | Float | Optional fallback | Initial right edge, used when x1 is otherwise free. |
y1i | Float | Optional fallback | Initial 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
x0 | Float | Optional keyword | Constrains the left edge. |
y0 | Float | Optional keyword | Constrains the bottom edge. |
x1 | Float | Optional keyword | Constrains the right edge. |
y1 | Float | Optional keyword | Constrains the top edge. |
w | Float | Optional keyword | Constrains the width. |
h | Float | Optional keyword | Constrains the height. |
layer | String | Optional keyword | Optional layer to associate with the rectangle. |
x0i | Float | Optional fallback | Initial value for x0. |
y0i | Float | Optional fallback | Initial value for y0. |
x1i | Float | Optional fallback | Initial value for x1. |
y1i | Float | Optional fallback | Initial 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
layer | String | Required, positional | A drawing layer. |
points | Int | Required, positional | Number of vertices. Coordinate indices run from 0 to points - 1. |
xN | Float | Optional keyword | x coordinate of vertex N. |
yN | Float | Optional keyword | y coordinate of vertex N. |
xNi | Float | Optional fallback | Initial x coordinate of vertex N. |
yNi | Float | Optional fallback | Initial 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
layer | String | Required, positional | A drawing layer. |
points | Int | Required, positional | Number of centerline points. |
width | Float | Optional keyword | Full width of the path. Must not solve to a negative value. |
begin_extension | Float | Optional keyword | How far the path extends past its first point. |
end_extension | Float | Optional keyword | How far the path extends past its last point. |
xN | Float | Optional keyword | x coordinate of centerline point N. |
yN | Float | Optional keyword | y coordinate of centerline point N. |
widthi | Float | Optional fallback | Initial width. |
begin_extensioni | Float | Optional fallback | Initial begin extension. |
end_extensioni | Float | Optional fallback | Initial end extension. |
xNi / yNi | Float | Optional fallback | Initial 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
value | String | Required, positional | The text. |
layer | String | Required, positional | Layer for the label. |
x | Float | Required, positional | x coordinate of the label origin. |
y | Float | Required, positional | y 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
cell | Cell | Required, positional | The cell value to place, such as inverter(1200., 2000., 4). |
reflect | Bool | Optional; false | Mirror the cell before rotating and translating it. |
angle | Int | Optional; 0 | Rotation in degrees: 0, 90, 180, or 270. |
x | Float | Optional keyword | x position. |
y | Float | Optional keyword | y position. |
xi | Float | Optional fallback | Initial x position. |
yi | Float | Optional fallback | Initial y position. |
construction | Bool | Optional; false | When 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
value | Cell | Inst | Required, positional | A 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
p | Float | Required, positional | Coordinate on the positive side of the measurement. |
n | Float | Required, positional | Coordinate on the negative side. |
value | Float | Required, positional | The constraint: p - n must equal this. |
coord | Float | Required, positional | Where the dimension line sits, on the perpendicular axis. |
pstop | Float | Required, positional | Where the extension line on the positive side ends. |
nstop | Float | Required, positional | Where the extension line on the negative side ends. |
horizontal | Bool | Required, positional | true for a horizontal measurement, false for vertical. |
Returns (). Nothing; the constraint and its label are added to the current cell.
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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
rect1 | Rect | Required | First rectangle. |
rect2 | Rect | Required | Second 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
rect1 | Rect | Required | First rectangle. |
rect2 | Rect | Required | Second 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
r | Rect | Required | Template. Each copy has its layer, width, and height. |
n | Int | Required | Number of copies. Below one, the result is a zero-size rectangle. |
xpitch | Float | Required | x pitch between copies. |
ypitch | Float | Required | y 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
r | Rect | Required | Template, copied at every position. |
nx | Int | Required | Number of columns. |
ny | Int | Required | Number of rows. |
xpitch | Float | Required | x pitch. |
ypitch | Float | Required | y 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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
r | Rect | Required | Template. |
w | Float | Required | Available width. |
h | Float | Required | Available height. |
xpitch | Float | Required | x pitch. |
ypitch | Float | Required | y 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.
Returns (). Nothing; four edge constraints are added.
center_rects
center_rects(r1: Rect, r2: Rect) -> ()
Constrains two rectangles to share a center.
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.
| Argument | Type | Requirement | Description |
|---|---|---|---|
r | Rect | Required | The construction rectangle. It must have a layer. |
Returns Rect. The drawn rectangle.