2020-02-27 13:33:09 -06:00
/******************************************************************************
* Memember functions for data structure VerilogTestbenchOption
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "vtr_assert.h"
2020-02-27 14:28:21 -06:00
# include "vtr_log.h"
2020-02-27 13:33:09 -06:00
# include "verilog_testbench_options.h"
/* begin namespace openfpga */
namespace openfpga {
/**************************************************
* Public Constructors
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
VerilogTestbenchOption : : VerilogTestbenchOption ( ) {
output_directory_ . clear ( ) ;
2020-10-12 13:31:51 -05:00
fabric_netlist_file_path_ . clear ( ) ;
2020-02-27 14:24:26 -06:00
reference_benchmark_file_path_ . clear ( ) ;
2020-02-27 13:33:09 -06:00
print_preconfig_top_testbench_ = false ;
print_formal_verification_top_netlist_ = false ;
print_top_testbench_ = false ;
simulation_ini_path_ . clear ( ) ;
2020-05-22 15:40:05 -05:00
explicit_port_mapping_ = false ;
2020-11-22 17:01:31 -06:00
include_signal_init_ = false ;
2021-06-14 12:37:49 -05:00
default_net_type_ = VERILOG_DEFAULT_NET_TYPE_NONE ;
2021-06-25 16:06:07 -05:00
embedded_bitstream_hdl_type_ = EMBEDDED_BITSTREAM_HDL_MODELSIM ;
2021-06-25 11:33:29 -05:00
time_unit_ = 1E-3 ;
2020-02-27 13:33:09 -06:00
verbose_output_ = false ;
}
/**************************************************
* Public Accessors
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
std : : string VerilogTestbenchOption : : output_directory ( ) const {
return output_directory_ ;
}
2020-10-12 13:31:51 -05:00
std : : string VerilogTestbenchOption : : fabric_netlist_file_path ( ) const {
return fabric_netlist_file_path_ ;
}
2020-02-27 14:24:26 -06:00
std : : string VerilogTestbenchOption : : reference_benchmark_file_path ( ) const {
return reference_benchmark_file_path_ ;
2020-02-27 13:33:09 -06:00
}
bool VerilogTestbenchOption : : print_formal_verification_top_netlist ( ) const {
return print_formal_verification_top_netlist_ ;
}
bool VerilogTestbenchOption : : print_preconfig_top_testbench ( ) const {
return print_preconfig_top_testbench_ ;
}
bool VerilogTestbenchOption : : print_top_testbench ( ) const {
return print_top_testbench_ ;
}
2020-05-29 19:07:21 -05:00
bool VerilogTestbenchOption : : fast_configuration ( ) const {
return fast_configuration_ ;
}
2020-02-27 13:33:09 -06:00
bool VerilogTestbenchOption : : print_simulation_ini ( ) const {
return ! simulation_ini_path_ . empty ( ) ;
}
std : : string VerilogTestbenchOption : : simulation_ini_path ( ) const {
return simulation_ini_path_ ;
}
2020-05-22 15:40:05 -05:00
bool VerilogTestbenchOption : : explicit_port_mapping ( ) const {
return explicit_port_mapping_ ;
}
2020-11-22 17:01:31 -06:00
bool VerilogTestbenchOption : : include_signal_init ( ) const {
return include_signal_init_ ;
}
2021-06-29 16:26:40 -05:00
bool VerilogTestbenchOption : : no_self_checking ( ) const {
2021-06-29 16:42:23 -05:00
return reference_benchmark_file_path_ . empty ( ) ;
2021-06-29 16:26:40 -05:00
}
2021-06-14 12:37:49 -05:00
e_verilog_default_net_type VerilogTestbenchOption : : default_net_type ( ) const {
return default_net_type_ ;
}
2021-06-25 11:33:29 -05:00
float VerilogTestbenchOption : : time_unit ( ) const {
return time_unit_ ;
}
2021-06-25 16:06:07 -05:00
e_embedded_bitstream_hdl_type VerilogTestbenchOption : : embedded_bitstream_hdl_type ( ) const {
return embedded_bitstream_hdl_type_ ;
}
2020-02-27 13:33:09 -06:00
bool VerilogTestbenchOption : : verbose_output ( ) const {
return verbose_output_ ;
}
/******************************************************************************
* Private Mutators
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void VerilogTestbenchOption : : set_output_directory ( const std : : string & output_dir ) {
output_directory_ = output_dir ;
}
2020-10-12 13:31:51 -05:00
void VerilogTestbenchOption : : set_fabric_netlist_file_path ( const std : : string & fabric_netlist_file_path ) {
fabric_netlist_file_path_ = fabric_netlist_file_path ;
}
2020-02-27 14:24:26 -06:00
void VerilogTestbenchOption : : set_reference_benchmark_file_path ( const std : : string & reference_benchmark_file_path ) {
reference_benchmark_file_path_ = reference_benchmark_file_path ;
2020-02-27 13:33:09 -06:00
/* Chain effect on other options:
* Enable / disable the print_preconfig_top_testbench and print_top_testbench
*/
set_print_preconfig_top_testbench ( print_preconfig_top_testbench_ ) ;
set_print_top_testbench ( print_top_testbench_ ) ;
}
void VerilogTestbenchOption : : set_print_formal_verification_top_netlist ( const bool & enabled ) {
print_formal_verification_top_netlist_ = enabled ;
}
2020-05-29 19:07:21 -05:00
void VerilogTestbenchOption : : set_fast_configuration ( const bool & enabled ) {
fast_configuration_ = enabled ;
}
2020-02-27 13:33:09 -06:00
void VerilogTestbenchOption : : set_print_preconfig_top_testbench ( const bool & enabled ) {
print_preconfig_top_testbench_ = enabled
2020-02-27 14:24:26 -06:00
& & ( ! reference_benchmark_file_path_ . empty ( ) ) ;
/* Enable print formal verification top_netlist if this is enabled */
if ( true = = print_preconfig_top_testbench_ ) {
2020-02-27 14:28:21 -06:00
if ( false = = print_formal_verification_top_netlist_ ) {
VTR_LOG_WARN ( " Forcely enable to print top-level Verilog netlist in formal verification purpose as print pre-configured top-level Verilog testbench is enabled \n " ) ;
print_formal_verification_top_netlist_ = true ;
}
2020-02-27 14:24:26 -06:00
}
2020-02-27 13:33:09 -06:00
}
void VerilogTestbenchOption : : set_print_top_testbench ( const bool & enabled ) {
2020-02-27 14:24:26 -06:00
print_top_testbench_ = enabled & & ( ! reference_benchmark_file_path_ . empty ( ) ) ;
2020-02-27 13:33:09 -06:00
}
void VerilogTestbenchOption : : set_print_simulation_ini ( const std : : string & simulation_ini_path ) {
simulation_ini_path_ = simulation_ini_path ;
}
2020-05-22 15:40:05 -05:00
void VerilogTestbenchOption : : set_explicit_port_mapping ( const bool & enabled ) {
explicit_port_mapping_ = enabled ;
}
2020-11-22 17:01:31 -06:00
void VerilogTestbenchOption : : set_include_signal_init ( const bool & enabled ) {
include_signal_init_ = enabled ;
}
2021-06-14 12:37:49 -05:00
void VerilogTestbenchOption : : set_default_net_type ( const std : : string & default_net_type ) {
/* Decode from net type string */ ;
if ( default_net_type = = std : : string ( VERILOG_DEFAULT_NET_TYPE_STRING [ VERILOG_DEFAULT_NET_TYPE_NONE ] ) ) {
default_net_type_ = VERILOG_DEFAULT_NET_TYPE_NONE ;
} else if ( default_net_type = = std : : string ( VERILOG_DEFAULT_NET_TYPE_STRING [ VERILOG_DEFAULT_NET_TYPE_WIRE ] ) ) {
default_net_type_ = VERILOG_DEFAULT_NET_TYPE_WIRE ;
} else {
VTR_LOG_WARN ( " Invalid default net type: '%s'! Expect ['%s'|'%s'] \n " ,
default_net_type . c_str ( ) ,
VERILOG_DEFAULT_NET_TYPE_STRING [ VERILOG_DEFAULT_NET_TYPE_NONE ] ,
VERILOG_DEFAULT_NET_TYPE_STRING [ VERILOG_DEFAULT_NET_TYPE_WIRE ] ) ;
}
}
2021-06-25 16:06:07 -05:00
void VerilogTestbenchOption : : set_embedded_bitstream_hdl_type ( const std : : string & embedded_bitstream_hdl_type ) {
/* Decode from HDL type string */ ;
if ( embedded_bitstream_hdl_type = = std : : string ( EMBEDDED_BITSTREAM_HDL_TYPE_STRING [ NUM_EMBEDDED_BITSTREAM_HDL_TYPES ] ) ) {
embedded_bitstream_hdl_type_ = NUM_EMBEDDED_BITSTREAM_HDL_TYPES ;
} else if ( embedded_bitstream_hdl_type = = std : : string ( EMBEDDED_BITSTREAM_HDL_TYPE_STRING [ EMBEDDED_BITSTREAM_HDL_IVERILOG ] ) ) {
embedded_bitstream_hdl_type_ = EMBEDDED_BITSTREAM_HDL_IVERILOG ;
} else if ( embedded_bitstream_hdl_type = = std : : string ( EMBEDDED_BITSTREAM_HDL_TYPE_STRING [ EMBEDDED_BITSTREAM_HDL_MODELSIM ] ) ) {
embedded_bitstream_hdl_type_ = EMBEDDED_BITSTREAM_HDL_MODELSIM ;
} else {
VTR_LOG_WARN ( " Invalid embedded bitstream type: '%s'! Expect ['%s'|'%s'|'%s'] \n " ,
embedded_bitstream_hdl_type . c_str ( ) ,
EMBEDDED_BITSTREAM_HDL_TYPE_STRING [ NUM_EMBEDDED_BITSTREAM_HDL_TYPES ] ,
EMBEDDED_BITSTREAM_HDL_TYPE_STRING [ EMBEDDED_BITSTREAM_HDL_IVERILOG ] ,
EMBEDDED_BITSTREAM_HDL_TYPE_STRING [ EMBEDDED_BITSTREAM_HDL_MODELSIM ] ) ;
}
}
2021-06-25 11:33:29 -05:00
void VerilogTestbenchOption : : set_time_unit ( const float & time_unit ) {
time_unit_ = time_unit ;
}
2020-02-27 13:33:09 -06:00
void VerilogTestbenchOption : : set_verbose_output ( const bool & enabled ) {
verbose_output_ = enabled ;
}
} /* end namespace openfpga */