1 /**********
2 Copyright 1990 Regents of the University of California.  All rights reserved.
3 Author: 1985 Thomas L. Quarles
4 **********/
5 
6 #ifndef ISRC
7 #define ISRC
8 
9 #include "ngspice/ifsim.h"
10 #include "ngspice/cktdefs.h"
11 #include "ngspice/gendefs.h"
12 #include "ngspice/complex.h"
13 
14 /*
15  * structures to describe independent current sources
16  */
17 
18 
19 /* information needed for each instance */
20 
21 typedef struct sISRCinstance {
22 
23     struct GENinstance gen;
24 
25 #define ISRCmodPtr(inst) ((struct sISRCmodel *)((inst)->gen.GENmodPtr))
26 #define ISRCnextInstance(inst) ((struct sISRCinstance *)((inst)->gen.GENnextInstance))
27 #define ISRCname gen.GENname
28 #define ISRCstate gen.GENstate
29 
30     const int ISRCnegNode;    /* number of negative node of source */
31     const int ISRCposNode;    /* number of positive node of source */
32 
33     int ISRCfunctionType;   /* code number of function type for source */
34     int ISRCfunctionOrder;  /* order of the function for the source */
35     double *ISRCcoeffs; /* pointer to array of coefficients */
36 
37     double ISRCdcValue; /* DC and TRANSIENT value of source */
38     double ISRCmValue;  /* Parallel multiplier */
39 
40     double ISRCacPhase; /* AC phase angle */
41     double ISRCacMag; /* AC magnitude */
42 
43     double ISRCacReal; /* AC real component */
44     double ISRCacImag; /* AC imaginary component */
45 
46     double ISRCdF1mag; /* distortion f1 magnitude */
47     double ISRCdF2mag; /* distortion f2 magnitude */
48     double ISRCdF1phase; /* distortion f1 phase */
49     double ISRCdF2phase; /* distortion f2 phase */
50 
51     struct trnoise_state *ISRCtrnoise_state; /* transient noise */
52     struct trrandom_state *ISRCtrrandom_state; /* transient random source */
53 
54     /* needed for outputting results */
55     double ISRCcurrent; /* current value */
56 
57     unsigned ISRCdcGiven     :1 ;  /* flag to indicate dc value given */
58     unsigned ISRCmGiven      :1 ;  /* flag to indicate multiplier given */
59     unsigned ISRCacGiven     :1 ;  /* flag to indicate ac keyword given */
60     unsigned ISRCacMGiven    :1 ;  /* flag to indicate ac magnitude given */
61     unsigned ISRCacPGiven    :1 ;  /* flag to indicate ac phase given */
62     unsigned ISRCfuncTGiven  :1 ;  /* flag to indicate function type given */
63     unsigned ISRCcoeffsGiven :1 ;  /* flag to indicate function coeffs given */
64     unsigned ISRCdGiven      :1 ;  /* flag to indicate source is a distortion input */
65     unsigned ISRCdF1given    :1 ;  /* flag to indicate source is an f1 distortion input */
66     unsigned ISRCdF2given    :1 ;  /* flag to indicate source is an f2 distortion input */
67 } ISRCinstance ;
68 
69 
70 /* per model data */
71 
72 typedef struct sISRCmodel {
73 
74     struct GENmodel gen;
75 
76 #define ISRCmodType gen.GENmodType
77 #define ISRCnextModel(inst) ((struct sISRCmodel *)((inst)->gen.GENnextModel))
78 #define ISRCinstances(inst) ((ISRCinstance *)((inst)->gen.GENinstances))
79 #define ISRCmodName gen.GENmodName
80 
81 } ISRCmodel;
82 
83 
84 /* source types */
85 
86 #ifndef PULSE_FUN_TYPES
87 #define PULSE_FUN_TYPES
88 enum {
89     PULSE = 1,
90     SINE,
91     EXP,
92     SFFM,
93     PWL,
94     AM,
95     TRNOISE,
96     TRRANDOM,
97     EXTERNAL,
98 };
99 
100 #endif
101 
102 /* device parameters */
103 enum {
104     ISRC_DC = 1,
105     ISRC_M,
106     ISRC_AC_MAG,
107     ISRC_AC_PHASE,
108     ISRC_AC,
109     ISRC_PULSE,
110     ISRC_SINE,
111     ISRC_EXP,
112     ISRC_PWL,
113     ISRC_SFFM,
114     ISRC_NEG_NODE,
115     ISRC_POS_NODE,
116     ISRC_AC_REAL,
117     ISRC_AC_IMAG,
118     ISRC_FCN_TYPE,
119     ISRC_FCN_ORDER,
120     ISRC_FCN_COEFFS,
121     ISRC_POWER,
122     ISRC_D_F1,
123     ISRC_D_F2,
124     ISRC_VOLTS,
125     ISRC_AM,
126     ISRC_CURRENT,
127 };
128 
129 enum {
130     ISRC_TRNOISE = 25,
131     ISRC_TRRANDOM,
132     ISRC_EXTERNAL,
133 };
134 
135 /* model parameters */
136 
137 /* device questions */
138 
139 /* model questions */
140 
141 #include "isrcext.h"
142 
143 #endif /*ISRC*/
144