From f53bc2c6b7f6770f60af0374a74a85387614e65e Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 25 Mar 2024 22:28:29 +0100 Subject: [PATCH] second round of additions to improve auto_hilight_graph_nodes --- src/draw.c | 8 ++++-- src/hilight.c | 36 ++++++++++++++++++++------ xschem_library/examples/poweramp.sch | 2 +- xschem_library/ngspice/delta_sigma.sch | 21 ++++++++------- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/draw.c b/src/draw.c index 8e2408c1..29de0296 100644 --- a/src/draw.c +++ b/src/draw.c @@ -3632,10 +3632,14 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct) if(strpbrk(express, " \n\t")) { expression = 1; } - if(!expression && tclgetboolvar("auto_hilight_graph_nodes")) { - hilight_graph_node(express, wc); + } + if(raw && raw->values && tclgetboolvar("auto_hilight_graph_nodes")) { + if(!expression) { + if(!bus_msb) hilight_graph_node(express, wc); + else hilight_graph_node(bus_msb, wc); } } + dbg(1, "express=%s, bus_msb=%s\n", express ? express : "NULL", bus_msb ? bus_msb : "NULL"); /* quickly find index number of ntok_copy variable to be plotted */ if( expression || (idx = get_raw_index(bus_msb ? bus_msb : express, NULL)) != -1 ) { int p, dset, ofs, ofs_end; diff --git a/src/hilight.c b/src/hilight.c index 5a2782e7..a01d86ac 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -259,28 +259,48 @@ static int there_are_hilights() int hilight_graph_node(const char *node, int col) { + int current = 0; const char *path; + const char *path3; + char *path2 = NULL; char *n = NULL; - char *nptr, *ptr; + char *nptr, *ptr, *ptr2; Hilight_hashentry *entry; - if(strchr(node, '.')) return 0; path = xctx->sch_path[xctx->currsch]; my_strdup2(_ALLOC_ID_, &n, node); nptr = n; - if(strstr(n, "i(")) {nptr[1] = ' '; nptr += 1;} - else if(strstr(n, "I(")) {nptr[1] = ' '; nptr += 1;} - if((ptr = strchr(n, ')'))) *ptr = '\0'; + dbg(1, "hilight_graph_node(): %s: %d\n", node, col); + if(strstr(n, "i(v.")) {current = 1; nptr += 4;} + else if(strstr(n, "I(V.")) {current = 1; nptr += 4;} + else if(strstr(n, "i(")) {current = 1; nptr += 2;} + else if(strstr(n, "I(")) {current = 1; nptr += 2;} + else if(strstr(n, "v(")) {nptr += 2;} + else if(strstr(n, "V(")) {nptr += 2;} + if((ptr = strrchr(n, ')'))) *ptr = '\0'; - dbg(1, "hilight_graph_node(): %s: %d\n", n, col); - entry = hier_hilight_hash_lookup(nptr, -col, path, XLOOKUP); + if((ptr2 = strrchr(nptr, '.'))) { + *ptr2 = '\0'; + path3 = nptr; + nptr = ptr2 + 1; + my_mstrcat(_ALLOC_ID_, &path2, path, path3, ".", NULL); + } + else { + my_strdup2(_ALLOC_ID_, &path2, path); + } + if(current) { + nptr--; + *nptr = ' '; + } + entry = hier_hilight_hash_lookup(nptr, -col, path2, XLOOKUP); if(!entry || entry->value != -col ) { - hier_hilight_hash_lookup(nptr, -col, path, XINSERT); + hier_hilight_hash_lookup(nptr, -col, path2, XINSERT); dbg(1, "hilight_graph_node(): propagate_hilights(), col=%d\n", col); propagate_hilights(1, 0, XINSERT_NOREPLACE); } my_free(_ALLOC_ID_, &n); + my_free(_ALLOC_ID_, &path2); return 1; } diff --git a/xschem_library/examples/poweramp.sch b/xschem_library/examples/poweramp.sch index 11791304..2aeaa275 100644 --- a/xschem_library/examples/poweramp.sch +++ b/xschem_library/examples/poweramp.sch @@ -61,7 +61,7 @@ VPP VNN x1.VBOOST x0.VBOOST" -color="4 15 6 12 7 4" +color="4 15 10 12 7 4" unitx=m hilight_wave=-1 linewidth_mult=2.3} diff --git a/xschem_library/ngspice/delta_sigma.sch b/xschem_library/ngspice/delta_sigma.sch index 8a424d3c..9f7753f8 100644 --- a/xschem_library/ngspice/delta_sigma.sch +++ b/xschem_library/ngspice/delta_sigma.sch @@ -36,10 +36,10 @@ x1=2e-12 x2=9e-06 divx=5 subdivx=1 -node="sig_in -vref -vcc" -color="8 9 11" +node="SIG_IN +VREF +VCC" +color="8 9 4" dataset=0 unitx=u } @@ -55,14 +55,15 @@ x1=2e-12 x2=9e-06 divx=5 subdivx=1 -node="CODE;code[5],code[4],code[3],code[2],code[1],code[0] -ck -rst -x1.comp" +node="CODE;CODE[5],CODE[4],CODE[3],CODE[2],CODE[1],CODE[0] +CK +RST +x1.COMP" color="7 4 10 4" dataset=0 unitx=u -digital=1} +digital=1 +} B 2 900 -970 1700 -630 {flags=graph y1=14.1924 y2=54.9924 @@ -186,7 +187,7 @@ tclcommand=" xschem raw_read $netlist_dir/[file tail [file rootname [xschem get current_name]]].raw tran " } -C {launcher.sym} 870 -90 0 0 {name=h1 +C {launcher.sym} 650 -870 0 0 {name=h1 descr="Netlist + Simulate Ctrl-Left-Click" tclcommand="xschem netlist; simulate"