diff --git a/openfpga/src/annotation/vpr_clustering_annotation.cpp b/openfpga/src/annotation/vpr_clustering_annotation.cpp index e0c7ab575..8dbc2d6f4 100644 --- a/openfpga/src/annotation/vpr_clustering_annotation.cpp +++ b/openfpga/src/annotation/vpr_clustering_annotation.cpp @@ -86,5 +86,10 @@ void VprClusteringAnnotation::add_physical_pb(const ClusterBlockId& block_id, physical_pbs_[block_id] = physical_pb; } +PhysicalPb& VprClusteringAnnotation::mutable_physical_pb(const ClusterBlockId& block_id) { + VTR_ASSERT(physical_pbs_.end() != physical_pbs_.find(block_id)); + + return physical_pbs_.at(block_id); +} } /* End namespace openfpga*/ diff --git a/openfpga/src/annotation/vpr_clustering_annotation.h b/openfpga/src/annotation/vpr_clustering_annotation.h index b72173e1d..f8e84bb02 100644 --- a/openfpga/src/annotation/vpr_clustering_annotation.h +++ b/openfpga/src/annotation/vpr_clustering_annotation.h @@ -41,6 +41,7 @@ class VprClusteringAnnotation { const ClusterNetId& net_id); void adapt_truth_table(t_pb* pb, const AtomNetlist::TruthTable& tt); void add_physical_pb(const ClusterBlockId& block_id, const PhysicalPb& physical_pb); + PhysicalPb& mutable_physical_pb(const ClusterBlockId& block_id); private: /* Internal data */ /* Pair a regular pb_type to its physical pb_type */ std::map> net_names_; diff --git a/openfpga/src/repack/physical_pb.cpp b/openfpga/src/repack/physical_pb.cpp index a29b6d401..59417080e 100644 --- a/openfpga/src/repack/physical_pb.cpp +++ b/openfpga/src/repack/physical_pb.cpp @@ -16,6 +16,17 @@ PhysicalPb::physical_pb_range PhysicalPb::pbs() const { return vtr::make_range(pb_ids_.begin(), pb_ids_.end()); } +std::vector PhysicalPb::primitive_pbs() const { + std::vector results; + /* The primitive pbs are those without any children */ + for (auto pb : pbs()) { + if (true == child_pbs_[pb].empty()) { + results.push_back(pb); + } + } + return results; +} + std::string PhysicalPb::name(const PhysicalPbId& pb) const { VTR_ASSERT(true == valid_pb_id(pb)); return names_[pb]; diff --git a/openfpga/src/repack/physical_pb.h b/openfpga/src/repack/physical_pb.h index d5f5b00a3..caea0a0b9 100644 --- a/openfpga/src/repack/physical_pb.h +++ b/openfpga/src/repack/physical_pb.h @@ -39,6 +39,7 @@ class PhysicalPb { typedef vtr::Range physical_pb_range; public: /* Public aggregators */ physical_pb_range pbs() const; + std::vector primitive_pbs() const; std::string name(const PhysicalPbId& pb) const; PhysicalPbId find_pb(const t_pb_graph_node* name) const; PhysicalPbId parent(const PhysicalPbId& pb) const;