Jspice3
Main Page
Data Structures
Files
File List
Globals
cktfndm.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
1993 Stephen R. Whiteley
6
****************************************************************************/
7
8
#include "
spice.h
"
9
#include <stdio.h>
10
#include <math.h>
11
#include "
cktdefs.h
"
12
#include "
sperror.h
"
13
#include "
util.h
"
14
#include "
cktext.h
"
15
16
17
int
18
CKTfndMod
(ckt,
type
,modfast,modname)
19
20
GENERIC
*ckt;
21
int
*
type
;
22
GENERIC
**modfast;
23
IFuid
modname;
24
{
25
GENmodel
*mods;
26
27
if
(modfast !=
NULL
&& *(
GENmodel
**)modfast !=
NULL
) {
28
/* already have modfast, so nothing to do */
29
if
(type) *type = (*(
GENmodel
**)modfast)->
GENmodType
;
30
return
(
OK
);
31
}
32
if
(*type >=0 && *type <
DEVmaxnum
) {
33
/* have device type, need to find model */
34
/* look through all models */
35
for
(mods = ((
CKTcircuit
*)ckt)->CKThead[*type]; mods !=
NULL
;
36
mods = mods->
GENnextModel
) {
37
if
(mods->
GENmodName
== modname) {
38
*modfast = (
char
*)mods;
39
return
(
OK
);
40
}
41
}
42
return
(
E_NOMOD
);
43
}
44
else
if
(*type == -1) {
45
/* look through all types (UGH - worst case - take forever) */
46
for
(*type = 0; *type <
DEVmaxnum
; (*type)++) {
47
/* need to find model & device */
48
/* look through all models */
49
for
(mods = ((
CKTcircuit
*)ckt)->CKThead[*type]; mods!=
NULL
;
50
mods = mods->
GENnextModel
) {
51
if
(mods->
GENmodName
== modname) {
52
*modfast = (
char
*)mods;
53
return
(
OK
);
54
}
55
}
56
}
57
*type = -1;
58
return
(
E_NOMOD
);
59
}
60
else
61
return
(
E_BADPARM
);
62
}
cktdefs.h
CKTfndMod
int CKTfndMod(GENERIC *ckt, int *type, GENERIC **modfast, IFuid modname)
Definition:
cktfndm.c:18
CKTcircuit
Definition:
cktdefs.h:62
E_BADPARM
#define E_BADPARM
Definition:
iferrmsg.h:26
sGENmodel::GENnextModel
struct sGENmodel * GENnextModel
Definition:
gendefs.h:41
OK
#define OK
Definition:
iferrmsg.h:17
IFuid
GENERIC * IFuid
Definition:
ifsim.h:72
sperror.h
NULL
#define NULL
Definition:
spdefs.h:121
type
Definition:
types.c:18
E_NOMOD
#define E_NOMOD
Definition:
iferrmsg.h:23
util.h
spice.h
sGENmodel
Definition:
gendefs.h:39
sGENmodel::GENmodType
int GENmodType
Definition:
gendefs.h:40
cktext.h
DEVmaxnum
int DEVmaxnum
Definition:
sconfig.c:166
GENERIC
char GENERIC
Definition:
ifsim.h:27
sGENmodel::GENmodName
IFuid GENmodName
Definition:
gendefs.h:45
src
lib
ckt
cktfndm.c
Generated by
1.8.11