From 539e37118ac97cd0acbcacee5477942ba1d7bcfe Mon Sep 17 00:00:00 2001 From: Lin Date: Thu, 31 Oct 2024 10:47:26 +0800 Subject: [PATCH] add option reduce error to warning --- .../openfpga_commands/setup_commands.rst | 4 ++++ libs/libpcf/src/io/pcf_reader.cpp | 22 +++++++++---------- libs/libpcf/src/io/pcf_reader.h | 2 +- .../src/base/openfpga_pcf2place_template.h | 4 +++- .../base/openfpga_setup_command_template.h | 4 ++++ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/docs/source/manual/openfpga_shell/openfpga_commands/setup_commands.rst b/docs/source/manual/openfpga_shell/openfpga_commands/setup_commands.rst index e955592c6..ed7f594d6 100644 --- a/docs/source/manual/openfpga_shell/openfpga_commands/setup_commands.rst +++ b/docs/source/manual/openfpga_shell/openfpga_commands/setup_commands.rst @@ -460,6 +460,10 @@ pcf2place .. option:: --no_time_stamp Do not print time stamp in output files + + .. option:: --reduce_error_to_warning + + Reduce error to warning while reading commands in pcf file .. option:: --verbose diff --git a/libs/libpcf/src/io/pcf_reader.cpp b/libs/libpcf/src/io/pcf_reader.cpp index a1dde16de..52f41dc73 100644 --- a/libs/libpcf/src/io/pcf_reader.cpp +++ b/libs/libpcf/src/io/pcf_reader.cpp @@ -27,7 +27,8 @@ constexpr const char COMMENT = '#'; * Return 1 if there are serious errors when parsing data * Return 2 if fail when opening files *******************************************************************/ -int read_pcf(const char* fname, PcfData& pcf_data) { +int read_pcf(const char* fname, PcfData& pcf_data, + bool reduce_error_to_warning = false) { vtr::ScopedStartFinishTimer timer("Read " + std::string(fname)); /* Create a file handler */ @@ -57,17 +58,16 @@ int read_pcf(const char* fname, PcfData& pcf_data) { pcf_data.set_io_pin(io_id, pin_name); } else if (word[0] == COMMENT) { // if it's a comment break; // or ignore the full line comment and move on - } else if (word.find("set_clk") == 0 || word.find("set_reset") == 0) { - /* set_clk and set_rest are known commands for Arkangel, disable the - * error message for these two commands when call read_pcf function - */ - break; } else { - /* Reach unknown command for OpenFpga, error out */ - VTR_LOG_ERROR("Unknown command '%s'!\n", word.c_str()); - num_err++; - break; // and move onto next line. without this, it will accept - // more following values on this line + if (reduce_error_to_warning) { + break; + } else { + /* Reach unknown command for OpenFpga, error out */ + VTR_LOG_ERROR("Unknown command '%s'!\n", word.c_str()); + num_err++; + break; // and move onto next line. without this, it will accept + // more following values on this line + } } } } diff --git a/libs/libpcf/src/io/pcf_reader.h b/libs/libpcf/src/io/pcf_reader.h index 347a50b68..aa32ee8cb 100644 --- a/libs/libpcf/src/io/pcf_reader.h +++ b/libs/libpcf/src/io/pcf_reader.h @@ -16,7 +16,7 @@ namespace openfpga { /* Parse a .pcf file through a stream, return an object which contains all the * data */ -int read_pcf(const char* fname, PcfData& pcf_data); +int read_pcf(const char* fname, PcfData& pcf_data, bool reduce_error_to_warning = false); } /* End namespace openfpga*/ diff --git a/openfpga/src/base/openfpga_pcf2place_template.h b/openfpga/src/base/openfpga_pcf2place_template.h index 4c430aaad..4a5ed4757 100644 --- a/openfpga/src/base/openfpga_pcf2place_template.h +++ b/openfpga/src/base/openfpga_pcf2place_template.h @@ -35,6 +35,8 @@ int pcf2place_wrapper_template(const Command& cmd, CommandOptionId opt_no_time_stamp = cmd.option("no_time_stamp"); CommandOptionId opt_pin_table_dir_convention = cmd.option("pin_table_direction_convention"); + CommandOptionId opt_reduce_error_to_warning = + cmd.option("reduce_error_to_warning"); CommandOptionId opt_verbose = cmd.option("verbose"); std::string pcf_fname = cmd_context.option_value(cmd, opt_pcf); @@ -71,7 +73,7 @@ int pcf2place_wrapper_template(const Command& cmd, /* Parse the input files */ openfpga::PcfData pcf_data; - openfpga::read_pcf(pcf_fname.c_str(), pcf_data); + openfpga::read_pcf(pcf_fname.c_str(), pcf_data,cmd_context.option_enable(cmd, opt_reduce_error_to_warning)); VTR_LOG("Read the design constraints from a pcf file: %s.\n", pcf_fname.c_str()); diff --git a/openfpga/src/base/openfpga_setup_command_template.h b/openfpga/src/base/openfpga_setup_command_template.h index 3c8c41f77..88fec6d94 100644 --- a/openfpga/src/base/openfpga_setup_command_template.h +++ b/openfpga/src/base/openfpga_setup_command_template.h @@ -599,6 +599,10 @@ ShellCommandId add_pcf2place_command_template( shell_cmd.add_option("no_time_stamp", false, "Do not print time stamp in output files"); + /* Add an option '--reduce_error_to_warning' */ + shell_cmd.add_option("reduce_error_to_warning", false, + "reduce error to warning while reading commands in pcf file"); + /* Add an option '--verbose' */ shell_cmd.add_option("verbose", false, "Enable verbose output");