From 9ccd14bf4d674c3fdffc5b7fd1d03367398e40ca Mon Sep 17 00:00:00 2001 From: tangxifan Date: Fri, 21 Jun 2024 16:45:05 -0700 Subject: [PATCH] [lib] now default switch of clk ntwk is split to default_tap_switch and default_driver_switch --- libs/libclkarchopenfpga/arch/example.xml | 2 +- .../src/base/clock_network.cpp | 30 ++++++++++++++----- .../src/base/clock_network.h | 13 +++++--- .../src/io/clock_network_xml_constants.h | 6 ++-- .../src/io/read_xml_clock_network.cpp | 12 ++++++-- .../src/io/write_xml_clock_network.cpp | 6 ++-- 6 files changed, 49 insertions(+), 20 deletions(-) diff --git a/libs/libclkarchopenfpga/arch/example.xml b/libs/libclkarchopenfpga/arch/example.xml index ac6e722dd..ac251bd3c 100644 --- a/libs/libclkarchopenfpga/arch/example.xml +++ b/libs/libclkarchopenfpga/arch/example.xml @@ -1,4 +1,4 @@ - + diff --git a/libs/libclkarchopenfpga/src/base/clock_network.cpp b/libs/libclkarchopenfpga/src/base/clock_network.cpp index ee562bfd5..7ae5b9a4f 100644 --- a/libs/libclkarchopenfpga/src/base/clock_network.cpp +++ b/libs/libclkarchopenfpga/src/base/clock_network.cpp @@ -18,7 +18,8 @@ namespace openfpga { // Begin namespace openfpga ***********************************************************************/ ClockNetwork::ClockNetwork() { default_segment_id_ = RRSegmentId::INVALID(); - default_switch_id_ = RRSwitchId::INVALID(); + default_tap_switch_id_ = RRSwitchId::INVALID(); + default_driver_switch_id_ = RRSwitchId::INVALID(); is_dirty_ = true; } @@ -172,11 +173,16 @@ RRSegmentId ClockNetwork::default_segment() const { return default_segment_id_; } -std::string ClockNetwork::default_switch_name() const { - return default_switch_name_; +std::string ClockNetwork::default_tap_switch_name() const { + return default_tap_switch_name_; } -RRSwitchId ClockNetwork::default_switch() const { return default_switch_id_; } +std::string ClockNetwork::default_driver_switch_name() const { + return default_driver_switch_name_; +} + +RRSwitchId ClockNetwork::default_tap_switch() const { return default_tap_switch_id_; } +RRSwitchId ClockNetwork::default_driver_switch() const { return default_driver_switch_id_; } std::string ClockNetwork::tree_name(const ClockTreeId& tree_id) const { VTR_ASSERT(valid_tree_id(tree_id)); @@ -417,16 +423,24 @@ void ClockNetwork::set_default_segment(const RRSegmentId& seg_id) { default_segment_id_ = seg_id; } -void ClockNetwork::set_default_switch(const RRSwitchId& switch_id) { - default_switch_id_ = switch_id; +void ClockNetwork::set_default_tap_switch(const RRSwitchId& switch_id) { + default_tap_switch_id_ = switch_id; +} + +void ClockNetwork::set_default_driver_switch(const RRSwitchId& switch_id) { + default_driver_switch_id_ = switch_id; } void ClockNetwork::set_default_segment_name(const std::string& name) { default_segment_name_ = name; } -void ClockNetwork::set_default_switch_name(const std::string& name) { - default_switch_name_ = name; +void ClockNetwork::set_default_tap_switch_name(const std::string& name) { + default_tap_switch_name_ = name; +} + +void ClockNetwork::set_default_driver_switch_name(const std::string& name) { + default_driver_switch_name_ = name; } ClockTreeId ClockNetwork::create_tree(const std::string& name, size_t width) { diff --git a/libs/libclkarchopenfpga/src/base/clock_network.h b/libs/libclkarchopenfpga/src/base/clock_network.h index 0b9b8a42b..ad8d5e61f 100644 --- a/libs/libclkarchopenfpga/src/base/clock_network.h +++ b/libs/libclkarchopenfpga/src/base/clock_network.h @@ -145,9 +145,11 @@ class ClockNetwork { /* Reserve a number of trees to be memory efficent */ void reserve_trees(const size_t& num_trees); void set_default_segment(const RRSegmentId& seg_id); - void set_default_switch(const RRSwitchId& switch_id); + void set_default_tap_switch(const RRSwitchId& switch_id); + void set_default_driver_switch(const RRSwitchId& switch_id); void set_default_segment_name(const std::string& name); - void set_default_switch_name(const std::string& name); + void set_default_tap_switch_name(const std::string& name); + void set_default_driver_switch_name(const std::string& name); /* Create a new tree, by default the tree can accomodate only 1 clock signal; * use width to adjust the size */ ClockTreeId create_tree(const std::string& name, size_t width = 1); @@ -250,8 +252,11 @@ class ClockNetwork { clock wires */ RRSegmentId default_segment_id_; std::string - default_switch_name_; /* The routing switch interconnecting clock wire */ - RRSwitchId default_switch_id_; + default_tap_switch_name_; /* The routing switch interconnecting clock wire */ + RRSwitchId default_tap_switch_id_; + std::string + default_driver_switch_name_; /* The routing switch interconnecting clock wire */ + RRSwitchId default_driver_switch_id_; /* Fast lookup */ std::map tree_name2id_map_; diff --git a/libs/libclkarchopenfpga/src/io/clock_network_xml_constants.h b/libs/libclkarchopenfpga/src/io/clock_network_xml_constants.h index db7216f2d..a172b88ec 100644 --- a/libs/libclkarchopenfpga/src/io/clock_network_xml_constants.h +++ b/libs/libclkarchopenfpga/src/io/clock_network_xml_constants.h @@ -6,8 +6,10 @@ constexpr const char* XML_CLOCK_NETWORK_ROOT_NAME = "clock_networks"; constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SEGMENT = "default_segment"; -constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SWITCH = - "default_switch"; +constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_TAP_SWITCH = + "default_tap_switch"; +constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_DRIVER_SWITCH = + "default_driver_switch"; constexpr const char* XML_CLOCK_TREE_NODE_NAME = "clock_network"; constexpr const char* XML_CLOCK_TREE_ATTRIBUTE_NAME = "name"; constexpr const char* XML_CLOCK_TREE_ATTRIBUTE_WIDTH = "width"; diff --git a/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp b/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp index ed083f483..372ec0c81 100644 --- a/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp +++ b/libs/libclkarchopenfpga/src/io/read_xml_clock_network.cpp @@ -263,11 +263,17 @@ ClockNetwork read_xml_clock_network(const char* fname) { .as_string(); clk_ntwk.set_default_segment_name(default_segment_name); - std::string default_switch_name = - get_attribute(xml_root, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SWITCH, + std::string default_tap_switch_name = + get_attribute(xml_root, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_TAP_SWITCH, loc_data) .as_string(); - clk_ntwk.set_default_switch_name(default_switch_name); + clk_ntwk.set_default_tap_switch_name(default_tap_switch_name); + + std::string default_driver_switch_name = + get_attribute(xml_root, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_DRIVER_SWITCH, + loc_data) + .as_string(); + clk_ntwk.set_default_driver_switch_name(default_driver_switch_name); size_t num_trees = std::distance(xml_root.children().begin(), xml_root.children().end()); diff --git a/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp b/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp index 720335aa4..a71051fe1 100644 --- a/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp +++ b/libs/libclkarchopenfpga/src/io/write_xml_clock_network.cpp @@ -168,8 +168,10 @@ int write_xml_clock_network(const char* fname, const ClockNetwork& clk_ntwk) { fp << "<" << XML_CLOCK_NETWORK_ROOT_NAME; write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SEGMENT, clk_ntwk.default_segment_name().c_str()); - write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SWITCH, - clk_ntwk.default_switch_name().c_str()); + write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_TAP_SWITCH, + clk_ntwk.default_tap_switch_name().c_str()); + write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_DRIVER_SWITCH, + clk_ntwk.default_driver_switch_name().c_str()); fp << ">" << "\n";