Limbo 3.5.4
Loading...
Searching...
No Matches
BookshelfDataBase.h
Go to the documentation of this file.
1
7
8#ifndef BOOKSHELFPARSER_DATABASE_H
9#define BOOKSHELFPARSER_DATABASE_H
10
11#include <string>
12#include <vector>
13#include <iostream>
14#include <fstream>
15#include <sstream>
16#include <cassert>
17#include <limits>
18
20namespace BookshelfParser {
21
23using std::cout;
24using std::endl;
25using std::cerr;
26using std::string;
27using std::vector;
28using std::pair;
29using std::make_pair;
30using std::ostream;
31typedef int int32_t;
32typedef unsigned int uint32_t;
33typedef long int64_t;
35
38class IntegerArray : public vector<int>
39{
40 public:
42 typedef vector<int> base_type;
43 using base_type::size_type;
44 using base_type::value_type;
45 using base_type::allocator_type;
47
50 IntegerArray(const allocator_type& alloc = allocator_type())
51 : base_type(alloc) {}
52
56 IntegerArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
57 : base_type(n, val, alloc) {}
58};
59
62class StringArray : public vector<string>
63{
64 public:
66 typedef vector<string> base_type;
67 using base_type::size_type;
68 using base_type::value_type;
69 using base_type::allocator_type;
71
74 StringArray(const allocator_type& alloc = allocator_type())
75 : base_type(alloc) {}
76
80 StringArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
81 : base_type(n, val, alloc) {}
82};
83
86struct Item
87{
89 virtual void print(ostream&) const {};
94 friend ostream& operator<<(ostream& ss, Item const& rhs)
95 {
96 rhs.print(ss);
97 return ss;
98 }
99};
100
101struct Row : public Item
102{
103 int32_t origin[2];
104 string orient;
105 int32_t height;
106 int32_t site_num;
107 int32_t site_width;
108 int32_t site_spacing;
109 int32_t site_orient;
115 {
116 reset();
117 }
118
119 void reset()
120 {
121 orient = "";
122 origin[0] = origin[1] = -1;
123 height = 0;
124 site_num = 0;
126 site_orient_str = "";
128 }
129
131 virtual void print(ostream& ss) const
132 {
133 ss << "//////// Row ////////" << endl
134 << "origin = " << origin[0] << " " << origin[1] << endl
135 << "orient = " << orient << endl
136 << "site width = " << site_width << endl
137 << "site_spacing = " << site_spacing << endl
138 << "site_orient = " << site_orient << endl
139 << "site_orient_str = " << site_orient_str << endl
140 << "site_symmetry = " << site_symmetry << endl
141 << "site_symmetry_str = " << site_symmetry_str << endl;
142 }
143};
144
145struct NetPin : public Item
146{
147 string node_name;
148 string pin_name;
149 char direct;
150 double offset[2];
151 double size[2];
152
155 {
156 node_name = "";
157 pin_name = "";
158 direct = '\0';
159 offset[0] = 0;
160 offset[1] = 0;
161 size[0] = 0;
162 size[1] = 0;
163 }
164
170 NetPin(string& nn, char d, double x, double y, double w, double h, string& pn)
171 {
172 node_name.swap(nn);
173 direct = d;
174 offset[0] = x;
175 offset[1] = y;
176 size[0] = w;
177 size[1] = h;
178 pin_name.swap(pn);
179 }
180
185 NetPin(string& nn, char d, double x, double y, double w, double h)
186 {
187 node_name.swap(nn);
188 direct = d;
189 offset[0] = x;
190 offset[1] = y;
191 size[0] = w;
192 size[1] = h;
193 pin_name.clear();
194 }
195
196 void reset()
197 {
198 node_name = "";
199 pin_name = "";
200 direct = 'I';
201 offset[0] = offset[1] = 0;
202 size[0] = size[1] = 0;
203 }
204};
205
206struct Net : public Item
207{
208 string net_name;
211 void reset()
212 {
213 net_name = "";
214 vNetPin.clear();
215 }
216
218 virtual void print(ostream& ss) const
219 {
220 ss << "//////// Net ////////" << endl
221 << "net_name = " << net_name << endl;
222 for (uint32_t i = 0; i < vNetPin.size(); ++i)
223 ss << "(" << vNetPin[i].node_name << ", " << vNetPin[i].pin_name << ") "
224 << vNetPin[i].direct << " @(" << vNetPin[i].offset[0] << ", " << vNetPin[i].offset[1] << ")";
225 ss << endl;
226 }
227};
228
230struct ShapeBox : public Item
231{
232 string name;
233 double origin[2];
234 double size[2];
235
242 ShapeBox(string& n, double x, double y, double w, double h)
243 {
244 name.swap(n);
245 origin[0] = x;
246 origin[1] = y;
247 size[0] = w;
248 size[1] = h;
249 }
250
251 void reset()
252 {
253 name = "";
254 origin[0] = origin[1] = 0;
255 size[0] = size[1] = 0;
256 }
257};
258
260struct NodeShape : public Item
261{
262 string node_name;
263 vector<ShapeBox> vShapeBox;
264
266 void reset()
267 {
268 node_name = "";
269 vShapeBox.clear();
270 }
271
273 virtual void print(ostream& ss) const
274 {
275 ss << "//////// NodeShape ////////" << endl
276 << "node_name = " << node_name << endl;
277 for (uint32_t i = 0; i < vShapeBox.size(); ++i)
278 ss << vShapeBox[i].name
279 << " @(" << vShapeBox[i].origin[0] << ", " << vShapeBox[i].origin[1] << ") "
280 << " w/h (" << vShapeBox[i].size[0] << ", " << vShapeBox[i].size[1] << ")"
281 << endl;
282 ss << endl;
283 }
284};
285
287struct IOPinLayer : public Item
288{
289 string pin_name;
290 int layer;
291
293 IOPinLayer(string& name, int l)
294 {
295 pin_name.swap(name);
296 layer = l;
297 }
298
299 void reset()
300 {
301 pin_name = "";
302 layer = std::numeric_limits<int>::max();
303 }
304};
305
307struct BlockageLayer : public Item
308{
309 string node_name;
311
313 void reset()
314 {
315 node_name = "";
316 vLayer.clear();
317 }
318};
319
323struct RouteInfo : public Item
324{
325 int numGrids[2];
332 double gridOrigin[2];
333 double tileSize[2];
335
337 void reset()
338 {
339 numGrids[0] = numGrids[1] = 0;
340 numLayers = 0;
341 vVerticalCapacity.clear();
342 vHorizontalCapacity.clear();
343 vMinWireWidth.clear();
344 vMinWireSpacing.clear();
345 vViaSpacing.clear();
346 gridOrigin[0] = gridOrigin[1] = 0;
347 tileSize[0] = tileSize[1] = 0;
348 blockagePorosity = 0;
349 }
350
352 virtual void print(ostream& ss) const
353 {
354 ss << "//////// RouteInfo ////////" << endl;
355 ss << "grids = " << numGrids[0] << ", " << numGrids[1] << endl;
356 ss << "numLayers = " << numLayers << endl;
357 ss << "vVerticalCapacity = ";
358 for (unsigned int i = 0; i < vVerticalCapacity.size(); ++i)
359 ss << vVerticalCapacity[i] << " ";
360 ss << endl;
361 ss << "vHorizontalCapacity = ";
362 for (unsigned int i = 0; i < vHorizontalCapacity.size(); ++i)
363 ss << vHorizontalCapacity[i] << " ";
364 ss << endl;
365 ss << "vMinWireWidth = ";
366 for (unsigned int i = 0; i < vMinWireWidth.size(); ++i)
367 ss << vMinWireWidth[i] << " ";
368 ss << endl;
369 ss << "vMinWireSpacing = ";
370 for (unsigned int i = 0; i < vMinWireSpacing.size(); ++i)
371 ss << vMinWireSpacing[i] << " ";
372 ss << endl;
373 ss << "vViaSpacing = ";
374 for (unsigned int i = 0; i < vViaSpacing.size(); ++i)
375 ss << vViaSpacing[i] << " ";
376 ss << endl;
377 ss << "gridOrigin = " << gridOrigin[0] << ", " << gridOrigin[1] << endl;
378 ss << "tileSize = " << tileSize[0] << ", " << tileSize[1] << endl;
379 ss << "blockagePorosity = " << blockagePorosity << endl;
380 }
381};
382
383// forward declaration
388{
389 public:
391 virtual void resize_bookshelf_node_terminals(int, int) = 0;
393 virtual void resize_bookshelf_net(int) = 0;
395 virtual void resize_bookshelf_pin(int) = 0;
397 virtual void resize_bookshelf_row(int) = 0;
399 virtual void resize_bookshelf_shapes(int);
405 virtual void add_bookshelf_terminal(string&, int, int) = 0;
407 virtual void add_bookshelf_terminal_NI(string&, int, int);
409 virtual void add_bookshelf_node(string&, int, int, bool) = 0;
411 virtual void add_bookshelf_net(Net const&) = 0;
413 virtual void add_bookshelf_row(Row const&) = 0;
415 virtual void set_bookshelf_node_position(string const&, double, double, string const&, string const&, bool) = 0;
417 virtual void set_bookshelf_net_weight(string const& name, double w);
419 virtual void set_bookshelf_shape(NodeShape const&);
423 virtual void add_bookshelf_niterminal_layer(string const&, string const&);
425 virtual void add_bookshelf_blockage_layers(string const&, vector<string> const&);
427 virtual void set_bookshelf_design(string&) = 0;
429 virtual void bookshelf_end() = 0;
430 private:
433 void bookshelf_user_cbk_reminder(const char* str) const;
434};
435
436} // namespace BookshelfParser
437
438#endif
Base class for bookshelf database. Only pure virtual functions are defined. User needs to inheritat...
virtual void set_bookshelf_node_position(string const &, double, double, string const &, string const &, bool)=0
set node position
virtual void add_bookshelf_terminal(string &, int, int)=0
add terminal
virtual void resize_bookshelf_shapes(int)
set number of shapes
virtual void resize_bookshelf_blockage_layers(int)
set number of blockage nodes with layers
virtual void resize_bookshelf_pin(int)=0
set number of pins
virtual void add_bookshelf_terminal_NI(string &, int, int)
add terminal_NI
virtual void add_bookshelf_node(string &, int, int, bool)=0
add node
virtual void add_bookshelf_row(Row const &)=0
add row
virtual void add_bookshelf_net(Net const &)=0
add net
virtual void set_bookshelf_net_weight(string const &name, double w)
set net weight
virtual void set_bookshelf_route_info(RouteInfo const &)
set routing information
virtual void add_bookshelf_blockage_layers(string const &, vector< string > const &)
set blockages with layers
virtual void add_bookshelf_niterminal_layer(string const &, string const &)
set NI terminal with layers
virtual void resize_bookshelf_row(int)=0
set number of rows
virtual void set_bookshelf_shape(NodeShape const &)
set node shapes
virtual void resize_bookshelf_node_terminals(int, int)=0
set number of terminals
virtual void resize_bookshelf_net(int)=0
set number of nets
virtual void set_bookshelf_design(string &)=0
set design name
virtual void resize_bookshelf_niterminal_layers(int)
set number of NI terminals with layers
virtual void bookshelf_end()=0
a callback when a bookshelf file reaches to the end
IntegerArray(const allocator_type &alloc=allocator_type())
IntegerArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
StringArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
StringArray(const allocator_type &alloc=allocator_type())
namespace for BookshelfParser
describe blockage node name, blocked layer list
void reset()
reset all data members
vector< int > vLayer
layer list
void reset()
reset all data members
IOPinLayer(string &name, int l)
constructor
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)
net to describe interconnection of netlist
vector< NetPin > vNetPin
void reset()
reset all data members
virtual void print(ostream &ss) const
NetPin(string &nn, char d, double x, double y, double w, double h, string &pn)
void reset()
reset all data members
double offset[2]
offset (x, y) to node origin
double size[2]
sizes (x, y) of pin
NetPin(string &nn, char d, double x, double y, double w, double h)
node shape to describe the shapes of node
void reset()
reset all data members
virtual void print(ostream &ss) const
information for routing to describe .route refer to DAC 2012 contest http://archive....
double gridOrigin[2]
Absolute coordinates of the origin of the grid (grid_lowerleft_X grid_lowerleft_Y).
vector< int > vMinWireSpacing
min wire spacing for each layer
int numGrids[2]
global routing grids in X and Y
double tileSize[2]
tile_width, tile_height
virtual void print(ostream &ss) const
vector< int > vViaSpacing
via spacing per layer
void reset()
reset all data members
int blockagePorosity
Porosity for routing blockages (Zero implies the blockage completely blocks overlapping routing track...
int numLayers
number of layers
vector< int > vVerticalCapacity
vertical capacity at each layer
vector< int > vMinWireWidth
min wire width for each layer
vector< int > vHorizontalCapacity
horizontal capacity at each layer
int32_t height
row height
virtual void print(ostream &ss) const
int32_t site_num
number of sites
int32_t site_spacing
spacing of a site
string site_orient_str
orientation of a site in string
void reset()
reset all data members
int32_t site_width
width of a site
int32_t site_orient
orientation of a site, one of these two will be valid
string orient
orientation
int32_t site_symmetry
symmetry of a site
void reset()
reset all data members
ShapeBox(string &n, double x, double y, double w, double h)
constructor
double origin[2]
lower left corner of the box
double size[2]
width and height