diff --git a/libopenfpga/libpinconstrain/src/file_readers/blif_reader.cpp b/libopenfpga/libpinconstrain/src/file_readers/blif_reader.cpp index 46f6bf68f..9f3e7f1a2 100644 --- a/libopenfpga/libpinconstrain/src/file_readers/blif_reader.cpp +++ b/libopenfpga/libpinconstrain/src/file_readers/blif_reader.cpp @@ -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; } diff --git a/libopenfpga/libpinconstrain/src/file_readers/csv_reader.cpp b/libopenfpga/libpinconstrain/src/file_readers/csv_reader.cpp index fe14b78e7..1fe9fe759 100644 --- a/libopenfpga/libpinconstrain/src/file_readers/csv_reader.cpp +++ b/libopenfpga/libpinconstrain/src/file_readers/csv_reader.cpp @@ -1,5 +1,6 @@ #include "csv_reader.h" #include +#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; } diff --git a/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.cpp b/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.cpp index e4adad10f..a27022d4b 100644 --- a/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.cpp +++ b/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.cpp @@ -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()); + commands.push_back(std::vector()); commands.back().push_back(a); commands.back().push_back(b); commands.back().push_back(c); - //pcf_pin_map.insert(std::pair(b, c)); } return true; } diff --git a/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.h b/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.h index 550986ee5..cf5cd8c2c 100644 --- a/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.h +++ b/libopenfpga/libpinconstrain/src/file_readers/pcf_reader.h @@ -17,11 +17,9 @@ Supported PCF commands: Every tile where is present will be constrained to use a given global clock. */ -using namespace std; class PcfReader { - vector> commands; - //std::map pcf_pin_map; + std::vector> commands; public: PcfReader() {} @@ -30,8 +28,7 @@ public: read_pcf(f); } bool read_pcf(const std::string &f); - const vector>& get_commands()const { return commands;} - //const unordered_map& get_pcf_pin_map()const { return pcf_pin_map;} + const std::vector>& get_commands()const { return commands;} }; #endif diff --git a/libopenfpga/libpinconstrain/src/pin_loc/pin_location.cpp b/libopenfpga/libpinconstrain/src/pin_loc/pin_location.cpp index b06f26d6e..2fb7d6be0 100644 --- a/libopenfpga/libpinconstrain/src/pin_loc/pin_location.cpp +++ b/libopenfpga/libpinconstrain/src/pin_loc/pin_location.cpp @@ -7,6 +7,7 @@ #include "pin_location.h" #include #include +#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 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 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 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; } diff --git a/libopenfpga/libpinconstrain/src/pin_loc/pin_location.h b/libopenfpga/libpinconstrain/src/pin_loc/pin_location.h index 40728b9a6..609752fc0 100644 --- a/libopenfpga/libpinconstrain/src/pin_loc/pin_location.h +++ b/libopenfpga/libpinconstrain/src/pin_loc/pin_location.h @@ -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_; diff --git a/openfpga/src/base/openfpga_constrain_pin_location_command.cpp b/openfpga/src/base/openfpga_constrain_pin_location_command.cpp index 0e0ae27a0..8b843e8dc 100644 --- a/openfpga/src/base/openfpga_constrain_pin_location_command.cpp +++ b/openfpga/src/base/openfpga_constrain_pin_location_command.cpp @@ -28,13 +28,6 @@ void add_openfpga_constrain_pin_location_command(openfpga::Shell