[core] code format
This commit is contained in:
parent
108bbad8d4
commit
f30663f708
|
@ -192,20 +192,24 @@ ShellCommandId add_write_fabric_bitstream_command_template(
|
|||
|
||||
CommandOptionId opt_filter_value = shell_cmd.add_option(
|
||||
"filter_value", false,
|
||||
"Specify what values should be written out in the resulting fabric bitstream [0|1|none]. Only applicable to XML file format. Default: none");
|
||||
"Specify what values should be written out in the resulting fabric "
|
||||
"bitstream [0|1|none]. Only applicable to XML file format. Default: none");
|
||||
shell_cmd.set_option_require_value(opt_filter_value, openfpga::OPT_STRING);
|
||||
|
||||
shell_cmd.add_option(
|
||||
"path_only", false,
|
||||
"Only paths will be written out in the resulting fabric bitstream. Only applicable to XML file format. Default: off");
|
||||
"Only paths will be written out in the resulting fabric bitstream. Only "
|
||||
"applicable to XML file format. Default: off");
|
||||
|
||||
shell_cmd.add_option(
|
||||
"value_only", false,
|
||||
"Only values will be written out in the resulting fabric bitstream. Only applicable to XML file format. Default: off");
|
||||
"Only values will be written out in the resulting fabric bitstream. Only "
|
||||
"applicable to XML file format. Default: off");
|
||||
|
||||
shell_cmd.add_option(
|
||||
"trim_path", false,
|
||||
"Trim the path by a level of 1 in the resulting fabric bitstream. Only applicable to XML file format. Default: off");
|
||||
"Trim the path by a level of 1 in the resulting fabric bitstream. Only "
|
||||
"applicable to XML file format. Default: off");
|
||||
|
||||
/* Add an option '--fast_configuration' */
|
||||
shell_cmd.add_option("fast_configuration", false,
|
||||
|
|
|
@ -32,7 +32,8 @@ BitstreamWriterOption::BitstreamWriterOption() {
|
|||
/**************************************************
|
||||
* Public Accessors
|
||||
*************************************************/
|
||||
BitstreamWriterOption::e_bitfile_type BitstreamWriterOption::output_file_type() const {
|
||||
BitstreamWriterOption::e_bitfile_type BitstreamWriterOption::output_file_type()
|
||||
const {
|
||||
return file_type_;
|
||||
}
|
||||
|
||||
|
@ -57,8 +58,12 @@ bool BitstreamWriterOption::output_path() const { return path_only_; }
|
|||
bool BitstreamWriterOption::output_value() const { return value_only_; }
|
||||
|
||||
bool BitstreamWriterOption::fast_configuration() const { return fast_config_; }
|
||||
bool BitstreamWriterOption::keep_dont_care_bits() const { return keep_dont_care_bits_; }
|
||||
bool BitstreamWriterOption::wl_decremental_order() const { return wl_decremental_order_; }
|
||||
bool BitstreamWriterOption::keep_dont_care_bits() const {
|
||||
return keep_dont_care_bits_;
|
||||
}
|
||||
bool BitstreamWriterOption::wl_decremental_order() const {
|
||||
return wl_decremental_order_;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Private Mutators
|
||||
|
@ -67,7 +72,8 @@ void BitstreamWriterOption::set_output_file_type(const std::string& val) {
|
|||
file_type_ = str2bitfile_type(val);
|
||||
}
|
||||
|
||||
void BitstreamWriterOption::set_output_file_name(const std::string& output_file) {
|
||||
void BitstreamWriterOption::set_output_file_name(
|
||||
const std::string& output_file) {
|
||||
output_file_ = output_file;
|
||||
}
|
||||
|
||||
|
@ -120,20 +126,27 @@ bool BitstreamWriterOption::validate(bool show_err_msg) const {
|
|||
if (file_type_ == BitstreamWriterOption::e_bitfile_type::XML) {
|
||||
/* All the options in the XML format should be off */
|
||||
if (path_only_ && value_only_) {
|
||||
VTR_LOGV_ERROR(show_err_msg, "Both path and value are specifed as only inputs! If specified, please define one of them\n");
|
||||
VTR_LOGV_ERROR(show_err_msg,
|
||||
"Both path and value are specifed as only inputs! If "
|
||||
"specified, please define one of them\n");
|
||||
return false;
|
||||
}
|
||||
if (!filter_value_.empty() && (filter_value_ != std::to_string(0) || filter_value_ != std::to_string(1))) {
|
||||
VTR_LOGV_ERROR(show_err_msg, "Invalid value '%s' for filter values. Expect [0|1]!\n", filter_value_);
|
||||
if (!filter_value_.empty() && (filter_value_ != std::to_string(0) ||
|
||||
filter_value_ != std::to_string(1))) {
|
||||
VTR_LOGV_ERROR(show_err_msg,
|
||||
"Invalid value '%s' for filter values. Expect [0|1]!\n",
|
||||
filter_value_);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BitstreamWriterOption::e_bitfile_type BitstreamWriterOption::str2bitfile_type(const std::string& type_str, const bool& verbose) const {
|
||||
BitstreamWriterOption::e_bitfile_type BitstreamWriterOption::str2bitfile_type(
|
||||
const std::string& type_str, const bool& verbose) const {
|
||||
for (int itype = size_t(BitstreamWriterOption::e_bitfile_type::TEXT);
|
||||
itype != size_t(BitstreamWriterOption::e_bitfile_type::NUM_TYPES); ++itype) {
|
||||
itype != size_t(BitstreamWriterOption::e_bitfile_type::NUM_TYPES);
|
||||
++itype) {
|
||||
if (type_str == std::string(BITFILE_TYPE_STRING_[itype])) {
|
||||
return static_cast<BitstreamWriterOption::e_bitfile_type>(itype);
|
||||
}
|
||||
|
@ -143,8 +156,9 @@ BitstreamWriterOption::e_bitfile_type BitstreamWriterOption::str2bitfile_type(co
|
|||
return BitstreamWriterOption::e_bitfile_type::NUM_TYPES;
|
||||
}
|
||||
|
||||
std::string BitstreamWriterOption::bitfile_type2str(const BitstreamWriterOption::e_bitfile_type& type,
|
||||
const bool& verbose) const {
|
||||
std::string BitstreamWriterOption::bitfile_type2str(
|
||||
const BitstreamWriterOption::e_bitfile_type& type,
|
||||
const bool& verbose) const {
|
||||
if (!valid_file_type(type)) {
|
||||
VTR_LOGV_ERROR(verbose, "Invalid type for bitstream file! Expect %s\n",
|
||||
bitfile_type_all2str().c_str());
|
||||
|
@ -156,7 +170,8 @@ std::string BitstreamWriterOption::bitfile_type2str(const BitstreamWriterOption:
|
|||
std::string BitstreamWriterOption::bitfile_type_all2str() const {
|
||||
std::string full_types = "[";
|
||||
for (int itype = size_t(BitstreamWriterOption::e_bitfile_type::TEXT);
|
||||
itype != size_t(BitstreamWriterOption::e_bitfile_type::NUM_TYPES); ++itype) {
|
||||
itype != size_t(BitstreamWriterOption::e_bitfile_type::NUM_TYPES);
|
||||
++itype) {
|
||||
full_types += std::string(BITFILE_TYPE_STRING_[itype]) + std::string("|");
|
||||
}
|
||||
full_types.pop_back();
|
||||
|
@ -164,8 +179,8 @@ std::string BitstreamWriterOption::bitfile_type_all2str() const {
|
|||
return full_types;
|
||||
}
|
||||
|
||||
|
||||
bool BitstreamWriterOption::valid_file_type(const BitstreamWriterOption::e_bitfile_type& bitfile_type) const {
|
||||
bool BitstreamWriterOption::valid_file_type(
|
||||
const BitstreamWriterOption::e_bitfile_type& bitfile_type) const {
|
||||
return bitfile_type != BitstreamWriterOption::e_bitfile_type::NUM_TYPES;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
/********************************************************************
|
||||
* Include header files required by the data structure definition
|
||||
*******************************************************************/
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
/* Begin namespace openfpga */
|
||||
namespace openfpga {
|
||||
|
@ -16,11 +16,8 @@ namespace openfpga {
|
|||
class BitstreamWriterOption {
|
||||
public: /* Private data structures */
|
||||
/* A type to define the bitstream file format */
|
||||
enum class e_bitfile_type {
|
||||
TEXT,
|
||||
XML,
|
||||
NUM_TYPES
|
||||
};
|
||||
enum class e_bitfile_type { TEXT, XML, NUM_TYPES };
|
||||
|
||||
public: /* Public constructor */
|
||||
/* Set default options */
|
||||
BitstreamWriterOption();
|
||||
|
@ -67,11 +64,11 @@ class BitstreamWriterOption {
|
|||
/** @brief Parse the file type from string to valid type. Parser
|
||||
* error can be turned on */
|
||||
e_bitfile_type str2bitfile_type(const std::string& type_str,
|
||||
const bool& verbose = false) const;
|
||||
const bool& verbose = false) const;
|
||||
|
||||
/** @brief Output the string representing file_type */
|
||||
std::string bitfile_type2str(const e_bitfile_type& type,
|
||||
const bool& verbose = false) const;
|
||||
const bool& verbose = false) const;
|
||||
/** @brief Validate the file_type */
|
||||
bool valid_file_type(const e_bitfile_type& bitfile_type) const;
|
||||
|
||||
|
@ -98,7 +95,8 @@ class BitstreamWriterOption {
|
|||
bool wl_decremental_order_;
|
||||
|
||||
/* Constants */
|
||||
std::array<const char*, size_t(e_bitfile_type::NUM_TYPES)> BITFILE_TYPE_STRING_;
|
||||
std::array<const char*, size_t(e_bitfile_type::NUM_TYPES)>
|
||||
BITFILE_TYPE_STRING_;
|
||||
};
|
||||
|
||||
} /* End namespace openfpga*/
|
||||
|
|
Loading…
Reference in New Issue