Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GdfDataBase.h
Go to the documentation of this file.
1 
13 #ifndef GDFPARSER_DATABASE_H
14 #define GDFPARSER_DATABASE_H
15 
16 #include <string>
17 #include <vector>
18 #include <iostream>
19 #include <fstream>
20 #include <sstream>
21 #include <cassert>
22 
24 namespace GdfParser {
25 
27 using std::cout;
28 using std::endl;
29 using std::cerr;
30 using std::string;
31 using std::vector;
32 using std::pair;
33 using std::make_pair;
34 using std::ostream;
35 typedef int int32_t;
36 typedef unsigned int uint32_t;
37 typedef long int64_t;
39 
42 class IntegerArray : public vector<int>
43 {
44  public:
46  typedef vector<int> base_type;
47  using base_type::size_type;
48  using base_type::value_type;
49  using base_type::allocator_type;
51 
54  IntegerArray(const allocator_type& alloc = allocator_type())
55  : base_type(alloc) {}
60  IntegerArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
61  : base_type(n, val, alloc) {}
62 };
63 
66 class NumberArray : public vector<double>
67 {
68  public:
70  typedef vector<double> base_type;
71  using base_type::size_type;
72  using base_type::value_type;
73  using base_type::allocator_type;
75 
78  NumberArray(const allocator_type& alloc = allocator_type())
79  : base_type(alloc) {}
84  NumberArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
85  : base_type(n, val, alloc) {}
86 };
87 
90 class StringArray : public vector<string>
91 {
92  public:
94  typedef vector<string> base_type;
95  using base_type::size_type;
96  using base_type::value_type;
97  using base_type::allocator_type;
99 
102  StringArray(const allocator_type& alloc = allocator_type())
103  : base_type(alloc) {}
108  StringArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
109  : base_type(n, val, alloc) {}
110 };
111 
114 struct Item
115 {
117  virtual void print(ostream&) const {};
122  friend ostream& operator<<(ostream& ss, Item const& rhs)
123  {
124  rhs.print(ss);
125  return ss;
126  }
127 };
128 
130 struct Point : public Item
131 {
132  double x;
133  double y;
134 
136  Point()
137  {
138  reset();
139  }
141  void reset()
142  {
143  x = y = 0.0;
144  }
147  virtual void print(ostream& ss) const
148  {
149  ss << "(" << x << "," << y << ")";
150  }
151 };
152 
154 struct CellPort : public Item
155 {
158  {
159  IN,
160  OUT,
161  INOUT,
162  POWER,
163  GROUND,
164  UNKNOWN
165  };
166  string name;
167  string layer;
170 
173  {
174  reset();
175  }
177  void reset()
178  {
179  name.clear();
180  layer.clear();
181  point.reset();
182  portType = UNKNOWN;
183  }
188  inline friend ostream& operator<<(ostream& ss, CellPort::PortTypeEnum portType)
189  {
190  switch (portType)
191  {
192  case CellPort::IN:
193  ss << "IN"; break;
194  case CellPort::OUT:
195  ss << "OUT"; break;
196  case CellPort::INOUT:
197  ss << "INOUT"; break;
198  case CellPort::POWER:
199  ss << "POWER"; break;
200  case CellPort::GROUND:
201  ss << "GROUND"; break;
202  case CellPort::UNKNOWN:
203  default:
204  ss << "UNKNOWN"; break;
205  }
206  return ss;
207  }
210  virtual void print(ostream& ss) const
211  {
212  ss << "//////// CellPort ////////" << endl
213  << "name = " << name << endl
214  << "layer = " << layer << endl
215  << "point = " << point << endl
216  << "type = " << portType << endl;
217  }
218 };
219 
221 struct CellInstance : public Item
222 {
223  std::string name;
224  std::string cellType;
226  int32_t orient;
227 
229  void reset()
230  {
231  name.clear();
232  cellType.clear();
233  position.reset();
234  orient = 0;
235  }
238  virtual void print(ostream& ss) const
239  {
240  ss << "//////// CellInstance ////////" << endl
241  << "name = " << name << endl
242  << "cellType = " << cellType << endl
243  << "position = " << position << endl
244  << "orient = " << orient << endl;
245  }
246 };
247 
249 struct PathObj : public Item
250 {
253  {
254  SEGMENT,
255  VIA,
256  STRING,
257  UNKNOWN
258  };
260  std::string name;
261  std::string layer;
262  double width;
265 
268  {
269  reset();
270  }
272  void reset()
273  {
274  pathObjType = UNKNOWN;
275  name.clear();
276  layer.clear();
277  width = 0;
278  startPoint.reset();
279  endPoint.reset();
280  }
281 };
282 
284 struct Path : public Item
285 {
286  std::string name;
287  std::vector<PathObj> vPathObj;
288 
291  {
292  reset();
293  }
295  void reset()
296  {
297  name.clear();
298  vPathObj.clear();
299  }
302  virtual void print(ostream& ss) const
303  {
304  ss << "//////// Path ////////" << endl
305  << "name = " << name << endl;
306  ss << "path objects\n";
307  for (uint32_t i = 0; i < vPathObj.size(); ++i)
308  ss << "name = " << vPathObj[i].name << " "
309  << "layer = " << vPathObj[i].layer << " "
310  << "width = " << vPathObj[i].width << " "
311  << "startPoint = " << vPathObj[i].startPoint << " "
312  << "endPoint = " << vPathObj[i].endPoint << " "
313  << endl;
314  }
315 };
316 
318 struct Text : public Item
319 {
322  {
323  NUMBER_OF_LAYERS,
324  WIRE_SPACINGS,
325  VIA_SPACINGS,
326  WIRE_WIDTHS,
327  VIA_WIDTHS,
328  VERTICAL_WIRE_COSTS,
329  HORIZONTAL_WIRE_COSTS,
330  VIA_COSTS,
331  STRING,
332  UNKNOWN
333  };
334 
336  std::string name;
337  std::string content;
338 
340  Text()
341  {
342  reset();
343  }
345  void reset()
346  {
347  textType = UNKNOWN;
348  content.clear();
349  }
352  virtual void print(ostream& ss) const
353  {
354  ss << "//////// Text ////////" << endl
355  << "name = " << name << endl;
356  ss << "content = " << content << endl;
357  }
358 };
359 
361 struct NetPort : public Item
362 {
363  std::string name;
364  std::string instName;
365 
368  {
369  reset();
370  }
372  void reset()
373  {
374  name.clear();
375  instName.clear();
376  }
377 };
379 struct Net : public Item
380 {
381  std::string name;
382  std::vector<NetPort> vNetPort;
383 
385  Net()
386  {
387  reset();
388  }
390  void reset()
391  {
392  name.clear();
393  vNetPort.clear();
394  }
397  virtual void print(ostream& ss) const
398  {
399  ss << "//////// Net ////////" << endl
400  << "name = " << name << endl;
401  for (uint32_t i = 0; i < vNetPort.size(); ++i)
402  ss << "(" << vNetPort[i].name << ", " << vNetPort[i].instName << ") ";
403  ss << endl;
404  }
405 };
407 struct Cell : public Item
408 {
409  std::string name;
410  std::vector<CellPort> vCellPort;
411  std::vector<Path> vPath;
412  std::vector<CellInstance> vCellInstance;
413  std::vector<Net> vNet;
414  std::vector<Text> vText;
415 
418  {
419  reset();
420  }
422  void reset()
423  {
424  name.clear();
425  vCellPort.clear();
426  vPath.clear();
427  vCellInstance.clear();
428  vNet.clear();
429  vText.clear();
430  }
433  virtual void print(ostream& ss) const
434  {
435  ss << "//////// Cell ////////" << endl
436  << "name = " << name << endl;
437  for (uint32_t i = 0; i < vCellPort.size(); ++i)
438  ss << vCellPort[i];
439  for (uint32_t i = 0; i < vPath.size(); ++i)
440  ss << vPath[i];
441  for (uint32_t i = 0; i < vCellInstance.size(); ++i)
442  ss << vCellInstance[i];
443  for (uint32_t i = 0; i < vNet.size(); ++i)
444  ss << vNet[i];
445  for (uint32_t i = 0; i < vText.size(); ++i)
446  ss << vText[i];
447  ss << endl;
448  }
449 };
450 
451 // forward declaration
457 {
458  public:
461  virtual void add_gdf_cell(Cell&) = 0;
462 };
463 
464 } // namespace GdfParser
465 
466 #endif
friend ostream & operator<<(ostream &ss, Item const &rhs)
Definition: GdfDataBase.h:122
IntegerArray(const allocator_type &alloc=allocator_type())
Definition: GdfDataBase.h:54
NumberArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
Definition: GdfDataBase.h:84
std::vector< CellInstance > vCellInstance
array of instances
Definition: GdfDataBase.h:412
bison does not support vector very well, so here create a dummy class for string array.
Definition: GdfDataBase.h:90
std::vector< Net > vNet
interconnections
Definition: GdfDataBase.h:413
Temporary data structures to hold parsed data. Base class for all temporary data structures.
Definition: GdfDataBase.h:114
Point startPoint
starting point
Definition: GdfDataBase.h:263
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:210
port of net
Definition: GdfDataBase.h:361
TextTypeEnum textType
test type
Definition: GdfDataBase.h:335
NetPort()
constructor
Definition: GdfDataBase.h:367
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:397
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:147
virtual void print(ostream &) const
print data members
Definition: GdfDataBase.h:117
std::string name
path name
Definition: GdfDataBase.h:286
std::string content
content of text
Definition: GdfDataBase.h:337
std::string cellType
standard cell type
Definition: GdfDataBase.h:224
std::vector< PathObj > vPathObj
objects on the path
Definition: GdfDataBase.h:287
Base class for def database. Only pure virtual functions are defined. User needs to inheritate this c...
Definition: GdfDataBase.h:456
routing path
Definition: GdfDataBase.h:284
std::string name
instance name
Definition: GdfDataBase.h:223
object on a path
Definition: GdfDataBase.h:249
std::string instName
corresponding instance name, empty for PI/PO
Definition: GdfDataBase.h:364
PortTypeEnum portType
port type
Definition: GdfDataBase.h:169
void reset()
reset all data members
Definition: GdfDataBase.h:229
namespace for GdfParser
Definition: GdfDataBase.h:24
bison does not support vector very well, so here create a dummy class for integer array...
Definition: GdfDataBase.h:42
void reset()
reset all data members
Definition: GdfDataBase.h:141
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:238
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:302
the whole routing layout is describe by a cell
Definition: GdfDataBase.h:407
string name
port name
Definition: GdfDataBase.h:166
Point endPoint
not always valid
Definition: GdfDataBase.h:264
std::vector< NetPort > vNetPort
array of net ports
Definition: GdfDataBase.h:382
double y
y coordinate
Definition: GdfDataBase.h:133
PathObj()
constructor
Definition: GdfDataBase.h:267
double width
width
Definition: GdfDataBase.h:262
double x
x coordinate
Definition: GdfDataBase.h:132
void reset()
reset all data members
Definition: GdfDataBase.h:390
IntegerArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
Definition: GdfDataBase.h:60
PathObjTypeEnum
type of path object
Definition: GdfDataBase.h:252
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:352
Net()
constructor
Definition: GdfDataBase.h:385
std::vector< Path > vPath
array of paths
Definition: GdfDataBase.h:411
net for interconnection
Definition: GdfDataBase.h:379
void reset()
reset all data members
Definition: GdfDataBase.h:372
std::vector< Text > vText
texts
Definition: GdfDataBase.h:414
Cell()
constructor
Definition: GdfDataBase.h:417
NumberArray(const allocator_type &alloc=allocator_type())
Definition: GdfDataBase.h:78
std::string name
more information for textType
Definition: GdfDataBase.h:336
void reset()
reset all data members
Definition: GdfDataBase.h:345
friend ostream & operator<<(ostream &ss, CellPort::PortTypeEnum portType)
print port type
Definition: GdfDataBase.h:188
Path()
constructor
Definition: GdfDataBase.h:290
PathObjTypeEnum pathObjType
path object type
Definition: GdfDataBase.h:259
int32_t orient
instance orientation
Definition: GdfDataBase.h:226
void reset()
reset all data memory
Definition: GdfDataBase.h:177
virtual void print(ostream &ss) const
print data members
Definition: GdfDataBase.h:433
class for point
Definition: GdfDataBase.h:130
std::string name
port name
Definition: GdfDataBase.h:363
void reset()
reset all data members
Definition: GdfDataBase.h:295
PortTypeEnum
type of port
Definition: GdfDataBase.h:157
Point position
instance position
Definition: GdfDataBase.h:225
std::string name
name
Definition: GdfDataBase.h:409
std::string name
only valid when pathObjType is STRING
Definition: GdfDataBase.h:260
StringArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
Definition: GdfDataBase.h:108
void reset()
reset all data members
Definition: GdfDataBase.h:422
virtual void add_gdf_cell(Cell &)=0
Add routing cell. It is safe to directly swap the contents in the cell for efficiency.
std::vector< CellPort > vCellPort
array of ports
Definition: GdfDataBase.h:410
Point point
port position
Definition: GdfDataBase.h:168
TextTypeEnum
type of text
Definition: GdfDataBase.h:321
Text()
constructor
Definition: GdfDataBase.h:340
string layer
port layer
Definition: GdfDataBase.h:167
bison does not support vector very well, so here create a dummy class for floating point number array...
Definition: GdfDataBase.h:66
std::string layer
layer name
Definition: GdfDataBase.h:261
Point()
constructor
Definition: GdfDataBase.h:136
StringArray(const allocator_type &alloc=allocator_type())
Definition: GdfDataBase.h:102
std::string name
net name
Definition: GdfDataBase.h:381
void reset()
reset all data members
Definition: GdfDataBase.h:272
CellPort()
constructor
Definition: GdfDataBase.h:172