Enhancing 'blend-mode' 0 (buddy tools) such that it will not generate instance duplicates

This commit is contained in:
Matthias Koefferlein 2024-05-29 22:36:33 +02:00
parent 1677111735
commit 149c972172
4 changed files with 26 additions and 4 deletions

View File

@ -197,10 +197,13 @@ GenericReaderOptions::add_options (tl::CommandLineOptions &cmd)
"--" + m_long_prefix + "blend-mode=mode", &m_cell_conflict_resolution, "Specifies how cell conflicts are resolved when using file concatenation",
"When concatenating files with '+', the reader will handle cells with identical names according to this mode:\n"
"\n"
"* 0: joins everything (unsafe)\n"
"* 0: joins everything (usually unsafe)\n"
"* 1: overwrite\n"
"* 2: skip new cell\n"
"* 3: rename cell (safe, default)"
"* 3: rename cell (safe, default)\n"
"\n"
"Mode 0 is a safe solution for the 'same hierarchy, different layers' case. Mode 3 is a safe solution for "
"joining multiple files into one and combining the hierarchy tree of all files as distinct separate trees.\n"
)
;
}

View File

@ -245,10 +245,16 @@ CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cel
db::Cell &target_cell = layout.cell (target_cell_index);
target_cell.set_ghost_cell (src_cell.is_ghost_cell () && target_cell.is_ghost_cell ());
// avoid generating duplicates
std::set<db::Instance, db::InstanceCompareFunction> current;
for (db::Cell::const_iterator i = target_cell.begin (); ! i.at_end (); ++i) {
current.insert (*i);
}
// copy over the instances
for (db::Cell::const_iterator i = src_cell.begin (); ! i.at_end (); ++i) {
// NOTE: cell indexed may be invalid because we delete subcells without update()
if (layout.is_valid_cell_index (i->cell_index ())) {
if (layout.is_valid_cell_index (i->cell_index ()) && current.find (*i) == current.end ()) {
target_cell.insert (*i);
}
}

View File

@ -1977,7 +1977,20 @@ OverlappingInstanceIteratorTraits::instance_from_stable_iter (const Iter &iter)
// box tree iterators deliver pointers, not iterators. Use instance_from_pointer to do this conversion.
return mp_insts->instance_from_pointer (&*iter);
}
/**
* @brief A compare function for db::Instance that uses "less" for value compare
*
* In contrast, "operator<" will compare the instance reference, not value.
*/
struct InstanceCompareFunction
{
bool operator() (const db::Instance &a, const db::Instance &b) const
{
return a.less (b);
}
};
}
#endif

Binary file not shown.