2023-01-06 19:48:00 -06:00
|
|
|
#ifndef OPENFPGA_VERILOG_TEMPLATE_H
|
|
|
|
#define OPENFPGA_VERILOG_TEMPLATE_H
|
|
|
|
|
2020-02-15 21:54:37 -06:00
|
|
|
/********************************************************************
|
|
|
|
* This file includes functions to compress the hierachy of routing architecture
|
|
|
|
*******************************************************************/
|
2023-01-06 19:48:00 -06:00
|
|
|
#include "command.h"
|
|
|
|
#include "command_context.h"
|
2023-01-06 19:50:47 -06:00
|
|
|
#include "command_exit_codes.h"
|
2020-02-15 21:54:37 -06:00
|
|
|
#include "globals.h"
|
2023-01-06 19:50:47 -06:00
|
|
|
#include "openfpga_scale.h"
|
|
|
|
#include "read_xml_bus_group.h"
|
|
|
|
#include "read_xml_pin_constraints.h"
|
|
|
|
#include "verilog_api.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
#include "vtr_time.h"
|
2020-02-15 21:54:37 -06:00
|
|
|
|
|
|
|
/* begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* A wrapper function to call the fabric Verilog generator of FPGA-Verilog
|
2020-02-15 21:54:37 -06:00
|
|
|
*******************************************************************/
|
2023-01-06 19:50:47 -06:00
|
|
|
template <class T>
|
2023-01-06 19:48:00 -06:00
|
|
|
int write_fabric_verilog_template(T& openfpga_ctx, const Command& cmd,
|
2023-01-06 19:50:47 -06:00
|
|
|
const CommandContext& cmd_context) {
|
2020-02-15 21:54:37 -06:00
|
|
|
CommandOptionId opt_output_dir = cmd.option("file");
|
2022-10-06 19:08:50 -05:00
|
|
|
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");
|
2022-10-06 19:08:50 -05: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");
|
2022-01-25 14:09:08 -06:00
|
|
|
CommandOptionId opt_no_time_stamp = cmd.option("no_time_stamp");
|
2022-01-31 14:48:05 -06:00
|
|
|
CommandOptionId opt_use_relative_path = cmd.option("use_relative_path");
|
2020-02-15 21:54:37 -06:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
2020-02-15 22:39:47 -06:00
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/* This is an intermediate data structure which is designed to modularize the
|
|
|
|
* FPGA-Verilog Keep it independent from any other outside data structures
|
2020-02-15 22:39:47 -06:00
|
|
|
*/
|
|
|
|
FabricVerilogOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
2022-10-06 19:08:50 -05:00
|
|
|
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));
|
2022-01-25 14:09:08 -06:00
|
|
|
options.set_time_stamp(!cmd_context.option_enable(cmd, opt_no_time_stamp));
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_use_relative_path(
|
|
|
|
cmd_context.option_enable(cmd, opt_use_relative_path));
|
|
|
|
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)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_default_net_type(
|
|
|
|
cmd_context.option_value(cmd, opt_default_net_type));
|
2021-02-28 12:57:40 -06:00
|
|
|
}
|
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());
|
2022-10-06 19:08:50 -05: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(),
|
2021-09-29 22:56:02 -05:00
|
|
|
openfpga_ctx.blwl_shift_register_banks(),
|
2022-10-06 19:08:50 -05:00
|
|
|
openfpga_ctx.arch().circuit_lib, openfpga_ctx.mux_lib(),
|
|
|
|
openfpga_ctx.decoder_lib(), g_vpr_ctx.device(),
|
2020-02-16 17:04:41 -06:00
|
|
|
openfpga_ctx.vpr_device_annotation(),
|
2022-10-06 19:08:50 -05:00
|
|
|
openfpga_ctx.device_rr_gsb(), options);
|
2020-04-08 17:18:05 -05:00
|
|
|
|
|
|
|
/* TODO: should identify the error code from internal function execution */
|
|
|
|
return CMD_EXEC_SUCCESS;
|
2022-10-06 19:08:50 -05:00
|
|
|
}
|
2020-02-15 21:54:37 -06:00
|
|
|
|
2021-06-03 16:37:49 -05:00
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* A wrapper function to call the full testbench generator of FPGA-Verilog
|
2021-06-03 16:37:49 -05:00
|
|
|
*******************************************************************/
|
2023-01-06 19:50:47 -06:00
|
|
|
template <class T>
|
|
|
|
int write_full_testbench_template(const T& openfpga_ctx, const Command& cmd,
|
|
|
|
const CommandContext& cmd_context) {
|
2021-06-03 16:37:49 -05:00
|
|
|
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");
|
2022-02-18 01:14:28 -06:00
|
|
|
CommandOptionId opt_bgf = cmd.option("bus_group_file");
|
2022-10-06 19:08:50 -05:00
|
|
|
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");
|
2022-10-06 19:08:50 -05:00
|
|
|
CommandOptionId opt_explicit_port_mapping =
|
|
|
|
cmd.option("explicit_port_mapping");
|
2021-06-14 12:37:49 -05:00
|
|
|
CommandOptionId opt_default_net_type = cmd.option("default_net_type");
|
2021-06-03 16:37:49 -05:00
|
|
|
CommandOptionId opt_include_signal_init = cmd.option("include_signal_init");
|
2022-01-25 14:09:08 -06:00
|
|
|
CommandOptionId opt_no_time_stamp = cmd.option("no_time_stamp");
|
2022-02-01 14:17:02 -06:00
|
|
|
CommandOptionId opt_use_relative_path = cmd.option("use_relative_path");
|
2021-06-03 16:37:49 -05:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/* This is an intermediate data structure which is designed to modularize the
|
|
|
|
* FPGA-Verilog Keep it independent from any other outside data structures
|
2021-06-03 16:37:49 -05:00
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
2022-10-06 19:08:50 -05:00
|
|
|
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));
|
|
|
|
options.set_fast_configuration(
|
|
|
|
cmd_context.option_enable(cmd, opt_fast_configuration));
|
|
|
|
options.set_explicit_port_mapping(
|
|
|
|
cmd_context.option_enable(cmd, opt_explicit_port_mapping));
|
2021-06-03 16:37:49 -05:00
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
2022-01-25 14:09:08 -06:00
|
|
|
options.set_time_stamp(!cmd_context.option_enable(cmd, opt_no_time_stamp));
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_use_relative_path(
|
|
|
|
cmd_context.option_enable(cmd, opt_use_relative_path));
|
2021-06-03 16:37:49 -05:00
|
|
|
options.set_print_top_testbench(true);
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_include_signal_init(
|
|
|
|
cmd_context.option_enable(cmd, opt_include_signal_init));
|
2021-06-14 12:37:49 -05:00
|
|
|
if (true == cmd_context.option_enable(cmd, opt_default_net_type)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_default_net_type(
|
|
|
|
cmd_context.option_value(cmd, opt_default_net_type));
|
2021-06-14 12:37:49 -05:00
|
|
|
}
|
2021-06-03 16:37:49 -05:00
|
|
|
|
|
|
|
/* If pin constraints are enabled by command options, read the file */
|
|
|
|
PinConstraints pin_constraints;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_pcf)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
pin_constraints =
|
|
|
|
read_xml_pin_constraints(cmd_context.option_value(cmd, opt_pcf).c_str());
|
2021-06-03 16:37:49 -05:00
|
|
|
}
|
2022-02-18 01:14:28 -06:00
|
|
|
|
|
|
|
/* If bug group file are enabled by command options, read the file */
|
|
|
|
BusGroup bus_group;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_bgf)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
bus_group =
|
|
|
|
read_xml_bus_group(cmd_context.option_value(cmd, opt_bgf).c_str());
|
2022-02-18 01:14:28 -06:00
|
|
|
}
|
2022-10-06 19:08:50 -05:00
|
|
|
|
|
|
|
return fpga_verilog_full_testbench(
|
|
|
|
openfpga_ctx.module_graph(), openfpga_ctx.bitstream_manager(),
|
|
|
|
openfpga_ctx.fabric_bitstream(), openfpga_ctx.blwl_shift_register_banks(),
|
|
|
|
g_vpr_ctx.atom(), g_vpr_ctx.placement(), pin_constraints, bus_group,
|
|
|
|
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-03 16:37:49 -05:00
|
|
|
|
2021-06-08 22:28:16 -05:00
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* A wrapper function to call the preconfigured wrapper generator of
|
|
|
|
*FPGA-Verilog
|
2021-06-08 22:28:16 -05:00
|
|
|
*******************************************************************/
|
2023-01-06 19:50:47 -06:00
|
|
|
template <class T>
|
|
|
|
int write_preconfigured_fabric_wrapper_template(
|
|
|
|
const T& openfpga_ctx, const Command& cmd,
|
|
|
|
const CommandContext& cmd_context) {
|
2021-06-08 22:28:16 -05:00
|
|
|
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");
|
2022-02-18 01:14:28 -06:00
|
|
|
CommandOptionId opt_bgf = cmd.option("bus_group_file");
|
2022-10-06 19:08:50 -05:00
|
|
|
CommandOptionId opt_explicit_port_mapping =
|
|
|
|
cmd.option("explicit_port_mapping");
|
2021-06-14 12:37:49 -05:00
|
|
|
CommandOptionId opt_default_net_type = cmd.option("default_net_type");
|
2021-06-24 18:07:41 -05:00
|
|
|
CommandOptionId opt_include_signal_init = cmd.option("include_signal_init");
|
2021-06-25 16:22:42 -05:00
|
|
|
CommandOptionId opt_embed_bitstream = cmd.option("embed_bitstream");
|
2022-01-25 14:09:08 -06:00
|
|
|
CommandOptionId opt_no_time_stamp = cmd.option("no_time_stamp");
|
2021-06-08 22:28:16 -05:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/* This is an intermediate data structure which is designed to modularize the
|
|
|
|
* FPGA-Verilog Keep it independent from any other outside data structures
|
2021-06-08 22:28:16 -05:00
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
2022-10-06 19:08:50 -05:00
|
|
|
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));
|
2022-01-25 14:09:08 -06:00
|
|
|
options.set_time_stamp(!cmd_context.option_enable(cmd, opt_no_time_stamp));
|
2021-06-08 22:28:16 -05:00
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_include_signal_init(
|
|
|
|
cmd_context.option_enable(cmd, opt_include_signal_init));
|
2021-06-08 22:28:16 -05:00
|
|
|
options.set_print_formal_verification_top_netlist(true);
|
2021-06-25 16:22:42 -05:00
|
|
|
|
2021-06-14 12:37:49 -05:00
|
|
|
if (true == cmd_context.option_enable(cmd, opt_default_net_type)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_default_net_type(
|
|
|
|
cmd_context.option_value(cmd, opt_default_net_type));
|
2021-06-14 12:37:49 -05:00
|
|
|
}
|
2021-06-08 22:28:16 -05:00
|
|
|
|
2021-06-25 16:22:42 -05:00
|
|
|
if (true == cmd_context.option_enable(cmd, opt_embed_bitstream)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_embedded_bitstream_hdl_type(
|
|
|
|
cmd_context.option_value(cmd, opt_embed_bitstream));
|
2021-06-25 16:22:42 -05:00
|
|
|
}
|
|
|
|
|
2021-06-08 22:28:16 -05:00
|
|
|
/* If pin constraints are enabled by command options, read the file */
|
|
|
|
PinConstraints pin_constraints;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_pcf)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
pin_constraints =
|
|
|
|
read_xml_pin_constraints(cmd_context.option_value(cmd, opt_pcf).c_str());
|
2021-06-08 22:28:16 -05:00
|
|
|
}
|
2022-02-18 01:14:28 -06:00
|
|
|
|
|
|
|
/* If bug group file are enabled by command options, read the file */
|
|
|
|
BusGroup bus_group;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_bgf)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
bus_group =
|
|
|
|
read_xml_bus_group(cmd_context.option_value(cmd, opt_bgf).c_str());
|
2022-02-18 01:14:28 -06:00
|
|
|
}
|
2022-10-06 19:08:50 -05:00
|
|
|
|
|
|
|
return fpga_verilog_preconfigured_fabric_wrapper(
|
|
|
|
openfpga_ctx.module_graph(), openfpga_ctx.bitstream_manager(),
|
|
|
|
g_vpr_ctx.atom(), g_vpr_ctx.placement(), pin_constraints, bus_group,
|
|
|
|
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
|
|
|
|
2021-06-08 22:53:51 -05:00
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* A wrapper function to call the preconfigured testbench generator of
|
|
|
|
*FPGA-Verilog
|
2021-06-08 22:53:51 -05:00
|
|
|
*******************************************************************/
|
2023-01-06 19:50:47 -06:00
|
|
|
template <class T>
|
2023-01-06 19:48:00 -06:00
|
|
|
int write_preconfigured_testbench_template(const T& openfpga_ctx,
|
2023-01-06 19:50:47 -06:00
|
|
|
const Command& cmd,
|
|
|
|
const CommandContext& cmd_context) {
|
2021-06-08 22:53:51 -05:00
|
|
|
CommandOptionId opt_output_dir = cmd.option("file");
|
|
|
|
CommandOptionId opt_pcf = cmd.option("pin_constraints_file");
|
2022-02-18 01:48:44 -06:00
|
|
|
CommandOptionId opt_bgf = cmd.option("bus_group_file");
|
2021-06-09 12:14:45 -05:00
|
|
|
CommandOptionId opt_fabric_netlist = cmd.option("fabric_netlist_file_path");
|
2022-10-06 19:08:50 -05:00
|
|
|
CommandOptionId opt_reference_benchmark =
|
|
|
|
cmd.option("reference_benchmark_file_path");
|
|
|
|
CommandOptionId opt_explicit_port_mapping =
|
|
|
|
cmd.option("explicit_port_mapping");
|
2021-06-14 12:37:49 -05:00
|
|
|
CommandOptionId opt_default_net_type = cmd.option("default_net_type");
|
2022-01-25 14:09:08 -06:00
|
|
|
CommandOptionId opt_no_time_stamp = cmd.option("no_time_stamp");
|
2022-02-01 15:25:09 -06:00
|
|
|
CommandOptionId opt_use_relative_path = cmd.option("use_relative_path");
|
2021-06-08 22:53:51 -05:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/* This is an intermediate data structure which is designed to modularize the
|
|
|
|
* FPGA-Verilog Keep it independent from any other outside data structures
|
2021-06-08 22:53:51 -05:00
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_output_dir));
|
2022-10-06 19:08:50 -05:00
|
|
|
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));
|
|
|
|
options.set_explicit_port_mapping(
|
|
|
|
cmd_context.option_enable(cmd, opt_explicit_port_mapping));
|
2022-01-25 14:09:08 -06:00
|
|
|
options.set_time_stamp(!cmd_context.option_enable(cmd, opt_no_time_stamp));
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_use_relative_path(
|
|
|
|
cmd_context.option_enable(cmd, opt_use_relative_path));
|
2021-06-08 22:53:51 -05:00
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
|
|
|
options.set_print_preconfig_top_testbench(true);
|
2021-06-14 12:37:49 -05:00
|
|
|
if (true == cmd_context.option_enable(cmd, opt_default_net_type)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_default_net_type(
|
|
|
|
cmd_context.option_value(cmd, opt_default_net_type));
|
2021-06-14 12:37:49 -05:00
|
|
|
}
|
2021-06-08 22:53:51 -05:00
|
|
|
|
|
|
|
/* If pin constraints are enabled by command options, read the file */
|
|
|
|
PinConstraints pin_constraints;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_pcf)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
pin_constraints =
|
|
|
|
read_xml_pin_constraints(cmd_context.option_value(cmd, opt_pcf).c_str());
|
2021-06-08 22:53:51 -05:00
|
|
|
}
|
2022-02-18 01:48:44 -06:00
|
|
|
|
|
|
|
/* If bug group file are enabled by command options, read the file */
|
|
|
|
BusGroup bus_group;
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_bgf)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
bus_group =
|
|
|
|
read_xml_bus_group(cmd_context.option_value(cmd, opt_bgf).c_str());
|
2022-02-18 01:48:44 -06:00
|
|
|
}
|
2022-10-06 19:08:50 -05:00
|
|
|
|
|
|
|
return fpga_verilog_preconfigured_testbench(
|
|
|
|
openfpga_ctx.module_graph(), g_vpr_ctx.atom(), pin_constraints, bus_group,
|
|
|
|
openfpga_ctx.fabric_global_port_info(),
|
|
|
|
openfpga_ctx.vpr_netlist_annotation(), openfpga_ctx.simulation_setting(),
|
|
|
|
options);
|
|
|
|
}
|
2021-06-08 22:53:51 -05:00
|
|
|
|
2021-06-08 23:10:02 -05:00
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* A wrapper function to call the simulation task information generator of
|
|
|
|
*FPGA-Verilog
|
2021-06-08 23:10:02 -05:00
|
|
|
*******************************************************************/
|
2023-01-06 19:50:47 -06:00
|
|
|
template <class T>
|
2023-01-06 19:48:00 -06:00
|
|
|
int write_simulation_task_info_template(const T& openfpga_ctx,
|
2023-01-06 19:50:47 -06:00
|
|
|
const Command& cmd,
|
|
|
|
const CommandContext& cmd_context) {
|
2021-06-09 11:49:00 -05:00
|
|
|
CommandOptionId opt_file = cmd.option("file");
|
|
|
|
CommandOptionId opt_hdl_dir = cmd.option("hdl_dir");
|
2022-10-06 19:08:50 -05:00
|
|
|
CommandOptionId opt_reference_benchmark =
|
|
|
|
cmd.option("reference_benchmark_file_path");
|
2021-06-25 11:10:16 -05:00
|
|
|
CommandOptionId opt_tb_type = cmd.option("testbench_type");
|
2021-06-25 11:33:29 -05:00
|
|
|
CommandOptionId opt_time_unit = cmd.option("time_unit");
|
2021-06-08 23:10:02 -05:00
|
|
|
CommandOptionId opt_verbose = cmd.option("verbose");
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/* This is an intermediate data structure which is designed to modularize the
|
|
|
|
* FPGA-Verilog Keep it independent from any other outside data structures
|
2021-06-08 23:10:02 -05:00
|
|
|
*/
|
|
|
|
VerilogTestbenchOption options;
|
2021-06-09 11:49:00 -05:00
|
|
|
options.set_output_directory(cmd_context.option_value(cmd, opt_hdl_dir));
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_reference_benchmark_file_path(
|
|
|
|
cmd_context.option_value(cmd, opt_reference_benchmark));
|
2021-06-08 23:10:02 -05:00
|
|
|
options.set_verbose_output(cmd_context.option_enable(cmd, opt_verbose));
|
2021-06-09 11:49:00 -05:00
|
|
|
options.set_print_simulation_ini(cmd_context.option_value(cmd, opt_file));
|
2021-06-08 23:10:02 -05:00
|
|
|
|
2021-06-25 11:33:29 -05:00
|
|
|
if (true == cmd_context.option_enable(cmd, opt_time_unit)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
options.set_time_unit(
|
|
|
|
string_to_time_unit(cmd_context.option_value(cmd, opt_time_unit)));
|
2021-06-25 11:33:29 -05:00
|
|
|
}
|
|
|
|
|
2021-06-25 11:10:16 -05:00
|
|
|
/* Identify testbench type */
|
|
|
|
std::string full_tb_tag("full_testbench");
|
|
|
|
std::string preconfig_tb_tag("preconfigured_testbench");
|
|
|
|
if (true == cmd_context.option_enable(cmd, opt_tb_type)) {
|
2022-10-06 19:08:50 -05:00
|
|
|
if (std::string("preconfigured_testbench") ==
|
|
|
|
cmd_context.option_value(cmd, opt_tb_type)) {
|
2021-06-25 11:10:16 -05:00
|
|
|
options.set_print_preconfig_top_testbench(true);
|
2022-10-06 19:08:50 -05:00
|
|
|
} else if (std::string("full_testbench") ==
|
|
|
|
cmd_context.option_value(cmd, opt_tb_type)) {
|
2021-06-25 11:10:16 -05:00
|
|
|
options.set_print_preconfig_top_testbench(false);
|
|
|
|
options.set_print_top_testbench(true);
|
|
|
|
} else {
|
|
|
|
/* Invalid option, error out */
|
2022-10-06 19:08:50 -05:00
|
|
|
VTR_LOG_ERROR(
|
|
|
|
"Invalid option value for testbench type: '%s'! Should be either '%s' "
|
|
|
|
"or '%s'\n",
|
|
|
|
cmd_context.option_value(cmd, opt_tb_type).c_str(), full_tb_tag.c_str(),
|
|
|
|
preconfig_tb_tag.c_str());
|
2021-06-25 11:10:16 -05:00
|
|
|
return CMD_EXEC_FATAL_ERROR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Deposit default type which is the preconfigured testbench */
|
|
|
|
options.set_print_preconfig_top_testbench(true);
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
return fpga_verilog_simulation_task_info(
|
|
|
|
openfpga_ctx.module_graph(), openfpga_ctx.bitstream_manager(),
|
|
|
|
g_vpr_ctx.atom(), g_vpr_ctx.placement(), openfpga_ctx.io_location_map(),
|
|
|
|
openfpga_ctx.simulation_setting(), openfpga_ctx.arch().config_protocol,
|
|
|
|
options);
|
|
|
|
}
|
2021-06-08 22:53:51 -05:00
|
|
|
|
2020-02-15 21:54:37 -06:00
|
|
|
} /* end namespace openfpga */
|
2023-01-06 19:48:00 -06:00
|
|
|
|
|
|
|
#endif
|