update xschemtest, more robust spice flatten.awk netlist flattener, specifically when translating expressions containing electrical nodes and parameters, all these need to be translated/substituted.

This commit is contained in:
Stefan Frederik 2022-10-12 01:16:23 +02:00
parent ce75ca2bbf
commit 662c14143d
7 changed files with 1989 additions and 1937 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Xschem" Language="1033" Version="3.1.1" Manufacturer="Xschem" UpgradeCode="0deb9c17-cbbd-491c-be3e-24446b27ccd5">
<Product Id="*" Name="Xschem" Language="1033" Version="3.1.2" Manufacturer="Xschem" UpgradeCode="0deb9c17-cbbd-491c-be3e-24446b27ccd5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<WixVariable Id="WixUILicenseRtf"
Value="License.rtf" />

File diff suppressed because it is too large Load Diff

View File

@ -389,12 +389,6 @@
<Component Id="cmpEE71F9B2266EB5D5942CCFD07E500A7B" Guid="{2F5161AB-FDE5-4F23-BFA7-BAB51687A35A}">
<File Id="fil3E54C9EB76BA0C4948F348194C65BC0C" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\cmos_inv.sym" />
</Component>
<Component Id="cmp7B638600CF97F07A1A28630B8B0AA89D" Guid="{13525D30-3B86-4CF2-95EA-C1FA17E82CD1}">
<File Id="fil336C8A349DF3CF8C433D345DEDC3BA60" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\cross.sch" />
</Component>
<Component Id="cmp9EA5369C321EA6C92B5E5252E1232CCE" Guid="{9883ECAA-3FD6-4F6E-82E8-0AACCAC690DD}">
<File Id="fil7C5844700BE513415386982411303722" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\cross.sym" />
</Component>
<Component Id="cmp6758C5CAFB49CCFE98ED4A0CB79444A2" Guid="{8A248740-7FDF-4900-A491-2C5FF43270D2}">
<File Id="filB0C628ED9C6CE9A400A928741D85657E" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\diode_1.sch" />
</Component>
@ -641,6 +635,12 @@
<Component Id="cmp653D0A919716C77B0160A681BB3332EC" Guid="{C96DAE2B-0D94-4BD4-803E-8914DB2DB851}">
<File Id="fil8C86CA039409D917D8D2709BC846BEF9" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\TwoStageAmp.sch" />
</Component>
<Component Id="cmp9006ACB643F7A2C6C3634882DBF943FA" Guid="{B88F52AD-D170-496D-8FA4-21B513C11A6E}">
<File Id="filF1A62E77676511ECA0E3FE5EDEF8A841" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\xcross.sch" />
</Component>
<Component Id="cmp30D416247CB7868426C9E8075767CD1A" Guid="{52EE3186-47F1-4EB5-9197-98C830178888}">
<File Id="filF5A70F7E36226A2E9F1F9AA2B0CAA833" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\xcross.sym" />
</Component>
<Component Id="cmpB573F1750B3939F980B65D02B78EE0E3" Guid="{3286D1EA-EA76-4CA3-A542-E335B89FBBFD}">
<File Id="filBCAF4D858D3BA6A0902F217004CD2351" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\examples\xnor.sch" />
</Component>
@ -5558,8 +5558,6 @@
<ComponentRef Id="cmp32F04546D3D34E506668FDCAF140AD26" />
<ComponentRef Id="cmp691FABAD9E70CAB633C4951FA945525F" />
<ComponentRef Id="cmpEE71F9B2266EB5D5942CCFD07E500A7B" />
<ComponentRef Id="cmp7B638600CF97F07A1A28630B8B0AA89D" />
<ComponentRef Id="cmp9EA5369C321EA6C92B5E5252E1232CCE" />
<ComponentRef Id="cmp6758C5CAFB49CCFE98ED4A0CB79444A2" />
<ComponentRef Id="cmpDAB9FD1BFB650AB1F914EC01154D3191" />
<ComponentRef Id="cmpADED9789CB9FCC2F3F7C192D39844489" />
@ -5642,6 +5640,8 @@
<ComponentRef Id="cmp7BBFD4FFD4BD205783E8852433FC5873" />
<ComponentRef Id="cmp5AF7A46758E91CA41D0CD61668C9C69A" />
<ComponentRef Id="cmp653D0A919716C77B0160A681BB3332EC" />
<ComponentRef Id="cmp9006ACB643F7A2C6C3634882DBF943FA" />
<ComponentRef Id="cmp30D416247CB7868426C9E8075767CD1A" />
<ComponentRef Id="cmpB573F1750B3939F980B65D02B78EE0E3" />
<ComponentRef Id="cmp07A884BAD56D6B1718967173C498C3C3" />
<ComponentRef Id="cmp93CCC992DFDB8670EC1762AF056E9A71" />

View File

@ -39,14 +39,16 @@ BEGIN{
# topcell=toupper(ARGV[2])
# ARGC=2
first_subckt = 1
global["0"] = 1 # 0 is always a global reference node
pathsep="_"
nodes["M"]=4; nodes["R"]=2; nodes["D"]=2; nodes["V"]=2
nodes["I"]=2; nodes["C"]=2; nodes["L"]=2; nodes["Q"]=3
nodes["E"]=4; nodes["G"]=4; nodes["H"]=2; nodes["F"]=2
nodes["B"]=2; nodes["S"]=4
}
{
if( ($0 !~/^\.include/) && ($0 !~/^\.INCLUDE/) ) $0=toupper($0)
# allow to specify *.nodes[W]=2 or *.nodes["W"] = 2 in the netlist for additional
if( toupper($0) !~/^(\.INCLUDE|\.LIB|\.WRITE| *WRITE)/) $0=toupper($0)
# allow to specify *.nodes[W]=2 or *.nodes["W"] = 2 metadata in the netlist for additional
# custom devices nodes specification.
if($0 ~/^[ \t]*\*\.[ \t]*NODES\["?[^]["]"?\][ \t]*=[ \t]*.*/) {
n_nodes = $0
@ -68,6 +70,8 @@ BEGIN{
{
a[lines-1]=a[lines-1] " " substr($0,2); next
}
gsub(/[\t ]*=[\t ]*/, "=")
a[lines++]=$0
}
@ -172,16 +176,21 @@ function expand(name, path, param,ports, # func. params
{
if(line[1] ~ devpattern)
{
nn = nodes[substr(line[1],1,1)]
if(a[j] ~ /^[GE].*(VALUE|CUR|VOL)=/) nn = 2 # behavioral VCVS/VCCS have 2 nodes only
printf "%s ",line[1] pathname
for(k=2;k<=nodes[substr(line[1],1,1)]+1;k++)
for(k = 2; k <= nn + 1; k++)
printf "%s ", getnode(name,pathnode,portarray,line[k])
for(; k<=num;k++)
{
if(line[1] ~ /[FH]/ && k==4) printf "%s ", line[k] pathname
else if(line[k] ~/.*VALUE=.*/)
printf "%s ",general_sub(line[k],name,pathnode,portarray)
else if(line[k] ~/=/)
{
if(line[1] ~ /^[FH]/ && k==4) printf "%s ", line[k] pathname
else if(line[k] ~ /^(VALUE|VOL|CUR|R|C|L|V|I)=/) {
# expressions contain spaces, but usually end the line. Concatenate all fields into line[k]
for(m = k + 1; m <= num; m++) line[k] = line[k] " " line[m]
printf "%s ",general_sub(subst_param(line[k], paramarray2),name,pathnode,portarray)
break
}
else if(line[k] ~/=/) {
split(line[k],parameter,"=")
if(parameter[2] in paramarray2)
printf "%s ", parameter[1] "=" paramarray2[parameter[2]]
@ -189,17 +198,47 @@ function expand(name, path, param,ports, # func. params
printf "%s ",parameter[1] "=" subckt[name,"param",parameter[2]]
else printf "%s ",line[k]
}
else printf "%s ", line[k]
else { # if parameter get actual value
if(line[k] in paramarray2) line[k] = paramarray2[line[k]]
else { # try to see if parameter inside quotes or braces
m = line[k]
gsub(/[{}']/, "", m)
if(m in paramarray2) line[k] = paramarray2[m]
}
printf "%s ", line[k]
}
}
}
else
printf "%s ", a[j]
else if(line[1] ~/^\.(SAVE|PRINT|PROBE)/) {
printf "%s ", general_sub(a[j],name,pathnode,portarray)
}
else {
printf "%s ", a[j]
}
printf "\n"
}
}
}
function subst_param(s, pa, p, i, ss)
{
for(p in pa) {
while(1) {
i = match(s, "[^a-zA-Z0-9_]" p "[^=a-zA-Z0-9_]")
ss = ""
if(i) {
ss = ss substr(s, 1, RSTART)
ss = ss pa[p]
ss = ss substr(s, RSTART + RLENGTH - 1)
s = ss
}
if(!i) {
break
}
}
}
return s
}
@ -208,6 +247,8 @@ function getnode(name, path, portarray, node)
# return the full path-name of <node> in subckt <name>
# in path <path>, called with ports <portarray>
{
sub(/ *$/, "", node)
sub(/^ */, "", node)
if(name!=topcell) # if we are in top cell, nothing to do
{
if(name SUBSEP "port" SUBSEP node in subckt)
@ -219,16 +260,27 @@ function getnode(name, path, portarray, node)
}
# expand expressions like: VALUE=3*V(IN)+VA)
# expand expressions like: VALUE=3*V(IN)+VA) or I={V(nn,mm) *1e-6}
# substituting node names
function general_sub(string,name,pathnode,portarray, nod,sss)
function general_sub(string,name,pathnode,portarray, nod, sss, state, lastc)
{
while(match(string, /V\([^\(\)]*\)/ ))
{
nod = substr(string,RSTART+2,RLENGTH-3)
sss=sss substr(string,1,RSTART-1) "V(" \
getnode(name,pathnode,portarray,nod) ")"
string=substr(string,RSTART+RLENGTH)
state = 0
while(1) {
# print "****** " string
if(state == 0 && match(string, /V\([^(),]*[,)]/)) { # match V(XXX) or V(XXX,
# print "***** here0"
lastc = substr(string, RSTART+RLENGTH-1, 1)
if(lastc == ",") state =1
nod = substr(string,RSTART+2,RLENGTH-3)
sss=sss substr(string,1,RSTART-1) "V(" getnode(name,pathnode,portarray,nod) lastc
string=substr(string,RSTART+RLENGTH)
} else if(state == 1 && match(string, /[^(),]*[)]/)) { # match YYY) only if state==1
# print "***** here1"
nod = substr(string,RSTART,RLENGTH-1)
sss=sss substr(string,1,RSTART-1) getnode(name,pathnode,portarray,nod) ")"
string=substr(string,RSTART+RLENGTH)
state = 0
} else break
}
sss=sss string
return sss

View File

@ -192,13 +192,13 @@ proc netlist_test {} {
foreach {f t h} {
rom8k.sch spice 1975420796
greycnt.sch verilog 2415454714
autozero_comp.sch spice 2275498269
autozero_comp.sch spice 1181616733
loading.sch vhdl 584526899
mos_power_ampli.sch spice 1004049459
hierarchical_tedax.sch tedax 998070173
LCC_instances.sch spice 2610855064
pcb_test1.sch tedax 1925087189
test_doublepin.sch spice 1447757360
test_doublepin.sch spice 556408606
simulate_ff.sch spice 1321596936
} {
xschem set netlist_type $t

View File

@ -231,7 +231,7 @@ C {lab_pin.sym} 200 -570 0 1 {name=p126 lab=CALB}
C {lab_pin.sym} 120 -570 0 0 {name=l50 lab=CAL}
C {code.sym} 840 -190 0 0 {name=STIMULI
only_toplevel=true
place=end
xxplace=end
value="* .option SCALE=1e-6
.option method=gear $$ seed=12
.param VCC=0.9

View File

@ -78,7 +78,7 @@ C {vsource.sym} 270 -640 0 0 {name=v2 value="'VCC/2'"}
C {lab_pin.sym} 270 -610 0 0 {name=p34 lab=0}
C {code_shown.sym} 10 -440 0 0 {name=CONTROL
tclcommand="xschem edit_vi_prop"
place=end
xxplace=end
value="
** download the models from:
** https://ptm.asu.edu/modelcard/65nm_bulk.txt