Scripting Schematic and SmartSPICE operations

(Caution: this note assumes you have LISP installed and wish to run Schemata and SmartSPICE from a LISP program – this is not useful for a typical user.  However, there are some examples like “access” that can just be typed into the smartspice I/O window)

 

I have provided some simple tools to control Schemata and SmartSPICE from a LISP script. These are easy to use but some of them assume you have Allegro LISP installed

 

Wrap any commands in a "with-schematic-smartspice" and they will be executed in SmartSPICE:

 

(with-schematic-smartspice ()

  (command :source)

  (command "ac dec 1 0.01meg 0.1meg")

  ...

  )

 

The above executes the command source (which sends the schematic you are looking at to SmartSPICE and sources it. Then it runs the command "ac dec 1 0.01meg 0.1meg" just as though you had typed it to SmartSPICE.

 

You can access and change any parameter in the Schematic like this:

 

(access "GCA" "M1" :width)

=> "2.5u"

 

This command accesses M1 in the Schematic called "GCA" and shows you its width. To change its width use the LISP setf function like this:

 

(setf (access "GCA" "M1" :width) "3.0u")

=> "3.0u"

(access "GCA" "M1" :width)

>= "3.0u"

 

The width will be changed in the Schematic if you go to "GCA" and hit refresh (the R key) you will see the width of M1 is now 3.0u.

 

You can access and change voltages on nodes by naming the node like this:

 

(access "GCA" "In" :spice-spec)

=> "1.0 AC 1"

(setf (access "GCA" "In" :spice-spec) "1.0 PULSE(1 2 1n 0.1n 0.1n 10n 20n)")

=> "1.0 PULSE(1 2 1n 0.1n 0.1n 10n 20n)"

 

Using these simple tools you can plot some spice results, change some values and plot again:

 

 (with-schematic-smartspice ()

   (command :source)

   (command "ac dec 10 10k 10g")

   (command ":plot V(out) :pane "test1")

   (setf (access "MySchematic" "R1" :values) "1.045k")

   (command :source)

   (command "ac dec 10 10k 10g")

   (command ":plot V(out) :pane "test with 1.045k")

   )