Jspice3
Main Page
Data Structures
Files
File List
Globals
srcpar.c
Go to the documentation of this file.
1
/***************************************************************************
2
JSPICE3 adaptation of Spice3e2 - 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
1987 Kanwar Jit Singh
6
1992 Stephen R. Whiteley
7
****************************************************************************/
8
9
#include "
spice.h
"
10
#include <stdio.h>
11
#include "
srcdefs.h
"
12
#include "
sperror.h
"
13
#include "
util.h
"
14
15
16
/* ARGSUSED */
17
int
18
SRCparam
(ckt,param,value,inst,select)
19
20
CKTcircuit
*ckt;
21
int
param;
22
IFvalue
*value;
23
GENinstance
*inst;
24
IFvalue
*select;
25
{
26
SRCinstance
*here = (
SRCinstance
*)inst;
27
28
switch
(param) {
29
case
SRC_I
:
30
if
(here->
SRCtype
)
31
return
(
E_BADPARM
);
32
here->
SRCtype
=
SRC_I
;
33
here->
SRCtree
= value->
tValue
;
34
break
;
35
case
SRC_V
:
36
if
(here->
SRCtype
)
37
return
(
E_BADPARM
);
38
here->
SRCtype
=
SRC_V
;
39
here->
SRCtree
= value->
tValue
;
40
break
;
41
case
SRC_DEP
:
42
if
(here->
SRCdep
)
43
return
(
E_BADPARM
);
44
switch
(value->
iValue
) {
45
case
'A'
:
46
break
;
47
case
'I'
:
48
if
(here->
SRCtype
)
49
return
(
E_BADPARM
);
50
here->
SRCtype
=
SRC_I
;
51
break
;
52
case
'V'
:
53
if
(here->
SRCtype
)
54
return
(
E_BADPARM
);
55
here->
SRCtype
=
SRC_V
;
56
break
;
57
case
'E'
:
58
if
(here->
SRCtype
)
59
return
(
E_BADPARM
);
60
here->
SRCtype
=
SRC_V
;
61
here->
SRCdep
=
SRC_VC
;
62
break
;
63
case
'F'
:
64
if
(here->
SRCtype
)
65
return
(
E_BADPARM
);
66
here->
SRCtype
=
SRC_I
;
67
here->
SRCdep
=
SRC_CC
;
68
break
;
69
case
'G'
:
70
if
(here->
SRCtype
)
71
return
(
E_BADPARM
);
72
here->
SRCtype
=
SRC_I
;
73
here->
SRCdep
=
SRC_VC
;
74
break
;
75
case
'H'
:
76
if
(here->
SRCtype
)
77
return
(
E_BADPARM
);
78
here->
SRCtype
=
SRC_V
;
79
here->
SRCdep
=
SRC_CC
;
80
break
;
81
default
:
82
return
(
E_BADPARM
);
83
}
84
break
;
85
case
SRC_DC
:
86
here->
SRCdcValue
= value->
rValue
;
87
here->
SRCdcGiven
=
TRUE
;
88
break
;
89
case
SRC_AC
:
90
switch
(value->
v
.
numValue
) {
91
case
2:
92
here->SRCacPhase = *(value->
v
.
vec
.rVec+1);
93
here->
SRCacPGiven
=
TRUE
;
94
case
1:
95
here->SRCacMag = *(value->
v
.
vec
.rVec);
96
here->
SRCacMGiven
=
TRUE
;
97
case
0:
98
here->
SRCacGiven
=
TRUE
;
99
break
;
100
default
:
101
return
(
E_BADPARM
);
102
}
103
break
;
104
case
SRC_AC_MAG
:
105
here->SRCacMag = value->
rValue
;
106
here->
SRCacMGiven
=
TRUE
;
107
here->
SRCacGiven
=
TRUE
;
108
break
;
109
case
SRC_AC_PHASE
:
110
here->SRCacPhase = value->
rValue
;
111
here->
SRCacPGiven
=
TRUE
;
112
here->
SRCacGiven
=
TRUE
;
113
break
;
114
case
SRC_FUNC
:
115
if
(here->
SRCtree
)
return
E_BADPARM
;
116
here->
SRCtree
= value->
tValue
;
117
break
;
118
case
SRC_D_F1
:
119
here->
SRCdF1given
=
TRUE
;
120
here->
SRCdGiven
=
TRUE
;
121
switch
(value->
v
.
numValue
) {
122
case
2:
123
here->
SRCdF1phase
= *(value->
v
.
vec
.rVec+1);
124
here->
SRCdF1mag
= *(value->
v
.
vec
.rVec);
125
break
;
126
case
1:
127
here->
SRCdF1mag
= *(value->
v
.
vec
.rVec);
128
here->
SRCdF1phase
= 0.0;
129
break
;
130
case
0:
131
here->
SRCdF1mag
= 1.0;
132
here->
SRCdF1phase
= 0.0;
133
break
;
134
default
:
135
return
(
E_BADPARM
);
136
}
137
break
;
138
case
SRC_D_F2
:
139
here->
SRCdF2given
=
TRUE
;
140
here->
SRCdGiven
=
TRUE
;
141
switch
(value->
v
.
numValue
) {
142
case
2:
143
here->
SRCdF2phase
= *(value->
v
.
vec
.rVec+1);
144
here->
SRCdF2mag
= *(value->
v
.
vec
.rVec);
145
break
;
146
case
1:
147
here->
SRCdF2mag
= *(value->
v
.
vec
.rVec);
148
here->
SRCdF2phase
= 0.0;
149
break
;
150
case
0:
151
here->
SRCdF2mag
= 1.0;
152
here->
SRCdF2phase
= 0.0;
153
break
;
154
default
:
155
return
(
E_BADPARM
);
156
}
157
break
;
158
case
SRC_GAIN
:
159
if
(here->
SRCccCoeffGiven
|| here->
SRCvcCoeffGiven
)
160
return
(
E_BADPARM
);
161
here->
SRCcoeff
= value->
rValue
;
162
if
(here->
SRCdep
==
SRC_CC
)
163
here->
SRCccCoeffGiven
=
TRUE
;
164
else
if
(here->
SRCdep
==
SRC_VC
)
165
here->
SRCvcCoeffGiven
=
TRUE
;
166
else
167
return
(
E_BADPARM
);
168
break
;
169
case
SRC_CONTROL
:
170
here->
SRCcontName
= value->
uValue
;
171
break
;
172
default
:
173
return
(
E_BADPARM
);
174
}
175
return
(
OK
);
176
}
SRC_I
#define SRC_I
Definition:
srcdefs.h:216
sSRCinstance::SRCdF2mag
double SRCdF2mag
Definition:
srcdefs.h:94
uIFvalue::numValue
int numValue
Definition:
ifsim.h:240
sSRCinstance::SRCdF2given
unsigned SRCdF2given
Definition:
srcdefs.h:186
SRC_V
#define SRC_V
Definition:
srcdefs.h:217
sSRCinstance
Definition:
srcdefs.h:20
sSRCinstance::SRCccCoeffGiven
unsigned SRCccCoeffGiven
Definition:
srcdefs.h:187
sSRCinstance::SRCcoeff
double SRCcoeff
Definition:
srcdefs.h:71
SRC_VC
#define SRC_VC
Definition:
srcdefs.h:213
srcdefs.h
SRCparam
int SRCparam(CKTcircuit *ckt, int param, IFvalue *value, GENinstance *inst, IFvalue *select)
Definition:
srcpar.c:18
sSRCinstance::SRCcontName
IFuid SRCcontName
Definition:
srcdefs.h:74
uIFvalue::vec
union uIFvalue::@13::@14 vec
CKTcircuit
Definition:
cktdefs.h:62
E_BADPARM
#define E_BADPARM
Definition:
iferrmsg.h:26
sSRCinstance::SRCdF1given
unsigned SRCdF1given
Definition:
srcdefs.h:185
sSRCinstance::SRCdcValue
double SRCdcValue
Definition:
srcdefs.h:77
SRC_AC
#define SRC_AC
Definition:
srcdefs.h:220
TRUE
#define TRUE
Definition:
util.h:27
uIFvalue::iValue
int iValue
Definition:
ifsim.h:232
uIFvalue::rValue
double rValue
Definition:
ifsim.h:233
SRC_AC_MAG
#define SRC_AC_MAG
Definition:
srcdefs.h:221
sSRCinstance::SRCdGiven
unsigned SRCdGiven
Definition:
srcdefs.h:184
sSRCinstance::SRCdep
int SRCdep
Definition:
srcdefs.h:68
OK
#define OK
Definition:
iferrmsg.h:17
sSRCinstance::SRCdcGiven
unsigned SRCdcGiven
Definition:
srcdefs.h:180
SRC_CONTROL
#define SRC_CONTROL
Definition:
srcdefs.h:227
sperror.h
SRC_AC_PHASE
#define SRC_AC_PHASE
Definition:
srcdefs.h:222
SRC_CC
#define SRC_CC
Definition:
srcdefs.h:212
sSRCinstance::SRCdF1phase
double SRCdF1phase
Definition:
srcdefs.h:97
util.h
sSRCinstance::SRCvcCoeffGiven
unsigned SRCvcCoeffGiven
Definition:
srcdefs.h:188
spice.h
sSRCinstance::SRCdF2phase
double SRCdF2phase
Definition:
srcdefs.h:100
sSRCinstance::SRCacGiven
unsigned SRCacGiven
Definition:
srcdefs.h:181
SRC_D_F2
#define SRC_D_F2
Definition:
srcdefs.h:225
uIFvalue::tValue
IFparseTree * tValue
Definition:
ifsim.h:238
SRC_D_F1
#define SRC_D_F1
Definition:
srcdefs.h:224
SRC_FUNC
#define SRC_FUNC
Definition:
srcdefs.h:223
SRC_DEP
#define SRC_DEP
Definition:
srcdefs.h:218
uIFvalue
Definition:
ifsim.h:231
sSRCinstance::SRCdF1mag
double SRCdF1mag
Definition:
srcdefs.h:91
uIFvalue::v
struct uIFvalue::@13 v
sSRCinstance::SRCacMGiven
unsigned SRCacMGiven
Definition:
srcdefs.h:182
sGENinstance
Definition:
gendefs.h:24
sSRCinstance::SRCtype
int SRCtype
Definition:
srcdefs.h:65
SRC_GAIN
#define SRC_GAIN
Definition:
srcdefs.h:226
sSRCinstance::SRCtree
IFparseTree * SRCtree
Definition:
srcdefs.h:103
SRC_DC
#define SRC_DC
Definition:
srcdefs.h:219
uIFvalue::uValue
IFuid uValue
Definition:
ifsim.h:236
sSRCinstance::SRCacPGiven
unsigned SRCacPGiven
Definition:
srcdefs.h:183
src
lib
dev
src
srcpar.c
Generated by
1.8.11