Limbo 3.5.4
Loading...
Searching...
No Matches
Limbo.Parsers.DefParser

Introduction

DEF together with LEF is a common file format in VLSI physical design. Generally LEF/DEF formats are quit complicated due to the complex cases in chip design. This parser is adjusted from the open source LEF parser released by Cadence Design Systems with C++ wrappers. The original parsers lie in the Thirdparty package. Users have to follow the LICENSE agreement from the original release. The parser does not contain full API of the original LEF/DEF parsers, but it is tested under various academic benchmarks for VLSI placement.

Examples

Flex/Bison Parser

See documented version: test/parsers/def/test_adapt.cpp

#include <iostream>
#include <fstream>
using std::cout;
using std::cin;
using std::endl;
using std::string;
{
public:
{
cout << "DefDataBase::" << __func__ << endl;
}
virtual void set_def_dividerchar(string const& token)
{
cout << __func__ << " => " << token << endl;
}
virtual void set_def_busbitchars(string const& token)
{
cout << __func__ << " => " << token << endl;
}
virtual void set_def_version(string const& token)
{
cout << __func__ << " => " << token << endl;
}
virtual void set_def_design(string const& token)
{
cout << __func__ << " => " << token << endl;
}
virtual void set_def_unit(int token)
{
cout << __func__ << " => " << token << endl;
}
virtual void set_def_diearea(int t1, int t2, int t3, int t4)
{
cout << __func__ << " => " << t1 << "," << t2 << "," << t3 << "," << t4 << endl;
}
virtual void add_def_row(DefParser::Row const&)
{
cout << __func__ << endl;
}
virtual void add_def_component(DefParser::Component const& c)
{
cout << __func__ << ": " << c.comp_name << ": status = " << c.status << endl;
}
virtual void resize_def_component(int token)
{
cout << __func__ << " => " << token << endl;
}
virtual void add_def_pin(DefParser::Pin const& p)
{
cout << __func__ << ": " << p.pin_name << endl;
}
virtual void resize_def_pin(int token)
{
cout << __func__ << " => " << token << endl;
}
virtual void add_def_net(DefParser::Net const& n)
{
cout << __func__ << ": " << n.net_name << ": weight " << n.net_weight << endl;
}
virtual void resize_def_net(int token)
{
cout << __func__ << " => " << token << endl;
}
virtual void resize_def_blockage(int n)
{
cout << __func__ << " => " << n << endl;
}
virtual void add_def_placement_blockage(std::vector<std::vector<int> > const& vBbox)
{
cout << __func__ << " => ";
for (std::vector<std::vector<int> >::const_iterator it = vBbox.begin(); it != vBbox.end(); ++it)
cout << "(" << (*it)[0] << ", " << (*it)[1] << ", " << (*it)[2] << ", " << (*it)[3] << ") ";
cout << endl;
}
virtual void resize_def_region(int n)
{
cout << __func__ << " => " << n << endl;
}
virtual void add_def_region(DefParser::Region const& region)
{
cout << __func__ << "\n" << region;
}
virtual void resize_def_group(int n)
{
cout << __func__ << " => " << n << endl;
}
virtual void add_def_group(DefParser::Group const& group)
{
cout << __func__ << "\n" << group;
}
virtual void end_def_design()
{
cout << __func__ << endl;
}
};
void test1(string const& filename)
{
cout << "////////////// test1 ////////////////" << endl;
DefParser::read(db, filename);
}
void test2(string const& filename)
{
cout << "////////////// test2 ////////////////" << endl;
DefParser::Driver driver (db);
//driver.trace_scanning = true;
//driver.trace_parsing = true;
driver.parse_file(filename);
}
int main(int argc, char** argv)
{
if (argc > 1)
{
test1(argv[1]);
test2(argv[1]);
}
else
cout << "at least 1 argument is required" << endl;
return 0;
}
Driver for Def parser.
Custom class that inheritates DefParser::DefDataBase with all the required callbacks defined.
virtual void add_def_region(DefParser::Region const &region)
add region
virtual void resize_def_blockage(int n)
set number of blockages
virtual void add_def_pin(DefParser::Pin const &p)
add pin
virtual void resize_def_net(int token)
set number of nets
virtual void set_def_unit(int token)
virtual void resize_def_pin(int token)
set number of pins
virtual void add_def_net(DefParser::Net const &n)
add net
virtual void set_def_dividerchar(string const &token)
virtual void end_def_design()
end of design
virtual void resize_def_region(int n)
set number of regions
virtual void set_def_version(string const &token)
virtual void resize_def_component(int token)
virtual void add_def_placement_blockage(std::vector< std::vector< int > > const &vBbox)
add placement blockages
DefDataBase()
constructor
virtual void set_def_design(string const &token)
virtual void add_def_row(DefParser::Row const &)
add row
virtual void resize_def_group(int n)
set number of groups
virtual void add_def_group(DefParser::Group const &group)
add group
virtual void add_def_component(DefParser::Component const &c)
add component
virtual void set_def_busbitchars(string const &token)
virtual void set_def_diearea(int t1, int t2, int t3, int t4)
Base class for def database. Only pure virtual functions are defined. User needs to inheritate this...
bool read(DefDataBase &db, const string &defFile)
API for DefParser. Read DEF file and initialize database by calling user-defined callback functions.
string status
placement status
string comp_name
component name
int32_t net_weight
net weight
string net_name
net name
string pin_name
pin name
int main()
void test2(string const &filename)
test std::list
void test1()
test function API

Compiling and running commands (assuming LIMBO_DIR is exported as the environment variable to the path where limbo library is installed)

g++ -o test_adapt test_adapt.cpp -I $LIMBO_DIR/include -L $LIMBO_DIR/lib -ldefparseradapt
./test_adapt benchmarks/simple.def

All Examples

References

LICENSE

Copyright 2012 - 2016, Cadence Design Systems
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.