Introduction
Verilog is a hardware programming language. In VLSI design, after logic synthesis, the circuit is converted from behavior level description to gate level netlist, which will be used in physical design. The parser supports reading the gate level netlists to help users initialize their databases.
Examples
Flex/Bison Parser
See documented version: test/parsers/verilog/test_bison.cpp
#include <iostream>
#include <fstream>
using std::cout;
using std::cin;
using std::endl;
using std::string;
{
public:
{
cout << "VerilogDataBase::" << __func__ << endl;
}
{
cout << __func__ << " => " << module_name << "\n";
for (std::vector<VerilogParser::GeneralName>::const_iterator it = vPinName.begin(); it != vPinName.end(); ++it)
cout << "\t" << it->name << "[" << it->range.low << ":" << it->range.high << "] ";
cout << endl;
}
virtual void verilog_instance_cbk(std::string
const& macro_name, std::string
const& inst_name, std::vector<VerilogParser::NetPin>
const& vNetPin)
{
cout << __func__ << " => " << macro_name << ", " << inst_name << ", ";
for (std::vector<VerilogParser::NetPin>::const_iterator it = vNetPin.begin(); it != vNetPin.end(); ++it)
{
if (it->net == "VerilogParser::CONSTANT_NET")
{
cout << it->pin << "(" << it->net << " " << it->extension.constant << ")" << "[" << it->range.low << ":" << it->range.high << "] ";
}
else if (it->net == "VerilogParser::GROUP_NETS")
{
cout << it->pin << "(" << it->net << " {";
for (std::vector<VerilogParser::GeneralName>::const_iterator itn = it->extension.vNetName->begin(); itn != it->extension.vNetName->end(); ++itn)
{
cout << "(" << itn->name << ")" << "[" << itn->range.low << ":" << itn->range.high << "] ";
}
cout << "} " << ")" << "[" << it->range.low << ":" << it->range.high << "] ";
}
else
{
cout << it->pin << "(" << it->net << ")" << "[" << it->range.low << ":" << it->range.high << "] ";
}
}
cout << endl;
}
{
cout << __func__ <<
" => " << net_name <<
" (" << range.
low <<
", " << range.
high <<
")" << endl;
}
{
cout << __func__ <<
" => " << pin_name <<
" " << type <<
" (" << range.
low <<
", " << range.
high <<
")" << endl;
}
{
cout << __func__ <<
" => " << target_name <<
" (" << target_range.
low <<
", " << target_range.
high <<
")" <<
" = "
<< source_name <<
" (" << source_range.
low <<
", " << source_range.
high <<
")" << endl;
}
};
void test1(
string const& filename)
{
cout << "////////////// test1 ////////////////" << endl;
}
void test2(
string const& filename)
{
cout << "////////////// test2 ////////////////" << endl;
driver.parse_file(filename);
}
int main(
int argc,
char** argv)
{
if (argc > 1)
{
}
else
cout << "at least 1 argument is required" << endl;
return 0;
}
Compiling and running commands (assuming LIMBO_DIR is exported as the environment variable to the path where limbo library is installed)
1 g++ -o test_bison test_bison.cpp -I $LIMBO_DIR/include -L $LIMBO_DIR/lib -lverilogparser
2 ./test_bison benchmarks/simple.v
All Examples
References