diff --git a/ChangeLog b/ChangeLog index aab9f4a5d..7e168049b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-06-19 Arno W. Peters + + * src/analysis/cktask.c: moved to src/devices. + + * src/analysis/cktbindn.c: moved, renamed to + src/devices/cktbindnode.c. + + * src/analysis/cktfdev.c: moved, renamed to + src/devices/cktfinddev.c. + 2000-06-18 Arno W. Peters * AUTHORS, doc/ngspice.texi: Included an acknowledgements diff --git a/TODO b/TODO index ceb9ef581..e5202b289 100644 --- a/TODO +++ b/TODO @@ -31,7 +31,8 @@ most appealing. Refactorings ------------ -Make devices dynamically loadable (perhaps use framework from glib). +Make devices dynamically loadable. Perhaps use framework from glib +(http://developer.gnome.org/doc/API/glib/index.html). Separate out circuit builder from the analysis code and put it in the devices directory (rename devices directory to simbuilder at some diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am index 31b2f4a8d..dcb10aee8 100644 --- a/src/analysis/Makefile.am +++ b/src/analysis/Makefile.am @@ -8,7 +8,6 @@ libckt_a_SOURCES = \ acsetp.c \ cktacct.c \ cktacdum.c \ - cktask.c \ cktaskaq.c \ cktasknq.c \ cktbindn.c \ @@ -23,7 +22,6 @@ libckt_a_SOURCES = \ cktdojob.c \ cktdump.c \ cktfbran.c \ - cktfdev.c \ cktfnda.c \ cktfndm.c \ cktfnode.c \ diff --git a/src/analysis/cktbindn.c b/src/analysis/cktbindn.c deleted file mode 100644 index b21b5af45..000000000 --- a/src/analysis/cktbindn.c +++ /dev/null @@ -1,54 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -/* CKTbindNode - * bind a node of the specified device of the given type to its place - * in the specified circuit. - */ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "smpdefs.h" -#include "cktdefs.h" -#include "devdefs.h" -#include "sperror.h" - - -extern SPICEdev *DEVices[]; - -/*ARGSUSED*/ -int -CKTbindNode(void *ckt, void *fast, int term, void *node) -{ - int mappednode; - int type = ((GENinstance *)fast)->GENmodPtr->GENmodType; - - mappednode = ((CKTnode *)node)->number; - - if(*((*DEVices[type]).DEVpublic.terms) >= term && term >0 ) { - switch(term) { - default: return(E_NOTERM); - case 1: - ((GENinstance *)fast)->GENnode1 = mappednode; - break; - case 2: - ((GENinstance *)fast)->GENnode2 = mappednode; - break; - case 3: - ((GENinstance *)fast)->GENnode3 = mappednode; - break; - case 4: - ((GENinstance *)fast)->GENnode4 = mappednode; - break; - case 5: - ((GENinstance *)fast)->GENnode5 = mappednode; - break; - } - return(OK); - } else { - return(E_NOTERM); - } -} diff --git a/src/analysis/cktfdev.c b/src/analysis/cktfdev.c deleted file mode 100644 index f28ef0695..000000000 --- a/src/analysis/cktfdev.c +++ /dev/null @@ -1,86 +0,0 @@ -/********** -Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Thomas L. Quarles -**********/ - -#include "ngspice.h" -#include -#include "ifsim.h" -#include "cktdefs.h" -#include "sperror.h" - - - -int -CKTfndDev(void *Ckt, int *type, void **fast, IFuid name, void *modfast, IFuid modname) -{ - CKTcircuit *ckt=(CKTcircuit *)Ckt; - GENinstance *here; - GENmodel *mods; - - if((GENinstance **)fast != (GENinstance **)NULL && - *(GENinstance **)fast != (GENinstance *)NULL) { - /* already have fast, so nothing much to do */ - /* just get & set type */ - if(type) *type = (*((GENinstance**)fast))->GENmodPtr->GENmodType; - return(OK); - } - if(modfast) { - /* have model, just need device */ - mods = (GENmodel*)modfast; - for(here = mods->GENinstances ; here != NULL; - here = here->GENnextInstance) { - if (here->GENname == name) { - if(fast != NULL) *(GENinstance **)fast = here; - if(type) *type = mods->GENmodType; - return(OK); - } - } - return(E_NODEV); - } - if(*type >=0 && *type < DEVmaxnum) { - /* have device type, need to find model & device */ - /* look through all models */ - for(mods=(GENmodel *)ckt->CKThead[*type]; mods != NULL ; - mods = mods->GENnextModel) { - /* and all instances */ - if(modname == (char *)NULL || mods->GENmodName == modname) { - for(here = mods->GENinstances ; here != NULL; - here = here->GENnextInstance) { - if (here->GENname == name) { - if(fast != 0) *(GENinstance **)fast = here; - return(OK); - } - } - if(mods->GENmodName == modname) { - return(E_NODEV); - } - } - } - return(E_NOMOD); - } else if(*type == -1) { - /* look through all types (UGH - worst case - take forever) */ - for(*type = 0;*type CKThead[*type];mods!=NULL; - mods = mods->GENnextModel) { - /* and all instances */ - if(modname == (char *)NULL || mods->GENmodName == modname) { - for(here = mods->GENinstances ; here != NULL; - here = here->GENnextInstance) { - if (here->GENname == name) { - if(fast != 0) *(GENinstance **)fast = here; - return(OK); - } - } - if(mods->GENmodName == modname) { - return(E_NODEV); - } - } - } - } - *type = -1; - return(E_NODEV); - } else return(E_BADPARM); -} diff --git a/src/spicelib/devices/Makefile.am b/src/spicelib/devices/Makefile.am index 70c749793..c50e19f72 100644 --- a/src/spicelib/devices/Makefile.am +++ b/src/spicelib/devices/Makefile.am @@ -40,7 +40,10 @@ libdev_a_SOURCES = \ devsup.c \ cktaccept.c \ cktaccept.h \ + cktask.c \ + cktbindnode.c \ cktcrte.c \ + cktfinddev.c \ cktinit.c INCLUDES = -I$(top_srcdir)/src/include diff --git a/src/analysis/cktask.c b/src/spicelib/devices/cktask.c similarity index 70% rename from src/analysis/cktask.c rename to src/spicelib/devices/cktask.c index bd6df2405..c645fc986 100644 --- a/src/analysis/cktask.c +++ b/src/spicelib/devices/cktask.c @@ -3,30 +3,30 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Thomas L. Quarles **********/ - /* CKTask - * Ask questions about a specified device. - */ +/* CKTask + * + * Ask questions about a specified device. */ -#include "ngspice.h" -#include -#include "cktdefs.h" -#include "ifsim.h" -#include "devdefs.h" -#include "sperror.h" +#include +#include +#include +#include "dev.h" -extern SPICEdev *DEVices[]; int CKTask(void *ckt, void *fast, int which, IFvalue *value, IFvalue *selector) { - int type = ((GENinstance *)fast)->GENmodPtr->GENmodType; + GENinstance *instance = (GENinstance *) fast; + int type = instance->GENmodPtr->GENmodType; int error; #ifdef PARALLEL_ARCH long msgtype, length; - long from = ((GENinstance *)fast)->GENowner; + long from = instance->GENowner; #endif /* PARALLEL_ARCH */ + SPICEdev **DEVices; + DEVices = devices(); if((*DEVices[type]).DEVask) { error = DEVices[type]->DEVask((CKTcircuit *)ckt, (GENinstance *)fast,which,value,selector); diff --git a/src/spicelib/devices/cktbindnode.c b/src/spicelib/devices/cktbindnode.c new file mode 100644 index 000000000..65d306343 --- /dev/null +++ b/src/spicelib/devices/cktbindnode.c @@ -0,0 +1,53 @@ +/********** +Copyright 1990 Regents of the University of California. All rights reserved. +Author: 1985 Thomas L. Quarles +**********/ + +/* CKTbindNode + * + * bind a node of the specified device of the given type to its place + * in the specified circuit. */ + +#include +#include +#include +#include + +#include "dev.h" + +int +CKTbindNode(void *ckt, void *fast, int term, void *node) +{ + int mappednode; + SPICEdev **devs; + GENinstance *instance = (GENinstance *) fast; + int type = instance->GENmodPtr->GENmodType; + + devs = devices(); + mappednode = ((CKTnode *)node)->number; + + if (*((*devs[type]).DEVpublic.terms) >= term && term >0 ) { + switch(term) { + default: + return E_NOTERM; + case 1: + instance->GENnode1 = mappednode; + break; + case 2: + instance->GENnode2 = mappednode; + break; + case 3: + instance->GENnode3 = mappednode; + break; + case 4: + instance->GENnode4 = mappednode; + break; + case 5: + instance->GENnode5 = mappednode; + break; + } + return OK; + } else { + return E_NOTERM; + } +} diff --git a/src/spicelib/devices/cktfinddev.c b/src/spicelib/devices/cktfinddev.c new file mode 100644 index 000000000..66b29eb64 --- /dev/null +++ b/src/spicelib/devices/cktfinddev.c @@ -0,0 +1,97 @@ +/********** +Copyright 1990 Regents of the University of California. All rights reserved. +Author: 1985 Thomas L. Quarles +**********/ + +#include +#include +#include + + +int +CKTfndDev(void *Ckt, int *type, void **fast, IFuid name, void *modfast, IFuid modname) +{ + CKTcircuit *ckt=(CKTcircuit *)Ckt; + GENinstance *here; + GENmodel *mods; + + if((GENinstance **)fast != (GENinstance **)NULL && + *(GENinstance **)fast != (GENinstance *)NULL) { + /* already have fast, so nothing much to do just get & set + type */ + if (type) + *type = (*((GENinstance**)fast))->GENmodPtr->GENmodType; + return(OK); + } + + if(modfast) { + /* have model, just need device */ + mods = (GENmodel*)modfast; + for (here = mods->GENinstances; + here != NULL; + here = here->GENnextInstance) { + if (here->GENname == name) { + if (fast != NULL) + *(GENinstance **)fast = here; + + if (type) + *type = mods->GENmodType; + + return OK; + } + } + return E_NODEV; + } + + if (*type >= 0 && *type < DEVmaxnum) { + /* have device type, need to find model & device */ + /* look through all models */ + for (mods = (GENmodel *)ckt->CKThead[*type]; + mods != NULL ; + mods = mods->GENnextModel) { + /* and all instances */ + if (modname == (char *)NULL || mods->GENmodName == modname) { + for (here = mods->GENinstances; + here != NULL; + here = here->GENnextInstance) { + if (here->GENname == name) { + if (fast != 0) + *(GENinstance **)fast = here; + return OK; + } + } + if(mods->GENmodName == modname) { + return E_NODEV; + } + } + } + return E_NOMOD; + } else if (*type == -1) { + /* look through all types (UGH - worst case - take forever) */ + for(*type = 0; *type < DEVmaxnum; (*type)++) { + /* need to find model & device */ + /* look through all models */ + for(mods=(GENmodel *)ckt->CKThead[*type];mods!=NULL; + mods = mods->GENnextModel) { + /* and all instances */ + if(modname == (char *)NULL || mods->GENmodName == modname) { + for (here = mods->GENinstances; + here != NULL; + here = here->GENnextInstance) { + if (here->GENname == name) { + if(fast != 0) + *(GENinstance **)fast = here; + return OK; + } + } + if(mods->GENmodName == modname) { + return E_NODEV; + } + } + } + } + *type = -1; + return E_NODEV; + } else + return E_BADPARM; +}