Limbo 3.5.4
Loading...
Searching...
No Matches
GdfDataBase.h
Go to the documentation of this file.
1
12
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
24namespace GdfParser {
25
27using std::cout;
28using std::endl;
29using std::cerr;
30using std::string;
31using std::vector;
32using std::pair;
33using std::make_pair;
34using std::ostream;
35typedef int int32_t;
36typedef unsigned int uint32_t;
37typedef long int64_t;
39
42class 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) {}
56
60 IntegerArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
61 : base_type(n, val, alloc) {}
62};
63
66class 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) {}
80
84 NumberArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
85 : base_type(n, val, alloc) {}
86};
87
90class 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) {}
104
108 StringArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
109 : base_type(n, val, alloc) {}
110};
111
114struct 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
130struct Point : public Item
131{
132 double x;
133 double y;
134
137 {
138 reset();
139 }
140
141 void reset()
142 {
143 x = y = 0.0;
144 }
145
147 virtual void print(ostream& ss) const
148 {
149 ss << "(" << x << "," << y << ")";
150 }
151};
152
154struct 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 }
176
177 void reset()
178 {
179 name.clear();
180 layer.clear();
181 point.reset();
182 portType = UNKNOWN;
183 }
184
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 }
208
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
221struct 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 }
236
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
249struct 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 }
271
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
284struct Path : public Item
285{
286 std::string name;
287 std::vector<PathObj> vPathObj;
288
291 {
292 reset();
293 }
294
295 void reset()
296 {
297 name.clear();
298 vPathObj.clear();
299 }
300
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
318struct 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
341 {
342 reset();
343 }
344
345 void reset()
346 {
347 textType = UNKNOWN;
348 content.clear();
349 }
350
352 virtual void print(ostream& ss) const
353 {
354 ss << "//////// Text ////////" << endl
355 << "name = " << name << endl;
356 ss << "content = " << content << endl;
357 }
358};
359
361struct NetPort : public Item
362{
363 std::string name;
364 std::string instName;
365
368 {
369 reset();
370 }
371
372 void reset()
373 {
374 name.clear();
375 instName.clear();
376 }
377};
378
379struct Net : public Item
380{
381 std::string name;
382 std::vector<NetPort> vNetPort;
383
386 {
387 reset();
388 }
389
390 void reset()
391 {
392 name.clear();
393 vNetPort.clear();
394 }
395
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};
406
407struct 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 }
421
422 void reset()
423 {
424 name.clear();
425 vCellPort.clear();
426 vPath.clear();
427 vCellInstance.clear();
428 vNet.clear();
429 vText.clear();
430 }
431
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
Base class for def database. Only pure virtual functions are defined. User needs to inheritate this...
virtual void add_gdf_cell(Cell &)=0
Add routing cell. It is safe to directly swap the contents in the cell for efficiency.
IntegerArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
Definition GdfDataBase.h:60
IntegerArray(const allocator_type &alloc=allocator_type())
Definition GdfDataBase.h:54
NumberArray(const allocator_type &alloc=allocator_type())
Definition GdfDataBase.h:78
NumberArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
Definition GdfDataBase.h:84
StringArray(const allocator_type &alloc=allocator_type())
StringArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
namespace for GdfParser
Definition GdfDataBase.h:24
the whole routing layout is describe by a cell
std::vector< Path > vPath
array of paths
Cell()
constructor
std::vector< Net > vNet
interconnections
std::vector< CellInstance > vCellInstance
array of instances
void reset()
reset all data members
std::string name
name
std::vector< Text > vText
texts
std::vector< CellPort > vCellPort
array of ports
virtual void print(ostream &ss) const
print data members
int32_t orient
instance orientation
std::string name
instance name
void reset()
reset all data members
std::string cellType
standard cell type
virtual void print(ostream &ss) const
print data members
Point position
instance position
PortTypeEnum
type of port
CellPort()
constructor
virtual void print(ostream &ss) const
print data members
Point point
port position
string name
port name
PortTypeEnum portType
port type
friend ostream & operator<<(ostream &ss, CellPort::PortTypeEnum portType)
print port type
string layer
port layer
void reset()
reset all data memory
Temporary data structures to hold parsed data. Base class for all temporary data structures.
virtual void print(ostream &) const
print data members
friend ostream & operator<<(ostream &ss, Item const &rhs)
void reset()
reset all data members
virtual void print(ostream &ss) const
print data members
std::vector< NetPort > vNetPort
array of net ports
Net()
constructor
std::string name
net name
void reset()
reset all data members
NetPort()
constructor
std::string name
port name
std::string instName
corresponding instance name, empty for PI/PO
void reset()
reset all data members
Path()
constructor
std::string name
path name
virtual void print(ostream &ss) const
print data members
std::vector< PathObj > vPathObj
objects on the path
PathObj()
constructor
Point startPoint
starting point
PathObjTypeEnum
type of path object
PathObjTypeEnum pathObjType
path object type
void reset()
reset all data members
std::string layer
layer name
double width
width
std::string name
only valid when pathObjType is STRING
Point endPoint
not always valid
class for point
double x
x coordinate
Point()
constructor
void reset()
reset all data members
virtual void print(ostream &ss) const
print data members
double y
y coordinate
std::string name
more information for textType
std::string content
content of text
virtual void print(ostream &ss) const
print data members
Text()
constructor
TextTypeEnum textType
test type
TextTypeEnum
type of text
void reset()
reset all data members