Closed qpwo closed 9 months ago
This is available as a simple tcl command:
in the xschem terminal:
xschem get current_name
returns the schematic name, like solar_panel.sch
file rootname [xschem get current_name]
returns solar_panel
So in your code block you can use this command to write the raw file with the same name as the schematic:
Note the whole command is wrapped inside a tcleval(....)
construct. This will invoke a round of tcl substitution to resolve $tcl_variables
and [tcl commands]
I will also add a sch_basename
global TCL variable so the expression [file rootname [xschem get current_name]].raw
can be simplified as $sch_basename
. Escaping can be used if you want a literal $something that must not be substituted, like \\$something.raw
(for the very nerd: double escaping is needed because the whole string is included in double quotes (value="..."
) and \"
can be used to enter a literal quote, so a \\
will enter a literal \
that will escape the $ to the TCL interpreter. If you don't get this quirk no problem, just ignore this detail :-) )
Great seems to work:
Oh great I don't even need the [return ...]
.
Correct, the whole expression inside tcleval( ..... ) is passed to a tcl subst
command. The subst command takes the input string and returns the string with [ ....] replaced with the return value of the associated tcl command and $xxx as the value for xxx variable.
sotcleval(test [return tcl] $x)
will return test tcl substitution
, assuming x
variable is set to substitution
Problem: I copy or rename circuit1.sch to circuit2.sch and make some changes and do my sim but the plots aren't working because I was doing
write circuit1.raw
!Solution: Xschem could set
$base
and your ngspice code can saywrite {$base}.raw
. Then schematics are fully copyable/renamable!I have my simulator in xschem configured to
But if
$base
was enabled by default then the skywater example schematics could use it and it would be a lot easier for newbs to copy them and make changes.