2020-02-15 21:54:37 -06:00
|
|
|
/********************************************************************
|
|
|
|
* This file includes functions to compress the hierachy of routing architecture
|
|
|
|
*******************************************************************/
|
|
|
|
/* Headers from vtrutil library */
|
|
|
|
#include "vtr_time.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
|
2020-04-08 17:18:05 -05:00
|
|
|
/* Headers from openfpgashell library */
|
|
|
|
#include "command_exit_codes.h"
|
|
|
|
|
2020-02-15 21:54:37 -06:00
|
|
|
#include "verilog_api.h"
|
|
|
|
#include "openfpga_verilog.h"
|
|
|
|
|
2021-01-19 17:56:30 -06:00
|
|
|
/* Headers from pcf library */
|
|
|
|
#include "read_xml_pin_constraints.h"
|
|
|
|
|
2020-02-15 21:54:37 -06:00
|
|
|
/* Include global variables of VPR */
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
2020-02-27 13:33:09 -06:00
|
|
|
* A wrapper function to call the fabric Verilog generator of FPGA-Verilog
|
2020-02-15 21:54:37 -06:00
|
|
|
*******************************************************************/
|
2020-04-08 17:18:05 -05:00
|
|
|
int write_fabric_verilog(OpenfpgaContext& openfpga_ctx,
|
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
2020-02-15 21:54:37 -06:00
|
|
|
|
|
|
|
CommandOptionId opt_output_dir = cmd.option("file");
|
|
|
|
CommandOptionId opt_explicit_port_mapping = cmd.option("explicit_port_mapping");
|
2020-02-15 22:39:47 -06:00
|
|
|
CommandOptionId opt_include_timing = cmd.option("include_timing");
|
2020-02-16 14:35:18 -06:00
|
|
|
CommandOptionId opt_print_user_defined_template = cmd.option("print_user_defined_template");
|
2021-02-28 12:57:40 -06:00
|
|
|
CommandOptionId opt_default_net_type = cmd.option("default_net_type");
|
2020-02-15 21:54:37 -06:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
2020-02-15 22:39:47 -06:00
|
|
|
|
|
|
|
/* This is an intermediate data structure which is designed to modularize the FPGA-Verilog
|
|
|
|
* Keep it independent from any other outside data structures
|
|
|
|
*/
|
|
|
|
FabricVerilogOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
|
|
|
options.set_explicit_port_mapping(cmd_context.option_enable(cmd, opt_explicit_port_mapping));
|
|
|
|
options.set_include_timing(cmd_context.option_enable(cmd, opt_include_timing));
|
2020-02-16 14:35:18 -06:00
|
|
|
options.set_print_user_defined_template(cmd_context.option_enable(cmd, opt_print_user_defined_template));
|
2021-02-28 12:57:40 -06:00
|
|
|
if (true == cmd_context.option_enable(cmd, opt_default_net_type)) {
|
|
|
|
options.set_default_net_type(cmd_context.option_value(cmd, opt_default_net_type));
|
|
|
|
}
|
2020-02-15 22:39:47 -06:00
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
|
|
|
options.set_compress_routing(openfpga_ctx.flow_manager().compress_routing());
|
2020-02-15 21:54:37 -06:00
|
|
|
|
2020-02-16 14:35:18 -06:00
|
|
|
fpga_fabric_verilog(openfpga_ctx.mutable_module_graph(),
|
2020-04-23 21:42:11 -05:00
|
|
|
openfpga_ctx.mutable_verilog_netlists(),
|
2020-02-15 21:54:37 -06:00
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.mux_lib(),
|
2020-05-27 15:25:06 -05:00
|
|
|
openfpga_ctx.decoder_lib(),
|
2020-02-16 17:04:41 -06:00
|
|
|
g_vpr_ctx.device(),
|
|
|
|
openfpga_ctx.vpr_device_annotation(),
|
2020-02-15 21:54:37 -06:00
|
|
|
openfpga_ctx.device_rr_gsb(),
|
2020-02-15 22:39:47 -06:00
|
|
|
options);
|
2020-04-08 17:18:05 -05:00
|
|
|
|
|
|
|
/* TODO: should identify the error code from internal function execution */
|
|
|
|
return CMD_EXEC_SUCCESS;
|
2020-02-15 21:54:37 -06:00
|
|
|
}
|
|
|
|
|
2020-02-27 13:33:09 -06:00
|
|
|
/********************************************************************
|
|
|
|
* A wrapper function to call the Verilog testbench generator of FPGA-Verilog
|
|
|
|
*******************************************************************/
|
2020-04-08 17:18:05 -05:00
|
|
|
int write_verilog_testbench(OpenfpgaContext& openfpga_ctx,
|
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
2020-02-27 13:33:09 -06:00
|
|
|
|
|
|
|
CommandOptionId opt_output_dir = cmd.option("file");
|
2020-10-12 13:31:51 -05:00
|
|
|
CommandOptionId opt_fabric_netlist = cmd.option("fabric_netlist_file_path");
|
2021-01-19 17:56:30 -06:00
|
|
|
CommandOptionId opt_pcf = cmd.option("pin_constraints_file");
|
2020-02-27 14:24:26 -06:00
|
|
|
CommandOptionId opt_reference_benchmark = cmd.option("reference_benchmark_file_path");
|
2020-02-27 13:33:09 -06:00
|
|
|
CommandOptionId opt_print_top_testbench = cmd.option("print_top_testbench");
|
2020-05-29 19:07:21 -05:00
|
|
|
CommandOptionId opt_fast_configuration = cmd.option("fast_configuration");
|
2020-02-27 13:33:09 -06:00
|
|
|
CommandOptionId opt_print_formal_verification_top_netlist = cmd.option("print_formal_verification_top_netlist");
|
|
|
|
CommandOptionId opt_print_preconfig_top_testbench = cmd.option("print_preconfig_top_testbench");
|
|
|
|
CommandOptionId opt_print_simulation_ini = cmd.option("print_simulation_ini");
|
2020-05-22 15:40:05 -05:00
|
|
|
CommandOptionId opt_explicit_port_mapping = cmd.option("explicit_port_mapping");
|
2020-11-22 17:01:31 -06:00
|
|
|
CommandOptionId opt_include_signal_init = cmd.option("include_signal_init");
|
|
|
|
CommandOptionId opt_support_icarus_simulator = cmd.option("support_icarus_simulator");
|
2020-02-27 13:33:09 -06:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
|
|
|
/* This is an intermediate data structure which is designed to modularize the FPGA-Verilog
|
|
|
|
* Keep it independent from any other outside data structures
|
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
2020-10-12 13:31:51 -05:00
|
|
|
options.set_fabric_netlist_file_path(cmd_context.option_value(cmd, opt_fabric_netlist));
|
2020-02-27 14:24:26 -06:00
|
|
|
options.set_reference_benchmark_file_path(cmd_context.option_value(cmd, opt_reference_benchmark));
|
2020-02-27 13:33:09 -06:00
|
|
|
options.set_print_formal_verification_top_netlist(cmd_context.option_enable(cmd, opt_print_formal_verification_top_netlist));
|
|
|
|
options.set_print_preconfig_top_testbench(cmd_context.option_enable(cmd, opt_print_preconfig_top_testbench));
|
2020-05-29 19:07:21 -05:00
|
|
|
options.set_fast_configuration(cmd_context.option_enable(cmd, opt_fast_configuration));
|
2020-02-27 13:33:09 -06:00
|
|
|
options.set_print_top_testbench(cmd_context.option_enable(cmd, opt_print_top_testbench));
|
|
|
|
options.set_print_simulation_ini(cmd_context.option_value(cmd, opt_print_simulation_ini));
|
2020-05-22 15:40:05 -05:00
|
|
|
options.set_explicit_port_mapping(cmd_context.option_enable(cmd, opt_explicit_port_mapping));
|
2020-11-22 17:01:31 -06:00
|
|
|
options.set_include_signal_init(cmd_context.option_enable(cmd, opt_include_signal_init));
|
|
|
|
options.set_support_icarus_simulator(cmd_context.option_enable(cmd, opt_support_icarus_simulator));
|
2020-02-27 13:33:09 -06:00
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
2020-04-08 17:18:05 -05:00
|
|
|
|
2021-01-19 17:56:30 -06:00
|
|
|
/* If pin constraints are enabled by command options, read the file */
|
|
|
|
PinConstraints pin_constraints;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_pcf)) {
|
|
|
|
pin_constraints = read_xml_pin_constraints(cmd_context.option_value(cmd, opt_pcf).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return fpga_verilog_testbench(openfpga_ctx.module_graph(),
|
|
|
|
openfpga_ctx.bitstream_manager(),
|
|
|
|
openfpga_ctx.fabric_bitstream(),
|
|
|
|
g_vpr_ctx.atom(),
|
|
|
|
g_vpr_ctx.placement(),
|
|
|
|
pin_constraints,
|
|
|
|
openfpga_ctx.io_location_map(),
|
|
|
|
openfpga_ctx.fabric_global_port_info(),
|
|
|
|
openfpga_ctx.vpr_netlist_annotation(),
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.simulation_setting(),
|
|
|
|
openfpga_ctx.arch().config_protocol,
|
|
|
|
options);
|
2020-02-27 13:33:09 -06:00
|
|
|
}
|
|
|
|
|
2021-06-03 16:37:49 -05:00
|
|
|
/********************************************************************
|
|
|
|
* A wrapper function to call the full testbench generator of FPGA-Verilog
|
|
|
|
*******************************************************************/
|
2021-06-08 22:28:16 -05:00
|
|
|
int write_full_testbench(const OpenfpgaContext& openfpga_ctx,
|
2021-06-03 16:37:49 -05:00
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
|
|
|
|
|
|
|
CommandOptionId opt_output_dir = cmd.option("file");
|
|
|
|
CommandOptionId opt_bitstream = cmd.option("bitstream");
|
|
|
|
CommandOptionId opt_fabric_netlist = cmd.option("fabric_netlist_file_path");
|
|
|
|
CommandOptionId opt_pcf = cmd.option("pin_constraints_file");
|
|
|
|
CommandOptionId opt_reference_benchmark = cmd.option("reference_benchmark_file_path");
|
2021-06-04 12:26:39 -05:00
|
|
|
CommandOptionId opt_fast_configuration = cmd.option("fast_configuration");
|
2021-06-03 16:37:49 -05:00
|
|
|
CommandOptionId opt_explicit_port_mapping = cmd.option("explicit_port_mapping");
|
|
|
|
CommandOptionId opt_include_signal_init = cmd.option("include_signal_init");
|
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
|
|
|
/* This is an intermediate data structure which is designed to modularize the FPGA-Verilog
|
|
|
|
* Keep it independent from any other outside data structures
|
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
|
|
|
options.set_fabric_netlist_file_path(cmd_context.option_value(cmd, opt_fabric_netlist));
|
|
|
|
options.set_reference_benchmark_file_path(cmd_context.option_value(cmd, opt_reference_benchmark));
|
2021-06-04 12:26:39 -05:00
|
|
|
options.set_fast_configuration(cmd_context.option_enable(cmd, opt_fast_configuration));
|
2021-06-03 16:37:49 -05:00
|
|
|
options.set_explicit_port_mapping(cmd_context.option_enable(cmd, opt_explicit_port_mapping));
|
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
|
|
|
options.set_print_top_testbench(true);
|
|
|
|
options.set_include_signal_init(cmd_context.option_enable(cmd, opt_include_signal_init));
|
|
|
|
|
|
|
|
/* If pin constraints are enabled by command options, read the file */
|
|
|
|
PinConstraints pin_constraints;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_pcf)) {
|
|
|
|
pin_constraints = read_xml_pin_constraints(cmd_context.option_value(cmd, opt_pcf).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return fpga_verilog_full_testbench(openfpga_ctx.module_graph(),
|
|
|
|
openfpga_ctx.bitstream_manager(),
|
|
|
|
openfpga_ctx.fabric_bitstream(),
|
|
|
|
g_vpr_ctx.atom(),
|
|
|
|
g_vpr_ctx.placement(),
|
|
|
|
pin_constraints,
|
|
|
|
cmd_context.option_value(cmd, opt_bitstream),
|
|
|
|
openfpga_ctx.io_location_map(),
|
|
|
|
openfpga_ctx.fabric_global_port_info(),
|
|
|
|
openfpga_ctx.vpr_netlist_annotation(),
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.simulation_setting(),
|
|
|
|
openfpga_ctx.arch().config_protocol,
|
|
|
|
options);
|
|
|
|
}
|
|
|
|
|
2021-06-08 22:28:16 -05:00
|
|
|
/********************************************************************
|
|
|
|
* A wrapper function to call the preconfigured wrapper generator of FPGA-Verilog
|
|
|
|
*******************************************************************/
|
|
|
|
int write_preconfigured_fabric_wrapper(const OpenfpgaContext& openfpga_ctx,
|
|
|
|
const Command& cmd, const CommandContext& cmd_context) {
|
|
|
|
|
|
|
|
CommandOptionId opt_output_dir = cmd.option("file");
|
|
|
|
CommandOptionId opt_fabric_netlist = cmd.option("fabric_netlist_file_path");
|
|
|
|
CommandOptionId opt_pcf = cmd.option("pin_constraints_file");
|
|
|
|
CommandOptionId opt_explicit_port_mapping = cmd.option("explicit_port_mapping");
|
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
|
|
|
/* This is an intermediate data structure which is designed to modularize the FPGA-Verilog
|
|
|
|
* Keep it independent from any other outside data structures
|
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
|
|
|
options.set_fabric_netlist_file_path(cmd_context.option_value(cmd, opt_fabric_netlist));
|
|
|
|
options.set_explicit_port_mapping(cmd_context.option_enable(cmd, opt_explicit_port_mapping));
|
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
|
|
|
options.set_print_formal_verification_top_netlist(true);
|
|
|
|
|
|
|
|
/* If pin constraints are enabled by command options, read the file */
|
|
|
|
PinConstraints pin_constraints;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_pcf)) {
|
|
|
|
pin_constraints = read_xml_pin_constraints(cmd_context.option_value(cmd, opt_pcf).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return fpga_verilog_preconfigured_fabric_wrapper(openfpga_ctx.module_graph(),
|
|
|
|
openfpga_ctx.bitstream_manager(),
|
|
|
|
g_vpr_ctx.atom(),
|
|
|
|
g_vpr_ctx.placement(),
|
|
|
|
pin_constraints,
|
|
|
|
openfpga_ctx.io_location_map(),
|
|
|
|
openfpga_ctx.fabric_global_port_info(),
|
|
|
|
openfpga_ctx.vpr_netlist_annotation(),
|
|
|
|
openfpga_ctx.arch().circuit_lib,
|
|
|
|
openfpga_ctx.arch().config_protocol,
|
|
|
|
options);
|
|
|
|
}
|
2021-06-03 16:37:49 -05:00
|
|
|
|
2020-02-15 21:54:37 -06:00
|
|
|
} /* end namespace openfpga */
|