Jspice3
src.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  1987 Kanwar Jit Singh
6  1993 Stephen R. Whiteley
7 ****************************************************************************/
8 
9 #include "spice.h"
10 #include <stdio.h>
11 #include "srcdefs.h"
12 #include "uflags.h"
13 
14 /* Arbitrary source */
15 static IFparm SRCpTable[] = { /* parameters */
16  IP( "i", SRC_I, IF_PARSETREE, "Current source "),
17  IP( "v", SRC_V, IF_PARSETREE, "Voltage source"),
18  IOP( "type", SRC_DEP, IF_INTEGER, "Type of dependency"),
19  IOPP( "dc", SRC_DC, IF_REAL, "D.C. source value"),
20  IOP( "ac", SRC_AC, IF_REALVEC, "AC magnitude, phase vector"),
21  IOPAAU("acmag", SRC_AC_MAG, IF_REAL, "A.C. Magnitude"),
22  IOPAAU("acphase", SRC_AC_PHASE, IF_REAL, "A.C. Phase"),
23  IOP( "function",SRC_FUNC, IF_PARSETREE, "Function specification"),
24  IP( "distof1", SRC_D_F1, IF_REALVEC, "f1 input for distortion"),
25  IP( "distof2", SRC_D_F2, IF_REALVEC, "f2 input for distortion"),
26  IOP( "gain", SRC_GAIN, IF_REAL , "Gain of source"),
27  IOP( "control", SRC_CONTROL, IF_INSTANCE, "Name of controlling source"),
28  OPU( "pos_node",SRC_POS_NODE, IF_INTEGER, "Positive node of source"),
29  OPU( "neg_node",SRC_NEG_NODE, IF_INTEGER, "Negative node of source"),
30  OPU( "acreal", SRC_AC_REAL, IF_REAL, "AC real part"),
31  OPU( "acimag", SRC_AC_IMAG, IF_REAL, "AC imaginary part"),
32  OP( "c", SRC_CURRENT, IF_REAL, "Voltage source current"),
33  OP( "p", SRC_POWER, IF_REAL, "Instantaneous power"),
34  OP( "cont_p_node",SRC_CONT_P_NODE,IF_INTEGER,
35  "Positive node of contr. source"),
36  OP( "cont_n_node",SRC_CONT_N_NODE,IF_INTEGER,
37  "Negative node of contr. source")
38 };
39 
40 
41 /* model parameters */
42 /* static IFparm SRCmPTable[] = { }; */
43 
44 static char *SRCnames1[] = {
45  "src+",
46  "src-",
47 };
48 
49 static char *SRCnames2[] = {
50  "src+",
51  "src-",
52  "srcC+",
53  "srcC-"
54 };
55 
56 static IFkeys SRCkeys[] = {
57  { 'a', NUMELEMS(SRCnames1), SRCnames1, 0, 0 },
58  { 'v', NUMELEMS(SRCnames1), SRCnames1, 0, 0 },
59  { 'i', NUMELEMS(SRCnames1), SRCnames1, 0, 0 },
60  { 'e', NUMELEMS(SRCnames2), SRCnames2, 0, 0 },
61  { 'f', NUMELEMS(SRCnames1), SRCnames1, 0, 1 },
62  { 'g', NUMELEMS(SRCnames2), SRCnames2, 0, 0 },
63  { 'h', NUMELEMS(SRCnames1), SRCnames1, 0, 1 },
64 };
65 
66 static int SRCkSize = NUMELEMS(SRCkeys);
67 static int SRCpTSize = NUMELEMS(SRCpTable);
68 static int SRCmPTSize = 0;
69 static int SRCiSize = sizeof(SRCinstance);
70 static int SRCmSize = sizeof(SRCmodel);
71 
72 
74  {
75  "Source",
76  "General source model ",
77 
78  &SRCkSize,
79  SRCkeys,
80  1,
81  NULL,
82  SRCparse,
83 
84  &SRCpTSize,
85  SRCpTable,
86 
87  0, /*&SRCmPTSize*/
88  NULL /*SRCmPTable*/
89  },
90 
91  SRCparam,
92  NULL,
93  SRCload,
94  SRCsetup,
95  SRCsetup,
96  NULL,
97  NULL,
98  SRCfindBr,
99  SRCacLoad, /* ac and normal load functions NOT identical */
100  NULL,
101  SRCdestroy,
102  SRCmDelete,
103  SRCdelete,
104  NULL,
105  SRCask,
106  NULL,
107  SRCpzLoad,
108  SRCconvTest,
109  NULL, /* DISTO */
110  NULL, /* NOISE */
111 
112  &SRCiSize,
113  &SRCmSize
114 };
#define SRC_I
Definition: srcdefs.h:216
#define SRC_AC_REAL
Definition: srcdefs.h:230
void SRCparse()
#define SRC_V
Definition: srcdefs.h:217
#define IOP(a, b, c, d)
Definition: devdefs.h:120
int SRCmDelete()
struct sSRCinstance SRCinstance
int SRCpzLoad()
static int SRCmSize
Definition: src.c:70
#define OPU(a, b, c, d)
Definition: uflags.h:65
#define NUMELEMS(ARRAY)
Definition: spice.h:157
static int SRCpTSize
Definition: src.c:67
#define SRC_POWER
Definition: srcdefs.h:233
#define SRC_AC
Definition: srcdefs.h:220
#define IF_INSTANCE
Definition: ifsim.h:112
int SRCask()
static int SRCmPTSize
Definition: src.c:68
#define SRC_CURRENT
Definition: srcdefs.h:232
#define SRC_AC_MAG
Definition: srcdefs.h:221
SPICEdev SRCinfo
Definition: src.c:73
#define SRC_CONTROL
Definition: srcdefs.h:227
int SRCdelete()
int SRCload()
static IFparm SRCpTable[]
Definition: src.c:15
int SRCconvTest()
#define NULL
Definition: spdefs.h:121
#define SRC_AC_PHASE
Definition: srcdefs.h:222
#define IF_INTEGER
Definition: ifsim.h:107
struct sSRCmodel SRCmodel
static int SRCkSize
Definition: src.c:66
static int SRCiSize
Definition: src.c:69
int SRCsetup()
#define SRC_NEG_NODE
Definition: srcdefs.h:229
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
static char * SRCnames2[]
Definition: src.c:49
#define SRC_D_F2
Definition: srcdefs.h:225
#define IOPAAU(a, b, c, d)
Definition: uflags.h:54
#define SRC_D_F1
Definition: srcdefs.h:224
#define SRC_CONT_N_NODE
Definition: srcdefs.h:235
#define SRC_FUNC
Definition: srcdefs.h:223
#define SRC_DEP
Definition: srcdefs.h:218
#define IF_REALVEC
Definition: ifsim.h:125
void SRCdestroy()
int SRCacLoad()
static char * SRCnames1[]
Definition: src.c:44
#define SRC_POS_NODE
Definition: srcdefs.h:228
int SRCparam()
#define OP(a, b, c, d)
Definition: devdefs.h:119
int SRCfindBr()
#define SRC_GAIN
Definition: srcdefs.h:226
#define SRC_DC
Definition: srcdefs.h:219
#define SRC_AC_IMAG
Definition: srcdefs.h:231
#define IOPP(a, b, c, d)
Definition: uflags.h:49
#define SRC_CONT_P_NODE
Definition: srcdefs.h:234
#define IF_PARSETREE
Definition: ifsim.h:113
static IFkeys SRCkeys[]
Definition: src.c:56