Code clean up based on review.
This commit is contained in:
parent
cfc0d08060
commit
3762a3aae4
|
@ -2,6 +2,7 @@
|
|||
#include "read_blif.h"
|
||||
#include "blifparse.hpp"
|
||||
#include "blif_reader.h"
|
||||
#include "vtr_log.h"
|
||||
|
||||
// blif parser callback
|
||||
using namespace blifparse;
|
||||
|
@ -34,7 +35,7 @@
|
|||
void finish_parse() override {}
|
||||
|
||||
void parse_error(const int curr_lineno, const std::string& near_text, const std::string& msg) override {
|
||||
fprintf(stderr, "Custom Error at line %d near '%s': %s\n", curr_lineno, near_text.c_str(), msg.c_str());
|
||||
VTR_LOG_ERROR("Custom Error at line %d near '%s': %s\n", curr_lineno, near_text.c_str(), msg.c_str());
|
||||
had_error_ = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "csv_reader.h"
|
||||
#include <algorithm>
|
||||
#include "vtr_log.h"
|
||||
|
||||
|
||||
bool CvsReader::read_cvs(const std::string &f)
|
||||
|
@ -7,7 +8,7 @@ bool CvsReader::read_cvs(const std::string &f)
|
|||
std::ifstream infile(f);
|
||||
if (!infile.is_open())
|
||||
{
|
||||
cout << "ERROR: cound not open the file " << f << endl;
|
||||
VTR_LOG_ERROR("ERROR: cound not open the file %s.\n", f.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
#include "pcf_reader.h"
|
||||
#include "vtr_log.h"
|
||||
|
||||
bool PcfReader::read_pcf(const std::string &f)
|
||||
{
|
||||
std::ifstream infile(f);
|
||||
if (!infile.is_open())
|
||||
{
|
||||
cout << "ERROR: cound not open the file " << f << endl;
|
||||
VTR_LOG_ERROR("ERROR: cound not open the file %s.\n", f.c_str());
|
||||
return false;
|
||||
}
|
||||
std::string line;
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
string a, b, c;
|
||||
std::string a, b, c;
|
||||
if (!(iss >> a >> b >> c))
|
||||
{
|
||||
break;
|
||||
} // error
|
||||
commands.push_back(vector<string>());
|
||||
commands.push_back(std::vector<std::string>());
|
||||
commands.back().push_back(a);
|
||||
commands.back().push_back(b);
|
||||
commands.back().push_back(c);
|
||||
//pcf_pin_map.insert(std::pair<std::string, string>(b, c));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,9 @@ Supported PCF commands:
|
|||
|
||||
Every tile where <net> is present will be constrained to use a given global clock.
|
||||
*/
|
||||
using namespace std;
|
||||
class PcfReader
|
||||
{
|
||||
vector<vector<string>> commands;
|
||||
//std::map<string, string> pcf_pin_map;
|
||||
std::vector<std::vector<std::string>> commands;
|
||||
|
||||
public:
|
||||
PcfReader() {}
|
||||
|
@ -30,8 +28,7 @@ public:
|
|||
read_pcf(f);
|
||||
}
|
||||
bool read_pcf(const std::string &f);
|
||||
const vector<vector<string>>& get_commands()const { return commands;}
|
||||
//const unordered_map<string, string>& get_pcf_pin_map()const { return pcf_pin_map;}
|
||||
const std::vector<std::vector<std::string>>& get_commands()const { return commands;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "pin_location.h"
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "vtr_log.h"
|
||||
|
||||
const string USAGE_MSG = "usage options: --xml PINMAP_XML --pcf PCF --blif BLIF --csv CSV_FILE --output OUTPUT";
|
||||
const cmd_line & pin_location::get_cmd() const
|
||||
|
@ -24,14 +25,14 @@ bool pin_location::reader_and_writer()
|
|||
string output_name = cmd.get_param("--output");
|
||||
if ((xml_name == "") || (csv_name == "") || (pcf_name == "") || (blif_name == "")|| (output_name == "") )
|
||||
{
|
||||
CERROR << error_messages[MISSING_IN_OUT_FILES] << std::endl << USAGE_MSG << endl;
|
||||
VTR_LOG_ERROR("%s\n %s\n", error_messages[MISSING_IN_OUT_FILES].c_str(), USAGE_MSG.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlReader rd_xml;
|
||||
if (!rd_xml.read_xml(xml_name))
|
||||
{
|
||||
CERROR << error_messages[PIN_LOC_XML_PARSE_ERROR] << std::endl;
|
||||
VTR_LOG_ERROR("%s.\n", error_messages[PIN_LOC_XML_PARSE_ERROR].c_str());
|
||||
return false;
|
||||
}
|
||||
std::map<std::string, PinMappingData> xml_port_map = rd_xml.get_port_map();
|
||||
|
@ -39,7 +40,7 @@ bool pin_location::reader_and_writer()
|
|||
CvsReader rd_csv;
|
||||
if (!rd_csv.read_cvs(csv_name))
|
||||
{
|
||||
CERROR << error_messages[PIN_MAP_CSV_PARSE_ERROR] << std::endl;
|
||||
VTR_LOG_ERROR("%s.\n", error_messages[PIN_MAP_CSV_PARSE_ERROR].c_str());
|
||||
return false;
|
||||
}
|
||||
map<string, string> csv_port_map = rd_csv.get_port_map();
|
||||
|
@ -47,14 +48,14 @@ bool pin_location::reader_and_writer()
|
|||
PcfReader rd_pcf;
|
||||
if (!rd_pcf.read_pcf(pcf_name))
|
||||
{
|
||||
CERROR << error_messages[PIN_CONSTRAINT_PARSE_ERROR] << std::endl;
|
||||
VTR_LOG_ERROR("%s.\n", error_messages[PIN_CONSTRAINT_PARSE_ERROR].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// read port info from blif file
|
||||
BlifReader rd_blif;
|
||||
if (!rd_blif.read_blif(blif_name)) {
|
||||
CERROR << error_messages[INPUT_DESIGN_PARSE_ERROR] << std::endl;
|
||||
VTR_LOG_ERROR("%s.\n", error_messages[INPUT_DESIGN_PARSE_ERROR].c_str());
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> inputs = rd_blif.get_inputs();
|
||||
|
@ -89,7 +90,7 @@ bool pin_location::reader_and_writer()
|
|||
}
|
||||
else
|
||||
{
|
||||
CERROR << error_messages[CONSTRAINED_PORT_NOT_FOUND] << ": <" << pin_name << ">" << std::endl;
|
||||
VTR_LOG_ERROR("%s: <%s>.\n", error_messages[CONSTRAINED_PORT_NOT_FOUND].c_str(), pin_name.c_str());
|
||||
out_file.close();
|
||||
return false;
|
||||
}
|
||||
|
@ -97,7 +98,7 @@ bool pin_location::reader_and_writer()
|
|||
if (constrained_ports.find(pin_name) == constrained_ports.end()) {
|
||||
constrained_ports.insert(pin_name);
|
||||
} else {
|
||||
CERROR << error_messages[RE_CONSTRAINED_PORT] << ": <" << pin_name << ">" << std::endl;
|
||||
VTR_LOG_ERROR("%s: <%s>.\n", error_messages[RE_CONSTRAINED_PORT].c_str(), pin_name.c_str());
|
||||
out_file.close();
|
||||
return false;
|
||||
}
|
||||
|
@ -114,7 +115,7 @@ bool pin_location::reader_and_writer()
|
|||
if (constrained_pins.find(cstr_name) == constrained_pins.end()) {
|
||||
constrained_pins.insert(cstr_name);
|
||||
} else {
|
||||
CERROR << error_messages[OVERLAP_PIN_IN_CONSTRAINT] << ": <" << cstr_name << ">" << std::endl;
|
||||
VTR_LOG_ERROR("%s: <%s>.\n", error_messages[OVERLAP_PIN_IN_CONSTRAINT].c_str(), cstr_name.c_str());
|
||||
out_file.close();
|
||||
return false;
|
||||
}
|
||||
|
@ -127,7 +128,7 @@ bool pin_location::reader_and_writer()
|
|||
}
|
||||
content_to_write += pin_name + " " + std::to_string(pinMapData.get_x()) + " " + std::to_string(pinMapData.get_y()) + " " + std::to_string(pinMapData.get_z()) + "\n";
|
||||
} else {
|
||||
CERROR << error_messages[CONSTRAINED_PIN_NOT_FOUND] << ": <" << cstr_name << ">" << std::endl;
|
||||
VTR_LOG_ERROR("%s: <%s>.\n", error_messages[CONSTRAINED_PIN_NOT_FOUND].c_str(), cstr_name.c_str());
|
||||
out_file.close();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef PIN_LOCATION
|
||||
#define PIN_LOCATION
|
||||
#ifndef PIN_LOCATION_H
|
||||
#define PIN_LOCATION_H
|
||||
#include "cmd_line.h"
|
||||
|
||||
// number of arguments for "pin_c", inlcuding the "pin_c" command itself
|
||||
|
@ -30,7 +30,6 @@ private:
|
|||
"Re-constrained port", // RE_CONSTRAINED_PORT
|
||||
"Overlap pin found in constraint" // OVERLAP_PIN_IN_CONSTRAINT
|
||||
};
|
||||
#define CERROR std::cerr << "[Error] "
|
||||
|
||||
cmd_line cl_;
|
||||
|
||||
|
|
|
@ -28,13 +28,6 @@ void add_openfpga_constrain_pin_location_command(openfpga::Shell<OpenfpgaContext
|
|||
CommandOptionId opt_blif_file = shell_cmd.add_option("blif", true, "file path to the synthesized blif");
|
||||
shell_cmd.set_option_require_value(opt_blif_file, openfpga::OPT_STRING);
|
||||
|
||||
#if 0
|
||||
/* Add an option '--net'*/
|
||||
/* Note: This is not implemented in "pin_c" c code yet */
|
||||
CommandOptionId opt_net_file = shell_cmd.add_option("net", true, "file path to the packed net");
|
||||
shell_cmd.set_option_require_value(opt_net_file, openfpga::OPT_STRING);
|
||||
#endif
|
||||
|
||||
/* Add an option '--pinmap_xml'*/
|
||||
CommandOptionId opt_pinmap_file = shell_cmd.add_option("pinmap_xml", true, "file path to the pin location XML");
|
||||
shell_cmd.set_option_require_value(opt_pinmap_file, openfpga::OPT_STRING);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Ru constrain_pin_location
|
||||
# Run constrain_pin_location
|
||||
constrain_pin_location --pcf ${AND2_PIN_CONSTRAIN_FILE} --blif ${VPR_TESTBENCH_BLIF} --pinmap_xml ${AND2_PIN_MAP_XML_FILE} --csv_file ${AND2_PIN_MAP_CSV_FILE} --output ${OPENFPGA_VPR_FIX_PINS_FILE}
|
||||
|
||||
# Run VPR for the 'and' design
|
||||
|
|
Loading…
Reference in New Issue