faster jump table in plot_raw_custom_data(), added simulation->add waveform reload launcher

This commit is contained in:
Stefan Frederik 2022-10-03 11:15:14 +02:00
parent 64d947a9dd
commit 4bbed85d23
4 changed files with 73 additions and 31 deletions

View File

@ -661,37 +661,39 @@ static double ravg_store(int what , int i, int p, int last, double value)
}
#define STACKMAX 200
#define PLUS -2
#define MINUS -3
#define MULT -4
#define DIVIS -5
#define POW -6
#define SIN -7
#define COS -8
#define EXP -9
#define LN -10
#define LOG10 -11
#define ABS -12
#define SGN -13
#define SQRT -14
#define TAN -15
#define INTEG -34
#define AVG -35
#define DERIV -36
#define EXCH -37
#define DUP -38
#define RAVG -39 /* running average */
#define DB20 -40
#define DERIV0 -41 /* derivative to first sweep variable, regardless of specified sweep_idx */
#define PREV -42 /* previous point */
#define DEL -43 /* delay by an anount of sweep axis distance */
#define NUMBER -60
#define SPICE_NODE 1
#define NUMBER 2
#define PLUS 3
#define MINUS 4
#define MULT 5
#define DIVIS 6
#define POW 7
#define SIN 8
#define COS 9
#define EXP 10
#define LN 11
#define LOG10 12
#define ABS 13
#define SGN 14
#define SQRT 15
#define TAN 16
#define INTEG 17
#define AVG 18
#define DERIV 19
#define EXCH 20
#define DUP 21
#define RAVG 22 /* running average */
#define DB20 23
#define DERIV0 24 /* derivative to first sweep variable, regardless of specified sweep_idx */
#define PREV 25 /* previous point */
#define DEL 26 /* delay by an anount of sweep axis distance */
#define ORDER_DERIV 1 /* 1 or 2: 1st order or 2nd order differentiation. 1st order is faster */
typedef struct {
int i;
double d;
int idx; /* spice index node */
double prevy;
double prevprevy;
double prev;
@ -773,7 +775,8 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
my_free(645, &ntok_copy);
return -1; /* no data found in raw file */
}
stack1[stackptr1].i = idx;
stack1[stackptr1].i = SPICE_NODE;
stack1[stackptr1].idx = idx;
stackptr1++;
}
dbg(1, " plot_raw_custom_data(): stack1= %d\n", stack1[stackptr1 - 1].i);
@ -785,8 +788,8 @@ int plot_raw_custom_data(int sweep_idx, int first, int last, const char *expr)
if(stack1[i].i == NUMBER) { /* number */
stack2[stackptr2++] = stack1[i].d;
}
else if(stack1[i].i >=0 && stack1[i].i < xctx->graph_nvars) { /* spice node */
stack2[stackptr2++] = xctx->graph_values[stack1[i].i][p];
else if(stack1[i].i == SPICE_NODE && stack1[i].idx < xctx->graph_nvars) { /* spice node */
stack2[stackptr2++] = xctx->graph_values[stack1[i].idx][p];
}
if(stackptr2 > 1) { /* 2 argument operators */

View File

@ -1355,7 +1355,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(argc==7)
/* pos sym_name x y rot */
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), (short)atoi(argv[5]),
/* flip prop draw first ito_push_undo */
/* flip prop draw first to_push_undo */
(short)atoi(argv[6]),NULL, 3, 1, 1);
else if(argc==8)
place_symbol(-1, argv[2], atof(argv[3]), atof(argv[4]), (short)atoi(argv[5]),

View File

@ -5725,6 +5725,17 @@ proc build_widgets { {topwin {} } } {
xschem raw_read $netlist_dir/[file tail [file rootname [xschem get current_name]]].raw
}
$topwin.menubar.simulation.menu add command -label {Add waveform graph} -command {xschem add_graph}
$topwin.menubar.simulation.menu add command -label {Add waveform reload launcher} -command {
if { [file exists [abs_sym_path devices/launcher.sym]] } {
xschem place_symbol devices/launcher.sym "name=h5\ndescr=\"load waves\"
tclcommand=\"xschem raw_read \$netlist_dir/[file tail [file rootname [xschem get current_name]]].raw tran\"
"
} else {
xschem place_symbol launcher.sym "name=h5\ndescr=\"load waves\"
tclcommand=\"xschem raw_read \$netlist_dir/[file tail [file rootname [xschem get current_name]]].raw tran\"
"
}
}
$topwin.menubar.simulation.menu add checkbutton -label "Live annotate probes with 'b' cursor" \
-variable live_cursor2_backannotate
$topwin.menubar.simulation.menu add command -label "Annotate Operating Point into schematic" \

View File

@ -1,8 +1,29 @@
v {xschem version=2.9.5_RC5 file_version=1.1}
v {xschem version=3.1.0 file_version=1.2
}
G {}
K {}
V {}
S {}
E {}
B 2 970 -610 1960 -220 {flags=graph
y1=-93
y2=1.3
ypos1=0
ypos2=2
divy=5
subdivy=1
unity=1
x1=-1.00075
x2=7.45087
divx=10
subdivx=8
node="\\"out db20()\\""
color=4
dataset=-1
unitx=1
logx=1
logy=0
}
N 100 -550 100 -520 {lab=IN}
N 650 -510 670 -510 {lab=OUT}
N 270 -550 430 -550 {lab=PLUS}
@ -20,6 +41,7 @@ N 800 -530 850 -530 {lab=0}
N 100 -550 130 -550 {lab=IN}
C {code_shown.sym} 20 -320 0 0 {name=CONTROL vhdl_ignore=true place=end value=".control
listing e
save all
run
write hpf.raw
let response = db(v(out)/v(in))
@ -28,7 +50,7 @@ C {code_shown.sym} 20 -320 0 0 {name=CONTROL vhdl_ignore=true place=end value=".
gnuplot hpf response xlog
.endc
"}
C {code_shown.sym} 280 -310 0 0 {name=DIRECTIVES vhdl_ignore=true place=end value=".ac oct 100 0.1 1k
C {code_shown.sym} 390 -310 0 0 {name=DIRECTIVES vhdl_ignore=true place=end value=".ac oct 100 0.1 100meg
.param pi = 3.1415926
.param Q = 1
.param freq = 20
@ -150,3 +172,9 @@ C {gnd.sym} 850 -460 0 0 {name=l3 lab=VEE}
C {vdd.sym} 850 -600 0 0 {name=l4 lab=VCC}
C {gnd.sym} 800 -530 0 0 {name=l6 lab=0}
C {opin.sym} 670 -510 0 0 {name=p9 lab=OUT}
C {launcher.sym} 1115 -175 0 0 {name=h5
descr="load ngspice waves"
tclcommand="
xschem raw_read $netlist_dir/hpf.raw ac
"
}