doc/sch updates (.op backannotation)

This commit is contained in:
stefan schippers 2023-01-15 00:25:57 +01:00
parent 2fa0155ca6
commit 2d30755f79
4 changed files with 37 additions and 12 deletions

View File

@ -48,18 +48,40 @@ lappend tcl_files ${XSCHEM_SHAREDIR}/ngspice_backannotate.tcl
** referenced file in netlist/simulation directory. ** referenced file in netlist/simulation directory.
.include "models_cmos_example.txt" .include "models_cmos_example.txt"
.control .control
<span style="color: red;"> op </span> <span style="color: red;white-space: pre;">op
<span style="color: red;"> save all </span> save all
<span style="color: red;"> write cmos_example.raw </span> write cmos_example.raw</span>
.endc .endc
</pre> </pre>
<p> <p>
The important parts are in red in above text. This ensures all variables are saved into the raw file. The important parts are in red in above text. This ensures all variables are saved into the raw file.
These instructions are for an interactive ngspice run.<br> These instructions are for an interactive ngspice run.<br>
You may have other simulations saved in the raw file (dc, tran, ac) however one operating point
must also be present:
</p>
<pre class="code">
.temp 30
** models are generally not free: you must download
** SPICE models for active devices and put them into the below
** referenced file in netlist/simulation directory.
.include "models_cmos_example.txt"
.control
save all
dc vplus 2.3 2.7 0.001
write cmos_example.raw
set appendwrite
<span style="color: red;white-space: pre;">op
save all
write cmos_example.raw</span>
.endc
</pre>
<p>
When done open the <kbd>Simulation-&gt; Configure simulators and tools</kbd> dialog box and ensure the When done open the <kbd>Simulation-&gt; Configure simulators and tools</kbd> dialog box and ensure the
<kbd>Ngspice</kbd> simulator is selected (not Ngspice batch). Also ensure the spice netlist mode is <kbd>Ngspice</kbd> simulator is selected (not Ngspice batch). Also ensure the spice netlist mode is
selected (<kbd>Options -&gt; Spice netlist</kbd>). selected (<kbd>Options -&gt; Spice netlist</kbd>).<br>
</p> </p>
<img src="backannotation2.png"> <img src="backannotation2.png">
<h3> SIMULATION </H3> <h3> SIMULATION </H3>
@ -82,8 +104,12 @@ points=1, vars=38, datasets=1
xschem [~] xschem [~]
</pre> </pre>
<p> <p>
If there are no errors we are ready and set. If there are no errors we are ready and set.<br>
you can load also a specific file:
</p> </p>
<pre class="code">
xschem [~] xschem annotate_op $netlist_dir/cmos_example_ngspice.raw
</pre>
<h3> ANNOTATION </H3> <h3> ANNOTATION </H3>
<p> <p>
@ -93,7 +119,6 @@ xschem [~]
In addition to specific probe elements also net labels will show voltage values and In addition to specific probe elements also net labels will show voltage values and
ammeters / voltage sources will show currents. ammeters / voltage sources will show currents.
</p> </p>
<p> <p>
To ensure all currents are saved modify the <kbd>STIMULI</kbd> attributes as follows: To ensure all currents are saved modify the <kbd>STIMULI</kbd> attributes as follows:
</p> </p>
@ -121,8 +146,6 @@ write cmos_example.raw
<img src="backannotation9.png"> <img src="backannotation9.png">
<p> <p>
Run again the simulation and the <kbd>xschem annotate_op</kbd> command and values will be updated. Run again the simulation and the <kbd>xschem annotate_op</kbd> command and values will be updated.
If you enable <kbd>View -&gt; Show hidden texts</kbd> net labels, voltage sources and ammeters will also show
voltages and currents.
</p> </p>
<img style="box-shadow:none;" src="backannotation10.png"> <img style="box-shadow:none;" src="backannotation10.png">
<p> <p>

View File

@ -933,11 +933,13 @@ static int try_dll_or_so(int logdepth, int is_dll, const char *lib_ldflags, cons
lib_filename = file_name(libname); lib_filename = file_name(libname);
lib_dirname = dir_name(libname); lib_dirname = dir_name(libname);
len = strlen(lib_filename) - strlen(libname_ext);
if (!is_dll) { if (!is_dll) {
len = strlen(lib_filename) - strlen(libname_ext);
for (ii=3; ii<len; ++ii) for (ii=3; ii<len; ++ii)
lib_filename[ii-3] = lib_filename[ii]; lib_filename[ii-3] = lib_filename[ii];
lib_filename[len-3] = 0; lib_filename[len-3] = 0;
} else {
lib_filename[len] = 0;
} }
app_ldflags_new = str_concat("", "-L", lib_dirname, " -l", lib_filename, app_ldflags_new = str_concat("", "-L", lib_dirname, " -l", lib_filename,

View File

@ -133,7 +133,6 @@ int find_fs_findnextfile(const char *name, int logdepth, int fatal)
char *test_c = char *test_c =
NL "#include <stdlib.h>" NL "#include <stdlib.h>"
NL "#include <stdio.h>" NL "#include <stdio.h>"
NL "#include <windows.h>"
NL "int main(int argc, char *argv[]) {" NL "int main(int argc, char *argv[]) {"
NL " WIN32_FIND_DATA fd;" NL " WIN32_FIND_DATA fd;"
NL " HANDLE h;" NL " HANDLE h;"
@ -156,7 +155,7 @@ int find_fs_findnextfile(const char *name, int logdepth, int fatal)
logprintf(logdepth, "find_fs_findnextfile: trying to find FindNextFile...\n"); logprintf(logdepth, "find_fs_findnextfile: trying to find FindNextFile...\n");
logdepth++; logdepth++;
if (try_icl(logdepth, "libs/fs/findnextfile", test_c, NULL, NULL, NULL)) return 0; if (try_icl(logdepth, "libs/fs/findnextfile", test_c, "#include <windows.h>", NULL, NULL)) return 0;
return try_fail(logdepth, "libs/fs/findnextfile"); return try_fail(logdepth, "libs/fs/findnextfile");
} }

View File

@ -162,7 +162,7 @@ device="ceramic capacitor" net_name=true}
C {lab_pin.sym} 500 -430 0 0 {name=p12 lab=G net_name=true} C {lab_pin.sym} 500 -430 0 0 {name=p12 lab=G net_name=true}
C {launcher.sym} 700 -60 0 0 {name=h1 C {launcher.sym} 700 -60 0 0 {name=h1
descr=Backannotate descr=Backannotate
tclcommand="xschem annotate_op"} tclcommand="xschem annotate_op $\{netlist_dir\}/cmos_example_ngspice.raw"}
C {launcher.sym} 700 -110 0 0 {name=h2 C {launcher.sym} 700 -110 0 0 {name=h2
descr="View raw file" descr="View raw file"
tclcommand="textwindow $netlist_dir/cmos_example.raw"} tclcommand="textwindow $netlist_dir/cmos_example.raw"}
@ -1558,6 +1558,7 @@ value=".temp 30
save all save all
op op
write cmos_example_ngspice.raw write cmos_example_ngspice.raw
set appendwrite
* tran 1n 300n * tran 1n 300n
dc vplus 2.3 2.7 0.001 dc vplus 2.3 2.7 0.001
write cmos_example_ngspice.raw write cmos_example_ngspice.raw