From 9f76b7d4a697f31c78ab5e83bc6f868db00b6f59 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 13 Apr 2012 16:08:24 +0200 Subject: [PATCH] load per `admsmodel' command --- src/frontend/com_dl.c | 9 +++++++++ src/frontend/com_dl.h | 4 ++++ src/frontend/commands.c | 7 +++++++ src/include/ngspice/ngspice.h | 2 +- src/main.c | 5 +++++ src/spicelib/devices/dev.c | 35 ++++++++++++++++++++++++++-------- src/spicelib/parser/inpdomod.c | 7 +++++-- 7 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/frontend/com_dl.c b/src/frontend/com_dl.c index e0a40bddf..cd35e18d0 100755 --- a/src/frontend/com_dl.c +++ b/src/frontend/com_dl.c @@ -4,6 +4,15 @@ #include <../spicelib/devices/dev.h> /*for load library commands*/ #include "com_dl.h" +#if ADMS >= 3 || 1 +void com_admsmodel(wordlist *wl){ + wordlist *ww; + for(ww = wl;ww;ww = ww->wl_next) + if(load_vadev(wl->wl_word)) + fprintf(cp_err,"Error: ADMS Library %s couldn't be loaded!\n",ww->wl_word); + return; +} +#endif #ifdef XSPICE void com_codemodel(wordlist *wl){ wordlist *ww; diff --git a/src/frontend/com_dl.h b/src/frontend/com_dl.h index e8210cefd..2160f99b5 100755 --- a/src/frontend/com_dl.h +++ b/src/frontend/com_dl.h @@ -1,6 +1,10 @@ #ifndef _COM_DL_H #define _COM_DL_H 1 +#if ADMS >= 3 || 1 +void com_admsmodel(wordlist *wl); +#endif + #ifdef XSPICE void com_codemodel(wordlist *wl); #endif diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 6bf240025..acbee0d49 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -246,6 +246,13 @@ struct comm spcp_coms[] = { NULL, "library library ... : Loads the opus librarys." } , #endif +#if ADMS >= 3 || 1 +#warning "yea, its there" + { "admsmodel", com_admsmodel, FALSE, TRUE, + { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, + NULL, + "library library ... : Loads the adms librarys." } , +#endif #ifdef DEVLIB { "use", com_use, FALSE, TRUE, { 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS, diff --git a/src/include/ngspice/ngspice.h b/src/include/ngspice/ngspice.h index 865b17c06..dfb1db4ac 100644 --- a/src/include/ngspice/ngspice.h +++ b/src/include/ngspice/ngspice.h @@ -234,7 +234,7 @@ extern int ARCHme; /* My logical process number */ extern int ARCHsize; /* Total number of processes */ #if ADMS >= 3 || 1 -int load_vadev(CKTcircuit *ckt, char *name); +int load_vadev(char *name); #endif #ifdef TCL_MODULE diff --git a/src/main.c b/src/main.c index 22e70922c..c16e3b202 100644 --- a/src/main.c +++ b/src/main.c @@ -417,6 +417,11 @@ struct dvec *EVTfindvec(char *node){ } #endif /* XSPICE */ +int load_vadev(char *name){ + NG_IGNORE(name); + return(1); +} + #endif /* SIMULATOR */ char *hlp_filelist[] = { "ngspice", 0 }; diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index 00e515d56..0b79e6717 100644 --- a/src/spicelib/devices/dev.c +++ b/src/spicelib/devices/dev.c @@ -169,7 +169,29 @@ int DEVflag(int type){ #include "ngspice/fteext.h" /* for ft_sim */ #include "ngspice/cktdefs.h" /* for DEVmaxnum */ #include -static void varelink(CKTcircuit *ckt) { + +int +is_adms_type(const char *type_name) +{ + int i; + + if(strcmp(type_name, "hicum0")) + return -1; + + for(i=0; iDEVpublic.name)) { + printf("found %d\n", i); + return i; + } + } + + return -1; +} + +static void +relink_fixme(void) { /* * This replacement done by SDB on 6.11.2003 @@ -180,14 +202,11 @@ static void varelink(CKTcircuit *ckt) { ft_sim->numDevices = DEVNUM; DEVmaxnum = DEVNUM; - ckt->CKThead = TREALLOC(GENmodel *, ckt->CKThead, DEVmaxnum); - ckt->CKThead[DEVmaxnum-1] = NULL; - - ft_sim->devices = devices_ptr(); return; } -int load_vadev(CKTcircuit *ckt, char *name) + +int load_vadev(char *name) { char *msg, libname[50]; void *lib; @@ -228,8 +247,8 @@ int load_vadev(CKTcircuit *ckt, char *name) DEVices = TREALLOC(SPICEdev *, DEVices, DEVNUM + 1); printf("Added device: %s from dynamic library %s\n", device->spicedev.DEVpublic.name, libname); DEVices[DEVNUM++] = & (device->spicedev); - varelink(ckt); - return DEVNUM-1; + relink_fixme(); + return 0; } #endif diff --git a/src/spicelib/parser/inpdomod.c b/src/spicelib/parser/inpdomod.c index 4b572d369..e17a6b53e 100644 --- a/src/spicelib/parser/inpdomod.c +++ b/src/spicelib/parser/inpdomod.c @@ -31,6 +31,8 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab) char *val; double rval=0, lval=0; + extern int is_adms_type(const char *type_name); + NG_IGNORE(ckt); line = image->line; @@ -46,10 +48,11 @@ char *INPdomodel(CKTcircuit *ckt, card * image, INPtables * tab) INPgetTok(&line, &type_name, 1); /* get model type */ #if ADMS >= 3 || 1 - if ((type=load_vadev(ckt,type_name)) && type>=0) { +#warning "nono" + if ((type=is_adms_type(type_name)) >= 0) { INPmodel *thismodel; char *error; -#ifdef TRACE +#if defined(TRACE) || 1 printf("inpdomod.c: got model %s from dynamic library - create device # %i\n",type_name,type); #endif INPmakeMod(modname, type, image);