FIX: error after recursive expansion leading to wrong netlist

This commit is contained in:
Stefan Frederik 2020-11-24 13:30:42 +01:00
parent e1110a2c98
commit a9a3538a71
2 changed files with 18 additions and 8 deletions

View File

@ -32,10 +32,10 @@ BEGIN{
}
END{
print "tEDAx v1"
print "begin netlist v1 " topcell
out("tEDAx v1")
out("begin netlist v1 " topcell)
expand(topcell, "", "", "")
print "end netlist"
out("end netlist")
}
@ -52,7 +52,7 @@ function expand(cell, instname, path, maplist, i, j, subpos, subcell, subi
subinst=$3
subpos = i
sub(/__subcircuit__/, "subcircuit", $0)
print "#" spaces(hier * 2 - 1) $0
out("#" spaces(hier * 2 - 1) $0)
for(i++; ;i++) {
$0 = netlist[i]
if($1 != "__map__") break
@ -60,9 +60,10 @@ function expand(cell, instname, path, maplist, i, j, subpos, subcell, subi
$4 = resolve_node($4, path, maplist)
submaplist = submaplist " " $2 " " $4
sub(/__map__/, "map", $0)
print "#" spaces(hier * 2 - 1) $0
out("#" spaces(hier * 2 - 1) $0)
}
expand(subcell, subinst, path subinst hiersep, submaplist)
$0 = netlist[i] # restore $0 after recursive call
}
if($1 == "conn") {
dbg("conn: $2=" $2)
@ -72,7 +73,7 @@ function expand(cell, instname, path, maplist, i, j, subpos, subcell, subi
if($1 ~/^(device|footprint|value|spiceval|spicedev|comptag|pinname|pinslot|pinidx)$/) {
$2 = path $2 #refdes
}
print spaces(hier * 2) $0
out(spaces(hier * 2) $0)
if($0 ~ /^end netlist/) break
}
hier--
@ -86,6 +87,13 @@ function spaces(n, s)
return substr(s,1,n)
}
function out(s)
{
if(length(s) > 512)
print "flatten_tedax: WARNING: >> " s "\n line length > 512 chars, this breaks tEDAx" > "/dev/stderr"
print s
}
function dbg(s)
{
if(debug) print s > "/dev/stderr"

View File

@ -137,8 +137,10 @@ proc netlist {source_file show netlist_file} {
}
}
if {$netlist_type eq {tedax}} {
eval exec {awk -f $XSCHEM_SHAREDIR/tedax.awk $source_file | $XSCHEM_SHAREDIR/flatten_tedax.awk \
> $netlist_dir/$netlist_file}
if {[catch {eval exec {awk -f $XSCHEM_SHAREDIR/tedax.awk $source_file | $XSCHEM_SHAREDIR/flatten_tedax.awk \
> $netlist_dir/$netlist_file} } err] } {
puts stderr "tEDAx errors: $err"
}
if ![string compare $show "show"] {
textwindow $netlist_dir/$netlist_file
}