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{ END{
print "tEDAx v1" out("tEDAx v1")
print "begin netlist v1 " topcell out("begin netlist v1 " topcell)
expand(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 subinst=$3
subpos = i subpos = i
sub(/__subcircuit__/, "subcircuit", $0) sub(/__subcircuit__/, "subcircuit", $0)
print "#" spaces(hier * 2 - 1) $0 out("#" spaces(hier * 2 - 1) $0)
for(i++; ;i++) { for(i++; ;i++) {
$0 = netlist[i] $0 = netlist[i]
if($1 != "__map__") break 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) $4 = resolve_node($4, path, maplist)
submaplist = submaplist " " $2 " " $4 submaplist = submaplist " " $2 " " $4
sub(/__map__/, "map", $0) sub(/__map__/, "map", $0)
print "#" spaces(hier * 2 - 1) $0 out("#" spaces(hier * 2 - 1) $0)
} }
expand(subcell, subinst, path subinst hiersep, submaplist) expand(subcell, subinst, path subinst hiersep, submaplist)
$0 = netlist[i] # restore $0 after recursive call
} }
if($1 == "conn") { if($1 == "conn") {
dbg("conn: $2=" $2) 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)$/) { if($1 ~/^(device|footprint|value|spiceval|spicedev|comptag|pinname|pinslot|pinidx)$/) {
$2 = path $2 #refdes $2 = path $2 #refdes
} }
print spaces(hier * 2) $0 out(spaces(hier * 2) $0)
if($0 ~ /^end netlist/) break if($0 ~ /^end netlist/) break
} }
hier-- hier--
@ -86,6 +87,13 @@ function spaces(n, s)
return substr(s,1,n) 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) function dbg(s)
{ {
if(debug) print s > "/dev/stderr" if(debug) print s > "/dev/stderr"

View File

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