Chenged parsing rules to accomodate new capacitor model.
This commit is contained in:
parent
a2cf5cab55
commit
1222eabbc9
|
|
@ -4,7 +4,6 @@ Author: 1988 Thomas L. Quarles
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
#include "ngspice.h"
|
#include "ngspice.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include "ifsim.h"
|
#include "ifsim.h"
|
||||||
#include "inpdefs.h"
|
#include "inpdefs.h"
|
||||||
#include "inpmacs.h"
|
#include "inpmacs.h"
|
||||||
|
|
@ -15,21 +14,23 @@ void INP2C(void *ckt, INPtables * tab, card * current)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* parse a capacitor card */
|
/* parse a capacitor card */
|
||||||
/* Cname <node> <node> <val> [IC=<val>] */
|
/* Cname <node> <node> [<val>] [<mname>] [IC=<val>] */
|
||||||
|
|
||||||
int mytype; /* the type we determine resistors are */
|
int mytype; /* the type we determine capacitors are */
|
||||||
int type; /* the type the model says it is */
|
int type = 0; /* the type the model says it is */
|
||||||
char *line; /* the part of the current line left to parse */
|
char *line; /* the part of the current line left to parse */
|
||||||
|
char *saveline; /* ... just in case we need to go back... */
|
||||||
char *name; /* the resistor's name */
|
char *name; /* the resistor's name */
|
||||||
char *model; /* the name of the resistor's model */
|
char *model; /* the name of the capacitor's model */
|
||||||
char *nname1; /* the first node's name */
|
char *nname1; /* the first node's name */
|
||||||
char *nname2; /* the second node's name */
|
char *nname2; /* the second node's name */
|
||||||
void *node1; /* the first node's node pointer */
|
void *node1; /* the first node's node pointer */
|
||||||
void *node2; /* the second node's node pointer */
|
void *node2; /* the second node's node pointer */
|
||||||
double val; /* temp to held resistance */
|
double val; /* temp to held resistance */
|
||||||
int error; /* error code temporary */
|
int error; /* error code temporary */
|
||||||
|
int error1; /* secondary error code temporary */
|
||||||
INPmodel *thismodel; /* pointer to model structure describing our model */
|
INPmodel *thismodel; /* pointer to model structure describing our model */
|
||||||
void *mdfast; /* pointer to the actual model */
|
void *mdfast = NULL; /* pointer to the actual model */
|
||||||
void *fast; /* pointer to the actual instance */
|
void *fast; /* pointer to the actual instance */
|
||||||
IFvalue ptemp; /* a value structure to package resistance into */
|
IFvalue ptemp; /* a value structure to package resistance into */
|
||||||
int waslead; /* flag to indicate that funny unlabeled number was found */
|
int waslead; /* flag to indicate that funny unlabeled number was found */
|
||||||
|
|
@ -48,32 +49,33 @@ void INP2C(void *ckt, INPtables * tab, card * current)
|
||||||
INPtermInsert(ckt, &nname1, tab, &node1);
|
INPtermInsert(ckt, &nname1, tab, &node1);
|
||||||
INPgetNetTok(&line, &nname2, 1);
|
INPgetNetTok(&line, &nname2, 1);
|
||||||
INPtermInsert(ckt, &nname2, tab, &node2);
|
INPtermInsert(ckt, &nname2, tab, &node2);
|
||||||
val = INPevaluate(&line, &error, 1);
|
val = INPevaluate(&line, &error1, 1);
|
||||||
if (error == 0) { /* Looks like a number */
|
|
||||||
type = mytype;
|
saveline = line;
|
||||||
ptemp.rValue = val;
|
|
||||||
if (!tab->defCmod) {
|
INPgetTok(&line, &model, 1);
|
||||||
IFnewUid(ckt, &uid, (IFuid) NULL, "C", UID_MODEL,
|
|
||||||
(void **) NULL);
|
if (*model) {
|
||||||
IFC(newModel, (ckt, type, &(tab->defCmod), uid));
|
/* token isn't null */
|
||||||
}
|
if (INPlookMod(model)) {
|
||||||
IFC(newInstance, (ckt, tab->defCmod, &fast, name));
|
/* If this is a valid model connect it */
|
||||||
GCA(INPpName, ("capacitance", &ptemp, ckt, type, fast));
|
INPinsert(&model, tab);
|
||||||
} else { /* looks like character strings */
|
thismodel = (INPmodel *) NULL;
|
||||||
INPgetTok(&line, &model, 1);
|
current->error = INPgetMod(ckt, model, &thismodel, tab);
|
||||||
INPinsert(&model, tab);
|
if (thismodel != NULL) {
|
||||||
thismodel = (INPmodel *) NULL;
|
if (mytype != thismodel->INPmodType) {
|
||||||
current->error = INPgetMod(ckt, model, &thismodel, tab);
|
LITERR("incorrect model type");
|
||||||
if (thismodel != NULL) {
|
return;
|
||||||
if (mytype != thismodel->INPmodType) {
|
}
|
||||||
LITERR("incorrect model type");
|
mdfast = thismodel->INPmodfast;
|
||||||
return;
|
type = thismodel->INPmodType;
|
||||||
}
|
}
|
||||||
type = mytype;
|
|
||||||
mdfast = thismodel->INPmodfast;
|
|
||||||
} else {
|
} else {
|
||||||
|
tfree(model);
|
||||||
|
/* It is not a model */
|
||||||
|
line = saveline; /* go back */
|
||||||
type = mytype;
|
type = mytype;
|
||||||
if (!tab->defCmod) {
|
if (!tab->defCmod) { /* create default C model */
|
||||||
IFnewUid(ckt, &uid, (IFuid) NULL, "C", UID_MODEL,
|
IFnewUid(ckt, &uid, (IFuid) NULL, "C", UID_MODEL,
|
||||||
(void **) NULL);
|
(void **) NULL);
|
||||||
IFC(newModel, (ckt, type, &(tab->defCmod), uid));
|
IFC(newModel, (ckt, type, &(tab->defCmod), uid));
|
||||||
|
|
@ -81,7 +83,24 @@ void INP2C(void *ckt, INPtables * tab, card * current)
|
||||||
mdfast = tab->defCmod;
|
mdfast = tab->defCmod;
|
||||||
}
|
}
|
||||||
IFC(newInstance, (ckt, mdfast, &fast, name));
|
IFC(newInstance, (ckt, mdfast, &fast, name));
|
||||||
|
} else {
|
||||||
|
tfree(model);
|
||||||
|
/* The token is null and a default model will be created */
|
||||||
|
type = mytype;
|
||||||
|
if (!tab->defCmod) {
|
||||||
|
/* create default C model */
|
||||||
|
IFnewUid(ckt, &uid, (IFuid) NULL, "C", UID_MODEL,
|
||||||
|
(void **) NULL);
|
||||||
|
IFC(newModel, (ckt, type, &(tab->defCmod), uid));
|
||||||
|
}
|
||||||
|
IFC(newInstance, (ckt, tab->defCmod, &fast, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error1 == 0) { /* Looks like a number */
|
||||||
|
ptemp.rValue = val;
|
||||||
|
GCA(INPpName, ("capacitance", &ptemp, ckt, type, fast));
|
||||||
|
}
|
||||||
|
|
||||||
IFC(bindNode, (ckt, fast, 1, node1));
|
IFC(bindNode, (ckt, fast, 1, node1));
|
||||||
IFC(bindNode, (ckt, fast, 2, node2));
|
IFC(bindNode, (ckt, fast, 2, node2));
|
||||||
PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab));
|
PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab));
|
||||||
|
|
@ -89,4 +108,5 @@ void INP2C(void *ckt, INPtables * tab, card * current)
|
||||||
ptemp.rValue = leadval;
|
ptemp.rValue = leadval;
|
||||||
GCA(INPpName, ("capacitance", &ptemp, ckt, type, fast));
|
GCA(INPpName, ("capacitance", &ptemp, ckt, type, fast));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue