WIP: added some convenience methods.

This commit is contained in:
Matthias Koefferlein 2018-12-26 00:39:34 +01:00
parent ec65d293e3
commit f342bdd83a
2 changed files with 84 additions and 2 deletions

View File

@ -21,9 +21,10 @@
*/
#include "dbNetlistDeviceExtractor.h"
#include "dbHierNetworkProcessor.h"
#include "dbNetlistProperty.h"
#include "dbRegion.h"
#include "dbHierNetworkProcessor.h"
#include "dbDeepRegion.h"
namespace db
{
@ -55,6 +56,47 @@ static void insert_into_region (const db::PolygonRef &s, const db::ICplxTrans &t
region.insert (s.obj ().transformed (tr * db::ICplxTrans (s.trans ())));
}
void NetlistDeviceExtractor::extract (const std::vector<db::Region *> regions)
{
tl_assert (! regions.empty ());
const db::Layout *layout = 0;
const db::Cell *cell = 0;
std::vector<unsigned int> layers;
layers.reserve (regions.size ());
for (std::vector<db::Region *>::const_iterator r = regions.begin (); r != regions.end (); ++r) {
// TODO: this is clumsy ...
db::DeepRegion *dr = dynamic_cast<db::DeepRegion *> ((*r)->delegate ());
tl_assert (dr != 0);
db::DeepLayer dl = dr->deep_layer ();
tl_assert (dl.layout () != 0);
tl_assert (dl.initial_cell () != 0);
if (! layout) {
layout = dl.layout ();
} else {
tl_assert (layout == dl.layout ());
}
if (! cell) {
cell = dl.initial_cell ();
} else {
tl_assert (cell == dl.initial_cell ());
}
layers.push_back (dl.layer ());
}
// NOTE: the const_cast's are there because the extraction will annotate the layout with port
// shapes. That's not part of the initial design, where the underlying deep shape store is
// immutable from the outside. But we know what we're doing.
extract (const_cast<db::Layout &> (*layout), const_cast<db::Cell &> (*cell), layers);
}
void NetlistDeviceExtractor::extract (db::Layout &layout, db::Cell &cell, const std::vector<unsigned int> &layers)
{
typedef db::PolygonRef shape_type;

View File

@ -25,8 +25,8 @@
#include "dbCommon.h"
#include "dbNetlist.h"
#include "dbHierNetworkProcessor.h"
#include "dbLayout.h"
#include "dbHierNetworkProcessor.h"
#include "gsiObject.h"
@ -81,6 +81,19 @@ public:
*/
void extract (Layout &layout, Cell &cell, const std::vector<unsigned int> &layers);
/**
* @brief Extracts the devices from a list of regions
*
* This method behaves identical to the other "extract" method, but accepts
* regions for input.
*
* As a requirement, the layout and initial cell of all of the regions
* has to be identical.
*
* Currently, the regions have to be deep regions.
*/
void extract (const std::vector<db::Region *> regions);
/**
* @brief Creates the device classes
* At least one device class needs to be defined. Use "register_device_class" to register
@ -148,6 +161,33 @@ protected:
return mp_layout->dbu ();
}
/**
* @brief Gets the layout the shapes are taken from
* NOTE: this method is provided for testing purposes mainly.
*/
db::Layout *layout ()
{
return mp_layout;
}
/**
* @brief Gets the layout the shapes are taken from (const version)
* NOTE: this method is provided for testing purposes mainly.
*/
const db::Layout *layout () const
{
return mp_layout;
}
/**
* @brief Gets the cell index of the current cell
* NOTE: this method is provided for testing purposes mainly.
*/
db::cell_index_type cell_index () const
{
return m_cell_index;
}
private:
tl::weak_ptr<db::Netlist> m_netlist;
db::Layout *mp_layout;