Skip to content

Commit 5d3c43d

Browse files
author
Brandon Heiner
committed
Added requested changes and fixed to pass all tests
1 parent 0129d82 commit 5d3c43d

File tree

12 files changed

+100
-40
lines changed

12 files changed

+100
-40
lines changed

doc/src/arch/reference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ 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, only uniform distributions may be used
758+
757759
.. arch:tag:: <x distr="{gaussian|uniform|pulse|delta}" peak="float" width=" float" xpeak=" float" dc=" float"/>
758760
759761
:req_param distr: The channel width distribution function

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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void CheckSetup(const t_packer_opts& PackerOpts,
1212
const t_router_opts& RouterOpts,
1313
const t_det_routing_arch& RoutingArch,
1414
const std::vector<t_segment_inf>& Segments,
15-
const t_timing_inf Timing) {
15+
const t_timing_inf Timing,
16+
const t_chan_width_dist Chans) {
1617
int i;
1718
int Tmp;
1819

@@ -60,6 +61,14 @@ void CheckSetup(const t_packer_opts& PackerOpts,
6061
}
6162
}
6263

64+
if (DETAILED == RouterOpts.route_type) {
65+
if ((Chans.chan_x_dist.type != UNIFORM)
66+
|| (Chans.chan_y_dist.type != UNIFORM)) {
67+
VPR_FATAL_ERROR(VPR_ERROR_OTHER,
68+
"Detailed routing currently only supported on FPGAs with uniform channel distributions.\n");
69+
}
70+
}
71+
6372
for (i = 0; i < (int)Segments.size(); ++i) {
6473
Tmp = Segments[i].arch_opin_switch;
6574
auto& device_ctx = g_vpr_ctx.device();

vpr/src/base/CheckSetup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void CheckSetup(const t_packer_opts& PackerOpts,
77
const t_router_opts& RouterOpts,
88
const t_det_routing_arch& RoutingArch,
99
const std::vector<t_segment_inf>& Segments,
10-
const t_timing_inf Timing);
10+
const t_timing_inf Timing,
11+
const t_chan_width_dist Chans);
1112

1213
#endif

vpr/src/base/place_and_route.cpp

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@
3737
#include "timing_info.h"
3838
#include "tatum/echo_writer.hpp"
3939

40-
/******************* Variables local to this module ************************/
41-
42-
/* Used to pass directionality from the binary_search_place_and_route subroutine *
43-
* to the init_chan subroutine. */
44-
static t_graph_type graph_directionality;
45-
4640
/******************* Subroutines local to this module ************************/
4741

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

5045
/************************* Subroutine Definitions ****************************/
@@ -82,6 +77,7 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
8277
int warnings;
8378

8479
t_graph_type graph_type;
80+
t_graph_type graph_directionality;
8581

8682
/* We have chosen to pass placer_opts_ref by reference because of its large size. *
8783
* However, since the value is mutated later in the function, we declare a *
@@ -93,7 +89,7 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
9389

9490
if (router_opts.route_type == GLOBAL) {
9591
graph_type = GRAPH_GLOBAL;
96-
graph_directionality = GRAPH_GLOBAL;
92+
graph_directionality = GRAPH_BIDIR;
9793
} else {
9894
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
9995
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
@@ -350,7 +346,7 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
350346
/* End binary search verification. */
351347
/* Restore the best placement (if necessary), the best routing, and *
352348
* * the best channel widths for final drawing and statistics output. */
353-
t_chan_width chan_width = init_chan(final, arch->Chans);
349+
t_chan_width chan_width = init_chan(final, arch->Chans, graph_directionality);
354350

355351
free_rr_graph();
356352

@@ -391,9 +387,11 @@ int binary_search_place_and_route(const t_placer_opts& placer_opts_ref,
391387
* @brief Assigns widths to channels (in tracks).
392388
*
393389
* Minimum one track per channel. The channel distributions read from
394-
* 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.
395393
*/
396-
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) {
397395
auto& device_ctx = g_vpr_ctx.mutable_device();
398396
auto& grid = device_ctx.grid;
399397

@@ -403,7 +401,6 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
403401
t_chan_width chan_width;
404402
chan_width.x_list.resize(grid.height());
405403
chan_width.y_list.resize(grid.width());
406-
int computed_width;
407404

408405
if (grid.height() > 1) {
409406
int num_channels = grid.height() - 1;
@@ -412,12 +409,7 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
412409

413410
for (size_t i = 0; i < grid.height(); ++i) {
414411
float y = float(i) / num_channels;
415-
computed_width = (int)floor(cfactor * comp_width(&chan_x_dist, y, separation) + 0.5);
416-
if ((GRAPH_BIDIR == graph_directionality) || computed_width % 2 == 0) {
417-
chan_width.x_list[i] = computed_width;
418-
} else {
419-
chan_width.x_list[i] = computed_width - 1;
420-
}
412+
chan_width.x_list[i] = compute_chan_width(cfactor, chan_x_dist, y, separation, graph_directionality);
421413
chan_width.x_list[i] = std::max(chan_width.x_list[i], 1); //Minimum channel width 1
422414
}
423415
}
@@ -429,12 +421,7 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
429421

430422
for (size_t i = 0; i < grid.width(); ++i) { //-2 for no perim channels
431423
float x = float(i) / num_channels;
432-
computed_width = (int)floor(cfactor * comp_width(&chan_y_dist, x, separation) + 0.5);
433-
if ((GRAPH_BIDIR == graph_directionality) || computed_width % 2 == 0) {
434-
chan_width.y_list[i] = computed_width;
435-
} else {
436-
chan_width.y_list[i] = computed_width - 1;
437-
}
424+
chan_width.y_list[i] = compute_chan_width(cfactor, chan_y_dist, x, separation, graph_directionality);
438425
chan_width.y_list[i] = std::max(chan_width.y_list[i], 1); //Minimum channel width 1
439426
}
440427
}
@@ -470,6 +457,26 @@ t_chan_width init_chan(int cfactor, t_chan_width_dist chan_width_dist) {
470457
return chan_width;
471458
}
472459

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.
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+
473480
/**
474481
* @brief Return the relative channel density.
475482
*

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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ void vpr_init_with_options(const t_options* options, t_vpr_setup* vpr_setup, t_a
305305
CheckSetup(vpr_setup->PackerOpts,
306306
vpr_setup->PlacerOpts,
307307
vpr_setup->RouterOpts,
308-
vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing);
308+
vpr_setup->RoutingArch, vpr_setup->Segments, vpr_setup->Timing, arch->Chans);
309309

310310
/* flush any messages to user still in stdout that hasn't gotten displayed */
311311
fflush(stdout);
@@ -885,15 +885,18 @@ void vpr_create_rr_graph(t_vpr_setup& vpr_setup, const t_arch& arch, int chan_wi
885885
auto det_routing_arch = &vpr_setup.RoutingArch;
886886
auto& router_opts = vpr_setup.RouterOpts;
887887

888-
t_chan_width chan_width = init_chan(chan_width_fac, arch.Chans);
889-
890888
t_graph_type graph_type;
889+
t_graph_type graph_directionality;
891890
if (router_opts.route_type == GLOBAL) {
892891
graph_type = GRAPH_GLOBAL;
892+
graph_directionality = GRAPH_BIDIR;
893893
} else {
894894
graph_type = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
895+
graph_directionality = (det_routing_arch->directionality == BI_DIRECTIONAL ? GRAPH_BIDIR : GRAPH_UNIDIR);
895896
}
896897

898+
t_chan_width chan_width = init_chan(chan_width_fac, arch.Chans, graph_directionality);
899+
897900
int warnings = 0;
898901

899902
//Clean-up any previous RR graph
@@ -1175,9 +1178,10 @@ void vpr_check_setup(const t_packer_opts& PackerOpts,
11751178
const t_router_opts& RouterOpts,
11761179
const t_det_routing_arch& RoutingArch,
11771180
const std::vector<t_segment_inf>& Segments,
1178-
const t_timing_inf& Timing) {
1181+
const t_timing_inf& Timing,
1182+
const t_chan_width_dist& Chans) {
11791183
CheckSetup(PackerOpts, PlacerOpts, RouterOpts, RoutingArch,
1180-
Segments, Timing);
1184+
Segments, Timing, Chans);
11811185
}
11821186

11831187
///@brief Show current setup

vpr/src/base/vpr_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ void vpr_check_setup(const t_packer_opts& PackerOpts,
175175
const t_router_opts& RouterOpts,
176176
const t_det_routing_arch& RoutingArch,
177177
const std::vector<t_segment_inf>& Segments,
178-
const t_timing_inf& Timing);
178+
const t_timing_inf& Timing,
179+
const t_chan_width_dist& Chans);
179180

180181
///@brief Show current setup
181182
void vpr_show_setup(const t_vpr_setup& vpr_setup);

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)