[lib] now default switch of clk ntwk is split to default_tap_switch and default_driver_switch

This commit is contained in:
tangxifan 2024-06-21 16:45:05 -07:00
parent 4fea194bac
commit 9ccd14bf4d
6 changed files with 49 additions and 20 deletions

View File

@ -1,4 +1,4 @@
<clock_networks default_segment="seg_len1" default_switch="fast_switch"> <clock_networks default_segment="seg_len1" default_tap_switch="fast_switch" default_driver_switch="slow_switch">
<clock_network name="example_network" width="8"> <clock_network name="example_network" width="8">
<spine name="spine_lvl3" start_x="0" start_y="2" end_x="2" end_y="2"> <spine name="spine_lvl3" start_x="0" start_y="2" end_x="2" end_y="2">
<switch_point tap="spine_lvl2_upper" x="2" y="2"/> <switch_point tap="spine_lvl2_upper" x="2" y="2"/>

View File

@ -18,7 +18,8 @@ namespace openfpga { // Begin namespace openfpga
***********************************************************************/ ***********************************************************************/
ClockNetwork::ClockNetwork() { ClockNetwork::ClockNetwork() {
default_segment_id_ = RRSegmentId::INVALID(); 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; is_dirty_ = true;
} }
@ -172,11 +173,16 @@ RRSegmentId ClockNetwork::default_segment() const {
return default_segment_id_; return default_segment_id_;
} }
std::string ClockNetwork::default_switch_name() const { std::string ClockNetwork::default_tap_switch_name() const {
return default_switch_name_; 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 { std::string ClockNetwork::tree_name(const ClockTreeId& tree_id) const {
VTR_ASSERT(valid_tree_id(tree_id)); 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; default_segment_id_ = seg_id;
} }
void ClockNetwork::set_default_switch(const RRSwitchId& switch_id) { void ClockNetwork::set_default_tap_switch(const RRSwitchId& switch_id) {
default_switch_id_ = 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) { void ClockNetwork::set_default_segment_name(const std::string& name) {
default_segment_name_ = name; default_segment_name_ = name;
} }
void ClockNetwork::set_default_switch_name(const std::string& name) { void ClockNetwork::set_default_tap_switch_name(const std::string& name) {
default_switch_name_ = 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) { ClockTreeId ClockNetwork::create_tree(const std::string& name, size_t width) {

View File

@ -145,9 +145,11 @@ class ClockNetwork {
/* Reserve a number of trees to be memory efficent */ /* Reserve a number of trees to be memory efficent */
void reserve_trees(const size_t& num_trees); void reserve_trees(const size_t& num_trees);
void set_default_segment(const RRSegmentId& seg_id); 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_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; /* Create a new tree, by default the tree can accomodate only 1 clock signal;
* use width to adjust the size */ * use width to adjust the size */
ClockTreeId create_tree(const std::string& name, size_t width = 1); ClockTreeId create_tree(const std::string& name, size_t width = 1);
@ -250,8 +252,11 @@ class ClockNetwork {
clock wires */ clock wires */
RRSegmentId default_segment_id_; RRSegmentId default_segment_id_;
std::string std::string
default_switch_name_; /* The routing switch interconnecting clock wire */ default_tap_switch_name_; /* The routing switch interconnecting clock wire */
RRSwitchId default_switch_id_; RRSwitchId default_tap_switch_id_;
std::string
default_driver_switch_name_; /* The routing switch interconnecting clock wire */
RRSwitchId default_driver_switch_id_;
/* Fast lookup */ /* Fast lookup */
std::map<std::string, ClockTreeId> tree_name2id_map_; std::map<std::string, ClockTreeId> tree_name2id_map_;

View File

@ -6,8 +6,10 @@
constexpr const char* XML_CLOCK_NETWORK_ROOT_NAME = "clock_networks"; constexpr const char* XML_CLOCK_NETWORK_ROOT_NAME = "clock_networks";
constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SEGMENT = constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SEGMENT =
"default_segment"; "default_segment";
constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SWITCH = constexpr const char* XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_TAP_SWITCH =
"default_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_NODE_NAME = "clock_network";
constexpr const char* XML_CLOCK_TREE_ATTRIBUTE_NAME = "name"; constexpr const char* XML_CLOCK_TREE_ATTRIBUTE_NAME = "name";
constexpr const char* XML_CLOCK_TREE_ATTRIBUTE_WIDTH = "width"; constexpr const char* XML_CLOCK_TREE_ATTRIBUTE_WIDTH = "width";

View File

@ -263,11 +263,17 @@ ClockNetwork read_xml_clock_network(const char* fname) {
.as_string(); .as_string();
clk_ntwk.set_default_segment_name(default_segment_name); clk_ntwk.set_default_segment_name(default_segment_name);
std::string default_switch_name = std::string default_tap_switch_name =
get_attribute(xml_root, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SWITCH, get_attribute(xml_root, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_TAP_SWITCH,
loc_data) loc_data)
.as_string(); .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 = size_t num_trees =
std::distance(xml_root.children().begin(), xml_root.children().end()); std::distance(xml_root.children().begin(), xml_root.children().end());

View File

@ -168,8 +168,10 @@ int write_xml_clock_network(const char* fname, const ClockNetwork& clk_ntwk) {
fp << "<" << XML_CLOCK_NETWORK_ROOT_NAME; fp << "<" << XML_CLOCK_NETWORK_ROOT_NAME;
write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SEGMENT, write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SEGMENT,
clk_ntwk.default_segment_name().c_str()); clk_ntwk.default_segment_name().c_str());
write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_SWITCH, write_xml_attribute(fp, XML_CLOCK_NETWORK_ATTRIBUTE_DEFAULT_TAP_SWITCH,
clk_ntwk.default_switch_name().c_str()); 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 << ">" fp << ">"
<< "\n"; << "\n";