updated xschem_library/examples/test_backannotated_subckt.sch; fix a potential segfault in proc fix_symbol

This commit is contained in:
stefan schippers 2023-06-08 01:08:05 +02:00
parent edaf4ccce9
commit d56e3939d5
2 changed files with 26 additions and 11 deletions

View File

@ -4614,7 +4614,6 @@ proc get_directory {f} {
# set 'n' last directory components to every symbol
proc fix_symbols {n} {
xschem push_undo
xschem remove_symbols
foreach {i s t} [xschem instance_list] {
set sympath [find_file_first [file tail $s]]
if { $sympath ne {}} {

View File

@ -1,33 +1,49 @@
v {xschem version=3.1.0 file_version=1.2 }
v {xschem version=3.4.0 file_version=1.2
}
G {}
K {}
V {}
S {}
E {}
T {To run this example a 'calc_rc' procedure must be defined.
you can paste example procedure below into xschem command prompt before
creating a netlist.
I have embedded below procedure in title instance so
it will be defined on load/drawing
Descend into the symbol ('i' key) and see how it is used in the 'format'
attribute to calculate "Res" and "Cap" subcircuit parameters from W and L
instance parameters.
Tcl scripts can be loaded in xcshemrc by appending a tcl file name to variable
tcl_files.} 40 -390 2 1 0.5 0.5 {layer=8 }
'tcl_files'.} 30 -420 2 1 0.5 0.5 {layer=8 }
T {proc calc_rc \{ L W \} \{
if \{[catch \{expr 1200*$L/$W\} res]\} \{set res -1\}
if \{[catch \{expr 1e-3*$W*$L\} cap]\} \{set cap -1\}
return "Res=$res Cap=$cap"
\} } 270 -370 0 0 0.4 0.4 { font=monospace}
T {Dynamic calculation of subcircuit parameters} 80 -730 0 0 0.8 0.8 {}
\} } 260 -400 0 0 0.4 0.4 { font=monospace}
T {Dynamic calculation of subcircuit parameters} 70 -760 0 0 0.8 0.8 {}
T {Title symbol has embedded TCL command
define calc_rc} 330 -110 0 0 0.4 0.4 { layer=6}
N 140 -130 140 -100 { lab=0}
N 140 -210 160 -210 { lab=IN}
N 140 -210 140 -190 { lab=IN}
C {lab_pin.sym} 670 -150 0 1 {name=p1 lab=OUT}
C {lab_pin.sym} 370 -150 0 0 {name=p2 lab=IN}
C {title.sym} 160 -30 0 0 {name=l1 author="Stefan Schippers"}
C {lab_pin.sym} 680 -170 0 1 {name=p1 lab=OUT}
C {lab_pin.sym} 380 -170 0 0 {name=p2 lab=IN}
C {title.sym} 160 -30 0 0 {name=l1 author="tcleval([
if \{ [info commands calc_rc] eq \{\} \} \{
puts \{defining calc_rc procedure...\}
puts \{############\}
proc calc_rc \{ L W \} \{
if \{[catch \{expr 1200*$L/$W\} res]\} \{set res -1\}
if \{[catch \{expr 1e-3*$W*$L\} cap]\} \{set cap -1\}
return \\"list Res=$res Cap=$cap\\"
\}
puts [info body calc_rc]
puts \{############\}
\}
]Stefan Schippers)"
}
C {vsource.sym} 140 -160 0 0 {name=V1 value="pwl 0 0 10n 0 11n 5"}
C {lab_pin.sym} 140 -100 0 0 {name=l2 sig_type=std_logic lab=0}
C {lab_pin.sym} 160 -210 0 1 {name=p3 lab=IN}
C {rcline.sym} 520 -150 0 0 {name=x1 L=1e-4 W=0.5e-6
C {rcline.sym} 530 -170 0 0 {name=x1 L=1e-4 W=0.5e-6
}
C {code_shown.sym} 890 -190 0 0 {name=STIMULI
only_toplevel=false