modification no build warning now

This commit is contained in:
Lin 2024-08-28 16:31:16 +08:00
parent cde4c8d34a
commit d4028b4e6f
3 changed files with 94 additions and 58 deletions

View File

@ -0,0 +1,61 @@
#include <string>
/* 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<size_t> 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<size_t> instance_coordinate(instance_x, instance_y);
return instance_coordinate;
}
int write_xml_block(
std::map<int, vtr::Point<size_t>>& id_unique_block_map,
std::map<int, std::vector<vtr::Point<size_t>>>& 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 << "<block";
write_xml_attribute(fp, "type", type.c_str());
write_xml_attribute(fp, "x", pair.second.x());
write_xml_attribute(fp, "y", pair.second.y());
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 << "<instance";
write_xml_attribute(fp, "x", instance_info.x());
write_xml_attribute(fp, "y", instance_info.y());
fp << "/>"
<< "\n";
}
}
openfpga::write_tab_to_file(fp, 1);
fp << "</block>"
<< "\n";
}
return CMD_EXEC_SUCCESS;
}
} // namespace openfpga

View File

@ -0,0 +1,25 @@
#ifndef IO_XML_UNIQUE_BLOCKS_H
#define IO_XML_UNIQUE_BLOCKS_H
#include <fstream>
#include "pugixml.hpp"
#include "pugixml_util.hpp"
#include "vtr_geometry.h"
/********************************************************************
* Function declaration
*******************************************************************/
namespace openfpga { // Begin namespace openfpga
vtr::Point<size_t> read_xml_unique_instance_info(
pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data);
int write_xml_block(
std::map<int, vtr::Point<size_t>>& id_unique_block_map,
std::map<int, std::vector<vtr::Point<size_t>>>& id_instance_map,
std::fstream& fp, std::string type);
} // End of namespace openfpga
#endif

View File

@ -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<size_t> read_xml_unique_instance_info;
int write_xml_block;
vtr::Point<size_t> 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<size_t> instance_coordinate(instance_x, instance_y);
return instance_coordinate;
}
template <class T>
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<int, vtr::Point<size_t>>& id_unique_block_map,
std::map<int, std::vector<vtr::Point<size_t>>>& 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 << "<block";
write_xml_attribute(fp, "type", type.c_str());
write_xml_attribute(fp, "x", pair.second.x());
write_xml_attribute(fp, "y", pair.second.y());
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 << "<instance";
write_xml_attribute(fp, "x", instance_info.x());
write_xml_attribute(fp, "y", instance_info.y());
fp << "/>"
<< "\n";
}
}
openfpga::write_tab_to_file(fp, 1);
fp << "</block>"
<< "\n";
}
return 0;
}
template <class T>
@ -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