1 /*************************************************************************** 2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992 3 Copyright 1990 Regents of the University of California. All rights reserved. 4 Authors: 1985 THomas L. Quarles 5 1992 Stephen R. Whiteley 6 ****************************************************************************/ 7 8 #ifndef DEV 9 #define DEV 10 11 #include "cktdefs.h" 12 13 /* devsup.c */ 14 #ifdef __STDC__ 15 16 extern double DEVlimvds(double,double); 17 extern double DEVpnjlim(double,double,double,double,int*); 18 extern double DEVfetlim(double,double,double); 19 extern void DEVqmeyer(double,double,double,double,double*,double*, 20 double*,double,double); 21 extern double DEVpred(CKTcircuit*,int); 22 extern double *DEVpredNew(CKTcircuit*); 23 extern int GENdelete(GENmodel*,IFuid,GENinstance**); 24 extern void GENdestroy(GENmodel**); 25 extern int GENmDelete(GENmodel**,IFuid,GENmodel*); 26 extern void GENmosParse(int,GENERIC*,GENERIC*,GENERIC*); 27 28 #else /* stdc */ 29 30 extern double DEVlimvds(); 31 extern double DEVpnjlim(); 32 extern double DEVfetlim(); 33 extern void DEVqmeyer(); 34 extern double DEVpred(); 35 extern double *DEVpredNew(); 36 extern int GENdelete(); 37 extern void GENdestroy(); 38 extern int GENmDelete(); 39 extern void GENmosParse(); 40 41 #endif /* stdc */ 42 43 typedef struct SPICEdev { 44 IFdevice DEVpublic; 45 46 #ifdef __STDC__ 47 int (*DEVparam)(CKTcircuit*,int,IFvalue*,GENinstance*,IFvalue *); 48 /* routine to input a parameter to a device instance */ 49 int (*DEVmodParam)(int,IFvalue*,GENmodel*); 50 /* routine to input a paramater to a model */ 51 int (*DEVload)(GENmodel*,CKTcircuit*); 52 /* routine to load the device into the matrix */ 53 int (*DEVsetup)(SMPmatrix*,GENmodel*,CKTcircuit*,int*); 54 /* setup routine to preprocess devices once before soloution begins */ 55 int (*DEVpzSetup)(SMPmatrix*,GENmodel*,CKTcircuit*,int*); 56 /* setup routine to process devices specially for pz analysis */ 57 int (*DEVtemperature)(GENmodel*,CKTcircuit*); 58 /* subroutine to do temperature dependent setup processing */ 59 int (*DEVtrunc)(GENmodel*,CKTcircuit*,double*); 60 /* subroutine to perform truncation error calc. */ 61 int (*DEVfindBranch)(CKTcircuit*,GENmodel*,IFuid); 62 /* subroutine to search for device branch eq.s */ 63 int (*DEVacLoad)(GENmodel*,CKTcircuit*); 64 /* ac analysis loading function */ 65 int (*DEVaccept)(CKTcircuit*,GENmodel*); 66 /* subroutine to call on acceptance of a timepoint */ 67 void (*DEVdestroy)(GENmodel**); 68 /* subroutine to destroy all models and instances */ 69 int (*DEVmodDelete)(GENmodel**,IFuid,GENmodel*); 70 /* subroutine to delete a model and all instances */ 71 int (*DEVdelete)(GENmodel*,IFuid,GENinstance**); 72 /* subroutine to delete an instance */ 73 int (*DEVsetic)(GENmodel*,CKTcircuit*); 74 /* routine to pick up device init conds from rhs */ 75 int (*DEVask)(CKTcircuit*,GENinstance*,int,IFvalue*,IFvalue*); 76 /* routine to ask about device details*/ 77 int (*DEVmodAsk)(CKTcircuit*,GENmodel*,int,IFvalue*); 78 /* routine to ask about model details*/ 79 int (*DEVpzLoad)(GENmodel*,CKTcircuit*,SPcomplex*); 80 /* routine to load for pole-zero analysis */ 81 int (*DEVconvTest)(GENmodel*,CKTcircuit*); 82 /* convergence test function */ 83 int (*DEVdisto)(int,GENmodel*,CKTcircuit*); 84 /* procedure to do distortion operations */ 85 int (*DEVnoise)(int, int, GENmodel*,CKTcircuit*, GENERIC *, double *); 86 /* noise routine */ 87 88 #else /* stdc */ 89 90 int (*DEVparam)(); /* input a parameter to a device instance */ 91 int (*DEVmodParam)(); /* input a paramater to a model */ 92 int (*DEVload)(); /* load the device into the matrix */ 93 int (*DEVsetup)(); /* preprocess devices before soloution begins */ 94 int (*DEVpzSetup)(); /* process devices specially for pz analysis */ 95 int (*DEVtemperature)();/* temperature dependent setup processing */ 96 int (*DEVtrunc)(); /* perform truncation error calc. */ 97 int (*DEVfindBranch)(); /* search for device branch eq.s */ 98 int (*DEVacLoad)(); /* ac analysis loading function */ 99 int (*DEVaccept)(); /* call on acceptance of a timepoint */ 100 void (*DEVdestroy)(); /* destroy all models and instances */ 101 int (*DEVmodDelete)(); /* delete a model and all instances */ 102 int (*DEVdelete)(); /* delete an instance */ 103 int (*DEVsetic)(); /* pick up device init conds from rhs */ 104 int (*DEVask)(); /* ask about device details*/ 105 int (*DEVmodAsk)(); /* ask about model details*/ 106 int (*DEVpzLoad)(); /* load for pole-zero analysis */ 107 int (*DEVconvTest)(); /* convergence test function */ 108 int (*DEVdisto)(); /* distortion routine */ 109 int (*DEVnoise)(); /* noise routine */ 110 111 #endif /* stdc */ 112 113 int *DEVinstSize; /* size of an instance */ 114 int *DEVmodSize; /* size of a model */ 115 116 } SPICEdev; /* instance of structure for each possible type of device */ 117 118 #define IP(a,b,c,d) { a , b , c|IF_SET , d } 119 #define OP(a,b,c,d) { a , b , c|IF_ASK , d } 120 #define IOP(a,b,c,d) { a , b , c|IF_SET|IF_ASK , d } 121 #define P(a,b,c,d) { a , b , c , d } 122 123 /* macro to make elements with built in test for out of memory */ 124 #define TSTALLOC(ptr,first,second) \ 125 if((here->ptr = spGetElement(matrix,here->first,here->second))==(double *)NULL){\ 126 return(E_NOMEM);\ 127 } 128 129 /* macros to do trapezoidal integration inline */ 130 #define NI_SUM(ckt,ceq,qcap){ \ 131 if(ckt->CKTintegrateMethod==TRAPEZOIDAL){ \ 132 if(ckt->CKTorder==1) \ 133 ceq=ckt->CKTag[1]* *(ckt->CKTstate1+qcap); \ 134 else \ 135 ceq= - *(ckt->CKTstate1+qcap+1)*ckt->CKTag[1]- \ 136 ckt->CKTag[0]* *(ckt->CKTstate1+qcap); \ 137 } \ 138 else {error=NIsum(ckt,&ceq,qcap); if(error) return(error);}\ 139 } 140 141 #define NI_INTEG(ckt,geq,ceq,cap,qcap){ \ 142 if (ckt->CKTintegrateMethod==TRAPEZOIDAL){ \ 143 if (ckt->CKTorder==1) \ 144 ceq=ckt->CKTag[1]* *(ckt->CKTstate1+qcap); \ 145 else \ 146 ceq= - *(ckt->CKTstate1+qcap+1)*ckt->CKTag[1]- \ 147 ckt->CKTag[0]* *(ckt->CKTstate1+qcap); \ 148 *(ckt->CKTstate0+qcap+1)= \ 149 ckt->CKTag[0]* *(ckt->CKTstate0+qcap)+ceq; \ 150 geq=ckt->CKTag[0]*cap; \ 151 } \ 152 else {error=NIintegrate(ckt,&geq,&ceq,cap,qcap); if(error) return(error);} \ 153 } 154 155 #endif /*DEV*/ 156