Skip to content

Commit 0cd06c2

Browse files
committed
Add flat version of sync_netlists_to_routing
1 parent 21d0150 commit 0cd06c2

13 files changed

+459
-87
lines changed

utils/fasm/src/main.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using namespace std;
2323
#include "fasm.h"
2424

2525
#include "post_routing_pb_pin_fixup.h"
26+
#include "sync_netlists_to_routing_flat.h"
2627

2728
/*
2829
* Exit codes to signal success/failure to scripts
@@ -86,15 +87,7 @@ int main(int argc, const char **argv) {
8687
bool is_flat = vpr_setup.RouterOpts.flat_routing;
8788
if (flow_succeeded) {
8889
if(is_flat) {
89-
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.atom().nlist,
90-
g_vpr_ctx.device(),
91-
g_vpr_ctx.mutable_atom(),
92-
g_vpr_ctx.atom().lookup,
93-
g_vpr_ctx.mutable_clustering(),
94-
g_vpr_ctx.placement(),
95-
g_vpr_ctx.routing(),
96-
vpr_setup.PackerOpts.pack_verbosity > 2,
97-
is_flat);
90+
sync_netlists_to_routing_flat();
9891
} else {
9992
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist,
10093
g_vpr_ctx.device(),
@@ -103,8 +96,7 @@ int main(int argc, const char **argv) {
10396
g_vpr_ctx.mutable_clustering(),
10497
g_vpr_ctx.placement(),
10598
g_vpr_ctx.routing(),
106-
vpr_setup.PackerOpts.pack_verbosity > 2,
107-
is_flat);
99+
vpr_setup.PackerOpts.pack_verbosity > 2);
108100
}
109101
}
110102

utils/fasm/test/test_fasm.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
#include "fasm_utils.h"
1010
#include "arch_util.h"
1111
#include "rr_graph_writer.h"
12-
#include "post_routing_pb_pin_fixup.h"
1312
#include <sstream>
1413
#include <fstream>
1514
#include <regex>
1615
#include <cmath>
1716
#include <algorithm>
1817

18+
#include "post_routing_pb_pin_fixup.h"
19+
#include "sync_netlists_to_routing_flat.h"
20+
1921
static constexpr const char kArchFile[] = "test_fasm_arch.xml";
2022
static constexpr const char kRrGraphFile[] = "test_fasm_rrgraph.xml";
2123

@@ -327,15 +329,18 @@ TEST_CASE("fasm_integration_test", "[fasm]") {
327329
/* Sync netlist to the actual routing (necessary if there are block
328330
ports with equivalent pins) */
329331
if (flow_succeeded) {
330-
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist,
331-
g_vpr_ctx.device(),
332-
g_vpr_ctx.mutable_atom(),
333-
g_vpr_ctx.atom().lookup,
334-
g_vpr_ctx.mutable_clustering(),
335-
g_vpr_ctx.placement(),
336-
g_vpr_ctx.routing(),
337-
vpr_setup.PackerOpts.pack_verbosity > 2,
338-
is_flat);
332+
if (is_flat) {
333+
sync_netlists_to_routing_flat();
334+
} else {
335+
sync_netlists_to_routing((const Netlist<>&) g_vpr_ctx.clustering().clb_nlist,
336+
g_vpr_ctx.device(),
337+
g_vpr_ctx.mutable_atom(),
338+
g_vpr_ctx.atom().lookup,
339+
g_vpr_ctx.mutable_clustering(),
340+
g_vpr_ctx.placement(),
341+
g_vpr_ctx.routing(),
342+
vpr_setup.PackerOpts.pack_verbosity > 2);
343+
}
339344
}
340345

341346
std::stringstream fasm_string;

vpr/src/base/atom_lookup.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ ClusterNetId AtomLookup::clb_net(const AtomNetId net_id) const {
103103
}
104104

105105
void AtomLookup::set_atom_clb_net(const AtomNetId net_id, const ClusterNetId clb_net_index) {
106-
VTR_ASSERT(net_id);
107106
//If either are invalid remove any mapping
108107
if (!net_id && clb_net_index != ClusterNetId::INVALID()) {
109108
//Remove

vpr/src/base/vpr_api.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#include "arch_util.h"
8484

8585
#include "post_routing_pb_pin_fixup.h"
86-
86+
#include "sync_netlists_to_routing_flat.h"
8787

8888
#include "load_flat_place.h"
8989

@@ -1434,27 +1434,28 @@ bool vpr_analysis_flow(const Netlist<>& net_list,
14341434
* - Turn on verbose output when users require verbose output
14351435
* for packer (default verbosity is set to 2 for compact logs)
14361436
*/
1437-
if (!is_flat) {
1438-
if (route_status.success()) {
1439-
sync_netlists_to_routing(net_list,
1440-
g_vpr_ctx.device(),
1441-
g_vpr_ctx.mutable_atom(),
1442-
g_vpr_ctx.atom().lookup,
1443-
g_vpr_ctx.mutable_clustering(),
1444-
g_vpr_ctx.placement(),
1445-
g_vpr_ctx.routing(),
1446-
vpr_setup.PackerOpts.pack_verbosity > 2,
1447-
is_flat);
1448-
1449-
std::string post_routing_packing_output_file_name = vpr_setup.PackerOpts.output_file + ".post_routing";
1450-
write_packing_results_to_xml(vpr_setup.PackerOpts.global_clocks,
1451-
Arch.architecture_id,
1452-
post_routing_packing_output_file_name.c_str());
1437+
if (route_status.success()) {
1438+
if (is_flat) {
1439+
sync_netlists_to_routing_flat();
14531440
} else {
1454-
VTR_LOG_WARN("Synchronization between packing and routing results is not applied due to illegal circuit implementation\n");
1441+
sync_netlists_to_routing(net_list,
1442+
g_vpr_ctx.device(),
1443+
g_vpr_ctx.mutable_atom(),
1444+
g_vpr_ctx.atom().lookup,
1445+
g_vpr_ctx.mutable_clustering(),
1446+
g_vpr_ctx.placement(),
1447+
g_vpr_ctx.routing(),
1448+
vpr_setup.PackerOpts.pack_verbosity > 2);
14551449
}
1456-
VTR_LOG("\n");
1450+
1451+
std::string post_routing_packing_output_file_name = vpr_setup.PackerOpts.output_file + ".post_routing";
1452+
write_packing_results_to_xml(vpr_setup.PackerOpts.global_clocks,
1453+
Arch.architecture_id,
1454+
post_routing_packing_output_file_name.c_str());
1455+
} else {
1456+
VTR_LOG_WARN("Synchronization between packing and routing results is not applied due to illegal circuit implementation\n");
14571457
}
1458+
VTR_LOG("\n");
14581459

14591460
vpr_analysis(net_list,
14601461
vpr_setup,

vpr/src/base/vpr_context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,9 @@ struct RoutingContext : public Context {
496496
* @brief User specified routing constraints
497497
*/
498498
UserRouteConstraints constraints;
499+
500+
/** Is flat routing enabled? */
501+
bool is_flat;
499502
};
500503

501504
/**

vpr/src/pack/post_routing_pb_pin_fixup.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ static void update_cluster_pin_with_post_routing_results(const Netlist<>& net_li
5151
const AtomContext& atom_ctx,
5252
const DeviceContext& device_ctx,
5353
ClusteringContext& clustering_ctx,
54-
const vtr::vector<RRNodeId, ParentNetId>& rr_node_nets,
54+
const vtr::vector<RRNodeId, ClusterNetId>& rr_node_nets,
5555
const t_pl_loc& grid_coord,
5656
const ClusterBlockId& blk_id,
5757
size_t& num_mismatches,
58-
const bool& verbose,
59-
bool is_flat) {
58+
const bool& verbose) {
6059
const int sub_tile_z = grid_coord.sub_tile;
6160
const int coord_x = grid_coord.x;
6261
const int coord_y = grid_coord.y;
@@ -210,15 +209,7 @@ static void update_cluster_pin_with_post_routing_results(const Netlist<>& net_li
210209
continue;
211210
}
212211

213-
ClusterNetId cluster_equivalent_net_id = ClusterNetId::INVALID();
214-
if (is_flat) {
215-
cluster_equivalent_net_id = atom_ctx.lookup.clb_net(convert_to_atom_net_id(routing_net_id));
216-
if (routing_net_id != ParentNetId::INVALID()) {
217-
VTR_ASSERT(cluster_equivalent_net_id != ClusterNetId::INVALID());
218-
}
219-
} else {
220-
cluster_equivalent_net_id = convert_to_cluster_net_id(routing_net_id);
221-
}
212+
ClusterNetId cluster_equivalent_net_id = convert_to_cluster_net_id(routing_net_id);
222213

223214
/* If the net from the routing results matches the net from the packing results,
224215
* nothing to be changed. Move on to the next net.
@@ -1050,20 +1041,17 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
10501041
ClusteringContext& clustering_ctx,
10511042
const PlacementContext& placement_ctx,
10521043
const RoutingContext& routing_ctx,
1053-
const bool& verbose,
1054-
bool is_flat) {
1044+
const bool& verbose) {
10551045
vtr::ScopedStartFinishTimer timer("Synchronize the packed netlist to routing optimization");
10561046

10571047
/* Reset the database for post-routing clb net mapping */
10581048
clustering_ctx.post_routing_clb_pin_nets.clear();
10591049
clustering_ctx.pre_routing_net_pin_mapping.clear();
10601050

10611051
/* Create net-to-rr_node mapping */
1062-
vtr::vector<RRNodeId, ParentNetId> rr_node_nets = annotate_rr_node_nets(net_list,
1052+
vtr::vector<RRNodeId, ClusterNetId> rr_node_nets = annotate_rr_node_nets(clustering_ctx,
10631053
device_ctx,
1064-
routing_ctx,
1065-
verbose,
1066-
is_flat);
1054+
verbose);
10671055

10681056
IntraLbPbPinLookup intra_lb_pb_pin_lookup(device_ctx.logical_block_types);
10691057

@@ -1076,12 +1064,7 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
10761064
/* Update the core logic (center blocks of the FPGA) */
10771065
for (const ParentBlockId& blk_id : net_list.blocks()) {
10781066
/* We know the entrance to grid info and mapping results, do the fix-up for this block */
1079-
ClusterBlockId clb_blk_id;
1080-
if (is_flat) {
1081-
clb_blk_id = atom_look_up.atom_clb(convert_to_atom_block_id(blk_id));
1082-
} else {
1083-
clb_blk_id = convert_to_cluster_block_id(blk_id);
1084-
}
1067+
ClusterBlockId clb_blk_id = convert_to_cluster_block_id(blk_id);
10851068
VTR_ASSERT(clb_blk_id != ClusterBlockId::INVALID());
10861069

10871070
if (seen_block_ids.insert(clb_blk_id).second) {
@@ -1093,8 +1076,7 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
10931076
placement_ctx.block_locs[clb_blk_id].loc,
10941077
clb_blk_id,
10951078
num_mismatches,
1096-
verbose,
1097-
is_flat);
1079+
verbose);
10981080

10991081
update_cluster_routing_traces_with_post_routing_results(atom_ctx,
11001082
intra_lb_pb_pin_lookup,

vpr/src/pack/post_routing_pb_pin_fixup.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ void sync_netlists_to_routing(const Netlist<>& net_list,
1616
ClusteringContext& clustering_ctx,
1717
const PlacementContext& placement_ctx,
1818
const RoutingContext& routing_ctx,
19-
const bool& verbose,
20-
bool is_flat);
19+
const bool& verbose);
2120

2221
#endif

0 commit comments

Comments
 (0)