From 854320d52d295e3031e55e16ce2f914149eb72a7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 20 May 2020 23:27:06 +0200 Subject: [PATCH] Debugging: proper assignment of net names through labels. --- src/db/db/dbHierNetworkProcessor.cc | 14 +++++-------- src/db/db/dbHierNetworkProcessor.h | 13 +++++++++++- src/db/db/dbNetlistExtractor.cc | 20 +++++++++++-------- src/db/unit_tests/dbNetlistExtractorTests.cc | 18 ++++++++++++++++- testdata/algo/device_extract_au1a.gds | Bin 7914 -> 8330 bytes 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/db/db/dbHierNetworkProcessor.cc b/src/db/db/dbHierNetworkProcessor.cc index babb8d5fc..33ae690d4 100644 --- a/src/db/db/dbHierNetworkProcessor.cc +++ b/src/db/db/dbHierNetworkProcessor.cc @@ -990,7 +990,7 @@ template struct get_shape_flags { }; template <> struct get_shape_flags { - db::ShapeIterator::flags_type operator() (bool /*with_attr*/) const + db::ShapeIterator::flags_type operator() () const { return db::ShapeIterator::Edges; } @@ -999,7 +999,7 @@ struct get_shape_flags template <> struct get_shape_flags { - db::ShapeIterator::flags_type operator() (bool /*with_attr*/) const + db::ShapeIterator::flags_type operator() () const { return db::ShapeIterator::Polygons; } @@ -1008,13 +1008,9 @@ struct get_shape_flags template <> struct get_shape_flags { - db::ShapeIterator::flags_type operator() (bool with_attr) const + db::ShapeIterator::flags_type operator() () const { - if (with_attr) { - return db::ShapeIterator::flags_type (db::ShapeIterator::Polygons | db::ShapeIterator::Texts); - } else { - return db::ShapeIterator::flags_type (db::ShapeIterator::Polygons); - } + return db::ShapeIterator::flags_type (db::ShapeIterator::Polygons | db::ShapeIterator::Texts); } }; @@ -1030,7 +1026,7 @@ local_clusters::build_clusters (const db::Cell &cell, const db::Connectivity db::box_convert bc; addressable_shape_delivery heap; attr_accessor attr; - db::ShapeIterator::flags_type shape_flags = get_shape_flags () (attr_equivalence != 0 /*with attributes*/); + db::ShapeIterator::flags_type shape_flags = get_shape_flags () (); for (db::Connectivity::layer_iterator l = conn.begin_layers (); l != conn.end_layers (); ++l) { const db::Shapes &shapes = cell.shapes (*l); diff --git a/src/db/db/dbHierNetworkProcessor.h b/src/db/db/dbHierNetworkProcessor.h index 577eef944..625a972b8 100644 --- a/src/db/db/dbHierNetworkProcessor.h +++ b/src/db/db/dbHierNetworkProcessor.h @@ -31,6 +31,7 @@ #include "dbCell.h" #include "dbInstElement.h" #include "tlEquivalenceClusters.h" +#include "tlAssert.h" #include #include @@ -1365,7 +1366,17 @@ inline db::properties_id_type prop_id_from_attr (size_t attr) */ inline size_t text_ref_to_attr (const db::Text *tr) { - return size_t (tr) * 2 + 1; + return size_t (tr) + 1; +} + +/** + * @brief Gets the text value from an attribute ID + */ +inline const char *text_from_attr (size_t attr) +{ + tl_assert ((attr & 1) != 0); + const db::Text *t = reinterpret_cast (attr - 1); + return t->string (); } } diff --git a/src/db/db/dbNetlistExtractor.cc b/src/db/db/dbNetlistExtractor.cc index bfe1fba9f..7783ffbc6 100644 --- a/src/db/db/dbNetlistExtractor.cc +++ b/src/db/db/dbNetlistExtractor.cc @@ -300,19 +300,23 @@ void NetlistExtractor::collect_labels (const connected_clusters_type &clusters, const local_cluster_type &lc = clusters.cluster_by_id (cid); for (local_cluster_type::attr_iterator a = lc.begin_attr (); a != lc.end_attr (); ++a) { - if (! db::is_prop_id_attr (*a)) { - continue; - } + if (db::is_prop_id_attr (*a)) { - db::properties_id_type pi = db::prop_id_from_attr (*a); + db::properties_id_type pi = db::prop_id_from_attr (*a); - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (pi); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (pi); + for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + + if (m_text_annot_name_id.first && j->first == m_text_annot_name_id.second) { + net_names.insert (j->second.to_string ()); + } - if (m_text_annot_name_id.first && j->first == m_text_annot_name_id.second) { - net_names.insert (j->second.to_string ()); } + } else { + + net_names.insert (db::text_from_attr (*a)); + } } diff --git a/src/db/unit_tests/dbNetlistExtractorTests.cc b/src/db/unit_tests/dbNetlistExtractorTests.cc index c6864d444..8b3600bd5 100644 --- a/src/db/unit_tests/dbNetlistExtractorTests.cc +++ b/src/db/unit_tests/dbNetlistExtractorTests.cc @@ -77,6 +77,7 @@ static void dump_nets_to_layout (const db::Netlist &nl, const db::hier_clusters< for (db::Circuit::const_net_iterator n = c->begin_nets (); n != c->end_nets (); ++n) { + std::string nn = "NET_" + c->name () + "_" + n->expanded_name (); const db::local_cluster &lc = clusters.clusters_per_cell (c->cell_index ()).cluster_by_id (n->cluster_id ()); bool any_shapes = false; @@ -86,7 +87,6 @@ static void dump_nets_to_layout (const db::Netlist &nl, const db::hier_clusters< if (any_shapes || (with_device_cells && n->terminal_count() > 0)) { - std::string nn = "NET_" + c->name () + "_" + n->expanded_name (); db::Cell &net_cell = ly.cell (ly.add_cell (nn.c_str ())); cell.insert (db::CellInstArray (db::CellInst (net_cell.cell_index ()), db::Trans ())); @@ -288,6 +288,14 @@ TEST(1_DeviceAndNetExtraction) net_ex.extract_nets (dss, 0, conn, nl, cl); + // check if net names are properly assigned + db::Circuit *top_circuit = nl.circuit_by_name ("RINGO"); + EXPECT_EQ (top_circuit != 0, true); + if (top_circuit) { + db::Net *fb_net = top_circuit->net_by_name ("FB"); + EXPECT_EQ (fb_net != 0, true); + } + // debug layers produced for nets // 202/0 -> Active // 203/0 -> Poly @@ -518,6 +526,14 @@ TEST(1a_DeviceAndNetExtractionWithTextsAsLabels) net_ex.extract_nets (dss, 0, conn, nl, cl); + // check if net names are properly assigned + db::Circuit *top_circuit = nl.circuit_by_name ("RINGO"); + EXPECT_EQ (top_circuit != 0, true); + if (top_circuit) { + db::Net *fb_net = top_circuit->net_by_name ("FB"); + EXPECT_EQ (fb_net != 0, true); + } + // debug layers produced for nets // 202/0 -> Active // 203/0 -> Poly diff --git a/testdata/algo/device_extract_au1a.gds b/testdata/algo/device_extract_au1a.gds index 79534b993db2fa59f48764479a023843932bb74a..47ac063c7e903def18bd5df9938bcdc44bff5693 100644 GIT binary patch delta 848 zcmaE5+vTXlz{bGD6u}_F$i)7Hft5joK^zEGkl7QJ)CDmGqvEj$p1O}IIC&Q%Hqli~ zDwE$a|5n5>nL&V!&CfL?-qSD4C|<>cVG@_vWChlr1Qhy*hD_eY^ofIqfq{*eiQ(Mj zIid=3>g3HFZdkm@#d#Zx z=r_)rSVSLiVN-jC8;jb_+jy#(bTM5i1PP@ePd|76_%Ih21_l2za=aJE==~5Q?MXl5HzMCesFVQVBvtp z-Z>fj$=(7x5vG;N$q|Uo$x4EAnSk+iP|%GTlo}?;$V|Q`$hKKWNR|^b3N}Ycn=mrD sIZZB*78MW@0;f2LJ3t;fC@6+17#19iMbO0sC@4HxkC%P(Ss7U-05r~>761SM delta 618 zcmeBjd}XV|z{bGD6u}_F$i)7Hft5jofq}t{!3vo@QAu48Q!pwXi{PpIn1YjcF=7*4 z#iTM>kM*7|I|G9ZD^9x^1lZX8TtnhL{lbjmRZJ!)vWZW=!1PlA!#$`9jVCW;6Q9KL z6Vo-DgV^pf64GusIgq1ya)BWG}I3`6*HPAo_^7M1}k5@68yiQPTa*jZb9&up_)n>R^PmqaG z4!@qsB|>wVR17EA3oB1H6INzYF$OU=*9psVV)}FQ8W|JD$qKx3>`*HvACwW^oF=Ej F1OOOxZx#Rm