Hardware Description Language for PCB design
.zen
file is a Starlark module. It can be used in two ways:
load()
ed into other modules. For example,
load("./MyFile.zen", "MyFunction", "MyType")
will load the MyFunction
and MyType
symbols from the MyFile.zen
module.Module()
helper. For
example, MyFile = Module("./MyFile.zen")
will import MyFile.zen
as a
schematic module, which you can instantiate like so:
load()
and Module()
statements support multiple resolution strategies:
@kicad-footprints
→ @gitlab/kicad/libraries/kicad-footprints:9.0.0
@kicad-symbols
→ @gitlab/kicad/libraries/kicad-symbols:9.0.0
@stdlib
→ @github/diodeinc/stdlib:HEAD
pcb.toml
:
Net
represents an electrical connection between component pins.
Net
Net(name="")
name
(optional): String identifier for the netSymbol
represents a schematic symbol definition with its pins. Symbols can be created manually or loaded from KiCad symbol libraries.
Symbol
Symbol(library_spec=None, name=None, definition=None, library=None)
library_spec
: (positional) String in format “library_path:symbol_name” or just “library_path” for single-symbol librariesname
: Symbol name (required when loading from multi-symbol library with named parameters)definition
: List of (signal_name, [pad_numbers]) tupleslibrary
: Path to KiCad symbol library filelibrary_spec
argument with the named library
or name
parameters.
Component
Component(**kwargs)
Key parameters:
name
: Instance name (required)footprint
: PCB footprint (required)symbol
: Symbol object defining pins (required)pins
: Pin connections to nets (required)prefix
: Reference designator prefix (default: “U”)mpn
: Manufacturer part numbertype
: Component typeproperties
: Additional properties dictusing()
enable automatic type promotion when passing interfaces across module boundaries:
Rules:
using()
field per type per interface - duplicate promotion targets to the same type are not allowedself
and cannot be overridden during instantiation.
Type: interface
interface(**fields)
field()
specifications, or using()
specificationsModule
Module(path)
name
: String identifier for the inputtype
: Expected type (Net
or interface type)default
: Default value if not provided by parentoptional
: If True, returns None when not provided (unless default is specified)name
: String identifier for the inputtype
: Expected type (str, int, float, bool, enum, or record type)default
: Default value if not providedconvert
: Optional conversion functionoptional
: If True, returns None when not provided (unless default is specified).zen
file that declares its inputs and creates components: