From 3d1f361953b8d7ac6c2162977237861328f86771 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 30 Mar 2026 10:00:14 +0200 Subject: [PATCH] spectre.awk: quote invalid identifiers (nodes, refdes) --- src/spectre.awk | 37 +++++++++++++++++++++++--------- src/spice.awk | 8 ++++--- tests/xschemtest.tcl | 2 +- xschem_library/devices/iopin.sym | 4 +++- xschem_library/devices/ipin.sym | 4 +++- xschem_library/devices/opin.sym | 4 +++- 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/spectre.awk b/src/spectre.awk index 591e60d9..5bfec6cd 100755 --- a/src/spectre.awk +++ b/src/spectre.awk @@ -36,9 +36,7 @@ BEGIN{ } } -# join split lines { - if($0 ~ /^\/\/\/\/ begin user (architecture|header) code/) { user_code = 1 } @@ -120,6 +118,7 @@ function sign(x) function process( i,j, iprefix, saveinstr, savetype, saveanalysis) { + gsub(/ *= */, "=") indent = $0 sub(/[^ \t].*/, "", indent) if($0 ~/\/\/\/\/ end_element/){ @@ -154,7 +153,7 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis) } # 20181208 do not process commented lines - if($1 ~/^\//) { + if($1 ~/^\/\//) { print return } @@ -223,13 +222,19 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis) if($0 ~ /^D/ ) sub(/PERI[ \t]*=/,"PJ=") - if( $1 ~ /^\/\.(ipin|opin|iopin)/ ) { - num=split($2,name,",") - for(i=1;i<=num;i++) print $1 " " name[i] - } else if( tolower($1) ~ /subckt/) { + #### this is never executed: commented lines are processed and skipped above + # if( $1 ~ /^\/\/\.(ipin|opin|iopin)/ ) { + # num=split($2,name,",") + # for(i=1;i<=num;i++) print $1 " " name[i] + # } else + + if( tolower($1) ~ /subckt/) { # remove m=.. from subcircuit definition since m= is a multiplier not a param sub(/ m=[0-9]+/," ",$0) gsub(","," ",$0) + for(i = 1; i <= NF; i++) { + $i = q($i) + } print $0 } else { num = split($1, name, ",") @@ -248,7 +253,7 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis) } for(i=1;i<=num;i++) { - printf "%s ", indent spiceprefix name[i] + printf "%s ", indent spiceprefix q(name[i]) for(j=2;j<=NF;j++) { @@ -256,7 +261,7 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis) # some CDL netlists have this: $SUB=?1 B where B is a node if($j !~ /^(.*=)?\?-?[0-9]+$/) { - printf "%s ", $j # if not a node just print it + printf "%s ", q($j) # if not a node just print it } else { @@ -271,7 +276,7 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis) for(l=0;l