[lib] code format
This commit is contained in:
parent
3bc959dcec
commit
091ac88c7e
|
@ -14,20 +14,17 @@
|
||||||
namespace openfpga {
|
namespace openfpga {
|
||||||
|
|
||||||
TileConfig::TileConfig() {
|
TileConfig::TileConfig() {
|
||||||
style_ = TileConfig::e_style::NUM_TYPES; /* Deposit an invalid value */
|
style_ = TileConfig::e_style::NUM_TYPES; /* Deposit an invalid value */
|
||||||
STYLE_STRING_ = {"top_left", "top_right", "bottom_left", "bottom_right", "custom"};
|
STYLE_STRING_ = {"top_left", "top_right", "bottom_left", "bottom_right",
|
||||||
|
"custom"};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* Public Accessors
|
* Public Accessors
|
||||||
*************************************************/
|
*************************************************/
|
||||||
TileConfig::e_style TileConfig::style() const {
|
TileConfig::e_style TileConfig::style() const { return style_; }
|
||||||
return style_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string TileConfig::style_to_string() const {
|
std::string TileConfig::style_to_string() const { return style2str(style_); }
|
||||||
return style2str(style_);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TileConfig::is_valid() const {
|
bool TileConfig::is_valid() const {
|
||||||
return style_ != TileConfig::e_style::NUM_TYPES;
|
return style_ != TileConfig::e_style::NUM_TYPES;
|
||||||
|
@ -35,7 +32,7 @@ bool TileConfig::is_valid() const {
|
||||||
|
|
||||||
int TileConfig::set_style(const std::string& value) {
|
int TileConfig::set_style(const std::string& value) {
|
||||||
style_ = str2style(value);
|
style_ = str2style(value);
|
||||||
return valid_style(style_);
|
return valid_style(style_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TileConfig::style_all2str() const {
|
std::string TileConfig::style_all2str() const {
|
||||||
|
@ -49,8 +46,8 @@ std::string TileConfig::style_all2str() const {
|
||||||
return full_types;
|
return full_types;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileConfig::e_style TileConfig::str2style(
|
TileConfig::e_style TileConfig::str2style(const std::string& style_str,
|
||||||
const std::string& style_str, const bool& verbose) const {
|
const bool& verbose) const {
|
||||||
for (int itype = size_t(TileConfig::e_style::TOP_LEFT);
|
for (int itype = size_t(TileConfig::e_style::TOP_LEFT);
|
||||||
itype != size_t(TileConfig::e_style::NUM_TYPES); ++itype) {
|
itype != size_t(TileConfig::e_style::NUM_TYPES); ++itype) {
|
||||||
if (style_str == std::string(STYLE_STRING_[itype])) {
|
if (style_str == std::string(STYLE_STRING_[itype])) {
|
||||||
|
@ -72,8 +69,7 @@ std::string TileConfig::style2str(const TileConfig::e_style& style,
|
||||||
return std::string(STYLE_STRING_[size_t(style)]);
|
return std::string(STYLE_STRING_[size_t(style)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileConfig::valid_style(
|
bool TileConfig::valid_style(const TileConfig::e_style& style) const {
|
||||||
const TileConfig::e_style& style) const {
|
|
||||||
return style != TileConfig::e_style::NUM_TYPES;
|
return style != TileConfig::e_style::NUM_TYPES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,27 @@
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Include header files required by the data structure definition
|
* Include header files required by the data structure definition
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
#include <string>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/* Begin namespace openfpga */
|
/* Begin namespace openfpga */
|
||||||
namespace openfpga {
|
namespace openfpga {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief tile configuration is a data structure to represent how programmable blocks and routing blocks are grouped into tiles
|
* @brief tile configuration is a data structure to represent how programmable
|
||||||
|
* blocks and routing blocks are grouped into tiles
|
||||||
*/
|
*/
|
||||||
class TileConfig {
|
class TileConfig {
|
||||||
public: /* Types */
|
public: /* Types */
|
||||||
enum class e_style { TOP_LEFT = 0, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, CUSTOM, NUM_TYPES };
|
enum class e_style {
|
||||||
|
TOP_LEFT = 0,
|
||||||
|
TOP_RIGHT,
|
||||||
|
BOTTOM_LEFT,
|
||||||
|
BOTTOM_RIGHT,
|
||||||
|
CUSTOM,
|
||||||
|
NUM_TYPES
|
||||||
|
};
|
||||||
|
|
||||||
public: /* Constructors */
|
public: /* Constructors */
|
||||||
TileConfig();
|
TileConfig();
|
||||||
|
|
||||||
|
@ -40,8 +49,7 @@ class TileConfig {
|
||||||
std::string style2str(const e_style& style,
|
std::string style2str(const e_style& style,
|
||||||
const bool& verbose = false) const;
|
const bool& verbose = false) const;
|
||||||
/** @brief Validate the style */
|
/** @brief Validate the style */
|
||||||
bool valid_style(
|
bool valid_style(const e_style& style) const;
|
||||||
const e_style& style) const;
|
|
||||||
|
|
||||||
private: /* Internal utility */
|
private: /* Internal utility */
|
||||||
/* Generate a string include all the valid style
|
/* Generate a string include all the valid style
|
||||||
|
@ -51,8 +59,7 @@ class TileConfig {
|
||||||
private: /* Internal Data */
|
private: /* Internal Data */
|
||||||
e_style style_;
|
e_style style_;
|
||||||
/* Constants */
|
/* Constants */
|
||||||
std::array<const char*, size_t(e_style::NUM_TYPES)>
|
std::array<const char*, size_t(e_style::NUM_TYPES)> STYLE_STRING_;
|
||||||
STYLE_STRING_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* End namespace openfpga*/
|
} /* End namespace openfpga*/
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
/* Headers from libarchfpga */
|
/* Headers from libarchfpga */
|
||||||
#include "arch_error.h"
|
#include "arch_error.h"
|
||||||
#include "command_exit_codes.h"
|
#include "command_exit_codes.h"
|
||||||
#include "tile_config_xml_constants.h"
|
|
||||||
#include "read_xml_tile_config.h"
|
#include "read_xml_tile_config.h"
|
||||||
#include "read_xml_util.h"
|
#include "read_xml_util.h"
|
||||||
|
#include "tile_config_xml_constants.h"
|
||||||
|
|
||||||
namespace openfpga { // Begin namespace openfpga
|
namespace openfpga { // Begin namespace openfpga
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ int read_xml_tile_config(const char* fname, TileConfig& tile_config) {
|
||||||
|
|
||||||
pugi::xml_node xml_root =
|
pugi::xml_node xml_root =
|
||||||
get_single_child(doc, XML_TILE_CONFIG_ROOT_NAME, loc_data);
|
get_single_child(doc, XML_TILE_CONFIG_ROOT_NAME, loc_data);
|
||||||
|
|
||||||
std::string style =
|
std::string style =
|
||||||
get_attribute(xml_root, XML_TILE_CONFIG_ATTRIBUTE_STYLE_NAME, loc_data)
|
get_attribute(xml_root, XML_TILE_CONFIG_ATTRIBUTE_STYLE_NAME, loc_data)
|
||||||
.as_string();
|
.as_string();
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Include header files that are required by function declaration
|
* Include header files that are required by function declaration
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
#include "tile_config.h"
|
|
||||||
#include "pugixml.hpp"
|
#include "pugixml.hpp"
|
||||||
#include "pugixml_util.hpp"
|
#include "pugixml_util.hpp"
|
||||||
|
#include "tile_config.h"
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Function declaration
|
* Function declaration
|
||||||
|
|
|
@ -50,7 +50,6 @@ int write_xml_tile_config(const char* fname, const TileConfig& tile_config) {
|
||||||
fp << "/>"
|
fp << "/>"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
|
|
||||||
/* Close the file stream */
|
/* Close the file stream */
|
||||||
fp.close();
|
fp.close();
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "openfpga_naming.h"
|
#include "openfpga_naming.h"
|
||||||
#include "read_xml_fabric_key.h"
|
#include "read_xml_fabric_key.h"
|
||||||
#include "read_xml_tile_config.h"
|
|
||||||
#include "read_xml_io_name_map.h"
|
#include "read_xml_io_name_map.h"
|
||||||
|
#include "read_xml_tile_config.h"
|
||||||
#include "vtr_log.h"
|
#include "vtr_log.h"
|
||||||
#include "vtr_time.h"
|
#include "vtr_time.h"
|
||||||
|
|
||||||
|
@ -135,10 +135,12 @@ int build_fabric_template(T& openfpga_ctx, const Command& cmd,
|
||||||
TileConfig tile_config;
|
TileConfig tile_config;
|
||||||
if (cmd_context.option_enable(cmd, opt_group_tile)) {
|
if (cmd_context.option_enable(cmd, opt_group_tile)) {
|
||||||
if (!cmd_context.option_enable(cmd, opt_compress_routing)) {
|
if (!cmd_context.option_enable(cmd, opt_compress_routing)) {
|
||||||
VTR_LOG_ERROR("Group tile is applicable only when compress routing is enabled!\n");
|
VTR_LOG_ERROR(
|
||||||
|
"Group tile is applicable only when compress routing is enabled!\n");
|
||||||
return CMD_EXEC_FATAL_ERROR;
|
return CMD_EXEC_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
curr_status = read_xml_tile_config(cmd_context.option_value(cmd, opt_group_tile).c_str(), tile_config);
|
curr_status = read_xml_tile_config(
|
||||||
|
cmd_context.option_value(cmd, opt_group_tile).c_str(), tile_config);
|
||||||
if (CMD_EXEC_SUCCESS != curr_status) {
|
if (CMD_EXEC_SUCCESS != curr_status) {
|
||||||
return CMD_EXEC_FATAL_ERROR;
|
return CMD_EXEC_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,7 +407,9 @@ ShellCommandId add_build_fabric_command_template(
|
||||||
|
|
||||||
/* Add an option '--group_tile' */
|
/* Add an option '--group_tile' */
|
||||||
CommandOptionId opt_group_tile = shell_cmd.add_option(
|
CommandOptionId opt_group_tile = shell_cmd.add_option(
|
||||||
"group_tile", false, "group programmable blocks and routing blocks into tiles. This helps to reduce the number of blocks at top-level");
|
"group_tile", false,
|
||||||
|
"group programmable blocks and routing blocks into tiles. This helps to "
|
||||||
|
"reduce the number of blocks at top-level");
|
||||||
shell_cmd.set_option_require_value(opt_group_tile, openfpga::OPT_STRING);
|
shell_cmd.set_option_require_value(opt_group_tile, openfpga::OPT_STRING);
|
||||||
|
|
||||||
/* Add an option '--generate_random_fabric_key' */
|
/* Add an option '--generate_random_fabric_key' */
|
||||||
|
|
Loading…
Reference in New Issue