Qucs-core  0.0.19
netdefs.h
Go to the documentation of this file.
00001 /*
00002  * netdefs.h - netlist definitions for arbitrary netlists
00003  *
00004  * Copyright (C) 2004, 2007, 2008 Stefan Jahn <stefan@lkcc.org>
00005  *
00006  * This is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  *
00011  * This software is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this package; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  * $Id$
00022  *
00023  */
00024 
00025 #ifndef __NETDEFS_H__
00026 #define __NETDEFS_H__
00027 
00028 namespace qucs {
00029 class environment;
00030 }
00031 
00032 /* Representation of a node list. */
00033 struct node_t {
00034   char * node;
00035   char * xlate;
00036   int xlatenr;
00037   struct node_t * next;
00038 };
00039 
00040 /* Representation of a value. */
00041 struct value_t {
00042   char * ident;
00043   char * unit;
00044   char * scale;
00045   double value;
00046   int var;
00047   int subst;
00048   int hint;
00049   int range;
00050   struct value_t * next;
00051 };
00052 
00053 /* Representation of a key / value pair. */
00054 struct pair_t {
00055   char * key;
00056   struct value_t * value;
00057   struct pair_t * next;
00058 };
00059 
00060 /* Representation of a definition line in the netlist. */
00061 struct definition_t {
00062   char * type;
00063   char * instance;
00064   struct node_t * nodes;
00065   struct pair_t * pairs;
00066   struct definition_t * next;
00067   struct definition_t * sub;
00068   qucs::environment * env;
00069   void * eqns;
00070   int duplicate;
00071   int action;
00072   int substrate;
00073   int nonlinear;
00074   int nodeset;
00075   int line;
00076   int copy;
00077   int ncount;
00078   char * text;
00079   char * subcircuit;
00080   struct value_t * values;
00081   struct define_t * define;
00082 };
00083 
00084 // Structure defining a key value pair.
00085 struct property_t {
00086   const char * key; // key name
00087   int type;         // type of property
00088   struct {
00089     nr_double_t d;  // default value
00090     const char * s; // default string
00091   } defaultval;
00092   struct {
00093     char il;        // interval boundary
00094     nr_double_t l;  // lower bound of the value
00095     nr_double_t h;  // upper bound of the value
00096     char ih;        // interval boundary
00097     const char * str[8]; // possible string list
00098   } range;
00099 };
00100 
00101 // Structure defining an available component type.
00102 struct define_t {
00103   const char * type;            // component name
00104   int nodes;                    // number of nodes
00105   int action;                   // is that an action?
00106   int substrate;                // is that a substrate?
00107   int nonlinear;                // is the component linear?
00108   struct property_t * required; // required properties
00109   struct property_t * optional; // optional proberties
00110 };
00111 
00112 // Maximum number of S-parameter ports.
00113 #define MAX_PORTS 256
00114 
00115 #define PROP_ACTION       1
00116 #define PROP_COMPONENT    0
00117 #define PROP_SUBSTRATE    1
00118 #define PROP_NO_SUBSTRATE 0
00119 #define PROP_NONLINEAR    1
00120 #define PROP_LINEAR       0
00121 #define PROP_NODES        -1
00122 #define PROP_NO_PROP      { NULL, PROP_REAL, { PROP_NO_VAL, PROP_NO_STR }, \
00123                             PROP_NO_RANGE }
00124 #define PROP_NO_VAL       0.0
00125 #define PROP_NO_STR       ((char *) -1)
00126 #define PROP_NO_RANGE     { '.', 0, 0, '.', { NULL } }
00127 #define PROP_VAL_MAX      std::numeric_limits<nr_double_t>::max()
00128 #define PROP_VAL_MIN      std::numeric_limits<nr_double_t>::min()
00129 #define PROP_POS_RANGE    { '[', 0, 0, '.', { NULL } }
00130 #define PROP_NEG_RANGE    { '.', 0, 0, ']', { NULL } }
00131 #define PROP_POS_RANGEX   { ']', 0, 0, '.', { NULL } }
00132 #define PROP_NEG_RANGEX   { '.', 0, 0, '[', { NULL } }
00133 #define PROP_MIN_VAL(k)   { '[', k, 0, '.', { NULL } }
00134 #define PROP_MAX_VAL(k)   { '.', 0, k, ']', { NULL } }
00135 #define PROP_MIN_VALX(k)  { ']', k, 0, '.', { NULL } }
00136 #define PROP_MAX_VALX(k)  { '.', 0, k, '[', { NULL } }
00137 #define PROP_RNG_X01I     { ']', 0, 1, ']', { NULL } }
00138 #define PROP_RNGII(f,t)   { '[', f, t, ']', { NULL } }
00139 #define PROP_RNGXI(f,t)   { ']', f, t, ']', { NULL } }
00140 #define PROP_RNGIX(f,t)   { '[', f, t, '[', { NULL } }
00141 #define PROP_RNGXX(f,t)   { ']', f, t, '[', { NULL } }
00142 
00143 #define PROP_RNG_STR1(s) \
00144   { '.', 0, 0, '.', { s, NULL } }
00145 #define PROP_RNG_STR2(s1,s2) \
00146   { '.', 0, 0, '.', { s1, s2, NULL } }
00147 #define PROP_RNG_STR3(s1,s2,s3) \
00148   { '.', 0, 0, '.', { s1, s2, s3, NULL } }
00149 #define PROP_RNG_STR4(s1,s2,s3,s4) \
00150   { '.', 0, 0, '.', { s1, s2, s3, s4, NULL } }
00151 #define PROP_RNG_STR5(s1,s2,s3,s4,s5) \
00152   { '.', 0, 0, '.', { s1, s2, s3, s4, s5, NULL } }
00153 #define PROP_RNG_STR6(s1,s2,s3,s4,s5,s6) \
00154   { '.', 0, 0, '.', { s1, s2, s3, s4, s5, s6, NULL } }
00155 #define PROP_RNG_STR7(s1,s2,s3,s4,s5,s6,s7) \
00156   { '.', 0, 0, '.', { s1, s2, s3, s4, s5, s6, s7, NULL } }
00157 
00158 #define PROP_RNG_YESNO    PROP_RNG_STR2 ("yes", "no")
00159 #define PROP_RNG_BJT      PROP_RNG_STR2 ("npn", "pnp")
00160 #define PROP_RNG_FET      PROP_RNG_STR2 ("nfet", "pfet")
00161 #define PROP_RNG_MOS      PROP_RNG_STR2 ("nmos", "pmos")
00162 #define PROP_RNG_TYP      PROP_RNG_STR4 ("lin", "log", "list", "const")
00163 #define PROP_RNG_SOL \
00164   PROP_RNG_STR5 ("CroutLU", "DoolittleLU", "HouseholderQR", \
00165                  "HouseholderLQ", "GolubSVD")
00166 #define PROP_RNG_DIS \
00167   PROP_RNG_STR7 ("Kirschning", "Kobayashi", "Yamashita", "Getsinger", \
00168                  "Schneider", "Pramanick", "Hammerstad")
00169 #define PROP_RNG_MOD \
00170   PROP_RNG_STR3 ("Wheeler", "Schneider", "Hammerstad")
00171 
00172 #define PROP_NONE         -1
00173 #define PROP_INT          0
00174 #define PROP_REAL         1
00175 #define PROP_STR          2
00176 #define PROP_LIST         3
00177 
00178 #define PROP_IS_PROP(prop)   ((prop).key != NULL)
00179 #define PROP_IS_VAL(prop)    ((prop).type != PROP_STR)
00180 #define PROP_IS_INT(prop)    ((prop).type == PROP_INT)
00181 #define PROP_IS_STR(prop)    (!PROP_IS_VAL (prop))
00182 #define PROP_IS_LST(prop)    ((prop).type == PROP_LIST)
00183 #define PROP_HAS_RANGE(prop) ((prop).range.l != 0 || (prop).range.h != 0 || \
00184                               (prop).range.il != '.' || (prop).range.ih != '.')
00185 #define PROP_HAS_STR(prop)   ((prop).range.str[0] != NULL)
00186 
00187 #define PROP_REQ static struct property_t required
00188 #define PROP_OPT static struct property_t optional
00189 #define PROP_DEF required, optional
00190 
00191 #define create_definition() \
00192   ((struct definition_t *) calloc (sizeof (struct definition_t), 1))
00193 #define create_value() \
00194   ((struct value_t *) calloc (sizeof (struct value_t), 1))
00195 #define create_node() \
00196   ((struct node_t *) calloc (sizeof (struct node_t), 1))
00197 #define create_pair() \
00198   ((struct pair_t *) calloc (sizeof (struct pair_t), 1))
00199 
00200 #endif /* __NETDEFS_H__ */