Skip to content

Commit e8a5f57

Browse files
committed
Add netlist and architecture SHA256 ID consistency checks when reading placement file
1 parent 9b86233 commit e8a5f57

File tree

9 files changed

+89
-93
lines changed

9 files changed

+89
-93
lines changed

vpr/SRC/base/netlist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct t_vnet{
7777
struct t_netlist{
7878
//vector<t_blocks> blocks; To-do: Need to implement later
7979
vector<t_vnet> net;
80+
std::string netlist_id;
8081
};
8182

8283
void echo_global_nlist_net(const t_netlist* g_nlist);

vpr/SRC/base/place_and_route.cpp

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,34 @@ using namespace std;
3838
/******************* Subroutines local to this module ************************/
3939

4040
static int binary_search_place_and_route(struct s_placer_opts placer_opts,
41-
char *place_file, char *net_file, char *arch_file, char *route_file,
41+
struct s_file_name_opts filename_opts,
42+
const t_arch* arch,
4243
bool verify_binary_search, int min_chan_width_hint,
4344
struct s_annealing_sched annealing_sched,
4445
struct s_router_opts router_opts,
4546
struct s_det_routing_arch *det_routing_arch, t_segment_inf * segment_inf,
46-
t_timing_inf timing_inf, t_chan_width_dist chan_width_dist,
47-
t_direct_inf *directs, int num_directs);
47+
t_timing_inf timing_inf);
4848

4949
static float comp_width(t_chan * chan, float x, float separation);
5050

5151
void post_place_sync(const int L_num_blocks);
5252

5353
/************************* Subroutine Definitions ****************************/
5454

55-
bool place_and_route(struct s_placer_opts placer_opts, char *place_file, char *net_file,
56-
char *arch_file, char *route_file,
55+
bool place_and_route(struct s_placer_opts placer_opts,
56+
struct s_file_name_opts filename_opts,
57+
const t_arch* arch,
5758
struct s_annealing_sched annealing_sched,
5859
struct s_router_opts router_opts,
5960
struct s_det_routing_arch *det_routing_arch, t_segment_inf * segment_inf,
60-
t_timing_inf timing_inf, t_chan_width_dist chan_width_dist,
61-
t_direct_inf *directs, int num_directs) {
61+
t_timing_inf timing_inf) {
6262

6363
/* This routine controls the overall placement and routing of a circuit. */
6464
char msg[vtr::BUFSIZE];
6565

6666
bool success = false;
6767
vtr::t_chunk net_delay_ch = {NULL, 0, NULL};
6868

69-
/*struct s_linked_vptr *net_delay_chunk_list_head;*/
7069
vtr::t_ivec **clb_opins_used_locally = NULL; /* [0..num_blocks-1][0..num_class-1] */
7170
clock_t begin, end;
7271

@@ -79,18 +78,22 @@ bool place_and_route(struct s_placer_opts placer_opts, char *place_file, char *n
7978

8079
if (!placer_opts.doPlacement || placer_opts.place_freq == PLACE_NEVER) {
8180
/* Read the placement from a file */
81+
<<<<<<< HEAD
8282
read_place(place_file, arch_file, net_file, nx, ny, num_blocks, block);
83+
=======
84+
read_place(filename_opts.ArchFile, filename_opts.NetFile, filename_opts.PlaceFile, arch, nx, ny, num_blocks, block);
85+
>>>>>>> Add netlist and architecture SHA256 ID consistency checks when reading placement file
8386
sync_grid_to_blocks(num_blocks, nx, ny, grid);
8487
} else {
8588
VTR_ASSERT((PLACE_ONCE == placer_opts.place_freq) || (PLACE_ALWAYS == placer_opts.place_freq));
8689
begin = clock();
87-
try_place(placer_opts, annealing_sched, chan_width_dist, router_opts,
90+
try_place(placer_opts, annealing_sched, arch->Chans, router_opts,
8891
det_routing_arch, segment_inf,
8992
#ifdef ENABLE_CLASSIC_VPR_STA
9093
timing_inf,
9194
#endif
92-
directs, num_directs);
93-
print_place(place_file, net_file, arch_file);
95+
arch->Directs, arch->num_directs);
96+
print_place(filename_opts.ArchFile, arch->architecture_id, filename_opts.NetFile, g_clbs_nlist.netlist_id.c_str(), filename_opts.PlaceFile);
9497
end = clock();
9598

9699
vtr::printf_info("Placement took %g seconds.\n", (float)(end - begin) / CLOCKS_PER_SEC);
@@ -108,21 +111,21 @@ bool place_and_route(struct s_placer_opts placer_opts, char *place_file, char *n
108111
if(width_fac != NO_FIXED_CHANNEL_WIDTH) {
109112
//Only try if a fixed channel width is specified
110113
try_graph(width_fac, router_opts, det_routing_arch,
111-
segment_inf, chan_width_dist,
112-
directs, num_directs);
114+
segment_inf, arch->Chans,
115+
arch->Directs, arch->num_directs);
113116
}
114117
return(true);
115118
}
116119

117120
/* If channel width not fixed, use binary search to find min W */
118121
if (NO_FIXED_CHANNEL_WIDTH == width_fac) {
119122
//Binary search for the min channel width
120-
g_solution_inf.channel_width = binary_search_place_and_route(placer_opts, place_file, net_file,
121-
arch_file, route_file,
123+
g_solution_inf.channel_width = binary_search_place_and_route(placer_opts,
124+
filename_opts,
125+
arch,
122126
router_opts.verify_binary_search, router_opts.min_channel_width_hint,
123127
annealing_sched, router_opts,
124-
det_routing_arch, segment_inf, timing_inf, chan_width_dist,
125-
directs, num_directs);
128+
det_routing_arch, segment_inf, timing_inf);
126129
success = (g_solution_inf.channel_width > 0 ? true : false);
127130
} else {
128131
//Route at the specified channel width
@@ -150,8 +153,8 @@ bool place_and_route(struct s_placer_opts placer_opts, char *place_file, char *n
150153
#ifdef ENABLE_CLASSIC_VPR_STA
151154
slacks,
152155
#endif
153-
chan_width_dist,
154-
clb_opins_used_locally, directs, num_directs);
156+
arch->Chans,
157+
clb_opins_used_locally, arch->Directs, arch->num_directs);
155158

156159
if (success == false) {
157160

@@ -163,7 +166,7 @@ bool place_and_route(struct s_placer_opts placer_opts, char *place_file, char *n
163166

164167
vtr::printf_info("Circuit successfully routed with a channel width factor of %d.\n", width_fac);
165168

166-
print_route(route_file);
169+
print_route(filename_opts.RouteFile);
167170

168171
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_ROUTING_SINK_DELAYS)) {
169172
print_sink_delays(getEchoFileName(E_ECHO_ROUTING_SINK_DELAYS));
@@ -209,26 +212,17 @@ bool place_and_route(struct s_placer_opts placer_opts, char *place_file, char *n
209212
delete [] g_switch_fanin_remap;
210213
g_switch_fanin_remap = NULL;
211214

212-
/*WMF: cleaning up memory usage */
213-
214-
/* if (g_heap_free_head)
215-
free(g_heap_free_head);
216-
if (g_trace_free_head)
217-
free(g_trace_free_head);
218-
if (g_linked_f_pointer_free_head)
219-
free(g_linked_f_pointer_free_head);*/
220-
221215
return(success);
222216
}
223217

224218
static int binary_search_place_and_route(struct s_placer_opts placer_opts,
225-
char *place_file, char *net_file, char *arch_file, char *route_file,
219+
struct s_file_name_opts filename_opts,
220+
const t_arch* arch,
226221
bool verify_binary_search, int min_chan_width_hint,
227222
struct s_annealing_sched annealing_sched,
228223
struct s_router_opts router_opts,
229224
struct s_det_routing_arch *det_routing_arch, t_segment_inf * segment_inf,
230-
t_timing_inf timing_inf, t_chan_width_dist chan_width_dist,
231-
t_direct_inf *directs, int num_directs) {
225+
t_timing_inf timing_inf) {
232226

233227
/* This routine performs a binary search to find the minimum number of *
234228
* tracks per channel required to successfully route a circuit, and returns *
@@ -356,20 +350,20 @@ static int binary_search_place_and_route(struct s_placer_opts placer_opts,
356350

357351
if (placer_opts.place_freq == PLACE_ALWAYS) {
358352
placer_opts.place_chan_width = current;
359-
try_place(placer_opts, annealing_sched, chan_width_dist,
353+
try_place(placer_opts, annealing_sched, arch->Chans,
360354
router_opts, det_routing_arch, segment_inf,
361355
#ifdef ENABLE_CLASSIC_VPR_STA
362356
timing_inf,
363357
#endif
364-
directs, num_directs);
358+
arch->Directs, arch->num_directs);
365359
}
366360
success = try_route(current, router_opts, det_routing_arch, segment_inf,
367361
timing_inf, net_delay,
368362
#ifdef ENABLE_CLASSIC_VPR_STA
369363
slacks,
370364
#endif
371-
chan_width_dist,
372-
clb_opins_used_locally, directs, num_directs);
365+
arch->Chans,
366+
clb_opins_used_locally, arch->Directs, arch->num_directs);
373367
attempt_count++;
374368
fflush(stdout);
375369

@@ -471,27 +465,29 @@ static int binary_search_place_and_route(struct s_placer_opts placer_opts,
471465
break;
472466
if (placer_opts.place_freq == PLACE_ALWAYS) {
473467
placer_opts.place_chan_width = current;
474-
try_place(placer_opts, annealing_sched, chan_width_dist,
468+
try_place(placer_opts, annealing_sched, arch->Chans,
475469
router_opts, det_routing_arch, segment_inf,
476470
#ifdef ENABLE_CLASSIC_VPR_STA
477471
timing_inf,
478472
#endif
479-
directs, num_directs);
473+
arch->Directs, arch->num_directs);
480474
}
481475
success = try_route(current, router_opts, det_routing_arch,
482476
segment_inf, timing_inf, net_delay,
483477
#ifdef ENABLE_CLASSIC_VPR_STA
484478
slacks,
485479
#endif
486-
chan_width_dist, clb_opins_used_locally, directs, num_directs);
480+
arch->Chans, clb_opins_used_locally, arch->Directs, arch->num_directs);
487481

488482
if (success && Fc_clipped == false) {
489483
final = current;
490484
save_routing(best_routing, clb_opins_used_locally,
491485
saved_clb_opins_used_locally);
492486

493487
if (placer_opts.place_freq == PLACE_ALWAYS) {
494-
print_place(place_file, net_file, arch_file);
488+
print_place(filename_opts.ArchFile, arch->architecture_id,
489+
filename_opts.NetFile, g_clbs_nlist.netlist_id.c_str(),
490+
filename_opts.PlaceFile);
495491
}
496492
}
497493

@@ -507,18 +503,8 @@ static int binary_search_place_and_route(struct s_placer_opts placer_opts,
507503
/* End binary search verification. */
508504
/* Restore the best placement (if necessary), the best routing, and *
509505
* * the best channel widths for final drawing and statistics output. */
510-
init_chan(final, chan_width_dist);
511-
512-
#if 0
513-
if (placer_opts.place_freq == PLACE_ALWAYS)
514-
{
515-
vtr::printf_info("Reading best placement back in.\n");
516-
placer_opts.place_chan_width = final;
517-
read_place(place_file, net_file, arch_file, placer_opts,
518-
router_opts, chan_width_dist, det_routing_arch,
519-
segment_inf, timing_inf);
520-
}
521-
#endif
506+
init_chan(final, arch->Chans);
507+
522508
free_rr_graph();
523509

524510
build_rr_graph(graph_type, num_types, type_descriptors, nx, ny, grid,
@@ -532,7 +518,7 @@ static int binary_search_place_and_route(struct s_placer_opts placer_opts,
532518
router_opts.base_cost_type,
533519
router_opts.trim_empty_channels,
534520
router_opts.trim_obs_channels,
535-
directs, num_directs, false,
521+
arch->Directs, arch->num_directs, false,
536522
det_routing_arch->dump_rr_structs_file,
537523
&det_routing_arch->wire_to_rr_ipin_switch,
538524
&g_num_rr_switches,
@@ -550,7 +536,7 @@ static int binary_search_place_and_route(struct s_placer_opts placer_opts,
550536
}
551537
vtr::printf_info("Best routing used a channel width factor of %d.\n", final);
552538

553-
print_route(route_file);
539+
print_route(filename_opts.RouteFile);
554540

555541
if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_ROUTING_SINK_DELAYS)) {
556542
print_sink_delays(getEchoFileName(E_ECHO_ROUTING_SINK_DELAYS));

vpr/SRC/base/place_and_route.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ typedef struct s_fmap_cell {
1515
} t_fmap_cell;
1616

1717
bool place_and_route(
18-
struct s_placer_opts placer_opts, char *place_file, char *net_file,
19-
char *arch_file, char *route_file,
18+
struct s_placer_opts placer_opts,
19+
struct s_file_name_opts filename_opts,
20+
const t_arch* arch,
2021
struct s_annealing_sched annealing_sched,
2122
struct s_router_opts router_opts,
2223
struct s_det_routing_arch *det_routing_arch, t_segment_inf * segment_inf,
23-
t_timing_inf timing_inf, t_chan_width_dist chan_width_dist,
24-
t_direct_inf *directs, int num_directs);
24+
t_timing_inf timing_inf);
2525

2626
void init_chan(int cfactor, t_chan_width_dist chan_width_dist);

vpr/SRC/base/read_netlist.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ using namespace std;
1616
#include "vtr_assert.h"
1717
#include "vtr_util.h"
1818
#include "vtr_log.h"
19+
#include "vtr_digest.h"
1920

2021
#include "vpr_types.h"
2122
#include "vpr_error.h"
@@ -89,6 +90,9 @@ void read_netlist(const char *net_file, const t_arch* arch,
8990
/* Parse the file */
9091
vtr::printf_info("Begin loading packed FPGA netlist file.\n");
9192

93+
//Save an identifier for the netlist based on it's contents
94+
clb_nlist->netlist_id = vtr::secure_digest_file(net_file);
95+
9296
pugi::xml_document doc;
9397
pugiutil::loc_data loc_data;
9498
try {

0 commit comments

Comments
 (0)