Browse Source

added SPICEadmsdev - a super structure of SPICEdev used to build dynamic device libraries

r29173 14 years ago
parent
commit
bab7e17a6a
  1. 4
      src/frontend/inpcom.c
  2. 34
      src/frontend/subckt.c
  3. 9
      src/include/ngspice/devdefs.h
  4. 78
      src/spicelib/devices/adms/admst/ngspice.xml
  5. 12
      src/spicelib/devices/dev.c

4
src/frontend/inpcom.c

@ -1540,7 +1540,11 @@ comment_out_unused_subckt_models( struct line *start_card , int no_of_lines)
found_model = FALSE;
for ( i = 0; i < num_used_model_names; i++ )
if ( strcmp( used_model_names[i], model_name ) == 0 || model_bin_match( used_model_names[i], model_name ) ) found_model = TRUE;
#ifdef ADMS
/* ngspice strategy to detect unused models fails with dynamic models - reason: # of terms unknown during parsing */
#else
if ( !found_model ) *line = '*';
#endif
tfree(model_name);
}
}

34
src/frontend/subckt.c

@ -1881,10 +1881,39 @@ devmodtranslate(struct line *deck, char *subname)
tfree(s->li_line);
s->li_line = buffer;
break;
case 'u': /* urc transmissionline */
#ifdef ADMS
name = gettok_node(&t); /* this can be either a model name or a node name. */
for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) {
if (eq(name, wlsub->wl_word)) { /* a three terminal bjt */
(void) sprintf(buffer + strlen(buffer), "%s:%s ",
subname, name);
found = TRUE;
break;
}
}
while (!found) {
(void) sprintf(buffer + strlen(buffer), "%s ", name);
tfree(name);
name = gettok_node(&t); /* this can be either a model name or a node name. */
for (wlsub = submod; wlsub; wlsub = wlsub->wl_next) {
if (eq(name, wlsub->wl_word)) { /* a three terminal bjt */
(void) sprintf(buffer + strlen(buffer), "%s:%s ",
subname, name);
found = TRUE;
break;
}
}
}
found = FALSE;
(void) strcat(buffer, t);
tfree(s->li_line);
s->li_line = buffer;
break;
#endif
/* 3 terminal devices */
case 'w': /* current controlled switch */
case 'u': /* urc transmissionline */
case 'j': /* jfet */
case 'z': /* hfet, mesa */
name = gettok(&t);
@ -2028,6 +2057,9 @@ devmodtranslate(struct line *deck, char *subname)
}
}
#endif
if (!found) /* Fallback w/o subckt name before */
(void) sprintf(buffer + strlen(buffer), "%s ", name);
tfree(name);

9
src/include/ngspice/devdefs.h

@ -103,6 +103,15 @@ typedef struct SPICEdev {
} SPICEdev; /* instance of structure for each possible type of device */
#ifdef ADMS
typedef struct SPICEadmsdev {
SPICEdev spicedev;
int (*DEVunsetup)(GENmodel*,CKTcircuit*);
int (*mkn)(GENmodel *, CKTcircuit *);
int (*mkj)(CKTcircuit *, GENmodel *, IFuid);
} SPICEadmsdev;
#endif
extern SPICEdev **DEVices;
extern int DEVmaxnum; /* size of DEVices array */

78
src/spicelib/devices/adms/admst/ngspice.xml

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE admst PUBLIC "-//noovela//DTD_ADMST 2.3.0//FR" "admst.dtd">
<!--
import file admst.dtd: wget http://www.noovela.com:8001/svn/adms/trunk/admst.dtd
validate: xmllint ngspice.xml -noout -postvalid -noblanks
-->
Tool 'ngspice.xml'
Copyright © 2011 Noovela - Author Laurent Lemaitre
This code IS to be used for non-commercial usage ONLY.
Note: publishing technical papers with the affiliation of a commercial company
which results are produced by the tool are typical commercial usage of the tool.
Commercial usage are subject to special fees.
Contact: r29173@noovela.com or www.noovela.com
-->
<admst xmlns:admst="http://mot-adms.sourceforge.net/adms/admst.xml" version="2.3.0">
<admst:value-to select="/#simulator" string="ngspice"/>
<admst:variable name="zddx"/>
@ -3279,33 +3284,33 @@ MAINTAINERCLEANFILES = Makefile.in
#include &quot;$(module)itf.h&quot;
SPICEdev $(module)info = {
{ "$module",
"$module created by adms",
&amp;$(module)nSize,
&amp;$(module)nSize,
$(module)names,
&amp;$(module)pTSize,
$(module)pTable,
&amp;$(module)mPTSize,
$(module)mPTable,
#ifdef XSPICE
/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/
NULL, /* This is a SPICE device, it has no MIF info data */
0, /* This is a SPICE device, it has no MIF info data */
NULL, /* This is a SPICE device, it has no MIF info data */
0, /* This is a SPICE device, it has no MIF info data */
NULL, /* This is a SPICE device, it has no MIF info data */
0, /* This is a SPICE device, it has no MIF info data */
NULL, /* This is a SPICE device, it has no MIF info data */
/*--------------------------- End of SDB fix -------------------------*/
#endif
DEV_DEFAULT
},
SPICEadmsdev $(module)admsinfo = {
{
{ "$module",
"$module created by adms",
&amp;$(module)nSize,
&amp;$(module)nSize,
$(module)names,
&amp;$(module)pTSize,
$(module)pTable,
&amp;$(module)mPTSize,
$(module)mPTable,
#ifdef XSPICE
/*---- Fixed by SDB 5.2.2003 to enable XSPICE/tclspice integration -----*/
NULL, /* This is a SPICE device, it has no MIF info data */
0, /* This is a SPICE device, it has no MIF info data */
NULL, /* This is a SPICE device, it has no MIF info data */
0, /* This is a SPICE device, it has no MIF info data */
NULL, /* This is a SPICE device, it has no MIF info data */
0, /* This is a SPICE device, it has no MIF info data */
NULL, /* This is a SPICE device, it has no MIF info data */
/*--------------------------- End of SDB fix -------------------------*/
#endif
DEV_DEFAULT
},
$(module)par, /* DEVparam */
$(module)mParam, /* DEVmodParam */
$(module)load, /* DEVload */
@ -3340,12 +3345,15 @@ SPICEdev $(module)info = {
&amp;$(module)iSize, /* DEVinstSize */
&amp;$(module)mSize /* DEVmodSize */
}, /*SPICEdev*/
NULL, /*mkn*/
NULL /*mkj*/
};
SPICEdev *
SPICEadmsdev *
get_$(module)_info(void)
{
return &amp;$(module)info;
return &amp;$(module)admsinfo;
}
</admst:template>
@ -3370,7 +3378,7 @@ get_$(module)_info(void)
#ifndef DEV_$(module)
#define DEV_$(module)
extern SPICEdev *get_$(module)_info(void);
extern SPICEadmsdev *get_$(module)_info(void);
#endif
@ -4322,8 +4330,8 @@ int $(module)setup (SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *
register $(module)instance *here;
typedef int FP1(CKTcircuit *ckt, CKTnode **node, IFuid basename, char *suffix);
typedef double * FP2(SMPmatrix *Matrix, int Row, int Col);
FP1*myCKTmkVolt=(FP1*)get_$(module)_info()->DEVunsetup;
FP2*mySMPmakeElt=(FP2*)get_$(module)_info()->DEVfindBranch;
FP1*myCKTmkVolt=(FP1*)get_$(module)_info()->mkn;
FP2*mySMPmakeElt=(FP2*)get_$(module)_info()->mkj;
/* loop through all the $(module) device models */
for ( ;model != NULL ;model = model-&gt;$(module)nextModel )

12
src/spicelib/devices/dev.c

@ -191,7 +191,7 @@ int load_vadev(CKTcircuit *ckt, char *name)
{
char libname[50];
void *lib;
SPICEdev *device;
SPICEadmsdev *device;
int l=(int)strlen("lib")+(int)strlen(name)+(int)strlen(".so");
@ -213,18 +213,18 @@ int load_vadev(CKTcircuit *ckt, char *name)
strcpy(libname, "get_");
strcat(libname,name);
strcat(libname,"_info");
device = ((SPICEdev * (*)(void)) lt_dlsym(lib,libname)) ();
device = ((SPICEadmsdev * (*)(void)) lt_dlsym(lib,libname)) ();
if(!device){
perror (lt_dlerror ());
return -1;
}
device->DEVunsetup = ((int (*)(GENmodel *, CKTcircuit *)) &CKTmkVolt);
device->DEVfindBranch = ((int (*)(CKTcircuit *, GENmodel *, IFuid)) &SMPmakeElt);
device->mkn = ((int (*)(GENmodel *, CKTcircuit *)) &CKTmkVolt);
device->mkj = ((int (*)(CKTcircuit *, GENmodel *, IFuid)) &SMPmakeElt);
DEVices = TREALLOC(SPICEdev *, DEVices, DEVNUM + 1);
printf("Added device: %s\n",device->DEVpublic.name);
DEVices[DEVNUM++] = device;
printf("Added device: %s from dynamic library %s\n",((SPICEdev *)device)->DEVpublic.name,libname);
DEVices[DEVNUM++] = (SPICEdev *)device;
varelink(ckt);
return DEVNUM-1;
}

Loading…
Cancel
Save