Jspice3
Main Page
Data Structures
Files
File List
Globals
sw.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 Gordon M. Jacobs
5
1993 Stephen R. Whiteley
6
****************************************************************************/
7
8
#include "
spice.h
"
9
#include <stdio.h>
10
#include "
swdefs.h
"
11
#include "
uflags.h
"
12
13
static
IFparm
SWpTable
[] = {
/* parameters */
14
IP
(
"on"
,
SW_IC_ON
,
IF_FLAG
,
"Switch initially closed"
),
15
IP
(
"off"
,
SW_IC_OFF
,
IF_FLAG
,
"Switch initially open"
),
16
IOPU
(
"pos_node"
,
SW_POS_NODE
,
IF_INTEGER
,
"Positive node of switch"
),
17
IOPU
(
"neg_node"
,
SW_NEG_NODE
,
IF_INTEGER
,
"Negative node of switch"
),
18
IOP
(
"control"
,
SW_CONTROL
,
IF_INSTANCE
,
"Name of controlling source"
),
19
OPU
(
"cont_p_node"
,
SW_POS_CONT_NODE
,
IF_INTEGER
,
"Positive cont node of switch"
),
20
OPU
(
"cont_n_node"
,
SW_NEG_CONT_NODE
,
IF_INTEGER
,
"Positive cont node of switch"
),
21
OP
(
"i"
,
SW_CURRENT
,
IF_REAL
,
"Switch current"
),
22
OP
(
"p"
,
SW_POWER
,
IF_REAL
,
"Switch power"
)
23
};
24
25
static
IFparm
SWmPTable
[] = {
/* model parameters */
26
IOPU
(
"sw"
,
SW_MOD_SW
,
IF_FLAG
,
"Switch model"
),
27
IOPU
(
"vt"
,
SW_MOD_VTH
,
IF_REAL
,
"Threshold voltage"
),
28
IOPU
(
"vh"
,
SW_MOD_VHYS
,
IF_REAL
,
"Hysteresis voltage"
),
29
IOPU
(
"it"
,
SW_MOD_ITH
,
IF_REAL
,
"Threshold current"
),
30
IOPU
(
"ih"
,
SW_MOD_IHYS
,
IF_REAL
,
"Hysterisis current"
),
31
IOPU
(
"ron"
,
SW_MOD_RON
,
IF_REAL
,
"Resistance when closed"
),
32
IOPU
(
"roff"
,
SW_MOD_ROFF
,
IF_REAL
,
"Resistance when open"
),
33
OPU
(
"gon"
,
SW_MOD_GON
,
IF_REAL
,
"Conductance when closed"
),
34
OPU
(
"goff"
,
SW_MOD_GOFF
,
IF_REAL
,
"Conductance when open"
)
35
};
36
37
static
char
*
SWnames1
[] = {
38
"S+"
,
39
"S-"
,
40
"SC+"
,
41
"SC-"
42
};
43
44
static
char
*
SWnames2
[] = {
45
"S+"
,
46
"S-"
47
};
48
49
static
char
*
SWmodNames
[] = {
50
"sw"
,
51
"csw"
,
52
NULL
53
};
54
55
static
IFkeys
SWkeys
[] = {
56
{
's'
,
NUMELEMS
(
SWnames1
),
SWnames1
, 0, 0 },
57
{
'w'
,
NUMELEMS
(
SWnames2
),
SWnames2
, 0, 1 },
58
};
59
60
61
static
int
SWkSize
=
NUMELEMS
(SWkeys);
62
static
int
SWpTSize
=
NUMELEMS
(SWpTable);
63
static
int
SWmPTSize
=
NUMELEMS
(SWmPTable);
64
static
int
SWiSize
=
sizeof
(
SWinstance
);
65
static
int
SWmSize
=
sizeof
(
SWmodel
);
66
67
68
SPICEdev
SWinfo
= {
69
{
70
"Switch"
,
71
"Ideal switch"
,
72
73
&
SWkSize
,
74
SWkeys
,
75
1,
76
SWmodNames
,
77
SWparse
,
78
79
&
SWpTSize
,
80
SWpTable
,
81
82
&
SWmPTSize
,
83
SWmPTable
,
84
},
85
86
SWparam
,
87
SWmParam
,
88
SWload
,
89
SWsetup
,
90
SWsetup
,
91
NULL
,
92
NULL
,
93
NULL
,
94
SWacLoad
,
95
NULL
,
96
GENdestroy
,
97
GENmDelete
,
98
GENdelete
,
99
NULL
,
100
SWask
,
101
SWmAsk
,
102
SWpzLoad
,
103
NULL
,
104
NULL
,
/* DISTO */
105
SWnoise
,
106
107
&
SWiSize
,
108
&
SWmSize
109
};
SW_MOD_IHYS
#define SW_MOD_IHYS
Definition:
swdefs.h:103
SWmParam
int SWmParam()
SW_POS_CONT_NODE
#define SW_POS_CONT_NODE
Definition:
swdefs.h:90
SWpTSize
static int SWpTSize
Definition:
sw.c:62
IOP
#define IOP(a, b, c, d)
Definition:
devdefs.h:120
SWask
int SWask()
SWnames2
static char * SWnames2[]
Definition:
sw.c:44
SW_MOD_VTH
#define SW_MOD_VTH
Definition:
swdefs.h:100
SWiSize
static int SWiSize
Definition:
sw.c:64
SW_IC_OFF
#define SW_IC_OFF
Definition:
swdefs.h:87
OPU
#define OPU(a, b, c, d)
Definition:
uflags.h:65
NUMELEMS
#define NUMELEMS(ARRAY)
Definition:
spice.h:157
SWinfo
SPICEdev SWinfo
Definition:
sw.c:68
SW_IC_ON
#define SW_IC_ON
Definition:
swdefs.h:86
SWmodel
struct sSWmodel SWmodel
GENdestroy
void GENdestroy()
SWmodNames
static char * SWmodNames[]
Definition:
sw.c:49
swdefs.h
SWinstance
struct sSWinstance SWinstance
SW_MOD_SW
#define SW_MOD_SW
Definition:
swdefs.h:97
IF_INSTANCE
#define IF_INSTANCE
Definition:
ifsim.h:112
SW_MOD_GON
#define SW_MOD_GON
Definition:
swdefs.h:104
SWmSize
static int SWmSize
Definition:
sw.c:65
SW_MOD_RON
#define SW_MOD_RON
Definition:
swdefs.h:98
SW_MOD_GOFF
#define SW_MOD_GOFF
Definition:
swdefs.h:105
SWmAsk
int SWmAsk()
SWmPTSize
static int SWmPTSize
Definition:
sw.c:63
SWload
int SWload()
NULL
#define NULL
Definition:
spdefs.h:121
SWacLoad
int SWacLoad()
IF_INTEGER
#define IF_INTEGER
Definition:
ifsim.h:107
SW_NEG_NODE
#define SW_NEG_NODE
Definition:
swdefs.h:89
SWmPTable
static IFparm SWmPTable[]
Definition:
sw.c:25
uflags.h
spice.h
SWparam
int SWparam()
SWnames1
static char * SWnames1[]
Definition:
sw.c:37
SW_MOD_ROFF
#define SW_MOD_ROFF
Definition:
swdefs.h:99
SW_POS_NODE
#define SW_POS_NODE
Definition:
swdefs.h:88
SWpzLoad
int SWpzLoad()
sIFparm
Definition:
ifsim.h:54
sIFkeys
Definition:
ifsim.h:267
IF_REAL
#define IF_REAL
Definition:
ifsim.h:108
IP
#define IP(a, b, c, d)
Definition:
devdefs.h:118
SPICEdev
Definition:
devdefs.h:43
SW_CURRENT
#define SW_CURRENT
Definition:
swdefs.h:93
SW_MOD_VHYS
#define SW_MOD_VHYS
Definition:
swdefs.h:101
SWnoise
int SWnoise()
IF_FLAG
#define IF_FLAG
Definition:
ifsim.h:106
GENmDelete
int GENmDelete()
GENdelete
int GENdelete()
SW_CONTROL
#define SW_CONTROL
Definition:
swdefs.h:92
SWkeys
static IFkeys SWkeys[]
Definition:
sw.c:55
SW_MOD_ITH
#define SW_MOD_ITH
Definition:
swdefs.h:102
SWsetup
int SWsetup()
SWpTable
static IFparm SWpTable[]
Definition:
sw.c:13
SWparse
void SWparse()
OP
#define OP(a, b, c, d)
Definition:
devdefs.h:119
SWkSize
static int SWkSize
Definition:
sw.c:61
SW_POWER
#define SW_POWER
Definition:
swdefs.h:94
IOPU
#define IOPU(a, b, c, d)
Definition:
uflags.h:48
SW_NEG_CONT_NODE
#define SW_NEG_CONT_NODE
Definition:
swdefs.h:91
src
lib
dev
sw
sw.c
Generated by
1.8.11