diff --git a/openfpga/src/annotation/device_rr_gsb.cpp b/openfpga/src/annotation/device_rr_gsb.cpp index 6af394bba..50e1cab33 100644 --- a/openfpga/src/annotation/device_rr_gsb.cpp +++ b/openfpga/src/annotation/device_rr_gsb.cpp @@ -621,7 +621,7 @@ void DeviceRRGSB::preload_unique_sb_module( } } -void DeviceRRGSB::get_id_unique_block_map( +void DeviceRRGSB::get_id_unique_sb_block_map( std::map>& id_unique_block_map) const { for (size_t id = 0; id < get_num_sb_unique_module(); ++id) { const auto& unique_block_coord = sb_unique_module_[id]; @@ -631,7 +631,7 @@ void DeviceRRGSB::get_id_unique_block_map( } } -void DeviceRRGSB::get_id_instance_map( +void DeviceRRGSB::get_id_sb_instance_map( std::map>>& id_instance_map) const { for (size_t location_x = 0; location_x < sb_unique_module_id_.size(); ++location_x) { @@ -643,4 +643,51 @@ void DeviceRRGSB::get_id_instance_map( } } } + +void DeviceRRGSB::get_id_unique_cbx_block_map( + std::map>& id_unique_block_map) const { + for (size_t id = 0; id < get_num_cb_unique_module(CHANX); ++id) { + const auto& unique_block_coord = cbx_unique_module_[id]; + auto unique_module_id = + cbx_unique_module_id_[unique_block_coord.x()][unique_block_coord.y()]; + id_unique_block_map[unique_module_id] = unique_block_coord; + } +} + +void DeviceRRGSB::get_id_cbx_instance_map( + std::map>>& id_instance_map) const { + for (size_t location_x = 0; location_x < cbx_unique_module_id_.size(); + ++location_x) { + for (size_t location_y = 0; location_y < cbx_unique_module_id_[0].size(); + ++location_y) { + auto unique_module_id = cbx_unique_module_id_[location_x][location_y]; + vtr::Point instance_coord(location_x, location_y); + id_instance_map[unique_module_id].push_back(instance_coord); + } + } +} + +void DeviceRRGSB::get_id_unique_cby_block_map( + std::map>& id_unique_block_map) const { + for (size_t id = 0; id < get_num_cb_unique_module(CHANY); ++id) { + const auto& unique_block_coord = cby_unique_module_[id]; + auto unique_module_id = + cby_unique_module_id_[unique_block_coord.x()][unique_block_coord.y()]; + id_unique_block_map[unique_module_id] = unique_block_coord; + } +} + +void DeviceRRGSB::get_id_cby_instance_map( + std::map>>& id_instance_map) const { + for (size_t location_x = 0; location_x < cby_unique_module_id_.size(); + ++location_x) { + for (size_t location_y = 0; location_y < cby_unique_module_id_[0].size(); + ++location_y) { + auto unique_module_id = cby_unique_module_id_[location_x][location_y]; + vtr::Point instance_coord(location_x, location_y); + id_instance_map[unique_module_id].push_back(instance_coord); + } + } +} + } /* End namespace openfpga*/ diff --git a/openfpga/src/annotation/device_rr_gsb.h b/openfpga/src/annotation/device_rr_gsb.h index 874c08c0e..513d4b003 100644 --- a/openfpga/src/annotation/device_rr_gsb.h +++ b/openfpga/src/annotation/device_rr_gsb.h @@ -103,9 +103,17 @@ class DeviceRRGSB { const vtr::Point block_coordinate, const std::vector> instance_coords); - void get_id_instance_map( + void get_id_sb_instance_map( std::map>>& id_instance_map) const; - void get_id_unique_block_map( + void get_id_unique_sb_block_map( + std::map>& id_unique_block_map) const; + void get_id_cbx_instance_map( + std::map>>& id_instance_map) const; + void get_id_unique_cbx_block_map( + std::map>& id_unique_block_map) const; + void get_id_cby_instance_map( + std::map>>& id_instance_map) const; + void get_id_unique_cby_block_map( std::map>& id_unique_block_map) const; private: /* Internal cleaners */ diff --git a/openfpga/src/fabric/read_xml_unique_blocks.h b/openfpga/src/fabric/read_xml_unique_blocks.h index 59ba8d106..395f44afd 100644 --- a/openfpga/src/fabric/read_xml_unique_blocks.h +++ b/openfpga/src/fabric/read_xml_unique_blocks.h @@ -4,7 +4,7 @@ /******************************************************************** * This file includes the top-level function of this library * which reads an XML of unique routing blocks to the associated - * data structures + * data structures device_rr_gsb *******************************************************************/ #include @@ -24,14 +24,15 @@ /* Headers from libarchfpga */ #include "arch_error.h" #include "device_rr_gsb_utils.h" +#include "openfpga_digest.h" #include "read_xml_unique_blocks.h" #include "read_xml_util.h" #include "rr_gsb.h" #include "write_xml_utils.h" -#include "openfpga_digest.h" /******************************************************************** - * Parse XML codes of a to an object of unique_blocks + * Parse XML codes of a to an object of device_rr_gsb + * instance is the mirror module of unique module. *******************************************************************/ vtr::Point read_xml_unique_instance_info( pugi::xml_node& xml_instance_info, const pugiutil::loc_data& loc_data) { @@ -93,8 +94,7 @@ void report_unique_module_status(T& openfpga_ctx, bool verbose_output) { 1.)); } /******************************************************************** - * Parse XML codes about to an object of - *RepackDesignConstraints + * Parse XML codes about to an object of device_rr_gsb *******************************************************************/ template int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name, @@ -159,14 +159,10 @@ int read_xml_unique_blocks(T& openfpga_ctx, const char* file_name, return 0; } - -template -int write_xml_sb_blocks(std::fstream& fp, const T& openfpga_ctx) { - std::map> id_unique_block_map; - std::map>> id_instance_map; - openfpga_ctx.device_rr_gsb().get_id_unique_block_map(id_unique_block_map); - openfpga_ctx.device_rr_gsb().get_id_instance_map(id_instance_map); - +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; @@ -174,11 +170,11 @@ int write_xml_sb_blocks(std::fstream& fp, const T& openfpga_ctx) { for (const auto& pair : id_unique_block_map) { openfpga::write_tab_to_file(fp, 1); fp << "" + fp << ">" << "\n"; for (const auto& instance_info : id_instance_map[pair.first]) { @@ -190,6 +186,9 @@ int write_xml_sb_blocks(std::fstream& fp, const T& openfpga_ctx) { fp << "/>" << "\n"; } + openfpga::write_tab_to_file(fp, 1); + fp << "" + << "\n"; } return 0; @@ -213,8 +212,23 @@ int write_xml_unique_blocks(const T& openfpga_ctx, const char* fname, << "\n"; int err_code = 0; - - err_code += write_xml_sb_blocks(fp, openfpga_ctx); + std::map> id_unique_block_map; + std::map>> id_instance_map; + openfpga_ctx.device_rr_gsb().get_id_unique_sb_block_map(id_unique_block_map); + openfpga_ctx.device_rr_gsb().get_id_sb_instance_map(id_instance_map); + err_code += write_xml_block(id_unique_block_map, id_instance_map, fp, "sb"); + + id_unique_block_map.clear(); + id_instance_map.clear(); + openfpga_ctx.device_rr_gsb().get_id_unique_cbx_block_map(id_unique_block_map); + openfpga_ctx.device_rr_gsb().get_id_cbx_instance_map(id_instance_map); + err_code += write_xml_block(id_unique_block_map, id_instance_map, fp, "cbx"); + + id_unique_block_map.clear(); + id_instance_map.clear(); + openfpga_ctx.device_rr_gsb().get_id_unique_cby_block_map(id_unique_block_map); + openfpga_ctx.device_rr_gsb().get_id_cby_instance_map(id_instance_map); + err_code += write_xml_block(id_unique_block_map, id_instance_map, fp, "cby"); /* Finish writing the root node */ fp << ""