mod according to code review

This commit is contained in:
Lin 2024-08-28 15:45:19 +08:00
parent 1b34f4f0d9
commit cde4c8d34a
3 changed files with 24 additions and 9 deletions

View File

@ -501,6 +501,7 @@ int read_unique_blocks_template(T& openfpga_ctx, const Command& cmd,
cmd_context.option_enable(cmd, opt_verbose)); cmd_context.option_enable(cmd, opt_verbose));
} else { } else {
VTR_LOG_ERROR("file type %s not supported", file_type.c_str()); VTR_LOG_ERROR("file type %s not supported", file_type.c_str());
return CMD_EXEC_FATAL_ERROR;
} }
} }
@ -528,6 +529,7 @@ int write_unique_blocks_template(T& openfpga_ctx, const Command& cmd,
cmd_context.option_enable(cmd, opt_verbose)); cmd_context.option_enable(cmd, opt_verbose));
} else { } else {
VTR_LOG_ERROR("file type %s not supported", file_type.c_str()); VTR_LOG_ERROR("file type %s not supported", file_type.c_str());
return CMD_EXEC_FATAL_ERROR;
} }
} }
} /* end namespace openfpga */ } /* end namespace openfpga */

View File

@ -947,13 +947,15 @@ ShellCommandId add_read_unique_blocks_command_template(
Command shell_cmd("read_unique_blocks"); Command shell_cmd("read_unique_blocks");
/* Add an option '--file' */ /* Add an option '--file' */
CommandOptionId opt_file = CommandOptionId opt_file = shell_cmd.add_option(
shell_cmd.add_option("file", true, "specify the unique blocks xml file"); "file", true, "specify the file which contains unique block information");
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING); shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
/* Add an option '--type' */ /* Add an option '--type' */
CommandOptionId opt_type = shell_cmd.add_option( CommandOptionId opt_type =
"type", true, "specify the type of the unique blocks xml file"); shell_cmd.add_option("type", true,
"Specify the type of the unique blocks file "
"[xml|bin]. If not specified, by default it is XML.");
shell_cmd.set_option_require_value(opt_type, openfpga::OPT_STRING); shell_cmd.set_option_require_value(opt_type, openfpga::OPT_STRING);
/* Add an option '--verbose' */ /* Add an option '--verbose' */
@ -984,13 +986,16 @@ ShellCommandId add_write_unique_blocks_command_template(
Command shell_cmd("write_unique_blocks"); Command shell_cmd("write_unique_blocks");
/* Add an option '--file' */ /* Add an option '--file' */
CommandOptionId opt_file = CommandOptionId opt_file = shell_cmd.add_option(
shell_cmd.add_option("file", true, "specify the unique blocks xml file"); "file", true,
"specify the file which we will write unique block information to");
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING); shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
/* Add an option '--type' */ /* Add an option '--type' */
CommandOptionId opt_type = shell_cmd.add_option( CommandOptionId opt_type =
"type", true, "specify the type of the unique blocks xml file"); shell_cmd.add_option("type", true,
"Specify the type of the unique blocks file "
"[xml|bin]. If not specified, by default it is XML.");
shell_cmd.set_option_require_value(opt_type, openfpga::OPT_STRING); shell_cmd.set_option_require_value(opt_type, openfpga::OPT_STRING);
/* Add an option '--verbose' */ /* Add an option '--verbose' */

View File

@ -36,6 +36,9 @@
* Parse XML codes of a <instance> to an object of device_rr_gsb * Parse XML codes of a <instance> to an object of device_rr_gsb
* instance is the mirror of unique module. * instance is the mirror of unique module.
*******************************************************************/ *******************************************************************/
namespace openfpga {
vtr::Point<size_t> read_xml_unique_instance_info;
int write_xml_block;
vtr::Point<size_t> read_xml_unique_instance_info( vtr::Point<size_t> read_xml_unique_instance_info(
pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data) { pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data) {
int instance_x = get_attribute(xml_instance_info, "x", loc_data).as_int(); int instance_x = get_attribute(xml_instance_info, "x", loc_data).as_int();
@ -190,7 +193,9 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
device_rr_gsb.preload_unique_cbx_module(block_coordinate, device_rr_gsb.preload_unique_cbx_module(block_coordinate,
instance_coords); instance_coords);
} else { } else {
VTR_LOG_ERROR("Unexpected type!"); archfpga_throw(loc_data.filename_c_str(),
loc_data.line(xml_block_info),
"Invalid block type '%s'\n", type);
} }
} else { } else {
bad_tag(xml_block_info, loc_data, xml_root, {"block"}); bad_tag(xml_block_info, loc_data, xml_root, {"block"});
@ -202,6 +207,7 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name,
device_rr_gsb.build_gsb_unique_module(); device_rr_gsb.build_gsb_unique_module();
if (verbose_output) { if (verbose_output) {
report_unique_module_status_read(openfpga_ctx, true); report_unique_module_status_read(openfpga_ctx, true);
return 0;
} }
} catch (pugiutil::XmlError& e) { } catch (pugiutil::XmlError& e) {
archfpga_throw(file_name, e.line(), "%s", e.what()); archfpga_throw(file_name, e.line(), "%s", e.what());
@ -294,8 +300,10 @@ int write_xml_unique_blocks(const T& openfpga_ctx, const char* fname,
fp.close(); fp.close();
if (verbose_output) { if (verbose_output) {
report_unique_module_status_write(openfpga_ctx, true); report_unique_module_status_write(openfpga_ctx, true);
return err_code;
} }
return err_code; return err_code;
} }
} // namespace openfpga
#endif #endif