From 82d623a35a9daf0cf389d5e4cb50edddcd1fb0e4 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 9 Jul 2017 12:59:22 +0200 Subject: [PATCH] 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. --- bsimcmg_benchmark_test/gummel_n.sp | 3 ++ .../devices/adms/admst/ngspiceMODULE.c.xml | 34 ++++++++++++------- .../devices/adms/admst/ngspiceMODULE.hxx.xml | 20 +++++++++-- .../devices/adms/admst/ngspiceMODULEask.c.xml | 17 ++++++++++ .../adms/admst/ngspiceMODULEdefs.h.xml | 19 +++++++++-- .../adms/admst/ngspiceMODULEsetup.c.xml | 2 ++ 6 files changed, 79 insertions(+), 16 deletions(-) diff --git a/bsimcmg_benchmark_test/gummel_n.sp b/bsimcmg_benchmark_test/gummel_n.sp index 2a3c30e85..cb1d501b5 100644 --- a/bsimcmg_benchmark_test/gummel_n.sp +++ b/bsimcmg_benchmark_test/gummel_n.sp @@ -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 diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULE.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULE.c.xml index dc887ee58..6ea922da0 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULE.c.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULE.c.xml @@ -33,27 +33,37 @@ #include "$(module)defs.h" #include "ngspice/suffix.h" - - +IFparm $(module)pTable[] = { + - - - - + IOP("%(lower-case(name))",$(module)_instance_%(name),IF_REAL,"%(name)"), - - - - + IOP("%(lower-case(name))",$(module)_instance_%(name),IF_INTEGER,"%(name)"), - - + + + + + + + + OP("%(lower-case(name))",$(module)_ask_%(name),IF_REAL,"%(attribute[name='desc']/value)"), + + + + + + + + +}; + diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml b/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml index 41b936538..09acb35b6 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml @@ -1147,6 +1147,9 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0. + + + @@ -2363,7 +2366,14 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0. - + + + + + + + + @@ -2718,7 +2728,13 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0. - + + + + + + + diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEask.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEask.c.xml index 2ebcdef42..d9bf9fb13 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULEask.c.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEask.c.xml @@ -62,6 +62,23 @@ int $(module)ask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, + + + + + + case $(module)_ask_%(name) : + value->rValue = ckt->CKTstate0[inst->GENstate + %(name)]; + return OK; + + + + + + + + + default: return(-1); } diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEdefs.h.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEdefs.h.xml index 28e8ced0b..9d85fbc8c 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULEdefs.h.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEdefs.h.xml @@ -253,10 +253,18 @@ typedef struct s$(module)instance { -#define $(module)numStates 0 - } $(module)instance ; +enum { + + + + %(name), + + + + $(module)numStates +}; /* per model data */ @@ -307,6 +315,13 @@ typedef struct s$(module)model { /* model structure */ + + + + $(module)_ask_%(name), + + + diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEsetup.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEsetup.c.xml index fe1d3511d..abba89c4f 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULEsetup.c.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEsetup.c.xml @@ -113,6 +113,8 @@ int $(module)setup (SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int * } + ((GENinstance*)here)->GENstate = *states; + *states += $(module)numStates; /* set states */