Skip to content

Commit c5d509c

Browse files
doxygen comment for process_fc()
1 parent 5e5b118 commit c5d509c

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,25 @@ static void process_mode(pugi::xml_node Parent,
262262
int& parent_pb_idx);
263263

264264
static void process_fc_values(pugi::xml_node Node, t_default_fc_spec& spec, const pugiutil::loc_data& loc_data);
265+
266+
/**
267+
* @brief Processes the <fc> XML node for a given sub-tile and initializes
268+
* the Fc specifications for its pins.
269+
*
270+
* This function parses default Fc values and any <fc_override> tags defined
271+
* within the XML node, then applies them to all port/segment combinations
272+
* of the specified sub-tile. If no <fc> node is present, it falls back to
273+
* the architecture-wide default Fc specification. The resulting Fc settings
274+
* are stored in the given physical tile type.
275+
*/
265276
static void process_fc(pugi::xml_node Node,
266277
t_physical_tile_type* PhysicalTileType,
267-
t_sub_tile* SubTile,
278+
const t_sub_tile& sub_tile,
268279
t_pin_counts pin_counts,
269-
std::vector<t_segment_inf>& segments,
280+
const std::vector<t_segment_inf>& segments,
270281
const t_default_fc_spec& arch_def_fc,
271282
const pugiutil::loc_data& loc_data);
283+
272284
static t_fc_override process_fc_override(pugi::xml_node node, const pugiutil::loc_data& loc_data);
273285

274286
/**
@@ -287,7 +299,8 @@ static void process_switch_block_locations(pugi::xml_node switchblock_locations,
287299
const t_arch& arch,
288300
const pugiutil::loc_data& loc_data);
289301

290-
static e_fc_value_type string_to_fc_value_type(const std::string& str, pugi::xml_node node, const pugiutil::loc_data& loc_data);
302+
static e_fc_value_type string_to_fc_value_type(std::string_view str, pugi::xml_node node, const pugiutil::loc_data& loc_data);
303+
291304
static void process_chan_width_distr(pugi::xml_node Node,
292305
t_arch* arch,
293306
const pugiutil::loc_data& loc_data);
@@ -1996,42 +2009,40 @@ static void process_mode(pugi::xml_node Parent,
19962009
static void process_fc_values(pugi::xml_node Node, t_default_fc_spec& spec, const pugiutil::loc_data& loc_data) {
19972010
spec.specified = true;
19982011

1999-
/* Load the default fc_in */
2012+
// Load the default fc_in
20002013
auto default_fc_in_attrib = get_attribute(Node, "in_type", loc_data);
20012014
spec.in_value_type = string_to_fc_value_type(default_fc_in_attrib.value(), Node, loc_data);
20022015

20032016
auto in_val_attrib = get_attribute(Node, "in_val", loc_data);
20042017
spec.in_value = vtr::atof(in_val_attrib.value());
20052018

2006-
/* Load the default fc_out */
2019+
// Load the default fc_out
20072020
auto default_fc_out_attrib = get_attribute(Node, "out_type", loc_data);
20082021
spec.out_value_type = string_to_fc_value_type(default_fc_out_attrib.value(), Node, loc_data);
20092022

20102023
auto out_val_attrib = get_attribute(Node, "out_val", loc_data);
20112024
spec.out_value = vtr::atof(out_val_attrib.value());
20122025
}
20132026

2014-
/* Takes in the node ptr for the 'fc' elements and initializes
2015-
* the appropriate fields of type. */
20162027
static void process_fc(pugi::xml_node Node,
20172028
t_physical_tile_type* PhysicalTileType,
2018-
t_sub_tile* SubTile,
2029+
const t_sub_tile& sub_tile,
20192030
t_pin_counts pin_counts,
2020-
std::vector<t_segment_inf>& segments,
2031+
const std::vector<t_segment_inf>& segments,
20212032
const t_default_fc_spec& arch_def_fc,
20222033
const pugiutil::loc_data& loc_data) {
20232034
std::vector<t_fc_override> fc_overrides;
20242035
t_default_fc_spec def_fc_spec;
20252036
if (Node) {
2026-
/* Load the default Fc values from the node */
2037+
// Load the default Fc values from the node
20272038
process_fc_values(Node, def_fc_spec, loc_data);
2028-
/* Load any <fc_override/> tags */
2039+
// Load any <fc_override/> tags
20292040
for (auto child_node : Node.children()) {
20302041
t_fc_override fc_override = process_fc_override(child_node, loc_data);
20312042
fc_overrides.push_back(fc_override);
20322043
}
20332044
} else {
2034-
/* Use the default value, if available */
2045+
// Use the default value, if available
20352046
if (!arch_def_fc.specified) {
20362047
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Node),
20372048
vtr::string_fmt("<sub_tile> is missing child <fc>, and no <default_fc> specified in architecture\n").c_str());
@@ -2042,12 +2053,12 @@ static void process_fc(pugi::xml_node Node,
20422053
/* Go through all the port/segment combinations and create the (potentially
20432054
* overriden) pin/seg Fc specifications */
20442055
for (size_t iseg = 0; iseg < segments.size(); ++iseg) {
2045-
for (int icapacity = 0; icapacity < SubTile->capacity.total(); ++icapacity) {
2056+
for (int icapacity = 0; icapacity < sub_tile.capacity.total(); ++icapacity) {
20462057
//If capacity > 0, we need t offset the block index by the number of pins per instance
20472058
//this ensures that all pins have an Fc specification
20482059
int iblk_pin = icapacity * pin_counts.total();
20492060

2050-
for (const auto& port : SubTile->ports) {
2061+
for (const t_physical_tile_port& port : sub_tile.ports) {
20512062
t_fc_specification fc_spec;
20522063

20532064
fc_spec.seg_index = iseg;
@@ -2110,7 +2121,7 @@ static void process_fc(pugi::xml_node Node,
21102121
for (int iport_pin = 0; iport_pin < port.num_pins; ++iport_pin) {
21112122
//XXX: this assumes that iterating through the tile ports
21122123
// in order yields the block pin order
2113-
int true_physical_blk_pin = SubTile->sub_tile_to_tile_pin_indices[iblk_pin];
2124+
int true_physical_blk_pin = sub_tile.sub_tile_to_tile_pin_indices[iblk_pin];
21142125
fc_spec.pins.push_back(true_physical_blk_pin);
21152126
++iblk_pin;
21162127
}
@@ -2124,7 +2135,7 @@ static void process_fc(pugi::xml_node Node,
21242135
static t_fc_override process_fc_override(pugi::xml_node node, const pugiutil::loc_data& loc_data) {
21252136
if (node.name() != std::string("fc_override")) {
21262137
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node),
2127-
vtr::string_fmt("Unexpeted node of type '%s' (expected optional 'fc_override')",
2138+
vtr::string_fmt("Unexpected node of type '%s' (expected optional 'fc_override')",
21282139
node.name())
21292140
.c_str());
21302141
}
@@ -2137,21 +2148,22 @@ static t_fc_override process_fc_override(pugi::xml_node node, const pugiutil::lo
21372148
bool seen_fc_value = false;
21382149
bool seen_port_or_seg = false;
21392150
for (auto attrib : node.attributes()) {
2140-
if (attrib.name() == std::string("port_name")) {
2151+
std::string_view attribute_name = attrib.name();
2152+
if (attribute_name == "port_name") {
21412153
fc_override.port_name = attrib.value();
21422154
seen_port_or_seg |= true;
2143-
} else if (attrib.name() == std::string("segment_name")) {
2155+
} else if (attribute_name == "segment_name") {
21442156
fc_override.seg_name = attrib.value();
21452157
seen_port_or_seg |= true;
2146-
} else if (attrib.name() == std::string("fc_type")) {
2158+
} else if (attribute_name == "fc_type") {
21472159
fc_override.fc_value_type = string_to_fc_value_type(attrib.value(), node, loc_data);
21482160
seen_fc_type = true;
2149-
} else if (attrib.name() == std::string("fc_val")) {
2161+
} else if (attribute_name == "fc_val") {
21502162
fc_override.fc_value = vtr::atof(attrib.value());
21512163
seen_fc_value = true;
21522164
} else {
21532165
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node),
2154-
vtr::string_fmt("Unexpected attribute '%s'", attrib.name()).c_str());
2166+
vtr::string_fmt("Unexpected attribute '%s'", attribute_name).c_str());
21552167
}
21562168
}
21572169

@@ -2173,7 +2185,7 @@ static t_fc_override process_fc_override(pugi::xml_node node, const pugiutil::lo
21732185
return fc_override;
21742186
}
21752187

2176-
static e_fc_value_type string_to_fc_value_type(const std::string& str, pugi::xml_node node, const pugiutil::loc_data& loc_data) {
2188+
static e_fc_value_type string_to_fc_value_type(std::string_view str, pugi::xml_node node, const pugiutil::loc_data& loc_data) {
21772189
e_fc_value_type fc_value_type = e_fc_value_type::FRACTIONAL;
21782190

21792191
if (str == "frac") {
@@ -2182,9 +2194,7 @@ static e_fc_value_type string_to_fc_value_type(const std::string& str, pugi::xml
21822194
fc_value_type = e_fc_value_type::ABSOLUTE;
21832195
} else {
21842196
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node),
2185-
vtr::string_fmt("Invalid fc_type '%s'. Must be 'abs' or 'frac'.\n",
2186-
str.c_str())
2187-
.c_str());
2197+
vtr::string_fmt("Invalid fc_type '%s'. Must be 'abs' or 'frac'.\n", str).c_str());
21882198
}
21892199

21902200
return fc_value_type;
@@ -3726,7 +3736,7 @@ static void process_sub_tiles(pugi::xml_node Node,
37263736

37273737
/* Load Fc */
37283738
Cur = get_single_child(CurSubTile, "fc", loc_data, ReqOpt::OPTIONAL);
3729-
process_fc(Cur, PhysicalTileType, &SubTile, pin_counts, segments, arch_def_fc, loc_data);
3739+
process_fc(Cur, PhysicalTileType, SubTile, pin_counts, segments, arch_def_fc, loc_data);
37303740

37313741
//Load equivalent sites information
37323742
Cur = get_single_child(CurSubTile, "equivalent_sites", loc_data, ReqOpt::REQUIRED);

0 commit comments

Comments
 (0)