Roel Jordans
01/09/2025, 11:53 AMRoel Jordans
01/09/2025, 11:57 AMStefan Schippers
01/10/2025, 4:51 AMres_high_po_chain.sch
for the schematic reference the following is used:
res_high_po_chain.tcl( @n )
where res_high_po_chain.tcl
is a script that outputs a valid schematic file on standard output xschem recognizes this syntax as a call to a generator script.
The reference is transformed to res_high_po_chain.tcl 15
where 15 is the substituted value for @n
the command res_high_po_chain.tcl 15
is executed and the output from the command is captured by xschem and used as the actual schematic. Try the files below, remember to set the tcl script access mode to executable.Stefan Schippers
01/10/2025, 4:54 AMRoel Jordans
01/10/2025, 8:27 AMRoel Jordans
01/10/2025, 9:26 AMStefan Schippers
01/10/2025, 12:18 PMschematic="res_high_po_chain.tcl(@n , @model )"
Since @n
and @model
parameters are used a space separator must be used: @n, @model
will substitute the value of n,
, while @n ,
will substitute the value of @n
. Xschem allows almost all characters in the definition of @
variables, since guys doing PCB design use almost all characters for their designs and also schematics imported from other tools (expecially synthesis tools) use almost all sort of strange characters. So comma, brackets and more are all allowed. var(2,3)=10
is valid and @var(2,3)
will replace with 10 in a symbol / subcircuit.Roel Jordans
01/10/2025, 12:42 PMStefan Schippers
01/10/2025, 12:58 PM$
for $var
substitution, [cmd]
for cmd
execution. Xschem itself uses @
for variable substitution. I used @
to avoid collisions with the commonly used $
character used by shell languages. Ngspice frequently uses @
and [ ]
to look up model parameters, so if a spice node like i(@m.x1.xm1.msky130_fd_pr__nfet_01v8_lvt[id])
needs to be processed by Tcl and xschem some special care must be used to avoid xschem to replace the @m.x1.xm1.msky130_fd_pr__nfet_01v8_lvt[id]
variable and /or tcl to execute the [id]
command. I have seen designs where instance and circuit net names contain spaces and backslashes. Some tools require escape characters \
when identifiers contain forbidden characters. Moreover, Spice and VHDL netlists are case insensitive while Verilog is case sensitive. So it is a complex world, and when fixing one thing it is very easy to break another one.Roel Jordans
01/10/2025, 1:45 PMRoel Jordans
01/20/2025, 3:21 PM.
I've modified the example to take a second argument with the width of the resistor so that my TCL generator can output the right model for the resistor. Attached is a version where I've temporarily replaced the @W
in the generator call with 0p35
to avoid the problem. This generates a usable netlist but requires me to keep track of the width parameter in two places.
Do you have a suggestion on how to avoid this so that I can use @W
as a parameter to the generator even though this will have a .
character in its value?Stefan Schippers
01/20/2025, 4:12 PMStefan Schippers
01/20/2025, 4:54 PMres_high_po_chain.tcl( @n , @W )
is translated to res_high_po_chain.tcl( 15 , 0.69 )
and then mangled to res_high_po_chain_tcl_15_0_69
which is a valid SPICE identifier.
Let me know if it works.Stefan Schippers
01/20/2025, 5:10 PMRoel Jordans
01/21/2025, 7:23 PMStefan Schippers
01/22/2025, 12:32 PM