better handle operating point clear / update when switching / reading / clearing raw files. dont use operating point data (ngspice::ngspice) above the hierarchy level where raw file has been loaded.

This commit is contained in:
stefan schippers 2023-10-29 14:04:52 +01:00
parent b680f5da20
commit d776d6a351
5 changed files with 54 additions and 21 deletions

View File

@ -519,6 +519,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> abort_operation</kbd></li><pre>
@ -677,6 +678,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> draw_window </kbd> direct draw into window </li>
<li><kbd> first_sel </kbd> get data about first selected object </li>
<li><kbd> fix_broken_tiled_fill </kbd> get drawing method setting (for broken GPUs) </li>
<li><kbd> fix_mouse_coord </kbd> get fix_mouse_coord setting (fix for broken RDP)</li>
<li><kbd> format </kbd> alternate format attribute to use in netlist (or NULL) </li>
<li><kbd> graph_lastsel </kbd> number of last graph that was clicked </li>
<li><kbd> gridlayer </kbd> layer number for grid </li>
@ -1182,6 +1184,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> constrained_move </kbd> set constrained move (1=horiz, 2=vert, 0=none) </li>
<li><kbd> draw_window </kbd> set drawing to window (1 or 0) </li>
<li><kbd> fix_broken_tiled_fill </kbd> alternate drawing method for broken GPUs </li>
<li><kbd> fix_mouse_coord </kbd> fix for wrong mouse coords in RDP software </li>
<li><kbd> format </kbd> set name of custom format attribute used for netlisting </li>
<li><kbd> header_text </kbd> set header metadata (used for license info) </li>
<li><kbd> hide_symbols </kbd> set to 0,1,2 for various hiding level of symbols </li>
@ -1323,6 +1326,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
Unselect everything. If draw is given and set to '0' no drawing is done </pre>
<li><kbd> update_all_sym_bboxes</kbd></li><pre>
Update all symbol bounding boxes (useful if show_pin_net_names is set) </pre>
<li><kbd> update_op</kbd></li><pre>
update tcl ngspice::ngspice array data from raw file point 0 </pre>
<li><kbd> view_prop</kbd></li><pre>
View attributes of selected element (read only)
if multiple selection show the first element (in xschem array order) </pre>
@ -1393,7 +1398,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
</ul>

View File

@ -818,7 +818,7 @@ int raw_read(const char *f, Raw **rawptr, const char *type)
/* what == 1: read another raw file and switch to it (make it the current one)
* what == 2: switch raw file. If filename given switch to that one, else switch to next
* what == 3: remove a raw file. If no filename given remove all, keep current in xctx->raw
* what == 3: remove a raw file. If no filename given remove all
* what == 4: print info
* what == 5: switch back to previous
* return 1 if sucessfull, 0 otherwise
@ -910,6 +910,7 @@ int extra_rawfile(int what, const char *file, const char *type)
for(i = 0; i < xctx->extra_raw_n; i++) {
free_rawfile(&xctx->extra_raw_arr[i], 0);
}
tcleval("array unset ngspice::ngspice_data");
xctx->raw = NULL;
xctx->extra_prev_idx = 0;
xctx->extra_idx = 0;
@ -936,6 +937,7 @@ int extra_rawfile(int what, const char *file, const char *type)
if(xctx->extra_raw_n) {
xctx->raw = xctx->extra_raw_arr[0];
} else {
tcleval("array unset ngspice::ngspice_data");
xctx->raw = NULL;
}
} else ret = 0;
@ -957,6 +959,27 @@ int extra_rawfile(int what, const char *file, const char *type)
return ret;
}
int update_op()
{
int res = 0, p = 0, i;
tcleval("array unset ngspice::ngspice_data");
if(xctx->raw && xctx->raw->values) {
tclsetvar("rawfile_loaded", "1");
xctx->raw->annot_p = 0;
for(i = 0; i < xctx->raw->nvars; ++i) {
char s[100];
res = 1;
xctx->raw->cursor_b_val[i] = xctx->raw->values[i][p];
my_snprintf(s, S(s), "%.4g", xctx->raw->values[i][p]);
dbg(1, "%s = %g\n", xctx->raw->names[i], xctx->raw->values[i][p]);
tclvareval("array set ngspice::ngspice_data [list {", xctx->raw->names[i], "} ", s, "]", NULL);
}
tclvareval("set ngspice::ngspice_data(n\\ vars) ", my_itoa( xctx->raw->nvars), NULL);
tclvareval("set ngspice::ngspice_data(n\\ points) 1", NULL);
}
return res;
}
/* Read data organized as a table
* First line is the header line containing variable names.
* data is presented in column format after the header line

View File

@ -260,7 +260,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* into schematic */
else if(!strcmp(argv[1], "annotate_op"))
{
int i;
char f[PATH_MAX + 100];
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc > 2) {
@ -274,23 +273,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
tclsetvar("rawfile_loaded", "0");
extra_rawfile(3, NULL, NULL);
free_rawfile(&xctx->raw, 1);
tcleval("array unset ngspice::ngspice_data");
raw_read(f, &xctx->raw, "op");
if(xctx->raw && xctx->raw->values) {
tclsetvar("rawfile_loaded", "1");
xctx->raw->annot_p = 0;
for(i = 0; i < xctx->raw->nvars; ++i) {
char s[100];
int p = 0;
xctx->raw->cursor_b_val[i] = xctx->raw->values[i][p];
my_snprintf(s, S(s), "%.4g", xctx->raw->values[i][p]);
dbg(1, "%s = %g\n", xctx->raw->names[i], xctx->raw->values[i][p]);
tclvareval("array set ngspice::ngspice_data [list {", xctx->raw->names[i], "} ", s, "]", NULL);
}
tclvareval("set ngspice::ngspice_data(n\\ vars) ", my_itoa( xctx->raw->nvars), NULL);
tclvareval("set ngspice::ngspice_data(n\\ points) 1", NULL);
draw();
}
update_op();
draw();
}
/* arc
@ -3102,15 +3087,20 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
} else {
ret = extra_rawfile(2, NULL, NULL);
}
update_op();
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else if(argc > 2 && !strcmp(argv[2], "info")) {
ret = extra_rawfile(4, NULL, NULL);
} else if(argc > 2 && !strcmp(argv[2], "switch_back")) {
ret = extra_rawfile(5, NULL, NULL);
update_op();
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else if(argc > 2 && !strcmp(argv[2], "clear")) {
if(argc > 3) ret = extra_rawfile(3, argv[3], NULL);
else ret = extra_rawfile(3, NULL, NULL);
if(argc > 3) {
ret = extra_rawfile(3, argv[3], NULL);
} else {
ret = extra_rawfile(3, NULL, NULL);
}
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
} else {
err = 1;
@ -3232,6 +3222,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
int res = 0;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(sch_waves_loaded() >= 0) {
tcleval("array unset ngspice::ngspice_data");
extra_rawfile(3, NULL, NULL);
free_rawfile(&xctx->raw, 1);
tclsetvar("rawfile_loaded", "0");
@ -4825,6 +4816,16 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
/* update_op
* update tcl ngspice::ngspice array data from raw file point 0 */
else if(!strcmp(argv[1], "update_op"))
{
int ret;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
ret = update_op();
Tcl_SetResult(interp, my_itoa(ret), TCL_VOLATILE);
}
else { cmd_found = 0;}
break;
case 'v': /*----------------------------------------------*/

View File

@ -1210,6 +1210,7 @@ extern char *base64_encode(const unsigned char *data, const size_t input_length,
extern unsigned char *ascii85_encode(const unsigned char *data, const size_t input_length, size_t *output_length);
extern int get_raw_index(const char *node);
extern void free_rawfile(Raw **rawptr, int dr);
extern int update_op();
extern int extra_rawfile(int what, const char *f, const char *type);
extern int raw_read(const char *f, Raw **rawptr, const char *type);
extern int table_read(const char *f);

View File

@ -915,6 +915,7 @@ proc ngspice::get_current {n} {
set path [string range [xschem get sch_path] 1 end]
# skip hierarchy components above the level where raw file has been loaded.
# node path names to look up in raw file begin from there.
if { [xschem get currsch] < $raw_level} { return {}}
set skip 0
while { $skip < $raw_level } {
regsub {^[^.]*\.} $path {} path
@ -957,6 +958,7 @@ proc ngspice::get_current {n} {
proc ngspice::get_diff_voltage {n m} {
set raw_level [xschem get raw_level]
set path [string range [xschem get sch_path] 1 end]
if { [xschem get currsch] < $raw_level} { return {}}
# skip hierarchy components above the level where raw file has been loaded.
# node path names to look up in raw file begin from there.
set skip 0
@ -988,6 +990,7 @@ proc ngspice::get_diff_voltage {n m} {
proc ngspice::get_voltage {n} {
set raw_level [xschem get raw_level]
set path [string range [xschem get sch_path] 1 end]
if { [xschem get currsch] < $raw_level} { return {}}
# skip hierarchy components above the level where raw file has been loaded.
# node path names to look up in raw file begin from there.
set skip 0
@ -1023,6 +1026,7 @@ proc update_schematic_header {} {
proc ngspice::get_node {n} {
set raw_level [xschem get raw_level]
set path [string range [xschem get sch_path] 1 end]
if { [xschem get currsch] < $raw_level} { return {}}
# skip hierarchy components above the level where raw file has been loaded.
# node path names to look up in raw file begin from there.
set skip 0