Skip to main content

Concepts

Here are the important concepts to understand about Circuitscript.

Circuits as graphs

All components and their pins are nodes in a graph. The commands defined in circuitscript help to describe the connectivity (edges) between component pins. However, instead of just listing the edges directly, the commands provide the designer a way to describe the circuit and help to build up the reasoning behind the circuit.

The traditional netlist focused on the connectivity, but adds additional complexity as the designer has to manage the node numbers (add page to illustrate). With a graph based approach, the relationship between components are defined and there is no need for designers to manage these node numbers.

Components and pins

A component is a node in the circuit graph. This component is created from a component definition and has a fixed number of pins.

For example: R1 = res(10k) creates a component with symbol class res and assigns it to the variable R1. The res symbol class defines a symbol that has 2 pins and this can be used to represent a resistor component. The standard library lib.cst includes other components that are commmonly used in schematics.

import lib

at res(10k)

12R110k

Nets

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.

Execution cursor and state

Circuits are built programmatically by adding and connecting different pins of symbols and wires. The execution cursor is the current point for executing commands and is defined as the current (component, pin) location.

For example:

import lib

R1 = res(10k)
R2 = res(20k)
at R1 pin 2
wire right 100
to R2 = res(20k)

12R110k12R220k

Explanation of each line:

  1. import lib - imports the common library
  2. R1 = res(10k) - creates a resistor R1 with value of 10k.
  3. R2 = res(20k) - creates a resistor R2 with value of 20k
  4. at R1 pin 2 - moves the "cursor" to pin 2 of R1.
  5. wire right 100 - draws a line of length 100 units. Cursor is moved to end of wire.
  6. to R2 pin 1 - pin 1 of R2 is connected to the cursor. Cursor remains at R2 pin 1

Wires

Wires between component pins are manually specified. This provides greater control in how the graphical schematics are displayed.

Example:

import lib 

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

at v5v
wire right 100
add res(10k)
wire right 200
add res(20k)
wire right 100
to gnd

5V12R110k12R220kGND