better backannotation info placement in net labels, fixes in translate() for @spice_get_voltage and @spice_get_current, fixes in ngspice_backannotate routines.
This commit is contained in:
parent
931c1520e3
commit
9c89a08111
10
src/draw.c
10
src/draw.c
|
|
@ -1644,9 +1644,15 @@ static double get_unit(const char *val)
|
|||
int sch_waves_loaded(void)
|
||||
{
|
||||
int i;
|
||||
if(xctx->graph_values && xctx->graph_names && xctx->graph_raw_schname) {
|
||||
if(xctx->graph_raw_level == -1) return -1;
|
||||
else if(xctx->graph_values && xctx->graph_names && xctx->graph_raw_schname) {
|
||||
dbg(1, "sch_waves_loaded(): graph_raw_schname=%s\n", xctx->graph_raw_schname);
|
||||
for(i = xctx->currsch; i >= 0; i--) {
|
||||
if( !strcmp(xctx->graph_raw_schname, xctx->sch[i]) ) return i;
|
||||
dbg(1, "sch_waves_loaded(): %d --> %s\n", i, xctx->sch[i]);
|
||||
if( !strcmp(xctx->graph_raw_schname, xctx->sch[i]) ) {
|
||||
dbg(1, "sch_waves_loaded(): returning %d\n", i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -111,9 +111,18 @@ proc ngspice::get_curr_probe {arr n } {
|
|||
|
||||
|
||||
proc ngspice::get_current {n} {
|
||||
global path graph_raw_level
|
||||
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.
|
||||
set skip 0
|
||||
while { $skip < $graph_raw_level } {
|
||||
regsub {^[^.]*\.} $path {} path
|
||||
incr skip
|
||||
}
|
||||
set n [string tolower $n]
|
||||
set prefix [string range $n 0 0]
|
||||
set path [string range [xschem get sch_path] 1 end]
|
||||
#puts "ngspice::get_current: path=$path n=$n"
|
||||
set n $path$n
|
||||
if { ![sim_is_xyce] } {
|
||||
if {$path ne {} } {
|
||||
|
|
@ -124,8 +133,8 @@ proc ngspice::get_current {n} {
|
|||
}
|
||||
}
|
||||
set n i($n)
|
||||
# puts "ngspice::get_current --> $n"
|
||||
set err [catch {set ::ngspice::ngspice_data($n)} res]
|
||||
#puts "ngspice::get_current --> $n"
|
||||
set err [catch {set ngspice::ngspice_data($n)} res]
|
||||
if { $err } {
|
||||
set res {?}
|
||||
} else {
|
||||
|
|
@ -140,15 +149,30 @@ proc ngspice::get_current {n} {
|
|||
}
|
||||
|
||||
proc ngspice::get_voltage {n} {
|
||||
set n [string tolower $n]
|
||||
global path graph_raw_level
|
||||
set path [string range [xschem get sch_path] 1 end]
|
||||
set n v($path$n)
|
||||
set err [catch {set ::ngspice::ngspice_data($n)} res]
|
||||
# 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
|
||||
while { $skip < $graph_raw_level } {
|
||||
regsub {^[^.]*\.} $path {} path
|
||||
incr skip
|
||||
}
|
||||
set n [string tolower $n]
|
||||
# puts "ngspice::get_voltage: path=$path n=$n"
|
||||
set node $path$n
|
||||
set err [catch {set ngspice::ngspice_data($node)} res]
|
||||
if {$err} {
|
||||
set node v(${path}${n})
|
||||
# puts "ngspice::get_voltage: trying $node"
|
||||
set err [catch {set ngspice::ngspice_data($node)} res]
|
||||
}
|
||||
if { $err } {
|
||||
# puts "get_ngspice_node: $res"
|
||||
set res {?}
|
||||
} else {
|
||||
if { abs($res) <1e-3 && $res != 0.0} {
|
||||
if { abs($res) <1e-5} {
|
||||
set res 0
|
||||
} elseif { abs($res) <1e-3 && $res != 0.0} {
|
||||
set res [ format %.4e $res ]
|
||||
} else {
|
||||
set res [ format %.4g $res ]
|
||||
|
|
@ -158,11 +182,19 @@ proc ngspice::get_voltage {n} {
|
|||
}
|
||||
|
||||
proc ngspice::get_node {n} {
|
||||
set n [string tolower $n]
|
||||
global path graph_raw_level
|
||||
set path [string range [xschem get sch_path] 1 end]
|
||||
# puts "ngspice::get_node --> $n, path=$path"
|
||||
# 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
|
||||
while { $skip < $graph_raw_level } {
|
||||
regsub {^[^.]*\.} $path {} path
|
||||
incr skip
|
||||
}
|
||||
set n [string tolower $n]
|
||||
# n may contain $path, so substitute its value
|
||||
set n [ subst -nocommand $n ]
|
||||
set err [catch {set ::ngspice::ngspice_data($n)} res]
|
||||
set err [catch {set ngspice::ngspice_data($n)} res]
|
||||
if { $err } {
|
||||
set res {?}
|
||||
} else {
|
||||
|
|
@ -176,11 +208,11 @@ proc ngspice::get_node {n} {
|
|||
}
|
||||
|
||||
proc ngspice::resetdata {} {
|
||||
array unset ::ngspice::ngspice_data
|
||||
array unset ngspice::ngspice_data
|
||||
}
|
||||
|
||||
proc ngspice::annotate {{f {}} {read_file 1}} {
|
||||
upvar ::ngspice::ngspice_data arr
|
||||
upvar ngspice::ngspice_data arr
|
||||
|
||||
|
||||
if { $read_file == 1} {
|
||||
|
|
@ -197,7 +229,7 @@ proc ngspice::annotate {{f {}} {read_file 1}} {
|
|||
fconfigure $fp -translation binary
|
||||
set op_point_read 0
|
||||
## not needed: done in ngspice::read_ngspice_raw
|
||||
# array unset ::ngspice::ngspice_data
|
||||
# array unset ngspice::ngspice_data
|
||||
while 1 {
|
||||
ngspice::read_ngspice_raw arr $fp
|
||||
if { [info exists arr(n\ points)] } {
|
||||
|
|
|
|||
11
src/token.c
11
src/token.c
|
|
@ -3019,7 +3019,7 @@ const char *translate(int inst, const char* s)
|
|||
else if(strcmp(token,"@spice_get_voltage")==0 )
|
||||
{
|
||||
int start_level; /* hierarchy level where waves were loaded */
|
||||
if((start_level = sch_waves_loaded() >= 0) && xctx->graph_annotate_p>=0) {
|
||||
if((start_level = sch_waves_loaded()) >= 0 && xctx->graph_annotate_p>=0) {
|
||||
int multip;
|
||||
int no_of_pins= (xctx->inst[inst].ptr + xctx->sym)->rects[PINLAYER];
|
||||
if(no_of_pins == 1) {
|
||||
|
|
@ -3044,12 +3044,15 @@ const char *translate(int inst, const char* s)
|
|||
fqnet = my_malloc(1548, len);
|
||||
my_snprintf(fqnet, len, "%s%s", path, net);
|
||||
strtolower(fqnet);
|
||||
dbg(1, "translate(): fqnet=%s start_level=%d\n", fqnet, start_level);
|
||||
idx = get_raw_index(fqnet);
|
||||
if(idx >= 0) {
|
||||
val = xctx->graph_values[idx][xctx->graph_annotate_p];
|
||||
}
|
||||
if(idx < 0) {
|
||||
my_snprintf(valstr, S(valstr), "?");
|
||||
my_snprintf(valstr, S(valstr), "");
|
||||
} else if( fabs(val) < 1.0e-5) {
|
||||
my_snprintf(valstr, S(valstr), "0");
|
||||
} else if( fabs(val) < 1.0e-3 && val != 0.0) {
|
||||
my_snprintf(valstr, S(valstr), "%.4e", val);
|
||||
} else {
|
||||
|
|
@ -3070,7 +3073,7 @@ const char *translate(int inst, const char* s)
|
|||
else if(strcmp(token,"@spice_get_current")==0 )
|
||||
{
|
||||
int start_level; /* hierarchy level where waves were loaded */
|
||||
if((start_level = sch_waves_loaded() >= 0) && xctx->graph_annotate_p>=0) {
|
||||
if((start_level = sch_waves_loaded()) >= 0 && xctx->graph_annotate_p>=0) {
|
||||
char *fqdev = NULL;
|
||||
const char *path = xctx->sch_path[xctx->currsch] + 1;
|
||||
char *dev = NULL;
|
||||
|
|
@ -3110,7 +3113,7 @@ const char *translate(int inst, const char* s)
|
|||
val = xctx->graph_values[idx][xctx->graph_annotate_p];
|
||||
}
|
||||
if(idx < 0) {
|
||||
my_snprintf(valstr, S(valstr), "?");
|
||||
my_snprintf(valstr, S(valstr), "");
|
||||
} else if( fabs(val) < 1.0e-3 && val != 0.0) {
|
||||
my_snprintf(valstr, S(valstr), "%.4e", val);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3111,7 +3111,6 @@ proc tclpropeval2 {s} {
|
|||
# puts "tclpropeval2: s=|$s|"
|
||||
if {$debug_var <=-1} {puts "tclpropeval2: $s"}
|
||||
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.
|
||||
set skip 0
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ S {}
|
|||
E {}
|
||||
B 5 -1.25 -1.25 1.25 1.25 {name=p dir=in}
|
||||
T {@lab} -7.5 -8.125 0 1 0.33 0.33 {}
|
||||
T {@spice_get_voltage} -16.875 11.40625 0 1 0.2 0.2 {layer=15 hide=true}
|
||||
T {@spice_get_voltage} 1.875 3.90625 0 0 0.2 0.2 {layer=15 hide=true}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ S {}
|
|||
E {}
|
||||
B 5 -1.25 -1.25 1.25 1.25 {name=p dir=in}
|
||||
T {@lab} -2.5 -1.25 2 0 0.27 0.27 {}
|
||||
T {@spice_get_voltage} -1.875 -24.84375 0 1 0.2 0.2 {vcenter=true layer=15 hide=true}
|
||||
T {@spice_get_voltage} -1.875 10.15625 0 1 0.2 0.2 {vcenter=true layer=15 hide=true}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,3 @@ L 15 21.25 -20 25 -20 {}
|
|||
L 15 25 -23.75 25 -20 {}
|
||||
L 15 25 -23.75 27.8125 -23.75 {}
|
||||
B 5 -0.46875 -0.46875 0.46875 0.46875 {name=p dir=xxx}
|
||||
T {@spice_get_voltage} 11.875 -34.84375 0 0 0.2 0.2 {vcenter=true layer=15 hide=true}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -19,8 +19,8 @@ B 2 1200 -500 1880 -310 {flags=graph
|
|||
y1 = -0.0059
|
||||
y2 = 11
|
||||
divy = 6
|
||||
x1=8e-09
|
||||
x2=0.0124755
|
||||
x1=0.0114403
|
||||
x2=0.0118423
|
||||
divx=10
|
||||
node="i(v.x1.vu)
|
||||
i(v.x0.vu)
|
||||
|
|
@ -29,11 +29,11 @@ i(v.x0.vd)"
|
|||
color="11 13 12 7"
|
||||
unitx=m}
|
||||
B 2 1200 -830 1880 -520 {flags=graph
|
||||
y1 = -31
|
||||
y2 = 77
|
||||
y1 = -49
|
||||
y2 = 58
|
||||
divy = 12
|
||||
x1=8e-09
|
||||
x2=0.0124755
|
||||
x1=0.0114403
|
||||
x2=0.0118423
|
||||
divx=10
|
||||
node="outp
|
||||
outm
|
||||
|
|
@ -44,11 +44,11 @@ x0.vboost"
|
|||
color="4 15 6 12 7 4"
|
||||
unitx=m}
|
||||
B 2 1200 -1020 1880 -830 {flags=graph
|
||||
y1 = 2.4e-11
|
||||
y2 = 840
|
||||
y1 = 0
|
||||
y2 = 830
|
||||
divy = 6
|
||||
x1=8e-09
|
||||
x2=0.0124755
|
||||
x1=0.0114403
|
||||
x2=0.0118423
|
||||
divx=10
|
||||
|
||||
|
||||
|
|
@ -57,11 +57,11 @@ color="4 7"
|
|||
node="\\"supply power;i(vcurrvnn) vnn * i(vcurrvpp) vpp * +\\"
|
||||
\\"running average supply power;i(vcurrvnn) vnn * i(vcurrvpp) vpp * + 1.0e-4 ravg()\\""}
|
||||
B 2 1200 -310 1880 -120 {flags=graph
|
||||
y1 = 0.0077
|
||||
y2 = 850
|
||||
y1 = 0
|
||||
y2 = 840
|
||||
divy = 6
|
||||
x1=8e-09
|
||||
x2=0.0124755
|
||||
x1=0.0114403
|
||||
x2=0.0118423
|
||||
divx=10
|
||||
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ node="[ngspice::get_current \{r19[i]\}]"
|
|||
descr = current
|
||||
}
|
||||
C {ngspice_get_expr.sym} 820 -510 2 0 {name=r29
|
||||
node="[format %.4g [expr ([ngspice::get_voltage outm] - [ngspice::get_voltage outp]) * [ngspice::get_current \{r1[i]\}]]] "
|
||||
node="[format %.4g [expr \{([ngspice::get_voltage outm] - [ngspice::get_voltage outp]) * [ngspice::get_current \{r1[i]\}]\}]] "
|
||||
descr = power
|
||||
}
|
||||
C {launcher.sym} 780 -190 0 0 {name=h3
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
v {xschem version=3.0.0 file_version=1.2 }
|
||||
v {xschem version=3.1.0 file_version=1.2
|
||||
}
|
||||
G {}
|
||||
K {}
|
||||
V {}
|
||||
|
|
@ -11,10 +12,10 @@ divy = 4
|
|||
x1=2.6e-07
|
||||
x2=3.4e-07
|
||||
divx=8
|
||||
node="v(xsa[0].ldqi)
|
||||
v(xsa[0].ldqib)
|
||||
v(xsa[0].ldsali)"
|
||||
color="12 5 10"}
|
||||
node="tcleval($\{path\}ldqi
|
||||
$\{path\}ldqib
|
||||
$\{path\}ldsali)"
|
||||
color="9 6 7"}
|
||||
B 2 380 -940 1060 -830 {flags=graph
|
||||
y1 = 0
|
||||
y2 = 2
|
||||
|
|
@ -32,10 +33,10 @@ divy = 2
|
|||
x1=2.6e-07
|
||||
x2=3.4e-07
|
||||
divx=8
|
||||
node="v(xsa[0].ldqiii)
|
||||
v(xsa[0].ldqii)
|
||||
v(xsa[0].ldsali)"
|
||||
color="12 5 4"}
|
||||
node="tcleval($\{path\}ldqiii
|
||||
$\{path\}ldqii
|
||||
$\{path\}ldsali)"
|
||||
color="6 8 7"}
|
||||
T {Was:
|
||||
60/24} 1420 -310 0 0 0.4 0.4 {}
|
||||
T {was: LDCP_B} 510 -410 0 0 0.4 0.4 {}
|
||||
|
|
@ -127,5 +128,5 @@ C {spice_probe.sym} 1320 -600 3 1 {name=p3 analysis=tran}
|
|||
C {spice_probe.sym} 200 -390 0 0 {name=p6 analysis=tran}
|
||||
C {spice_probe.sym} 270 -630 0 0 {name=p7 analysis=tran}
|
||||
C {spice_probe.sym} 940 -380 0 0 {name=p11 analysis=tran}
|
||||
C {spice_probe.sym} 1560 -330 2 1 {name=p30 analysis=tran}
|
||||
C {spice_probe.sym} 1510 -370 2 1 {name=p30 analysis=tran}
|
||||
C {lab_pin.sym} 640 -380 0 0 {name=p12 lab=LDCP_B}
|
||||
|
|
|
|||
Loading…
Reference in New Issue