Skip to main content

Nets and power symbols

A net consist of a group of connected component pins. In an ideal world, without lossy interconnects, these pins are electrically tied and have the same voltage.

Net components​

In the standard library, the supply function creates a supply component in the schematic.

from "std" import *

gnd = dgnd()

at v5v = supply("5V")
wire down 100
add cap(100n)

wire down 100
to gnd
line 5:15VComponent C1: line 7:1C1100nline 10:4GND

A net component has a special property, whenever it is referenced it will create a duplicate of itself. In the following example, the v5v net component is duplicated when it is referenced.

The gnd component is also a net component, and similary duplicated when referenced.

Normal non-net components do not have this property and will not duplicate themselves when referenced.

from "std" import *

v5v = supply("5V")
gnd = dgnd()

at v5v
wire down 100
add cap(100n)
wire down 100
to gnd

at v5v
wire down 100
add res(10k)
wire down 100
to gnd
line 6:15VComponent C1: line 8:1C1100nline 10:4GNDline 12:15VComponent R1: line 14:1R110kline 16:4GND

Creating net components​

The standard library provides the supply and net functions that create net components. Most of the time, calling these 2 functions are enough for most circuits.

To create a net component, create a component with the following parameters:

  • type set to net
  • copy set to true - this will duplicate the component automatically if it is referenced.
  • net_name in params
from "std" import *

my_gnd = create component:
pins: 1
copy: true
type: "net"
params:
net_name: "my_gnd"

my_net = create component:
pins: 1
copy: true
type: "net"
params:
net_name: "hello"

at my_net
wire down 100
add res(10k)
wire down 100
to my_gnd

at my_net
wire down 100
add cap(100n)
wire down 100
to my_gnd
line 17:111?AComponent R1: line 19:1R110kline 21:411?Aline 23:111?AComponent C1: line 25:1C1100nline 27:411?A

Net component parameters​

The following parameters are important for net components:

  • net_name: name that is assigned to the net
  • net_priority: when two nets with different net_name are connected, the net with the higher priority will be used. The other net will be merged into the higher priority net. All pins within the other net will have the net_name of the higher priority net.

Net labels​

A net label is created using the label(name, direction) function, where name is the string identifier for the net and anchor controls which way the label text is anchored.

Any two nets that share the same label name are considered electrically connected, even if they are not physically wired together in the schematic. This makes net labels a powerful tool for organizing complex circuits.

from "std" import *

v5 = supply("5V")
gnd = dgnd()

at v5
wire down 100
add res(10k)
wire down 100

branch:
wire right 200
branch:
wire down 100
add cap(100n)
wire down 100
to gnd

wire right 300
add label("midpt", "right")
..net.color = "red"
..net.highlight = "red"
..net.highlight_width = 20

wire down 100
add res(10k)
wire down 100
to gnd
line 6:15VComponent R1: line 8:1R110kComponent C1: line 15:9C1100nline 17:12GNDNet label midpt: line 20:5midptComponent R2: line 26:1R210kline 28:4GND

Net namespaces​

A net namespace prefixes a callable call with / followed by an expression, scoping the nets created inside that call under the given name. This is useful when the same callable/function is invoked multiple times and each invocation should get its own set of nets, rather than all invocations sharing (or colliding on) the same net names.

The forms below are shown with a stand-in sub() callable, not real syntax to copy directly:

/"lit0" sub()        # string literal namespace
/("ch" + i) sub() # computed namespace
/chname sub() # variable holding a string
/scope1 sub() # bare identifier is used as the namespace text itself

A bare / with no expression means the global namespace.

There is also a relative form, +/name, which appends name to the namespace already in effect at the call site, rather than replacing it. This matters when namespaced calls are nested: if an outer call is running under the outer_ns namespace and it makes an inner call prefixed with +/deeper, the inner call ends up under outer_ns/deeper, whereas prefixing it with /deeper (no +) would have replaced the namespace entirely, dropping outer_ns. At the top level, with no outer namespace in effect, +/name and /name behave the same.

The following example calls the same sub() callable twice, once under the "lit0" namespace and once under a namespace held in the chname variable. Each call creates its own SIG net, and the two calls produce distinct nets: /lit0/SIG and /var0/SIG.

from "std" import *

anchor = net("ANCHOR")

def sub():
wire down 100 right 100
add res(10k)
wire right 100 up 100
add net("SIG")

at anchor
branch:
/"lit0" sub()

chname = "var0"
at anchor
branch:
/chname sub()
line 11:1ANCHORComponent R1_1: line 7:5R1_110kline 9:5SIGline 16:1ANCHORComponent R1_2: line 7:5R1_210kline 9:5SIG

Net visual parameters​

The following parameters can be set on the .net object within the net component to modify the visual properties of the net.

NameDescription
colorColor of net wires
line_widthLine width of the net wires
highlightHighlight color of net wires
highlight_widthHighlight width of the net wires

Examples:

from "std" import *

gnd = dgnd()

v5 = supply("5V")
v5.net.color = "red"
v5.net.line_width = 10
v5.net.highlight = "red"
v5.net.highlight_width = 10

at v5
wire down 100
branch:
wire down 100
add cap(100n)
wire down 100
to gnd

wire right 300 down 100
add cap(100n)
wire down 100
to gnd
line 11:15VComponent C1: line 15:5C1100nline 17:8GNDComponent C2: line 20:1C2100nline 22:4GND

Alternatively, the double dot syntax can also be used to avoid the need to reference v5 repeatedly.

from "std" import *

gnd = dgnd()
v5 = supply("5V")

at v5
..net.color = "red"
..net.line_width = 10
..net.highlight = "red"
..net.highlight_width = 10

wire down 100
branch:
wire down 100
add cap(100n)
wire down 100
to gnd

wire right 300 down 100
add cap(100n)
wire down 100
to gnd
line 6:15VComponent C1: line 15:5C1100nline 17:8GNDComponent C2: line 20:1C2100nline 22:4GND

Net classes​

Net classes let you define a reusable set of visual properties under a name, then assign that class to multiple nets. This reduces repetition and keeps schematics visually consistent. Individual net.* overrides still take precedence over class defaults.

Creating a net class​

Use the create netclass: block to define a class:

power_class = create netclass:
name: "power"
color: "red"
line_width: 20
highlight: "red"
highlight_width: 10

Supported parameters:

NameDescription
nameRequired. String identifier for the class
colorWire color
line_widthWire thickness
highlightHighlight color
highlight_widthHighlight thickness
highlight_opacityHighlight opacity (0–1)

Assigning a net class to a net​

Assign a class using ..class = my_class either at creation time or inside an at block:

# at creation time
v5 = supply("5V")
..class = power_class

# or inside an at block
at v3v3
..class = power_class

A per-net override (..net.color, etc.) always takes precedence over the class value.

from "std" import *

power_class = create netclass:
name: "power"
color: "red"
line_width: 20
highlight: "red"
highlight_width: 10

gnd = dgnd()

v5 = supply("5V")
..class = power_class

v3v3 = supply("3V3")
..class = power_class
..net.color = "blue"

at v5
wire down 100 right 100
add res(10k)
wire right 100 down 100
to gnd

at v3v3
wire down 100 right 100
add res(1k)
wire right 100 down 100
to gnd
line 19:15VComponent R1: line 21:1R110kline 23:4GNDline 25:13V3Component R2: line 27:1R21kline 29:4GND

Power symbols​

The standard library std.cst provides the supply function. This can be used to create power symbols with the name of the power net.

from "std" import *
v5v = supply("5V") # creates 5V net
v3v3 = supply("3V3") # creates 3.3V net
gnd = dgnd() # creates GND net

at v5v
wire down 100 right 100
add res(300)
wire right 100
add led("red") pin 2
wire right 100 down 100
to gnd

at v3v3
wire down 100 right 100
add res(200)
wire right 100
add led("green") pin 2
wire right 100 down 100
to gnd

line 6:15VComponent R1: line 8:1R1300Component D1: line 10:112D1redline 12:4GNDline 14:13V3Component R2: line 16:1R2200Component D2: line 18:112D2greenline 20:4GND