allow "xschem descned -<n>" (n=number) to descend into nth rightmost instance; added traversal.awk script
This commit is contained in:
parent
0dfbc9ded9
commit
a14c541d9e
|
|
@ -13,7 +13,7 @@ put /local/install_shares {
|
||||||
keys.help xschem.help xschem.tcl break.awk convert_to_verilog2001.awk
|
keys.help xschem.help xschem.tcl break.awk convert_to_verilog2001.awk
|
||||||
flatten.awk flatten_tedax.awk flatten_savenodes.awk make_sym.awk make_sym_lcc.awk symgen.awk order_labels.awk
|
flatten.awk flatten_tedax.awk flatten_savenodes.awk make_sym.awk make_sym_lcc.awk symgen.awk order_labels.awk
|
||||||
sort_labels.awk spice.awk tedax.awk verilog.awk vhdl.awk hspice_backannotate.tcl add_custom_menu.tcl
|
sort_labels.awk spice.awk tedax.awk verilog.awk vhdl.awk hspice_backannotate.tcl add_custom_menu.tcl
|
||||||
change_index.tcl resources.tcl xschemrc ngspice_backannotate.tcl gschemtoxschem.awk
|
change_index.tcl resources.tcl xschemrc ngspice_backannotate.tcl gschemtoxschem.awk traversal.awk
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate a list of objects from the list of source files
|
# generate a list of objects from the list of source files
|
||||||
|
|
|
||||||
|
|
@ -1288,7 +1288,7 @@ int descend_schematic(int instnumber)
|
||||||
if(inst_mult > 1) { /* on multiple instances ask where to descend, to correctly evaluate
|
if(inst_mult > 1) { /* on multiple instances ask where to descend, to correctly evaluate
|
||||||
the hierarchy path you descend to */
|
the hierarchy path you descend to */
|
||||||
|
|
||||||
if(instnumber <= 0 ) {
|
if(instnumber == 0 ) {
|
||||||
const char *inum;
|
const char *inum;
|
||||||
tclvareval("input_line ", "{input instance number (leftmost = 1) to descend into:\n"
|
tclvareval("input_line ", "{input instance number (leftmost = 1) to descend into:\n"
|
||||||
"negative numbers select instance starting\nfrom the right (rightmost = -1)}"
|
"negative numbers select instance starting\nfrom the right (rightmost = -1)}"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
proc traversal {file} {
|
||||||
|
if { $file eq {} || [file exists $file] } {
|
||||||
|
puts stderr "empty or existing file..."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
xschem unselect_all
|
||||||
|
xschem set no_draw 1 ;# disable screen update
|
||||||
|
xschem set no_undo 1 ;# disable undo
|
||||||
|
set fd [open $file "w"]
|
||||||
|
hier_traversal $fd 0
|
||||||
|
xschem set no_draw 0
|
||||||
|
xschem set no_undo 0
|
||||||
|
close $fd
|
||||||
|
}
|
||||||
|
|
||||||
|
# return "$n * $indent" spaces
|
||||||
|
proc spaces {n} {
|
||||||
|
set indent 4
|
||||||
|
set n [expr {$n * $indent}]
|
||||||
|
return [format %${n}s {}]
|
||||||
|
}
|
||||||
|
|
||||||
|
# recursive procedure
|
||||||
|
proc hier_traversal {fd {level 0}} {
|
||||||
|
set schpath [xschem get sch_path]
|
||||||
|
set instances [xschem get instances]
|
||||||
|
for {set i 0} { $i < $instances} { incr i} {
|
||||||
|
set instname [xschem getprop instance $i name]
|
||||||
|
set symbol [xschem getprop instance $i cell::name]
|
||||||
|
set type [xschem getprop symbol $symbol type]
|
||||||
|
puts $fd "[spaces $level]$schpath$instname symbol: $symbol, type: $type"
|
||||||
|
if {$type eq {subcircuit}} {
|
||||||
|
set current_level [xschem get currsch]
|
||||||
|
set ninst [lindex [split [xschem expandlabel $instname] { }] 1]
|
||||||
|
for {set n 1} {$n <= $ninst} { incr n} {
|
||||||
|
xschem select instance $i
|
||||||
|
xschem descend $n
|
||||||
|
# ensure previous descend was successful
|
||||||
|
if {[xschem get currsch] == $current_level + 1} {
|
||||||
|
incr level
|
||||||
|
hier_traversal $fd $level
|
||||||
|
xschem go_back
|
||||||
|
incr level -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue