Skip to content

Commit 649d616

Browse files
sfkhalidvaughnbetz
authored andcommitted
Added a lookup for which atoms are in a cluster in clustered_netlist_utils. Use this lookup when writing out constraints XML
1 parent f5b8750 commit 649d616

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

vpr/src/base/clustered_netlist_utils.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "clustered_netlist_utils.h"
2+
#include "globals.h"
23
ClusteredPinAtomPinsLookup::ClusteredPinAtomPinsLookup(const ClusteredNetlist& clustered_netlist, const AtomNetlist& atom_netlist, const IntraLbPbPinLookup& pb_gpin_lookup) {
34
init_lookup(clustered_netlist, atom_netlist, pb_gpin_lookup);
45
}
@@ -33,3 +34,25 @@ void ClusteredPinAtomPinsLookup::init_lookup(const ClusteredNetlist& clustered_n
3334
}
3435
}
3536
}
37+
38+
ClusterAtomsLookup::ClusterAtomsLookup() {
39+
init_lookup();
40+
}
41+
42+
void ClusterAtomsLookup::init_lookup() {
43+
auto& atom_ctx = g_vpr_ctx.atom();
44+
auto& cluster_ctx = g_vpr_ctx.clustering();
45+
46+
cluster_atoms.resize(cluster_ctx.clb_nlist.blocks().size());
47+
48+
for (auto atom_blk_id : atom_ctx.nlist.blocks()) {
49+
ClusterBlockId clb_index = atom_ctx.lookup.atom_clb(atom_blk_id);
50+
51+
cluster_atoms[clb_index].push_back(atom_blk_id);
52+
}
53+
}
54+
55+
std::vector<AtomBlockId> ClusterAtomsLookup::atoms_in_cluster(ClusterBlockId blk_id) {
56+
std::vector<AtomBlockId> atoms = cluster_atoms[blk_id];
57+
return atoms;
58+
}

vpr/src/base/clustered_netlist_utils.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,15 @@ class ClusteredPinAtomPinsLookup {
2727
vtr::vector<AtomPinId, ClusterPinId> atom_pin_connected_cluster_pin_;
2828
};
2929

30+
class ClusterAtomsLookup {
31+
public:
32+
ClusterAtomsLookup();
33+
std::vector<AtomBlockId> atoms_in_cluster(ClusterBlockId blk_id);
34+
35+
private:
36+
void init_lookup();
37+
38+
private:
39+
vtr::vector<ClusterBlockId, std::vector<AtomBlockId>> cluster_atoms;
40+
};
3041
#endif

vpr/src/base/vpr_constraints_writer.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "pugixml.hpp"
1414
#include "pugixml_util.hpp"
1515
#include "echo_files.h"
16+
#include "clustered_netlist_utils.h"
1617

1718
#include <fstream>
1819
#include "vpr_constraints_writer.h"
@@ -39,26 +40,14 @@ void write_vpr_floorplan_constraints(const char* file_name, int expand, bool sub
3940
}
4041

4142
void setup_vpr_floorplan_constraints(VprConstraints& constraints, int expand, bool subtile) {
42-
auto& place_ctx = g_vpr_ctx.placement();
43-
auto& atom_ctx = g_vpr_ctx.atom();
4443
auto& cluster_ctx = g_vpr_ctx.clustering();
45-
46-
std::map<ClusterBlockId, std::vector<AtomBlockId>> cluster_atoms;
47-
48-
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
49-
cluster_atoms.insert({blk_id, std::vector<AtomBlockId>()});
50-
}
51-
52-
for (auto atom_blk_id : atom_ctx.nlist.blocks()) {
53-
ClusterBlockId clb_index = atom_ctx.lookup.atom_clb(atom_blk_id);
54-
55-
cluster_atoms[clb_index].push_back(atom_blk_id);
56-
}
44+
auto& place_ctx = g_vpr_ctx.placement();
45+
ClusterAtomsLookup atoms_lookup;
5746

5847
int part_id = 0;
59-
for (auto i = cluster_atoms.begin(); i != cluster_atoms.end(); i++) {
48+
for (auto blk_id : cluster_ctx.clb_nlist.blocks()) {
6049
std::string part_name;
61-
part_name = cluster_ctx.clb_nlist.block_name(i->first);
50+
part_name = cluster_ctx.clb_nlist.block_name(blk_id);
6251
PartitionId partid(part_id);
6352

6453
Partition part;
@@ -67,7 +56,7 @@ void setup_vpr_floorplan_constraints(VprConstraints& constraints, int expand, bo
6756
PartitionRegion pr;
6857
Region reg;
6958

70-
auto loc = place_ctx.block_locs[i->first].loc;
59+
auto loc = place_ctx.block_locs[blk_id].loc;
7160

7261
reg.set_region_rect(loc.x - expand, loc.y - expand, loc.x + expand, loc.y + expand);
7362
if (subtile) {
@@ -79,10 +68,11 @@ void setup_vpr_floorplan_constraints(VprConstraints& constraints, int expand, bo
7968
part.set_part_region(pr);
8069
constraints.add_partition(part);
8170

82-
int num_atoms = i->second.size();
71+
std::vector<AtomBlockId> atoms = atoms_lookup.atoms_in_cluster(blk_id);
72+
int num_atoms = atoms.size();
8373

84-
for (auto j = 0; j < num_atoms; j++) {
85-
AtomBlockId atom_id = i->second[j];
74+
for (auto atm = 0; atm < num_atoms; atm++) {
75+
AtomBlockId atom_id = atoms[atm];
8676
constraints.add_constrained_atom(atom_id, partid);
8777
}
8878
part_id++;

vpr/src/base/vpr_constraints_writer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
#ifndef VPR_SRC_BASE_VPR_CONSTRAINTS_WRITER_H_
1717
#define VPR_SRC_BASE_VPR_CONSTRAINTS_WRITER_H_
1818

19+
/**
20+
* @brief Write out floorplan constraints to an XML file based on current placement
21+
*
22+
* @param file_name The name of the file that the constraints will be written to
23+
* @param expand The amount the floorplan region will be expanded around the current
24+
* x, y location of the block. Ex. if location is (1, 1) and expand = 1,
25+
* the floorplan region will be from (0, 0) to (2, 2).
26+
* @param subtile Specifies whether to write out the constraint regions with or without
27+
* subtile values.
28+
*/
1929
void write_vpr_floorplan_constraints(const char* file_name, int expand, bool subtile);
2030

2131
void setup_vpr_floorplan_constraints(VprConstraints& constraints, int expand, bool subtile);

0 commit comments

Comments
 (0)