try to allow access to (*desc*) exported values in the "state" vector

variables which are annotated with (*desc*) will be put into the "state"
vector. "OP" definitions for them will be emited, and the device_ask() function
will be extended to query these values.

issues:
  save @instance[varname]
is required,
otherwise, only the very last value will be saved in a "scalar" instead of
  all the results in a "vector"

there might well be issues with upper/lower case.
I lower-cased all variable names, because the ngspice frontend
  does so as well. but I've seen some parameters which are not lower-cased.
it might be these can not be accessed even though they are present,
  simply because it is not possible to "name" a non lower-cased thing.

this is merly a hack for bsimcmg,
  there was pretty not testing at all, and no consideration
  was given to the other models at all.
This commit is contained in:
rlar 2017-07-09 12:59:22 +02:00 committed by Holger Vogt
parent ac263f9cc7
commit 82d623a35a
6 changed files with 79 additions and 16 deletions

View File

@ -26,8 +26,11 @@ m1 drain gate source bulk 0 nmos1 TFIN=15n L=30n NFIN=10 NRS=1 NRD=1
.print dc par'ids' par'gx' par'gx2' par'gx3' par 'gx4'
.control
save @m1[VDSSAT]
run
show all
plot -i(vdrain)
plot @m1[VDSSAT]
.endc
.end

View File

@ -33,27 +33,37 @@
#include "$(module)defs.h"
#include "ngspice/suffix.h"
<admst:text format="IFparm $(module)pTable[] = {\n"/>
<admst:join select="variable[parametertype='instance' and input='yes']" separator=",\n">
IFparm $(module)pTable[] = {
<admst:for-each select="variable[parametertype='instance' and input='yes']">
<admst:choose>
<admst:when test="[type='real']">
<admst:value-of select="name"/>
<admst:value-of select="name"/>
<admst:value-of select="lower-case(name)"/>
<admst:text format=" IOP(&quot;%s&quot;,$(module)_instance_%s,IF_REAL,&quot;%s&quot;)"/>
IOP("%(lower-case(name))",$(module)_instance_%(name),IF_REAL,"%(name)"),
</admst:when>
<admst:when test="[type='integer']">
<admst:value-of select="name"/>
<admst:value-of select="name"/>
<admst:value-of select="lower-case(name)"/>
<admst:text format=" IOP(&quot;%s&quot;,$(module)_instance_%s,IF_INTEGER,&quot;%s&quot;)"/>
IOP("%(lower-case(name))",$(module)_instance_%(name),IF_INTEGER,"%(name)"),
</admst:when>
<admst:otherwise>
<admst:fatal format="parameter of type 'string' not supported\n"/>
</admst:otherwise>
</admst:choose>
</admst:join>
<admst:text format="\n};\n"/>
</admst:for-each>
<admst:for-each select="variable">
<admst:if test="attribute[name='desc']">
<admst:if test="[not((input='yes' and (parametertype='model' or parametertype='instance')) or (input='np' and (scope='global_model' or scope='global_instance')))]">
<admst:choose>
<admst:when test="[type='real']">
OP("%(lower-case(name))",$(module)_ask_%(name),IF_REAL,"%(attribute[name='desc']/value)"),
</admst:when>
<admst:otherwise>
<admst:fatal format="parameter of type 'string' not supported\n"/>
</admst:otherwise>
</admst:choose>
</admst:if>
</admst:if>
</admst:for-each>
};
<admst:text format="IFparm $(module)mPTable[] = {\n"/>
<admst:join select="variable[parametertype='model' and input='yes']" separator=",\n">
<admst:choose>

View File

@ -1147,6 +1147,9 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0.
<admst:when test="[input='no' and scope='global_instance']">
<admst:variable name="e" select="pInst-&gt;%(name)"/>
</admst:when>
<admst:when test="attribute[name='desc']">
<admst:variable name="e" select="ckt->CKTstate0[((GENinstance*)here)->GENstate + %(name)]"/>
</admst:when>
<admst:otherwise>
<admst:variable name="e" select="%(name)"/>
</admst:otherwise>
@ -2363,7 +2366,14 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0.
</admst:when>
</admst:choose>
</admst:for-each>
<admst:text format="%(lhs/name)=$allep;\n"/>
<admst:choose>
<admst:when test="lhs/attribute[name='desc']">
<admst:text format="ckt->CKTstate0[((GENinstance*)here)->GENstate + %(lhs/name)]=$allep; /* indeed 3 */\n"/>
</admst:when>
<admst:otherwise>
<admst:text format="%(lhs/name)=$allep; /* indeed 3 */\n"/>
</admst:otherwise>
</admst:choose>
<admst:text format="EXIT_IF_ISNAN(%(lhs/name))\n"/>
<admst:text format="#endif\n"/>
</admst:when>
@ -2718,7 +2728,13 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0.
</admst:new>
<admst:if test="block/adms[datatypename='module']">
<admst:text test="[static='no' and dynamic='yes']" format="#if defined(_DYNAMIC)\n"/>
<admst:text test="[scope='local']" format="%(vtype(.)) %(name);\n"/>
<admst:choose>
<admst:when test="attribute[name='desc']">
</admst:when>
<admst:otherwise>
<admst:text test="[scope='local']" format="%(vtype(.)) %(name);\n"/>
</admst:otherwise>
</admst:choose>
<admst:if test="[insource='yes']/probe">
<admst:for-each select="probe">
<admst:variable name="pprobe" select="%(.)"/>

View File

@ -62,6 +62,23 @@ int $(module)ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value,
</admst:choose>
<admst:text format=" return OK;\n"/>
</admst:for-each>
<admst:for-each select="variable">
<admst:if test="attribute[name='desc']">
<admst:if test="[not((input='yes' and (parametertype='model' or parametertype='instance')) or (input='np' and (scope='global_model' or scope='global_instance')))]">
<admst:choose>
<admst:when test="[type='real']">
case $(module)_ask_%(name) :
value->rValue = ckt->CKTstate0[inst->GENstate + %(name)];
return OK;
</admst:when>
<admst:otherwise>
<admst:fatal format="parameter of type 'string' not supported\n"/>
</admst:otherwise>
</admst:choose>
</admst:if>
</admst:if>
</admst:for-each>
default:
return(-1);
}

View File

@ -253,10 +253,18 @@ typedef struct s$(module)instance {
</admst:if>
</admst:for-each>
#define $(module)numStates 0
} $(module)instance ;
enum {
<admst:for-each select="variable">
<admst:if test="attribute[name='desc']">
<admst:if test="[not((input='yes' and (parametertype='model' or parametertype='instance')) or (input='np' and (scope='global_model' or scope='global_instance')))]">
%(name),
</admst:if>
</admst:if>
</admst:for-each>
$(module)numStates
};
/* per model data */
@ -307,6 +315,13 @@ typedef struct s$(module)model { /* model structure */
<admst:value-of select="name"/>
<admst:text format=" $(module)_instance_%s,\n"/>
</admst:for-each>
<admst:for-each select="variable">
<admst:if test="attribute[name='desc']">
<admst:if test="[not((input='yes' and (parametertype='model' or parametertype='instance')) or (input='np' and (scope='global_model' or scope='global_instance')))]">
$(module)_ask_%(name),
</admst:if>
</admst:if>
</admst:for-each>
<admst:text format=" DUMMY_INSTANCE"/>
<admst:text format="\n} e_$(module)_instance;\n"/>

View File

@ -113,6 +113,8 @@ int $(module)setup (SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *
</admst:for-each>
}
</admst:if>
((GENinstance*)here)->GENstate = *states;
*states += $(module)numStates;
/* set states */
<admst:for-each select="source[dynamic='yes']">
<admst:value-of select="branch/nnode/name"/>