Skip to content

jitx/commands

Package name: jitx/commands

Summary

Data Types

AssignSymbolError

Constructors

Function Description
AssignSymbolError Constructor for defstruct AssignSymbolError

AssignLandPatternError

Constructors

Function Description
AssignLandPatternError Constructor for defstruct AssignLandPatternError

AuthorizedVendor

Define the approved vendors used by the design.

Functions

Function Description
set-bom-vendors

General Definitions

Function Description
clear-definitions
make-port (+ 1)
via-filled Get the filled attribute o a pcb-via definition.
design-explorer-to-string
enable-import-dump-ir Dump the generated internal representation during import
port-type Get the type of a port from a component or module definition/instance
modify-components Transforms module by modifying every component definition by calling the
simplify
dbquery
ref?
apply-variants Apply Variants to a design to obtain a new design
set-config-sets
ports (+ 1) Get the ports of a component, bundle, or module
get-min-space Get the minimum space rule for a given LayerSpecifier.
set-main-module Define the "main" module of the current design.
public-instances (+ 1) Get the public instances of a module.
start-timer
clearance (+ 1) Get a specific clearance rule.
public-single-instances (+ 1) Get the public single (non array) instances of a module.
bom-vendors
no-connect? Check if a pin is no-connect.
assign-pins?
instantiable-type Return the type of instantiable an object is.
view-schematic (+ 1) Visualize the generated schematic.
print-rules-functions
export-bom Export the bill of materials (BOM) to the design directory.
set-export-board? Set whether export-cad should generate board files.
enable-debug-plugin-serializer Enable debugging printout from the plugin object serializer.
set-design-directory
start-new-timer
dbquery-first
export-cad (+ 1) Export the JITX design to CAD.
set-value-format-options Set the formats of the value strings during export operation.
public-single-pin-nets (+ 1) Get the nets of a module.
pad-type Get the type of a pcb-pad definition.
make-pin
assign-symbol Assign a symbol to a pcb-component
get-signal-boundary Retrieve the signal-boundary of a Board.
model3ds Get the model3ds of a pcb-landpattern.
single-instances (+ 1) Get the single (non array) instances of a module.
get-shape-from-contour Get a shape from a tuple of lines/polylines.
via-backdrills Get the backdrill of a pcb-via definition.
set-use-layout-sketch Configure the placer to run in sketch mode.
make-net (+ 3)
set-default-rules Sets the default rules for all designs in the current program.
pads Get the pads of a pcb-landpattern.
refs Return all the refs inside of an object
layers Get the layer statements of a pcb-landpattern or pcb-pad.
set-schematic-template Sets the template used for any calls to view-schematic.
landpattern Get the landpattern associated with a pcb-component definition.
view-design-explorer (+ 1) Visualize the design as a hierarchical tree.
set-export-backend Set the CAD exporter backend to use.
dot (+ 2)
log-event-time
run-evals?
save-generated-file
clear-timers
layer Get all the shapes on a specific layer of a landpattern
get-property?
view-board-to-string
instance-status? Retrieve the component in-BOM and on-board status of a component instance (deprecated)
connected? (+ 1) Check if a pin or a net is connected
get
side Get the side of a pad in a landpattern
dbquery-skip-cache
disable-spy Disable dumping the generated internal representation during compilation
do-not-populate? Check if a component instance is marked do-not-populate
public-nets (+ 1) Get the nets of a module.
set-current-design Set the directory "./designs/" that JITX will use to store design data.
dbquery-all
set-cad-info
all-items-with-properties
set-paper Set the paper size used in schematic export
via-stop Get the stop layer of a pcb-via definition.
save-to-svg
set-use-layout-groups Configure the placer to run in groups mode.
assign-landpattern Map a landpattern to a component using pin properties.
reference-prefix? (+ 1) Get the reference prefix of a component, if it exists.
via-diameter Get the diameter of a pcb-via definition.
get-property
im-feeling-lucky
get-merged-physical-design-module Obtain the physical-design-transformed "main" module of the current design.
instance-type Determine if an instance is a component, module, or array.
enable-spy Dump the generated internal representation during compilation
mpn? (+ 1) Get the MPN of a component, if it exists.
via-tented Get the tented sides of a pcb-via definition.
nets (+ 1) Get the nets of a module.
notify-vscode-of-loaded-jitx-shell
via-hole-diameter Get the hole diameter of a pcb-via definition.
pins (+ 1) Get the pins associated with an object.
instances (+ 1) Get the instances of a module.
clear-dbquery-cache Clear the cache on disk used for part queries with dbquery so that the parts gets refreshed next time the queries are run.
make-node (+ 1)
print-current-rules
via-in-pad Get the via-in-pad attribute of a pcb-via definition.
instance-definition Get the pcb-* definition of an instance.
min-width Compute the minimum width in a sequence of shapes.
name Get the name of an object
manufacturer? (+ 1) Get the manufacturer name of a component, if it exists.
pose Get the pose of a pad inside a pcb-landpattern.
single-pin-nets (+ 1) Get the nets of a module.
offset Compute a shape that is "offset" from another by a fixed distance.
pad Get the pcb-pad definition of a pad in a landpattern.
ref Get the associated Ref of an object instance.
run-evals Runs all eval-when blocks nested within module to return a newly evaluated Instantiable.
topology-ends Get the ends of a named topology.
view-bom View the bill of materials (BOM).
evaluate Evaluates a definition, expanding its statements.
via-type Get the drill type of a pcb-via definition.
expand Expand a shape by a fixed distance.
assign-pins Explicitly run pin assignment before automatic placement, visualization, or export.
import-cad (+ 1) Import CAD projects from KiCAD or Altium.
set-export-schematic? Set whether export-cad should generate schematic files.
current-rules Get the current design rules of the project
view (+ 5) View a landpattern, schematic symbol, or pcb-component.
get-net Find a net with a given name in a module.
freeze-reference-designators Freeze all the reference designators, so they will not be recomputed.
indices Get the indices of an array of JITX objects.
get? (+ 2)
has-board? Check if the board has been set.
get-stackup Retrieve the stackup of a Board.
component-instances (+ 1) Get the instances of a module that are components (not modules).
get-board Get the current pcb-board, if it exists
get-def-string Get the string representation of the ESIR definition as ASCII.
explorer-json
stop-timer
set-board Sets the pcb-board object used by the current design.
package-poses Get the package poses associated with a pcb-component definition.
component-status? Retrieve the component in-BOM and on-board status of a component instance (deprecated)
view-board (+ 1) Visualize the generated board.
expand-or-shrink Expand or shrink a shape by a fixed distance.
get-boundary Retrieve the boundary of a Board.
set-bom-design-quantity Set the quantity of boards to manufacturer when generating a BOM.
connected-pins Return the pins connected to an existing pin.
make-inst
save-timing-report
set-ipc-info
min-space Compute the minimum space in a sequence of shapes.
pad-def Get the pcb-pad definition of a pad in a landpattern.
set-bom-metrics set-bom-metrics(metrics: Tuple)
set-rules Set the design rules for the current design.
all-connected-items Returns a list of all the connected items to a pin or net.
get-export-backend Get the currently set CAD exporter backend.
get-min-width Get the minimum width rule for a given LayerSpecifier.
via-backdrill DEPRECATED!: Use via-backdrills instead
reference-designator Get the reference designator of a component.
optimized-mode? Checks whether the algorithmic core has been compiled
clearances Get the clearances specified by a Rules object
view-sub-schematic (+ 3) Visualize the generated sub-schematic for a list of nets and instances.
emodel? (+ 1) Get the emodel of a component or the component of an inst, if it exists.
transform-component Applies body on component to return a newly transformed Instantiable.
compare-cad
set-property
via-start Get the start layer of a pcb-via definition.
print-def Print the ESIR definition as ASCII. Not very human readable.
set-bom-columns set-bom-columns(cols: Tuple)
length Get the length of an instance or bundle array.
originating-instantiable Get the inst definition that created an instance.
pad-shape Get the shape of a pcb-pad definition.
datasheet? (+ 1) Get the datasheet name of a component, if it exists.
dims Compute the x/y dimensions of a shape.
clear-default-rules This has been deprecated; JITX now includes a default rule set.
run-checks Runs all checks statements, saves results in a file named filename, and returns a CheckSummary.
transform-module Applies body on module to return a newly transformed Instantiable. This is how to run custom passes on your design module.
containing-instance Get the instance that an object is contained within, if it exists.
current-rules? Get the current design rules.

Definitions

AssignSymbolError

public defstruct AssignSymbolError <: Exception :
    errors: Tuple
    symbol: String

  • errors: Tuple

  • symbol: String

Constructors

AssignSymbolError

Constructor for defstruct AssignSymbolError

public defn AssignSymbolError (symbol:String, errors:Tuple)

AssignLandPatternError

public defstruct AssignLandPatternError <: Exception :
    msg: String|Printable
    name: String

  • msg: String|Printable

  • name: String

Constructors

AssignLandPatternError

Constructor for defstruct AssignLandPatternError

public defn AssignLandPatternError (name:String, msg:String|Printable)

AuthorizedVendor

Define the approved vendors used by the design.

public defenum AuthorizedVendor <: Equalable & Hashable

  • JLCPCB

  • LCSC

  • DigiKey

  • Future

  • Mouser

  • Arrow

  • Avnet

  • Newark

Syntax

set-bom-vendors([
  "JLCPCB",
  "Arrow",
  "Avnet",
  "DigiKey",
  "Future",
  "Mouser",
  "Newark"
])

set-bom-design-quantity(100)

;write the BOM files to disk
export-bom()

Description

The set-bom-vendors command will define the list of approved parts vendors. Parts are queried from these vendors to be placed in the design.

It is possible to use the enum's specified in AuthorizedVendor instead of String to avoid typo. For example: set-bom-vendors([LCSC]) works also.

Functions

set-bom-vendors

public defn set-bom-vendors (vendors:Tuple<String|AuthorizedVendor>|False) -> Null

  • Returns Null

General Definitions

clear-definitions

public defn clear-definitions () -> Null

  • Returns Null

make-port

public defn make-port (name:Symbol)

make-port

public defn make-port (name:Symbol, type:PortType)

via-filled

Get the filled attribute o a pcb-via definition.

public defn via-filled (obj:JITXDef) -> True|False

  • Returns True|False

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-filled(th-via))

Description

The via-filled introspection function returns whether a pcb-via definition is filled or not. If the filled attribute is not specified, the default value is returned. See pcb-via documentation for more information.

design-explorer-to-string

public defn design-explorer-to-string (def:Instantiable) -> String

  • Returns String

enable-import-dump-ir

Dump the generated internal representation during import

public defn enable-import-dump-ir (b:True|False) -> Null

  • Returns Null

Syntax

enable-import-dump-ir(true)
import-cad(...)

Description

The enable-import-dump-ir command is a debugging tool to dump the importer's internal representation(s) into a human readable text form. It is generally only useful for analyzing importer errors. The command can be called with false as the input to re-disable dumping after enabling.

port-type

Get the type of a port from a component or module definition/instance

public defn port-type (obj:JITXObject) -> PortType

  • Returns PortType

Syntax

pcb-module my-module :
  port p : i2c
  println(port-type(p))

Description

Ports of components or modules may be one of a given [PortType], valid port types are SinglePin, Bundle, PortArray

modify-components

Transforms module by modifying every component definition by calling the

public defn modify-components (modify-component:(Instantiable) -> Instantiable|False, module:Instantiable) -> Instantiable

  • Returns Instantiable

user-supplied function modify-component on them. Whenever modify-component returns a new Instantiable, the component definition will be swapped in place. However, this substitution only takes effect in the new module returned by modify-components. If modify-component instead returns false, the component will be left as is.

To make useful changes, modify-component can use the transform-component function to add statements to the given component definition.

Example

defn standardize-parts (module:Instantiable) -> Instantiable :
  within component = modify-components(module) :
    if name(component) == "my-resistor" :
      println("standardizing component %_" % [name(component)])
      within transform-component(component) :
        inside pcb-component :
          val [p1,p2] = pins(self) as [Pin Pin]
          val symb = my-preferred-resistor-symbol
          val [q1,q2] = pins(symb) as [Pin Pin]
          override symbol = symb(p1 => q1, p2 => q2)
    else :
      false ; don't change the component
val new-design = standardize-parts(original-design)
set-main-module(new-design)

This example overrides the symbol of every component named my-resistor to my-preferred-resistor-symbol, mapping the pins in the order they were given.

simplify

public defn simplify (s:Shape) -> Shape

  • Returns Shape

dbquery

public defn dbquery (params:Tuple<KeyValue<String, Tuple<String>|Tuple<Double>|String|Double|Int>>, limit:Int) -> Tuple<JSON>

  • Returns Tuple<JSON>

ref?

public defn ref? (a:JITXObject) -> Ref|False

  • Returns Ref|False

apply-variants

Apply Variants to a design to obtain a new design

public defn apply-variants (vs:Tuple<String>, module:Instantiable) -> Instantiable

  • Returns Instantiable

Or no Variant is used if the argument is empty

Syntax

pcb-module my-module :
  inst a : component-a

  variant "DNP" :
    do-not-populate(a)

val new-module = apply-variants(["DNP"] my-module)
set-main-module(new-module)

Description

The apply-variants command is used to transform a module into another module with the Variants applied.

set-config-sets

public defn set-config-sets (configs:Tuple<Symbol>) -> Null

  • Returns Null

ports

Get the ports of a component, bundle, or module

public defn ports (obj:JITXObject)

Syntax

val ports = ports(my-component)
for p in ports do :
  println(ref(port))

Description

ports are defined using the port statement. The ports introspection retrieves all port statements associated with the bundle, component, or module.

ports

public defn ports (def:Instantiable|Bundle)

get-min-space

Get the minimum space rule for a given LayerSpecifier.

public defn get-min-space (l:LayerSpecifier|LayerIndex) -> Double

  • Returns Double

Syntax

val min-cu-space = get-min-space(LayerIndex(0))

Description

get-min-space is a convenience function around clearance and current-rules introspections for quickly retrieving the DRC parameters for the minimum space on a given layer. Currently only copper and solder mask bridge spacings are supported.

set-main-module

Define the "main" module of the current design.

public defn set-main-module (module:Instantiable)

Syntax

pcb-module main-module :
  ...

set-main-module(main-module)

Description

The main module is the root of the entire JITX design, and is analogous to a "root" schematic sheet.

public-instances

Get the public instances of a module.

public defn public-instances (obj:JITXObject)

Syntax

pcb-module my-module :
  inst R1 : gen-res-cmp(1.0e3)
  public inst R2 : gen-res-cmp(2.0e3)

; This loop will only print "2000.0", since
; R1 is a private instance.
for cmp in public-instances(my-module) do :
  println(property(cmp.resistance))

Description

By default, all instances in a module are considered to have "private" visibility, which disables instantiators from referencing the instances' refs, ports, and properties.

The public-instances introspection returns a sequence of instances of a module that are explicitly marked public.

public-instances

public defn public-instances (def:Instantiable)

start-timer

public defn start-timer (name:String) -> Null

  • Returns Null

clearance

Get a specific clearance rule.

public defn clearance (r:Rules, c:ClearanceType) -> Double

  • Returns Double

Syntax

val min-cu-width = clearance(current-rules(), MinCopperWidth)
println(min-cu-width)

; convenience variation to lookup a
; val min-cu-width = clearance(MinCopperWidth)

Description

The clearance introspection takes a Rules and ClearanceType and lookups up the associated value with that ClearanceType. When called without an explicit Rules argument, the current-rules() are used.

clearance

public defn clearance (c:ClearanceType) -> Double

  • Returns Double

public-single-instances

Get the public single (non array) instances of a module.

public defn public-single-instances (obj:JITXObject)

Syntax

pcb-module my-module :
  inst R : gen-res-cmp(1.0e3)[10]
  inst R11 : gen-res-cmp(2.0e3)
  public inst R12 : gen-res-cmp(3.0e3)

; This loop will only print "3000.0", as there
; is only one "single' instance in `my-module`.
; that is explicitly marked `public`
for cmp in single-instances(my-module) do :
  println(property(cmp.resistance))

Description

The public-single-instances introspection returns a sequence of explicitly public instances that are not defined within instance arrays.

public-single-instances

public defn public-single-instances (def:Instantiable)

bom-vendors

public defn bom-vendors () -> Tuple<String>|False

  • Returns Tuple<String>|False

no-connect?

Check if a pin is no-connect.

public defn no-connect? (pin:JITXObject) -> True|False

  • Returns True|False

Syntax

pcb-component component :
  pin GND
  pin VDD
  pin NC
  no-connect(NC)

pcb-module my-module :
  inst U1 : component
  ; prints false.
  println(no-connect?(U1.GND)
  ; prints false.
  println(no-connect?(U1.VDD)
  ; prints true.
  println(no-connect?(U1.NC)

Description

The no-connect? introspection checks if a no-connect(...) statement has been applied to the given pin. This is useful when writing checks.

assign-pins?

public defn assign-pins? () -> Instantiable|False

  • Returns Instantiable|False

instantiable-type

Return the type of instantiable an object is.

public defn instantiable-type (obj:JITXObject) -> InstantiableType

  • Returns InstantiableType

Syntax

pcb-module my-module :
  ...

; prints `Instantiable`.
println(instantiable-type(obj))

Description

The instantiable-type is either a single instantiable (Instantiable) or an array of instantiables (InstantiableArray).

view-schematic

Visualize the generated schematic.

public defn view-schematic (view-mode:ViewMode) -> Null

  • Returns Null

Syntax

; Default: update the view
view-schematic()
; Visualize, panning to the center of the view and zooming to fit
view-schematic(NewView)
; Visualize, but maintain the same pan/zoom state.
view-schematic(UpdateView)

Description

The view-schematic command is used to visualize the generated circuit board.

view-schematic

public defn view-schematic () -> Null

  • Returns Null

print-rules-functions

public defn print-rules-functions () -> Null

  • Returns Null

export-bom

Export the bill of materials (BOM) to the design directory.

public defn export-bom () -> Null

  • Returns Null

Syntax

set-bom-vendors([
  "JLCPCB",
  "Arrow",
  "Avnet",
  "DigiKey",
  "Future",
  "Mouser",
  "Newark"
])

set-bom-design-quantity(100)

;write the BOM files to disk
export-bom()

Description

The export-bom command will create the following files in the design directory :

<design-directory>/bom/<design>.tsv
<design-directory>/bom/<design>.select

The .tsv file is a tab separated value that can be imported by spreadsheet software to order parts. The formatting is not defined and subject to change. Parts are autoselected, unless overridden by the .select file.

set-export-board?

Set whether export-cad should generate board files.

public defn set-export-board? (b:True|False) -> Null

  • Returns Null

Syntax

set-export-board?(true) ; or false

Description

By default, the export command will generate a board. Use set-export-board? to control whether it is generated or not.

enable-debug-plugin-serializer

Enable debugging printout from the plugin object serializer.

public defn enable-debug-plugin-serializer () -> Null

  • Returns Null

Syntax

enable-debug-serializer()

set-design-directory

public defn set-design-directory (filepath:String) -> Null

  • Returns Null

start-new-timer

public defn start-new-timer (name:String) -> String

  • Returns String

dbquery-first

public defn dbquery-first (args:Tuple<KeyValue<String, Tuple<String>|Tuple<Double>|String|Double|Int>>) -> JSON

  • Returns JSON

export-cad

Export the JITX design to CAD.

public defn export-cad (field-mapping:False|Tuple<KeyValue<String, String>>) -> Null

  • Returns Null

Syntax

set-current-design("jitx-design")
set-export-backend(`altium)

; ... run design ...

export-cad()
; Cad files written to <project-root>/designs/jitx-design/altium
Or
val mappings = [
  "rated-temperature" => "Rated-temperature"
  "datasheet" => "Datasheet"
]
export-cad(mappings)
; Cad files exported with the field/property names converted.

Description

The export-cad command will take the generated board and schematic and convert it to a set of files in the design directory that can be used in CAD software.

The output directory will be &#60;design-directory-name>/&#60;export-backend>.

An optional field-mappings can be supplied as an argument. Name, Description, Manufacturer, MPN, Reference-prefix will always be exported, even if there is no field-mappings. Their exported names can be changed by using the field-mapping.

Component properties can also be exported if an entry exists in field-mappings. For example, if there is a property(U1.datasheet) = "http://www.somewhere.com/my-datasheet.pdf", using "datasheet" => "Datasheet" in the field-mappings (as above), a field "Datasheet" with value "https://www.somewhere.com/my-datasheet.pdf" will appear as a property of the component in CAD software.

A property will not be exported if... * there is no corresponding entry in field-mappings; OR * it does not exist; OR * its value cannot be converted to a string.

To export a property without name change, put the same name in both ends of the mapping. For example, "rated-voltage" => "rated-voltage".

export-cad

public defn export-cad ()

set-value-format-options

Set the formats of the value strings during export operation.

public defn set-value-format-options (format-options:Tuple<String>) -> Null

  • Returns Null

Syntax

set-current-design("jitx-design")
set-export-backend(`kicad)
val format-options = ["keep-decimal" "LC-units-always-present"]
set-value-format-options(format-options)

; ... run design ...

export-cad()
; Cad files written to <project-root>/designs/jitx-design/altium

Description

The set-value-format-options command will set the preferences to generate component values. It is optional. export-cad will work even if this command is not present. By default, without this command the output will look like these: By way of examples: | |Value |Output| |----------|------------------|------| |Resistor |3300 Ohm |3K3 | | |100 Ohm |100R | |----------|------------------|------| |Capacitor |0.0000047 Farad |4.7u | | |0.000000010 Farad |10n | |----------|------------------|------| |Inductor |0.010 Henry |10m |

If a string is present in the format-options, the value will be different: "use-small-k" => 3300-ohm Resistor Value will be: 3k3 "use-greek-mu" => 0.0000047-farad Capacitor Value will be: 4.7μ "use-greek-ohm" => 100-ohm Resistor Value will be: 100Ω "R-unit-always-present" => 3300-ohm Resistor Value will be: 3K3R or 3K3Ω "LC-units-always-present" => 0.0000047-farad Capacitor Value will be: 4.7uF "R-not-replace-decimal-by-quantifier" => 3300-ohm Resistor Value will be: 3.3K "LC-replace-decimal-by-quantifier" => 0.0000047-farad Capacitor Value will be: 4u7 "keep-decimal" => 100-ohm Resistor Value will be: 100.0R "C-replace-n-by-K" => 0.000000010-farad Capacitor Value will be: 10K or 10k (if "use-small-k" is also present) "add-tolerance" => 0.010-henry Inductor Value will be: 10m ± 20% (depends on actual tolerance value)

public-single-pin-nets

Get the nets of a module.

public defn public-single-pin-nets (obj:JITXObject)

Syntax

pcb-module my-module :
  inst R1 : gen-res-cmp(1.0e3)
  inst R2 : gen-res-cmp(1.0e3)
  net my-net (R1.p[1], R2.p[1])
  public net my-public-net (R1.p[2], R2.p[2])

  for n in public-nets(self) do :
    println(name(n))

Description

The public-single-pin-nets introspection is useful for extracting all the net statements of a module with a single pin that are explicitly marked public.

public-single-pin-nets

public defn public-single-pin-nets (def:Instantiable)

pad-type

Get the type of a pcb-pad definition.

public defn pad-type (p:Pad|Self)

Syntax

pcb-pad my-pad :
  shape = Circle(1.0)
  type  = SMD

println(pad-type(my-pad))

Description

The pad-type introspection returns the PadType associated with a pcb-pad definition, which can either be TH (through hole) or SMD (surface mount)

make-pin

public defn make-pin (name:Symbol)

assign-symbol

Assign a symbol to a pcb-component

public defn assign-symbol (symbol:SchematicSymbol) -> Null

  • Returns Null

Syntax

public pcb-component component :
  name = "142-0761-881"
  manufacturer = "Johnson / Cinch Connectivity Solutions"
  mpn = "142-0761-881"
  reference-prefix = "J"

  pin-properties :
    [pin:Ref  |pads:Int ...   | side:Dir]
    [sig      | 1             | Left    ]
    [gnd      | 2 3           | Down    ]

  assign-symbol(coax-sym)
  assign-landpattern(johnson-142-0761-881-pkg)

Description

The assign-symbol function uses the pin column in a pin-properties table to map the pins of a component to the pins of a schematic symbol. The symbol pin names must match the component pin names

get-signal-boundary

Retrieve the signal-boundary of a Board.

public defn get-signal-boundary (def:Board) -> Shape

  • Returns Shape

Syntax

pcb-board my-board:
  signal-boundary = my-shape
  ...

pcb-module main-module :
  println("Board signal-boundary: %_" % [get-signal-boundary(get-board() as Board)])

set-board(my-board)
; Prints the value of `my-shape`, a Shape object
set-main-module(main-module)

Description

The get-signal-boundary introspection returns the "signal-boundary" field of a given pcb-board. Its return value is a Shape.

model3ds

Get the model3ds of a pcb-landpattern.

public defn model3ds (obj:LandPattern|Self) -> Tuple<Model3D>

  • Returns Tuple<Model3D>

Syntax

stanza val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20 for model3d in model3ds(landpattern) do : println(model3d)

# Description

The model3ds introspection returns all the Model3Ds in the landpattern.

single-instances

Get the single (non array) instances of a module.

public defn single-instances (obj:JITXObject)

Syntax

pcb-module my-module :
  inst R : gen-res-cmp(1.0e3)[10]
  inst R11 : gen-res-cmp(2.0e3)

; This loop will only print "2000.0", as there
; is only one "single' instance in `my-module`.
for cmp in single-instances(my-module) do :
  println(property(cmp.resistance))

Description

The single-instances introspection returns a sequence of instances of a module that are not defined within instance arrays.

single-instances

public defn single-instances (def:Instantiable)

get-shape-from-contour

Get a shape from a tuple of lines/polylines.

public defn get-shape-from-contour (lines:Tuple<Line|Polyline>) -> Polygon|PolygonWithArcs

  • Returns Polygon|PolygonWithArcs

Syntax

val line1 = Line(1.0, [Point(0.0, 1.0), Point(0.0, 0.0)])
val line2 = Polyline(1.0, [Point(0.0, 0.0), Point(1.0, 0.0), Point(0.0, 1.0)])
val shape = get-shape-from-contour([line1, line2])
println(shape)

Description

The get-shape-from-contour command computes a polygon from a list of lines and/or polylines. The lines/polylines must be in the same order as they are along the boundary of the polygon.

via-backdrills

Get the backdrill of a pcb-via definition.

public defn via-backdrills (obj:JITXDef) -> BackdrillSet

  • Returns BackdrillSet

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-backdrills(th-via))

Description

The via-backdrills introspection function returns any backdrills of a pcb-via definition. If backdrills are not specified, the default value is returned. See pcb-via documentation for more information.

set-use-layout-sketch

Configure the placer to run in sketch mode.

public defn set-use-layout-sketch () -> Null

  • Returns Null

Syntax

set-use-layout-sketch()

Description

When running in sketch mode, the placer will not take Layout Groups into account (faster).

make-net

public defn make-net (name:Symbol, type:PortType|False, refs:Seqable<JITXObject|Seqable<JITXObject>>, public?:True|False)

make-net

public defn make-net (name:Symbol, type:PortType|False, refs:Seqable<JITXObject|Seqable<JITXObject>>)

make-net

public defn make-net (name:Symbol, refs:Seqable<JITXObject|Seqable<JITXObject>>, public?:True|False)

make-net

public defn make-net (name:Symbol, refs:Seqable<JITXObject|Seqable<JITXObject>>)

set-default-rules

Sets the default rules for all designs in the current program.

public defn set-default-rules (rules:Rules)

This has been deprecated; JITX now includes a default rule set.

Syntax

pcb-rules jlc-pcb-rules :
  ...

set-default-rules(jlc-pcb-rules)

Description

Default rules differ from design rules set in set-rules in that they are not cleared between designs, and serves as temporary or default values for design rules so generators can make progress even if you have not set the rules for your design.

Default rules can also be used to share design rules in multi-design programs.

pads

Get the pads of a pcb-landpattern.

public defn pads (obj:LandPattern|Self) -> Tuple<LandPatternPad>

  • Returns Tuple<LandPatternPad>

Syntax

val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20
for pad in pads(landpattern) do :
  println(pad)

Description

The pads introspection returns all the LandPatternPads that have been created using the pad ... statement.

refs

Return all the refs inside of an object

public defn refs (obj:JITXObject)

Syntax

pcb-module main-module :
  for r in refs(self) do :
    println(r)

layers

Get the layer statements of a pcb-landpattern or pcb-pad.

public defn layers (obj:LandPattern|Pad|Self) -> Tuple<LayerShape>

  • Returns Tuple<LayerShape>

Syntax

val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20
for layer in layers(landpattern) do :
  println("There is a %_ on %_." % [shape(layer), specifier(layer)])

Description

The layers introspection finds all the geometry specified in layer statements in landpattern or pad definitions. It is useful for writing landpattern checks.

set-schematic-template

Sets the template used for any calls to view-schematic.

public defn set-schematic-template (t:SchematicTemplate)

Syntax

pcb-schematic-template my-template :
  ...

set-schematic-template(my-template)
view-schematic()

Description

Schematic templates allow the user to customize the appearance of the schematic. This command allows the user to select such a template for use with the JITX visualizer. Exported schematics will still be subject to styling by the relevant export target.

landpattern

Get the landpattern associated with a pcb-component definition.

public defn landpattern (obj:Self|JITXDef) -> LandPattern

  • Returns LandPattern

Syntax

val component   = ocdb/components/abracon/AMB7/component(10.0e6)
val landpattern = landpattern(component)
print-def(landpattern)

Description

The landpattern introspection function returns the pcb-landpattern definition associated with a pcb-component definition. This is useful for writing checks that look at the landpatterns of components placed in the design.

view-design-explorer

Visualize the design as a hierarchical tree.

public defn view-design-explorer () -> Null

  • Returns Null

Syntax

; Visualize the design as a tree
view-design-explorer()

Description

The view-design-explorer command is used to visualize the design in the VSCode UI.

view-design-explorer

public defn view-design-explorer (def:Instantiable -- default-3d:True|False = ?) -> Null

  • Returns Null

set-export-backend

Set the CAD exporter backend to use.

public defn set-export-backend (backend:Symbol) -> Null

  • Returns Null

Syntax

set-current-design("jitx-design")
set-export-backend(`altium)

; ... run design ...

export-cad()
; Cad files written to <project-root>/designs/jitx-design/altium

Description

The set-export-backend command will control which CAD backend that export-cad will use. The backend will also define some constraints on internals like placement and visualization.

dot

public defn dot (obj:JITXObject, name:Symbol|String) -> JITXObject

  • Returns JITXObject

dot

public defn dot (def:JITXDef, name:Symbol|String) -> JITXObject

  • Returns JITXObject

dot

public defn dot (obj:JITXObject|JITXDef, r:Ref) -> JITXObject

  • Returns JITXObject

log-event-time

public defn log-event-time (name:String) -> Null

  • Returns Null

run-evals?

public defn run-evals? (module:Instantiable) -> Instantiable|False

  • Returns Instantiable|False

save-generated-file

public defn save-generated-file (file:String, contents:String) -> Null

  • Returns Null

clear-timers

public defn clear-timers () -> Null

  • Returns Null

layer

Get all the shapes on a specific layer of a landpattern

public defn layer (obj:LandPattern|Pad|Self, l:LayerSpecifier) -> Tuple<Shape>

  • Returns Tuple<Shape>

Syntax

val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20
val solder-mask = layer(landpattern, SolderMask(Top))

Description

The layer introspection retrieves all the geometry on a single layer defined in a landpattern or pad.

get-property?

public defn get-property? (obj:JITXObject|JITXDef, name:Symbol) -> Maybe<?>

  • Returns Maybe<?>

view-board-to-string

public defn view-board-to-string () -> String

  • Returns String

instance-status?

Retrieve the component in-BOM and on-board status of a component instance (deprecated)

public defn instance-status? (obj:JITXObject) -> [ComponentBOMStatus, ComponentBoardStatus]

  • Returns [ComponentBOMStatus, ComponentBoardStatus]

connected?

Check if a pin or a net is connected

public defn connected? (obj:JITXObject) -> True|False

  • Returns True|False

Syntax

pcb-module my-module :
  inst R : gen-res-cmp(1.0e3)
  println(connected?(R.p[1]))

Description

The connected? introspection checks if a pin or net is connected to any other pins or nets in a design. This is useful when writing checks for connected or unconnected components.

connected?

public defn connected? (objs:Seqable<JITXObject>) -> True|False

  • Returns True|False

get

public defn get (obj:JITXObject, index:Int) -> JITXObject

  • Returns JITXObject

side

Get the side of a pad in a landpattern

public defn side (l:JITXObject)

Syntax

val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20
val pads-on-top =
  for pad in pads(landpattern) filter :
    side(pad) is Top

Description

The side introspection is used to find which side of the board a landpattern pad is upon.

dbquery-skip-cache

public defn dbquery-skip-cache (params:Tuple<KeyValue<String, Tuple<String>|Tuple<Double>|String|Double|Int>>, limit:Int) -> Tuple<JSON>

  • Returns Tuple<JSON>

disable-spy

Disable dumping the generated internal representation during compilation

public defn disable-spy () -> Null

  • Returns Null

Syntax

disable-spy()

Description

The disable-spy command disables the dumping of the compiler's internal representation(s) after a call to enable-spy.

do-not-populate?

Check if a component instance is marked do-not-populate

public defn do-not-populate? (obj:JITXObject) -> True|False

  • Returns True|False

public-nets

Get the nets of a module.

public defn public-nets (obj:JITXObject)

Syntax

pcb-module my-module :
  inst R1 : gen-res-cmp(1.0e3)
  inst R2 : gen-res-cmp(1.0e3)
  net my-net (R1.p[1], R2.p[1])
  public net my-public-net (R1.p[2], R2.p[2])

  for n in public-nets(self) do :
    println(name(n))

Description

The public-nets introspection is useful for extracting all the net statements of a module that are explicitly marked public. It's important to note that this corresponds to the individual net statements, and not the electrical concept of a "net." For example, if there are two public nets in a module that are electrically identical, calling nets(self) will return both of them.

public-nets

public defn public-nets (def:Instantiable)

set-current-design

Set the directory "./designs/<name>" that JITX will use to store design data.

public defn set-current-design (name:String) -> Null

  • Returns Null

Syntax

set-current-design("jitx-design")

Description

The set-current-design command will clear design state and create a new design directory to store data JITX uses. This directory will contain export data, 3D model files, and cached data used by the design.

dbquery-all

public defn dbquery-all (params:Tuple<KeyValue<String, Tuple<String>|Tuple<Double>|String|Double|Int>>) -> Tuple<JSON>

  • Returns Tuple<JSON>

set-cad-info

public defn set-cad-info (name:String, info:?)

all-items-with-properties

public defn all-items-with-properties (m:Self|JITXDef, prop-names:Tuple<Symbol>) -> Tuple<JITXObjectProperty>

  • Returns Tuple<JITXObjectProperty>

set-paper

Set the paper size used in schematic export

public defn set-paper (paper:Paper) -> Null

  • Returns Null

Syntax

set-paper(ISO-A4)

Description

The set-paper command is used to define the paper size in the exported schematic files.

Valid values are :

public defenum Paper :
  ISO-A0
  ISO-A1
  ISO-A2
  ISO-A3
  ISO-A4
  ISO-A5
  ANSI-A
  ANSI-B
  ANSI-C
  ANSI-D
  ANSI-E
  ANSI-A0 ;deprecated do not use
  ANSI-A1 ;deprecated do not use
  ANSI-A2 ;deprecated do not use
  ANSI-A3 ;deprecated do not use
  ANSI-A4 ;deprecated do not use
  ANSI-A5 ;deprecated do not use

Deprecation Notice: Enum values ANSI-A0 through ANSI-A5 are being deprecated and will be removed soon. Do not use them, use ISO-A0 through ISO-A5 instead.

via-stop

Get the stop layer of a pcb-via definition.

public defn via-stop (obj:JITXDef) -> LayerIndex

  • Returns LayerIndex

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-stop(th-via))

Description

The via-stop introspection function returns the stop LayerIndex of a pcb-via definition.

save-to-svg

public defn save-to-svg (filename:String) -> Null

  • Returns Null

set-use-layout-groups

Configure the placer to run in groups mode.

public defn set-use-layout-groups () -> Null

  • Returns Null

Syntax

set-use-layout-groups()

Description

When running in groups mode, the placer will take Layout Groups into account (slower).

assign-landpattern

Map a landpattern to a component using pin properties.

public defn assign-landpattern (package:LandPattern) -> Null

  • Returns Null

Syntax

public pcb-component component :
  manufacturer = "Texas Instruments"
  mpn          = "FDC2214QRGH"

  pin-properties :
    [pin:Ref | pads:Int ... | side:Dir ]
    [i2c.scl | 1            | Left     ]
    [i2c.sda | 2            | Left     ]
    [CLKIN   | 3            | Left     ]
    [ADDR    | 4            | Left     ]
    [INTB    | 5            | Left     ]
    [SD      | 6            | Left     ]
    [VDD     | 7            | Left     ]
    [GND     | 8            | Left     ]
    [IN0A    | 9            | Right    ]
    [IN0B    | 10           | Right    ]
    [IN1A    | 11           | Right    ]
    [IN1B    | 12           | Right    ]
    [IN2A    | 13           | Right    ]
    [IN2B    | 14           | Right    ]
    [IN3A    | 15           | Right    ]
    [IN3B    | 16           | Right    ]

val lp = qfn-landpattern(0.5, 3.8, 16, 0.25, 0.4, [2.6 2.6])
assign-landpattern(lp)

Description

The assign-landpattern convenience function is a helper for mapping a landpattern to a pcb-component using the pin-properties table. The table must contain a pads column whose type is | pads: Int ...|, | pads: Ref ...| or |pads: Int|Ref ...|. Multiple entries in the pads column can be used to assign a component pin to multiple pads.

reference-prefix?

Get the reference prefix of a component, if it exists.

public defn reference-prefix? (c:Instantiable) -> String|False

  • Returns String|False

Syntax

pcb-module my-module :
  inst U : ocdb/components/abracon/AMB7/component(10.0e6)
  println(reference-prefix?(U))

Description

Looks up the value associated with an reference-prefix = ... statement in a pcb-component.

reference-prefix?

public defn reference-prefix? (obj:JITXObject) -> String|False

  • Returns String|False

via-diameter

Get the diameter of a pcb-via definition.

public defn via-diameter (obj:JITXDef) -> Double

  • Returns Double

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-diameter(th-via))

Description

The via-diameter introspection function returns the diameter of a pcb-via definition.

get-property

public defn get-property (obj:JITXObject|JITXDef, name:Symbol) -> ?

  • Returns ?

im-feeling-lucky

public defn im-feeling-lucky () -> Null

  • Returns Null

get-merged-physical-design-module

Obtain the physical-design-transformed "main" module of the current design.

public defn get-merged-physical-design-module () -> Instantiable

  • Returns Instantiable

Syntax

val new-module = get-merged-physical-design-module()

Description

Returns a new module which incorporates all of the physical design information incorporated into the "main" module of the current design.

instance-type

Determine if an instance is a component, module, or array.

public defn instance-type (obj:JITXObject) -> InstanceType

  • Returns InstanceType

Syntax

pcb-module my-module :
  inst X : my-component[10]
  print-def(instance-type(X))

Description

The instance-type introspection retrieves the type of an instance, represented as the enum InstanceType:

public defenum InstanceType :
  SingleComponent
  SingleModule
  InstanceArray

enable-spy

Dump the generated internal representation during compilation

public defn enable-spy () -> Null

  • Returns Null

Syntax

enable-spy()
evaluate(my-design)

Description

The enable-spy command is a debugging tool to dump the compiler's internal representation(s) into a human readable text form. It is generally only useful for analyzing internal compiler errors.

mpn?

Get the MPN of a component, if it exists.

public defn mpn? (c:Instantiable) -> String|False

  • Returns String|False

Syntax

pcb-module my-module :
  inst U : ocdb/components/abracon/AMB7/component(10.0e6)
  println(mpn?(U))

Description

Looks up the value associated with an mpn = ... statement in a pcb-component.

mpn?

public defn mpn? (obj:JITXObject) -> String|False

  • Returns String|False

via-tented

Get the tented sides of a pcb-via definition.

public defn via-tented (obj:JITXDef) -> Side|True|False

  • Returns Side|True|False

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-tented(th-via))

Description

The via-tented introspection function returns which sides of a pcb-via definition are tented. If the tented attribute is not specified, the default value is returned. See pcb-via documentation for more information.

nets

Get the nets of a module.

public defn nets (obj:JITXObject)

Syntax

pcb-module my-module :
  port p : power
  inst R1 : gen-res-cmp(1.0e3)
  inst R2 : gen-res-cmp(1.0e3)
  net my-net (R1.p[1], R2.p[1])
  net (R1.p[2], R2.p[2])
  net (R1.p[2], p.V-)

  ; Prints three net objects
  for n in nets(self) do :
    println(name(n))

Description

The nets introspection is useful for extracting all the net statements of a module. It's important to note that this corresponds to the individual net statements, and not the electrical concept of a "net". For example, the code snippet above will print out three unique net objects, even though we only have two electrical nets.

nets

public defn nets (def:Instantiable)

notify-vscode-of-loaded-jitx-shell

public defn notify-vscode-of-loaded-jitx-shell (filepath:String) -> Null

  • Returns Null

via-hole-diameter

Get the hole diameter of a pcb-via definition.

public defn via-hole-diameter (obj:JITXDef) -> Double

  • Returns Double

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-hole-diameter(th-via))

Description

The via-hole-diameter introspection function returns the hole diameter of a pcb-via definition.

pins

Get the pins associated with an object.

public defn pins (obj:JITXObject)

Syntax

val cmp = gen-res-cmp(1.0e3)
for p in pins(cmp) do :
  println(ref(p))

Description

The pins introspection is useful for extracting the pins of a component, bundle, or schematic symbol.

pins

public defn pins (def:Instantiable|Bundle|SchematicSymbol)

instances

Get the instances of a module.

public defn instances (obj:JITXObject)

Syntax

inside pcb-module :
  for r in [1.0e3, 2.0e3, 3.0e3] do :
    inst R : gen-res-cmp(r)

  for i in instances(self) do :
    if has-property?(i.resistance) :
      println("There is a resistor: %_ ohms." % [property(i.resistance)])

Description

The instances introspection returns a sequence of all the instances within a module. This is useful for checks and generators that need to loop over the instances of a module to find their properties, generate additional instances, and so on.

instances

public defn instances (def:Instantiable)

clear-dbquery-cache

Clear the cache on disk used for part queries with dbquery so that the parts gets refreshed next time the queries are run.

public defn clear-dbquery-cache () -> Null

  • Returns Null

make-node

public defn make-node (name:Symbol, type:PortType, public?:True|False)

make-node

public defn make-node (name:Symbol, type:PortType)

print-current-rules

public defn print-current-rules ()

via-in-pad

Get the via-in-pad attribute of a pcb-via definition.

public defn via-in-pad (obj:JITXDef) -> True|False

  • Returns True|False

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-in-pad(th-via))

Description

The via-in-pad introspection function returns whether a via definition is permitted inside a pad or not. If the via-in-pad attribute is not specified, the default value is returned. See pcb-via documentation for more information.

instance-definition

Get the pcb-* definition of an instance.

public defn instance-definition (obj:JITXObject) -> Instantiable

  • Returns Instantiable

Syntax

pcb-module my-module :
  inst X : my-component
  print-def(instance-definition(X))

Description

The instance-definition introspection retrieves the pcb-* definition that corresponds to a given component or module.

min-width

Compute the minimum width in a sequence of shapes.

public defn min-width (s:Seqable<Shape>) -> Double

  • Returns Double

Syntax

val r1 = loc(-0.5, 0.0) * Rectangle(2.0, 1.0)
val r2 = loc( 0.5, 0.0) * Rectangle(2.0, 1.0)
val mw = min-width([r1, r2])
println(mw)

Description

The minimum width is defined as the minimum length of a line you can draw inside the shape between two segments (on the boundary) with opposite directions and overlapping.

name

Get the name of an object

public defn name (def:JITXDef) -> String

  • Returns String

Syntax

pcb-component my-component :
  name = "My Awesome Component"

println(name(my-component))
; prints, "My Awesome Component"

Description

Every definition in JITX has an associated name. It may be overridden explicitly using the name = ... syntax, else it is inferred from the identifier given in the definition. The name (...) introspection function will lookup the associated name from a given definition

manufacturer?

Get the manufacturer name of a component, if it exists.

public defn manufacturer? (c:Instantiable) -> String|False

  • Returns String|False

Syntax

pcb-module my-module :
  inst U : ocdb/components/abracon/AMB7/component(10.0e6)
  println(manufacturer?(U))

Description

Looks up the value associated with an manufacturer = ... statement in a pcb-component.

manufacturer?

public defn manufacturer? (obj:JITXObject) -> String|False

  • Returns String|False

pose

Get the pose of a pad inside a pcb-landpattern.

public defn pose (l:JITXObject)

WARNING: pad is deprecated. Please use pad-def instead.

Syntax

val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20
for pad in pads(landpattern) do :
  println("There is a pad at: %_" % [pose(pad)])

Description

The pose introspection retrieves the Pose of a pad in a landpattern.

single-pin-nets

Get the nets of a module.

public defn single-pin-nets (obj:JITXObject)

Syntax

pcb-module my-module :
  inst R1 : gen-res-cmp(1.0e3)
  inst R2 : gen-res-cmp(1.0e3)
  net my-net (R1.p[1], R2.p[1])
  net my-single-net (R1.p[2])

  for n in public-nets(self) do :
    println(name(n))

Description

The single-pin-nets introspection is useful for extracting all the net statements of a module that contain only a single pin.

single-pin-nets

public defn single-pin-nets (def:Instantiable)

offset

Compute a shape that is "offset" from another by a fixed distance.

public defn offset (s:Shape, amount:Double) -> Shape

  • Returns Shape

Syntax

val rect = Rectangle(10.0, 10.0)
val offset-rect = offset(rect, 1.0)
println(offset-rect) ; Rectangle(11.0, 11.0)

Description

The offset command derives a new shape from an existing one using a factor to expand the dimensions in x/y directions. This is useful when creating new shapes that are a fixed size larger than some root shape.

pad

Get the pcb-pad definition of a pad in a landpattern.

public defn pad (l:JITXObject)

Syntax

val landpattern = ocdb/components/st-microelectronics/landpatterns/TSSOP20
for p in pads(landpattern) do :
  val def = pad(p)
  print-def(def)

Description

The pad introspection returns the pcb-pad definition of a landpattern pad. This is useful for writing landpattern checks that need to inspect the pad data, for example their layers.

ref

Get the associated Ref of an object instance.

public defn ref (a:JITXObject) -> Ref

  • Returns Ref

Syntax

pcb-module my-module :
  inst U1 : my-component

  ; Print out the Refs of the pins of a component
  for p in pins(U1) do :
    println(ref(p))

Description

Instances, ports, pins, and pads in the design hierarchy have an associated "reference" name, for example, my-module.U1.p[3]. The ref(...) introspection will look up the associated Ref value with any object, if it is assigned.

run-evals

Runs all eval-when blocks nested within module to return a newly evaluated Instantiable.

public defn run-evals (module:Instantiable) -> Instantiable

  • Returns Instantiable

Syntax

pcb-module main-module :
  eval-when has-property?(self.voltage) :
    println("Voltage assigned!")

defn assign-voltage () :
  inside pcb-module :
    property(self.voltage) = 3.3

val transformed-module = transform-module(assign-voltage, main-module)
val evaluated-module = run-evals(transformed-module)

Description

eval-when statements need to be driven by the design generator code. The run-evals command is used to control this.

topology-ends

Get the ends of a named topology.

public defn topology-ends (obj:JITXObject) -> KeyValue<JITXObject, JITXObject>

  • Returns KeyValue<JITXObject, JITXObject>

Syntax

pcb-module my-module :
  inst R1 : gen-res-cmp(1.0e3)
  inst R2 : gen-res-cmp(1.0e3)
  topology my-topo (R1.p[1] => R2.p[1])
  val ends:KeyValue<JITXObject,JITXObject> = topology-ends(my-topo)
  println("Topology goes from %_ to %_" % [key(ends) value(ends)])

Description

The topology-ends introspection is useful for extracting the start and end of a named topology object.

view-bom

View the bill of materials (BOM).

public defn view-bom (view:BOMViewMode = ?)

Syntax

view-bom(view:BOMViewMode = BOM-LAST)

Description

BOMViewMode is either BOM-STD: evaluate based on the criteria and display the result BOM-DIFF: evaluate based on the criteria and display the difference since the last version BOM-LAST: do not evaluate, just display the last version if no parameter is given, view-bom(BOM-LAST) is the default.

evaluate

Evaluates a definition, expanding its statements.

public defn evaluate (def:JITXDef) -> Null

  • Returns Null

Syntax

pcb-pad simple-pad :
  shape = Circle(1.0)
  apply-soldermask()

evaluate(simple-pad)

Description

The evaluate (...) introspection forces the expansion of a pcb-*** definition, including all of its generators. This is useful when writing unit test, or working on generators outside of an existing design.

via-type

Get the drill type of a pcb-via definition.

public defn via-type (obj:JITXDef) -> ViaDrillType

  • Returns ViaDrillType

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-type(th-via))

Description

The via-type introspection function returns the ViaDrillType of a pcb-via definition, which can be either MechanicalDrill or LaserDrill.

expand

Expand a shape by a fixed distance.

public defn expand (s:Shape, amount:Double) -> Shape

  • Returns Shape

Syntax

val shape = Rectangle(10.0, 10.0)
val expanded = expand(shape, 1.0)
println(expanded)

Description

The expand command computes an "expanded" shape, which is a shape that is exactly amount distance away from the perimeter of s. amount must be non-negative.

assign-pins

Explicitly run pin assignment before automatic placement, visualization, or export.

public defn assign-pins () -> Instantiable

  • Returns Instantiable

Syntax

pcb-module my-module :
  pin x
  supports gpio :
    gpio.gpio => x
  require mygpio: gpio from self

set-main-module(my-module)
val my-module-assigned = assign-pins()

Description

JITX will automatically run pin assignment prior to board placement, export, and visualization. Pin assignment can be run manually using the assign-pins function, which can be useful when running checks or debugging.

Running assign-pins?() instead of assign-pins will return False if there is no valid pin assignment.

import-cad

Import CAD projects from KiCAD or Altium.

public defn import-cad (input-dir:String, output-dir:String, cad:CadSoftware) -> ImportCadResult

  • Returns ImportCadResult

Syntax

defpackage import-script :
  import core
  import jitx
  import jitx/commands

import-cad("input-directory", "output-directory", Altium)

Optional field-mapping can be used to change property field names, used only in KiCad. Possible target Fields are "Name", "Manufacturer", "MPN", "Description", case-sensitive. For example, you can map "Field1" to "Manufacturer" and "Part Desc" to "Description" by

val mapping = [ "Field1" => "Manufacturer" "Part Desc" => "Description" ]
import-cad("input-design", "output-directory", Altium, field-mapping)

Description

The import-cad command is used to read KiCAD or Altium files from input-directory and generate JITX code in output-directory. The currently supported CadSoftware values are :

public defenum CadSoftware :
  Kicad ; Experimental v6 support
  Altium
Requirements
  • The inputdirectory must exist.
  • input may not be a symbolic link.
  • The output directory must not exist or be an empty directory
  • When importing a board, schematic, and netlist:
  • Reference designators in the project files must be consistent.
  • Nets on the board, in the schematic, and netlist must be consistent.
  • "Consistent" means components may not be present on the board or schematic that aren't in the other, nets on the board/schematic/netlist must be the same, etc.
  • Altium constraints :
  • Only files generated with the JITX Altium Extension will be imported. These are files with the following extensions :
    • (SCHLIB).JSON
    • (SCHDOC).JSON
    • (PRJPCB).JSON
    • (PCBLIB).JSON
    • (PCBDOC).JSON
  • Kicad constraints :
  • Only files of the following file extension will be imported :
    • kicad_mod
    • kicad_sym
    • kicad_pcb
    • kicad_sch
    • net
    • kicad_pro
    • fp-lib-table
  • Only Kicad 6 is supported.
  • A netlist (.net) file must be provided.
  • Only one .kicad_pcb, .kicad_pro, and .net file may exist in the input directory.
  • 3D Model Files:
  • only .step, .stp, and .wrl files will be copied to imported code.
  • BOM Files:
  • BOM files must be named jitx-import-bom.tsv and be of the correct schema

import-cad

public defn import-cad (input-dir:String, output-dir:String, cad:CadSoftware, field-mapping:False|Tuple<KeyValue<String, String>>) -> ImportCadResult

  • Returns ImportCadResult

set-export-schematic?

Set whether export-cad should generate schematic files.

public defn set-export-schematic? (b:True|False) -> Null

  • Returns Null

Syntax

set-export-schematic?(true) ; or false

Description

By default, the export command will generate a schematic. Use set-export-schematic? to control whether it is generated or not.

current-rules

Get the current design rules of the project

public defn current-rules () -> Rules

  • Returns Rules

Syntax

val rules = current-rules()

Description

The current-rules introspection returns the design rules that have been set with set-rules, or set-default-rules if set-rules has never been called. It fails if there are no design rules for the design.

view

View a landpattern, schematic symbol, or pcb-component.

public defn view (def:LandPattern, view-mode:ViewMode) -> Null

  • Returns Null

Syntax

; Default: update the view
view(ocdb/utils/symbols/resistor-sym)
; Visualize, panning to the center of the view and zooming to fit
view(ocdb/utils/symbols/resistor-sym, NewView)
; Visualize, but maintain the same pan/zoom state.
view(ocdb/utils/symbols/resistor-sym, UpdateView)

Description

The view command is used to visualize generated landpatterns, schematic symbols, or components. It will fail if passed a pcb-module or array of instantiables.

view

public defn view (def:SchematicSymbol, view-mode:ViewMode) -> Null

  • Returns Null

view

public defn view (def:Instantiable, view-mode:ViewMode) -> Null

  • Returns Null

view

public defn view (def:LandPattern) -> Null

  • Returns Null

view

public defn view (def:SchematicSymbol) -> Null

  • Returns Null

view

public defn view (def:Instantiable) -> Null

  • Returns Null

get-net

Find a net with a given name in a module.

public defn get-net (name:String) -> JITXObject

  • Returns JITXObject

Syntax

pcb-module my-module :
  inst R1 : gen-res-cmp(1.0e3)
  inst R2 : gen-res-cmp(1.0e3)
  net my-net (R1.p[1], R2.p[1])

  ; ...

  val my-net = get-net(my-module, "my-net")

Description

Sometimes nets are generated programmatically and it may not be possible to use the local identifier to lookup a net. For this purpose, the get-net introspection will search the net statements of the current module.

This function must be called inside pcb-module.

freeze-reference-designators

Freeze all the reference designators, so they will not be recomputed.

public defn freeze-reference-designators () -> Instantiable

  • Returns Instantiable

Syntax

val lowered-module = run-final-passes(module)
set-main-module(lowered-module)
set-main-module(freeze-reference-designators())

Description

The freeze-reference-designators command stops the JITX compiler from generating new reference designators for existing components in a design.

indices

Get the indices of an array of JITX objects.

public defn indices (obj:JITXObject) -> Seqable<Int>

  • Returns Seqable<Int>

Syntax

inside pcb-module :
  port p: pin[[1 2 3 5 7]]

  val indices = indices(p)

  for idx in indices do :
    val p* = p[idx]
    println(port-type(p*))

Description

Arrays of JITX objects can have custom indices. The indices (...) introspection is useful for extracting port/pin or instances indices for generators that may need to reference them.

get?

public defn get? (obj:JITXObject, index:Int) -> JITXObject|False

  • Returns JITXObject|False

get?

public defn get? (obj:JITXObject, name:Symbol|String) -> JITXObject|False

  • Returns JITXObject|False

get?

public defn get? (def:JITXDef, name:Symbol|String) -> JITXObject|False

  • Returns JITXObject|False

has-board?

Check if the board has been set.

public defn has-board? () -> True|False

  • Returns True|False

Syntax

println(has-board?())
set-board(ocdb/utils/defaults/default-board(4))
println(has-board?())

Description

The has-board? introspection is a convenience function to check if the board has been set by a call to set-board.

get-stackup

Retrieve the stackup of a Board.

public defn get-stackup (def:Board) -> Stackup

  • Returns Stackup

Syntax

pcb-stackup my-stackup :
  ...
pcb-board my-board:
  stackup = my-stackup
  ...

pcb-module main-module :
; Prints my-stackup
  println("Stackup: %_" % [get-stackup(get-board() as Board)])

set-board(my-board)
set-main-module(main-module)

Description

The get-stackup introspection returns the "stackup" property of a given pcb-board. Its return value is a Stackup JITX definition.

component-instances

Get the instances of a module that are components (not modules).

public defn component-instances (obj:JITXObject)

Syntax

pcb-module sub-module :
  ..
pcb-module my-module :
  inst sub : sub-module
  inst cmp : gen-res-cmp(1.0e3)

; This will only print "my-module.cmp" as it is the only
; instance of the module that is **not** another module.
for cmp in component-instances(my-module) do :
  println(ref(cmp))

Description

The component-instances introspection returns a sequence of instances of a module that are components, that is to say that they are instances at the bottom of the design hierarchy (not contained within submodules of the module).

component-instances

public defn component-instances (def:Instantiable)

get-board

Get the current pcb-board, if it exists

public defn get-board () -> Board|False

  • Returns Board|False

Syntax

val current-board? = get-board()

Description

The get-board introspection returns a board that has been set by set-board, if it exists.

get-def-string

Get the string representation of the ESIR definition as ASCII.

public defn get-def-string (def:JITXDef) -> String

  • Returns String

Returns the same string that print-def prints.

Syntax

pcb-module my-module :
  ...

val my-module-str = get-def-string(my-module)

get-def-string will return the fully expanded definition string. JITX definitions include pcb-board, pcb-module, pcb-rules, pcb-stackup, pcb-component, pcb-pad, pcb-landpattern, etc.

explorer-json

public defn explorer-json (def:JITXDef) -> JSON

  • Returns JSON

stop-timer

public defn stop-timer (name:String) -> Null

  • Returns Null

set-board

Sets the pcb-board object used by the current design.

public defn set-board (board:Board)

Syntax

pcb-board my-board :
  ...

set-board(my-board)

Description

This specifies the pcb-board which defines the stackup, board outline, and signal boundary of the physical board used in the design.

Multi-board designs require separate calls to set-current-design, set-board, etc.

package-poses

Get the package poses associated with a pcb-component definition.

public defn package-poses (obj:JITXDef) -> Tuple<PackagePose>

  • Returns Tuple<PackagePose>

Syntax

val package-poses = package-poses(my-module)
do(println, package-poses)
print-def(inst(package-poses[0]))

Description

The package-poses introspection function returns the pose information given explicitly to instances in a pcb-module definition. The returned object is

public defstruct PackagePose :
  inst:Instance
  pose:Pose|False
  side:Side
  anchor:Instance|False

component-status?

Retrieve the component in-BOM and on-board status of a component instance (deprecated)

public defn component-status? (obj:JITXObject) -> [ComponentBOMStatus, ComponentBoardStatus]

  • Returns [ComponentBOMStatus, ComponentBoardStatus]

view-board

Visualize the generated board.

public defn view-board (view-mode:ViewMode) -> Null

  • Returns Null

Syntax

; Default: update the view
view-board()
; Visualize, panning to the center of the view and zooming to fit
view-board(NewView)
; Visualize, but maintain the same pan/zoom state.
view-board(UpdateView)

Description

The view-board command is used to visualize the generated circuit board.

view-board

public defn view-board () -> Null

  • Returns Null

expand-or-shrink

Expand or shrink a shape by a fixed distance.

public defn expand-or-shrink (s:Shape, amount:Double) -> Shape

  • Returns Shape

Syntax

val shape = Rectangle(10.0, 10.0)
val expanded = expand-or-shrink(shape, 1.0)
println(expanded)
val shrunken = expand-or-shrink(shape, -1.0)
println(shrunken)

Description

The expand-or-shrink command computes an "expanded" or a "shrunken" version of the shape s. If amount is positive, s will be expanded, otherwise if amount is negative, s will be shrunken. This command behaves exactly like expand when amount is positive.

get-boundary

Retrieve the boundary of a Board.

public defn get-boundary (def:Board) -> Shape

  • Returns Shape

Syntax

pcb-board my-board:
  boundary = my-shape
  ...

pcb-module main-module :
  println("Board boundary: %_" % [get-boundary(get-board() as Board)])

set-board(my-board)
; Prints the value of `my-shape`, a Shape object
set-main-module(main-module)

Description

The get-boundary introspection returns the "boundary" field of a given pcb-board. Its return value is a Shape.

set-bom-design-quantity

Set the quantity of boards to manufacturer when generating a BOM.

public defn set-bom-design-quantity (quantity:Int) -> Null

  • Returns Null

Syntax

set-bom-vendors([
  "JLCPCB",
  "LCSC",
  "DigiKey",
  "Future",
  "Mouser",
  "Arrow",
  "Avnet"
  "Newark"
])

set-bom-design-quantity(100)

;write the BOM files to disk
export-bom()

Description

The set-bom-design-quantity is used to define the number of boards to manufacturer. It is combined with the vendors list to automatically find parts from the vendors lists in the appropriate quantity to assemble the generated board design.

connected-pins

Return the pins connected to an existing pin.

public defn connected-pins (obj:JITXObject) -> Tuple<Pin>

  • Returns Tuple<Pin>

Syntax

pcb-module my-module :
  pin gnd
  public inst R: gen-res-cmp(1.0e3)[4]
  for n in 0 to 4 do :
    net (gnd, R[n].p[1])

  val connected = connected-pins(gnd)
  for p in connected do :
    println(ref(p))

Description

The connected-pins introspection returns a Tuple of all the pins connected to the argument, excluding the argument pin itself. This is useful for writing connectivity checks.

make-inst

public defn make-inst (name:Symbol, type:InstantiableType, public?:True|False)

save-timing-report

public defn save-timing-report (filename:String) -> Null

  • Returns Null

set-ipc-info

public defn set-ipc-info (ipc-info:IpcInfo) -> Null

  • Returns Null

min-space

Compute the minimum space in a sequence of shapes.

public defn min-space (s:Seqable<Shape>) -> Double

  • Returns Double

Syntax

val shapes = [
  loc(1.0, 1.0) * Circle(0.001)
  loc(2.0, -1.0) * Circle(0.01)
]

println(min-space(shapes))

Description

The minimum space in a set of shapes is defined as the smallest distance between non overlapping sides of the shapes. This command is useful when writing DRC checks.

pad-def

Get the pcb-pad definition of a pad in a landpattern.

public defn pad-def (l:JITXObject)

This is an alias for the pad introspection, since pad is a reserved keyword in pcb-landpattern contexts.

Syntax

pcb-landpattern lp (pad-size:Dims) :
  pad p[1] : smd-pad(pad-size)
  pad p[2] : smd-pad(pad-size)
  for p in pads(self) do :
    val def = pad-def(p)
    ; Prints "SMD"
    println(pad-type(def))

Description

The pad-def introspection returns the pcb-pad definition of a landpattern pad. This is useful for writing landpattern checks that need to inspect the pad definition.

set-bom-metrics

set-bom-metrics(metrics: Tuple<BOMMetric>)

public defn set-bom-metrics (metrics:Tuple<BOMMetric>|False)

set the metrics of the bill of materials (BOM).

Syntax

set-bom-metrics([
  BOMMetric(BOMMetricLineItems, "Line Items"),
  BOMMetric(BOMMetricComponentCount, "Components"),
  BOMMetric(BOMMetricTotalCost, "Cost")
])

Description

Set the metrics and their display names in the BOM visualizer.

If not set, the above metrics are used by default.

set-rules

Set the design rules for the current design.

public defn set-rules (rules:Rules)

Syntax

pcb-rules jlc-pcb-rules :
  ...

set-rules(jlc-pcb-rules)

Description

The design rules takes the name of a pcb-rules as an argument and configures the design rules used for generators and checks in the current design. This will be cleared on calls to set-current-design.

all-connected-items

Returns a list of all the connected items to a pin or net.

public defn all-connected-items (m:Self|Instantiable) -> Tuple<ConnectedItems>

  • Returns Tuple<ConnectedItems>

Syntax

pcb-module my-module :
  val N = 100
  inst R: gen-res-cmp(1.0e3)[N]
  net gnd ()
  for n in 0 to 100 do :
    net (R.p[1], gnd)

  val connected-items = all-connected-items(self)
  for item in connected-items :
    for n in nets(item) do :
      println(ref(n))

Description

The all-connected-items introspection returns a tuple of ConnectedItems which represent all the connected items in a module. This is primarily used when writing checks that need to observe the full design, for example checking if specific component pins are net'd together or pins on nets have the appropriate properties.

The ConnectedItems structure contains the following fields :

public defstruct ConnectedItems :
  nets: Tuple<Net>
  module-pins: Tuple<Pin>
  component-pins: Tuple<Pin>
  abstract-pins: Tuple<Pin>

get-export-backend

Get the currently set CAD exporter backend.

public defn get-export-backend ()

Syntax

set-current-design("jitx-design")
get-export-backend()

Description

The get-export-backend command returns which CAD backend export-cad is currently set to use.

get-min-width

Get the minimum width rule for a given LayerSpecifier.

public defn get-min-width (l:LayerSpecifier|LayerIndex) -> Double

  • Returns Double

Syntax

val min-cu-width = get-min-width(LayerIndex(0))

Description

get-min-width is a convenience function around clearance and current-rules introspections for quickly retrieving the DRC parameters for minimum width on a given layer. Currently, only copper, silkscreen, and solder mask opening widths are supported.

via-backdrill

DEPRECATED!: Use via-backdrills instead

public defn via-backdrill (obj:JITXDef) -> BackdrillSet|False

  • Returns BackdrillSet|False

This version returns false instead of an empty set ;

reference-designator

Get the reference designator of a component.

public defn reference-designator (obj:JITXObject) -> String

  • Returns String

Syntax

pcb-module my-module :
  inst R : gen-res-cmp(1.0e3)
  println(reference-designator(R))

Description

The reference-designator retrieves the the reference designator of a component in the design, which is either generated automatically or defined explicitly using the reference-designator(object) = ... syntax.

optimized-mode?

Checks whether the algorithmic core has been compiled

public defn optimized-mode? () -> True|False

  • Returns True|False

with optimizations enabled.

Syntax

optimized-mode?()

Description

The optimized-mode? command returns true if the algorithmic core has been compiled with optimizations enabled, or false otherwise.

clearances

Get the clearances specified by a Rules object

public defn clearances (r:Rules) -> Tuple<RuleClearance>

  • Returns Tuple<RuleClearance>

Syntax

for clearance in clearances(current-rules()) :
  println(clearance)

Description

The clearances introspection returns the design rules as a list of RuleClearance objects, containing their name and value.

view-sub-schematic

Visualize the generated sub-schematic for a list of nets and instances.

public defn view-sub-schematic (objects:Tuple<JITXObject>, schematic-group?:True|False) -> Null

  • Returns Null

Nets can be single nets, net arrays or bundle nets.

Instances can be component or module instances. They can be single instances or instance arrays.

Syntax

; Objects given to view-sub-schematic need to reference the design main module.
set-main-module(main-module)

; Visualize a list of nets and instances. Default: no schematic groups.
view-sub-schematic([main-module.gnd, main-module.P3V3])
; Visualize a list of nets and instances with schematic groups.
view-sub-schematic([main-module.gnd, main-module.P3V3], true)
; Visualize a single net or instance. Default: no schematic groups.
view-sub-schematic(main-module.sensors)
; Visualize a single net or instance with schematic groups.
view-sub-schematic(main-module.sensors, true)

Description

The view-sub-schematic command is used to visualize a subset of the schematic of the generated board.

view-sub-schematic

public defn view-sub-schematic (object:JITXObject, schematic-group?:True|False) -> Null

  • Returns Null

view-sub-schematic

public defn view-sub-schematic (object:JITXObject) -> Null

  • Returns Null

view-sub-schematic

public defn view-sub-schematic (objects:Tuple<JITXObject>) -> Null

  • Returns Null

emodel?

Get the emodel of a component or the component of an inst, if it exists.

public defn emodel? (c:Instantiable) -> EModel|False

  • Returns EModel|False

Syntax

pcb-module my-module :
  inst U : chip-resistor(1000.0)
  println(emodel?(U))

Description

Looks up the value associated with an emodel = ... statement in a pcb-component.

emodel?

public defn emodel? (obj:JITXObject) -> EModel|False

  • Returns EModel|False

transform-component

Applies body on component to return a newly transformed Instantiable.

public defn transform-component (body:() -> ?, module:Instantiable) -> Instantiable

  • Returns Instantiable

Example

pcb-component my-component :
  ; ...

val my-modified-component = within transform-component(my-component) :
  inside pcb-component :
    override landpattern = my-new-landpattern
    override symbol = my-new-symbol
    property(self.transformed) = true

This example returns a modified component which has the same name, descriptions, pins, and so on, of the original component, but now has a different landpattern and symbol, and a new property. Note the use of the override keyword to allow setting the landpattern and symbol after they have already been set.

Because override is not yet implemented for many component attributes which can only be set once, such as name, description, mpn, manufacturer, etc., these will only be able to be set if the original component definition did not set them. override is also not yet implemented for symbols (setting multiple symbol units on one component).

transform-component is mainly intended to be used with modify-components.

compare-cad

public defn compare-cad (input-dir:String, output-dir:String, cad:CadSoftware) -> ImportCadResult

  • Returns ImportCadResult

set-property

public defn set-property (obj:JITXObject, name:Symbol, value:JITXValue) -> Null

  • Returns Null

via-start

Get the start layer of a pcb-via definition.

public defn via-start (obj:JITXDef) -> LayerIndex

  • Returns LayerIndex

Syntax

pcb-via th-via :
  type = MechanicalDrill
  start = LayerIndex(0, Top)
  stop = LayerIndex(0, Bottom)
  diameter = 0.6
  hole-diameter = 0.3

println(via-start(th-via))

Description

The via-start introspection function returns the start LayerIndex of a pcb-via definition.

print-def

Print the ESIR definition as ASCII. Not very human readable.

public defn print-def (def:JITXDef)

Use Design Explorer to see this data structured for human consumption.

Syntax

pcb-module my-module :
  ...

print-def(my-module)

print-def will print out the fully expanded definition. JITX definitions include pcb-board, pcb-module, pcb-rules, pcb-stackup, pcb-component, pcb-pad, pcb-landpattern, etc.

set-bom-columns

set-bom-columns(cols: Tuple<BOMColumn>)

public defn set-bom-columns (cols:Tuple<BOMColumn>|False)

set the columns of the bill of materials (BOM).

Syntax

set-bom-columns([
  BOMColumn(BOMFieldStatus, "Status", 10.0)
  BOMColumn(BOMFieldInsts, "References", 10.0)
  BOMColumn(BOMFieldMPN, "MPN", 10.0)
  BOMColumn(BOMFieldDescription, "Description", 20.0)
  BOMColumn(BOMFieldVendor, "Supplier", 10.0)
  BOMColumn(BOMFieldQuantity, "Qty", 5.0)
  BOMColumn(BOMFieldSubtotal, "Total", 5.0)
  BOMColumn(BOMFieldPreferred, "Preferred", 5.0)
])

Description

Set the columns to display in BOM Visualizer and to export. If none is set, JITX default columns are used.

length

Get the length of an instance or bundle array.

public defn length (obj:JITXObject) -> Int

  • Returns Int

Syntax

  inst R : gen-res-cmp(1.0e3)[5]
  println(length(R))

Description

Bundles and instances may be created in arrays, the length introspection will return the length of those arrays.

originating-instantiable

Get the inst definition that created an instance.

public defn originating-instantiable (obj:JITXObject) -> Instantiable

  • Returns Instantiable

Syntax

  inst i: gen-res-cmp(3.0)
  print-def(originating-instantiable(i))

Description

The originating-instantiable retrieves the Instantiable that was used to create an instance in a module.

pad-shape

Get the shape of a pcb-pad definition.

public defn pad-shape (p:Pad|Self)

Syntax

pcb-pad my-pad :
  shape = Circle(1.0)
  type  = SMD

println(pad-shape(my-pad))

Description

The pad-shape introspection returns the shape of a pad that has been defined using the shape = ... statement.

datasheet?

Get the datasheet name of a component, if it exists.

public defn datasheet? (c:Instantiable) -> String|False

  • Returns String|False

Syntax

pcb-module my-module :
  inst U : ocdb/components/abracon/AMB7/component(10.0e6)
  println(datasheet?(U))

Description

Looks up the value associated with an datasheet = ... statement in a pcb-component.

datasheet?

public defn datasheet? (obj:JITXObject) -> String|False

  • Returns String|False

dims

Compute the x/y dimensions of a shape.

public defn dims (s:Shape) -> Dims

  • Returns Dims

Syntax

val shape = Union([
  Rectangle(10.0, 10.0)
  loc(2.0, 0.0 * Circle(10.0, 10.0)
])

println(dims(shape))

Description

The dims command takes a shape as an argument and computes the x/y dimensions (bounding box) of the complete shape. This is useful for simple collision detection and size computation.

clear-default-rules

This has been deprecated; JITX now includes a default rule set.

public defn clear-default-rules ()

Syntax

  clear-default-rules()

Description

Removes default rules if they are set. This is primarily used for testing.

run-checks

Runs all checks statements, saves results in a file named filename, and returns a CheckSummary.

public defn run-checks (filename:String) -> CheckSummary

  • Returns CheckSummary

Syntax

pcb-check check-5V (a:JITXObject) :
  #CHECK(has-property?(a.voltage))
  #CHECK(property(a.voltage) is Double)
  #CHECK(property(a.voltage) == 5.0)

pcb-module mymodule :
  pin x
  property(x.voltage) = 5.0
  check check-5V(self)

set-main-module(mymodule)
run-checks("5V-check.txt")

Description

The run-checks command is used to run pcb-checks on a design. Checks are arbitrary DRC, ERC, or other static analyses defined in code to validate a design programmatically.

transform-module

Applies body on module to return a newly transformed Instantiable. This is how to run custom passes on your design module.

public defn transform-module (body:() -> ?, module:Instantiable) -> Instantiable

  • Returns Instantiable

Syntax

pcb-module main-module :
  ; ...

defn generate-power () :
  inside pcb-module :
    ; ...

val module-with-power = transform-module(generate-power, main-module)

Description

The transform-module function takes two arguments, a function body and pcb-module module. The compiler will apply body to the module

containing-instance

Get the instance that an object is contained within, if it exists.

public defn containing-instance (obj:JITXObject) -> Instance|False

  • Returns Instance|False

Syntax

pcb-module sub-module :
  public inst R : gen-res-cmp(1.0e3)

pcb-module parent-module :
  inst i: sub-module

  println(ref(containing-instance(i.R)))

Description

The containing-instance introspection retrieves the instance that owns another instance. This is useful for generators and checks that might not have access to the original identifier of a given instance.

current-rules?

Get the current design rules.

public defn current-rules? () -> Rules|False

  • Returns Rules|False

This has been deprecated; use current-rules() instead.

Syntax

val no-rules = current-rules?()
println(no-rules) ; false
set-rules(ocdb/utils/defaults/default-rules)
val rules = current-rules?()
println(rules) ; Rules

Description

Like current-rules, current-rules? returns the design rules of the project if they have been set, but does not crash if they are not available and returns false otherwise.