Limbo 3.5.4
Loading...
Searching...
No Matches
DefDataBase.h
Go to the documentation of this file.
1
7
8#ifndef DEFPARSER_DATABASE_H
9#define DEFPARSER_DATABASE_H
10
11#include "limbo/thirdparty/lefdef/5.8/def/def/defiNet.hpp"
12#include "limbo/thirdparty/lefdef/5.8/def/def/defiRowTrack.hpp"
13#include "limbo/thirdparty/lefdef/5.8/def/def/defiVia.hpp"
14#include <array>
15#include <ostream>
16#include <string>
17#include <vector>
18#include <iostream>
19#include <fstream>
20#include <sstream>
21#include <cassert>
22#include <limbo/thirdparty/lefdef/5.8/def/def/defrReader.hpp>
23#include <limbo/thirdparty/lefdef/5.8/def/def/defiAlias.hpp>
24
26namespace DefParser {
27
29using std::cout;
30using std::endl;
31using std::cerr;
32using std::string;
33using std::vector;
34using std::pair;
35using std::make_pair;
36using std::ostringstream;
37typedef int int32_t;
38typedef unsigned int uint32_t;
39typedef long int64_t;
41
44struct Item
45{
47 virtual void print(ostringstream&) const {};
52 friend std::ostream& operator<<(std::ostream& os, Item const& rhs)
53 {
54 std::ostringstream ss;
55 rhs.print(ss);
56 os << ss.str();
57 return os;
58 }
59
63 friend ostringstream& operator<<(ostringstream& ss, Item const& rhs)
64 {
65 rhs.print(ss);
66 return ss;
67 }
68};
69
70struct Row : public Item
71{
72 string row_name;
73 string macro_name;
74 int32_t origin[2];
75 string orient;
76 int32_t repeat[2];
77 int32_t step[2];
79 void reset()
80 {
81 row_name = macro_name = orient = "";
82 origin[0] = origin[1] = -1;
83 repeat[0] = repeat[1] = -1;
84 step[0] = step[1] = -1;
85 }
86
88 virtual void print(ostringstream& ss) const
89 {
90 ss << "//////// Row ////////" << endl
91 << "row_name = " << row_name << endl
92 << "macro_name = " << macro_name << endl
93 << "origin = " << origin[0] << " " << origin[1] << endl
94 << "orient = " << orient << endl
95 << "repeat = " << repeat[0] << " " << repeat[1] << endl
96 << "step = " << step[0] << " " << step[1] << endl;
97 }
98};
99
100struct Component : public Item
101{
102 string comp_name;
103 string macro_name;
104 string status;
105 int32_t origin[2];
106 string orient;
108 void reset()
109 {
111 origin[0] = origin[1] = -1;
112 }
113
115 virtual void print(ostringstream& ss) const
116 {
117 ss << "//////// Component ////////" << endl
118 << "comp_name = " << comp_name << endl
119 << "macro_name = " << macro_name << endl
120 << "status = " << status << endl
121 << "origin = " << origin[0] << " " << origin[1] << endl
122 << "orient = " << orient << endl;
123 }
124};
125
126struct PinPort : public Item
127{
128 string status;
129 int32_t origin[2];
130 string orient;
134 void reset()
135 {
136 status = orient = "";
137 origin[0] = origin[1] = -1;
138 vLayer.clear();
139 vBbox.clear();
140 }
141
143 virtual void print(ostringstream& ss) const
144 {
145 ss << "//////// Port ////////" << endl
146 << "status = " << status << endl
147 << "origin = " << origin[0] << " " << origin[1] << endl
148 << "orient = " << orient << endl;
149 for (uint32_t i = 0; i < vLayer.size(); ++i)
150 ss << "layer " << vLayer[i] << " " << vBbox[i][0] << " " << vBbox[i][1] << " " << vBbox[i][2] << " " << vBbox[i][3] << endl;
151 }
152};
153
154struct Pin : public Item
155{
156 string pin_name;
157 string net_name;
158 string direct;
159 string status;
160 int32_t origin[2];
161 string orient;
164 string use;
167 void reset()
168 {
169 pin_name = net_name = direct = status = orient = "";
170 origin[0] = origin[1] = -1;
171 vLayer.clear();
172 vBbox.clear();
173 vPinPort.clear();
174 use = "";
175 }
176
178 virtual void print(ostringstream& ss) const
179 {
180 ss << "//////// Pin ////////" << endl
181 << "pin_name = " << pin_name << endl
182 << "net_name = " << net_name << endl
183 << "direct = " << direct << endl
184 << "status = " << status << endl
185 << "origin = " << origin[0] << " " << origin[1] << endl
186 << "orient = " << orient << endl;
187 for (uint32_t i = 0; i < vLayer.size(); ++i)
188 ss << "layer " << vLayer[i] << " " << vBbox[i][0] << " " << vBbox[i][1] << " " << vBbox[i][2] << " " << vBbox[i][3] << endl;
189 ss << "use = " << use << endl;
190 for (uint32_t i = 0; i < vPinPort.size(); ++i)
191 vPinPort[i].print(ss);
192 }
193};
194
195struct Net : public Item
196{
197 string net_name;
198 int32_t net_weight;
201 void reset()
202 {
203 net_name = "";
204 net_weight = 1;
205 vNetPin.clear();
206 }
207
209 virtual void print(ostringstream& ss) const
210 {
211 ss << "//////// Net ////////" << endl
212 << "net_name = " << net_name << endl
213 << "net_weight = " << net_weight << endl;
214 for (uint32_t i = 0; i < vNetPin.size(); ++i)
215 ss << "(" << vNetPin[i].first << ", " << vNetPin[i].second << ") ";
216 ss << endl;
217 }
218};
219
220struct Region : public Item
221{
222 string region_name;
223 string region_type;
224 std::vector<std::vector<int> > vRectangle;
225 std::vector<string> vPropertyName;
226 std::vector<string> vPropertyValue;
227 std::vector<char> vPropertyType;
228
230 void reset()
231 {
232 region_name = "";
233 region_type = "";
234 vRectangle.clear();
235 vPropertyName.clear();
236 vPropertyValue.clear();
237 vPropertyType.clear();
238 }
239
241 virtual void print(ostringstream& ss) const
242 {
243 ss << "//////// Region ////////" << endl
244 << "region_name = " << region_name << endl
245 << "region_type = " << region_type << endl;
246 for (uint32_t i = 0; i < vRectangle.size(); ++i)
247 ss << "(" << vRectangle[i][0] << ", " << vRectangle[i][1] << ", " << vRectangle[i][2] << ", " << vRectangle[i][3] << ") ";
248 ss << endl;
249 for (uint32_t i = 0; i < vPropertyName.size(); ++i)
250 ss << "Property " << vPropertyName[i] << " " << vPropertyType[i] << " " << vPropertyValue[i] << endl;
251 }
252};
253
254struct Group : public Item
255{
256 string group_name;
257 std::vector<string> vGroupMember;
258 string region_name;
259 int perim;
260 int maxx;
261 int maxy;
262 std::vector<std::vector<int> > vRectangle;
263 std::vector<string> vPropertyName;
264 std::vector<string> vPropertyValue;
265 std::vector<char> vPropertyType;
266
268 void reset()
269 {
270 group_name = "";
271 vGroupMember.clear();
272 region_name = "";
273 perim = 0;
274 maxx = 0;
275 maxy = 0;
276 vRectangle.clear();
277 vPropertyName.clear();
278 vPropertyValue.clear();
279 vPropertyType.clear();
280 }
281
283 virtual void print(ostringstream& ss) const
284 {
285 ss << "//////// Group ////////" << endl
286 << "group_name = " << group_name << endl
287 << "region_name = " << region_name << endl
288 << "perim = " << perim << endl
289 << "maxx = " << maxx << ", " << "maxy = " << maxy << endl;
290 ss << "vGroupMember[" << vGroupMember.size() << "] = ";
291 for (uint32_t i = 0; i < vGroupMember.size(); ++i)
292 ss << vGroupMember[i] << " ";
293 ss << endl;
294 for (uint32_t i = 0; i < vRectangle.size(); ++i)
295 ss << "(" << vRectangle[i][0] << ", " << vRectangle[i][1] << ", " << vRectangle[i][2] << ", " << vRectangle[i][3] << ") ";
296 ss << endl;
297 for (uint32_t i = 0; i < vPropertyName.size(); ++i)
298 ss << "Property " << vPropertyName[i] << " " << vPropertyType[i] << " " << vPropertyValue[i] << endl;
299 }
300};
301
302struct Track : public Item
303{
304 string track_name;
305 std::vector<string> vLayerNames;
306 int start;
307 int step;
308 int num;
309 int firstTrackMask;
310 int sameMask;
311
313 void reset()
314 {
315 track_name = "";
316 vLayerNames.clear();
317 start = 0;
318 step = 0;
319 num = 0;
320 firstTrackMask = 0;
321 sameMask = 0;
322 }
323
325 virtual void print(ostringstream& ss) const
326 {
327 ss << "//////// Track ////////" << endl
328 << "start = " << start << endl
329 << "step = " << step << endl
330 << "num = " << num << endl
331 << "Layer ";
332 for (auto &layername: vLayerNames) {
333 ss << layername << " ";
334 }
335 ss << endl;
336 }
337};
338
339struct GCellGrid : public Item
340{
342 int start;
343 int step;
344 int num;
345
347 void reset()
348 {
349 gcellgrid_name = "";
350 start = 0;
351 step = 0;
352 num = 0;
353 }
354
356 virtual void print(ostringstream& ss) const
357 {
358 ss << "//////// GCellGrid ////////" << endl
359 << "name = " << gcellgrid_name << endl
360 << "start = " << start << endl
361 << "step = " << step << endl
362 << "num = " << num << endl;
363 }
364};
365struct ViaType : public Item
366{
367 std::string viatype_name;
368 int x, y;
369
371 void reset()
372 {
373 viatype_name = "";
374 x = 0;
375 y = 0;
376 }
377
379 virtual void print(ostringstream& ss) const
380 {
381 ss << "//////// Via ////////" << endl
382 << "type = " << viatype_name << endl
383 << "coord = ()" << x << ", " << y << ")" << endl;
384 }
385};
386struct Via : public Item
387{
388 std::string viatype_name;
389 int x, y;
390
392 void reset()
393 {
394 viatype_name = "";
395 x = 0;
396 y = 0;
397 }
398
400 virtual void print(ostringstream& ss) const
401 {
402 ss << "//////// Via ////////" << endl
403 << "type = " << viatype_name << endl
404 << "coord = ()" << x << ", " << y << ")" << endl;
405 }
406};
407
408struct SNet : public Item
409{
410 std::string net_name;
411 std::string type;
413 vector<Via> vias;
414
415
417 void reset()
418 {
419 net_name = "";
420 shapes.clear();
421 vias.clear();
422 type = "";
423 }
424
426 virtual void print(ostringstream& ss) const
427 {
428 ss << "//////// Special Net ////////" << endl
429 << "name = " << net_name << endl
430 << "type = " << type << endl
431 << "vias = ";
432 for (auto const& via: vias) {
433 via.print(ss);
434 }
435 ss << endl << "shapes = ";
436 for (auto const& rect: shapes) {
437 ss << '(';
438 for (int i = 0; i < rect.size(); ++i) {
439 ss << rect[i] << ", ";
440 }
441 ss << ") ";
442 }
443 ss << endl;
444 }
445};
446// forward declaration
452{
453 public:
455 virtual void set_def_dividerchar(string const&) = 0;
457 virtual void set_def_busbitchars(string const&) = 0;
459 virtual void set_def_version(string const&) = 0;
461 virtual void set_def_design(string const&) = 0;
463 virtual void set_def_unit(int) = 0;
465 virtual void set_def_diearea(int, int, int, int) = 0;
467 virtual void set_def_diearea(int, const int*, const int*);
469 virtual void add_def_row(Row const&) = 0;
471 virtual void add_def_component(Component const&) = 0;
473 virtual void resize_def_component(int) = 0;
475 virtual void add_def_pin(Pin const&) = 0;
477 virtual void resize_def_pin(int) = 0;
479 virtual void add_def_net(Net const&) = 0;
481 virtual void resize_def_net(int) = 0;
483 virtual void add_def_track(defiTrack const&);
484 virtual void add_def_gcellgrid(GCellGrid const&);
485 virtual void add_def_snet(defiNet const&);
486 virtual void add_def_via(defiVia const&);
488 virtual void add_def_route_blockage(std::vector<std::vector<int> > const&, std::string const&);
489 // check these callbacks at runtime
491 virtual void resize_def_blockage(int);
493 virtual void add_def_placement_blockage(std::vector<std::vector<int> > const&);
495 virtual void resize_def_region(int);
497 virtual void add_def_region(Region const&);
499 virtual void resize_def_group(int);
501 virtual void add_def_group(Group const&);
503 virtual void end_def_design();
504
505 protected:
508 void def_user_cbk_reminder(const char* str) const;
509};
510
511} // namespace DefParser
512
513#endif
Base class for def database. Only pure virtual functions are defined. User needs to inheritate this...
virtual void add_def_route_blockage(std::vector< std::vector< int > > const &, std::string const &)
add placement blockages, array of boxes with xl, yl, xh, yh
virtual void set_def_dividerchar(string const &)=0
set divider characters
virtual void add_def_component(Component const &)=0
add component/cell
virtual void resize_def_component(int)=0
add component/cell
virtual void add_def_row(Row const &)=0
add row
virtual void set_def_version(string const &)=0
set DEF version
virtual void set_def_diearea(int, int, int, int)=0
set die area xl, yl, xh, yh
virtual void resize_def_net(int)=0
set number of nets
virtual void resize_def_blockage(int)
set number of blockages
virtual void add_def_pin(Pin const &)=0
add pin
virtual void resize_def_group(int)
set number of groups
virtual void end_def_design()
end of design
virtual void add_def_placement_blockage(std::vector< std::vector< int > > const &)
add placement blockages, array of boxes with xl, yl, xh, yh
virtual void set_def_design(string const &)=0
set design name
virtual void set_def_unit(int)=0
set DEF unit
virtual void resize_def_region(int)
set number of regions
virtual void set_def_busbitchars(string const &)=0
set BUS bit characters
virtual void add_def_region(Region const &)
add region
virtual void add_def_net(Net const &)=0
add net
virtual void add_def_group(Group const &)
add group
virtual void resize_def_pin(int)=0
set number of pins
void def_user_cbk_reminder(const char *str) const
remind users to define some optional callback functions at runtime
virtual void set_def_diearea(int, const int *, const int *)
set die area, optional parameters for non-rectangular shapes defined as points
namespace for DefParser
Definition DefDataBase.h:26
cell in placement
string status
placement status
void reset()
reset all data members
virtual void print(ostringstream &ss) const
print data members
string macro_name
macro name of component, standard cell type
int32_t origin[2]
x, y of origin
string comp_name
component name
routing tracks
string gcellgrid_name
group name
void reset()
reset all data members
virtual void print(ostringstream &ss) const
print data members
group to describe cells corresponding to region
std::vector< std::vector< int > > vRectangle
array of regions with (xl, yl, xh, yh)
void reset()
reset all data members
std::vector< string > vPropertyName
array of property names
string region_name
region name
std::vector< string > vPropertyValue
array of property values
string group_name
group name
int perim
MAXHALFPERIMETER, I do not know what they are used for.
std::vector< char > vPropertyType
array of property types
virtual void print(ostringstream &ss) const
print data members
std::vector< string > vGroupMember
group members
Temporary data structures to hold parsed data. Base class for all temporary data structures.
Definition DefDataBase.h:45
friend ostringstream & operator<<(ostringstream &ss, Item const &rhs)
Definition DefDataBase.h:63
friend std::ostream & operator<<(std::ostream &os, Item const &rhs)
Definition DefDataBase.h:52
virtual void print(ostringstream &) const
print data members
Definition DefDataBase.h:47
net to describe interconnection of netlist
void reset()
reset all data members
int32_t net_weight
net weight
string net_name
net name
vector< std::pair< string, string > > vNetPin
virtual void print(ostringstream &ss) const
print data members
pin of node/cell
void reset()
reset all data members
vector< vector< int32_t > > vBbox
bounding box on each layer
vector< string > vLayer
layers
vector< PinPort > vPinPort
string use
"use" token in DEF file
string pin_name
pin name
string net_name
net name
string orient
orientation
string direct
direction
virtual void print(ostringstream &ss) const
print data members
int32_t origin[2]
offset to node origin
string status
placement status
vector< string > vLayer
layers
virtual void print(ostringstream &ss) const
print data members
vector< vector< int32_t > > vBbox
int32_t origin[2]
offset to node origin
void reset()
reset all data members
string orient
orientation
string status
placement status
region to describe regions like fence
void reset()
reset all data members
string region_type
region type
std::vector< string > vPropertyName
array of property names
std::vector< std::vector< int > > vRectangle
array of rectangles with (xl, yl, xh, yh)
std::vector< char > vPropertyType
array of property types
virtual void print(ostringstream &ss) const
print data members
std::vector< string > vPropertyValue
array of property values
string region_name
region name
placement row
Definition DefDataBase.h:71
int32_t repeat[2]
do x by y
Definition DefDataBase.h:76
int32_t step[2]
Definition DefDataBase.h:77
string macro_name
macro name of row
Definition DefDataBase.h:73
int32_t origin[2]
x, y of origin
Definition DefDataBase.h:74
string orient
orientation
Definition DefDataBase.h:75
void reset()
reset all data members
Definition DefDataBase.h:79
virtual void print(ostringstream &ss) const
print data members
Definition DefDataBase.h:88
string row_name
row name
Definition DefDataBase.h:72
routing tracks
void reset()
reset all data members
std::string net_name
group name
vector< vector< int > > shapes
shapes in snet, only support rectangles yet
virtual void print(ostringstream &ss) const
print data members
routing tracks
string track_name
group name
virtual void print(ostringstream &ss) const
print data members
void reset()
reset all data members
std::vector< string > vLayerNames
group members
void reset()
reset all data members
virtual void print(ostringstream &ss) const
print data members
std::string viatype_name
group name
void reset()
reset all data members
std::string viatype_name
group name
virtual void print(ostringstream &ss) const
print data members