Skip to content

Commit 7b887c3

Browse files
Add comments and rename GridDefType
1 parent 6911986 commit 7b887c3

File tree

7 files changed

+44
-40
lines changed

7 files changed

+44
-40
lines changed

libs/libarchfpga/src/echo_arch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ void PrintArchInfo(FILE* Echo, const t_arch* arch) {
101101
//Layout
102102
fprintf(Echo, "*************************************************\n");
103103
for (const auto& grid_layout : arch->grid_layouts) {
104-
if (grid_layout.grid_type == GridDefType::AUTO) {
104+
if (grid_layout.grid_type == e_grid_def_type::AUTO) {
105105
fprintf(Echo, "Layout: '%s' Type: auto Aspect_Ratio: %f\n", grid_layout.name.c_str(), grid_layout.aspect_ratio);
106106
} else {
107-
VTR_ASSERT(grid_layout.grid_type == GridDefType::FIXED);
107+
VTR_ASSERT(grid_layout.grid_type == e_grid_def_type::FIXED);
108108
fprintf(Echo, "Layout: '%s' Type: fixed Width: %d Height %d\n", grid_layout.name.c_str(), grid_layout.width, grid_layout.height);
109109
}
110110
}

libs/libarchfpga/src/grid_types.h

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,21 @@
1313
struct t_metadata_dict;
1414

1515
/**
16-
* @brief Grid location specification
16+
* @brief Grid location specification, used to capture user's intended architecture specification.
17+
* will be later turned into a flattened device grid according to the device's size.
1718
* Each member is a formula evaluated in terms of 'W' (device width),
1819
* and 'H' (device height). Formulas can be evaluated using parse_formula()
1920
* from expr_eval.h.
2021
*/
2122
struct t_grid_loc_spec {
22-
std::string start_expr; //Starting position (inclusive)
23-
std::string end_expr; //Ending position (inclusive)
23+
std::string start_expr; ///<Starting position (inclusive)
24+
std::string end_expr; ///<Ending position (inclusive)
2425

25-
std::string repeat_expr; //Distance between repeated
26-
// region instances
26+
std::string repeat_expr; ///<Distance between repeated region instances
2727

28-
std::string incr_expr; //Distance between block instantiations
29-
// with the region
28+
std::string incr_expr; ///<Distance between block instantiations with the region
3029
};
3130

32-
/* Definition of how to place physical logic block in the grid.
33-
34-
*/
35-
3631
/**
3732
* @brief Definition of how to place physical logic block in the grid.
3833
* @details This defines a region of the grid to be set to a specific type
@@ -69,7 +64,7 @@ struct t_grid_loc_spec {
6964
* <-------------->
7065
* repeatx
7166
*
72-
* startx/endx and endx/endy define a rectangular region instances dimensions.
67+
* startx/endx and endx/endy define a rectangular region instance's dimensions.
7368
* The region instance is then repeated every repeatx/repeaty (if specified).
7469
*
7570
* Within a particular region instance a block of block_type is laid down every
@@ -103,29 +98,38 @@ struct t_grid_loc_def {
10398
t_grid_loc_def(std::string block_type_val, int priority_val)
10499
: block_type(std::move(block_type_val))
105100
, priority(priority_val)
106-
, x{"0", "W-1", "max(w+1,W)", "w"} //Fill in x direction, no repeat, incr by block width
107-
, y{"0", "H-1", "max(h+1,H)", "h"} //Fill in y direction, no repeat, incr by block height
101+
, x{"0", "W-1", "max(w+1,W)", "w"} // Fill in x direction, no repeat, incr by block width
102+
, y{"0", "H-1", "max(h+1,H)", "h"} // Fill in y direction, no repeat, incr by block height
108103
{}
109104

110-
std::string block_type; //The block type name
105+
std::string block_type; ///< The block type name
111106

112-
int priority = 0; //Priority of the specification.
113-
// In case of conflicting specifications
114-
// the largest priority wins.
107+
int priority = 0; ///< Priority of the specification. In case of conflicting specifications the largest priority wins.
115108

116-
t_grid_loc_spec x; //Horizontal location specification
117-
t_grid_loc_spec y; //Vertical location specification
109+
t_grid_loc_spec x; ///< Horizontal location specification
110+
t_grid_loc_spec y; ///< Vertical location specification
118111

119-
// When 1 metadata tag is split among multiple t_grid_loc_def, one
120-
// t_grid_loc_def is arbitrarily chosen to own the metadata, and the other
121-
// t_grid_loc_def point to the owned version.
112+
/**
113+
* @brief When 1 metadata tag is split among multiple t_grid_loc_def, one
114+
* t_grid_loc_def is arbitrarily chosen to own the metadata, and the other
115+
* t_grid_loc_def point to the owned version.
116+
*
117+
*/
122118
std::unique_ptr<t_metadata_dict> owned_meta;
123-
t_metadata_dict* meta = nullptr; // Metadata for this location definition. This
124-
// metadata may be shared with multiple grid_locs
125-
// that come from a common definition.
119+
120+
/**
121+
* @brief Metadata for this location definition. This
122+
* metadata may be shared with multiple grid_locs
123+
* that come from a common definition.
124+
*/
125+
t_metadata_dict* meta = nullptr;
126126
};
127127

128-
enum class GridDefType {
128+
/**
129+
* @brief Enum for specfying if the architecture grid specification is for an auto sized device (variable size)
130+
* or a fixed size device.
131+
*/
132+
enum class e_grid_def_type {
129133
AUTO,
130134
FIXED
131135
};

libs/libarchfpga/src/physical_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ struct t_layer_def {
257257
};
258258

259259
struct t_grid_def {
260-
GridDefType grid_type = GridDefType::AUTO; //The type of this grid specification
260+
e_grid_def_type grid_type = e_grid_def_type::AUTO; //The type of this grid specification
261261

262262
std::string name = ""; //The name of this device
263263

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ struct ArchReader {
22442244
grid_def.width += 2;
22452245
grid_def.height += 2;
22462246

2247-
grid_def.grid_type = GridDefType::FIXED;
2247+
grid_def.grid_type = e_grid_def_type::FIXED;
22482248

22492249
if (name == "auto") {
22502250
// At the moment, the interchange specifies fixed-layout only architectures,

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,15 +2585,15 @@ static t_grid_def process_grid_layout(vtr::string_internment& strings,
25852585
if (layout_type_tag.name() == std::string("auto_layout")) {
25862586
expect_only_attributes(layout_type_tag, {"aspect_ratio"}, loc_data);
25872587

2588-
grid_def.grid_type = GridDefType::AUTO;
2588+
grid_def.grid_type = e_grid_def_type::AUTO;
25892589

25902590
grid_def.aspect_ratio = get_attribute(layout_type_tag, "aspect_ratio", loc_data, ReqOpt::OPTIONAL).as_float(1.);
25912591
grid_def.name = "auto";
25922592

25932593
} else if (layout_type_tag.name() == std::string("fixed_layout")) {
25942594
expect_only_attributes(layout_type_tag, {"width", "height", "name"}, loc_data);
25952595

2596-
grid_def.grid_type = GridDefType::FIXED;
2596+
grid_def.grid_type = e_grid_def_type::FIXED;
25972597
grid_def.width = get_attribute(layout_type_tag, "width", loc_data).as_int();
25982598
grid_def.height = get_attribute(layout_type_tag, "height", loc_data).as_int();
25992599
std::string name = get_attribute(layout_type_tag, "name", loc_data).value();
@@ -2654,7 +2654,7 @@ static void process_block_type_locs(t_grid_def& grid_def,
26542654
// tags do not have. For this reason we check if loc_spec_tag is an interposer tag
26552655
// and switch code paths if it is.
26562656
if (loc_type == std::string("interposer_cut")) {
2657-
if (grid_def.grid_type == GridDefType::AUTO) {
2657+
if (grid_def.grid_type == e_grid_def_type::AUTO) {
26582658
archfpga_throw(loc_data.filename_c_str(), loc_data.line(loc_spec_tag), "Interposers are not currently supported for auto sized devices.");
26592659
}
26602660

vpr/src/base/setup_grid.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ DeviceGrid create_device_grid(const std::string& layout_name, const std::vector<
8484
if (layout_name == "auto") {
8585
VTR_ASSERT(!grid_layouts.empty());
8686
//Auto-size
87-
if (grid_layouts[0].grid_type == GridDefType::AUTO) {
87+
if (grid_layouts[0].grid_type == e_grid_def_type::AUTO) {
8888
//Auto layout of the specified dimensions
8989
return build_device_grid(grid_layouts[0], width, height);
9090
} else {
@@ -152,7 +152,7 @@ static DeviceGrid auto_size_device_grid(const std::vector<t_grid_def>& grid_layo
152152
DeviceGrid grid;
153153

154154
auto is_auto_grid_def = [](const t_grid_def& grid_def) {
155-
return grid_def.grid_type == GridDefType::AUTO;
155+
return grid_def.grid_type == e_grid_def_type::AUTO;
156156
};
157157

158158
auto auto_layout_itr = std::find_if(grid_layouts.begin(), grid_layouts.end(), is_auto_grid_def);
@@ -230,8 +230,8 @@ static DeviceGrid auto_size_device_grid(const std::vector<t_grid_def>& grid_layo
230230
grid_layouts_view.push_back(&layout);
231231
}
232232
auto area_cmp = [](const t_grid_def* lhs, const t_grid_def* rhs) {
233-
VTR_ASSERT(lhs->grid_type == GridDefType::FIXED);
234-
VTR_ASSERT(rhs->grid_type == GridDefType::FIXED);
233+
VTR_ASSERT(lhs->grid_type == e_grid_def_type::FIXED);
234+
VTR_ASSERT(rhs->grid_type == e_grid_def_type::FIXED);
235235

236236
int lhs_area = lhs->width * lhs->height;
237237
int rhs_area = rhs->width * rhs->height;
@@ -339,7 +339,7 @@ static bool grid_satisfies_instance_counts(const DeviceGrid& grid, const std::ma
339339

340340
///@brief Build the specified device grid
341341
static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_width, size_t grid_height, bool warn_out_of_range, const std::vector<t_logical_block_type_ptr>& limiting_resources) {
342-
if (grid_def.grid_type == GridDefType::FIXED) {
342+
if (grid_def.grid_type == e_grid_def_type::FIXED) {
343343
if (grid_def.width != int(grid_width) || grid_def.height != int(grid_height)) {
344344
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
345345
"Requested grid size (%zu%zu) does not match fixed device size (%dx%d)",

vpr/test/test_interchange_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ TEST_CASE("read_interchange_layout", "[vpr]") {
5151
FPGAInterchangeReadArch(kArchFile, /*timing_enabled=*/true, &arch, physical_tile_types, logical_block_types);
5252

5353
auto& gd = arch.grid_layouts[0];
54-
REQUIRE(gd.grid_type == GridDefType::FIXED);
54+
REQUIRE(gd.grid_type == e_grid_def_type::FIXED);
5555
REQUIRE(gd.height == 12);
5656
REQUIRE(gd.width == 12);
5757

0 commit comments

Comments
 (0)