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
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
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:
typeset tonetcopyset totrue- this will duplicate the component automatically if it is referenced.net_nameinparams
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
Net component parameters
The following parameters are important for net components:
net_name: name that is assigned to the netnet_priority: when two nets with differentnet_nameare 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 thenet_nameof the higher priority net.
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.
| Name | Description |
|---|---|
color | Color of net wires |
line_width | Line width of the net wires |
highlight | Highlight color of net wires |
highlight_width | Highlight 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
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
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
Power symbols
To create power symbols, call the supply function 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