[core] developing fpga_core insertion

This commit is contained in:
tangxifan 2023-06-17 23:42:45 -07:00
parent cd748b1a5e
commit 8bc70b590a
4 changed files with 81 additions and 0 deletions

View File

@ -231,6 +231,18 @@ int write_fabric_io_info_template(const T& openfpga_ctx, const Command& cmd,
cmd_context.option_enable(cmd, opt_verbose)); cmd_context.option_enable(cmd, opt_verbose));
} }
/********************************************************************
* Add fpga_core module to the module graph
*******************************************************************/
template <class T>
int add_fpga_core_to_fabric_template(T& openfpga_ctx, const Command& cmd,
const CommandContext& cmd_context) {
CommandOptionId opt_verbose = cmd.option("verbose");
bool verbose_output = cmd_context.option_enable(cmd, opt_verbose);
return add_fpga_core_to_device_module_graph(openfpga_ctx.mutable_module_graph(), verbose_output);
}
} /* end namespace openfpga */ } /* end namespace openfpga */
#endif #endif

View File

@ -692,6 +692,35 @@ ShellCommandId add_route_clock_rr_graph_command_template(
return shell_cmd_id; return shell_cmd_id;
} }
/********************************************************************
* - Add a command to Shell environment: add_fpga_core_to_fabric
* - Add associated options
* - Add command dependency
*******************************************************************/
template <class T>
ShellCommandId add_add_fpga_core_to_fabric_command_template(
openfpga::Shell<T>& shell, const ShellCommandClassId& cmd_class_id,
const std::vector<ShellCommandId>& dependent_cmds, const bool& hidden) {
Command shell_cmd("add_fpga_core_to_fabric");
/* Add an option '--verbose' */
shell_cmd.add_option("verbose", false, "Show verbose outputs");
/* Add command 'pb_pin_fixup' to the Shell */
ShellCommandId shell_cmd_id = shell.add_command(
shell_cmd,
"Add fpga_core as an intermediate layer to FPGA fabric. After this command, the fpga_top will remain the top-level module while there is a new module fpga_core under it. Under fpga_core, there will be the detailed building blocks",
hidden);
shell.set_command_class(shell_cmd_id, cmd_class_id);
shell.set_command_execute_function(shell_cmd_id,
add_fpga_core_to_fabric_template<T>);
/* Add command dependency to the Shell */
shell.set_command_dependency(shell_cmd_id, dependent_cmds);
return shell_cmd_id;
}
template <class T> template <class T>
void add_setup_command_templates(openfpga::Shell<T>& shell, void add_setup_command_templates(openfpga::Shell<T>& shell,
const bool& hidden = false) { const bool& hidden = false) {
@ -859,6 +888,7 @@ void add_setup_command_templates(openfpga::Shell<T>& shell,
lut_tt_fixup_dependent_cmds.push_back(vpr_cmd_id); lut_tt_fixup_dependent_cmds.push_back(vpr_cmd_id);
add_lut_truth_table_fixup_command_template<T>( add_lut_truth_table_fixup_command_template<T>(
shell, openfpga_setup_cmd_class, lut_tt_fixup_dependent_cmds, hidden); shell, openfpga_setup_cmd_class, lut_tt_fixup_dependent_cmds, hidden);
/******************************** /********************************
* Command 'build_fabric' * Command 'build_fabric'
*/ */
@ -869,6 +899,16 @@ void add_setup_command_templates(openfpga::Shell<T>& shell,
ShellCommandId build_fabric_cmd_id = add_build_fabric_command_template<T>( ShellCommandId build_fabric_cmd_id = add_build_fabric_command_template<T>(
shell, openfpga_setup_cmd_class, build_fabric_dependent_cmds, hidden); shell, openfpga_setup_cmd_class, build_fabric_dependent_cmds, hidden);
/********************************
* Command 'add_fpga_core_to_fabric'
*/
/* The command should NOT be executed before
* 'build_fabric' */
std::vector<ShellCommandId> add_fpga_core_to_fabric_dependent_cmds;
add_fpga_core_to_fabric_dependent_cmds.push_back(build_fabric_cmd_id);
ShellCommandId add_fpga_core_to_fabric_cmd_id = add_add_fpga_core_to_fabric_command_template<T>(
shell, openfpga_setup_cmd_class, add_fpga_core_to_fabric_dependent_cmds, hidden);
/******************************** /********************************
* Command 'write_fabric_hierarchy' * Command 'write_fabric_hierarchy'
*/ */

View File

@ -126,4 +126,31 @@ int build_device_module_graph(
return status; return status;
} }
/********************************************************************
* The main function to be called for adding the fpga_core wrapper to a FPGA fabric
* - Rename existing fpga_top to fpga_core
* - Create a wrapper module 'fpga_top' on the fpga_core
*******************************************************************/
int add_fpga_core_to_device_module_graph(ModuleManager& module_manager, const bool& verbose) {
int status = CMD_EXEC_SUCCESS;
/* Execute the module graph api */
std::string top_module_name = generate_fpga_top_module_name();
ModuleId top_module = module_manager.find_module(top_module_name);
if (!module_manager.valid_module_id(top_module)) {
return CMD_EXEC_FATAL_ERROR;
}
/* TODO: Use a constant for the top_module name */
/* Rename existing top module to fpga_core */
module_manager.set_module_name(top_module, "fpga_core");
/* Create a wrapper module under the existing fpga_top */
ModuleId new_top_module = module_manager.create_wrapper(top_module, top_module_name),
if (!module_manager.valid_module_id(new_top_module)) {
return CMD_EXEC_FATAL_ERROR;
}
return status;
}
} /* end namespace openfpga */ } /* end namespace openfpga */

View File

@ -23,6 +23,8 @@ int build_device_module_graph(
const bool& duplicate_grid_pin, const FabricKey& fabric_key, const bool& duplicate_grid_pin, const FabricKey& fabric_key,
const bool& generate_random_fabric_key, const bool& verbose); const bool& generate_random_fabric_key, const bool& verbose);
int add_fpga_core_to_device_module_graph(ModuleManager& module_manager, const bool& verbose);
} /* end namespace openfpga */ } /* end namespace openfpga */
#endif #endif