[Tool] Add report bitstream distribution command to openfpga shell
This commit is contained in:
parent
01b3a96e4b
commit
db9bb9124e
|
@ -86,12 +86,13 @@ void rec_report_block_bitstream_distribution_to_xml_file(std::fstream& fp,
|
|||
* Notes:
|
||||
* - The output format is a table whose format is compatible with RST files
|
||||
*******************************************************************/
|
||||
void report_architecture_bitstream_distribution(const BitstreamManager& bitstream_manager,
|
||||
const std::string& fname,
|
||||
const size_t& max_hierarchy_level) {
|
||||
int report_architecture_bitstream_distribution(const BitstreamManager& bitstream_manager,
|
||||
const std::string& fname,
|
||||
const size_t& max_hierarchy_level) {
|
||||
/* Ensure that we have a valid file name */
|
||||
if (true == fname.empty()) {
|
||||
VTR_LOG_ERROR("Received empty file name to report bitstream!\n\tPlease specify a valid file name.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string timer_message = std::string("Report architecture bitstream distribution into XML file '") + fname + std::string("'");
|
||||
|
@ -116,6 +117,8 @@ void report_architecture_bitstream_distribution(const BitstreamManager& bitstrea
|
|||
|
||||
/* Close file handler */
|
||||
fp.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
void report_architecture_bitstream_distribution(const BitstreamManager& bitstream_manager,
|
||||
const std::string& fname,
|
||||
const size_t& max_hierarchy_level = 1);
|
||||
int report_architecture_bitstream_distribution(const BitstreamManager& bitstream_manager,
|
||||
const std::string& fname,
|
||||
const size_t& max_hierarchy_level = 1);
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
/* Headers from fpgabitstream library */
|
||||
#include "read_xml_arch_bitstream.h"
|
||||
#include "write_xml_arch_bitstream.h"
|
||||
#include "report_arch_bitstream_distribution.h"
|
||||
|
||||
#include "openfpga_naming.h"
|
||||
|
||||
|
@ -165,4 +166,41 @@ int write_io_mapping(const OpenfpgaContext& openfpga_ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* A wrapper function to call the report_arch_bitstream_distribution() in FPGA bitstream
|
||||
*******************************************************************/
|
||||
int report_bitstream_distribution(const OpenfpgaContext& openfpga_ctx,
|
||||
const Command& cmd, const CommandContext& cmd_context) {
|
||||
|
||||
CommandOptionId opt_file = cmd.option("file");
|
||||
|
||||
int status = CMD_EXEC_SUCCESS;
|
||||
|
||||
VTR_ASSERT(true == cmd_context.option_enable(cmd, opt_file));
|
||||
|
||||
std::string src_dir_path = find_path_dir_name(cmd_context.option_value(cmd, opt_file));
|
||||
|
||||
/* Create directories */
|
||||
create_directory(src_dir_path);
|
||||
|
||||
/* Default depth requirement, this is to limit the report size by default */
|
||||
int depth = 1;
|
||||
CommandOptionId opt_depth = cmd.option("depth");
|
||||
if (true == cmd_context.option_enable(cmd, opt_depth)) {
|
||||
depth = std::atoi(cmd_context.option_value(cmd, opt_depth).c_str());
|
||||
/* Error out if we have negative depth */
|
||||
if (0 > depth) {
|
||||
VTR_LOG_ERROR("Invalid depth '%d' which should be 0 or a positive number!\n",
|
||||
depth);
|
||||
return CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
status = report_architecture_bitstream_distribution(openfpga_ctx.bitstream_manager(),
|
||||
cmd_context.option_value(cmd, opt_file),
|
||||
depth);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
|
|
@ -27,6 +27,9 @@ int write_fabric_bitstream(const OpenfpgaContext& openfpga_ctx,
|
|||
int write_io_mapping(const OpenfpgaContext& openfpga_ctx,
|
||||
const Command& cmd, const CommandContext& cmd_context);
|
||||
|
||||
int report_bitstream_distribution(const OpenfpgaContext& openfpga_ctx,
|
||||
const Command& cmd, const CommandContext& cmd_context);
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,40 @@ ShellCommandId add_openfpga_build_arch_bitstream_command(openfpga::Shell<Openfpg
|
|||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: report_bitstream_distribution
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
static
|
||||
ShellCommandId add_openfpga_report_bitstream_distribution_command(openfpga::Shell<OpenfpgaContext>& shell,
|
||||
const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds) {
|
||||
Command shell_cmd("report_bitstream_distribution");
|
||||
|
||||
/* Add an option '--file' */
|
||||
CommandOptionId opt_file = shell_cmd.add_option("file", true, "file path to output the bitstream distribution");
|
||||
shell_cmd.set_option_short_name(opt_file, "f");
|
||||
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
|
||||
|
||||
/* Add an option '--depth' */
|
||||
CommandOptionId opt_depth = shell_cmd.add_option("depth", false, "Specify the max. depth of blocks which will appear in report");
|
||||
shell_cmd.set_option_require_value(opt_depth, openfpga::OPT_INT);
|
||||
|
||||
/* Add an option '--verbose' */
|
||||
shell_cmd.add_option("verbose", false, "Enable verbose output");
|
||||
|
||||
/* Add command 'report_bitstream_distribution' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(shell_cmd, "Report bitstream distribution");
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_execute_function(shell_cmd_id, report_bitstream_distribution);
|
||||
|
||||
/* Add command dependency to the Shell */
|
||||
shell.set_command_dependency(shell_cmd_id, dependent_cmds);
|
||||
|
||||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: build_fabric_bitstream
|
||||
* - Add associated options
|
||||
|
@ -187,6 +221,14 @@ void add_openfpga_bitstream_commands(openfpga::Shell<OpenfpgaContext>& shell) {
|
|||
cmd_dependency_build_arch_bitstream.push_back(shell_cmd_repack_id);
|
||||
ShellCommandId shell_cmd_build_arch_bitstream_id = add_openfpga_build_arch_bitstream_command(shell, openfpga_bitstream_cmd_class, cmd_dependency_build_arch_bitstream);
|
||||
|
||||
/********************************
|
||||
* Command 'report_bitstream_distribution'
|
||||
*/
|
||||
/* The 'report_bitstream_distribution' command should NOT be executed before 'build_architecture_bitstream' */
|
||||
std::vector<ShellCommandId> cmd_dependency_report_bitstream_distribution;
|
||||
cmd_dependency_build_arch_bitstream.push_back(shell_cmd_build_arch_bitstream_id);
|
||||
add_openfpga_report_bitstream_distribution_command(shell, openfpga_bitstream_cmd_class, cmd_dependency_report_bitstream_distribution);
|
||||
|
||||
/********************************
|
||||
* Command 'build_fabric_bitstream'
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue