[core] now support regular expression in module name for fabric pin physical location output
This commit is contained in:
parent
5960cc14aa
commit
f63ea06c4e
|
@ -441,7 +441,7 @@ int write_fabric_pin_physical_location_template(
|
||||||
|
|
||||||
std::string file_name = cmd_context.option_value(cmd, opt_file);
|
std::string file_name = cmd_context.option_value(cmd, opt_file);
|
||||||
|
|
||||||
std::string module_name;
|
std::string module_name("*"); /* Use a wildcard for everything */
|
||||||
CommandOptionId opt_module = cmd.option("module");
|
CommandOptionId opt_module = cmd.option("module");
|
||||||
if (true == cmd_context.option_enable(cmd, opt_module)) {
|
if (true == cmd_context.option_enable(cmd, opt_module)) {
|
||||||
module_name = cmd_context.option_value(cmd, opt_module).empty();
|
module_name = cmd_context.option_value(cmd, opt_module).empty();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
/* Headers from vtrutil library */
|
/* Headers from vtrutil library */
|
||||||
#include "vtr_assert.h"
|
#include "vtr_assert.h"
|
||||||
|
@ -142,24 +143,18 @@ int write_xml_fabric_pin_physical_location(const char* fname,
|
||||||
/* If module name is not specified, walk through all the modules and write
|
/* If module name is not specified, walk through all the modules and write
|
||||||
* physical pin location when any is specified */
|
* physical pin location when any is specified */
|
||||||
short cnt = 0;
|
short cnt = 0;
|
||||||
if (module_name.empty()) {
|
/* Use regular expression to capture the module whose name matches the pattern */
|
||||||
for (ModuleId curr_module : module_manager.modules()) {
|
for (ModuleId curr_module : module_manager.modules()) {
|
||||||
int err_code = write_xml_fabric_module_pin_phy_loc(
|
std::string curr_module_name = module_manager.module_name(curr_module);
|
||||||
fp, module_manager, curr_module, show_invalid_side, verbose);
|
std::string pattern = module_name;
|
||||||
if (err_code != CMD_EXEC_SUCCESS) {
|
std::regex star_replace("\\*");
|
||||||
return CMD_EXEC_FATAL_ERROR;
|
std::regex questionmark_replace("\\?");
|
||||||
}
|
std::string wildcard_pattern = std::regex_replace(std::regex_replace(pattern, star_replace, ".*"), questionmark_replace, ".");
|
||||||
cnt++;
|
std::regex wildcard_regex(wildcard_pattern);
|
||||||
}
|
if (!std::regex_match(curr_module_name, wildcard_regex)) {
|
||||||
} else {
|
continue;
|
||||||
/* Check if the module name is valid or not, if not, error out */
|
|
||||||
ModuleId curr_module = module_manager.find_module(module_name);
|
|
||||||
if (!module_manager.valid_module_id(curr_module)) {
|
|
||||||
VTR_LOG_ERROR(
|
|
||||||
"Invalid module name '%s' which does not exist in current fabric!\n",
|
|
||||||
module_name.c_str());
|
|
||||||
return CMD_EXEC_FATAL_ERROR;
|
|
||||||
}
|
}
|
||||||
|
VTR_LOGV(verbose, "Output pin physical location of module '%s'.\n", curr_module_name.c_str());
|
||||||
/* Write the pin physical location for this module */
|
/* Write the pin physical location for this module */
|
||||||
int err_code = write_xml_fabric_module_pin_phy_loc(
|
int err_code = write_xml_fabric_module_pin_phy_loc(
|
||||||
fp, module_manager, curr_module, show_invalid_side, verbose);
|
fp, module_manager, curr_module, show_invalid_side, verbose);
|
||||||
|
@ -176,6 +171,13 @@ int write_xml_fabric_pin_physical_location(const char* fname,
|
||||||
/* Close the file stream */
|
/* Close the file stream */
|
||||||
fp.close();
|
fp.close();
|
||||||
|
|
||||||
|
/* If there is no match, error out! */
|
||||||
|
if (cnt == 0) {
|
||||||
|
VTR_LOG_ERROR("Invalid regular expression for module name '%s' which does not match any in current fabric!\n",
|
||||||
|
module_name.c_str());
|
||||||
|
return CMD_EXEC_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
VTR_LOGV(verbose, "Outputted %lu modules with pin physical location.\n", cnt);
|
VTR_LOGV(verbose, "Outputted %lu modules with pin physical location.\n", cnt);
|
||||||
|
|
||||||
return CMD_EXEC_SUCCESS;
|
return CMD_EXEC_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue