OpenFPGA/openfpga/src/annotation/annotate_routing.cpp

55 lines
2.0 KiB
C++
Raw Normal View History

2020-02-05 23:12:44 -06:00
/********************************************************************
* This file includes functions that are used to annotate routing results
* from VPR to OpenFPGA
*******************************************************************/
/* Headers from vtrutil library */
#include "vtr_assert.h"
#include "vtr_log.h"
#include "annotate_routing.h"
/* begin namespace openfpga */
namespace openfpga {
/********************************************************************
* Create a mapping between each rr_node and its mapped nets
* based on VPR routing results
* - Unmapped rr_node will use invalid ids
*******************************************************************/
void annotate_rr_node_nets(const DeviceContext& device_ctx,
const ClusteringContext& clustering_ctx,
const RoutingContext& routing_ctx,
VprRoutingAnnotation& vpr_routing_annotation,
const bool& verbose) {
2020-02-05 23:12:44 -06:00
size_t counter = 0;
VTR_LOG("Annotating rr_node with routed nets...");
VTR_LOGV(verbose, "\n");
2020-02-05 23:12:44 -06:00
for (auto net_id : clustering_ctx.clb_nlist.nets()) {
2020-02-05 23:12:44 -06:00
/* Ignore nets that are not routed */
if (true == clustering_ctx.clb_nlist.net_is_ignored(net_id)) {
2020-02-05 23:12:44 -06:00
continue;
}
/* Ignore used in local cluster only, reserved one CLB pin */
if (false == clustering_ctx.clb_nlist.net_sinks(net_id).size()) {
2020-02-05 23:12:44 -06:00
continue;
}
t_trace* tptr = routing_ctx.trace[net_id].head;
2020-02-05 23:12:44 -06:00
while (tptr != nullptr) {
RRNodeId rr_node = tptr->index;
/* Ignore source and sink nodes, they are the common node multiple starting and ending points */
if ( (SOURCE != device_ctx.rr_graph.node_type(rr_node))
&& (SINK != device_ctx.rr_graph.node_type(rr_node)) ) {
vpr_routing_annotation.set_rr_node_net(rr_node, net_id);
counter++;
}
2020-02-05 23:12:44 -06:00
tptr = tptr->next;
}
}
VTR_LOG("Done with %d nodes mapping\n", counter);
}
} /* end namespace openfpga */