Skip to main content

std::schematic

std::schematic is the standard library module that builds a cell's schematic: signals, the connections between them, devices, and schematic instances of other cells. See Schematics for how these fit together.

Importing​

Nothing in std::schematic is in scope by default. Import the names a module uses:

use std::schematic::{Device, DeviceKind, Signal, connect, device, signals};
use std::schematic::inst as sinst;

std::layout also has an inst, so a module that places cells in both views imports at least one of them under another name, or calls it by full path. A name such as Signal or Device is only in scope once imported, in type position as well as in calls.

Signal, connect, device, and inst are implemented by the compiler. They can only be called, so a reference that isn't a call, such as let f = connect;, is an error. Device is only a type. DeviceKind is an ordinary enum, and signals an ordinary function.

The placement keywords x, y, angle, and reflect, and the route of a connection, are grid units that only say where the GUI draws an element. None of them can be read back.

Signal​

Signal(x=Int, y=Int, angle=Int) -> Signal

Creates a signal of the current cell.

ArgumentTypeRequirementDescription
xIntOptional keyword, with yWhere the signal's pin or label is drawn, in grid units.
yIntOptional keyword, with xWhere the signal's pin or label is drawn, in grid units.
angleIntOptional keywordCounterclockwise rotation of the pin or label in degrees, a multiple of 90.

Returns Signal. A new signal, on a net of its own until it is connected.

pub let vdd = Signal();
pub let a = Signal(x=-8, y=0);

Signal is also the type of a signal, as in fn tie(s: Signal).

connect​

connect(a: Signal, b: Signal, route=[(Int, Int)]) -> ()

Joins the nets of two signals.

ArgumentTypeRequirementDescription
aSignalRequired, positionalA signal of the current cell.
bSignalRequired, positionalA signal of the current cell.
route[(Int, Int)]Optional keywordThe corners of the wire that draws the connection, in grid units, from the pin of a to the pin of b. [] is a straight wire; without route, no wire is drawn.

Returns (). Nothing; the two nets become one.

connect(out, nmos.d);
connect(a, nmos.g, route=[(-4, 0), (-4, -4)]);

device​

device(kind: DeviceKind, terminals: [Signal], model: String, <name>=Float | Int | String, …, x=Int, y=Int, angle=Int, reflect=Bool) -> Device

Adds a primitive device to the current cell.

ArgumentTypeRequirementDescription
kindDeviceKindRequired, positionalThe kind of device, which decides its terminals and whether it needs a model.
terminals[Signal]Required, positionalThe signals the device connects to, in the order its kind expects. signals(n) makes fresh ones.
modelStringRequired, positionalThe model name, without whitespace, or "" for none.
valueFloat | Int | StringOptional keywordThe value of a Res or Cap device, in any case (VALUE also works). Other kinds do not take it.
<name>Float | Int | StringOptional keywordA device parameter, kept in the order written. Names must differ other than in case. A Float must be solved to a finite number.
x, yIntOptional keywords, togetherWhere the device is drawn, in grid units. Reserved in every case, so X=1 is an error rather than a parameter.
angleIntOptional keywordCounterclockwise rotation in degrees, a multiple of 90.
reflectBoolOptional keywordMirror about the x axis before rotating.

Returns Device. The device's handle, whose fields are its terminals.

device(DeviceKind::Mos, [d, g, s, b], "nch", w=2., l=0.15, nf=2);
device(DeviceKind::Res, [top, bottom], "", value=1000.);
let mn = device(DeviceKind::Nmos, signals(4), "nch", w=1., l=0.15, x=0, y=-4);
connect(a, mn.g);

The device table lists the terminals and model each kind requires.

inst​

inst(cell: Cell, x=Int, y=Int, angle=Int, reflect=Bool) -> SchematicInst

Places a cell in the current cell's schematic.

ArgumentTypeRequirementDescription
cellCellRequired, positionalThe cell value to place, such as inv(2., 1., 2).
x, yIntOptional keywords, togetherWhere the instance is drawn, in grid units.
angleIntOptional keywordCounterclockwise rotation in degrees, a multiple of 90.
reflectBoolOptional keywordMirror about the x axis before rotating.

Returns SchematicInst. The instance, whose ports read as its terminals.

let nmos = std::schematic::inst(mos(true, 1., 2), x=0, y=-4);
connect(a, nmos.g);

signals​

signals(n: Int) -> [Signal]

Creates fresh signals.

ArgumentTypeRequirementDescription
nIntRequired, positionalHow many signals to create.

Returns [Signal]. n new signals of the current cell, each on a net of its own.

let mn = device(DeviceKind::Nmos, signals(4), "nch", w=1., l=0.15);

Written in Argon, so the signals belong to the cell that calls it. They have no placement of their own and draw nothing.

Device​

The type of the handle device returns. Its fields are the device's terminals, named by its kind, and terminals, every terminal in order:

KindFields
Mos, Nmos, Pmosd, g, s, b
Res, Cap, Diodep, n
Bjt, Npn, Pnpc, b, e, and sub with 4 terminals
Subcktnone by name
every kindterminals: [Signal]

Every named field has type Signal. The names are checked against the device's kind when the cell runs, so r.g on a resistor is an error. See device handles.

DeviceKind​

enum DeviceKind {
Mos,
Nmos,
Pmos,
Res,
Cap,
Diode,
Bjt,
Npn,
Pnp,
Subckt,
}

The kind of a device placed with device: a MOSFET, a resistor, a capacitor, a diode, a bipolar transistor, or an instance of a subcircuit the cell does not define, such as a PDK model. Nmos and Pmos are Mos devices, and Npn and Pnp are Bjt devices, drawn with a polarity symbol; they netlist as their base kind.