Jspice3
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 
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 };
#define SW_MOD_IHYS
Definition: swdefs.h:103
int SWmParam()
#define SW_POS_CONT_NODE
Definition: swdefs.h:90
static int SWpTSize
Definition: sw.c:62
#define IOP(a, b, c, d)
Definition: devdefs.h:120
int SWask()
static char * SWnames2[]
Definition: sw.c:44
#define SW_MOD_VTH
Definition: swdefs.h:100
static int SWiSize
Definition: sw.c:64
#define SW_IC_OFF
Definition: swdefs.h:87
#define OPU(a, b, c, d)
Definition: uflags.h:65
#define NUMELEMS(ARRAY)
Definition: spice.h:157
SPICEdev SWinfo
Definition: sw.c:68
#define SW_IC_ON
Definition: swdefs.h:86
struct sSWmodel SWmodel
void GENdestroy()
static char * SWmodNames[]
Definition: sw.c:49
struct sSWinstance SWinstance
#define SW_MOD_SW
Definition: swdefs.h:97
#define IF_INSTANCE
Definition: ifsim.h:112
#define SW_MOD_GON
Definition: swdefs.h:104
static int SWmSize
Definition: sw.c:65
#define SW_MOD_RON
Definition: swdefs.h:98
#define SW_MOD_GOFF
Definition: swdefs.h:105
int SWmAsk()
static int SWmPTSize
Definition: sw.c:63
int SWload()
#define NULL
Definition: spdefs.h:121
int SWacLoad()
#define IF_INTEGER
Definition: ifsim.h:107
#define SW_NEG_NODE
Definition: swdefs.h:89
static IFparm SWmPTable[]
Definition: sw.c:25
int SWparam()
static char * SWnames1[]
Definition: sw.c:37
#define SW_MOD_ROFF
Definition: swdefs.h:99
#define SW_POS_NODE
Definition: swdefs.h:88
int SWpzLoad()
Definition: ifsim.h:54
Definition: ifsim.h:267
#define IF_REAL
Definition: ifsim.h:108
#define IP(a, b, c, d)
Definition: devdefs.h:118
#define SW_CURRENT
Definition: swdefs.h:93
#define SW_MOD_VHYS
Definition: swdefs.h:101
int SWnoise()
#define IF_FLAG
Definition: ifsim.h:106
int GENmDelete()
int GENdelete()
#define SW_CONTROL
Definition: swdefs.h:92
static IFkeys SWkeys[]
Definition: sw.c:55
#define SW_MOD_ITH
Definition: swdefs.h:102
int SWsetup()
static IFparm SWpTable[]
Definition: sw.c:13
void SWparse()
#define OP(a, b, c, d)
Definition: devdefs.h:119
static int SWkSize
Definition: sw.c:61
#define SW_POWER
Definition: swdefs.h:94
#define IOPU(a, b, c, d)
Definition: uflags.h:48
#define SW_NEG_CONT_NODE
Definition: swdefs.h:91