From 8305024cd609aa98358b614c3fd50958301d2807 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 2 Dec 2023 23:00:44 +0100 Subject: [PATCH] break.awk: do not break user code lines in spice netlists --- src/break.awk | 11 ++++++++--- tests/xschemtest.tcl | 10 +++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/break.awk b/src/break.awk index a8d061d0..ec9e6627 100755 --- a/src/break.awk +++ b/src/break.awk @@ -25,6 +25,8 @@ BEGIN{ quote=0 } +/^\*\*\*\* begin user architecture code/ { user_code = 1 } + { pos=0 sub(/[ \t]*$/, "") # chop trailing white space @@ -32,7 +34,8 @@ BEGIN{ quote=0 } first = substr($0,1,1) # dont break .include lines as ngspice chokes on these. - if(tolower($1) ~ /\.inc(lude)?|\.lib|\.title|\.save|\.write/) nobreak = 1 + if(user_code == 1) nobreak = 1 + else if(tolower($1) ~ /\.inc(lude)?|\.lib|\.title|\.save|\.write/) nobreak = 1 else if($0 ~/^\*\* ..._path:/) nobreak = 1 else nobreak = 0 # 20151203 faster executionif no {}' present @@ -42,7 +45,7 @@ BEGIN{ quote=0 } pos++ c = substr($0,i,1) if(c ~/[{}']/) quote=!quote - if(!nobreak && pos> 100 && !quote && (c ~/[ \t]/)) { + if(!nobreak && pos> 130 && !quote && (c ~/[ \t]/)) { if(first=="*") c = "\n*+" c else @@ -56,7 +59,7 @@ BEGIN{ quote=0 } split($0, a, /[^ \t]+/) for(i=1;i<=NF;i++) { pos += length($i)+length(a[i]) - if(!nobreak && pos>100) { + if(!nobreak && pos>130) { if(first=="*") { printf "%s", "\n*+" } else { @@ -71,3 +74,5 @@ BEGIN{ quote=0 } printf "\n" } } + +/^\*\*\*\* end user architecture code/ { user_code = 0 } diff --git a/tests/xschemtest.tcl b/tests/xschemtest.tcl index eb997144..96f89609 100644 --- a/tests/xschemtest.tcl +++ b/tests/xschemtest.tcl @@ -190,21 +190,21 @@ proc test_xschem_simulation {{f simulate_ff.sch}} { proc netlist_test {} { global netlist_dir foreach {f t h} { - rom8k.sch spice 1947979332 + rom8k.sch spice 665784374 greycnt.sch verilog 3032956185 autozero_comp.sch spice 751826850 test_generators.sch spice 49312823 - inst_sch_select.sch spice 2444330953 - test_bus_tap.sch spice 181420586 + inst_sch_select.sch spice 2432089114 + test_bus_tap.sch spice 188702715 loading.sch vhdl 2975204502 mos_power_ampli.sch spice 125840804 hierarchical_tedax.sch tedax 998070173 - LCC_instances.sch spice 696885230 + LCC_instances.sch spice 1646579002 pcb_test1.sch tedax 1925087189 test_doublepin.sch spice 4159808692 simulate_ff.sch spice 574849766 test_symbolgen.sch spice 2593807370 - test_mosgen.sch spice 21996225 + test_mosgen.sch spice 2380524013 } { xschem set netlist_type $t xschem load [abs_sym_path $f]