[core] developing renaming commands. options and functions
This commit is contained in:
parent
7913e6cc6a
commit
2a45b49890
|
@ -18,6 +18,7 @@
|
|||
#include "openfpga_naming.h"
|
||||
#include "read_xml_fabric_key.h"
|
||||
#include "read_xml_io_name_map.h"
|
||||
#include "read_xml_module_name_map.h"
|
||||
#include "read_xml_tile_config.h"
|
||||
#include "vtr_log.h"
|
||||
#include "vtr_time.h"
|
||||
|
@ -103,6 +104,7 @@ int build_fabric_template(T& openfpga_ctx, const Command& cmd,
|
|||
CommandOptionId opt_load_fabric_key = cmd.option("load_fabric_key");
|
||||
CommandOptionId opt_group_tile = cmd.option("group_tile");
|
||||
CommandOptionId opt_group_config_block = cmd.option("group_config_block");
|
||||
CommandOptionId opt_name_module_using_index = cmd.option("name_module_using_index");
|
||||
CommandOptionId opt_verbose = cmd.option("verbose");
|
||||
|
||||
/* Report conflicts with options:
|
||||
|
@ -173,12 +175,15 @@ int build_fabric_template(T& openfpga_ctx, const Command& cmd,
|
|||
curr_status = build_device_module_graph(
|
||||
openfpga_ctx.mutable_module_graph(), openfpga_ctx.mutable_decoder_lib(),
|
||||
openfpga_ctx.mutable_blwl_shift_register_banks(),
|
||||
openfpga_ctx.mutable_fabric_tile(), const_cast<const T&>(openfpga_ctx),
|
||||
openfpga_ctx.mutable_fabric_tile(),
|
||||
openfpga_ctx.mutable_module_name_map(),
|
||||
const_cast<const T&>(openfpga_ctx),
|
||||
g_vpr_ctx.device(), cmd_context.option_enable(cmd, opt_frame_view),
|
||||
cmd_context.option_enable(cmd, opt_compress_routing),
|
||||
cmd_context.option_enable(cmd, opt_duplicate_grid_pin),
|
||||
predefined_fabric_key, tile_config,
|
||||
cmd_context.option_enable(cmd, opt_group_config_block),
|
||||
cmd_context.option_enable(cmd, opt_name_module_using_index),
|
||||
cmd_context.option_enable(cmd, opt_gen_random_fabric_key),
|
||||
cmd_context.option_enable(cmd, opt_verbose));
|
||||
|
||||
|
@ -336,6 +341,32 @@ int add_fpga_core_to_fabric_template(T& openfpga_ctx, const Command& cmd,
|
|||
core_inst_name, frame_view, verbose_output);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* Rename modules in module graph with a set of given rules
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
int rename_modules_template(const T& openfpga_ctx, const Command& cmd,
|
||||
const CommandContext& cmd_context) {
|
||||
CommandOptionId opt_verbose = cmd.option("verbose");
|
||||
|
||||
/* Check the option '--file' is enabled or not
|
||||
* Actually, it must be enabled as the shell interface will check
|
||||
* before reaching this fuction
|
||||
*/
|
||||
CommandOptionId opt_file = cmd.option("file");
|
||||
VTR_ASSERT(true == cmd_context.option_enable(cmd, opt_file));
|
||||
VTR_ASSERT(false == cmd_context.option_value(cmd, opt_file).empty());
|
||||
|
||||
std::string file_name = cmd_context.option_value(cmd, opt_file);
|
||||
|
||||
if (CMD_EXEC_SUCCESS != read_xml_module_name_map(file_name.c_str(), openfpga_ctx.mutable_module_name_map())) {
|
||||
return CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
|
||||
/* Write hierarchy to a file */
|
||||
return rename_fabric_modules(openfpga_ctx.mutable_module_graph(), openfpga_ctx.module_name_map(), cmd_context.option_enable(cmd, opt_verbose));
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "fabric_tile.h"
|
||||
#include "io_location_map.h"
|
||||
#include "io_name_map.h"
|
||||
#include "module_name_map.h"
|
||||
#include "memory_bank_shift_register_banks.h"
|
||||
#include "module_manager.h"
|
||||
#include "mux_library.h"
|
||||
|
@ -107,6 +108,7 @@ class OpenfpgaContext : public Context {
|
|||
return io_location_map_;
|
||||
}
|
||||
const openfpga::IoNameMap& io_name_map() const { return io_name_map_; }
|
||||
const openfpga::ModuleNameMap& module_name_map() const { return module_name_map_; }
|
||||
const openfpga::FabricTile& fabric_tile() const { return fabric_tile_; }
|
||||
const openfpga::FabricGlobalPortInfo& fabric_global_port_info() const {
|
||||
return fabric_global_port_info_;
|
||||
|
@ -167,6 +169,7 @@ class OpenfpgaContext : public Context {
|
|||
return io_location_map_;
|
||||
}
|
||||
openfpga::IoNameMap& mutable_io_name_map() { return io_name_map_; }
|
||||
openfpga::ModuleNameMap& mutable_module_name_map() { return module_name_map_; }
|
||||
openfpga::FabricTile& mutable_fabric_tile() { return fabric_tile_; }
|
||||
openfpga::FabricGlobalPortInfo& mutable_fabric_global_port_info() {
|
||||
return fabric_global_port_info_;
|
||||
|
@ -223,6 +226,7 @@ class OpenfpgaContext : public Context {
|
|||
openfpga::ModuleManager module_graph_;
|
||||
openfpga::IoLocationMap io_location_map_;
|
||||
openfpga::IoNameMap io_name_map_;
|
||||
openfpga::ModuleNameMap module_name_map_;
|
||||
openfpga::FabricTile fabric_tile_;
|
||||
openfpga::FabricGlobalPortInfo fabric_global_port_info_;
|
||||
|
||||
|
|
|
@ -395,6 +395,10 @@ ShellCommandId add_build_fabric_command_template(
|
|||
shell_cmd.add_option("duplicate_grid_pin", false,
|
||||
"Duplicate the pins on the same side of a grid");
|
||||
|
||||
/* Add an option '--name_module_using_index' */
|
||||
shell_cmd.add_option("name_module_using_index", false,
|
||||
"Use index to name modules, such as cbx_0_, rather than coordinates, such as cbx_1__0_");
|
||||
|
||||
/* Add an option '--load_fabric_key' */
|
||||
CommandOptionId opt_load_fkey = shell_cmd.add_option(
|
||||
"load_fabric_key", false, "load the fabric key from the given file");
|
||||
|
@ -786,6 +790,37 @@ ShellCommandId add_write_fabric_key_command_template(
|
|||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: rename_modules
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
ShellCommandId add_rename_modules_command_template(
|
||||
openfpga::Shell<T>& shell, const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds, const bool& hidden) {
|
||||
Command shell_cmd("rename_modules");
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId opt_file =
|
||||
shell_cmd.add_option("file", true, "file path to the XML file that contains renaming rules");
|
||||
shell_cmd.set_option_short_name(opt_file, "f");
|
||||
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
|
||||
|
||||
shell_cmd.add_option("verbose", false, "Show verbose outputs");
|
||||
|
||||
/* Add command to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(
|
||||
shell_cmd, "Rename modules with a set of given rules", hidden);
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_const_execute_function(shell_cmd_id,
|
||||
rename_modules_template<T>);
|
||||
|
||||
/* Add command dependency to the Shell */
|
||||
shell.set_command_dependency(shell_cmd_id, dependent_cmds);
|
||||
|
||||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void add_setup_command_templates(openfpga::Shell<T>& shell,
|
||||
const bool& hidden = false) {
|
||||
|
@ -1005,6 +1040,18 @@ void add_setup_command_templates(openfpga::Shell<T>& shell,
|
|||
add_write_fabric_io_info_command_template<T>(
|
||||
shell, openfpga_setup_cmd_class, cmd_dependency_write_fabric_io_info,
|
||||
hidden);
|
||||
|
||||
/********************************
|
||||
* Command 'rename_modules'
|
||||
*/
|
||||
/* The 'rename_modules' command should NOT be executed before
|
||||
* 'build_fabric' */
|
||||
std::vector<ShellCommandId> cmd_dependency_rename_modules;
|
||||
cmd_dependency_rename_modules.push_back(build_fabric_cmd_id);
|
||||
add_rename_modules_command_template<T>(
|
||||
shell, openfpga_setup_cmd_class, cmd_dependency_rename_modules,
|
||||
hidden);
|
||||
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
|
|
@ -34,11 +34,14 @@ namespace openfpga {
|
|||
int build_device_module_graph(
|
||||
ModuleManager& module_manager, DecoderLibrary& decoder_lib,
|
||||
MemoryBankShiftRegisterBanks& blwl_sr_banks, FabricTile& fabric_tile,
|
||||
ModuleNameMap& module_name_map,
|
||||
const OpenfpgaContext& openfpga_ctx, const DeviceContext& vpr_device_ctx,
|
||||
const bool& frame_view, const bool& compress_routing,
|
||||
const bool& duplicate_grid_pin, const FabricKey& fabric_key,
|
||||
const TileConfig& tile_config, const bool& group_config_block,
|
||||
const bool& generate_random_fabric_key, const bool& verbose) {
|
||||
const bool& name_module_using_index,
|
||||
const bool& generate_random_fabric_key,
|
||||
const bool& verbose) {
|
||||
vtr::ScopedStartFinishTimer timer("Build fabric module graph");
|
||||
|
||||
int status = CMD_EXEC_SUCCESS;
|
||||
|
@ -151,6 +154,24 @@ int build_device_module_graph(
|
|||
rename_primitive_module_port_names(module_manager,
|
||||
openfpga_ctx.arch().circuit_lib);
|
||||
|
||||
/* Collect module names and initialize module name mapping */
|
||||
status = init_fabric_module_map_name(module_manager, module_name_map);
|
||||
if (CMD_EXEC_FATAL_ERROR == status) {
|
||||
return status;
|
||||
}
|
||||
if (name_module_using_index) {
|
||||
/* Update module name data */
|
||||
status = update_module_map_name_with_indexing_names(module_name_map, device_rr_gsb, fabric_tile);
|
||||
if (CMD_EXEC_FATAL_ERROR == status) {
|
||||
return status;
|
||||
}
|
||||
/* Apply module naming */
|
||||
status = rename_fabric_modules(module_manager, module_name_map, verbose);
|
||||
if (CMD_EXEC_FATAL_ERROR == status) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue