<@U01819B63HP>: I am looking for a way to plot a ...
# xschem
t
@Stefan Schippers: I am looking for a way to plot a 2-dimensional sweep in xschem (without resorting to an external tool like octave to generate the plots). I know of two ways to get the data for a 2D sweep, but I can only get ngspice to produce a meaningful plot for one of those methods, and I can't get xschem to produce a meaningful plot for either one. Example with sweep over voltage and temperature for a transistor characteristic:
Copy code
.control
save all
set temp=27
dc VDD 0 1 0.01
write BG3_ZTC_1v8_lvt_X.raw
reset
set temp=100
dc VDD 0 1 0.01
set appendwrite
write BG3_ZTC_1v8_lvt_X.raw
* plot dc1.i(VID1) dc2.i(VID1)
.endc
With the above control block, the plot command (uncommented) works, and reading back the raw file and issuing the same plot command works. However, an attempt to do the plot in xschem just produces an error complaining that the raw file cannot be read, with the message
Copy code
Xschem requires all datasets to be saved with identical and same number of variables
There is a mismatch, so this and following datasets will not be read
Raw file data read: /home/tim/.xschem/simulations/BG3_ZTC_1v8_lvt_X.raw
points=101, vars=8, datasets=1 sim_type=dc
(xschem schematic attached) The other method would be to let ngspice do the 2D sweep:
Copy code
dc TEMP 27 100 73 VDD 0 1 0.01
When I do that, all the correct data is in the raw file, but it's all in one vector and I can't figure out how to get the plot to separate the two variables. Is there a known solution to this problem? I'm guessing that there is one involving the
set curplot
command. Managing plots in ngspice doesn't seem to be terribly well documented. . .
s
@Tim Edwards the
reset
command resets also the
save all
keyword, as a result the second run has only 2 vars saved (voltage source currents). The updated schematic does the job, (see the syntax for accessing individual datasets in graphs: "node%dataset") please check.
t
@Stefan Schippers: Ah, I did not know that about
reset
. That does explain the problem; thanks for the help!
s
@Tim Edwards Multiple runs (from a same raw file) in Xschem are organized in memory as an array of vectors, where each vector has elements in consecutive memory locations (so displaying all values of all runs for a single simulation node requires accessing consecutive memory addresses). This is done to maximize cache locality (the in-memory data layout is actually the transpose of the binary raw file data layout), and works well if all runs have the same number of variables (but may have different # of points) . If different runs have different number of saved nodes the best approach is to save in different files, in this case there are no special requirements.
t
@Stefan Schippers: Quick question: Was the
node%dataset
notations for graphs added to xschem recently? I'm doing some back-and-forth here helping Phil Allen with xschem details (you might have noticed his name on the schematic). He's not getting the suffix notation to work. It could be a typo or something in the schematic (I haven't seen his latest version of the schematic), but then he also mentioned using the menu option "Unload/load spice .raw file" to load the graphs, and I have not seen that menu option in recent versions of xschem. Which leads to a second question: What happened to that menu option? Was it deprecated in favor of the "Load graph" symbol?
s
@Tim Edwards the node%n syntax was added on Oct 13 2023:
Copy code
commit 617e6b3b8d5d0bfe82dedd60f8cdb5bca469a682
Author: stefan schippers <stefan.schippers@gmail.com>
Date:   Fri Oct 13 15:51:51 2023 +0200

    update live backannotation if "a" and "b" cursors are swapped, syntax node%n is now allowed to plot only dataset "n" of the node. Update html docs and example autozero_comp circuit
The Load/Unload is gone (Toggle buttons are not a very good choice in general) and a better menu is added to the Waves button. This was done on Nov.9 2023. So yes, Phil Allen xschem is rather old. A simple Load/Unload button does not work well if the raw file contains multiple simulations (OP, DC, TRAN, ...), in this case the type of analysis to load must be specified.
t
@Stefan Schippers: Thanks, as always!