44#include " pugixml_util.hpp"
55#include " arch_error.h"
66#include " switchblock_types.h"
7+ #include " vtr_util.h"
78
89/* *
910 * @brief Parses all <sg_link> tags under a <sg_link_list> tag.
@@ -26,32 +27,12 @@ static std::vector<t_sg_link> parse_sg_link_tags(pugi::xml_node sg_link_list_tag
2627 sg_link.seg_type = pugiutil::get_attribute (node, " seg_type" , loc_data).as_string ();
2728
2829 // Since the offset attributes are optional and might not exist, the as_int method will return a value of zero if the attribute is empty
29- int x_offset = pugiutil::get_attribute (node, " x_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
30- int y_offset = pugiutil::get_attribute (node, " y_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
31- int z_offset = pugiutil::get_attribute (node, " z_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
30+ sg_link. x_offset = pugiutil::get_attribute (node, " x_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
31+ sg_link. y_offset = pugiutil::get_attribute (node, " y_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
32+ sg_link. z_offset = pugiutil::get_attribute (node, " z_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
3233
33- if (x_offset == 0 && y_offset == 0 && z_offset == 0 ) {
34- archfpga_throw (loc_data.filename_c_str (), loc_data.line (node), " All offset fields in the <sg_link> are zero or missing." );
35- }
36-
37- // We expect exactly one non-zero offset so the gather and scatter points are joined by a node that can be represented by a straight wire.
38- if (x_offset != 0 ) {
39- sg_link.x_offset = x_offset;
40- if (y_offset != 0 || z_offset != 0 ) {
41- archfpga_throw (loc_data.filename_c_str (), loc_data.line (node), " More than one of the offset fields in the <sg_link> are non-zero." );
42- }
43- }
44- if (y_offset != 0 ) {
45- sg_link.y_offset = y_offset;
46- if (x_offset != 0 || z_offset != 0 ) {
47- archfpga_throw (loc_data.filename_c_str (), loc_data.line (node), " More than one of the offset fields in the <sg_link> are non-zero." );
48- }
49- }
50- if (z_offset != 0 ) {
51- sg_link.z_offset = z_offset;
52- if (y_offset != 0 || x_offset != 0 ) {
53- archfpga_throw (loc_data.filename_c_str (), loc_data.line (node), " More than one of the offset fields in the <sg_link> are non-zero." );
54- }
34+ if (!vtr::exactly_k_conditions (1 , sg_link.x_offset != 0 , sg_link.y_offset != 0 , sg_link.z_offset != 0 )) {
35+ archfpga_throw (loc_data.filename_c_str (), loc_data.line (node), " One and only one of the offset fields in the <sg_link> should be non-zero." );
5536 }
5637
5738 sg_link_list.push_back (sg_link);
0 commit comments