From a9a3538a715799f2dedbed1d97b4c98a8c856dcf Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Tue, 24 Nov 2020 13:30:42 +0100 Subject: [PATCH] FIX: error after recursive expansion leading to wrong netlist --- src/flatten_tedax.awk | 20 ++++++++++++++------ src/xschem.tcl | 6 ++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/flatten_tedax.awk b/src/flatten_tedax.awk index 5a4ef720..7f47afe3 100755 --- a/src/flatten_tedax.awk +++ b/src/flatten_tedax.awk @@ -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" diff --git a/src/xschem.tcl b/src/xschem.tcl index 08321376..b9760659 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -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 }