add read/write simulation setting commands to openfpga shell
This commit is contained in:
parent
15f087598c
commit
4a2f6dfae2
|
@ -50,6 +50,7 @@
|
|||
class OpenfpgaContext : public Context {
|
||||
public: /* Public accessors */
|
||||
const openfpga::Arch& arch() const { return arch_; }
|
||||
const openfpga::SimulationSetting& simulation_setting() const { return sim_setting_; }
|
||||
const openfpga::VprDeviceAnnotation& vpr_device_annotation() const { return vpr_device_annotation_; }
|
||||
const openfpga::VprNetlistAnnotation& vpr_netlist_annotation() const { return vpr_netlist_annotation_; }
|
||||
const openfpga::VprClusteringAnnotation& vpr_clustering_annotation() const { return vpr_clustering_annotation_; }
|
||||
|
@ -68,6 +69,7 @@ class OpenfpgaContext : public Context {
|
|||
const openfpga::NetlistManager& verilog_netlists() const { return verilog_netlists_; }
|
||||
public: /* Public mutators */
|
||||
openfpga::Arch& mutable_arch() { return arch_; }
|
||||
openfpga::SimulationSetting& mutable_simulation_setting() { return sim_setting_; }
|
||||
openfpga::VprDeviceAnnotation& mutable_vpr_device_annotation() { return vpr_device_annotation_; }
|
||||
openfpga::VprNetlistAnnotation& mutable_vpr_netlist_annotation() { return vpr_netlist_annotation_; }
|
||||
openfpga::VprClusteringAnnotation& mutable_vpr_clustering_annotation() { return vpr_clustering_annotation_; }
|
||||
|
@ -87,6 +89,7 @@ class OpenfpgaContext : public Context {
|
|||
private: /* Internal data */
|
||||
/* Data structure to store information from read_openfpga_arch library */
|
||||
openfpga::Arch arch_;
|
||||
openfpga::SimulationSetting sim_setting_;
|
||||
|
||||
/* Annotation to pb_type of VPR */
|
||||
openfpga::VprDeviceAnnotation vpr_device_annotation_;
|
||||
|
|
|
@ -87,5 +87,59 @@ int write_arch(const OpenfpgaContext& openfpga_context,
|
|||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* Top-level function to read an OpenFPGA simulation setting file
|
||||
* we use the APIs from the libarchopenfpga library
|
||||
*
|
||||
* The command will accept an option '--file' which is the simulation setting
|
||||
* file provided by users
|
||||
*******************************************************************/
|
||||
int read_simulation_setting(OpenfpgaContext& openfpga_context,
|
||||
const Command& cmd, const CommandContext& cmd_context) {
|
||||
/* 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 arch_file_name = cmd_context.option_value(cmd, opt_file);
|
||||
|
||||
VTR_LOG("Reading XML simulation setting '%s'...\n",
|
||||
arch_file_name.c_str());
|
||||
openfpga_context.mutable_simulation_setting() = read_xml_openfpga_simulation_settings(arch_file_name.c_str());
|
||||
|
||||
/* TODO: should identify the error code from internal function execution */
|
||||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* A function to write an OpenFPGA simulation setting file
|
||||
* we use the APIs from the libarchopenfpga library
|
||||
*
|
||||
* The command will accept an option '--file' which is the simulation setting
|
||||
* file provided by users
|
||||
*******************************************************************/
|
||||
int write_simulation_setting(const OpenfpgaContext& openfpga_context,
|
||||
const Command& cmd, const CommandContext& cmd_context) {
|
||||
/* 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 arch_file_name = cmd_context.option_value(cmd, opt_file);
|
||||
|
||||
VTR_LOG("Writing XML simulation setting to '%s'...\n",
|
||||
arch_file_name.c_str());
|
||||
write_xml_openfpga_simulation_settings(arch_file_name.c_str(), openfpga_context.simulation_setting());
|
||||
|
||||
/* TODO: should identify the error code from internal function execution */
|
||||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ int read_arch(OpenfpgaContext& openfpga_context,
|
|||
int write_arch(const OpenfpgaContext& openfpga_context,
|
||||
const Command& cmd, const CommandContext& cmd_context);
|
||||
|
||||
int read_simulation_setting(OpenfpgaContext& openfpga_context,
|
||||
const Command& cmd, const CommandContext& cmd_context);
|
||||
|
||||
int write_simulation_setting(const OpenfpgaContext& openfpga_context,
|
||||
const Command& cmd, const CommandContext& cmd_context);
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -64,6 +64,55 @@ ShellCommandId add_openfpga_write_arch_command(openfpga::Shell<OpenfpgaContext>&
|
|||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: read_openfpga_simulation_setting
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
static
|
||||
ShellCommandId add_openfpga_read_simulation_setting_command(openfpga::Shell<OpenfpgaContext>& shell,
|
||||
const ShellCommandClassId& cmd_class_id) {
|
||||
Command shell_cmd("read_openfpga_simulation_setting");
|
||||
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId opt_file = shell_cmd.add_option("file", true, "file path to the simulation setting XML");
|
||||
shell_cmd.set_option_short_name(opt_file, "f");
|
||||
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
|
||||
|
||||
/* Add command 'read_openfpga_arch' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(shell_cmd, "read OpenFPGA simulation setting file");
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_execute_function(shell_cmd_id, read_simulation_setting);
|
||||
|
||||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: write_openfpga_simulation_setting
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
static
|
||||
ShellCommandId add_openfpga_write_simulation_setting_command(openfpga::Shell<OpenfpgaContext>& shell,
|
||||
const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds) {
|
||||
Command shell_cmd("write_openfpga_simulation_setting");
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId opt_file = shell_cmd.add_option("file", true, "file path to the simulation setting XML");
|
||||
shell_cmd.set_option_short_name(opt_file, "f");
|
||||
shell_cmd.set_option_require_value(opt_file, openfpga::OPT_STRING);
|
||||
|
||||
/* Add command 'write_openfpga_arch' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(shell_cmd, "write OpenFPGA simulation setting file");
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_const_execute_function(shell_cmd_id, write_simulation_setting);
|
||||
|
||||
/* 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: link_openfpga_arch
|
||||
* - Add associated options
|
||||
|
@ -295,16 +344,33 @@ void add_openfpga_setup_commands(openfpga::Shell<OpenfpgaContext>& shell) {
|
|||
openfpga_setup_cmd_class,
|
||||
write_arch_dependent_cmds);
|
||||
|
||||
/********************************
|
||||
* Command 'read_openfpga_simulation_setting'
|
||||
*/
|
||||
ShellCommandId read_sim_setting_cmd_id = add_openfpga_read_simulation_setting_command(shell,
|
||||
openfpga_setup_cmd_class);
|
||||
|
||||
/********************************
|
||||
* Command 'write_openfpga_simulation_setting'
|
||||
*/
|
||||
/* The 'write_openfpga_simulation_setting' command should NOT be executed before 'read_openfpga_simulation_setting' */
|
||||
std::vector<ShellCommandId> write_sim_setting_dependent_cmds(1, read_sim_setting_cmd_id);
|
||||
add_openfpga_write_simulation_setting_command(shell,
|
||||
openfpga_setup_cmd_class,
|
||||
write_sim_setting_dependent_cmds);
|
||||
|
||||
/********************************
|
||||
* Command 'link_openfpga_arch'
|
||||
*/
|
||||
/* The 'link_openfpga_arch' command should NOT be executed before 'vpr' */
|
||||
std::vector<ShellCommandId> link_arch_dependent_cmds;
|
||||
link_arch_dependent_cmds.push_back(read_arch_cmd_id);
|
||||
link_arch_dependent_cmds.push_back(read_sim_setting_cmd_id);
|
||||
link_arch_dependent_cmds.push_back(vpr_cmd_id);
|
||||
ShellCommandId link_arch_cmd_id = add_openfpga_link_arch_command(shell,
|
||||
openfpga_setup_cmd_class,
|
||||
link_arch_dependent_cmds);
|
||||
|
||||
/********************************
|
||||
* Command 'write_gsb'
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue