Skip to content

Commit c4279dd

Browse files
authored
Merge pull request #1786 from byuccl/vtr_new_routing
Added the ability to perform detailed routing with different channel widths
2 parents c43fdbc + 5021128 commit c4279dd

File tree

10 files changed

+85
-23
lines changed

10 files changed

+85
-23
lines changed

doc/src/arch/reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ Global Routing Information
754754
If global routing is to be performed, channels in different directions and in different parts of the FPGA can be set to different relative widths.
755755
This is specified in the content within the ``<chan_width_distr>`` tag.
756756
757-
.. note:: If detailed routing is to be performed, all the channels in the FPGA must have the same width.
757+
.. note:: If detailed routing is to be performed, only uniform distributions may be used
758758
759759
.. arch:tag:: <x distr="{gaussian|uniform|pulse|delta}" peak="float" width=" float" xpeak=" float" dc=" float"/>
760760

utils/route_diag/src/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ static void profile_source(int source_rr_node,
215215
VTR_LOG("\n");
216216
}
217217

218-
219218
static t_chan_width setup_chan_width(t_router_opts router_opts,
220219
t_chan_width_dist chan_width_dist) {
221220
/*we give plenty of tracks, this increases routability for the */
222221
/*lookup table generation */
223222

223+
t_graph_type graph_directionality;
224224
int width_fac;
225225

226226
if (router_opts.fixed_channel_width == NO_FIXED_CHANNEL_WIDTH) {
@@ -236,7 +236,13 @@ static t_chan_width setup_chan_width(t_router_opts router_opts,
236236
width_fac = router_opts.fixed_channel_width;
237237
}
238238

239-
return init_chan(width_fac, chan_width_dist);
239+
if (router_opts.route_type == GLOBAL) {
240+
graph_directionality = GRAPH_BIDIR;
241+
} else {
242+
graph_directionality = GRAPH_UNIDIR;
243+
}
244+
245+
return init_chan(width_fac, chan_width_dist, graph_directionality);
240246
}
241247

242248
t_route_util_options read_route_util_options(int argc, const char** argv) {
@@ -289,7 +295,6 @@ int main(int argc, const char **argv) {
289295

290296
vpr_setup_clock_networks(vpr_setup, Arch);
291297

292-
293298
t_chan_width chan_width = setup_chan_width(
294299
vpr_setup.RouterOpts,
295300
Arch.Chans);

vpr/src/base/CheckSetup.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ void CheckSetup(const t_packer_opts& PackerOpts,
6363

6464
if (DETAILED == RouterOpts.route_type) {
6565
if ((Chans.chan_x_dist.type != UNIFORM)
66-
|| (Chans.chan_y_dist.type != UNIFORM)
67-
|| (Chans.chan_x_dist.peak != Chans.chan_y_dist.peak)) {
66+
|| (Chans.chan_y_dist.type != UNIFORM)) {
6867
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
69-
"Detailed routing currently only supported on FPGAs with all channels of equal width.\n");
68+
"Detailed routing currently only supported on FPGAs with uniform channel distributions.\n");
7069
}
7170
}
7271

vpr/src/base/place_and_route.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
/******************* Subroutines local to this module ************************/
4141

42+
static int compute_chan_width(int cfactor, t_chan chan_dist, float distance, float separation, t_graph_type graph_directionality);
4243
static float comp_width(t_chan* chan, float x, float separation);
4344

4445
/************************* Subroutine Definitions ****************************/
@@ -76,6 +77,7 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
7677
int warnings;
7778

7879
t_graph_type graph_type;
80+
t_graph_type graph_directionality;
7981

8082
/* We have chosen to pass placer_opts_ref by reference because of its large size. *
8183
* However, since the value is mutated later in the function, we declare a *
@@ -87,8 +89,10 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
8789

8890
if (router_opts.route_type == GLOBAL) {
8991
graph_type = GRAPH_GLOBAL;
92+
graph_directionality = GRAPH_BIDIR;
9093
} else {
9194
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
95+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
9296
}
9397

9498
best_routing = alloc_saved_routing();
@@ -342,7 +346,7 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
342346
/* End binary search verification. */
343347
/* Restore the best placement (if necessary), the best routing, and *
344348
* * the best channel widths for final drawing and statistics output. */
345-
t_chan_width chan_width = init_chan(final, arch->Chans);
349+
t_chan_width chan_width = init_chan(final, arch->Chans, graph_directionality);
346350

347351
free_rr_graph();
348352

@@ -383,9 +387,11 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
383387
* @brief Assigns widths to channels (in tracks).
384388
*
385389
* Minimum one track per channel. The channel distributions read from
386-
* the architecture file are scaled by cfactor.
390+
* the architecture file are scaled by cfactor. The graph directionality
391+
* is used to determine if the channel width should be rounded to an
392+
* even number.
387393
*/
388-
t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
394+
t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist, t_graph_type graph_directionality) {
389395
auto& device_ctx = g_vpr_ctx.mutable_device();
390396
auto& grid = device_ctx.grid;
391397

@@ -403,7 +409,7 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
403409

404410
for (size_t i = 0; i < grid.height(); ++i) {
405411
float y = float(i) / num_channels;
406-
chan_width.x_list[i] = (int)floor(cfactor * comp_width(&chan_x_dist, y, separation) + 0.5);
412+
chan_width.x_list[i] = compute_chan_width(cfactor, chan_x_dist, y, separation, graph_directionality);
407413
chan_width.x_list[i] = std::max(chan_width.x_list[i], 1); //Minimum channel width 1
408414
}
409415
}
@@ -415,8 +421,7 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
415421

416422
for (size_t i = 0; i < grid.width(); ++i) { //-2 for no perim channels
417423
float x = float(i) / num_channels;
418-
419-
chan_width.y_list[i] = (int)floor(cfactor * comp_width(&chan_y_dist, x, separation) + 0.5);
424+
chan_width.y_list[i] = compute_chan_width(cfactor, chan_y_dist, x, separation, graph_directionality);
420425
chan_width.y_list[i] = std::max(chan_width.y_list[i], 1); //Minimum channel width 1
421426
}
422427
}
@@ -452,6 +457,26 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
452457
return chan_width;
453458
}
454459

460+
/**
461+
* @brief Computes the channel width and adjusts it to be an an even number if unidirectional
462+
* since unidirectional graphs need to have paired wires.
463+
*
464+
* @param cfactor Channel width factor: multiplier on the channel width distribution (usually the number of tracks in the widest channel).
465+
* @param chan_dist Channel width distribution.
466+
* @param x The distance (between 0 and 1) we are across the chip.
467+
* @param separation The distance between two channels in the 0 to 1 coordinate system.
468+
* @param graph_directionality The directionality of the graph (unidirectional or bidirectional).
469+
*/
470+
static int compute_chan_width(int cfactor, t_chan chan_dist, float distance, float separation, t_graph_type graph_directionality) {
471+
int computed_width;
472+
computed_width = (int)floor(cfactor * comp_width(&chan_dist, distance, separation) + 0.5);
473+
if ((GRAPH_BIDIR == graph_directionality) || computed_width % 2 == 0) {
474+
return computed_width;
475+
} else {
476+
return computed_width - 1;
477+
}
478+
}
479+
455480
/**
456481
* @brief Return the relative channel density.
457482
*

vpr/src/base/place_and_route.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "vpr_types.h"
1212
#include "timing_info.h"
1313
#include "RoutingDelayCalculator.h"
14+
#include "rr_graph.h"
1415

1516
struct t_fmap_cell {
1617
int fs; ///<at this fs
@@ -35,7 +36,7 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
3536
std::shared_ptr<SetupHoldTimingInfo> timing_info,
3637
std::shared_ptr<RoutingDelayCalculator> delay_calc);
3738

38-
t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist);
39+
t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist, t_graph_type graph_directionality);
3940

4041
void post_place_sync();
4142

vpr/src/base/vpr_api.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ void vpr_init_with_options(const t_options* options, t_vpr_setup* vpr_setup, t_a
306306
CheckSetup(vpr_setup->PackerOpts,
307307
vpr_setup->PlacerOpts,
308308
vpr_setup->RouterOpts,
309-
vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing,
310-
arch->Chans);
309+
vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing, arch->Chans);
311310

312311
/* flush any messages to user still in stdout that hasn't gotten displayed */
313312
fflush(stdout);
@@ -890,15 +889,18 @@ void vpr_create_rr_graph(t_vpr_setup& vpr_setup, const t_arch& arch, int chan_wi
890889
auto det_routing_arch = &vpr_setup.RoutingArch;
891890
auto& router_opts = vpr_setup.RouterOpts;
892891

893-
t_chan_width chan_width = init_chan(chan_width_fac, arch.Chans);
894-
895892
t_graph_type graph_type;
893+
t_graph_type graph_directionality;
896894
if (router_opts.route_type == GLOBAL) {
897895
graph_type = GRAPH_GLOBAL;
896+
graph_directionality = GRAPH_BIDIR;
898897
} else {
899898
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
899+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
900900
}
901901

902+
t_chan_width chan_width = init_chan(chan_width_fac, arch.Chans, graph_directionality);
903+
902904
int warnings = 0;
903905

904906
//Clean-up any previous RR graph

vpr/src/place/place.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ void try_place(const t_placer_opts& placer_opts,
442442
t_placer_statistics stats;
443443

444444
t_placement_checkpoint placement_checkpoint;
445+
t_graph_type graph_directionality;
445446

446447
std::shared_ptr<SetupTimingInfo> timing_info;
447448
std::shared_ptr<PlacementDelayCalculator> placement_delay_calc;
@@ -481,7 +482,13 @@ void try_place(const t_placer_opts& placer_opts,
481482

482483
width_fac = placer_opts.place_chan_width;
483484

484-
init_chan(width_fac, chan_width_dist);
485+
if (router_opts.route_type == GLOBAL) {
486+
graph_directionality = GRAPH_BIDIR;
487+
} else {
488+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
489+
}
490+
491+
init_chan(width_fac, chan_width_dist, graph_directionality);
485492

486493
alloc_and_load_placement_structs(placer_opts.place_cost_exp, placer_opts,
487494
directs, num_directs);

vpr/src/place/timing_place_lookup.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ static t_chan_width setup_chan_width(const t_router_opts& router_opts,
309309
/*we give plenty of tracks, this increases routability for the */
310310
/*lookup table generation */
311311

312+
t_graph_type graph_directionality;
312313
int width_fac;
313314

314315
if (router_opts.fixed_channel_width == NO_FIXED_CHANNEL_WIDTH) {
@@ -324,7 +325,13 @@ static t_chan_width setup_chan_width(const t_router_opts& router_opts,
324325
width_fac = router_opts.fixed_channel_width;
325326
}
326327

327-
return init_chan(width_fac, chan_width_dist);
328+
if (router_opts.route_type == GLOBAL) {
329+
graph_directionality = GRAPH_BIDIR;
330+
} else {
331+
graph_directionality = GRAPH_UNIDIR;
332+
}
333+
334+
return init_chan(width_fac, chan_width_dist, graph_directionality);
328335
}
329336

330337
static float route_connection_delay(

vpr/src/route/route_common.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,17 @@ void try_graph(int width_fac, const t_router_opts& router_opts, t_det_routing_ar
207207
auto& device_ctx = g_vpr_ctx.mutable_device();
208208

209209
t_graph_type graph_type;
210+
t_graph_type graph_directionality;
210211
if (router_opts.route_type == GLOBAL) {
211212
graph_type = GRAPH_GLOBAL;
213+
graph_directionality = GRAPH_BIDIR;
212214
} else {
213215
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
216+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
214217
}
215218

216219
/* Set the channel widths */
217-
t_chan_width chan_width = init_chan(width_fac, chan_width_dist);
220+
t_chan_width chan_width = init_chan(width_fac, chan_width_dist, graph_directionality);
218221

219222
/* Free any old routing graph, if one exists. */
220223
free_rr_graph();
@@ -256,14 +259,17 @@ bool try_route(int width_fac,
256259
auto& cluster_ctx = g_vpr_ctx.clustering();
257260

258261
t_graph_type graph_type;
262+
t_graph_type graph_directionality;
259263
if (router_opts.route_type == GLOBAL) {
260264
graph_type = GRAPH_GLOBAL;
265+
graph_directionality = GRAPH_BIDIR;
261266
} else {
262267
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
268+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
263269
}
264270

265271
/* Set the channel widths */
266-
t_chan_width chan_width = init_chan(width_fac, chan_width_dist);
272+
t_chan_width chan_width = init_chan(width_fac, chan_width_dist, graph_directionality);
267273

268274
/* Set up the routing resource graph defined by this FPGA architecture. */
269275
int warning_count;

vpr/test/test_connection_router.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,17 @@ TEST_CASE("connection_router", "[vpr]") {
127127

128128
vpr_create_device_grid(vpr_setup, arch);
129129
vpr_setup_clock_networks(vpr_setup, arch);
130-
auto chan_width = init_chan(vpr_setup.RouterOpts.fixed_channel_width, arch.Chans);
130+
auto det_routing_arch = &vpr_setup.RoutingArch;
131+
auto& router_opts = vpr_setup.RouterOpts;
132+
t_graph_type graph_directionality;
133+
134+
if (router_opts.route_type == GLOBAL) {
135+
graph_directionality = GRAPH_BIDIR;
136+
} else {
137+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
138+
}
139+
140+
auto chan_width = init_chan(vpr_setup.RouterOpts.fixed_channel_width, arch.Chans, graph_directionality);
131141

132142
alloc_routing_structs(
133143
chan_width,

0 commit comments

Comments
 (0)