Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_DeviceEntity.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright(C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_DeviceEntity.h,v $
27 //
28 // Purpose : This file contains the device entity base class.
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 04/03/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.117.2.1 $
40 //
41 // Revision Date : $Date: 2014/02/26 20:16:30 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 
47 #ifndef Xyce_N_DEV_DeviceEntity_h
48 #define Xyce_N_DEV_DeviceEntity_h
49 
50 #include <iosfwd>
51 #include <map>
52 #include <string>
53 #include <vector>
54 
55 #include <N_DEV_fwd.h>
56 #include <N_IO_fwd.h>
57 #include <N_UTL_fwd.h>
58 #include <N_UTL_NetlistLocation.h>
59 #include <N_DEV_Pars.h>
60 
61 class N_LAS_Vector;
62 
63 namespace Xyce {
64 namespace Device {
65 
66 typedef std::map<std::string, std::vector<Param>, LessNoCase> CompositeParamMap;
67 
68 void populateParams(const ParameterMap &parameter_map, std::vector<Param> &param_list, CompositeParamMap &composite_param_map);
69 void setParameters(CompositeParam &composite_param, const std::string &pName, const Param &ndParam );
70 void setParameters(DeviceEntity &entity, std::vector<Param>::const_iterator begin, std::vector<Param>::const_iterator end, const DeviceOptions &device_options);
71 
72 std::ostream &printParameter(std::ostream &os, const DeviceEntity &entity, const std::string &name, const Descriptor &param);
73 std::ostream &printCompositeParameters(std::ostream &os, const CompositeParam &composite);
74 
75 struct Depend
76 {
77  std::string name;
78  Util::Expression * expr;
79  union resUnion
80  {
81  double * result;
82  std::vector<double> * resVec;
83  } resultU;
85  std::vector<double> vals;
86  std::vector<std::string> global_params;
87  int n_vars, lo_var;
88 };
89 
90 //-----------------------------------------------------------------------------
91 // Class : DeviceEntity
92 // Purpose :
93 // Special Notes :
94 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
95 // Creation Date : 6/11/02
96 //-----------------------------------------------------------------------------
98 {
99 public:
100  DeviceEntity(
101  const char * const entity_type,
102  const std::string & device_name,
103  ParametricData<void> & parametric_data,
104  const SolverState & solver_state,
105  const DeviceOptions & device_options,
106  const std::string & netlist_path,
107  int netlist_line);
108 
109 private:
110  DeviceEntity(const DeviceEntity &);
112 
113 public:
114  virtual ~DeviceEntity();
115 
116  virtual bool processParams() = 0;
117 
118  virtual bool processInstanceParams() = 0;
119 
120  virtual CompositeParam *constructComposite(const std::string &composite_name, const std::string &param_name)
121  {
122  return NULL;
123  }
124 
125  bool setDefaultParam(double val);
126  double getDefaultParam();
127 
128  bool scaleParam(const std::string & paramName, double val, double val0);
129  bool scaleParam(const std::string & paramName, double val);
130  bool scaleDefaultParam(double val);
131 
132  bool setParam(const std::string & paramName, double val);
133  bool getParam(const std::string & paramName, double & result);
134  bool getParamBreakpoints( std::vector<Util::BreakPoint> & );
135 
136  bool updateDependentParameters(N_LAS_Vector & vars);
137  bool updateDependentParameters(double temp_tmp);
138  bool updateGlobalParameters(std::map<std::string, double> &);
140 
141  double setDependentParameter(Util::Param &, double *, ParameterType::ExprAccess);
142  double setDependentParameter(Util::Param &, std::vector<double> *, int , ParameterType::ExprAccess);
143  void setDependentParameter(Util::Param & par, Depend & dependentParam, ParameterType::ExprAccess depend);
144 
146  {
148  }
149 
150  void setParams(const std::vector<Param> & params)
151  {
152  setParameters(*this, params.begin(), params.end(), devOptions_);
153  }
154 
155 public:
156  bool given(const std::string & parameter_name) const;
157 
158  const char *getEntityType() const
159  {
160  return entityType_;
161  }
162 
163  const std::string &getName() const
164  {
165  return name_;
166  }
167 
168  void setDefaultParamName(const std::string &default_param_name)
169  {
170  defaultParamName_ = default_param_name;
171  }
172 
173  const std::vector<Depend> &getDependentParams()
174  {
175  return dependentParams;
176  }
177 
179  {
180  return devOptions_;
181  }
182 
183  const SolverState &getSolverState() const
184  {
185  return solState_;
186  }
187 
188  const NetlistLocation &netlistLocation() const
189  {
190  return netlistLocation_;
191  }
192 
194  {
195  return parametricData_.getMap();
196  }
197 
198 private:
199  void escape(std::string &) const;
201 
202 private:
203  const char * const entityType_;
204  std::string name_;
205  std::string defaultParamName_;
207  NetlistLocation netlistLocation_;
208 
211 
212 protected:
213  std::vector<Depend> dependentParams;
214  std::vector<int> expVarGIDs;
215  std::vector<int> expVarLIDs;
216  std::vector<std::string> expVarNames;
217  std::vector<double> expVarVals;
218  std::vector<double> eVarVals;
219 };
220 
221 struct DeviceEntityCmp : public std::binary_function<DeviceEntity, DeviceEntity, bool>
222 
223 {
224  bool operator()(const DeviceEntity &entity_0, const DeviceEntity &entity_1) const
225  {
226  return less_nocase(entity_0.getName(), entity_1.getName());
227  }
228  bool operator()(const DeviceEntity *entity_0, const DeviceEntity *entity_1) const
229  {
230  return less_nocase(entity_0->getName(), entity_1->getName());
231  }
232 };
233 
234 } // namespace Device
235 } // namespace Xyce
236 
238 
239 #endif // Xyce_N_DEV_DeviceEntity_h