Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_DeviceBlock.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_DeviceBlock.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 02/28/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.33 $
40 //
41 // Revision Date : $Date: 2014/05/19 20:00:59 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-----------------------------------------------------------------------------
45 
46 
47 #ifndef Xyce_N_DEV_DeviceBlock_h
48 #define Xyce_N_DEV_DeviceBlock_h
49 
50 #include <string>
51 #include <vector>
52 #include <iosfwd>
53 
54 #include <N_DEV_Param.h>
55 #include <N_DEV_InstanceName.h>
56 #include <N_UTL_NetlistLocation.h>
57 #include <N_UTL_Misc.h>
58 #include <N_UTL_Xyce.h>
59 #include <N_UTL_Packable.h>
60 
61 
62 namespace Xyce {
63 namespace Device {
64 
65 //-----------------------------------------------------------------------------
66 // Class : ModelBlock
67 // Purpose :
68 // Special Notes :
69 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
70 // Creation Date : 3/31/00
71 //-----------------------------------------------------------------------------
72 ///
73 /// ModelBlock represents a .MODEL line from the netlist.
74 ///
75 class ModelBlock : public Packable
76 {
77  friend std::ostream& operator<<(std::ostream& os, const ModelBlock & mb);
78 
79 public:
80  ModelBlock(const std::string &name = "", const std::string &type = "", int level = 1);
81 
82  ModelBlock(const ModelBlock & right);
83  ModelBlock &operator=(const ModelBlock & right);
84 
85  ~ModelBlock();
86 
87  const ModelName &getName() const
88  {
89  return name_;
90  }
91 
92  void setName(const ModelName &name)
93  {
94  name_ = name;
95  }
96 
97  const std::string &getType() const
98  {
99  return type_;
100  }
101 
102  void setType(const std::string &type)
103  {
104  type_ = type;
105  }
106 
107  int getLevel() const
108  {
109  return level_;
110  }
111 
112  void setLevel(int level)
113  {
114  level_ = level;
115  }
116 
117  const NetlistLocation &getNetlistLocation() const
118  {
119  return netlistLocation_;
120  }
121 
122  void setNetlistLocation(const NetlistLocation &netlist_location)
123  {
124  netlistLocation_ = netlist_location;
125  }
126 
127  bool operator==(const ModelBlock &right) const
128  {
129  return equal_nocase(name_, right.name_);
130  }
131 
132  bool operator!=(const ModelBlock &right) const
133  {
134  return !equal_nocase(name_, right.name_);
135  }
136 
137  void clear();
138 
139  // Packing Utils
140  Packable * instance() const;
141  int packedByteCount() const;
142 
143  void pack( char * buf, int bsize, int & pos, N_PDS_Comm * comm ) const;
144  void unpack( char * pB, int bsize, int & pos, N_PDS_Comm * comm );
145 
146 private:
147  ModelName name_; ///< Model name
148  std::string type_; ///< Model type
149  int level_; ///< Device level
150  NetlistLocation netlistLocation_; ///< Path and line number of .MODEL command
151 
152 public:
153  std::vector<Param> params; ///< Parameters from the line
154 };
155 
156 //-----------------------------------------------------------------------------
157 // Class : InstanceBlock
158 // Purpose :
159 // Special Notes :
160 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
161 // Creation Date : 3/31/00
162 //-----------------------------------------------------------------------------
163 ///
164 /// InstanceBlock represent a device instance line from the netlist.
165 ///
166 class InstanceBlock : public Packable
167 {
168  friend std::ostream& operator<<(std::ostream& os, const InstanceBlock & ib);
169 
170 public:
171  InstanceBlock(const std::string &name = std::string());
172 
173  InstanceBlock(const InstanceBlock & right);
175 
176  ~InstanceBlock();
177 
179  {
180  return name_;
181  }
182 
183  void setInstanceName(const InstanceName &name)
184  {
185  name_ = name;
186  }
187 
188  const ModelName &getModelName() const
189  {
190  return modelName_;
191  }
192 
193  void setModelName(const ModelName &modelName)
194  {
195  modelName_ = modelName;
196  }
197 
198  const NetlistLocation &getNetlistLocation() const {
199  return netlistLocation_;
200  }
201 
202  void setNetlistLocation(const NetlistLocation &netlist_location)
203  {
204  netlistLocation_ = netlist_location;
205  }
206 
207  bool operator==(const InstanceBlock &right) const
208  {
209  return equal_nocase(name_.getEncodedName(), right.name_.getEncodedName());
210  }
211 
212  bool operator!=(const InstanceBlock &right) const
213  {
214  return !equal_nocase(name_.getEncodedName(), right.name_.getEncodedName());
215  }
216 
217  void clear ();
218 
219  //Packing Utils
220  Packable * instance() const;
221  int packedByteCount() const;
222 
223  void pack( char * buf, int bsize, int & pos, N_PDS_Comm * comm ) const;
224  void unpack( char * pB, int bsize, int & pos, N_PDS_Comm * comm );
225 
226 private:
227  InstanceName name_; ///< Device instance name
228  ModelName modelName_; ///< Model name if provided
229  NetlistLocation netlistLocation_; ///< Path and line number of .MODEL command
230 
231 public:
232  std::vector<Param> params;
233 
238 
239  bool modelFlag;
242  bool offFlag;
243  bool off;
244 };
245 
246 } // namespace Device
247 } // namespace Xyce
248 
251 
252 #endif