Jspice3
dioask.c
Go to the documentation of this file.
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 #include "spice.h"
9 #include <stdio.h>
10 #include <math.h>
11 #include "diodefs.h"
12 #include "tskdefs.h"
13 #include "sperror.h"
14 #include "const.h"
15 #include "util.h"
16 
17 
18 /* ARGSUSED */
19 int
20 DIOask (ckt,inst,which,value,select)
21 
22 CKTcircuit *ckt;
23 GENinstance *inst;
24 int which;
25 IFvalue *value;
26 IFvalue *select;
27 {
28  DIOinstance *here = (DIOinstance*)inst;
29  static char *msg = "Current and power not available for ac analysis";
30 
31  switch (which) {
32  case DIO_AREA:
33  value->rValue = here->DIOarea;
34  break;
35  case DIO_IC:
36  value->rValue = here->DIOinitCond;
37  break;
38  case DIO_OFF:
39  value->iValue = here->DIOoff;
40  break;
41  case DIO_CURRENT:
42  if (ckt->CKTstate0)
43  value->rValue = here->DIOcd;
44  break;
45  case DIO_VOLTAGE:
46  if (ckt->CKTstate0)
47  value->rValue = *(ckt->CKTstate0 + here->DIOvoltage);
48  break;
49  case DIO_CHARGE:
50  if (ckt->CKTstate0)
51  value->rValue = *(ckt->CKTstate0 + here->DIOcapCharge);
52  break;
53  case DIO_CAPCUR:
54  if (ckt->CKTstate0)
55  value->rValue = *(ckt->CKTstate0 + here->DIOcapCurrent);
56  break;
57  case DIO_CONDUCT:
58  if (ckt->CKTstate0)
59  value->rValue = here->DIOgd;
60  break;
61  case DIO_POWER :
62  if (ckt->CKTcurrentAnalysis & DOING_AC) {
63  errMsg = MALLOC(strlen(msg)+1);
64  errRtn = "DIOask";
65  strcpy(errMsg,msg);
66  return (E_ASKPOWER);
67  }
68  if (ckt->CKTstate0) {
69  value->rValue = here->DIOcd *
70  *(ckt->CKTstate0 + here->DIOvoltage);
71  }
72  break;
73  case DIO_TEMP:
74  value->rValue = here->DIOtemp - CONSTCtoK;
75  break;
76  /* new in 3f2 */
77  case DIO_CAP:
78  value->rValue = here->DIOcap;
79  break;
80  default:
81  return (E_BADPARM);
82  }
83  return (OK);
84 }
85 
double DIOgd
Definition: diodefs.h:61
#define DIO_VOLTAGE
Definition: diodefs.h:169
#define DIO_IC
Definition: diodefs.h:166
char * strcpy()
#define CONSTCtoK
Definition: const.h:11
char * errMsg
Definition: main.c:42
#define DIO_CHARGE
Definition: diodefs.h:170
#define E_BADPARM
Definition: iferrmsg.h:26
double DIOcd
Definition: diodefs.h:60
#define DIO_CAP
Definition: diodefs.h:175
int iValue
Definition: ifsim.h:232
double rValue
Definition: ifsim.h:233
#define DIO_CURRENT
Definition: diodefs.h:168
#define DOING_AC
Definition: tskdefs.h:24
double DIOtemp
Definition: diodefs.h:50
#define OK
Definition: iferrmsg.h:17
unsigned DIOoff
Definition: diodefs.h:42
#define MALLOC(x)
Definition: util.h:9
#define DIO_TEMP
Definition: diodefs.h:174
#define DIO_POWER
Definition: diodefs.h:173
#define DIO_CAPCUR
Definition: diodefs.h:171
double DIOcap
Definition: diodefs.h:62
#define DIO_CONDUCT
Definition: diodefs.h:172
char * errRtn
Definition: main.c:41
#define E_ASKPOWER
Definition: sperror.h:27
#define DIO_AREA
Definition: diodefs.h:165
double DIOarea
Definition: diodefs.h:48
#define DIO_OFF
Definition: diodefs.h:167
int DIOask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
Definition: dioask.c:20
double DIOinitCond
Definition: diodefs.h:49