Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1988 Thomas L. Quarles
**********/
Original note:
Added device calls for Mesfet models and HFET models
provided by Trond Ytterdal as of Nov 98
*/
#include "ngspice/ngspice.h"
#include <stdio.h>
#include "ngspice/ifsim.h"
#include "ngspice/inpdefs.h"
#include "ngspice/inpmacs.h"
#include "ngspice/fteext.h"
#include "inpxx.h"
void INP2Z(CKTcircuit *ckt, INPtables * tab, struct card *current)
{
int type;
char *line;
char *name;
char *nname1;
char *nname2;
char *nname3;
CKTnode *node1;
CKTnode *node2;
CKTnode *node3;
int error;
GENinstance *fast;
IFvalue ptemp;
int waslead;
double leadval;
char *model;
INPmodel *thismodel;
GENmodel *mdfast;
IFuid uid;
line = current->line;
INPgetNetTok(&line, &name, 1);
INPinsert(&name, tab);
INPgetNetTok(&line, &nname1, 1);
INPtermInsert(ckt, &nname1, tab, &node1);
INPgetNetTok(&line, &nname2, 1);
INPtermInsert(ckt, &nname2, tab, &node2);
INPgetNetTok(&line, &nname3, 1);
INPtermInsert(ckt, &nname3, tab, &node3);
INPgetNetTok(&line, &model, 1);
INPinsert(&model, tab);
current->error = INPgetMod(ckt, model, &thismodel, tab);
if (thismodel != NULL) {
if ( thismodel->INPmodType != INPtypelook("MES")
&& thismodel->INPmodType != INPtypelook("MESA")
&& thismodel->INPmodType != INPtypelook("HFET1")
&& thismodel->INPmodType != INPtypelook("HFET2"))
{
LITERR("incorrect model type");
return;
}
type = thismodel->INPmodType;
mdfast = (thismodel->INPmodfast);
} else {
type = INPtypelook("MES");
if (type < 0 ) {
LITERR("Device type MES not supported by this binary\n");
return;
}
if (!tab->defZmod) {
IFnewUid(ckt, &uid, NULL, "Z", UID_MODEL, NULL);
IFC(newModel, (ckt, type, &(tab->defZmod), uid));
}
mdfast = tab->defZmod;
}
IFC(newInstance, (ckt, mdfast, &fast, name));
IFC(bindNode, (ckt, fast, 1, node1));
IFC(bindNode, (ckt, fast, 2, node2));
IFC(bindNode, (ckt, fast, 3, node3));
PARSECALL((&line, ckt, type, fast, &leadval, &waslead, tab));
if ( (waslead) && ( type != INPtypelook("MES") ) ) {
ptemp.rValue = leadval;
GCA(INPpName, ("area", &ptemp, ckt, type, fast));
}
}