From 091ac88c7e495c526dbb8ceeaebb8adafb3d788e Mon Sep 17 00:00:00 2001 From: tangxifan Date: Fri, 14 Jul 2023 12:16:40 -0700 Subject: [PATCH] [lib] code format --- libs/libtileconfig/src/base/tile_config.cpp | 22 ++++++++----------- libs/libtileconfig/src/base/tile_config.h | 21 ++++++++++++------ .../src/io/read_xml_tile_config.cpp | 4 ++-- .../src/io/read_xml_tile_config.h | 2 +- .../src/io/write_xml_tile_config.cpp | 1 - .../src/base/openfpga_build_fabric_template.h | 8 ++++--- .../base/openfpga_setup_command_template.h | 4 +++- 7 files changed, 34 insertions(+), 28 deletions(-) diff --git a/libs/libtileconfig/src/base/tile_config.cpp b/libs/libtileconfig/src/base/tile_config.cpp index 35f13a2c7..49fa8e52f 100644 --- a/libs/libtileconfig/src/base/tile_config.cpp +++ b/libs/libtileconfig/src/base/tile_config.cpp @@ -14,20 +14,17 @@ namespace openfpga { TileConfig::TileConfig() { - style_ = TileConfig::e_style::NUM_TYPES; /* Deposit an invalid value */ - STYLE_STRING_ = {"top_left", "top_right", "bottom_left", "bottom_right", "custom"}; + style_ = TileConfig::e_style::NUM_TYPES; /* Deposit an invalid value */ + STYLE_STRING_ = {"top_left", "top_right", "bottom_left", "bottom_right", + "custom"}; } /************************************************** * Public Accessors *************************************************/ -TileConfig::e_style TileConfig::style() const { - return style_; -} +TileConfig::e_style TileConfig::style() const { return style_; } -std::string TileConfig::style_to_string() const { - return style2str(style_); -} +std::string TileConfig::style_to_string() const { return style2str(style_); } bool TileConfig::is_valid() const { return style_ != TileConfig::e_style::NUM_TYPES; @@ -35,7 +32,7 @@ bool TileConfig::is_valid() const { int TileConfig::set_style(const std::string& value) { style_ = str2style(value); - return valid_style(style_); + return valid_style(style_); } std::string TileConfig::style_all2str() const { @@ -49,8 +46,8 @@ std::string TileConfig::style_all2str() const { return full_types; } -TileConfig::e_style TileConfig::str2style( - const std::string& style_str, const bool& verbose) const { +TileConfig::e_style TileConfig::str2style(const std::string& style_str, + const bool& verbose) const { for (int itype = size_t(TileConfig::e_style::TOP_LEFT); itype != size_t(TileConfig::e_style::NUM_TYPES); ++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)]); } -bool TileConfig::valid_style( - const TileConfig::e_style& style) const { +bool TileConfig::valid_style(const TileConfig::e_style& style) const { return style != TileConfig::e_style::NUM_TYPES; } diff --git a/libs/libtileconfig/src/base/tile_config.h b/libs/libtileconfig/src/base/tile_config.h index e4e1f3d40..41dd8acd9 100644 --- a/libs/libtileconfig/src/base/tile_config.h +++ b/libs/libtileconfig/src/base/tile_config.h @@ -4,18 +4,27 @@ /******************************************************************** * Include header files required by the data structure definition *******************************************************************/ -#include #include +#include /* Begin 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 { 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 */ TileConfig(); @@ -40,8 +49,7 @@ class TileConfig { std::string style2str(const e_style& style, const bool& verbose = false) const; /** @brief Validate the style */ - bool valid_style( - const e_style& style) const; + bool valid_style(const e_style& style) const; private: /* Internal utility */ /* Generate a string include all the valid style @@ -51,8 +59,7 @@ class TileConfig { private: /* Internal Data */ e_style style_; /* Constants */ - std::array - STYLE_STRING_; + std::array STYLE_STRING_; }; } /* End namespace openfpga*/ diff --git a/libs/libtileconfig/src/io/read_xml_tile_config.cpp b/libs/libtileconfig/src/io/read_xml_tile_config.cpp index 4bf093d99..f332f5688 100644 --- a/libs/libtileconfig/src/io/read_xml_tile_config.cpp +++ b/libs/libtileconfig/src/io/read_xml_tile_config.cpp @@ -17,9 +17,9 @@ /* Headers from libarchfpga */ #include "arch_error.h" #include "command_exit_codes.h" -#include "tile_config_xml_constants.h" #include "read_xml_tile_config.h" #include "read_xml_util.h" +#include "tile_config_xml_constants.h" 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 = get_single_child(doc, XML_TILE_CONFIG_ROOT_NAME, loc_data); - + std::string style = get_attribute(xml_root, XML_TILE_CONFIG_ATTRIBUTE_STYLE_NAME, loc_data) .as_string(); diff --git a/libs/libtileconfig/src/io/read_xml_tile_config.h b/libs/libtileconfig/src/io/read_xml_tile_config.h index 2c84b5538..7e80f612e 100644 --- a/libs/libtileconfig/src/io/read_xml_tile_config.h +++ b/libs/libtileconfig/src/io/read_xml_tile_config.h @@ -4,9 +4,9 @@ /******************************************************************** * Include header files that are required by function declaration *******************************************************************/ -#include "tile_config.h" #include "pugixml.hpp" #include "pugixml_util.hpp" +#include "tile_config.h" /******************************************************************** * Function declaration diff --git a/libs/libtileconfig/src/io/write_xml_tile_config.cpp b/libs/libtileconfig/src/io/write_xml_tile_config.cpp index 528f2131b..48e1254df 100644 --- a/libs/libtileconfig/src/io/write_xml_tile_config.cpp +++ b/libs/libtileconfig/src/io/write_xml_tile_config.cpp @@ -50,7 +50,6 @@ int write_xml_tile_config(const char* fname, const TileConfig& tile_config) { fp << "/>" << "\n"; - /* Close the file stream */ fp.close(); diff --git a/openfpga/src/base/openfpga_build_fabric_template.h b/openfpga/src/base/openfpga_build_fabric_template.h index a8a81adb1..2fc4b3d69 100644 --- a/openfpga/src/base/openfpga_build_fabric_template.h +++ b/openfpga/src/base/openfpga_build_fabric_template.h @@ -17,8 +17,8 @@ #include "globals.h" #include "openfpga_naming.h" #include "read_xml_fabric_key.h" -#include "read_xml_tile_config.h" #include "read_xml_io_name_map.h" +#include "read_xml_tile_config.h" #include "vtr_log.h" #include "vtr_time.h" @@ -135,10 +135,12 @@ int build_fabric_template(T& openfpga_ctx, const Command& cmd, TileConfig tile_config; if (cmd_context.option_enable(cmd, opt_group_tile)) { 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; } - 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) { return CMD_EXEC_FATAL_ERROR; } diff --git a/openfpga/src/base/openfpga_setup_command_template.h b/openfpga/src/base/openfpga_setup_command_template.h index 9267531ad..12d34c00d 100644 --- a/openfpga/src/base/openfpga_setup_command_template.h +++ b/openfpga/src/base/openfpga_setup_command_template.h @@ -407,7 +407,9 @@ ShellCommandId add_build_fabric_command_template( /* Add an option '--group_tile' */ 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); /* Add an option '--generate_random_fabric_key' */