From f0943dea53600e2e05b13587bb64df3cf9cadc02 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 24 Apr 2025 22:01:56 +0200 Subject: [PATCH] More debugging support --- src/pex/pex/gsiDeclRExtractor.cc | 15 ++++++++++----- src/pex/pex/pexSquareCountingRExtractor.cc | 8 +++++--- src/pex/pex/pexSquareCountingRExtractor.h | 17 +++++++++++++++++ src/pex/pex/pexTriangulationRExtractor.cc | 5 ++++- src/pex/pex/pexTriangulationRExtractor.h | 17 +++++++++++++++++ 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/pex/pex/gsiDeclRExtractor.cc b/src/pex/pex/gsiDeclRExtractor.cc index 626575092..740765e33 100644 --- a/src/pex/pex/gsiDeclRExtractor.cc +++ b/src/pex/pex/gsiDeclRExtractor.cc @@ -400,16 +400,19 @@ Class decl_RNetwork ("pex", "RNetwork", "This class has been introduced in version 0.30.1\n" ); -static pex::RExtractor *new_sqc_rextractor (double dbu) +static pex::RExtractor *new_sqc_rextractor (double dbu, bool skip_simplify) { - return new pex::SquareCountingRExtractor (dbu); + auto res = new pex::SquareCountingRExtractor (dbu); + res->set_skip_simplfy (skip_simplify); + return res; } -static pex::RExtractor *new_tesselation_rextractor (double dbu, double min_b, double max_area) +static pex::RExtractor *new_tesselation_rextractor (double dbu, double min_b, double max_area, bool skip_reduction) { auto res = new pex::TriangulationRExtractor (dbu); res->triangulation_parameters ().min_b = min_b; res->triangulation_parameters ().max_area = max_area; + res->set_skip_reduction (skip_reduction); return res; } @@ -421,7 +424,7 @@ static pex::RNetwork *extract_ipolygon (pex::RExtractor *rex, const db::Polygon } Class decl_RExtractor ("pex", "RExtractor", - gsi::constructor ("square_counting_extractor", &new_sqc_rextractor, gsi::arg ("dbu"), + gsi::constructor ("square_counting_extractor", &new_sqc_rextractor, gsi::arg ("dbu"), gsi::arg ("skip_simplify", false), "@brief Creates a square counting R extractor\n" "The square counting extractor extracts resistances from a polygon with ports using the following approach:\n" "\n" @@ -440,9 +443,10 @@ Class decl_RExtractor ("pex", "RExtractor", "values, multiply the element resistance values by the sheet resistance.\n" "\n" "@param dbu The database unit of the polygons the extractor will work on\n" + "@param skip_simplify If true, the final step to simplify the netlist will be skipped. This feature is for testing mainly.\n" "@return A new \\RExtractor object that implements the square counting extractor\n" ) + - gsi::constructor ("tesselation_extractor", &new_tesselation_rextractor, gsi::arg ("dbu"), gsi::arg ("min_b", 0.3), gsi::arg ("max_area", 0.0), + gsi::constructor ("tesselation_extractor", &new_tesselation_rextractor, gsi::arg ("dbu"), gsi::arg ("min_b", 0.3), gsi::arg ("max_area", 0.0), gsi::arg ("skip_reduction", false), "@brief Creates a tesselation R extractor\n" "The tesselation extractor starts with a triangulation of the original polygon. The triangulation is " "turned into a resistor network and simplified.\n" @@ -464,6 +468,7 @@ Class decl_RExtractor ("pex", "RExtractor", "@param dbu The database unit of the polygons the extractor will work on\n" "@param min_b Defines the min 'b' value of the refined Delaunay triangulation (see \\Polygon#delaunay)\n" "@param max_area Defines maximum area value of the refined Delaunay triangulation (see \\Polygon#delaunay). The value is given in square micrometer units.\n" + "@param skip_reduction If true, the reduction step for the netlist will be skipped. This feature is for testing mainly. The resulting R graph will contain all the original triangles and the internal nodes representing the vertexes.\n" "@return A new \\RExtractor object that implements the square counting extractor\n" ) + gsi::factory_ext ("extract", &extract_ipolygon, gsi::arg ("polygon"), gsi::arg ("vertex_ports", std::vector (), "[]"), gsi::arg ("polygon_ports", std::vector (), "[]"), diff --git a/src/pex/pex/pexSquareCountingRExtractor.cc b/src/pex/pex/pexSquareCountingRExtractor.cc index 0ad1bfa27..9170239d0 100644 --- a/src/pex/pex/pexSquareCountingRExtractor.cc +++ b/src/pex/pex/pexSquareCountingRExtractor.cc @@ -71,6 +71,7 @@ struct JoinEdgeSets SquareCountingRExtractor::SquareCountingRExtractor (double dbu) { m_dbu = dbu; + m_skip_simplify = false; m_decomp_param.split_edges = true; m_decomp_param.with_segments = false; @@ -162,8 +163,7 @@ SquareCountingRExtractor::do_extract (const db::Polygon &db_poly, const std::vec ++em; } - // @@@ TODO: multiply with sheet rho! - // @@@ TODO: width dependency + // TODO: width dependency? if (r == 0) { rnetwork.create_element (pex::RElement::short_value (), pl->second, pl_next->second); } else { @@ -292,7 +292,9 @@ SquareCountingRExtractor::extract (const db::Polygon &polygon, const std::vector } - rnetwork.simplify (); + if (! m_skip_simplify) { + rnetwork.simplify (); + } } } diff --git a/src/pex/pex/pexSquareCountingRExtractor.h b/src/pex/pex/pexSquareCountingRExtractor.h index 9ceb99d46..2d95b3e26 100644 --- a/src/pex/pex/pexSquareCountingRExtractor.h +++ b/src/pex/pex/pexSquareCountingRExtractor.h @@ -64,6 +64,22 @@ public: return m_decomp_param; } + /** + * @brief Sets a value indicating whether to skip the simplify step + */ + void set_skip_simplfy (bool f) + { + m_skip_simplify = f; + } + + /** + * @brief Gets a value indicating whether to skip the simplify step + */ + bool skip_simplify () const + { + return m_skip_simplify; + } + /** * @brief Sets the database unit */ @@ -129,6 +145,7 @@ protected: private: db::plc::ConvexDecompositionParameters m_decomp_param; double m_dbu; + bool m_skip_simplify; }; } diff --git a/src/pex/pex/pexTriangulationRExtractor.cc b/src/pex/pex/pexTriangulationRExtractor.cc index e52a40f88..b39a6a37d 100644 --- a/src/pex/pex/pexTriangulationRExtractor.cc +++ b/src/pex/pex/pexTriangulationRExtractor.cc @@ -32,6 +32,7 @@ namespace pex TriangulationRExtractor::TriangulationRExtractor (double dbu) { m_dbu = dbu; + m_skip_reduction = false; m_tri_param.min_b = 0.3; m_tri_param.max_area = 0.0; @@ -206,7 +207,9 @@ TriangulationRExtractor::extract (const db::Polygon &polygon, const std::vector< // eliminate internal nodes - eliminate_all (rnetwork); + if (! m_skip_reduction) { + eliminate_all (rnetwork); + } } void diff --git a/src/pex/pex/pexTriangulationRExtractor.h b/src/pex/pex/pexTriangulationRExtractor.h index 4215d0180..6749c7f84 100644 --- a/src/pex/pex/pexTriangulationRExtractor.h +++ b/src/pex/pex/pexTriangulationRExtractor.h @@ -65,6 +65,22 @@ public: return m_tri_param; } + /** + * @brief Sets a value indicating whether to skip the reduction step + */ + void set_skip_reduction (bool f) + { + m_skip_reduction = f; + } + + /** + * @brief Gets a value indicating whether to skip the reduction step + */ + bool skip_reduction () const + { + return m_skip_reduction; + } + /** * @brief Sets the database unit */ @@ -89,6 +105,7 @@ public: private: db::plc::TriangulationParameters m_tri_param; double m_dbu; + bool m_skip_reduction; void create_conductances (const db::plc::Polygon &tri, const std::unordered_map &vertex2node, RNetwork &rnetwork); void eliminate_node (pex::RNode *node, RNetwork &rnetwork);