ckti2nod.c, cktbindnode.c, minor cleanup

This commit is contained in:
rlar 2017-01-07 13:06:56 +01:00
parent 239780ebef
commit c3275241a5
2 changed files with 19 additions and 27 deletions

View File

@ -2,13 +2,6 @@
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Thomas L. Quarles
**********/
/*
*/
/* CKTinst2Node
* get the name and node pointer for a node given a device it is
* bound to and the terminal of the device.
*/
#include "ngspice/ngspice.h"
#include "ngspice/ifsim.h"
@ -18,30 +11,32 @@ Author: 1985 Thomas L. Quarles
#include "ngspice/devdefs.h"
/* CKTinst2Node
* get the name and node pointer for a node given a device it is
* bound to and the terminal of the device.
*/
int
CKTinst2Node(CKTcircuit *ckt, void *instPtr, int terminal, CKTnode **node, IFuid *nodeName)
{
int nodenum;
int type;
GENinstance *inst = (GENinstance *) instPtr;
int type = inst->GENmodPtr->GENmodType;
CKTnode *here;
type = ((GENinstance *)instPtr)->GENmodPtr->GENmodType;
if(*(DEVices[type]->DEVpublic.terms) >= terminal && terminal > 0) {
if (*(DEVices[type]->DEVpublic.terms) >= terminal && terminal > 0) {
/* argh, terminals are counted from 1 */
nodenum = ((GENinstance *)instPtr)->GENnode[terminal - 1];
/* ok, now we know its number, so we just have to find it.*/
for(here = ckt->CKTnodes;here;here = here->next) {
if(here->number == nodenum) {
/* found it */
int nodenum = inst->GENnode[terminal - 1];
for (here = ckt->CKTnodes; here; here = here->next)
if (here->number == nodenum) {
*node = here;
*nodeName = here->name;
return(OK);
return OK;
}
}
return(E_NOTFOUND);
return E_NOTFOUND;
} else {
return(E_NOTERM);
return E_NOTERM;
}
}

View File

@ -15,21 +15,18 @@ Author: 1985 Thomas L. Quarles
#include "dev.h"
int
CKTbindNode(CKTcircuit *ckt, GENinstance *instance, int term, CKTnode *node)
{
int mappednode;
SPICEdev **devs;
SPICEdev **devs = devices();
int type = instance->GENmodPtr->GENmodType;
NG_IGNORE(ckt);
devs = devices();
mappednode = node->number;
if (*(devs[type]->DEVpublic.terms) >= term && term > 0) {
/* argh, terminals are counted from 1 */
instance->GENnode[term - 1] = mappednode;
instance->GENnode[term - 1] = node->number;
return OK;
} else {
return E_NOTERM;