From 33e2fb8dc174cfa59e46a827acd87876ea638af3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 25 Dec 2018 02:17:41 +0100 Subject: [PATCH] WIP: refinement of device extraction algorithm --- src/db/db/dbNetlistDeviceExtractor.cc | 34 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/db/db/dbNetlistDeviceExtractor.cc b/src/db/db/dbNetlistDeviceExtractor.cc index 8e5b30908..686fa52f3 100644 --- a/src/db/db/dbNetlistDeviceExtractor.cc +++ b/src/db/db/dbNetlistDeviceExtractor.cc @@ -46,6 +46,7 @@ void NetlistDeviceExtractor::initialize (db::Netlist *nl) m_device_name_index = 0; m_propname_id = 0; m_netlist.reset (nl); + create_device_classes (); } @@ -60,32 +61,54 @@ void NetlistDeviceExtractor::extract (db::Layout &layout, db::Cell &cell, const db::ShapeIterator::flags_type shape_iter_flags = db::ShapeIterator::Polygons; mp_layout = &layout; + // port properties are kept in property index 0 m_propname_id = mp_layout->properties_repository ().prop_name_id (tl::Variant (int (0))); tl_assert (m_netlist.get () != 0); + // build a cell-id-to-circuit lookup table + std::map circuits_by_cell; + for (db::Netlist::circuit_iterator c = m_netlist->begin_circuits (); c != m_netlist->end_circuits (); ++c) { + circuits_by_cell.insert (std::make_pair (c->cell_index (), c.operator-> ())); + } + + // collect the cells below the top cell std::set called_cells; called_cells.insert (cell.cell_index ()); cell.collect_called_cells (called_cells); + // build the device clusters db::Connectivity device_conn = get_connectivity (layout, layers); - db::hier_clusters device_clusters; device_clusters.build (layout, cell, shape_iter_flags, device_conn); + // for each cell investigate the clusters for (std::set::const_iterator ci = called_cells.begin (); ci != called_cells.end (); ++ci) { m_cell_index = *ci; - mp_circuit = new db::Circuit (); - mp_circuit->set_cell_index (*ci); - mp_circuit->set_name (layout.cell_name (*ci)); - m_netlist->add_circuit (mp_circuit); + std::map::const_iterator c2c = circuits_by_cell.find (*ci); + if (c2c != circuits_by_cell.end ()) { + // reuse existing circuit + mp_circuit = c2c->second; + + } else { + + // create a new circuit for this cell + mp_circuit = new db::Circuit (); + mp_circuit->set_cell_index (*ci); + mp_circuit->set_name (layout.cell_name (*ci)); + m_netlist->add_circuit (mp_circuit); + + } + + // investigate each cluster db::connected_clusters cc = device_clusters.clusters_per_cell (*ci); for (db::connected_clusters::all_iterator c = cc.begin_all (); !c.at_end(); ++c) { + // take only root clusters - others have upward connections and are not "whole" if (! cc.is_root (*c)) { continue; } @@ -102,6 +125,7 @@ void NetlistDeviceExtractor::extract (db::Layout &layout, db::Cell &cell, const } } + // do the actual device extraction extract_devices (layer_geometry); }