Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BookshelfDataBase.h
Go to the documentation of this file.
1 
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 
19 namespace BookshelfParser {
20 
22 using std::cout;
23 using std::endl;
24 using std::cerr;
25 using std::string;
26 using std::vector;
27 using std::pair;
28 using std::make_pair;
29 using std::ostream;
30 typedef int int32_t;
31 typedef unsigned int uint32_t;
32 typedef long int64_t;
34 
37 class IntegerArray : public vector<int>
38 {
39  public:
41  typedef vector<int> base_type;
42  using base_type::size_type;
43  using base_type::value_type;
44  using base_type::allocator_type;
46 
49  IntegerArray(const allocator_type& alloc = allocator_type())
50  : base_type(alloc) {}
55  IntegerArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
56  : base_type(n, val, alloc) {}
57 };
58 
61 class StringArray : public vector<string>
62 {
63  public:
65  typedef vector<string> base_type;
66  using base_type::size_type;
67  using base_type::value_type;
68  using base_type::allocator_type;
70 
73  StringArray(const allocator_type& alloc = allocator_type())
74  : base_type(alloc) {}
79  StringArray(size_type n, const value_type& val, const allocator_type& alloc = allocator_type())
80  : base_type(n, val, alloc) {}
81 };
82 
85 struct Item
86 {
88  virtual void print(ostream&) const {};
93  friend ostream& operator<<(ostream& ss, Item const& rhs)
94  {
95  rhs.print(ss);
96  return ss;
97  }
98 };
100 struct Row : public Item
101 {
102  int32_t origin[2];
103  string orient;
104  int32_t height;
105  int32_t site_num;
106  int32_t site_width;
107  int32_t site_spacing;
108  int32_t site_orient;
109  int32_t site_symmetry;
110  Row()
112  {
113  reset();
114  }
116  void reset()
117  {
118  orient = "";
119  origin[0] = origin[1] = -1;
120  height = 0;
121  site_num = 0;
122  site_width = site_spacing = site_orient = site_symmetry = 0;
123  }
126  virtual void print(ostream& ss) const
127  {
128  ss << "//////// Row ////////" << endl
129  << "origin = " << origin[0] << " " << origin[1] << endl
130  << "orient = " << orient << endl
131  << "site width = " << site_width << endl
132  << "site_spacing = " << site_spacing << endl
133  << "site_orient = " << site_orient << endl
134  << "site_symmetry = " << site_symmetry << endl;
135  }
136 };
138 struct NetPin : public Item
139 {
140  string node_name;
141  string pin_name;
142  char direct;
143  double offset[2];
144  double size[2];
145 
148  {
149  node_name = "";
150  pin_name = "";
151  direct = '\0';
152  offset[0] = 0;
153  offset[1] = 0;
154  size[0] = 0;
155  size[1] = 0;
156  }
163  NetPin(string& nn, char d, double x, double y, double w, double h, string& pn)
164  {
165  node_name.swap(nn);
166  direct = d;
167  offset[0] = x;
168  offset[1] = y;
169  size[0] = w;
170  size[1] = h;
171  pin_name.swap(pn);
172  }
178  NetPin(string& nn, char d, double x, double y, double w, double h)
179  {
180  node_name.swap(nn);
181  direct = d;
182  offset[0] = x;
183  offset[1] = y;
184  size[0] = w;
185  size[1] = h;
186  pin_name.clear();
187  }
189  void reset()
190  {
191  node_name = "";
192  pin_name = "";
193  direct = 'I';
194  offset[0] = offset[1] = 0;
195  size[0] = size[1] = 0;
196  }
197 };
199 struct Net : public Item
200 {
201  string net_name;
202  vector<NetPin> vNetPin;
203  void reset()
205  {
206  net_name = "";
207  vNetPin.clear();
208  }
211  virtual void print(ostream& ss) const
212  {
213  ss << "//////// Net ////////" << endl
214  << "net_name = " << net_name << endl;
215  for (uint32_t i = 0; i < vNetPin.size(); ++i)
216  ss << "(" << vNetPin[i].node_name << ", " << vNetPin[i].pin_name << ") "
217  << vNetPin[i].direct << " @(" << vNetPin[i].offset[0] << ", " << vNetPin[i].offset[1] << ")";
218  ss << endl;
219  }
220 };
221 // forward declaration
226 {
227  public:
229  virtual void resize_bookshelf_node_terminals(int, int) = 0;
231  virtual void resize_bookshelf_net(int) = 0;
233  virtual void resize_bookshelf_pin(int) = 0;
235  virtual void resize_bookshelf_row(int) = 0;
237  virtual void add_bookshelf_terminal(string&, int, int) = 0;
239  virtual void add_bookshelf_node(string&, int, int) = 0;
241  virtual void add_bookshelf_net(Net const&) = 0;
243  virtual void add_bookshelf_row(Row const&) = 0;
245  virtual void set_bookshelf_node_position(string const&, double, double, string const&, string const&, bool) = 0;
247  virtual void set_bookshelf_design(string&) = 0;
249  virtual void bookshelf_end() = 0;
250 };
251 
252 } // namespace BookshelfParser
253 
254 #endif
StringArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
virtual void print(ostream &ss) const
virtual void resize_bookshelf_row(int)=0
set number of rows
StringArray(const allocator_type &alloc=allocator_type())
IntegerArray(const allocator_type &alloc=allocator_type())
vector< NetPin > vNetPin
virtual void add_bookshelf_node(string &, int, int)=0
add node
double offset[2]
offset (x, y) to node origin
int32_t height
row height
Base class for bookshelf database. Only pure virtual functions are defined. User needs to inheritate ...
namespace for BookshelfParser
net to describe interconnection of netlist
friend ostream & operator<<(ostream &ss, Item const &rhs)
int32_t origin[2]
x, y
virtual void set_bookshelf_node_position(string const &, double, double, string const &, string const &, bool)=0
set node position
NetPin(string &nn, char d, double x, double y, double w, double h)
string net_name
net name
IntegerArray(size_type n, const value_type &val, const allocator_type &alloc=allocator_type())
int32_t site_orient
orientation of a site
virtual void print(ostream &) const
print data members
virtual void add_bookshelf_terminal(string &, int, int)=0
add terminal
void reset()
reset all data members
virtual void set_bookshelf_design(string &)=0
set design name
string node_name
node name
virtual void print(ostream &ss) const
bison does not support vector very well, so here create a dummy class for string array.
double size[2]
sizes (x, y) of pin
Temporary data structures to hold parsed data. Base class for all temporary data structures.
int32_t site_spacing
spacing of a site
bison does not support vector very well, so here create a dummy class for integer array...
virtual void add_bookshelf_net(Net const &)=0
add net
int32_t site_width
width of a site
virtual void resize_bookshelf_pin(int)=0
set number of pins
string orient
orientation
void reset()
reset all data members
int32_t site_num
number of sites
virtual void add_bookshelf_row(Row const &)=0
add row
NetPin(string &nn, char d, double x, double y, double w, double h, string &pn)
virtual void resize_bookshelf_net(int)=0
set number of nets
virtual void resize_bookshelf_node_terminals(int, int)=0
set number of terminals
void reset()
reset all data members
virtual void bookshelf_end()=0
a callback when a bookshelf file reaches to the end
describe a pin of a net