diff --git a/src/db/db/dbCommonReader.cc b/src/db/db/dbCommonReader.cc index 172a56213..e74b7a105 100644 --- a/src/db/db/dbCommonReader.cc +++ b/src/db/db/dbCommonReader.cc @@ -239,6 +239,7 @@ CommonReader::merge_cell (db::Layout &layout, db::cell_index_type target_cell_in { const db::Cell &src_cell = layout.cell (src_cell_index); db::Cell &target_cell = layout.cell (target_cell_index); + target_cell.set_ghost_cell (src_cell.is_ghost_cell () && target_cell.is_ghost_cell ()); // copy over the instances for (db::Cell::const_iterator i = src_cell.begin (); ! i.at_end (); ++i) { @@ -347,7 +348,7 @@ CommonReader::finish (db::Layout &layout) // no conflict - plain rename - for (std::map >::const_iterator i = m_name_map.begin (); i != m_name_map.end () && ! has_conflict; ++i) { + for (std::map >::const_iterator i = m_name_map.begin (); i != m_name_map.end (); ++i) { layout.rename_cell (i->second.second, i->first.c_str ()); } @@ -379,7 +380,8 @@ CommonReader::finish (db::Layout &layout) db::cell_index_type ci_org = c2n.second; // NOTE: proxy cells are never resolved. "RenameCell" is a plain and simple case. - if (c2n.first && m_cc_resolution != RenameCell && ! layout.cell (ci_org).is_proxy ()) { + // Ghost cells are merged rendering the new cell a non-ghost cell. + if (c2n.first && (m_cc_resolution != RenameCell || layout.cell (ci_org).is_ghost_cell () || layout.cell (ci_new).is_ghost_cell ()) && ! layout.cell (ci_org).is_proxy ()) { cells_with_conflict.push_back (std::make_pair (ci_new, ci_org)); } else { layout.rename_cell (ci_new, layout.uniquify_cell_name (i->second.c_str ()).c_str ()); diff --git a/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc b/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc index 757192281..6447871f6 100644 --- a/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc +++ b/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc @@ -541,6 +541,78 @@ TEST(4_CollectModeRename) db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); } +TEST(4_CollectModeRenameWithGhost) +{ + db::Manager m (false); + db::Layout layout (&m); + + db::LoadLayoutOptions options; + options.get_options ().cell_conflict_resolution = db::RenameCell; + + { + tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic_ag.gds"); + db::Reader reader (file); + reader.read (layout, options); + } + + { + tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic_b.gds"); + db::Reader reader (file); + reader.read (layout, options); + } + + std::string fn_au (tl::testsrc () + "/testdata/gds/collect_rename_au2.gds"); + db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); +} + +TEST(4_CollectModeRenameWithGhostReverse) +{ + db::Manager m (false); + db::Layout layout (&m); + + db::LoadLayoutOptions options; + options.get_options ().cell_conflict_resolution = db::RenameCell; + + { + tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic_a.gds"); + db::Reader reader (file); + reader.read (layout, options); + } + + { + tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic_bg.gds"); + db::Reader reader (file); + reader.read (layout, options); + } + + std::string fn_au (tl::testsrc () + "/testdata/gds/collect_rename_au3.gds"); + db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); +} + +TEST(4_CollectModeRenameWithGhostBoth) +{ + db::Manager m (false); + db::Layout layout (&m); + + db::LoadLayoutOptions options; + options.get_options ().cell_conflict_resolution = db::RenameCell; + + { + tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic_ag.gds"); + db::Reader reader (file); + reader.read (layout, options); + } + + { + tl::InputStream file (tl::testsrc () + "/testdata/gds/collect_basic_bg.gds"); + db::Reader reader (file); + reader.read (layout, options); + } + + std::string fn_au (tl::testsrc () + "/testdata/gds/collect_rename_au4.gds"); + db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); +} + TEST(4_CollectModeOverwrite) { db::Manager m (false); diff --git a/testdata/gds/collect_basic_a.gds b/testdata/gds/collect_basic_a.gds new file mode 100644 index 000000000..d8fe0f2d7 Binary files /dev/null and b/testdata/gds/collect_basic_a.gds differ diff --git a/testdata/gds/collect_basic_ag.gds b/testdata/gds/collect_basic_ag.gds new file mode 100644 index 000000000..5b0a6ba07 Binary files /dev/null and b/testdata/gds/collect_basic_ag.gds differ diff --git a/testdata/gds/collect_basic_b.gds b/testdata/gds/collect_basic_b.gds new file mode 100644 index 000000000..e9eb3e975 Binary files /dev/null and b/testdata/gds/collect_basic_b.gds differ diff --git a/testdata/gds/collect_basic_bg.gds b/testdata/gds/collect_basic_bg.gds new file mode 100644 index 000000000..792c63f91 Binary files /dev/null and b/testdata/gds/collect_basic_bg.gds differ diff --git a/testdata/gds/collect_rename_au2.gds b/testdata/gds/collect_rename_au2.gds new file mode 100644 index 000000000..6b48a1f4a Binary files /dev/null and b/testdata/gds/collect_rename_au2.gds differ diff --git a/testdata/gds/collect_rename_au3.gds b/testdata/gds/collect_rename_au3.gds new file mode 100644 index 000000000..c4b6cda40 Binary files /dev/null and b/testdata/gds/collect_rename_au3.gds differ diff --git a/testdata/gds/collect_rename_au4.gds b/testdata/gds/collect_rename_au4.gds new file mode 100644 index 000000000..5e7dd2dc7 Binary files /dev/null and b/testdata/gds/collect_rename_au4.gds differ