From 53dc7fe3bfb3293d3ae4647a91435168d290fa21 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Mon, 19 Sep 2022 11:22:04 +0200 Subject: [PATCH] add backannotation info (as hidden text) in lab_pin.sym, lab_wire.sym, transitioning example schematics from old (push) backannotation model to new pull model. --- src/ngspice_backannotate.tcl | 71 +++++++++++---------- xschem_library/devices/lab_pin.sym | 4 +- xschem_library/devices/lab_wire.sym | 7 +- xschem_library/devices/spice_probe.sym | 5 +- xschem_library/examples/LCC_instances.sch | 10 ++- xschem_library/examples/classD_amp.sch | 18 +++--- xschem_library/examples/mos_power_ampli.sch | 45 ++++--------- xschem_library/examples/poweramp.sch | 35 ++++------ 8 files changed, 86 insertions(+), 109 deletions(-) diff --git a/src/ngspice_backannotate.tcl b/src/ngspice_backannotate.tcl index 82ab4720..f851a7e7 100644 --- a/src/ngspice_backannotate.tcl +++ b/src/ngspice_backannotate.tcl @@ -204,45 +204,48 @@ proc ngspice::annotate {{f {}} {read_file 1}} { if { $op_point_read } { ### disable screen redraw and undo when looping to speed up performance ### but save state on undo stack before doing backannotations. - xschem push_undo - xschem set no_undo 1 - xschem set no_draw 1 - set lastinst [xschem get instances] - set path [string range [xschem get sch_path] 1 end] - for { set i 0 } { $i < $lastinst } {incr i } { - set name [xschem getprop instance $i name] - set type [xschem getprop instance $i cell::type] - if { $type eq {probe} } { - set net $path[xschem instance_net $i p] - if {[catch {xschem setprop instance $i voltage [ngspice::get_voltage_probe arr $net] fast} err]} { - puts "Warning 1: ${err}, net: $net" + + if {0} { + xschem push_undo + xschem set no_undo 1 + xschem set no_draw 1 + set lastinst [xschem get instances] + set path [string range [xschem get sch_path] 1 end] + for { set i 0 } { $i < $lastinst } {incr i } { + set name [xschem getprop instance $i name] + set type [xschem getprop instance $i cell::type] + if { $type eq {probe} } { + set net $path[xschem instance_net $i p] + if {[catch {xschem setprop instance $i voltage [ngspice::get_voltage_probe arr $net] fast} err]} { + puts "Warning 1: ${err}, net: $net" + } } - } - if { $type eq {current_probe} } { - if {[catch {xschem setprop instance $i current [ngspice::get_curr_probe arr $path$name] fast} err]} { - puts "Warning 2: $err" + if { $type eq {current_probe} } { + if {[catch {xschem setprop instance $i current [ngspice::get_curr_probe arr $path$name] fast} err]} { + puts "Warning 2: $err" + } } - } - if { $type eq {differential_probe} } { - set netp $path[xschem instance_net $i p] - set netm $path[xschem instance_net $i m] - if {[catch {xschem setprop instance $i voltage [ngspice::get_diff_probe arr $netp $netm] fast} err]} { - puts "Warning 3: $err" + if { $type eq {differential_probe} } { + set netp $path[xschem instance_net $i p] + set netm $path[xschem instance_net $i m] + if {[catch {xschem setprop instance $i voltage [ngspice::get_diff_probe arr $netp $netm] fast} err]} { + puts "Warning 3: $err" + } } + # puts "$i $name $type" } - # puts "$i $name $type" - } - - # re-enable undo and draw - xschem set no_undo 0 - xschem set no_draw 0 + + # re-enable undo and draw + xschem set no_undo 0 + xschem set no_draw 0 + + ### xschem setprop instructions have not altered circuit topology so + ### in this case a connectivity rebuild is not needed. + # xschem rebuild_connectivity + # + # + } ;# if {0} xschem redraw - - ### xschem setprop instructions have not altered circuit topology so - ### in this case a connectivity rebuild is not needed. - # xschem rebuild_connectivity - # - # } else { puts "no operating point found!" } diff --git a/xschem_library/devices/lab_pin.sym b/xschem_library/devices/lab_pin.sym index e80c5129..de4fe4bd 100644 --- a/xschem_library/devices/lab_pin.sym +++ b/xschem_library/devices/lab_pin.sym @@ -1,4 +1,5 @@ -v {xschem version=2.9.8 file_version=1.2} +v {xschem version=3.1.0 file_version=1.2 +} G {} K {type=label format="*.alias @lab" @@ -8,3 +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 {tcleval( [ ngspice::get_node v($\{path\}@@p\\) ] )} -16.875 17.65625 0 1 0.2 0.2 {vcenter=true layer=15 hide=true} diff --git a/xschem_library/devices/lab_wire.sym b/xschem_library/devices/lab_wire.sym index dd9788a5..175023a5 100644 --- a/xschem_library/devices/lab_wire.sym +++ b/xschem_library/devices/lab_wire.sym @@ -1,5 +1,7 @@ -v {xschem version=2.9.5_RC6 file_version=1.1} -G {type=label +v {xschem version=3.1.0 file_version=1.2 +} +G {} +K {type=label format="*.alias @lab" template="name=l1 sig_type=std_logic lab=xxx"} V {} @@ -7,3 +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 {tcleval( [ ngspice::get_node v($\{path\}@@p\\) ] )} -1.875 -24.84375 0 1 0.2 0.2 {vcenter=true layer=15 hide=true} diff --git a/xschem_library/devices/spice_probe.sym b/xschem_library/devices/spice_probe.sym index bd52712c..801e54d6 100644 --- a/xschem_library/devices/spice_probe.sym +++ b/xschem_library/devices/spice_probe.sym @@ -1,4 +1,5 @@ -v {xschem version=2.9.9 file_version=1.2 } +v {xschem version=3.1.0 file_version=1.2 +} G {} K {type=probe vhdl_ignore=true @@ -22,4 +23,4 @@ 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 {@voltage} 12.5 -37.5 0 0 0.2 0.2 {layer=15} +T {tcleval( [ ngspice::get_node v($\{path\}@@p\\) ] )} 11.875 -34.84375 0 0 0.2 0.2 {vcenter=true layer=15 hide=true} diff --git a/xschem_library/examples/LCC_instances.sch b/xschem_library/examples/LCC_instances.sch index e4a38867..08ad99b4 100644 --- a/xschem_library/examples/LCC_instances.sch +++ b/xschem_library/examples/LCC_instances.sch @@ -32,7 +32,8 @@ node="a zz zzz" color="4 6 8" -sweep="v(a)"} +sweep="v(a)" +dataset=0} B 2 10 -930 570 -700 {flags=graph y1 = -0.0578112 y2 = 3.04806 @@ -43,7 +44,8 @@ divx=6 node="z a" color="4 6" -sweep="v(a) v(z)"} +sweep="v(a) v(z)" +dataset=0} P 4 5 560 -700 560 -510 1350 -510 1350 -700 560 -700 {dash=3} P 4 5 820 -920 820 -730 1350 -730 1350 -920 820 -920 {dash=3} T {These 2 instances are equivalent} 260 -310 0 0 0.4 0.4 {} @@ -179,7 +181,3 @@ tclcommand=" xschem raw_read $netlist_dir/[file tail [file rootname [xschem get current_name]]].raw " } -C {ngspice_probe.sym} 520 -490 0 0 {name=r3} -C {ngspice_probe.sym} 200 -490 0 1 {name=r3} -C {ngspice_probe.sym} 360 -190 0 0 {name=r3} -C {ngspice_probe.sym} 240 -190 0 1 {name=r3} diff --git a/xschem_library/examples/classD_amp.sch b/xschem_library/examples/classD_amp.sch index aefb024f..504b0682 100644 --- a/xschem_library/examples/classD_amp.sch +++ b/xschem_library/examples/classD_amp.sch @@ -92,8 +92,8 @@ ypos2=36.4765 divy=5 subdivy=1 unity=1 -x1=0.000192788 -x2=0.00195727 +x1=0.000509817 +x2=0.000687424 divx=5 subdivx=1 node="out @@ -111,8 +111,8 @@ ypos2=7.14491 divy=5 subdivy=1 unity=1 -x1=0.000192788 -x2=0.00195727 +x1=0.000509817 +x2=0.000687424 divx=5 subdivx=1 @@ -134,8 +134,8 @@ ypos2=14.7089 divy=5 subdivy=1 unity=1 -x1=0.000192788 -x2=0.00195727 +x1=0.000509817 +x2=0.000687424 divx=5 subdivx=1 @@ -159,8 +159,8 @@ ypos2=36.4765 divy=5 subdivy=1 unity=1 -x1=0.000192788 -x2=0.00195727 +x1=0.000509817 +x2=0.000687424 divx=5 subdivx=1 @@ -429,7 +429,7 @@ OFFSET=5 AMPLITUDE=10} C {lab_pin.sym} 710 -520 0 1 {name=p1 lab=DRIVEU} C {parax_cap.sym} 670 -510 0 0 {name=C6 gnd=0 value=200f m=1} -C {vsource.sym} 440 -460 0 1 {name=Voffs value=0.1} +C {vsource.sym} 440 -460 0 0 {name=Voffs value=0.1} C {lab_pin.sym} 440 -490 0 0 {name=p2 lab=REFU} C {vsource.sym} 440 -310 2 1 {name=Voffs1 value=0.1} C {lab_pin.sym} 440 -340 0 0 {name=p5 lab=REFD} diff --git a/xschem_library/examples/mos_power_ampli.sch b/xschem_library/examples/mos_power_ampli.sch index 9c53ffc9..15700945 100644 --- a/xschem_library/examples/mos_power_ampli.sch +++ b/xschem_library/examples/mos_power_ampli.sch @@ -176,12 +176,12 @@ C {lab_pin.sym} 180 -580 0 0 {name=p15 lab=C5} C {lab_pin.sym} 340 -580 0 1 {name=p16 lab=C9} C {lab_pin.sym} 180 -1000 0 0 {name=p17 lab=E1} C {lab_pin.sym} 560 -1080 0 0 {name=p25 lab=VPP} -C {lab_pin.sym} 340 -970 0 1 {name=p23 lab=E2} -C {lab_pin.sym} 560 -970 0 1 {name=p28 lab=E6} +C {lab_pin.sym} 340 -980 0 1 {name=p23 lab=E2} +C {lab_pin.sym} 560 -980 0 1 {name=p28 lab=E6} C {lab_pin.sym} 840 -1000 0 0 {name=p29 lab=E4} C {lab_pin.sym} 180 -1120 0 0 {name=p34 lab=VBOOST} -C {ammeter.sym} 1110 -540 0 0 {name=vd net_name=true current=0.2069} -C {ammeter.sym} 1110 -640 0 0 {name=vu net_name=true current=0.2005} +C {ammeter.sym} 1110 -540 0 0 {name=vd net_name=true } +C {ammeter.sym} 1110 -640 0 0 {name=vu net_name=true } C {lab_pin.sym} 60 -1180 0 0 {name=p27 lab=VPP} C {pnp.sym} 200 -950 0 1 {name=Q1 model=q2n2907p area=1 net_name=true} C {pnp.sym} 360 -790 0 1 {name=Q2 model=q2n2907p area=1 net_name=true} @@ -264,18 +264,18 @@ C {lab_pin.sym} 180 -690 0 0 {name=p8 lab=C7} C {lab_pin.sym} 340 -710 0 1 {name=p31 lab=C2} C {title.sym} 160 -30 0 0 {name=l2 author="Stefan Schippers"} C {lab_pin.sym} 860 -700 0 0 {name=p32 lab=SA} -C {ammeter.sym} 1110 -350 0 0 {name=v0 net_name=true current=0.2263} +C {ammeter.sym} 1110 -350 0 0 {name=v0 net_name=true } C {lab_pin.sym} 860 -380 0 0 {name=p35 lab=SB} -C {ammeter.sym} 560 -890 0 0 {name=v1 net_name=true current=0.01956} -C {ammeter.sym} 340 -890 0 0 {name=v2 net_name=true current=0.01947} -C {ammeter.sym} 260 -310 0 0 {name=v3 net_name=true current=0.03918} -C {ammeter.sym} 700 -440 3 0 {name=v4 net_name=true current=0.01941} -C {ammeter.sym} 690 -680 0 0 {name=v5 net_name=true current=0.006184} -C {ammeter.sym} 180 -870 0 1 {name=v6 net_name=true current=0.01949} -C {ammeter.sym} 840 -890 0 0 {name=v7 net_name=true current=0.01944} +C {ammeter.sym} 560 -890 0 0 {name=v1 net_name=true } +C {ammeter.sym} 340 -890 0 0 {name=v2 net_name=true } +C {ammeter.sym} 260 -310 0 0 {name=v3 net_name=true } +C {ammeter.sym} 700 -440 3 0 {name=v4 net_name=true } +C {ammeter.sym} 690 -680 0 0 {name=v5 net_name=true } +C {ammeter.sym} 180 -870 0 1 {name=v6 net_name=true } +C {ammeter.sym} 840 -890 0 0 {name=v7 net_name=true } C {spice_probe_vdiff.sym} 860 -410 0 0 {name=p37 voltage=3.688} C {spice_probe_vdiff.sym} 860 -730 0 0 {name=p38 voltage=3.68} -C {ammeter.sym} 1300 -590 3 0 {name=v8 net_name=true current=-2.1216e-04} +C {ammeter.sym} 1300 -590 3 0 {name=v8 net_name=true } C {opin.sym} 600 -130 0 0 {name=p5 lab=OUT} C {ipin.sym} 530 -180 0 0 {name=p1 lab=MINUS} C {ipin.sym} 530 -140 0 0 {name=p4 lab=VSS} @@ -305,9 +305,6 @@ tclcommand=" xschem redraw " } -C {ngspice_probe.sym} 750 -1120 0 0 {name=p54} -C {ngspice_probe.sym} 180 -760 0 0 {name=p53} -C {ngspice_probe.sym} 560 -710 0 0 {name=p55} C {ngspice_get_value.sym} 1130 -780 0 0 {name=nmos1 node=i(@r.$\{path\}xm1.rd[i]) descr="Id="} C {ngspice_get_expr.sym} 800 -1000 0 1 {name=r8 @@ -318,23 +315,10 @@ C {ngspice_get_expr.sym} 860 -980 0 0 {name=r9 node="[format %.4g [expr [ngspice::get_current \{q4[ic]\}] / [ngspice::get_current \{q4[ib]\}] ] ]" descr = beta } -C {ngspice_probe.sym} 560 -830 0 0 {name=p41} -C {ngspice_probe.sym} 560 -530 0 1 {name=p42} -C {ngspice_probe.sym} 590 -440 2 1 {name=p47} C {ngspice_get_expr.sym} 860 -920 0 0 {name=r15 node="[format %.4g [expr ([ngspice::get_voltage e4] - [ngspice::get_voltage e11]) * [ngspice::get_current \{q4[ic]\}]]] W" descr = power } -C {ngspice_probe.sym} 260 -260 0 0 {name=p48} -C {ngspice_probe.sym} 90 -70 0 0 {name=p49} -C {ngspice_probe.sym} 100 -210 0 1 {name=p52} -C {ngspice_probe.sym} 1190 -590 0 1 {name=p39} -C {ngspice_probe.sym} 890 -700 2 1 {name=p43} -C {ngspice_probe.sym} 460 -790 2 1 {name=p44} -C {ngspice_probe.sym} 730 -810 2 1 {name=p46} -C {ngspice_probe.sym} 440 -950 0 0 {name=p50} -C {ngspice_probe.sym} 200 -470 0 0 {name=p45} -C {ngspice_probe.sym} 340 -600 0 0 {name=p51} C {ngspice_get_expr.sym} 330 -900 0 1 {name=r17 node="[ngspice::get_current v2]" descr = current @@ -367,7 +351,7 @@ C {ngspice_get_expr.sym} 240 -210 0 1 {name=r6 node="[format %.4g [expr [ngspice::get_current \{q3[ic]\}] / [ngspice::get_current \{q3[ib]\}] ] ]" descr = beta } -C {ngspice_get_expr.sym} 860 -780 0 0 {name=r16 +C {ngspice_get_expr.sym} 850 -820 0 0 {name=r16 node="[format %.4g [expr ([ngspice::get_voltage e11] - [ngspice::get_voltage ga]) * [ngspice::get_current \{q11[ic]\}]]] W" descr = power } @@ -395,7 +379,6 @@ C {ngspice_get_expr.sym} 210 -650 0 0 {name=r14 node="[format %.4g [expr ([ngspice::get_voltage c7] - [ngspice::get_voltage c5]) * [ngspice::get_current \{q7[ic]\}]]]" descr = power } -C {ngspice_probe.sym} 180 -560 0 0 {name=p36} C {ngspice_get_expr.sym} 200 -500 0 0 {name=r13 node="[format %.4g [expr ([ngspice::get_voltage c5] - [ngspice::get_voltage e9]) * [ngspice::get_current \{q5[ic]\}]]]" descr = power diff --git a/xschem_library/examples/poweramp.sch b/xschem_library/examples/poweramp.sch index 8a202dfa..44e71728 100644 --- a/xschem_library/examples/poweramp.sch +++ b/xschem_library/examples/poweramp.sch @@ -245,9 +245,9 @@ C {lab_pin.sym} 350 -270 0 0 {name=p19 lab=FB} C {lab_pin.sym} 350 -730 0 0 {name=p25 lab=FBN} C {title.sym} 160 -30 0 0 {name=l2 author="Stefan Schippers"} C {lab_pin.sym} 870 -1200 0 0 {name=p27 lab=IN_INT} -C {ammeter.sym} 210 -1220 3 0 {name=vcurrvpp net_name=true current=0.54} -C {ammeter.sym} 210 -1060 3 0 {name=vcurrvnn net_name=true current=-0.4526} -C {ammeter.sym} 210 -1140 3 0 {name=vcurrvss net_name=true current=-0.08742} +C {ammeter.sym} 210 -1220 3 0 {name=vcurrvpp net_name=true } +C {ammeter.sym} 210 -1060 3 0 {name=vcurrvnn net_name=true } +C {ammeter.sym} 210 -1140 3 0 {name=vcurrvss net_name=true } C {launcher.sym} 780 -120 0 0 {name=h2 descr="Ctrl-Click Clear all probes" @@ -274,22 +274,12 @@ tclcommand=" xschem redraw " } -C {ngspice_probe.sym} 350 -810 0 1 {name=p55} -C {ngspice_probe.sym} 150 -1140 0 1 {name=p34} C {capa.sym} 270 -1180 0 0 {name=C2 m=1 value="100u"} -C {ngspice_probe.sym} 70 -1220 0 1 {name=p35} -C {ngspice_probe.sym} 70 -1060 0 1 {name=p36} -C {ngspice_probe.sym} 310 -1140 0 0 {name=p37} -C {ngspice_probe.sym} 840 -700 0 1 {name=p29} -C {ngspice_probe.sym} 810 -240 0 1 {name=p38} -C {ngspice_probe.sym} 300 -680 0 1 {name=p33} -C {ngspice_probe.sym} 300 -220 0 1 {name=p30} -C {ngspice_probe.sym} 350 -320 0 1 {name=p39} C {ngspice_get_expr.sym} 535 -475 0 1 {name=r18 node="[ngspice::get_current \{r2[i]\}]" descr = current } -C {ngspice_get_expr.sym} 575 -915 0 0 {name=r1 +C {ngspice_get_expr.sym} 585 -895 0 0 {name=r1 node="[ngspice::get_current \{r19[i]\}]" descr = current } @@ -311,11 +301,11 @@ load $netlist_dir/$rawfile table_set $rawfile\\" unset rawfile" } -C {spice_probe.sym} 710 -860 0 0 {name=p40 analysis=tran voltage=-0.1364} -C {spice_probe.sym} 710 -400 0 0 {name=p41 analysis=tran voltage=-0.1364} -C {spice_probe.sym} 660 -1200 0 0 {name=p42 analysis=tran voltage=0.0000e+00} -C {spice_probe.sym} 670 -1120 0 0 {name=p43 analysis=tran voltage=0.0000e+00} -C {spice_probe.sym} 950 -1200 0 0 {name=p44 analysis=tran voltage=0.0000e+00} +C {spice_probe.sym} 710 -860 0 0 {name=p40 analysis=tran } +C {spice_probe.sym} 710 -400 0 0 {name=p41 analysis=tran } +C {spice_probe.sym} 660 -1200 0 0 {name=p42 analysis=tran } +C {spice_probe.sym} 670 -1120 0 0 {name=p43 analysis=tran } +C {spice_probe.sym} 950 -1200 0 0 {name=p44 analysis=tran } C {launcher.sym} 1000 -270 0 0 {name=h1 descr="Backannotate" tclcommand="ngspice::annotate $netlist_dir/poweramp_op.raw"} @@ -323,8 +313,8 @@ C {ngspice_get_expr.sym} 130 -1010 0 0 {name=r19 node="[ngspice::get_current \{r9[i]\}]" descr = current } -C {spice_probe.sym} 300 -1220 0 0 {name=p45 analysis=tran voltage=49.84} -C {spice_probe.sym} 300 -1060 0 0 {name=p46 analysis=tran voltage=-49.86} +C {spice_probe.sym} 300 -1220 0 0 {name=p45 analysis=tran } +C {spice_probe.sym} 300 -1060 0 0 {name=p46 analysis=tran } C {launcher.sym} 1145 -1165 0 0 {name=h5 descr="load ngspice waves" tclcommand=" @@ -390,6 +380,3 @@ tclcommand=" xschem raw_read $netlist_dir/poweramp_xyce.raw " } -C {ngspice_probe.sym} 880 -1200 0 1 {name=p29} -C {ngspice_probe.sym} 550 -830 0 1 {name=p29} -C {ngspice_probe.sym} 550 -750 0 1 {name=p29}