make struct GENinstance truly generic
drop the GENnode struct member, which is actually part of the derived instance structs
This commit is contained in:
parent
315990688c
commit
bc84b06b24
|
|
@ -21,10 +21,21 @@ struct GENinstance {
|
||||||
* current model*/
|
* current model*/
|
||||||
IFuid GENname; /* pointer to character string naming this instance */
|
IFuid GENname; /* pointer to character string naming this instance */
|
||||||
int GENstate; /* state index number */
|
int GENstate; /* state index number */
|
||||||
int GENnode[7]; /* node numbers to which this instance is connected to */
|
|
||||||
|
/* The actual devices have to place their node elements
|
||||||
|
* right after the the end of struct GENinstance
|
||||||
|
* where there can be accessed by generic GENnode()[]
|
||||||
|
* A notable exception is the XSPICE MIF device
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
int GENnode[]; /* node numbers to which this instance is connected to */
|
||||||
/* carefull, thats overlayed into the actual device structs */
|
/* carefull, thats overlayed into the actual device structs */
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int *GENnode(struct GENinstance *inst)
|
||||||
|
{ return (int*)(inst + 1); }
|
||||||
|
|
||||||
|
|
||||||
/* per model data */
|
/* per model data */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ CKTinst2Node(CKTcircuit *ckt, void *instPtr, int terminal, CKTnode **node, IFuid
|
||||||
|
|
||||||
if (*(DEVices[type]->DEVpublic.terms) >= terminal && terminal > 0) {
|
if (*(DEVices[type]->DEVpublic.terms) >= terminal && terminal > 0) {
|
||||||
/* argh, terminals are counted from 1 */
|
/* argh, terminals are counted from 1 */
|
||||||
int nodenum = inst->GENnode[terminal - 1];
|
int nodenum = GENnode(inst)[terminal - 1];
|
||||||
|
|
||||||
for (here = ckt->CKTnodes; here; here = here->next)
|
for (here = ckt->CKTnodes; here; here = here->next)
|
||||||
if (here->number == nodenum) {
|
if (here->number == nodenum) {
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,8 @@ TFanal(CKTcircuit *ckt, int restart)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job->TFinIsI) {
|
if (job->TFinIsI) {
|
||||||
ckt->CKTrhs[ptr->GENnode[0]] -= 1;
|
ckt->CKTrhs[GENnode(ptr)[0]] -= 1;
|
||||||
ckt->CKTrhs[ptr->GENnode[1]] += 1;
|
ckt->CKTrhs[GENnode(ptr)[1]] += 1;
|
||||||
} else {
|
} else {
|
||||||
insrc = CKTfndBranch(ckt, job->TFinSrc);
|
insrc = CKTfndBranch(ckt, job->TFinSrc);
|
||||||
ckt->CKTrhs[insrc] += 1;
|
ckt->CKTrhs[insrc] += 1;
|
||||||
|
|
@ -119,8 +119,8 @@ TFanal(CKTcircuit *ckt, int restart)
|
||||||
|
|
||||||
/* now for input resistance */
|
/* now for input resistance */
|
||||||
if (job->TFinIsI) {
|
if (job->TFinIsI) {
|
||||||
outputs[1] = ckt->CKTrhs[ptr->GENnode[1]] -
|
outputs[1] = ckt->CKTrhs[GENnode(ptr)[1]] -
|
||||||
ckt->CKTrhs[ptr->GENnode[0]];
|
ckt->CKTrhs[GENnode(ptr)[0]];
|
||||||
} else {
|
} else {
|
||||||
if(fabs(ckt->CKTrhs[insrc])<1e-20) {
|
if(fabs(ckt->CKTrhs[insrc])<1e-20) {
|
||||||
outputs[1]=1e20;
|
outputs[1]=1e20;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ CKTbindNode(CKTcircuit *ckt, GENinstance *instance, int term, CKTnode *node)
|
||||||
|
|
||||||
if (*(devs[type]->DEVpublic.terms) >= term && term > 0) {
|
if (*(devs[type]->DEVpublic.terms) >= term && term > 0) {
|
||||||
/* argh, terminals are counted from 1 */
|
/* argh, terminals are counted from 1 */
|
||||||
instance->GENnode[term - 1] = node->number;
|
GENnode(instance)[term - 1] = node->number;
|
||||||
return OK;
|
return OK;
|
||||||
} else {
|
} else {
|
||||||
return E_NOTERM;
|
return E_NOTERM;
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ URCunsetup(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
return E_NOMOD;
|
return E_NOMOD;
|
||||||
|
|
||||||
for (in = modfast->GENinstances; in; in = in->GENnextInstance)
|
for (in = modfast->GENinstances; in; in = in->GENnextInstance)
|
||||||
CKTdltNNum(ckt, in->GENnode[0]);
|
CKTdltNNum(ckt, GENnode(in)[0]);
|
||||||
|
|
||||||
CKTdltMod(ckt, modfast); /* Does the elements too */
|
CKTdltMod(ckt, modfast); /* Does the elements too */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ INP2M(CKTcircuit *ckt, INPtables *tab, card *current)
|
||||||
if (i < numnodes)
|
if (i < numnodes)
|
||||||
IFC (bindNode, (ckt, fast, i + 1, node[i]));
|
IFC (bindNode, (ckt, fast, i + 1, node[i]));
|
||||||
else
|
else
|
||||||
fast->GENnode[i] = -1;
|
GENnode(fast)[i] = -1;
|
||||||
|
|
||||||
PARSECALL ((&line, ckt, type, fast, &leadval, &waslead, tab));
|
PARSECALL ((&line, ckt, type, fast, &leadval, &waslead, tab));
|
||||||
if (waslead)
|
if (waslead)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue