[core] syntax

This commit is contained in:
tangxifan 2024-05-18 12:29:38 -07:00
parent be1d7517c9
commit 3b93bea3d1
5 changed files with 15 additions and 15 deletions

View File

@ -71,7 +71,7 @@ ArchDirectId ArchDirect::add_direct(const std::string& name) {
direct_ids_.push_back(direct);
names_.push_back(name);
circuit_models_.push_back(CircuitModelId::INVALID());
types_.emplace_back(NUM_DIRECT_TYPES);
types_.emplace_back(e_direct_type::NUM_DIRECT_TYPES);
directions_.emplace_back(vtr::Point<e_direct_direction>(
NUM_DIRECT_DIRECTIONS, NUM_DIRECT_DIRECTIONS));

View File

@ -21,7 +21,7 @@ enum class e_direct_type {
INTER_ROW,
NUM_DIRECT_TYPES
};
constexpr std::array<const char*, NUM_DIRECT_TYPES> DIRECT_TYPE_STRING = {
constexpr std::array<const char*, (size_t)e_direct_type::NUM_DIRECT_TYPES> DIRECT_TYPE_STRING = {
{"inner_column_or_row", "part_of_cb", "inter_column", "inter_row"}};
enum e_direct_direction { POSITIVE_DIR, NEGATIVE_DIR, NUM_DIRECT_DIRECTIONS };

View File

@ -279,11 +279,11 @@ ArchDirect read_xml_direct_circuit(pugi::xml_node& Node,
/* Add more information*/
std::string direct_type_name =
get_attribute(xml_direct, "type", loc_data, pugiutil::ReqOpt::OPTIONAL)
.as_string(DIRECT_TYPE_STRING[e_direct_type::INNER_COLUMN_OR_ROW]);
.as_string(DIRECT_TYPE_STRING[size_t(e_direct_type::INNER_COLUMN_OR_ROW)]);
e_direct_type direct_type = string_to_direct_type(direct_type_name);
if (NUM_DIRECT_TYPES == direct_type) {
if (e_direct_type::NUM_DIRECT_TYPES == direct_type) {
archfpga_throw(
loc_data.filename_c_str(), loc_data.line(xml_direct),
"Direct type '%s' is not support! Acceptable values are [inner_column_or_row|part_of_cb|column|row]\n",
@ -293,7 +293,7 @@ ArchDirect read_xml_direct_circuit(pugi::xml_node& Node,
arch_direct.set_type(direct, direct_type);
/* The following syntax is only available for inter-column/row */
if (arch_direct.type(direct) != INTER_COLUMN && arch_direct.type(direct) != INTER_ROW) {
if (arch_direct.type(direct) != e_direct_type::INTER_COLUMN && arch_direct.type(direct) != e_direct_type::INTER_ROW) {
continue;
}

View File

@ -57,7 +57,7 @@ static void write_xml_direct_component_circuit(
fp, "circuit_model_name",
circuit_lib.model_name(arch_direct.circuit_model(direct_id)).c_str());
write_xml_attribute(fp, "type",
DIRECT_TYPE_STRING[arch_direct.type(direct_id)]);
DIRECT_TYPE_STRING[size_t(arch_direct.type(direct_id))]);
write_xml_attribute(fp, "x_dir",
DIRECT_DIRECTION_STRING[arch_direct.x_dir(direct_id)]);
write_xml_attribute(fp, "y_dir",

View File

@ -197,7 +197,7 @@ static vtr::Point<size_t> find_inter_direct_destination_coordinate(
* Our search space will start from the next column
* and ends at the RIGHT side of fabric
*/
if (INTER_COLUMN == arch_direct.type(arch_direct_id)) {
if (e_direct_type::INTER_COLUMN == arch_direct.type(arch_direct_id)) {
if (POSITIVE_DIR == arch_direct.x_dir(arch_direct_id)) {
/* Our first search space will be in x-direction:
*
@ -262,7 +262,7 @@ static vtr::Point<size_t> find_inter_direct_destination_coordinate(
* Our search space will start from the next column
* and ends at the RIGHT side of fabric
*/
if (INTER_ROW == arch_direct.type(arch_direct_id)) {
if (e_direct_type::INTER_ROW == arch_direct.type(arch_direct_id)) {
if (POSITIVE_DIR == arch_direct.y_dir(arch_direct_id)) {
/* Our first search space will be in y-direction:
*
@ -326,10 +326,10 @@ static vtr::Point<size_t> find_inter_direct_destination_coordinate(
for (size_t ix : first_search_space) {
std::vector<vtr::Point<size_t>> next_col_row_coords;
for (size_t iy : second_search_space) {
if (INTER_COLUMN == arch_direct.type(arch_direct_id)) {
if (e_direct_type::INTER_COLUMN == arch_direct.type(arch_direct_id)) {
next_col_row_coords.push_back(vtr::Point<size_t>(ix, iy));
} else {
VTR_ASSERT(INTER_ROW == arch_direct.type(arch_direct_id));
VTR_ASSERT(e_direct_type::INTER_ROW == arch_direct.type(arch_direct_id));
/* For cross-row connection, our search space is flipped */
next_col_row_coords.push_back(vtr::Point<size_t>(iy, ix));
}
@ -549,8 +549,8 @@ static void build_inter_column_row_tile_direct(
/* Go through the direct connection list, see if we need intra-column/row
* connection here */
if ((INTER_COLUMN != arch_direct.type(arch_direct_id)) &&
(INTER_ROW != arch_direct.type(arch_direct_id))) {
if ((e_direct_type::INTER_COLUMN != arch_direct.type(arch_direct_id)) &&
(e_direct_type::INTER_ROW != arch_direct.type(arch_direct_id))) {
return;
}
/* For cross-column connection, we will search the first valid grid in each
@ -568,7 +568,7 @@ static void build_inter_column_row_tile_direct(
* +------+
*
*/
if (INTER_COLUMN == arch_direct.type(arch_direct_id)) {
if (e_direct_type::INTER_COLUMN == arch_direct.type(arch_direct_id)) {
for (size_t ix = 1; ix < device_ctx.grid.width() - 1; ++ix) {
std::vector<vtr::Point<size_t>> next_col_src_grid_coords;
/* For negative y- direction, we should start from y = ny */
@ -671,7 +671,7 @@ static void build_inter_column_row_tile_direct(
}
/* Reach here, it must be a cross-row connection */
VTR_ASSERT(INTER_ROW == arch_direct.type(arch_direct_id));
VTR_ASSERT(e_direct_type::INTER_ROW == arch_direct.type(arch_direct_id));
/* For cross-row connection, we will search the first valid grid in each
* column from x = 1 to x = nx
*
@ -804,7 +804,7 @@ TileDirect build_device_tile_direct(const DeviceContext& device_ctx,
exit(1);
}
/* Build from original VPR arch definition */
if((INNER_COLUMN_OR_ROW == arch_direct.type(arch_direct_id)) {
if (e_direct_type::INNER_COLUMN_OR_ROW == arch_direct.type(arch_direct_id)) {
build_inner_column_row_tile_direct(tile_direct,
device_ctx.arch->Directs[idirect],
device_ctx, arch_direct_id, verbose);