Skip to content

Commit 1a4e7ec

Browse files
committed
applied all requested changes
1 parent db50dd0 commit 1a4e7ec

File tree

3 files changed

+168
-154
lines changed

3 files changed

+168
-154
lines changed

libs/libarchfpga/src/physical_types.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,11 @@ struct t_arch {
21042104
std::vector<std::string> ipin_cblock_switch_name;
21052105

21062106
std::vector<t_grid_def> grid_layouts; //Set of potential device layouts
2107-
std::string device_layout; //the layout that is chosen to be used with command line options
2107+
2108+
//the layout that is chosen to be used with command line options
2109+
//It is used to generate custom SB for a specific locations within the device
2110+
//If the layout is not specified in the command line options, this variable will be set to "auto"
2111+
std::string device_layout;
21082112

21092113
t_clock_arch_spec clock_arch; // Clock related data types
21102114

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,6 +3937,43 @@ static void ProcessSegments(pugi::xml_node Parent,
39373937
"Atleast one segment per-axis needs to get specified if no segments with non-specified (default) axis attribute exist.");
39383938
}
39393939
}
3940+
3941+
3942+
static void calculate_custom_SB_locations(const pugiutil::loc_data& loc_data, const pugi::xml_node& SubElem, const int grid_width, const int grid_height, t_switchblock_inf& sb){
3943+
auto startx_attr = get_attribute(SubElem, "startx", loc_data, ReqOpt::OPTIONAL);
3944+
auto endx_attr = get_attribute(SubElem, "endx", loc_data, ReqOpt::OPTIONAL);
3945+
3946+
auto starty_attr = get_attribute(SubElem, "starty", loc_data, ReqOpt::OPTIONAL);
3947+
auto endy_attr = get_attribute(SubElem, "endy", loc_data, ReqOpt::OPTIONAL);
3948+
3949+
auto repeatx_attr = get_attribute(SubElem, "repeatx", loc_data, ReqOpt::OPTIONAL);
3950+
auto repeaty_attr = get_attribute(SubElem, "repeaty", loc_data, ReqOpt::OPTIONAL);
3951+
3952+
auto incrx_attr = get_attribute(SubElem, "incrx", loc_data, ReqOpt::OPTIONAL);
3953+
auto incry_attr = get_attribute(SubElem, "incry", loc_data, ReqOpt::OPTIONAL);
3954+
3955+
//parse the values from the architecture file and fill out SB region information
3956+
vtr::FormulaParser p;
3957+
3958+
vtr::t_formula_data vars;
3959+
vars.set_var_value("W", grid_width);
3960+
vars.set_var_value("H", grid_height);
3961+
3962+
3963+
sb.reg_x.start = startx_attr.empty() ? 0 : p.parse_formula(startx_attr.value(), vars);
3964+
sb.reg_y.start = starty_attr.empty() ? 0 : p.parse_formula(starty_attr.value(), vars);
3965+
3966+
sb.reg_x.end = endx_attr.empty() ? (grid_width - 1) : p.parse_formula(endx_attr.value(), vars);
3967+
sb.reg_y.end = endy_attr.empty() ? (grid_height -1) : p.parse_formula(endy_attr.value(), vars);
3968+
3969+
sb.reg_x.repeat = repeatx_attr.empty() ? 0 : p.parse_formula(repeatx_attr.value(), vars);
3970+
sb.reg_y.repeat = repeaty_attr.empty() ? 0 : p.parse_formula(repeaty_attr.value(), vars);
3971+
3972+
sb.reg_x.incr = incrx_attr.empty() ? 1 : p.parse_formula(incrx_attr.value(), vars);
3973+
sb.reg_y.incr = incry_attr.empty() ? 1 : p.parse_formula(incry_attr.value(), vars);
3974+
3975+
}
3976+
39403977
/* Processes the switchblocklist section from the xml architecture file.
39413978
* See vpr/SRC/route/build_switchblocks.c for a detailed description of this
39423979
* switch block format */
@@ -3948,8 +3985,7 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu
39483985
/* get the number of switchblocks */
39493986
int num_switchblocks = count_children(Parent, "switchblock", loc_data);
39503987
arch->switchblocks.reserve(num_switchblocks);
3951-
3952-
// get the device layout width and height
3988+
39533989
int layout_index = -1;
39543990
for(layout_index = 0; layout_index < (int) arch->grid_layouts.size(); layout_index++){
39553991
if(arch->grid_layouts.at(layout_index).name == arch->device_layout){
@@ -4005,6 +4041,9 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu
40054041

40064042
/* get the switchblock coordinate only if sb.location is set to E_XY_SPECIFIED*/
40074043
if(sb.location == e_sb_location::E_XY_SPECIFIED){
4044+
if (arch->device_layout == "auto"){
4045+
archfpga_throw(loc_data.filename_c_str(), loc_data.line(SubElem), "Specifying SB locations for auto layout devices are not supported yet!\n");
4046+
}
40084047
expect_only_attributes(SubElem,
40094048
{"x", "y", "type",
40104049
"startx", "endx", "repeatx", "incrx",
@@ -4024,41 +4063,12 @@ static void ProcessSwitchblocks(pugi::xml_node Parent, t_arch* arch, const pugiu
40244063
"Location (%d,%d) is not valid within the grid! grid dimensions are: (%d,%d)\n", sb.x, sb.y, grid_width, grid_height);
40254064
}
40264065

4027-
4028-
/* Location also might be specified with regular expression, get the region that this SB should be applied to*/
4066+
/* if the the switchblock exact location is not specified and a region is specified within the architecture file,
4067+
* we have to parse the region specification and apply the SB pattern to all the locations fall into the specified
4068+
* region based on device width and height.
4069+
*/
40294070
if (sb.x == -1 && sb.y == -1) {
4030-
auto startx_attr = get_attribute(SubElem, "startx", loc_data, ReqOpt::OPTIONAL);
4031-
auto endx_attr = get_attribute(SubElem, "endx", loc_data, ReqOpt::OPTIONAL);
4032-
4033-
auto starty_attr = get_attribute(SubElem, "starty", loc_data, ReqOpt::OPTIONAL);
4034-
auto endy_attr = get_attribute(SubElem, "endy", loc_data, ReqOpt::OPTIONAL);
4035-
4036-
auto repeatx_attr = get_attribute(SubElem, "repeatx", loc_data, ReqOpt::OPTIONAL);
4037-
auto repeaty_attr = get_attribute(SubElem, "repeaty", loc_data, ReqOpt::OPTIONAL);
4038-
4039-
auto incrx_attr = get_attribute(SubElem, "incrx", loc_data, ReqOpt::OPTIONAL);
4040-
auto incry_attr = get_attribute(SubElem, "incry", loc_data, ReqOpt::OPTIONAL);
4041-
4042-
//parse the values from the architecture file and fill out SB region information
4043-
vtr::FormulaParser p;
4044-
4045-
vtr::t_formula_data vars;
4046-
vars.set_var_value("W", grid_width);
4047-
vars.set_var_value("H", grid_height);
4048-
4049-
4050-
sb.reg_x.start = startx_attr.empty() ? 0 : p.parse_formula(startx_attr.value(), vars);
4051-
sb.reg_y.start = starty_attr.empty() ? 0 : p.parse_formula(starty_attr.value(), vars);
4052-
4053-
sb.reg_x.end = endx_attr.empty() ? (grid_width - 1) : p.parse_formula(endx_attr.value(), vars);
4054-
sb.reg_y.end = endy_attr.empty() ? (grid_height -1) : p.parse_formula(endy_attr.value(), vars);
4055-
4056-
sb.reg_x.repeat = repeatx_attr.empty() ? 0 : p.parse_formula(repeatx_attr.value(), vars);
4057-
sb.reg_y.repeat = repeaty_attr.empty() ? 0 : p.parse_formula(repeaty_attr.value(), vars);
4058-
4059-
sb.reg_x.incr = incrx_attr.empty() ? 1 : p.parse_formula(incrx_attr.value(), vars);
4060-
sb.reg_y.incr = incry_attr.empty() ? 1 : p.parse_formula(incry_attr.value(), vars);
4061-
4071+
calculate_custom_SB_locations(loc_data, SubElem, grid_width, grid_height, sb);
40624072
}
40634073

40644074
}

0 commit comments

Comments
 (0)