From 3b25e427205d741dc4e3927555d945b5f5c00014 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 26 Jun 2024 15:51:00 -0700 Subject: [PATCH] [lib] syntax --- .../libclkarchopenfpga/src/base/clock_network.cpp | 15 +++++++-------- libs/libclkarchopenfpga/src/base/clock_network.h | 4 ++-- .../src/io/read_xml_clock_network.cpp | 12 ++++++------ .../src/io/write_xml_clock_network.cpp | 6 +++++- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/libs/libclkarchopenfpga/src/base/clock_network.cpp b/libs/libclkarchopenfpga/src/base/clock_network.cpp index 69fbed21b..6abb021d8 100644 --- a/libs/libclkarchopenfpga/src/base/clock_network.cpp +++ b/libs/libclkarchopenfpga/src/base/clock_network.cpp @@ -703,8 +703,7 @@ ClockInternalDriverId ClockNetwork::add_spine_switch_point_internal_driver( ClockTapId ClockNetwork::add_tree_tap(const ClockTreeId& tree_id, const std::string& from_port, - const std::string& to_port, - const ) { + const std::string& to_port) { VTR_ASSERT(valid_tree_id(tree_id)); /* TODO: Consider find existing tap template and avoid duplication in storage */ ClockTapId tap_id = ClockTapId(tap_ids_.size()); @@ -712,7 +711,7 @@ ClockTapId ClockNetwork::add_tree_tap(const ClockTreeId& tree_id, tap_from_ports_.push_back(from_port); tap_to_ports_.push_back(to_port); tap_bbs_.emplace_back(empty_tap_bb_); - tap_bb_steps_.emplace_back(vtr::Point(1, 1)); + tap_bb_steps_.emplace_back(vtr::Point(0, 0)); tree_taps_[tree_id].push_back(tap_id); return tap_id; } @@ -720,7 +719,7 @@ ClockTapId ClockNetwork::add_tree_tap(const ClockTreeId& tree_id, bool ClockNetwork::set_tap_bounding_box(const ClockTapId& tap_id, const vtr::Rect& bb) { VTR_ASSERT(valid_tap_id(tap_id)); /* Check the bounding box, ensure it must be valid */ - if (bb.height() < 0 || bb.width() < 0) { + if (bb.xmax() < bb.xmin() || bb.ymax() < bb.ymin()) { VTR_LOG_ERROR("Invalid bounding box (xlow=%lu, ylow=%lu) -> (xhigh=%lu, yhigh=%lu)! Must follow: xlow <= xhigh, ylow <= yhigh!\n", bb.xmin(), bb.ymin(), bb.xmax(), bb.ymax()); return false; } @@ -728,25 +727,25 @@ bool ClockNetwork::set_tap_bounding_box(const ClockTapId& tap_id, const vtr::Rec return true; } -bool ClockNetwork::set_tap_step_x(const ClockTapId& tap_id, const size_t step) { +bool ClockNetwork::set_tap_step_x(const ClockTapId& tap_id, const size_t& step) { VTR_ASSERT(valid_tap_id(tap_id)); /* Must be a valid step >= 1 */ if (step == 0) { VTR_LOG_ERROR("Invalid x-direction step (=%lu) for any bounding box! Expect an integer >= 1!\n", step); return false; } - tap_bbs_[tap_id].set_x(step); + tap_bb_steps_[tap_id].set_x(step); return true; } -bool ClockNetwork::set_tap_step_y(const ClockTapId& tap_id, const size_t step) { +bool ClockNetwork::set_tap_step_y(const ClockTapId& tap_id, const size_t& step) { VTR_ASSERT(valid_tap_id(tap_id)); /* Must be a valid step >= 1 */ if (step == 0) { VTR_LOG_ERROR("Invalid y-direction step (=%lu) for any bounding box! Expect an integer >= 1!\n", step); return false; } - tap_bbs_[tap_id].set_y(step); + tap_bb_steps_[tap_id].set_y(step); return true; } diff --git a/libs/libclkarchopenfpga/src/base/clock_network.h b/libs/libclkarchopenfpga/src/base/clock_network.h index f440c397c..e5236ab10 100644 --- a/libs/libclkarchopenfpga/src/base/clock_network.h +++ b/libs/libclkarchopenfpga/src/base/clock_network.h @@ -49,7 +49,7 @@ class ClockNetwork { typedef vtr::Range clock_internal_driver_range; /* Type of tap points */ - enum class : unsigned char { + enum class e_tap_type : unsigned char { ALL = 0, SINGLE, REGION, @@ -284,7 +284,7 @@ class ClockNetwork { vtr::vector tree_widths_; vtr::vector tree_depths_; vtr::vector> tree_top_spines_; - vtr::vector tree_taps_; + vtr::vector> tree_taps_; /* Basic information of each spine */ vtr::vector spine_ids_; diff --git a/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp b/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp index 2c8e8fdfe..fe90cd7f0 100644 --- a/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp +++ b/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp @@ -67,10 +67,10 @@ static void read_xml_clock_tree_tap_type_single(pugi::xml_node& xml_tap, /* Single tap only require a coordinate */ size_t tap_x = - get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_X, loc_data, pugi::ReqOpt::REQUIRED) + get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_X, loc_data, pugiutil::ReqOpt::REQUIRED) .as_int(); size_t tap_y = - get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_Y, loc_data, pugi::ReqOpt::REQUIRED) + get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_Y, loc_data, pugiutil::ReqOpt::REQUIRED) .as_int(); clk_ntwk.set_tap_bounding_box(tap_id, vtr::Rect(tap_x, tap_y, tap_x, tap_y)); } @@ -97,16 +97,16 @@ static void read_xml_clock_tree_tap_type_region(pugi::xml_node& xml_tap, /* Region require a bounding box */ size_t tap_start_x = - get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_STARTX, loc_data, pugi::ReqOpt::REQUIRED) + get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_STARTX, loc_data, pugiutil::ReqOpt::REQUIRED) .as_int(); size_t tap_start_y = - get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_STARTY, loc_data, pugi::ReqOpt::REQUIRED) + get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_STARTY, loc_data, pugiutil::ReqOpt::REQUIRED) .as_int(); size_t tap_end_x = - get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_ENDX, loc_data, pugi::ReqOpt::REQUIRED) + get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_ENDX, loc_data, pugiutil::ReqOpt::REQUIRED) .as_int(); size_t tap_end_y = - get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_ENDY, loc_data, pugi::ReqOpt::REQUIRED) + get_attribute(xml_tap, XML_CLOCK_TREE_TAP_ATTRIBUTE_ENDY, loc_data, pugiutil::ReqOpt::REQUIRED) .as_int(); clk_ntwk.set_tap_bounding_box(tap_id, vtr::Rect(tap_start_x, tap_start_y, tap_end_x, tap_end_y)); diff --git a/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp b/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp index addb745ed..cdcc12ecf 100644 --- a/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp +++ b/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp @@ -30,7 +30,7 @@ static int write_xml_clock_tree_taps(std::fstream& fp, fp << "<" << XML_CLOCK_TREE_TAPS_NODE_NAME << ">\n"; /* Depends on the type */ for (ClockTapId tap_id : clk_ntwk.tree_taps(tree_id)) { - switch clk_ntwk.tap_type(tap_id): { + switch (clk_ntwk.tap_type(tap_id)) { case ClockNetwork::e_tap_type::ALL: { openfpga::write_tab_to_file(fp, 4); fp << "<" << XML_CLOCK_TREE_TAP_ALL_NODE_NAME << ""; @@ -40,6 +40,7 @@ static int write_xml_clock_tree_taps(std::fstream& fp, clk_ntwk.tap_to_port(tap_id).c_str()); fp << "/>" << "\n"; + break; } case ClockNetwork::e_tap_type::SINGLE: { openfpga::write_tab_to_file(fp, 4); @@ -54,6 +55,7 @@ static int write_xml_clock_tree_taps(std::fstream& fp, clk_ntwk.tap_y(tap_id)); fp << "/>" << "\n"; + break; } case ClockNetwork::e_tap_type::REGION: { openfpga::write_tab_to_file(fp, 4); @@ -76,12 +78,14 @@ static int write_xml_clock_tree_taps(std::fstream& fp, clk_ntwk.tap_step_y(tap_id)); fp << "/>" << "\n"; + break; } default: { VTR_LOG_ERROR("Invalid type of tap point!\n"); return 1; } } + } openfpga::write_tab_to_file(fp, 3); fp << "\n";