Tim Edwards
02/19/2024, 3:03 PM${name}
; for the equations I introduced a stack notation with the odd looking variables ${*}
${/}
${+}
${-}
and suchlike; so ${A} ${B} ${+} 2 ${/}
would resolve to (A+B)/2
. This notation can get rather cumbersome. I think I can replace the whole system with just a call to xschem to generate a netlist if I pass all the variable names to xschem, but I would also need to replace the stack notation stuff. I think it is a straightforward matter of replacing it with calls to tcleval
. I've attached a schematic for a CACE testbench. How should I write the device parameters with tcleval
(or any other syntax that works) so that xschem would do the work of variable substitution and produce the output I'm currently doing with python code inside CACE? (FYI, the variable notation on pins is also being handled inside CACE but I do not think this is needed and I can dispense with it altogether).)Stefan Schippers
02/20/2024, 1:43 AMtcleval(...)
the content ...
will be passed to the tcl subst
command. That means all tcl $variables
are replaced with their values and all tcl [commands]
are replaced with the command return values.
If I set a voltage source value attribute this way: value="tcleval([expr {$val + 3}])"
the voltage source will be netlisted with a value of 6 if val
is a tcl variable set to 3
.
SInce $
and []
have a special meaning to tcleval() they need to be escaped if you want them literally: if you need a literal [
use `\\[`:
value="tcleval(\\$val=$val)" --> $val=3
The following line:
meas tran vhigh1 FIND V(inp) WHEN V(out) = ${Vvdd} 2 ${/} CROSS=1
will change to:
meas tran vhigh1 FIND V(inp) WHEN V(out) = [expr ${Vvdd} / 2.0] CROSS=1
if you wrap the whole text inside tcleval():
value="tcleval(.control
tran [expr ${risetime} * 2. / 100.] [expr ${risetime} * 4.]
...
meas tran vhigh1 FIND V(inp) WHEN V(out) = [expr ${Vvdd} / 2.0] CROSS=1
...
)"
Tim Edwards
02/20/2024, 1:51 AMxschem --command "set temperature 100; set vvdd 3.0; ..."
?Stefan Schippers
02/20/2024, 1:56 AMxschem --tcl 'set var1 xxx; set var2 yyy; ...' cmrr.sch
or
xschem --script setvars.tcl cmrr.sch
if variable definitions are in an external fileStefan Schippers
02/20/2024, 1:58 AMxschem --command 'set var1 xxx; set var2 yyy; ...' cmrr.sch
Stefan Schippers
02/20/2024, 2:03 AM--preinit 'tcl_commands'
: do these commands in a very early stage, before loading xschemrc
--tcl 'tcl_commands'
: do the commands right after sourcing xschemrc, before building the GUI
`--command 'tcl_commands'`: do the commands after completing startup. This makes all 'xschem' tcl commands available.
Setting TCL variables can be done with any of the 3 above.Tim Edwards
02/20/2024, 2:06 AM--script
option, because then I can optionally keep the script files and use them to re-run the simulation without having to reconstruct a long command line.
The goal is to get away from a "special format" in the schematic and have a schematic that can be netlisted and simulated with or without the CACE system.Stefan Schippers
02/20/2024, 2:08 AM.tran 'risetime / 50' 'risetime *4'
Tim Edwards
02/20/2024, 2:09 AMStefan Schippers
02/20/2024, 2:10 AMStefan Schippers
02/20/2024, 2:10 AMStefan Schippers
02/20/2024, 2:25 AMset debug_tcleval 1
If you redraw the screen failing tcl evaluations will be printed:
tclpropeval2 warning: DC ${Vvsdd} --> can't read "Vvsdd": no such variableLinen is a search-engine friendly community platform. We offer integrations with existing Slack/Discord communities and make those conversations Google-searchable.
Powered by