[core] now command functions are templates, which can be used by other extensions
This commit is contained in:
parent
e57e5b2d05
commit
93c00207ab
|
@ -1,23 +0,0 @@
|
|||
#ifndef OPENFPGA_SPICE_H
|
||||
#define OPENFPGA_SPICE_H
|
||||
|
||||
/********************************************************************
|
||||
* Include header files that are required by function declaration
|
||||
*******************************************************************/
|
||||
#include "command.h"
|
||||
#include "command_context.h"
|
||||
#include "openfpga_context.h"
|
||||
|
||||
/********************************************************************
|
||||
* Function declaration
|
||||
*******************************************************************/
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
int write_fabric_spice(OpenfpgaContext& openfpga_ctx, const Command& cmd,
|
||||
const CommandContext& cmd_context);
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
|
@ -1,94 +1,11 @@
|
|||
/********************************************************************
|
||||
* Add commands to the OpenFPGA shell interface,
|
||||
* in purpose of generate SPICE netlists modeling the full FPGA fabric
|
||||
* This is one of the core engine of openfpga, including:
|
||||
* - generate_fabric_spice : generate Verilog netlists about FPGA fabric
|
||||
* - TODO: generate_spice_top_testbench : generate SPICE testbenches for
|
||||
*top-level module
|
||||
* - TODO: generate_spice_grid_testbench : generate SPICE testbenches for grids
|
||||
* - TODO: generate_spice_cb_testbench : generate SPICE testbenches for
|
||||
*connection blocks
|
||||
* - TODO: generate_spice_sb_testbench : generate SPICE testbenches for switch
|
||||
*blocks
|
||||
* - TODO: generate_spice_lut_testbench : generate SPICE testbenches for Look-Up
|
||||
*Tables
|
||||
* - TODO: generate_spice_hard_logic_testbench : generate SPICE testbenches for
|
||||
*all the hard logics
|
||||
* - TODO: generate_spice_local_routing_testbench : generate SPICE testbenches
|
||||
*for local routing
|
||||
* - TODO: generate_spice_cb_routing_testbench : generate SPICE testbenches for
|
||||
*routing circuit inside connection blocks
|
||||
* - TODO: generate_spice_sb_routing_testbench : generate SPICE testbenches for
|
||||
*routing circuit inside switch blocks
|
||||
*******************************************************************/
|
||||
#include "openfpga_spice_command_template.h"
|
||||
#include "openfpga_spice_command.h"
|
||||
|
||||
#include "openfpga_spice.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: generate fabric Verilog
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
static ShellCommandId add_openfpga_write_fabric_spice_command(
|
||||
openfpga::Shell<OpenfpgaContext>& shell,
|
||||
const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds) {
|
||||
Command shell_cmd("write_fabric_spice");
|
||||
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId output_opt = shell_cmd.add_option(
|
||||
"file", true, "Specify the output directory for SPICE netlists");
|
||||
shell_cmd.set_option_short_name(output_opt, "f");
|
||||
shell_cmd.set_option_require_value(output_opt, openfpga::OPT_STRING);
|
||||
|
||||
/* Add an option '--explicit_port_mapping' */
|
||||
shell_cmd.add_option("explicit_port_mapping", false,
|
||||
"Use explicit port mapping in Verilog netlists");
|
||||
|
||||
/* Add an option '--verbose' */
|
||||
shell_cmd.add_option("verbose", false, "Enable verbose output");
|
||||
|
||||
/* Add command 'write_fabric_spice' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(
|
||||
shell_cmd, "generate SPICE netlists modeling full FPGA fabric");
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_execute_function(shell_cmd_id, write_fabric_spice);
|
||||
|
||||
/* Add command dependency to the Shell */
|
||||
shell.set_command_dependency(shell_cmd_id, dependent_cmds);
|
||||
|
||||
return shell_cmd_id;
|
||||
}
|
||||
|
||||
void add_openfpga_spice_commands(openfpga::Shell<OpenfpgaContext>& shell) {
|
||||
/* Get the unique id of 'build_fabric' command which is to be used in creating
|
||||
* the dependency graph */
|
||||
const ShellCommandId& build_fabric_cmd_id =
|
||||
shell.command(std::string("build_fabric"));
|
||||
|
||||
/* Add a new class of commands */
|
||||
ShellCommandClassId openfpga_spice_cmd_class =
|
||||
shell.add_command_class("FPGA-SPICE");
|
||||
|
||||
/********************************
|
||||
* Command 'write_fabric_spice'
|
||||
*/
|
||||
/* The 'write_fabric_spice' command should NOT be executed before
|
||||
* 'build_fabric' */
|
||||
std::vector<ShellCommandId> fabric_spice_dependent_cmds;
|
||||
fabric_spice_dependent_cmds.push_back(build_fabric_cmd_id);
|
||||
add_openfpga_write_fabric_spice_command(shell, openfpga_spice_cmd_class,
|
||||
fabric_spice_dependent_cmds);
|
||||
|
||||
/********************************
|
||||
* TODO: Command 'write_spice_top_testbench'
|
||||
*/
|
||||
/* The command 'write_spice_top_testbench' should NOT be executed before
|
||||
* 'build_fabric' */
|
||||
add_spice_command_templates<OpenfpgaContext>(shell);
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
#ifndef OPENFPGA_SPICE_COMMAND_TEMPLATE_H
|
||||
#define OPENFPGA_SPICE_COMMAND_TEMPLATE_H
|
||||
|
||||
/********************************************************************
|
||||
* Add commands to the OpenFPGA shell interface,
|
||||
* in purpose of generate SPICE netlists modeling the full FPGA fabric
|
||||
* This is one of the core engine of openfpga, including:
|
||||
* - generate_fabric_spice : generate Verilog netlists about FPGA fabric
|
||||
* - TODO: generate_spice_top_testbench : generate SPICE testbenches for
|
||||
*top-level module
|
||||
* - TODO: generate_spice_grid_testbench : generate SPICE testbenches for grids
|
||||
* - TODO: generate_spice_cb_testbench : generate SPICE testbenches for
|
||||
*connection blocks
|
||||
* - TODO: generate_spice_sb_testbench : generate SPICE testbenches for switch
|
||||
*blocks
|
||||
* - TODO: generate_spice_lut_testbench : generate SPICE testbenches for Look-Up
|
||||
*Tables
|
||||
* - TODO: generate_spice_hard_logic_testbench : generate SPICE testbenches for
|
||||
*all the hard logics
|
||||
* - TODO: generate_spice_local_routing_testbench : generate SPICE testbenches
|
||||
*for local routing
|
||||
* - TODO: generate_spice_cb_routing_testbench : generate SPICE testbenches for
|
||||
*routing circuit inside connection blocks
|
||||
* - TODO: generate_spice_sb_routing_testbench : generate SPICE testbenches for
|
||||
*routing circuit inside switch blocks
|
||||
*******************************************************************/
|
||||
#include "shell.h"
|
||||
#include "openfpga_spice_template.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
||||
/********************************************************************
|
||||
* - Add a command to Shell environment: generate fabric Verilog
|
||||
* - Add associated options
|
||||
* - Add command dependency
|
||||
*******************************************************************/
|
||||
template <class T>
|
||||
ShellCommandId add_write_fabric_spice_command_template(
|
||||
openfpga::Shell<T>& shell,
|
||||
const ShellCommandClassId& cmd_class_id,
|
||||
const std::vector<ShellCommandId>& dependent_cmds) {
|
||||
Command shell_cmd("write_fabric_spice");
|
||||
|
||||
/* Add an option '--file' in short '-f'*/
|
||||
CommandOptionId output_opt = shell_cmd.add_option(
|
||||
"file", true, "Specify the output directory for SPICE netlists");
|
||||
shell_cmd.set_option_short_name(output_opt, "f");
|
||||
shell_cmd.set_option_require_value(output_opt, openfpga::OPT_STRING);
|
||||
|
||||
/* Add an option '--explicit_port_mapping' */
|
||||
shell_cmd.add_option("explicit_port_mapping", false,
|
||||
"Use explicit port mapping in Verilog netlists");
|
||||
|
||||
/* Add an option '--verbose' */
|
||||
shell_cmd.add_option("verbose", false, "Enable verbose output");
|
||||
|
||||
/* Add command 'write_fabric_spice' to the Shell */
|
||||
ShellCommandId shell_cmd_id = shell.add_command(
|
||||
shell_cmd, "generate SPICE netlists modeling full FPGA fabric");
|
||||
shell.set_command_class(shell_cmd_id, cmd_class_id);
|
||||
shell.set_command_execute_function(shell_cmd_id, write_fabric_spice_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_spice_command_templates(openfpga::Shell<T>& shell) {
|
||||
/* Get the unique id of 'build_fabric' command which is to be used in creating
|
||||
* the dependency graph */
|
||||
const ShellCommandId& build_fabric_cmd_id =
|
||||
shell.command(std::string("build_fabric"));
|
||||
|
||||
/* Add a new class of commands */
|
||||
ShellCommandClassId openfpga_spice_cmd_class =
|
||||
shell.add_command_class("FPGA-SPICE");
|
||||
|
||||
/********************************
|
||||
* Command 'write_fabric_spice'
|
||||
*/
|
||||
/* The 'write_fabric_spice' command should NOT be executed before
|
||||
* 'build_fabric' */
|
||||
std::vector<ShellCommandId> fabric_spice_dependent_cmds;
|
||||
fabric_spice_dependent_cmds.push_back(build_fabric_cmd_id);
|
||||
add_write_fabric_spice_command_template<T>(shell, openfpga_spice_cmd_class,
|
||||
fabric_spice_dependent_cmds);
|
||||
|
||||
/********************************
|
||||
* TODO: Command 'write_spice_top_testbench'
|
||||
*/
|
||||
/* The command 'write_spice_top_testbench' should NOT be executed before
|
||||
* 'build_fabric' */
|
||||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
|
@ -1,16 +1,12 @@
|
|||
/********************************************************************
|
||||
* This file includes functions to compress the hierachy of routing architecture
|
||||
*******************************************************************/
|
||||
/* Headers from vtrutil library */
|
||||
#ifndef OPENFPGA_SPICE_TEMPLATE_H
|
||||
#define OPENFPGA_SPICE_TEMPLATE_H
|
||||
|
||||
#include "vtr_log.h"
|
||||
#include "vtr_time.h"
|
||||
|
||||
/* Headers from openfpgashell library */
|
||||
#include "command_exit_codes.h"
|
||||
#include "openfpga_spice.h"
|
||||
#include "spice_api.h"
|
||||
|
||||
/* Include global variables of VPR */
|
||||
#include "command.h"
|
||||
#include "command_context.h"
|
||||
#include "globals.h"
|
||||
|
||||
/* begin namespace openfpga */
|
||||
|
@ -19,8 +15,9 @@ namespace openfpga {
|
|||
/********************************************************************
|
||||
* A wrapper function to call the fabric SPICE generator of FPGA-SPICE
|
||||
*******************************************************************/
|
||||
int write_fabric_spice(OpenfpgaContext& openfpga_ctx, const Command& cmd,
|
||||
const CommandContext& cmd_context) {
|
||||
template <class T>
|
||||
int write_fabric_spice_template(T& openfpga_ctx, const Command& cmd,
|
||||
const CommandContext& cmd_context) {
|
||||
CommandOptionId opt_output_dir = cmd.option("file");
|
||||
CommandOptionId opt_explicit_port_mapping =
|
||||
cmd.option("explicit_port_mapping");
|
||||
|
@ -47,3 +44,5 @@ int write_fabric_spice(OpenfpgaContext& openfpga_ctx, const Command& cmd,
|
|||
}
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue