From 37012efba0ef39c27c5f0d6135be150e1978f287 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 24 Jun 2019 20:56:20 +0200 Subject: [PATCH] WIP: fixed unit tests, bug fix in DeepRegion -> and and not shall return a DeepRegion always. --- src/db/db/dbDeepRegion.cc | 30 +++++++++++++------- src/db/db/dbRegion.cc | 7 +++++ src/db/db/dbRegion.h | 6 ++++ src/db/unit_tests/dbNetlistExtractorTests.cc | 4 +-- src/drc/drc/built-in-macros/_drc_netter.rb | 2 +- testdata/drc/drcSimpleTests_12.drc | 2 +- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index 1d2cd5673..149555c20 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -23,7 +23,6 @@ #include "dbDeepRegion.h" #include "dbDeepShapeStore.h" -#include "dbEmptyRegion.h" #include "dbEmptyEdgePairs.h" #include "dbRegion.h" #include "dbRegionUtils.h" @@ -462,10 +461,13 @@ DeepRegion::and_with (const Region &other) const { const DeepRegion *other_deep = dynamic_cast (other.delegate ()); - if (empty () || other.empty ()) { + if (empty ()) { - // Nothing to do - return new EmptyRegion (); + return clone (); + + } else if (other.empty ()) { + + return other.delegate ()->clone (); } else if (! other_deep) { @@ -483,14 +485,8 @@ DeepRegion::not_with (const Region &other) const { const DeepRegion *other_deep = dynamic_cast (other.delegate ()); - if (empty ()) { + if (empty () || other.empty ()) { - // Nothing to do - return new EmptyRegion (); - - } else if (other.empty ()) { - - // Nothing to do return clone (); } else if (! other_deep) { @@ -1231,6 +1227,12 @@ DeepRegion::merged (bool min_coherence, unsigned int min_wc) const RegionDelegate * DeepRegion::sized (coord_type d, unsigned int mode) const { + if (empty ()) { + // Nothing to do - NOTE: don't return EmptyRegion because we want to + // maintain "deepness" + return clone (); + } + ensure_merged_polygons_valid (); db::Layout &layout = m_merged_polygons.layout (); @@ -1299,6 +1301,12 @@ struct XYAnisotropyAndMagnificationReducer RegionDelegate * DeepRegion::sized (coord_type dx, coord_type dy, unsigned int mode) const { + if (empty ()) { + // Nothing to do - NOTE: don't return EmptyRegion because we want to + // maintain "deepness" + return clone (); + } + if (dx == dy) { return sized (dx, mode); } diff --git a/src/db/db/dbRegion.cc b/src/db/db/dbRegion.cc index d362a7af9..6a5ace5e7 100644 --- a/src/db/db/dbRegion.cc +++ b/src/db/db/dbRegion.cc @@ -232,6 +232,13 @@ Region::Region (const RecursiveShapeIterator &si, DeepShapeStore &dss, const db: mp_delegate = new DeepRegion (si, dss, trans, merged_semantics, area_ratio, max_vertex_count); } +Region::Region (DeepShapeStore &dss) +{ + tl_assert (dss.is_singular ()); + unsigned int layout_index = 0; // singular layout index + mp_delegate = new db::DeepRegion (db::DeepLayer (&dss, layout_index, dss.layout (layout_index).insert_layer ())); +} + const db::RecursiveShapeIterator & Region::iter () const { diff --git a/src/db/db/dbRegion.h b/src/db/db/dbRegion.h index c2c940e21..1c6e5ff37 100644 --- a/src/db/db/dbRegion.h +++ b/src/db/db/dbRegion.h @@ -345,6 +345,12 @@ public: */ explicit Region (const RecursiveShapeIterator &si, DeepShapeStore &dss, const db::ICplxTrans &trans, bool merged_semantics = true, double area_ratio = 3.0, size_t max_vertex_count = 16); + /** + * @brief Creates a new empty layer inside the dss + * This method requires the DSS to be singular. + */ + explicit Region (DeepShapeStore &dss); + /** * @brief Gets the underlying delegate object */ diff --git a/src/db/unit_tests/dbNetlistExtractorTests.cc b/src/db/unit_tests/dbNetlistExtractorTests.cc index 9b822dc7d..7bc49b804 100644 --- a/src/db/unit_tests/dbNetlistExtractorTests.cc +++ b/src/db/unit_tests/dbNetlistExtractorTests.cc @@ -1136,7 +1136,7 @@ TEST(5_ResAndCapWithBulkExtraction) db::Region rmetal2_lbl (db::RecursiveShapeIterator (ly, tc, metal2_lbl), dss); db::Region rcap (db::RecursiveShapeIterator (ly, tc, cap), dss); db::Region rres (db::RecursiveShapeIterator (ly, tc, res), dss); - db::Region rbulk; + db::Region rbulk (dss); // derived regions @@ -1409,7 +1409,7 @@ TEST(6_BJT3TransistorExtraction) db::Region rmetal2_lbl (db::RecursiveShapeIterator (ly, tc, metal2_lbl), dss); db::Region rpplus (db::RecursiveShapeIterator (ly, tc, pplus), dss); db::Region rnplus (db::RecursiveShapeIterator (ly, tc, nplus), dss); - db::Region rbulk; + db::Region rbulk (dss); // derived regions diff --git a/src/drc/drc/built-in-macros/_drc_netter.rb b/src/drc/drc/built-in-macros/_drc_netter.rb index a36564f25..9bc3da681 100644 --- a/src/drc/drc/built-in-macros/_drc_netter.rb +++ b/src/drc/drc/built-in-macros/_drc_netter.rb @@ -400,7 +400,7 @@ module DRC id = data.data_id - if @layers[id] + if @layers && @layers[id] # already registered return end diff --git a/testdata/drc/drcSimpleTests_12.drc b/testdata/drc/drcSimpleTests_12.drc index 0792169a5..ed7b9c996 100644 --- a/testdata/drc/drcSimpleTests_12.drc +++ b/testdata/drc/drcSimpleTests_12.drc @@ -54,7 +54,7 @@ connect(metal2, metal2_lbl) # Actually performs the extraction -join_nets("{VDDZ,VSSZ,NEXT,FB}") +connect_implicit("{VDDZ,VSSZ,NEXT,FB}") netlist = l2n_data.netlist