Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
netdefs.h
Go to the documentation of this file.
1 /*
2  * netdefs.h - netlist definitions for arbitrary netlists
3  *
4  * Copyright (C) 2004, 2007, 2008 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id$
22  *
23  */
24 
25 #ifndef __NETDEFS_H__
26 #define __NETDEFS_H__
27 
28 namespace qucs {
29 class environment;
30 }
31 
32 /* Representation of a node list. */
33 struct node_t {
34  char * node;
35  char * xlate;
36  int xlatenr;
37  struct node_t * next;
38 };
39 
40 /* Representation of a value. */
41 struct value_t {
42  char * ident;
43  char * unit;
44  char * scale;
45  double value;
46  int var;
47  int subst;
48  int hint;
49  int range;
50  struct value_t * next;
51 };
52 
53 /* Representation of a key / value pair. */
54 struct pair_t {
55  char * key;
56  struct value_t * value;
57  struct pair_t * next;
58 };
59 
60 /* Representation of a definition line in the netlist. */
61 struct definition_t {
62  char * type;
63  char * instance;
64  struct node_t * nodes;
65  struct pair_t * pairs;
66  struct definition_t * next;
67  struct definition_t * sub;
69  void * eqns;
70  int duplicate;
71  int action;
72  int substrate;
73  int nonlinear;
74  int nodeset;
75  int line;
76  int copy;
77  int ncount;
78  char * text;
79  char * subcircuit;
80  struct value_t * values;
81  struct define_t * define;
82 };
83 
84 // Structure defining a key value pair.
85 struct property_t {
86  const char * key; // key name
87  int type; // type of property
88  struct {
89  nr_double_t d; // default value
90  const char * s; // default string
91  } defaultval;
92  struct {
93  char il; // interval boundary
94  nr_double_t l; // lower bound of the value
95  nr_double_t h; // upper bound of the value
96  char ih; // interval boundary
97  const char * str[8]; // possible string list
98  } range;
99 };
100 
101 // Structure defining an available component type.
102 struct define_t {
103  const char * type; // component name
104  int nodes; // number of nodes
105  int action; // is that an action?
106  int substrate; // is that a substrate?
107  int nonlinear; // is the component linear?
108  struct property_t * required; // required properties
109  struct property_t * optional; // optional proberties
110 };
111 
112 // Maximum number of S-parameter ports.
113 #define MAX_PORTS 256
114 
115 #define PROP_ACTION 1
116 #define PROP_COMPONENT 0
117 #define PROP_SUBSTRATE 1
118 #define PROP_NO_SUBSTRATE 0
119 #define PROP_NONLINEAR 1
120 #define PROP_LINEAR 0
121 #define PROP_NODES -1
122 #define PROP_NO_PROP { NULL, PROP_REAL, { PROP_NO_VAL, PROP_NO_STR }, \
123  PROP_NO_RANGE }
124 #define PROP_NO_VAL 0.0
125 #define PROP_NO_STR ((char *) -1)
126 #define PROP_NO_RANGE { '.', 0, 0, '.', { NULL } }
127 #define PROP_VAL_MAX NR_MAX
128 #define PROP_VAL_MIN NR_MIN
129 #define PROP_POS_RANGE { '[', 0, 0, '.', { NULL } }
130 #define PROP_NEG_RANGE { '.', 0, 0, ']', { NULL } }
131 #define PROP_POS_RANGEX { ']', 0, 0, '.', { NULL } }
132 #define PROP_NEG_RANGEX { '.', 0, 0, '[', { NULL } }
133 #define PROP_MIN_VAL(k) { '[', k, 0, '.', { NULL } }
134 #define PROP_MAX_VAL(k) { '.', 0, k, ']', { NULL } }
135 #define PROP_MIN_VALX(k) { ']', k, 0, '.', { NULL } }
136 #define PROP_MAX_VALX(k) { '.', 0, k, '[', { NULL } }
137 #define PROP_RNG_X01I { ']', 0, 1, ']', { NULL } }
138 #define PROP_RNGII(f,t) { '[', f, t, ']', { NULL } }
139 #define PROP_RNGXI(f,t) { ']', f, t, ']', { NULL } }
140 #define PROP_RNGIX(f,t) { '[', f, t, '[', { NULL } }
141 #define PROP_RNGXX(f,t) { ']', f, t, '[', { NULL } }
142 
143 #define PROP_RNG_STR1(s) \
144  { '.', 0, 0, '.', { s, NULL } }
145 #define PROP_RNG_STR2(s1,s2) \
146  { '.', 0, 0, '.', { s1, s2, NULL } }
147 #define PROP_RNG_STR3(s1,s2,s3) \
148  { '.', 0, 0, '.', { s1, s2, s3, NULL } }
149 #define PROP_RNG_STR4(s1,s2,s3,s4) \
150  { '.', 0, 0, '.', { s1, s2, s3, s4, NULL } }
151 #define PROP_RNG_STR5(s1,s2,s3,s4,s5) \
152  { '.', 0, 0, '.', { s1, s2, s3, s4, s5, NULL } }
153 #define PROP_RNG_STR6(s1,s2,s3,s4,s5,s6) \
154  { '.', 0, 0, '.', { s1, s2, s3, s4, s5, s6, NULL } }
155 #define PROP_RNG_STR7(s1,s2,s3,s4,s5,s6,s7) \
156  { '.', 0, 0, '.', { s1, s2, s3, s4, s5, s6, s7, NULL } }
157 
158 #define PROP_RNG_YESNO PROP_RNG_STR2 ("yes", "no")
159 #define PROP_RNG_BJT PROP_RNG_STR2 ("npn", "pnp")
160 #define PROP_RNG_FET PROP_RNG_STR2 ("nfet", "pfet")
161 #define PROP_RNG_MOS PROP_RNG_STR2 ("nmos", "pmos")
162 #define PROP_RNG_TYP PROP_RNG_STR4 ("lin", "log", "list", "const")
163 #define PROP_RNG_SOL \
164  PROP_RNG_STR5 ("CroutLU", "DoolittleLU", "HouseholderQR", \
165  "HouseholderLQ", "GolubSVD")
166 #define PROP_RNG_DIS \
167  PROP_RNG_STR7 ("Kirschning", "Kobayashi", "Yamashita", "Getsinger", \
168  "Schneider", "Pramanick", "Hammerstad")
169 #define PROP_RNG_MOD \
170  PROP_RNG_STR3 ("Wheeler", "Schneider", "Hammerstad")
171 
172 #define PROP_NONE -1
173 #define PROP_INT 0
174 #define PROP_REAL 1
175 #define PROP_STR 2
176 #define PROP_LIST 3
177 
178 #define PROP_IS_PROP(prop) ((prop).key != NULL)
179 #define PROP_IS_VAL(prop) ((prop).type != PROP_STR)
180 #define PROP_IS_INT(prop) ((prop).type == PROP_INT)
181 #define PROP_IS_STR(prop) (!PROP_IS_VAL (prop))
182 #define PROP_IS_LST(prop) ((prop).type == PROP_LIST)
183 #define PROP_HAS_RANGE(prop) ((prop).range.l != 0 || (prop).range.h != 0 || \
184  (prop).range.il != '.' || (prop).range.ih != '.')
185 #define PROP_HAS_STR(prop) ((prop).range.str[0] != NULL)
186 
187 #define PROP_REQ static struct property_t required
188 #define PROP_OPT static struct property_t optional
189 #define PROP_DEF required, optional
190 
191 #define create_definition() \
192  ((struct definition_t *) calloc (sizeof (struct definition_t), 1))
193 #define create_value() \
194  ((struct value_t *) calloc (sizeof (struct value_t), 1))
195 #define create_node() \
196  ((struct node_t *) calloc (sizeof (struct node_t), 1))
197 #define create_pair() \
198  ((struct pair_t *) calloc (sizeof (struct pair_t), 1))
199 
200 #endif /* __NETDEFS_H__ */
nr_double_t l
Definition: netdefs.h:94
Definition: netdefs.h:33
int substrate
Definition: netdefs.h:72
int subst
Definition: netdefs.h:47
struct node_t * nodes
Definition: netdefs.h:64
struct node_t * next
Definition: netdefs.h:37
char * xlate
Definition: netdefs.h:35
char * scale
Definition: netdefs.h:44
struct value_t * values
Definition: netdefs.h:80
struct value_t * next
Definition: netdefs.h:50
char * type
Definition: netdefs.h:62
int line
Definition: netdefs.h:75
const char * key
Definition: netdefs.h:86
int var
Definition: netdefs.h:46
const char * type
Definition: netdefs.h:103
Houses the settings for netlist evaluation.
Definition: environment.h:51
int action
Definition: netdefs.h:71
nr_double_t h
Definition: netdefs.h:95
double value
Definition: netdefs.h:45
Definition: netdefs.h:54
char * ident
Definition: netdefs.h:42
char * instance
Definition: netdefs.h:63
int nodes
Definition: netdefs.h:104
int action
Definition: netdefs.h:105
char * node
Definition: netdefs.h:34
char il
Definition: netdefs.h:93
struct definition_t * sub
Definition: netdefs.h:67
struct value_t * value
Definition: netdefs.h:56
char * unit
Definition: netdefs.h:43
int range
Definition: netdefs.h:49
char ih
Definition: netdefs.h:96
struct property_t * required
Definition: netdefs.h:108
struct property_t::@6 defaultval
const char * str[8]
Definition: netdefs.h:97
int nodeset
Definition: netdefs.h:74
const char * s
Definition: netdefs.h:90
int duplicate
Definition: netdefs.h:70
int nonlinear
Definition: netdefs.h:107
char * subcircuit
Definition: netdefs.h:79
int nonlinear
Definition: netdefs.h:73
struct define_t * define
Definition: netdefs.h:81
struct property_t::@7 range
int ncount
Definition: netdefs.h:77
int substrate
Definition: netdefs.h:106
struct pair_t * pairs
Definition: netdefs.h:65
char * text
Definition: netdefs.h:78
int xlatenr
Definition: netdefs.h:36
int copy
Definition: netdefs.h:76
struct property_t * optional
Definition: netdefs.h:109
char * key
Definition: netdefs.h:55
int type
Definition: netdefs.h:87
int hint
Definition: netdefs.h:48
struct pair_t * next
Definition: netdefs.h:57
struct definition_t * next
Definition: netdefs.h:66
qucs::environment * env
Definition: netdefs.h:68
nr_double_t d
Definition: netdefs.h:89
void * eqns
Definition: netdefs.h:69