diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 7b7af40ac..98af26a3e 100644 --- a/src/frontend/inpcom.c +++ b/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); } } diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index b07bf763c..3cd6041f4 100644 --- a/src/frontend/subckt.c +++ b/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); diff --git a/src/include/ngspice/devdefs.h b/src/include/ngspice/devdefs.h index fb5ba6771..ccd6f47ad 100644 --- a/src/include/ngspice/devdefs.h +++ b/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 */ diff --git a/src/spicelib/devices/adms/admst/ngspice.xml b/src/spicelib/devices/adms/admst/ngspice.xml index ff86d807f..97be268db 100644 --- a/src/spicelib/devices/adms/admst/ngspice.xml +++ b/src/spicelib/devices/adms/admst/ngspice.xml @@ -1,9 +1,14 @@ +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 +--> @@ -3279,33 +3284,33 @@ MAINTAINERCLEANFILES = Makefile.in #include "$(module)itf.h" -SPICEdev $(module)info = { - { "$module", - "$module created by adms", - &$(module)nSize, - &$(module)nSize, - $(module)names, - &$(module)pTSize, - $(module)pTable, - &$(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", + &$(module)nSize, + &$(module)nSize, + $(module)names, + &$(module)pTSize, + $(module)pTable, + &$(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 = { &$(module)iSize, /* DEVinstSize */ &$(module)mSize /* DEVmodSize */ + }, /*SPICEdev*/ + NULL, /*mkn*/ + NULL /*mkj*/ }; -SPICEdev * +SPICEadmsdev * get_$(module)_info(void) { - return &$(module)info; + return &$(module)admsinfo; } @@ -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->$(module)nextModel ) diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index e2468785d..bce192bc3 100644 --- a/src/spicelib/devices/dev.c +++ b/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; }