From 460ebe561d4529e4bb3b4a0e4ab387172e2a51d2 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Sun, 25 Oct 2020 03:03:23 +0100 Subject: [PATCH] sqwsource.sym: better labels, various fixes, comments and more debug messages in tcleval() stuff, some fixes (error checks) in "device_model" related model_name() function --- src/scheduler.c | 4 ++-- src/spice_netlist.c | 15 ++++++++++----- src/token.c | 6 +++++- src/xschem.tcl | 10 ++++++++-- xschem_library/devices/sqwsource.sym | 4 ++-- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 4ce21088..bd25f6b1 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -720,7 +720,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } } if(!found) { - Tcl_AppendResult(interp, "xSymbol not found", NULL); + Tcl_AppendResult(interp, "Symbol not found", NULL); return TCL_ERROR; } if(argc == 4) @@ -1557,7 +1557,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } } if(iinstances) { - my_snprintf(s, S(s), "xInstance: %g %g %g %g", xctx->inst[i].x1, xctx->inst[i].y1, + my_snprintf(s, S(s), "Instance: %g %g %g %g", xctx->inst[i].x1, xctx->inst[i].y1, xctx->inst[i].x2, xctx->inst[i].y2); Tcl_AppendResult(interp, s, NULL); my_snprintf(s, S(s), "\nSymbol: %g %g %g %g", diff --git a/src/spice_netlist.c b/src/spice_netlist.c index e8f7ff47..f6ef7a7a 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -278,13 +278,18 @@ static char *model_name(const char *m) { char *m_lower = NULL; char *modelname = NULL; - + int n; + int l = strlen(m) + 1; my_strdup(255, &m_lower, m); strtolower(m_lower); - my_realloc(256, &modelname, strlen(m) + 1); - my_realloc(257, &model_name_result, strlen(m) + 1); - sscanf(m_lower, " %s %s", model_name_result, modelname); - my_strcat(296, &model_name_result, modelname); + my_realloc(256, &modelname, l); + my_realloc(257, &model_name_result, l); + n = sscanf(m_lower, " %s %s", model_name_result, modelname); + if(n<2) my_strncpy(model_name_result, m_lower, l); + else { + /* build a hash key value with no spaces to make device_model attributes with different spaces equivalent*/ + my_strcat(296, &model_name_result, modelname); + } my_free(948, &modelname); my_free(949, &m_lower); return model_name_result; diff --git a/src/token.c b/src/token.c index b74c8459..247bf3fe 100644 --- a/src/token.c +++ b/src/token.c @@ -1659,7 +1659,11 @@ void print_spice_element(FILE *fd, int inst) /* do a second round of substitutions, but without calling tcl */ if(result && strstr(result, "eval(") == result) { char *c = strrchr(result, ')'); - if(c) *c = '\0'; + if(c) while(1) { /* shift following characters back 1 char */ + *c = c[1]; + c++; + if(!*c) break; + } my_strdup2(88, &result, translate(inst, result+5)); } fprintf(fd, "%s", result); diff --git a/src/xschem.tcl b/src/xschem.tcl index 9ef01f5b..b69a3276 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1876,9 +1876,15 @@ proc property_search {} { # proc tclpropeval {s instname symname} { # puts "tclpropeval: $s $instname $symname" + global env tcl_debug + if {$tcl_debug <=-1} {puts "tclpropeval: $s"} regsub {^@tcleval\(} $s {} s - regsub {\)$} $s {} s - return [eval $s] + regsub {\)([ \t\n]*)$} $s {\1} s + if { [catch {eval $s} res] } { + if { $tcl_debug<=-1 } { puts "tclpropeval warning: $res"} + set res ?\n + } + return $res } # this hook is called in translate() if whole string is contained in a tcleval(...) construct diff --git a/xschem_library/devices/sqwsource.sym b/xschem_library/devices/sqwsource.sym index f4714c84..caa6ac91 100644 --- a/xschem_library/devices/sqwsource.sym +++ b/xschem_library/devices/sqwsource.sym @@ -25,8 +25,8 @@ L 4 5 5 10 5 {} B 5 -2.5 -32.5 2.5 -27.5 {name=p dir=inout} B 5 -2.5 27.5 2.5 32.5 {name=m dir=inout} A 4 0 0 15 270 360 {} -T {@vhi} 20 -6.25 0 0 0.2 0.2 {} +T {V=@vhi} 20 -6.25 0 0 0.2 0.2 {} T {@name} 20 -18.75 0 0 0.2 0.2 {} T {@#0:net_name} 10 -30 0 0 0.15 0.15 {layer=15} T {@#1:net_name} 10 20 0 0 0.15 0.15 {layer=15} -T {@freq} 20 6.25 0 0 0.2 0.2 {} +T {f=@freq Hz} 20 6.25 0 0 0.2 0.2 {}