From 2ec66255e3c9eff3ed53dbf4e1994c192d72e6d8 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Tue, 28 Dec 2021 00:44:59 +0100 Subject: [PATCH] perf optimization in graph drawing --- src/draw.c | 8 ++- src/xschem.h | 4 +- xschem_library/examples/mos_power_ampli.sch | 17 ++++- xschem_library/ngspice/solar_panel.sch | 9 ++- xschem_library/rom8k/rom8k.sch | 75 ++++++++++++++++++--- 5 files changed, 94 insertions(+), 19 deletions(-) diff --git a/src/draw.c b/src/draw.c index 342897db..1775ed7e 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1499,7 +1499,7 @@ void read_binary_block(FILE *fd) /* read buffer */ tmp = my_calloc(1405, xctx->nvars, sizeof(double *)); /* allocate storage for binary block */ - if(!xctx->values) xctx->values = my_calloc(118, xctx->nvars, sizeof(RAW_FLOAT *)); + if(!xctx->values) xctx->values = my_calloc(118, xctx->nvars, sizeof(SPICE_DATA *)); for(p = 0 ; p < xctx->nvars; p++) { my_realloc(372, &xctx->values[p], (size + xctx->npoints[xctx->datasets]) * sizeof(double)); } @@ -1793,10 +1793,12 @@ static void get_y_points(int v, int first, int last, double cy, double dy, doubl int p; double yy; int poly_npoints = 0; + double s1 = 1.0 / n_nodes; + double s2 = s1 * .66; for(p = first ; p < last; p++) { yy = xctx->values[v][p]; if(digital) { - yy = ydelta * wcnt / n_nodes + yy / n_nodes/1.5; + yy = ydelta * wcnt * s1 + yy *s2; } /* Build poly y array. Translate from graph coordinates to {x1,y1} - {x2, y2} world. */ yarr[poly_npoints] = W_Y(yy); @@ -1997,7 +1999,7 @@ void draw_graph(int c, int i, int flags) if(unitx != 1.0) my_snprintf(tmpstr, S(tmpstr), "%s[%c]", stok ? stok : "" , unitx_suffix); else my_snprintf(tmpstr, S(tmpstr), "%s", stok ? stok : ""); draw_string(wave_color, NOW, tmpstr, 2, 1, 0, 0, - rx1 + 2 + rw/n_nodes * wcnt, ry2-1, txtsizelab, txtsizelab); + rx1 + 2 + rw / n_nodes * wcnt, ry2-1, txtsizelab, txtsizelab); } /* draw node labels in graph */ if(unity != 1.0) my_snprintf(tmpstr, S(tmpstr), "%s[%c]", ntok, unity_suffix); diff --git a/src/xschem.h b/src/xschem.h index 462fcee4..64ce49f9 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -332,7 +332,7 @@ do { \ #define INT_BUS_WIDTH(x) ( (int)( (BUS_WIDTH) * (x) ) == 0 ? 1 : (int)( (BUS_WIDTH) * (x) ) ) /* set do double if you need more precision at the expense of memory */ -#define RAW_FLOAT float +#define SPICE_DATA float typedef struct @@ -693,7 +693,7 @@ typedef struct { int undo_initialized; /* read raw files (draw.c) */ char **names; - RAW_FLOAT **values; + SPICE_DATA **values; int nvars; int *npoints; int datasets; diff --git a/xschem_library/examples/mos_power_ampli.sch b/xschem_library/examples/mos_power_ampli.sch index 9642c6c5..f50f04b1 100644 --- a/xschem_library/examples/mos_power_ampli.sch +++ b/xschem_library/examples/mos_power_ampli.sch @@ -1,4 +1,4 @@ -v {xschem version=2.9.9 file_version=1.2 } +v {xschem version=3.0.0 file_version=1.2 } G {} K {} V {} @@ -6,6 +6,20 @@ S {} E {} L 15 270 -460 340 -390 {} L 15 270 -330 340 -390 {} +B 2 1520 -750 2440 -70 {flags=1 +y1=-51.8382 +y2=48.1618 +divy=4 +subdivy=4 +x1=0.0157884 +x2=0.0164453 +divx=8 +subdivx=1 +node="tcleval(v($\{path\}ga) v($\{path\}gb) v($\{path\}outi)) v(vnn))" +color="7 8 10 11 12 13 14 15 16 17" +dataset=0 +unitx=m +} T {ANALOG AUDIO AMPLIFIER N-Channel only power stage} 430 -270 0 0 0.5 0.5 {layer=8} N 180 -500 180 -470 {lab=E9} @@ -421,3 +435,4 @@ C {launcher.sym} 770 -150 0 0 {name=h4 descr="View Raw file" tclcommand="textwindow $netlist_dir/[file tail [file rootname [ xschem get schname 0 ] ] ].raw" } +C {spice_probe.sym} 790 -600 0 0 {name=p60 analysis=tran voltage=-0.1364} diff --git a/xschem_library/ngspice/solar_panel.sch b/xschem_library/ngspice/solar_panel.sch index 6ee526e8..70eed863 100644 --- a/xschem_library/ngspice/solar_panel.sch +++ b/xschem_library/ngspice/solar_panel.sch @@ -41,7 +41,8 @@ L 8 810 -610 830 -610 {} B 2 1110 -950 1530 -800 {flags=1 y1 = 0 y2 = 20 -divy = 10 +divy = 5 +subdivy=1 x1=0 x2=0.0002 divx=9 @@ -50,7 +51,8 @@ color="11 18" unitx=m subdivx=4} B 2 1110 -790 1530 -660 {flags=1 y1 = 0 y2 = 20 -divy = 10 +divy = 6 +subdivy=1 x1=0 x2=0.0002 divx=8 @@ -58,7 +60,8 @@ node="v(panel)" unitx=m} B 2 1110 -650 1530 -520 {flags=1 y1 = 0 y2 = 4 -divy = 8 +divy = 4 +subdivy=1 x1=0 x2=0.0002 divx=8 diff --git a/xschem_library/rom8k/rom8k.sch b/xschem_library/rom8k/rom8k.sch index 1c96bb18..5d0a7a24 100644 --- a/xschem_library/rom8k/rom8k.sch +++ b/xschem_library/rom8k/rom8k.sch @@ -31,8 +31,8 @@ B 2 1840 -360 2890 -280 {flags=1 y1 = -0.0039 y2 = 0.87 divy = 1 -x1=1.28096e-07 -x2=1.98813e-07 divx=10 +x1=1.26223e-07 +x2=2.06222e-07 divx=10 node=" v(ldbl[0]) v(ldbl[16]) v(ldbl[32]) v(ldbl[1]) v(ldbl[17]) v(ldbl[33]) @@ -43,9 +43,10 @@ B 2 1840 -920 2890 -710 {flags=1 digital=0 y1 = -0.00091 y2 = 1.5 +subdivy=4 divy = 4 -x1=1.28096e-07 -x2=1.98813e-07 +x1=1.26223e-07 +x2=2.06222e-07 divx=10 subdivx=4 node="v(ldcp) v(ldyms[4]) v(ldyms[5]) v(ldyms[6]) v(ldyms[7])" @@ -57,8 +58,8 @@ y2 = 1.6 divy = 3 subdivy=1 subdivx = 4 -x1=1.28096e-07 -x2=1.98813e-07 divx=10 +x1=1.26223e-07 +x2=2.06222e-07 divx=10 node=" v(ldcp) v(ldwl[0]) v(ldwl[1]) v(ldwl[2]) v(ldwl[3]) @@ -72,8 +73,8 @@ B 2 1840 -120 2890 -40 {flags=1 y1 = -0.021 y2 = 0.9 divy = 1 -x1=1.28096e-07 -x2=1.98813e-07 divx=10 +x1=1.26223e-07 +x2=2.06222e-07 divx=10 node="v(ldymsref)" color=3 unitx=n subdivy=4} B 2 1840 -710 2890 -360 {flags=1 @@ -81,8 +82,8 @@ digital=1 y1 = 0 y2 = 1.5 divy = 1 -x1=1.28096e-07 -x2=1.98813e-07 divx=10 +x1=1.26223e-07 +x2=2.06222e-07 divx=10 node="v(ldcp) v(lden) v(ldprech) --- v(ldl1x[0]) v(ldl1x[1]) v(ldl1x[2]) v(ldl1x[3]) @@ -94,6 +95,60 @@ color=4 xcolor="5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 3 4 5 6" unitx=n } +B 2 1840 -1030 2890 -920 {flags=1 +y1 = 0 +y2 = 2 +divy = 2 +x1=1.26223e-07 +x2=2.06222e-07 +divx=8 +comm="example of using tcl to replace the path + with $path variable automatically" +node="tcleval(v(xctrl.ldcp_ref) v(xctrl.ldprechref))" +color="16 11 15" +} +B 2 1840 -1120 2890 -1030 {flags=1 +y1 = 0 +y2 = 2 +divy = 2 +x1=1.26223e-07 +x2=2.06222e-07 +divx=8 +comm="example of using tcl to replace the path + with $path variable automatically" +node="tcleval(v(xctrl.ldcp_ref) v(xctrl.ldcpb))" +color="16 11 15" +} +B 2 1840 -1210 2890 -1120 {flags=1 +y1 = 0 +y2 = 2 +divy = 2 +x1=1.26223e-07 +x2=2.06222e-07 +divx=8 +comm="example of using tcl to replace the path + with $path variable automatically" +node="tcleval(v(xctrl.ldcp_ref) v(xctrl.ldouti) v(xctrl.ldoutib))" +color="16 11 15" +} +B 2 1840 -1500 2890 -1320 {flags=1 +y1 = 0 +y2 = 2 +divy = 4 +x1=1.26223e-07 +x2=2.06222e-07 +divx=8 +node="v(xsa[0].ldqi) v(xsa[0].ldqib) v(xsa[0].ldsali)" +color="16 11 15"} +B 2 1840 -1320 2890 -1210 {flags=1 +y1 = 0 +y2 = 2 +divy = 2 +x1=1.26223e-07 +x2=2.06222e-07 +divx=8 +node="v(xsa[0].ldqiii) v(xsa[0].ldqii) v(xsa[0].ldsali)" +color="16 11 15"} B 7 950 -250 980 -80 {} B 7 1150 -250 1180 -80 {} B 21 10 -970 240 -750 {}