2023-09-16 01:22:31 -05:00
|
|
|
/* Headers from vtrutil library */
|
2023-09-16 01:32:40 -05:00
|
|
|
#include "rename_modules.h"
|
2023-09-16 01:22:31 -05:00
|
|
|
|
|
|
|
#include "command_exit_codes.h"
|
|
|
|
#include "openfpga_naming.h"
|
2023-09-16 01:32:40 -05:00
|
|
|
#include "vtr_assert.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
#include "vtr_time.h"
|
2023-09-16 01:22:31 -05:00
|
|
|
|
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
2023-09-16 01:32:40 -05:00
|
|
|
/** @brief Initialize a module name map with the existing module names from a
|
|
|
|
* module manager. In this case, all the built-in names are the same as
|
|
|
|
* customized names */
|
|
|
|
int init_fabric_module_name_map(ModuleNameMap& module_name_map,
|
|
|
|
const ModuleManager& module_manager,
|
|
|
|
const bool& verbose) {
|
2023-09-16 01:22:31 -05:00
|
|
|
int status = CMD_EXEC_SUCCESS;
|
|
|
|
/* the module name map should be empty! */
|
|
|
|
module_name_map.clear();
|
|
|
|
size_t cnt = 0;
|
|
|
|
for (ModuleId curr_module : module_manager.modules()) {
|
2023-09-16 01:32:40 -05:00
|
|
|
status = module_name_map.set_tag_to_name_pair(
|
|
|
|
module_manager.module_name(curr_module),
|
|
|
|
module_manager.module_name(curr_module));
|
2023-09-16 01:22:31 -05:00
|
|
|
if (status != CMD_EXEC_SUCCESS) {
|
|
|
|
return CMD_EXEC_SUCCESS;
|
|
|
|
}
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
VTR_LOGV(verbose, "Initialized module name map for '%lu' modules\n", cnt);
|
|
|
|
return CMD_EXEC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-09-16 01:32:40 -05:00
|
|
|
int update_module_map_name_with_indexing_names(ModuleNameMap& module_name_map,
|
|
|
|
const DeviceRRGSB& device_rr_gsb,
|
|
|
|
const FabricTile& fabric_tile,
|
|
|
|
const bool& verbose) {
|
2023-09-16 01:22:31 -05:00
|
|
|
int status = CMD_EXEC_SUCCESS;
|
|
|
|
/* Walk through the device rr gsb on the unique routing modules */
|
|
|
|
for (size_t isb = 0; isb < device_rr_gsb.get_num_sb_unique_module(); ++isb) {
|
|
|
|
const RRGSB& unique_mirror = device_rr_gsb.get_sb_unique_module(isb);
|
2023-09-16 01:32:40 -05:00
|
|
|
vtr::Point<size_t> gsb_coordinate(unique_mirror.get_sb_x(),
|
|
|
|
unique_mirror.get_sb_y());
|
|
|
|
std::string name_using_coord =
|
|
|
|
generate_switch_block_module_name(gsb_coordinate);
|
|
|
|
std::string name_using_index =
|
|
|
|
generate_switch_block_module_name_using_index(isb);
|
|
|
|
status =
|
|
|
|
module_name_map.set_tag_to_name_pair(name_using_coord, name_using_index);
|
2023-09-16 01:22:31 -05:00
|
|
|
if (status != CMD_EXEC_SUCCESS) {
|
|
|
|
return CMD_EXEC_SUCCESS;
|
|
|
|
}
|
2023-09-16 01:32:40 -05:00
|
|
|
VTR_LOGV(verbose, "Now use indexing name for module '%s' (was '%s')\n",
|
|
|
|
name_using_index.c_str(), name_using_coord.c_str());
|
2023-09-16 01:22:31 -05:00
|
|
|
}
|
|
|
|
for (t_rr_type cb_type : {CHANX, CHANY}) {
|
|
|
|
for (size_t icb = 0; icb < device_rr_gsb.get_num_cb_unique_module(cb_type);
|
|
|
|
++icb) {
|
2023-09-16 01:32:40 -05:00
|
|
|
const RRGSB& unique_mirror =
|
|
|
|
device_rr_gsb.get_cb_unique_module(cb_type, icb);
|
2023-09-16 01:22:31 -05:00
|
|
|
vtr::Point<size_t> gsb_coordinate(unique_mirror.get_cb_x(cb_type),
|
|
|
|
unique_mirror.get_cb_y(cb_type));
|
2023-09-16 01:32:40 -05:00
|
|
|
std::string name_using_coord =
|
|
|
|
generate_connection_block_module_name(cb_type, gsb_coordinate);
|
|
|
|
std::string name_using_index =
|
|
|
|
generate_connection_block_module_name_using_index(cb_type, icb);
|
|
|
|
status = module_name_map.set_tag_to_name_pair(name_using_coord,
|
|
|
|
name_using_index);
|
2023-09-16 01:22:31 -05:00
|
|
|
if (status != CMD_EXEC_SUCCESS) {
|
|
|
|
return CMD_EXEC_SUCCESS;
|
|
|
|
}
|
2023-09-16 01:32:40 -05:00
|
|
|
VTR_LOGV(verbose, "Now use indexing name for module '%s' (was '%s')\n",
|
|
|
|
name_using_index.c_str(), name_using_coord.c_str());
|
2023-09-16 01:22:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Walk through the fabric tile on the unique routing modules */
|
|
|
|
for (size_t itile = 0; itile < fabric_tile.unique_tiles().size(); ++itile) {
|
|
|
|
FabricTileId fabric_tile_id = fabric_tile.unique_tiles()[itile];
|
|
|
|
vtr::Point<size_t> tile_coord = fabric_tile.tile_coordinate(fabric_tile_id);
|
|
|
|
std::string name_using_coord = generate_tile_module_name(tile_coord);
|
2023-09-16 01:30:34 -05:00
|
|
|
std::string name_using_index = generate_tile_module_name_using_index(itile);
|
2023-09-16 01:32:40 -05:00
|
|
|
status =
|
|
|
|
module_name_map.set_tag_to_name_pair(name_using_coord, name_using_index);
|
2023-09-16 01:22:31 -05:00
|
|
|
if (status != CMD_EXEC_SUCCESS) {
|
|
|
|
return CMD_EXEC_SUCCESS;
|
|
|
|
}
|
2023-09-16 01:32:40 -05:00
|
|
|
VTR_LOGV(verbose, "Now use indexing name for module '%s' (was '%s')\n",
|
|
|
|
name_using_index.c_str(), name_using_coord.c_str());
|
2023-09-16 01:22:31 -05:00
|
|
|
}
|
|
|
|
return CMD_EXEC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-09-16 01:32:40 -05:00
|
|
|
int rename_fabric_modules(ModuleManager& module_manager,
|
|
|
|
const ModuleNameMap& module_name_map,
|
|
|
|
const bool& verbose) {
|
2023-09-16 01:22:31 -05:00
|
|
|
int status = CMD_EXEC_SUCCESS;
|
|
|
|
size_t cnt = 0;
|
|
|
|
for (ModuleId curr_module : module_manager.modules()) {
|
2023-09-16 01:32:40 -05:00
|
|
|
std::string new_name =
|
|
|
|
module_name_map.name(module_manager.module_name(curr_module));
|
2023-09-16 01:30:34 -05:00
|
|
|
if (new_name != module_manager.module_name(curr_module)) {
|
2023-09-16 01:32:40 -05:00
|
|
|
VTR_LOGV(verbose, "Rename module '%s' to its new name '%s'\n",
|
|
|
|
module_manager.module_name(curr_module).c_str(),
|
|
|
|
new_name.c_str());
|
2023-09-16 01:22:31 -05:00
|
|
|
module_manager.set_module_name(curr_module, new_name);
|
|
|
|
}
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
VTR_LOG("Renamed %lu modules\n", cnt);
|
|
|
|
return status;
|
2023-09-16 01:32:40 -05:00
|
|
|
}
|
2023-09-16 01:22:31 -05:00
|
|
|
|
|
|
|
} /* end namespace openfpga */
|