My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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: netdefs.h 1825 2011-03-11 20:42:14Z ela $
22  *
23  */
24 
25 #ifndef __NETDEFS_H__
26 #define __NETDEFS_H__
27 
28 class environment;
29 
30 /* Representation of a node list. */
31 struct node_t {
32  char * node;
33  char * xlate;
34  int xlatenr;
35  struct node_t * next;
36 };
37 
38 /* Representation of a value. */
39 struct value_t {
40  char * ident;
41  char * unit;
42  char * scale;
43  double value;
44  int var;
45  int subst;
46  int hint;
47  int range;
48  struct value_t * next;
49 };
50 
51 /* Representation of a key / value pair. */
52 struct pair_t {
53  char * key;
54  struct value_t * value;
55  struct pair_t * next;
56 };
57 
58 /* Representation of a definition line in the netlist. */
59 struct definition_t {
60  char * type;
61  char * instance;
62  struct node_t * nodes;
63  struct pair_t * pairs;
64  struct definition_t * next;
65  struct definition_t * sub;
67  void * eqns;
68  int duplicate;
69  int action;
70  int substrate;
71  int nonlinear;
72  int nodeset;
73  int line;
74  int copy;
75  int ncount;
76  char * text;
77  char * subcircuit;
78  struct value_t * values;
79  struct define_t * define;
80 };
81 
82 // Structure defining a key value pair.
83 struct property_t {
84  const char * key; // key name
85  int type; // type of property
86  struct {
87  nr_double_t d; // default value
88  const char * s; // default string
89  } defaultval;
90  struct {
91  char il; // interval boundary
92  nr_double_t l; // lower bound of the value
93  nr_double_t h; // upper bound of the value
94  char ih; // interval boundary
95  const char * str[8]; // possible string list
96  } range;
97 };
98 
99 // Structure defining an available component type.
100 struct define_t {
101  const char * type; // component name
102  int nodes; // number of nodes
103  int action; // is that an action?
104  int substrate; // is that a substrate?
105  int nonlinear; // is the component linear?
106  struct property_t * required; // required properties
107  struct property_t * optional; // optional proberties
108 };
109 
110 // Maximum number of S-parameter ports.
111 #define MAX_PORTS 256
112 
113 #define PROP_ACTION 1
114 #define PROP_COMPONENT 0
115 #define PROP_SUBSTRATE 1
116 #define PROP_NO_SUBSTRATE 0
117 #define PROP_NONLINEAR 1
118 #define PROP_LINEAR 0
119 #define PROP_NODES -1
120 #define PROP_NO_PROP { NULL, PROP_REAL, { PROP_NO_VAL, PROP_NO_STR }, \
121  PROP_NO_RANGE }
122 #define PROP_NO_VAL 0.0
123 #define PROP_NO_STR ((char *) -1)
124 #define PROP_NO_RANGE { '.', 0, 0, '.', { NULL } }
125 #define PROP_VAL_MAX NR_MAX
126 #define PROP_VAL_MIN NR_MIN
127 #define PROP_POS_RANGE { '[', 0, 0, '.', { NULL } }
128 #define PROP_NEG_RANGE { '.', 0, 0, ']', { NULL } }
129 #define PROP_POS_RANGEX { ']', 0, 0, '.', { NULL } }
130 #define PROP_NEG_RANGEX { '.', 0, 0, '[', { NULL } }
131 #define PROP_MIN_VAL(k) { '[', k, 0, '.', { NULL } }
132 #define PROP_MAX_VAL(k) { '.', 0, k, ']', { NULL } }
133 #define PROP_MIN_VALX(k) { ']', k, 0, '.', { NULL } }
134 #define PROP_MAX_VALX(k) { '.', 0, k, '[', { NULL } }
135 #define PROP_RNG_X01I { ']', 0, 1, ']', { NULL } }
136 #define PROP_RNGII(f,t) { '[', f, t, ']', { NULL } }
137 #define PROP_RNGXI(f,t) { ']', f, t, ']', { NULL } }
138 #define PROP_RNGIX(f,t) { '[', f, t, '[', { NULL } }
139 #define PROP_RNGXX(f,t) { ']', f, t, '[', { NULL } }
140 
141 #define PROP_RNG_STR1(s) \
142  { '.', 0, 0, '.', { s, NULL } }
143 #define PROP_RNG_STR2(s1,s2) \
144  { '.', 0, 0, '.', { s1, s2, NULL } }
145 #define PROP_RNG_STR3(s1,s2,s3) \
146  { '.', 0, 0, '.', { s1, s2, s3, NULL } }
147 #define PROP_RNG_STR4(s1,s2,s3,s4) \
148  { '.', 0, 0, '.', { s1, s2, s3, s4, NULL } }
149 #define PROP_RNG_STR5(s1,s2,s3,s4,s5) \
150  { '.', 0, 0, '.', { s1, s2, s3, s4, s5, NULL } }
151 #define PROP_RNG_STR6(s1,s2,s3,s4,s5,s6) \
152  { '.', 0, 0, '.', { s1, s2, s3, s4, s5, s6, NULL } }
153 #define PROP_RNG_STR7(s1,s2,s3,s4,s5,s6,s7) \
154  { '.', 0, 0, '.', { s1, s2, s3, s4, s5, s6, s7, NULL } }
155 
156 #define PROP_RNG_YESNO PROP_RNG_STR2 ("yes", "no")
157 #define PROP_RNG_BJT PROP_RNG_STR2 ("npn", "pnp")
158 #define PROP_RNG_FET PROP_RNG_STR2 ("nfet", "pfet")
159 #define PROP_RNG_MOS PROP_RNG_STR2 ("nmos", "pmos")
160 #define PROP_RNG_TYP PROP_RNG_STR4 ("lin", "log", "list", "const")
161 #define PROP_RNG_SOL \
162  PROP_RNG_STR5 ("CroutLU", "DoolittleLU", "HouseholderQR", \
163  "HouseholderLQ", "GolubSVD")
164 #define PROP_RNG_DIS \
165  PROP_RNG_STR7 ("Kirschning", "Kobayashi", "Yamashita", "Getsinger", \
166  "Schneider", "Pramanick", "Hammerstad")
167 #define PROP_RNG_MOD \
168  PROP_RNG_STR3 ("Wheeler", "Schneider", "Hammerstad")
169 
170 #define PROP_NONE -1
171 #define PROP_INT 0
172 #define PROP_REAL 1
173 #define PROP_STR 2
174 #define PROP_LIST 3
175 
176 #define PROP_IS_PROP(prop) ((prop).key != NULL)
177 #define PROP_IS_VAL(prop) ((prop).type != PROP_STR)
178 #define PROP_IS_INT(prop) ((prop).type == PROP_INT)
179 #define PROP_IS_STR(prop) (!PROP_IS_VAL (prop))
180 #define PROP_IS_LST(prop) ((prop).type == PROP_LIST)
181 #define PROP_HAS_RANGE(prop) ((prop).range.l != 0 || (prop).range.h != 0 || \
182  (prop).range.il != '.' || (prop).range.ih != '.')
183 #define PROP_HAS_STR(prop) ((prop).range.str[0] != NULL)
184 
185 #define PROP_REQ static struct property_t required
186 #define PROP_OPT static struct property_t optional
187 #define PROP_DEF required, optional
188 
189 #define create_definition() \
190  ((struct definition_t *) calloc (sizeof (struct definition_t), 1))
191 #define create_value() \
192  ((struct value_t *) calloc (sizeof (struct value_t), 1))
193 #define create_node() \
194  ((struct node_t *) calloc (sizeof (struct node_t), 1))
195 #define create_pair() \
196  ((struct pair_t *) calloc (sizeof (struct pair_t), 1))
197 
198 #endif /* __NETDEFS_H__ */