2020-07-05 13:10:12 -05:00
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* Add commands to the OpenFPGA shell interface,
|
2020-07-05 13:10:12 -05:00
|
|
|
* in purpose of generate SPICE netlists modeling the full FPGA fabric
|
|
|
|
* This is one of the core engine of openfpga, including:
|
2022-10-06 19:08:50 -05:00
|
|
|
* - generate_fabric_spice : generate Verilog netlists about FPGA fabric
|
|
|
|
* - TODO: generate_spice_top_testbench : generate SPICE testbenches for
|
|
|
|
*top-level module
|
2020-07-05 13:10:12 -05:00
|
|
|
* - TODO: generate_spice_grid_testbench : generate SPICE testbenches for grids
|
2022-10-06 19:08:50 -05:00
|
|
|
* - 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
|
2020-07-05 13:10:12 -05:00
|
|
|
*******************************************************************/
|
|
|
|
#include "openfpga_spice_command.h"
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
#include "openfpga_spice.h"
|
|
|
|
|
2020-07-05 13:10:12 -05:00
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* - Add a command to Shell environment: generate fabric Verilog
|
|
|
|
* - Add associated options
|
2020-07-05 13:10:12 -05:00
|
|
|
* - Add command dependency
|
|
|
|
*******************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
static ShellCommandId add_openfpga_write_fabric_spice_command(
|
|
|
|
openfpga::Shell<OpenfpgaContext>& shell,
|
|
|
|
const ShellCommandClassId& cmd_class_id,
|
|
|
|
const std::vector<ShellCommandId>& dependent_cmds) {
|
2020-07-05 13:10:12 -05:00
|
|
|
Command shell_cmd("write_fabric_spice");
|
|
|
|
|
|
|
|
/* Add an option '--file' in short '-f'*/
|
2022-10-06 19:08:50 -05:00
|
|
|
CommandOptionId output_opt = shell_cmd.add_option(
|
|
|
|
"file", true, "Specify the output directory for SPICE netlists");
|
2020-07-05 13:10:12 -05:00
|
|
|
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' */
|
2022-10-06 19:08:50 -05:00
|
|
|
shell_cmd.add_option("explicit_port_mapping", false,
|
|
|
|
"Use explicit port mapping in Verilog netlists");
|
2020-07-05 13:10:12 -05:00
|
|
|
|
|
|
|
/* Add an option '--verbose' */
|
|
|
|
shell_cmd.add_option("verbose", false, "Enable verbose output");
|
2022-10-06 19:08:50 -05:00
|
|
|
|
2020-07-05 13:10:12 -05:00
|
|
|
/* Add command 'write_fabric_spice' to the Shell */
|
2022-10-06 19:08:50 -05:00
|
|
|
ShellCommandId shell_cmd_id = shell.add_command(
|
|
|
|
shell_cmd, "generate SPICE netlists modeling full FPGA fabric");
|
2020-07-05 13:10:12 -05:00
|
|
|
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) {
|
2022-10-06 19:08:50 -05:00
|
|
|
/* 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"));
|
2020-07-05 13:10:12 -05:00
|
|
|
|
|
|
|
/* Add a new class of commands */
|
2022-10-06 19:08:50 -05:00
|
|
|
ShellCommandClassId openfpga_spice_cmd_class =
|
|
|
|
shell.add_command_class("FPGA-SPICE");
|
2020-07-05 13:10:12 -05:00
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/********************************
|
|
|
|
* Command 'write_fabric_spice'
|
2020-07-05 13:10:12 -05:00
|
|
|
*/
|
2022-10-06 19:08:50 -05:00
|
|
|
/* The 'write_fabric_spice' command should NOT be executed before
|
|
|
|
* 'build_fabric' */
|
2020-07-05 13:10:12 -05:00
|
|
|
std::vector<ShellCommandId> fabric_spice_dependent_cmds;
|
|
|
|
fabric_spice_dependent_cmds.push_back(build_fabric_cmd_id);
|
2022-10-06 19:08:50 -05:00
|
|
|
add_openfpga_write_fabric_spice_command(shell, openfpga_spice_cmd_class,
|
2020-07-05 13:10:12 -05:00
|
|
|
fabric_spice_dependent_cmds);
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/********************************
|
|
|
|
* TODO: Command 'write_spice_top_testbench'
|
2020-07-05 13:10:12 -05:00
|
|
|
*/
|
2022-10-06 19:08:50 -05:00
|
|
|
/* The command 'write_spice_top_testbench' should NOT be executed before
|
|
|
|
* 'build_fabric' */
|
|
|
|
}
|
2020-07-05 13:10:12 -05:00
|
|
|
|
|
|
|
} /* end namespace openfpga */
|