[core] adding new commands
This commit is contained in:
parent
65b27a3377
commit
e175472a07
|
@ -31,6 +31,7 @@ set_target_properties(libopenfpga PROPERTIES PREFIX "") #Avoid extra 'lib' prefi
|
|||
|
||||
#Specify link-time dependancies
|
||||
target_link_libraries(libopenfpga
|
||||
libclkarchopenfpga
|
||||
libarchopenfpga
|
||||
libopenfpgashell
|
||||
libopenfpgautil
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "vpr_netlist_annotation.h"
|
||||
#include "vpr_placement_annotation.h"
|
||||
#include "vpr_routing_annotation.h"
|
||||
#include "clock_network.h"
|
||||
|
||||
/********************************************************************
|
||||
* This file includes the declaration of the date structure
|
||||
|
@ -61,6 +62,9 @@ class OpenfpgaContext : public Context {
|
|||
const openfpga::BitstreamSetting& bitstream_setting() const {
|
||||
return bitstream_setting_;
|
||||
}
|
||||
const openfpga::ClockNetwork& clock_arch() const {
|
||||
return clock_arch_;
|
||||
}
|
||||
const openfpga::VprDeviceAnnotation& vpr_device_annotation() const {
|
||||
return vpr_device_annotation_;
|
||||
}
|
||||
|
@ -116,6 +120,9 @@ class OpenfpgaContext : public Context {
|
|||
openfpga::BitstreamSetting& mutable_bitstream_setting() {
|
||||
return bitstream_setting_;
|
||||
}
|
||||
openfpga::ClockNetwork& mutable_clock_arch() {
|
||||
return clock_arch_;
|
||||
}
|
||||
openfpga::VprDeviceAnnotation& mutable_vpr_device_annotation() {
|
||||
return vpr_device_annotation_;
|
||||
}
|
||||
|
@ -165,6 +172,7 @@ class OpenfpgaContext : public Context {
|
|||
openfpga::Arch arch_;
|
||||
openfpga::SimulationSetting sim_setting_;
|
||||
openfpga::BitstreamSetting bitstream_setting_;
|
||||
openfpga::ClockNetwork clock_arch_;
|
||||
|
||||
/* Annotation to pb_type of VPR */
|
||||
openfpga::VprDeviceAnnotation vpr_device_annotation_;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "read_xml_openfpga_arch.h"
|
||||
#include "vtr_log.h"
|
||||
#include "write_xml_openfpga_arch.h"
|
||||
#include "read_xml_clock_network.h"
|
||||
#include "write_xml_clock_network.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
@ -209,6 +211,63 @@ int write_bitstream_setting_template(const T& openfpga_context,
|
|||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* Top-level function to read an OpenFPGA bitstream setting file
|
||||
* we use the APIs from the libarchopenfpga library
|
||||
*
|
||||
* The command will accept an option '--file' which is the bitstream setting
|
||||
* file provided by users
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
int read_openfpga_clock_arch_template(T& 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 clock architecture '%s'...\n", arch_file_name.c_str());
|
||||
openfpga_context.mutable_clock_arch() =
|
||||
read_xml_clock_network(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 bitstream 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
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
int write_openfpga_clock_arch_template(const T& 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 clock architecture to '%s'...\n", arch_file_name.c_str());
|
||||
write_xml_clock_network(arch_file_name.c_str(),
|
||||
openfpga_context.clock_arch());
|
||||
|
||||
/* TODO: should identify the error code from internal function execution */
|
||||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -570,6 +570,65 @@ ShellCommandId add_pcf2place_command_template(
|
|||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: read_openfpga_clock_arch
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
ShellCommandId add_read_openfpga_clock_arch_command_template(
|
||||
openfpga::Shell<T>& shell, const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds, const bool& hidden) {
|
||||
Command shell_cmd("read_openfpga_clock_arch");
|
||||
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId opt_file = shell_cmd.add_option(
|
||||
"file", true, "file path to the clock architecture 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_clock_arch' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(
|
||||
shell_cmd, "read OpenFPGA clock architecture file", hidden);
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_execute_function(shell_cmd_id,
|
||||
read_openfpga_clock_arch_template<T>);
|
||||
/* 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: write_openfpga_clock_arch
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
ShellCommandId add_write_openfpga_clock_arch_command_template(
|
||||
openfpga::Shell<T>& shell, const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds, const bool& hidden) {
|
||||
Command shell_cmd("write_openfpga_clock_arch");
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId opt_file = shell_cmd.add_option(
|
||||
"file", true, "file path to the clock architecture 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_clock_arch' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(
|
||||
shell_cmd, "write OpenFPGA clock architecture file", hidden);
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_const_execute_function(shell_cmd_id,
|
||||
write_openfpga_clock_arch_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) {
|
||||
|
@ -636,6 +695,27 @@ void add_setup_command_templates(openfpga::Shell<T>& shell,
|
|||
shell, openfpga_setup_cmd_class, write_bitstream_setting_dependent_cmds,
|
||||
hidden);
|
||||
|
||||
/********************************
|
||||
* Command 'read_openfpga_clock_arch'
|
||||
*/
|
||||
std::vector<ShellCommandId> read_openfpga_clock_arch_dependent_cmds;
|
||||
read_openfpga_clock_arch_dependent_cmds.push_back(vpr_cmd_id);
|
||||
read_openfpga_clock_arch_dependent_cmds.push_back(read_arch_cmd_id);
|
||||
ShellCommandId read_openfpga_clock_arch_cmd_id =
|
||||
add_read_openfpga_clock_arch_command_template<T>(
|
||||
shell, openfpga_setup_cmd_class, read_openfpga_clock_arch_dependent_cmds, hidden);
|
||||
|
||||
/********************************
|
||||
* Command 'write_openfpga_clock_arch'
|
||||
*/
|
||||
/* The 'write_openfpga_clock_arch' command should NOT be executed
|
||||
* before 'read_openfpga_clock_arch' */
|
||||
std::vector<ShellCommandId> write_openfpga_clock_arch_dependent_cmds(
|
||||
1, read_openfpga_clock_arch_cmd_id);
|
||||
add_write_openfpga_clock_arch_command_template<T>(
|
||||
shell, openfpga_setup_cmd_class, write_openfpga_clock_arch_dependent_cmds,
|
||||
hidden);
|
||||
|
||||
/********************************
|
||||
* Command 'link_openfpga_arch'
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue