Browse Source

* src/analysis/cktask.c: moved to src/devices.


			
			
				pre-master-46
			
			
		
arno 26 years ago
parent
commit
6f81cb9446
  1. 10
      ChangeLog
  2. 3
      TODO
  3. 2
      src/analysis/Makefile.am
  4. 54
      src/analysis/cktbindn.c
  5. 86
      src/analysis/cktfdev.c
  6. 3
      src/spicelib/devices/Makefile.am
  7. 24
      src/spicelib/devices/cktask.c
  8. 53
      src/spicelib/devices/cktbindnode.c
  9. 97
      src/spicelib/devices/cktfinddev.c

10
ChangeLog

@ -1,3 +1,13 @@
2000-06-19 Arno W. Peters <A.W.Peters@ieee.org>
* 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 <A.W.Peters@ieee.org> 2000-06-18 Arno W. Peters <A.W.Peters@ieee.org>
* AUTHORS, doc/ngspice.texi: Included an acknowledgements * AUTHORS, doc/ngspice.texi: Included an acknowledgements

3
TODO

@ -31,7 +31,8 @@ most appealing.
Refactorings 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 Separate out circuit builder from the analysis code and put it in the
devices directory (rename devices directory to simbuilder at some devices directory (rename devices directory to simbuilder at some

2
src/analysis/Makefile.am

@ -8,7 +8,6 @@ libckt_a_SOURCES = \
acsetp.c \ acsetp.c \
cktacct.c \ cktacct.c \
cktacdum.c \ cktacdum.c \
cktask.c \
cktaskaq.c \ cktaskaq.c \
cktasknq.c \ cktasknq.c \
cktbindn.c \ cktbindn.c \
@ -23,7 +22,6 @@ libckt_a_SOURCES = \
cktdojob.c \ cktdojob.c \
cktdump.c \ cktdump.c \
cktfbran.c \ cktfbran.c \
cktfdev.c \
cktfnda.c \ cktfnda.c \
cktfndm.c \ cktfndm.c \
cktfnode.c \ cktfnode.c \

54
src/analysis/cktbindn.c

@ -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 <stdio.h>
#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);
}
}

86
src/analysis/cktfdev.c

@ -1,86 +0,0 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
**********/
#include "ngspice.h"
#include <stdio.h>
#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 <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);
}

3
src/spicelib/devices/Makefile.am

@ -40,7 +40,10 @@ libdev_a_SOURCES = \
devsup.c \ devsup.c \
cktaccept.c \ cktaccept.c \
cktaccept.h \ cktaccept.h \
cktask.c \
cktbindnode.c \
cktcrte.c \ cktcrte.c \
cktfinddev.c \
cktinit.c cktinit.c
INCLUDES = -I$(top_srcdir)/src/include INCLUDES = -I$(top_srcdir)/src/include

24
src/analysis/cktask.c → 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 Author: 1985 Thomas L. Quarles
**********/ **********/
/* CKTask
* Ask questions about a specified device.
*/
/* CKTask
*
* Ask questions about a specified device. */
#include "ngspice.h"
#include <stdio.h>
#include "cktdefs.h"
#include "ifsim.h"
#include "devdefs.h"
#include "sperror.h"
#include <config.h>
#include <devdefs.h>
#include <sperror.h>
#include "dev.h"
extern SPICEdev *DEVices[];
int int
CKTask(void *ckt, void *fast, int which, IFvalue *value, IFvalue *selector) 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; int error;
#ifdef PARALLEL_ARCH #ifdef PARALLEL_ARCH
long msgtype, length; long msgtype, length;
long from = ((GENinstance *)fast)->GENowner;
long from = instance->GENowner;
#endif /* PARALLEL_ARCH */ #endif /* PARALLEL_ARCH */
SPICEdev **DEVices;
DEVices = devices();
if((*DEVices[type]).DEVask) { if((*DEVices[type]).DEVask) {
error = DEVices[type]->DEVask((CKTcircuit *)ckt, error = DEVices[type]->DEVask((CKTcircuit *)ckt,
(GENinstance *)fast,which,value,selector); (GENinstance *)fast,which,value,selector);

53
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 <config.h>
#include <stdio.h>
#include <devdefs.h>
#include <sperror.h>
#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;
}
}

97
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 <config.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 < 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;
}
Loading…
Cancel
Save