From d4028b4e6f09dbe61a49469297a6815b62fc55da Mon Sep 17 00:00:00 2001 From: Lin Date: Wed, 28 Aug 2024 16:31:16 +0800 Subject: [PATCH] modification no build warning now --- .../src/io/io_xml_unique_blocks.cpp | 61 +++++++++++++++++ .../src/io/io_xml_unique_blocks.h | 25 +++++++ .../src/fabric/read_write_xml_unique_blocks.h | 66 +++---------------- 3 files changed, 94 insertions(+), 58 deletions(-) create mode 100644 libs/libfabrickey/src/io/io_xml_unique_blocks.cpp create mode 100644 libs/libfabrickey/src/io/io_xml_unique_blocks.h diff --git a/libs/libfabrickey/src/io/io_xml_unique_blocks.cpp b/libs/libfabrickey/src/io/io_xml_unique_blocks.cpp new file mode 100644 index 000000000..2cfab2000 --- /dev/null +++ b/libs/libfabrickey/src/io/io_xml_unique_blocks.cpp @@ -0,0 +1,61 @@ +#include +/* Headers from vtr util library */ +#include "vtr_assert.h" +#include "vtr_time.h" + +/* Headers from libarchfpga */ +#include "arch_error.h" +#include "io_xml_unique_blocks.h" +#include "openfpga_digest.h" +#include "read_xml_util.h" +#include "write_xml_utils.h" + +namespace openfpga { +vtr::Point read_xml_unique_instance_info( + 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_y = get_attribute(xml_instance_info, "y", loc_data).as_int(); + vtr::Point instance_coordinate(instance_x, instance_y); + return instance_coordinate; +} + +int write_xml_block( + std::map>& id_unique_block_map, + std::map>>& id_instance_map, + std::fstream& fp, std::string type) { + /* Validate the file stream */ + if (false == openfpga::valid_file_stream(fp)) { + return CMD_EXEC_FATAL_ERROR; + } + for (const auto& pair : id_unique_block_map) { + openfpga::write_tab_to_file(fp, 1); + fp << "" + << "\n"; + + for (const auto& instance_info : id_instance_map[pair.first]) { + if (instance_info.x() == pair.second.x() && + instance_info.y() == pair.second.y()) { + ; + } else { + openfpga::write_tab_to_file(fp, 2); + fp << "" + << "\n"; + } + } + openfpga::write_tab_to_file(fp, 1); + fp << "" + << "\n"; + } + + return CMD_EXEC_SUCCESS; +} +} // namespace openfpga diff --git a/libs/libfabrickey/src/io/io_xml_unique_blocks.h b/libs/libfabrickey/src/io/io_xml_unique_blocks.h new file mode 100644 index 000000000..25a7f812e --- /dev/null +++ b/libs/libfabrickey/src/io/io_xml_unique_blocks.h @@ -0,0 +1,25 @@ +#ifndef IO_XML_UNIQUE_BLOCKS_H +#define IO_XML_UNIQUE_BLOCKS_H + +#include + +#include "pugixml.hpp" +#include "pugixml_util.hpp" +#include "vtr_geometry.h" +/******************************************************************** + * Function declaration + *******************************************************************/ + +namespace openfpga { // Begin namespace openfpga + +vtr::Point read_xml_unique_instance_info( + pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data); + +int write_xml_block( + std::map>& id_unique_block_map, + std::map>>& id_instance_map, + std::fstream& fp, std::string type); + +} // End of namespace openfpga + +#endif diff --git a/openfpga/src/fabric/read_write_xml_unique_blocks.h b/openfpga/src/fabric/read_write_xml_unique_blocks.h index f7c3091ef..56ad3dcaa 100644 --- a/openfpga/src/fabric/read_write_xml_unique_blocks.h +++ b/openfpga/src/fabric/read_write_xml_unique_blocks.h @@ -26,8 +26,8 @@ /* Headers from libarchfpga */ #include "arch_error.h" #include "device_rr_gsb_utils.h" +#include "io_xml_unique_blocks.h" #include "openfpga_digest.h" -#include "read_write_xml_unique_blocks.h" #include "read_xml_util.h" #include "rr_gsb.h" #include "write_xml_utils.h" @@ -37,16 +37,6 @@ * instance is the mirror of unique module. *******************************************************************/ namespace openfpga { -vtr::Point read_xml_unique_instance_info; -int write_xml_block; -vtr::Point read_xml_unique_instance_info( - 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_y = get_attribute(xml_instance_info, "y", loc_data).as_int(); - vtr::Point instance_coordinate(instance_x, instance_y); - return instance_coordinate; -} - template void report_unique_module_status_read(T& openfpga_ctx, bool verbose_output) { /* Report the stats */ @@ -199,7 +189,6 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name, } } else { bad_tag(xml_block_info, loc_data, xml_root, {"block"}); - return 1; } } /* As preloading gsb hasn't been developed, we should build gsb using the @@ -207,53 +196,11 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name, device_rr_gsb.build_gsb_unique_module(); if (verbose_output) { report_unique_module_status_read(openfpga_ctx, true); - return 0; } + return CMD_EXEC_SUCCESS; } catch (pugiutil::XmlError& e) { archfpga_throw(file_name, e.line(), "%s", e.what()); } - - return 0; -} - -int write_xml_block( - std::map>& id_unique_block_map, - std::map>>& id_instance_map, - std::fstream& fp, std::string type) { - /* Validate the file stream */ - if (false == openfpga::valid_file_stream(fp)) { - return 2; - } - for (const auto& pair : id_unique_block_map) { - openfpga::write_tab_to_file(fp, 1); - fp << "" - << "\n"; - - for (const auto& instance_info : id_instance_map[pair.first]) { - if (instance_info.x() == pair.second.x() && - instance_info.y() == pair.second.y()) { - ; - } else { - openfpga::write_tab_to_file(fp, 2); - fp << "" - << "\n"; - } - } - openfpga::write_tab_to_file(fp, 1); - fp << "" - << "\n"; - } - - return 0; } template @@ -300,10 +247,13 @@ int write_xml_unique_blocks(const T& openfpga_ctx, const char* fname, fp.close(); if (verbose_output) { report_unique_module_status_write(openfpga_ctx, true); - return err_code; } - return err_code; -} + + if (err_code >= 1) { + return CMD_EXEC_FATAL_ERROR; + } else { + return CMD_EXEC_SUCCESS; + } } // namespace openfpga #endif