Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1988 Thomas L. Quarles
Modified: 2001 Paolo Nenzi (Cider Integration)
**********/
#include "ngspice/ngspice.h"
#include "ngspice/devdefs.h"
#include "ngspice/fteext.h"
#include "ngspice/ifsim.h"
#include "ngspice/inpdefs.h"
#include "ngspice/inpmacs.h"
#include "inpxx.h"
#include <stdio.h>
void INP2N(CKTcircuit *ckt, INPtables *tab, struct card *current) {
* [W=<val>] [AD=<val>] [AS=<val>] [PD=<val>]
* [PS=<val>] [NRD=<val>] [NRS=<val>] [OFF]
* [IC=<val>,<val>,<val>]
*/
int type;
char *line;
char *name;
const int max_i = 20;
CKTnode *node[20];
int error;
int numnodes;
GENinstance *fast;
int waslead;
double leadval;
INPmodel *thismodel;
GENmodel *mdfast;
int i;
line = current->line;
INPgetNetTok(&line, &name, 1);
INPinsert(&name, tab);
for (i = 0;; i++) {
char *token;
INPgetNetTok(&line, &token, 1);
if (i >= 1) {
txfree(INPgetMod(ckt, token, &thismodel, tab));
if (thismodel) {
INPinsert(&token, tab);
break;
}
}
if (i >= max_i) {
LITERR("could not find a valid modelname");
return;
}
INPtermInsert(ckt, &token, tab, &node[i]);
}
type = thismodel->INPmodType;
mdfast = thismodel->INPmodfast;
IFdevice *dev = ft_sim->devices[type];
if (!dev->registry_entry) {
LITERR("incorrect model type! Expected OSDI device");
return;
}
if (i == 0) {
LITERR("not enough nodes");
return;
}
if (i > *dev->terms) {
LITERR("too many nodes connected to instance");
return;
}
numnodes = i;
IFC(newInstance, (ckt, mdfast, &fast, name));
for (i = 0; i < *dev->terms; i++)
if (i < numnodes)
IFC(bindNode, (ckt, fast, i + 1, node[i]));
else
GENnode(fast)[i] = -1;
PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab));
if (waslead)
LITERR(" error: no unlabeled parameter permitted on osdi devices\n");
}