Skip to content

Commit f56ab21

Browse files
authored
Merge pull request #1715 from verilog-to-routing/fix_cluster_constraints_init
Add routine to initialize cluster_constraints data structure in the c…
2 parents 283e6a6 + 25a37a6 commit f56ab21

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

vpr/src/base/vpr_api.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
#include "cluster.h"
7070
#include "output_clustering.h"
7171
#include "vpr_constraints_reader.h"
72+
#include "place_constraints.h"
73+
7274
#include "vpr_constraints_writer.h"
75+
7376
#include "pack_report.h"
7477
#include "overuse_report.h"
7578

@@ -517,6 +520,8 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {
517520
VTR_ASSERT(packer_opts.doPacking == STAGE_LOAD);
518521
//Load a previous packing from the .net file
519522
vpr_load_packing(vpr_setup, arch);
523+
//Load cluster_constraints data structure here since loading pack file
524+
load_cluster_constraints();
520525
}
521526

522527
/* Sanity check the resulting netlist */

vpr/src/place/place_constraints.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,37 @@ bool cluster_floorplanning_legal(ClusterBlockId blk_id, const t_pl_loc& loc) {
142142

143143
return floorplanning_good;
144144
}
145+
146+
void load_cluster_constraints() {
147+
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
148+
auto& cluster_ctx = g_vpr_ctx.clustering();
149+
ClusterAtomsLookup atoms_lookup;
150+
151+
floorplanning_ctx.cluster_constraints.resize(cluster_ctx.clb_nlist.blocks().size());
152+
153+
for (auto cluster_id : cluster_ctx.clb_nlist.blocks()) {
154+
std::vector<AtomBlockId> atoms = atoms_lookup.atoms_in_cluster(cluster_id);
155+
PartitionRegion empty_pr;
156+
floorplanning_ctx.cluster_constraints[cluster_id] = empty_pr;
157+
158+
//if there are any constrainted atoms in the cluster,
159+
//we update the cluster's PartitionRegion
160+
for (unsigned int i = 0; i < atoms.size(); i++) {
161+
PartitionId partid = floorplanning_ctx.constraints.get_atom_partition(atoms[i]);
162+
163+
if (partid != PartitionId::INVALID()) {
164+
PartitionRegion pr = floorplanning_ctx.constraints.get_partition_pr(partid);
165+
if (floorplanning_ctx.cluster_constraints[cluster_id].empty()) {
166+
floorplanning_ctx.cluster_constraints[cluster_id] = pr;
167+
} else {
168+
PartitionRegion intersect_pr = intersection(pr, floorplanning_ctx.cluster_constraints[cluster_id]);
169+
if (intersect_pr.empty()) {
170+
VTR_LOG_ERROR("Cluster block %zu has atoms with incompatible floorplan constraints.\n", size_t(cluster_id));
171+
} else {
172+
floorplanning_ctx.cluster_constraints[cluster_id] = intersect_pr;
173+
}
174+
}
175+
}
176+
}
177+
}
178+
}

vpr/src/place/place_constraints.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Author: khalid88
77
*/
88
#include "move_transactions.h"
9+
#include "clustered_netlist_utils.h"
910

1011
#ifndef VPR_SRC_PLACE_PLACE_CONSTRAINTS_H_
1112
# define VPR_SRC_PLACE_PLACE_CONSTRAINTS_H_
@@ -51,4 +52,15 @@ inline bool floorplan_legal(const t_pl_blocks_to_be_moved& blocks_affected) {
5152
return true;
5253
}
5354

55+
/*
56+
* Load cluster_constraints if the pack stage of VPR is skipped. The cluster_constraints
57+
* data structure is normally loaded during packing, so this routine is called when the packing stage is not performed.
58+
* If no constraints file is specified, every cluster is assigned
59+
* an empty PartitionRegion. If a constraints file is specified, cluster_constraints is loaded according to
60+
* the floorplan constraints specified in the file.
61+
* Load cluster_constraints according to the floorplan constraints specified in
62+
* the constraints XML file.
63+
*/
64+
void load_cluster_constraints();
65+
5466
#endif /* VPR_SRC_PLACE_PLACE_CONSTRAINTS_H_ */

0 commit comments

Comments
 (0)