Browse Source

CKTfndMod(), return the found model instead of error code

pre-master-46
rlar 13 years ago
parent
commit
f0882dbdfd
  1. 4
      src/frontend/spiceif.c
  2. 2
      src/include/ngspice/cktdefs.h
  3. 2
      src/include/ngspice/ifsim.h
  4. 14
      src/spicelib/analysis/cktfndm.c
  5. 2
      src/spicelib/analysis/cktmcrt.c
  6. 4
      src/spicelib/devices/urc/urcsetup.c
  7. 2
      src/tclspice.c

4
src/frontend/spiceif.c

@ -624,7 +624,7 @@ finddev_special(
// assert(second && *second == -1) // assert(second && *second == -1)
// assert(third && *third == NULL) // assert(third && *third == NULL)
err = ft_sim->findModel (ckt, &type, modptr, name);
*modptr = ft_sim->findModel (ckt, &type, modptr, name);
err = *modptr ? OK : E_NOMOD; err = *modptr ? OK : E_NOMOD;
if (err == OK) { if (err == OK) {
*device_or_model = 1; *device_or_model = 1;
@ -1225,7 +1225,7 @@ finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr)
// assert(second && *second == -1) // assert(second && *second == -1)
// assert(third && *third == NULL) // assert(third && *third == NULL)
err = ft_sim->findModel (ckt, &type, modptr, name);
*modptr = ft_sim->findModel (ckt, &type, modptr, name);
err = *modptr ? OK : E_NOMOD; err = *modptr ? OK : E_NOMOD;
if (err == OK) if (err == OK)
return (type); return (type);

2
src/include/ngspice/cktdefs.h

@ -320,7 +320,7 @@ extern void CKTncDump(CKTcircuit *);
extern int CKTfndAnal(CKTcircuit *, int *, JOB **, IFuid , TSKtask *, IFuid); extern int CKTfndAnal(CKTcircuit *, int *, JOB **, IFuid , TSKtask *, IFuid);
extern int CKTfndBranch(CKTcircuit *, IFuid); extern int CKTfndBranch(CKTcircuit *, IFuid);
extern GENinstance *CKTfndDev(CKTcircuit *, IFuid); extern GENinstance *CKTfndDev(CKTcircuit *, IFuid);
extern int CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid);
extern GENmodel *CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid);
extern int CKTfndNode(CKTcircuit *, CKTnode **, IFuid); extern int CKTfndNode(CKTcircuit *, CKTnode **, IFuid);
extern int CKTfndTask(CKTcircuit *, TSKtask **, IFuid ); extern int CKTfndTask(CKTcircuit *, TSKtask **, IFuid );
extern int CKTground(CKTcircuit *, CKTnode **, IFuid); extern int CKTground(CKTcircuit *, CKTnode **, IFuid);

2
src/include/ngspice/ifsim.h

@ -381,7 +381,7 @@ struct IFsimulator {
/* set a parameter on a model */ /* set a parameter on a model */
int (*askModelQuest) (CKTcircuit *, GENmodel *, int, IFvalue *, IFvalue *); int (*askModelQuest) (CKTcircuit *, GENmodel *, int, IFvalue *, IFvalue *);
/* ask a questions about a model */ /* ask a questions about a model */
int (*findModel) (CKTcircuit *, int *, GENmodel **, IFuid);
GENmodel *(*findModel) (CKTcircuit *, int *, GENmodel **, IFuid);
/* find a specific model */ /* find a specific model */
int (*deleteModel) (CKTcircuit *, GENmodel *); int (*deleteModel) (CKTcircuit *, GENmodel *);
/* delete a model from the circuit*/ /* delete a model from the circuit*/

14
src/spicelib/analysis/cktfndm.c

@ -13,7 +13,7 @@ Author: 1985 Thomas L. Quarles
int
GENmodel *
CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname) CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
{ {
GENmodel *mods; GENmodel *mods;
@ -21,7 +21,7 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
if(modfast != NULL && *modfast != NULL) { if(modfast != NULL && *modfast != NULL) {
/* already have modfast, so nothing to do */ /* already have modfast, so nothing to do */
if(type) *type = (*modfast)->GENmodType; if(type) *type = (*modfast)->GENmodType;
return(OK);
return *modfast;
} }
if(*type >=0 && *type < DEVmaxnum) { if(*type >=0 && *type < DEVmaxnum) {
/* have device type, need to find model */ /* have device type, need to find model */
@ -30,10 +30,10 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
mods = mods->GENnextModel) { mods = mods->GENnextModel) {
if(mods->GENmodName == modname) { if(mods->GENmodName == modname) {
*modfast = mods; *modfast = mods;
return(OK);
return *modfast;
} }
} }
return(E_NOMOD);
return NULL;
} else if(*type == -1) { } else if(*type == -1) {
/* look through all types (UGH - worst case - take forever) */ /* look through all types (UGH - worst case - take forever) */
for(*type = 0;*type <DEVmaxnum;(*type)++) { for(*type = 0;*type <DEVmaxnum;(*type)++) {
@ -43,11 +43,11 @@ CKTfndMod(CKTcircuit *ckt, int *type, GENmodel **modfast, IFuid modname)
mods = mods->GENnextModel) { mods = mods->GENnextModel) {
if(mods->GENmodName == modname) { if(mods->GENmodName == modname) {
*modfast = mods; *modfast = mods;
return(OK);
return *modfast;
} }
} }
} }
*type = -1; *type = -1;
return(E_NOMOD);
} else return(E_NOMOD);
return NULL;
} else return NULL;
} }

2
src/spicelib/analysis/cktmcrt.c

@ -25,7 +25,7 @@ CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name)
// assert(second) // assert(second)
// assert(third && *third == NULL) // assert(third && *third == NULL)
error = CKTfndMod(ckt, &type, &mymodfast, name);
mymodfast = CKTfndMod(ckt, &type, &mymodfast, name);
error = mymodfast ? OK : E_NOMOD; error = mymodfast ? OK : E_NOMOD;
if(error == E_NOMOD) { if(error == E_NOMOD) {
mymodfast = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize)); mymodfast = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize));

4
src/spicelib/devices/urc/urcsetup.c

@ -310,7 +310,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
type = -1; type = -1;
// assert(second && *second == -1) // assert(second && *second == -1)
// assert(third && *third == NULL) // assert(third && *third == NULL)
error = CKTfndMod(ckt, &type, &modfast, varUid);
modfast = CKTfndMod(ckt, &type, &modfast, varUid);
error = modfast ? OK : E_NOMOD; error = modfast ? OK : E_NOMOD;
if (error) if (error)
return error; return error;
@ -330,7 +330,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
type = -1; type = -1;
// assert(second && *second == -1) // assert(second && *second == -1)
// assert(third && *third == NULL) // assert(third && *third == NULL)
error = CKTfndMod(ckt, &type, &modfast, varUid);
modfast = CKTfndMod(ckt, &type, &modfast, varUid);
error = modfast ? OK : E_NOMOD; error = modfast ? OK : E_NOMOD;
if (error) if (error)
return error; return error;

2
src/tclspice.c

@ -1399,7 +1399,7 @@ get_mod_param TCL_CMDPROCARGS(clientData, interp, argc, argv)
typecode = -1; typecode = -1;
// assert(second && *second == -1) // assert(second && *second == -1)
// assert(third && *third == NULL) // assert(third && *third == NULL)
err = ft_sim->findModel (ft_curckt->ci_ckt, &typecode, &modptr, name);
modptr = ft_sim->findModel (ft_curckt->ci_ckt, &typecode, &modptr, name);
err = modptr ? OK : E_NOMOD; err = modptr ? OK : E_NOMOD;
} else { } else {
typecode = devptr->GENmodPtr->GENmodType; typecode = devptr->GENmodPtr->GENmodType;

Loading…
Cancel
Save