Skip to content

Commit 8c32975

Browse files
Improve comments for scatter-gather parsing
1 parent 43352c0 commit 8c32975

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

libs/libarchfpga/src/parse_switchblocks.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ static t_wireconn_inf parse_wireconn_inline(pugi::xml_node node,
163163
bool can_skip_from_or_to) {
164164

165165
// Parse an inline wireconn definition, using attributes
166-
expect_only_attributes(node, {"num_conns", "from_type", "to_type", "from_switchpoint", "to_switchpoint", "from_order", "to_order", "switch_override", "side"}, loc_data);
166+
expect_only_attributes(node,
167+
{"num_conns", "from_type", "to_type", "from_switchpoint",
168+
"to_switchpoint", "from_order", "to_order", "switch_override", "side"},
169+
loc_data);
167170

168171
t_wireconn_inf wc;
169172

@@ -336,7 +339,7 @@ static void set_switch_func_type(SBSideConnection& conn, const char* func_type)
336339
if (std::string(func_type).find_first_not_of("rtlbauRTLBAU") != std::string::npos) {
337340
archfpga_throw(__FILE__, __LINE__, "Unknown direction specified: %s\n", func_type);
338341
}
339-
342+
340343
e_side from_side = CHAR_SIDE_MAP.at(func_type[0]);
341344
e_side to_side = CHAR_SIDE_MAP.at(func_type[1]);
342345

libs/libarchfpga/src/read_xml_arch_file_sg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static std::vector<t_sg_link> parse_sg_link_tags(pugi::xml_node sg_link_list_tag
3333
if (x_offset == 0 && y_offset == 0 && z_offset == 0) {
3434
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node), "All offset fields in the <sg_link> are non-zero or missing.");
3535
}
36-
36+
3737
// 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.
3838
if (x_offset != 0) {
3939
sg_link.x_offset = x_offset;

libs/libarchfpga/src/scatter_gather_types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*
1111
*/
1212
enum class e_scatter_gather_type {
13-
UNIDIR, // Unidirectional connection
14-
BIDIR // Bidirectional connection
13+
UNIDIR, ///< Unidirectional connection
14+
BIDIR ///< Bidirectional connection
1515
};
1616

1717
/**
@@ -29,12 +29,12 @@ struct t_sg_location {
2929
*
3030
*/
3131
struct t_sg_link {
32-
std::string name; // Name of the sg_link.
33-
std::string mux_name; // Name of the multiplexer used to gather connections.
34-
std::string seg_type; // Segment/wire used to move through the device to the scatter location.
35-
int x_offset; // X offset of where the scatter happens relative to the gather. If set, the y and z offsets must be zero.
36-
int y_offset; // y offset of where the scatter happens relative to the gather. If set, the x and z offsets must be zero.
37-
int z_offset; // z offset of where the scatter happens relative to the gather. If set, the x and y offsets must be zero.
32+
std::string name; ///< Name of the sg_link.
33+
std::string mux_name; ///< Name of the multiplexer used to gather connections.
34+
std::string seg_type; ///< Segment/wire used to move through the device to the scatter location.
35+
int x_offset; ///< X offset of where the scatter happens relative to the gather. If set, the y and z offsets must be zero.
36+
int y_offset; ///< y offset of where the scatter happens relative to the gather. If set, the x and z offsets must be zero.
37+
int z_offset; ///< z offset of where the scatter happens relative to the gather. If set, the x and y offsets must be zero.
3838
};
3939

4040
/**

libs/libarchfpga/src/switchblock_types.h

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ const std::unordered_map<char, e_side> CHAR_SIDE_MAP = {
4444
{'U', UNDER},
4545
{'u', UNDER}};
4646

47-
constexpr std::array<e_side, NUM_2D_SIDES> TOTAL_2D_SIDES = {{TOP, RIGHT, BOTTOM, LEFT}}; //Set of all side orientations
48-
constexpr std::array<const char*, NUM_2D_SIDES> TOTAL_2D_SIDE_STRINGS = {{"TOP", "RIGHT", "BOTTOM", "LEFT"}}; //String versions of side orientations
47+
constexpr std::array<e_side, NUM_2D_SIDES> TOTAL_2D_SIDES = {{TOP, RIGHT, BOTTOM, LEFT}}; // Set of all side orientations
48+
constexpr std::array<const char*, NUM_2D_SIDES> TOTAL_2D_SIDE_STRINGS = {{"TOP", "RIGHT", "BOTTOM", "LEFT"}}; // String versions of side orientations
4949

50-
constexpr std::array<e_side, NUM_3D_SIDES> TOTAL_3D_SIDES = {{TOP, RIGHT, BOTTOM, LEFT, ABOVE, UNDER}}; //Set of all side orientations including different layers
51-
constexpr std::array<const char*, NUM_3D_SIDES> TOTAL_3D_SIDE_STRINGS = {{"TOP", "RIGHT", "BOTTOM", "LEFT", "ABOVE", "UNDER"}}; //String versions of side orientations including different layers
50+
constexpr std::array<e_side, NUM_3D_SIDES> TOTAL_3D_SIDES = {{TOP, RIGHT, BOTTOM, LEFT, ABOVE, UNDER}}; // Set of all side orientations including different layers
51+
constexpr std::array<const char*, NUM_3D_SIDES> TOTAL_3D_SIDE_STRINGS = {{"TOP", "RIGHT", "BOTTOM", "LEFT", "ABOVE", "UNDER"}}; // String versions of side orientations including different layers
5252

53-
/* Specifies what part of the FPGA a custom switchblock should be built in (i.e. perimeter, core, everywhere) */
53+
/**
54+
* @brief Specifies what part of the FPGA a custom switchblock should be built in (i.e. perimeter, core, everywhere)
55+
*
56+
*/
5457
enum class e_sb_location {
5558
E_PERIMETER = 0,
5659
E_CORNER,
@@ -77,10 +80,13 @@ struct t_sb_loc_spec {
7780
int end = -1;
7881
};
7982

80-
/* represents a connection between two sides of a switchblock */
83+
/**
84+
* @brief represents a connection between two sides of a switchblock
85+
*
86+
*/
8187
class SBSideConnection {
8288
public:
83-
/* specify the two SB sides that form a connection */
89+
// Specify the two SB sides that form a connection
8490
enum e_side from_side = TOP;
8591
enum e_side to_side = TOP;
8692

@@ -96,7 +102,7 @@ class SBSideConnection {
96102
, to_side(to) {
97103
}
98104

99-
/* overload < operator which will be used by std::map */
105+
// Overload < operator which will be used by std::map
100106
bool operator<(const SBSideConnection& obj) const {
101107
bool result;
102108

@@ -115,24 +121,30 @@ class SBSideConnection {
115121
};
116122

117123
enum class SwitchPointOrder {
118-
FIXED, //Switchpoints are ordered as specified in architecture
119-
SHUFFLED //Switchpoints are shuffled (more diversity)
124+
FIXED, ///< Switchpoints are ordered as specified in architecture
125+
SHUFFLED ///< Switchpoints are shuffled (more diversity)
120126
};
121127

122-
//A collection of switchpoints associated with a segment
128+
/**
129+
* @brief A collection of switchpoints associated with a segment
130+
*
131+
*/
123132
struct t_wire_switchpoints {
124-
std::string segment_name; //The type of segment
125-
std::vector<int> switchpoints; //The indices of wire points along the segment
133+
std::string segment_name; ///< The type of segment
134+
std::vector<int> switchpoints; ///< The indices of wire points along the segment
126135
};
127136

128-
/* Used to list information about a set of track segments that should connect through a switchblock */
137+
/**
138+
* @brief Used to list information about a set of track segments that should connect through a switchblock
139+
*
140+
*/
129141
struct t_wireconn_inf {
130-
std::vector<t_wire_switchpoints> from_switchpoint_set; //The set of segment/wirepoints representing the 'from' set (union of all t_wire_switchpoints in vector)
131-
std::vector<t_wire_switchpoints> to_switchpoint_set; //The set of segment/wirepoints representing the 'to' set (union of all t_wire_switchpoints in vector)
132-
SwitchPointOrder from_switchpoint_order = SwitchPointOrder::FIXED; //The desired from_switchpoint_set ordering
133-
SwitchPointOrder to_switchpoint_order = SwitchPointOrder::FIXED; //The desired to_switchpoint_set ordering
134-
int switch_override_indx = DEFAULT_SWITCH; // index in switch array of the switch used to override wire_switch of the 'to' set.
135-
// DEFAULT_SWITCH is a sentinel value (i.e. the usual driving switch from a wire for the receiving wire will be used)
142+
std::vector<t_wire_switchpoints> from_switchpoint_set; ///< The set of segment/wirepoints representing the 'from' set (union of all t_wire_switchpoints in vector)
143+
std::vector<t_wire_switchpoints> to_switchpoint_set; ///< The set of segment/wirepoints representing the 'to' set (union of all t_wire_switchpoints in vector)
144+
SwitchPointOrder from_switchpoint_order = SwitchPointOrder::FIXED; ///< The desired from_switchpoint_set ordering
145+
SwitchPointOrder to_switchpoint_order = SwitchPointOrder::FIXED; ///< The desired to_switchpoint_set ordering
146+
int switch_override_indx = DEFAULT_SWITCH; ///< index in switch array of the switch used to override wire_switch of the 'to' set.
147+
///< DEFAULT_SWITCH is a sentinel value (i.e. the usual driving switch from a wire for the receiving wire will be used)
136148

137149
std::string num_conns_formula; /* Specifies how many connections should be made for this wireconn.
138150
*
@@ -150,7 +162,7 @@ struct t_wireconn_inf {
150162
* larger than 'to')
151163
*/
152164

153-
std::vector<e_side> sides; // Used for scatter-gather wireconns determining which sides to gather from / scatter to, ignored in other usages.
165+
std::vector<e_side> sides; ///< Used for scatter-gather wireconns determining which sides to gather from / scatter to, ignored in other usages.
154166
};
155167

156168
/* Use a map to index into the string permutation functions used to connect from one side to another */

0 commit comments

Comments
 (0)